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