feat(facade): add ListWrapper.toJSON method

This commit is contained in:
Brian Ford 2015-06-30 13:19:20 -07:00
parent b3fc357a15
commit 2335075506
2 changed files with 9 additions and 0 deletions

View File

@ -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) {

View File

@ -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 {