Comparing version 0.2.7 to 0.2.8
74
jymin.js
/** | ||
* _ _ ___ ____ _____ | ||
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ \ |___ | | ||
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | __) | / / | ||
* | |_| | |_| | | | | | | | | | | \ V /| |_| | / __/ _ / / | ||
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)_____(_)_/ | ||
* _ _ ___ ____ ___ | ||
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ \ ( _ ) | ||
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | __) | / _ \ | ||
* | |_| | |_| | | | | | | | | | | \ V /| |_| | / __/ | (_) | | ||
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)_____(_)___/ | ||
* |___/ | ||
@@ -33,3 +33,3 @@ * | ||
this.jymin = {version: '0.2.7'}; | ||
this.jymin = {version: '0.2.8'}; | ||
@@ -137,2 +137,19 @@ /** | ||
/** | ||
* Iterate over an array, and call a callback with (index, value), as in jQuery.each | ||
*/ | ||
var each = function ( | ||
array, // Array: The array to iterate over. | ||
callback // Function: The function to call on each item. `callback(item, index, array)` | ||
) { | ||
if (array) { | ||
for (var index = 0, length = getLength(array); index < length; index++) { | ||
var result = callback(index, array[index], array); | ||
if (result === false) { | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Iterate over an object's keys, and call a function on each key value pair. | ||
@@ -155,2 +172,19 @@ */ | ||
/** | ||
* Iterate over an object's keys, and call a function on each (value, key) pair. | ||
*/ | ||
var forOf = function ( | ||
object, // Object*: The object to iterate over. | ||
callback // Function*: The function to call on each pair. `callback(value, key, object)` | ||
) { | ||
if (object) { | ||
for (var key in object) { | ||
var result = callback(object[key], key, object); | ||
if (result === false) { | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Decorate an object with properties from another object. If the properties | ||
@@ -1336,3 +1370,3 @@ */ | ||
*/ | ||
var stringify = function (data, stack, strict) { | ||
var stringify = function (data, strict, stack) { | ||
var reserved = /^(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with)$/; | ||
@@ -1344,3 +1378,3 @@ if (data === null) { | ||
if (strict) { | ||
data = '[Function]'; | ||
data = '-1'; | ||
} | ||
@@ -1377,3 +1411,3 @@ else { | ||
forEach(data, function (value) { | ||
push(parts, stringify(value, stack, strict)); | ||
push(parts, stringify(value, strict, stack)); | ||
}); | ||
@@ -1388,3 +1422,3 @@ } | ||
} | ||
push(parts, key + ':' + stringify(value, stack, strict)); | ||
push(parts, key + ':' + stringify(value, strict, stack)); | ||
}); | ||
@@ -1501,3 +1535,3 @@ } | ||
*/ | ||
var onReady = window.onReady = function ( | ||
var onReady = window._ON_READY = function ( | ||
callback | ||
@@ -1511,7 +1545,17 @@ ) { | ||
// The first item in the queue causes onReady to be triggered. | ||
// The 1st callback makes schedules onReady, if not waiting for scripts. | ||
if (!getLength(queue)) { | ||
setTimeout(function () { | ||
onReady(); | ||
}, 1); | ||
// In production, there should be a single script, therefore no wait. | ||
var waitingForScripts = false; | ||
// In development, individual scripts might still be loading. | ||
//+env:dev,debug | ||
waitingForScripts = window._WAITING_FOR_SCRIPTS; | ||
//-env:dev,debug | ||
if (!waitingForScripts) { | ||
// At the next tick, we've excuted this whole script. | ||
addTimeout(onReady, onReady, 1); | ||
} | ||
} | ||
@@ -1518,0 +1562,0 @@ |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"main": "chug/chug.js", | ||
@@ -18,0 +18,0 @@ "homepage": "http://lighter.io/jymin", |
@@ -19,2 +19,19 @@ /** | ||
/** | ||
* Iterate over an array, and call a callback with (index, value), as in jQuery.each | ||
*/ | ||
var each = function ( | ||
array, // Array: The array to iterate over. | ||
callback // Function: The function to call on each item. `callback(item, index, array)` | ||
) { | ||
if (array) { | ||
for (var index = 0, length = getLength(array); index < length; index++) { | ||
var result = callback(index, array[index], array); | ||
if (result === false) { | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Iterate over an object's keys, and call a function on each key value pair. | ||
@@ -37,2 +54,19 @@ */ | ||
/** | ||
* Iterate over an object's keys, and call a function on each (value, key) pair. | ||
*/ | ||
var forOf = function ( | ||
object, // Object*: The object to iterate over. | ||
callback // Function*: The function to call on each pair. `callback(value, key, object)` | ||
) { | ||
if (object) { | ||
for (var key in object) { | ||
var result = callback(object[key], key, object); | ||
if (result === false) { | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Decorate an object with properties from another object. If the properties | ||
@@ -39,0 +73,0 @@ */ |
/** | ||
* Create JSON that doesn't necessarily have to be strict. | ||
*/ | ||
var stringify = function (data, stack, strict) { | ||
var stringify = function (data, strict, stack) { | ||
var reserved = /^(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with)$/; | ||
@@ -11,3 +11,3 @@ if (data === null) { | ||
if (strict) { | ||
data = '[Function]'; | ||
data = '-1'; | ||
} | ||
@@ -44,3 +44,3 @@ else { | ||
forEach(data, function (value) { | ||
push(parts, stringify(value, stack, strict)); | ||
push(parts, stringify(value, strict, stack)); | ||
}); | ||
@@ -55,3 +55,3 @@ } | ||
} | ||
push(parts, key + ':' + stringify(value, stack, strict)); | ||
push(parts, key + ':' + stringify(value, strict, stack)); | ||
}); | ||
@@ -58,0 +58,0 @@ } |
/** | ||
* Execute a callback when the page loads. | ||
*/ | ||
var onReady = window.onReady = function ( | ||
var onReady = window._ON_READY = function ( | ||
callback | ||
@@ -13,7 +13,17 @@ ) { | ||
// The first item in the queue causes onReady to be triggered. | ||
// The 1st callback makes schedules onReady, if not waiting for scripts. | ||
if (!getLength(queue)) { | ||
setTimeout(function () { | ||
onReady(); | ||
}, 1); | ||
// In production, there should be a single script, therefore no wait. | ||
var waitingForScripts = false; | ||
// In development, individual scripts might still be loading. | ||
//+env:dev,debug | ||
waitingForScripts = window._WAITING_FOR_SCRIPTS; | ||
//-env:dev,debug | ||
if (!waitingForScripts) { | ||
// At the next tick, we've excuted this whole script. | ||
addTimeout(onReady, onReady, 1); | ||
} | ||
} | ||
@@ -20,0 +30,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98004
3626