Fix the error msg
This commit is contained in:
parent
1833352238
commit
27f4c1b7b4
13
lib/list.js
13
lib/list.js
|
@ -13,7 +13,7 @@ function List(items, itemType, parent) {
|
|||
try {
|
||||
items = JSON.parse(items);
|
||||
} catch (e) {
|
||||
throw new Error('could not create List from JSON string: ', items);
|
||||
throw new Error(util.format('could not create List from JSON string: %j', items));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ function List(items, itemType, parent) {
|
|||
|
||||
items = items || [];
|
||||
if (!Array.isArray(items)) {
|
||||
throw new Error('Items must be an array: ' + items);
|
||||
throw new Error(util.format('Items must be an array: %j', items));
|
||||
}
|
||||
|
||||
if(!itemType) {
|
||||
|
@ -92,12 +92,3 @@ List.prototype.toString = function () {
|
|||
return JSON.stringify(this.toJSON());
|
||||
};
|
||||
|
||||
/*
|
||||
var strArray = new List(['1', 2], String);
|
||||
strArray.push(3);
|
||||
console.log(strArray);
|
||||
console.log(strArray.length);
|
||||
|
||||
console.log(strArray.toJSON());
|
||||
console.log(strArray.toString());
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue