Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
var TOKEN_NULL = -3;
var TOKEN_EMPTY_STRING = -4;
var TOKEN_UNDEFINED = -5;

var isArray = Array.isArray;
if (typeof isArray !== "function") {
isArray = function(item) {
if (!item || typeof item !== "object") {
return false;
}
else if (item instanceof Array) {
return true;
}
return Object.prototype.toString.call(item) === '[object Array]';
}
}

var pack = function(json, options) {

Expand Down Expand Up @@ -61,7 +74,7 @@
}

// Case 1: The item is Array Object
if ( item instanceof Array) {
if (isArray(item)) {

// Create a new sub-AST of type Array (@)
var ast = ['@'];
Expand Down