feat(facade): add ListWrapper.toJSON method
This commit is contained in:
parent
b3fc357a15
commit
2335075506
|
@ -1,9 +1,12 @@
|
|||
library facade.collection;
|
||||
|
||||
import 'dart:collection' show IterableBase, Iterator;
|
||||
import 'dart:convert' show JsonEncoder;
|
||||
export 'dart:core' show Map, List, Set;
|
||||
import 'dart:math' show max, min;
|
||||
|
||||
var jsonEncoder = new JsonEncoder();
|
||||
|
||||
class MapIterator extends Iterator<List> {
|
||||
final Iterator _iterator;
|
||||
final Map _map;
|
||||
|
@ -170,6 +173,10 @@ class ListWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
static String toJSON(List l) {
|
||||
return jsonEncoder.convert(l);
|
||||
}
|
||||
|
||||
// JS splice, slice, fill functions can take start < 0 which indicates a position relative to
|
||||
// the end of the list
|
||||
static int _startOffset(List l, int start) {
|
||||
|
|
|
@ -238,6 +238,8 @@ export class ListWrapper {
|
|||
}
|
||||
}
|
||||
static toString<T>(l: List<T>): string { return l.toString(); }
|
||||
static toJSON<T>(l: List<T>): string { return JSON.stringify(l); }
|
||||
|
||||
}
|
||||
|
||||
export function isListLikeIterable(obj): boolean {
|
||||
|
|
Loading…
Reference in New Issue