Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sugar

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sugar - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

.travis.yml

13

CAUTION.md

@@ -13,2 +13,15 @@ ## Caution!

v1.2.5+
=======
- Level: Major
- `String#truncate` arguments changed. `ellipsis` (`"..."` by default) is now the last argument of four. Second argument is now `split` which is true by default, so the method will behave like standard truncate methods by default. `from` added as the third parameter and determines where to truncate. Can be `"right"` (default), `"left"`, or `"middle"`.
- Level: Major
- `Function#debounce` no longer has an argument `wait`. Equivalent function is now `Function#throttle` (no arguments). `fn.debounce(100, false)` is now `fn.throttle(100)`.
- Level: Minor
- `Object.isObject` now returns `true` for extended objects.
v1.2.4+

@@ -15,0 +28,0 @@ =======

@@ -0,1 +1,15 @@

v1.2.5
======
### API Changes ###
- String#truncate refactored to split words by default (standard behavior) allow splitting in various positions, and changing argument order.
- Object.isObject should be true for extended objects as well.
- Function#throttle added to take the place of Function#debounce with `false` as the `wait` parameter.
- Date parsing support for hour/minute/second fractions (now take the place of milliseconds).
- Date parsing support now sees commas in decimals.
- Date parsing support for .NET dates.
v1.2.4

@@ -2,0 +16,0 @@ ======

2

lib/main.js
if(typeof window === 'undefined') {
require('./core');
require('./dates');
require('./inflections');
}

7

package.json
{
"name": "sugar",
"version": "1.2.4",
"version": "1.2.5",
"description": "A Javascript library for working with native objects.",

@@ -9,6 +9,7 @@ "keywords": ["functional", "utility", "ender"],

"main": "./lib/main",
"ender": "./release/1.2.4/development/sugar-1.2.4.development.js",
"ender": "./release/1.2.5/development/sugar-1.2.5.development.js",
"directories" : {"lib" : "./lib"},
"repository" : {"type" : "git", "url": "https://github.com/andrewplummer/Sugar.git"},
"engines" : {"node" : ">= 0.4.0"}
"engines" : {"node" : ">= 0.4.0"},
"scripts": {"test": "./unit_tests/node.sh"}
}
Sugar
=====
[![Build Status](https://secure.travis-ci.org/spaghetticode/Sugar.png)](http://travis-ci.org/spaghetticode/Sugar)
A Javascript library for working with native objects.

@@ -31,3 +33,3 @@ http://sugarjs.com/

Unit tests can be run through the shell script at `./unit_tests/node.sh`.
Unit tests can be run through the shell script at `./unit_tests/node.sh`

@@ -34,0 +36,0 @@

environment = 'node';
require(process.env.SUGAR_CORE || '../../../lib/core.js');
require(process.env.SUGAR_DATES || '../../../lib/dates.js');
require(process.env.SUGAR_DATES || '../../../lib/inflections.js');
var Sugar = require('../../../lib/main');

@@ -8,0 +6,0 @@ // Test suite

@@ -181,2 +181,5 @@ test('Function', function () {

// Function#throttle
async(function(){

@@ -187,3 +190,3 @@ var fn, ret, counter = 0, expected = [['3p0', 1],['luke', 6]];

counter++;
}).debounce(50, false);
}).throttle(50);

@@ -211,3 +214,2 @@ fn.call('3p0', 1);

// Function#after

@@ -214,0 +216,0 @@

@@ -11,2 +11,3 @@ test('Object', function () {

equal(Object.isObject({}), true, 'Object.isObject | {}');
equal(Object.isObject(Object.extended()), true, 'Object.isObject | extended object');
equal(Object.isObject(new Object({})), true, 'Object.isObject | new Object()');

@@ -13,0 +14,0 @@ equal(Object.isObject([]), false, 'Object.isObject | []');

@@ -1,3 +0,3 @@

// Underscore.js 1.2.1
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore.js 1.3.3
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.

@@ -51,5 +51,6 @@ // Portions of Underscore are inspired or borrowed from Prototype,

// Export the Underscore object for **Node.js** and **"CommonJS"**, with
// backwards-compatibility for the old `require()` API. If we're not in
// CommonJS, add `_` to the global object.
// Export the Underscore object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `_` as a global object via a string identifier,
// for Closure Compiler "advanced" mode.
if (typeof exports !== 'undefined') {

@@ -60,9 +61,3 @@ if (typeof module !== 'undefined' && module.exports) {

exports._ = _;
} else if (typeof define === 'function' && define.amd) {
// Register as a named module with AMD.
define('underscore', function() {
return _;
});
} else {
// Exported as a string, for Closure Compiler "advanced" mode.
root['_'] = _;

@@ -72,3 +67,3 @@ }

// Current version.
_.VERSION = '1.2.1';
_.VERSION = '1.3.3';

@@ -91,3 +86,3 @@ // Collection Functions

for (var key in obj) {
if (hasOwnProperty.call(obj, key)) {
if (_.has(obj, key)) {
if (iterator.call(context, obj[key], key, obj) === breaker) return;

@@ -101,3 +96,3 @@ }

// Delegates to **ECMAScript 5**'s native `map` if available.
_.map = function(obj, iterator, context) {
_.map = _.collect = function(obj, iterator, context) {
var results = [];

@@ -109,2 +104,3 @@ if (obj == null) return results;

});
if (obj.length === +obj.length) results.length = obj.length;
return results;

@@ -116,3 +112,3 @@ };

_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
var initial = memo !== void 0;
var initial = arguments.length > 2;
if (obj == null) obj = [];

@@ -131,3 +127,3 @@ if (nativeReduce && obj.reduce === nativeReduce) {

});
if (!initial) throw new TypeError("Reduce of empty array with no initial value");
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
return memo;

@@ -139,9 +135,11 @@ };

_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
return memo !== void 0 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
}
var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
return _.reduce(reversed, iterator, memo, context);
var reversed = _.toArray(obj).reverse();
if (context && !initial) iterator = _.bind(iterator, context);
return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
};

@@ -194,3 +192,3 @@

});
return result;
return !!result;
};

@@ -202,3 +200,3 @@

var any = _.some = _.any = function(obj, iterator, context) {
iterator = iterator || _.identity;
iterator || (iterator = _.identity);
var result = false;

@@ -208,3 +206,3 @@ if (obj == null) return result;

each(obj, function(value, index, list) {
if (result |= iterator.call(context, value, index, list)) return breaker;
if (result || (result = iterator.call(context, value, index, list))) return breaker;
});

@@ -221,3 +219,3 @@ return !!result;

found = any(obj, function(value) {
if (value === target) return true;
return value === target;
});

@@ -231,3 +229,3 @@ return found;

return _.map(obj, function(value) {
return (method.call ? method || value : value[method]).apply(value, args);
return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
});

@@ -243,3 +241,3 @@ };

_.max = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.max.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return -Infinity;

@@ -256,3 +254,3 @@ var result = {computed : -Infinity};

_.min = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.min.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return Infinity;

@@ -271,9 +269,5 @@ var result = {computed : Infinity};

each(obj, function(value, index, list) {
if (index == 0) {
shuffled[0] = value;
} else {
rand = Math.floor(Math.random() * (index + 1));
shuffled[index] = shuffled[rand];
shuffled[rand] = value;
}
rand = Math.floor(Math.random() * (index + 1));
shuffled[index] = shuffled[rand];
shuffled[rand] = value;
});

@@ -284,3 +278,4 @@ return shuffled;

// Sort the object's values by a criterion produced by an iterator.
_.sortBy = function(obj, iterator, context) {
_.sortBy = function(obj, val, context) {
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
return _.pluck(_.map(obj, function(value, index, list) {

@@ -293,2 +288,4 @@ return {

var a = left.criteria, b = right.criteria;
if (a === void 0) return 1;
if (b === void 0) return -1;
return a < b ? -1 : a > b ? 1 : 0;

@@ -323,8 +320,8 @@ }), 'value');

// Safely convert anything iterable into a real, live array.
_.toArray = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
if (_.isArray(iterable)) return slice.call(iterable);
if (_.isArguments(iterable)) return slice.call(iterable);
return _.values(iterable);
_.toArray = function(obj) {
if (!obj) return [];
if (_.isArray(obj)) return slice.call(obj);
if (_.isArguments(obj)) return slice.call(obj);
if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
return _.values(obj);
};

@@ -334,3 +331,3 @@

_.size = function(obj) {
return _.toArray(obj).length;
return _.isArray(obj) ? obj.length : _.keys(obj).length;
};

@@ -342,5 +339,5 @@

// Get the first element of an array. Passing **n** will return the first N
// values in the array. Aliased as `head`. The **guard** check allows it to work
// with `_.map`.
_.first = _.head = function(array, n, guard) {
// values in the array. Aliased as `head` and `take`. The **guard** check
// allows it to work with `_.map`.
_.first = _.head = _.take = function(array, n, guard) {
return (n != null) && !guard ? slice.call(array, 0, n) : array[0];

@@ -360,3 +357,7 @@ };

_.last = function(array, n, guard) {
return (n != null) && !guard ? slice.call(array, array.length - n) : array[array.length - 1];
if ((n != null) && !guard) {
return slice.call(array, Math.max(array.length - n, 0));
} else {
return array[array.length - 1];
}
};

@@ -396,11 +397,13 @@

var initial = iterator ? _.map(array, iterator) : array;
var result = [];
_.reduce(initial, function(memo, el, i) {
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) {
memo[memo.length] = el;
result[result.length] = array[i];
var results = [];
// The `isSorted` flag is irrelevant if the array only contains two elements.
if (array.length < 3) isSorted = true;
_.reduce(initial, function (memo, value, index) {
if (isSorted ? _.last(memo) !== value || !memo.length : !_.include(memo, value)) {
memo.push(value);
results.push(array[index]);
}
return memo;
}, []);
return result;
return results;
};

@@ -425,6 +428,7 @@

// Take the difference between one array and another.
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_.difference = function(array, other) {
return _.filter(array, function(value){ return !_.include(other, value); });
_.difference = function(array) {
var rest = _.flatten(slice.call(arguments, 1), true);
return _.filter(array, function(value){ return !_.include(rest, value); });
};

@@ -456,3 +460,3 @@

if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
for (i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;
for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
return -1;

@@ -466,3 +470,3 @@ };

var i = array.length;
while (i--) if (array[i] === item) return i;
while (i--) if (i in array && array[i] === item) return i;
return -1;

@@ -533,3 +537,3 @@ };

var key = hasher.apply(this, arguments);
return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
};

@@ -542,3 +546,3 @@ };

var args = slice.call(arguments, 2);
return setTimeout(function(){ return func.apply(func, args); }, wait);
return setTimeout(function(){ return func.apply(null, args); }, wait);
};

@@ -555,15 +559,20 @@

_.throttle = function(func, wait) {
var timeout, context, args, throttling, finishThrottle;
finishThrottle = _.debounce(function(){ throttling = false; }, wait);
var context, args, timeout, throttling, more, result;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var throttler = function() {
var later = function() {
timeout = null;
func.apply(context, args);
finishThrottle();
if (more) func.apply(context, args);
whenDone();
};
if (!timeout) timeout = setTimeout(throttler, wait);
if (!throttling) func.apply(context, args);
if (finishThrottle) finishThrottle();
if (!timeout) timeout = setTimeout(later, wait);
if (throttling) {
more = true;
} else {
result = func.apply(context, args);
}
whenDone();
throttling = true;
return result;
};

@@ -574,13 +583,15 @@ };

// be triggered. The function will be called after it stops being called for
// N milliseconds.
_.debounce = function(func, wait) {
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
_.debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var throttler = function() {
var later = function() {
timeout = null;
func.apply(context, args);
if (!immediate) func.apply(context, args);
};
if (immediate && !timeout) func.apply(context, args);
clearTimeout(timeout);
timeout = setTimeout(throttler, wait);
timeout = setTimeout(later, wait);
};

@@ -605,3 +616,3 @@ };

return function() {
var args = [func].concat(slice.call(arguments));
var args = [func].concat(slice.call(arguments, 0));
return wrapper.apply(this, args);

@@ -614,5 +625,5 @@ };

_.compose = function() {
var funcs = slice.call(arguments);
var funcs = arguments;
return function() {
var args = slice.call(arguments);
var args = arguments;
for (var i = funcs.length - 1; i >= 0; i--) {

@@ -627,2 +638,3 @@ args = [funcs[i].apply(this, args)];

_.after = function(times, func) {
if (times <= 0) return func();
return function() {

@@ -641,3 +653,3 @@ if (--times < 1) { return func.apply(this, arguments); }

var keys = [];
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
return keys;

@@ -665,3 +677,3 @@ };

for (var prop in source) {
if (source[prop] !== void 0) obj[prop] = source[prop];
obj[prop] = source[prop];
}

@@ -672,2 +684,11 @@ });

// Return a copy of the object only containing the whitelisted properties.
_.pick = function(obj) {
var result = {};
each(_.flatten(slice.call(arguments, 1)), function(key) {
if (key in obj) result[key] = obj[key];
});
return result;
};
// Fill in a given object with default properties.

@@ -703,3 +724,3 @@ _.defaults = function(obj) {

// A strict comparison is necessary because `null == undefined`.
if ((a == null) || (b == null)) return a === b;
if (a == null || b == null) return a === b;
// Unwrap any wrapped objects.

@@ -709,39 +730,31 @@ if (a._chain) a = a._wrapped;

// Invoke a custom `isEqual` method if one is provided.
if (_.isFunction(a.isEqual)) return a.isEqual(b);
if (_.isFunction(b.isEqual)) return b.isEqual(a);
// Compare object types.
var typeA = typeof a;
if (typeA != typeof b) return false;
// Optimization; ensure that both values are truthy or falsy.
if (!a != !b) return false;
// `NaN` values are equal.
if (_.isNaN(a)) return _.isNaN(b);
// Compare string objects by value.
var isStringA = _.isString(a), isStringB = _.isString(b);
if (isStringA || isStringB) return isStringA && isStringB && String(a) == String(b);
// Compare number objects by value.
var isNumberA = _.isNumber(a), isNumberB = _.isNumber(b);
if (isNumberA || isNumberB) return isNumberA && isNumberB && +a == +b;
// Compare boolean objects by value. The value of `true` is 1; the value of `false` is 0.
var isBooleanA = _.isBoolean(a), isBooleanB = _.isBoolean(b);
if (isBooleanA || isBooleanB) return isBooleanA && isBooleanB && +a == +b;
// Compare dates by their millisecond values.
var isDateA = _.isDate(a), isDateB = _.isDate(b);
if (isDateA || isDateB) return isDateA && isDateB && a.getTime() == b.getTime();
// Compare RegExps by their source patterns and flags.
var isRegExpA = _.isRegExp(a), isRegExpB = _.isRegExp(b);
if (isRegExpA || isRegExpB) {
// Ensure commutative equality for RegExps.
return isRegExpA && isRegExpB &&
a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className != toString.call(b)) return false;
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
// Ensure that both values are objects.
if (typeA != 'object') return false;
// Arrays or Arraylikes with different lengths are not equal.
if (a.length !== b.length) return false;
// Objects with different constructors are not equal.
if (a.constructor !== b.constructor) return false;
if (typeof a != 'object' || typeof b != 'object') return false;
// Assume equality for cyclic structures. The algorithm for detecting cyclic

@@ -758,17 +771,33 @@ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.

var size = 0, result = true;
// Deep compare objects.
for (var key in a) {
if (hasOwnProperty.call(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = hasOwnProperty.call(b, key) && eq(a[key], b[key], stack))) break;
// Recursively compare objects and arrays.
if (className == '[object Array]') {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
result = size == b.length;
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
// Ensure commutative equality for sparse arrays.
if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
}
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (hasOwnProperty.call(b, key) && !size--) break;
} else {
// Objects with different constructors are not equivalent.
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
// Deep compare objects.
for (var key in a) {
if (_.has(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
}
}
result = !size;
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (_.has(b, key) && !(size--)) break;
}
result = !size;
}
}

@@ -788,4 +817,5 @@ // Remove the first object from the stack of traversed objects.

_.isEmpty = function(obj) {
if (obj == null) return true;
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
for (var key in obj) if (hasOwnProperty.call(obj, key)) return false;
for (var key in obj) if (_.has(obj, key)) return false;
return true;

@@ -811,10 +841,9 @@ };

// Is a given variable an arguments object?
if (toString.call(arguments) == '[object Arguments]') {
_.isArguments = function(obj) {
return toString.call(obj) == '[object Arguments]';
};
if (!_.isArguments(arguments)) {
_.isArguments = function(obj) {
return toString.call(obj) == '[object Arguments]';
return !!(obj && _.has(obj, 'callee'));
};
} else {
_.isArguments = function(obj) {
return !!(obj && hasOwnProperty.call(obj, 'callee'));
};
}

@@ -837,2 +866,7 @@

// Is a given object a finite number?
_.isFinite = function(obj) {
return _.isNumber(obj) && isFinite(obj);
};
// Is the given value `NaN`?

@@ -869,2 +903,7 @@ _.isNaN = function(obj) {

// Has own property?
_.has = function(obj, key) {
return hasOwnProperty.call(obj, key);
};
// Utility Functions

@@ -892,5 +931,13 @@ // -----------------

_.escape = function(string) {
return (''+string).replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};
// If the value of the named property is a function then invoke it;
// otherwise, return it.
_.result = function(object, property) {
if (object == null) return null;
var value = object[property];
return _.isFunction(value) ? value.call(object) : value;
};
// Add your own custom functions to the Underscore object, ensuring that

@@ -920,29 +967,80 @@ // they're correctly added to the OOP wrapper as well.

// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var noMatch = /.^/;
// Certain characters need to be escaped so that they can be put into a
// string literal.
var escapes = {
'\\': '\\',
"'": "'",
'r': '\r',
'n': '\n',
't': '\t',
'u2028': '\u2028',
'u2029': '\u2029'
};
for (var p in escapes) escapes[escapes[p]] = p;
var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
var unescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;
// Within an interpolation, evaluation, or escaping, remove HTML escaping
// that had been previously added.
var unescape = function(code) {
return code.replace(unescaper, function(match, escape) {
return escapes[escape];
});
};
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(str, data) {
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.escape, function(match, code) {
return "',_.escape(" + code.replace(/\\'/g, "'") + "),'";
})
.replace(c.interpolate, function(match, code) {
return "'," + code.replace(/\\'/g, "'") + ",'";
})
.replace(c.evaluate || null, function(match, code) {
return "');" + code.replace(/\\'/g, "'")
.replace(/[\r\n\t]/g, ' ') + "__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', tmpl);
return data ? func(data) : func;
_.template = function(text, data, settings) {
settings = _.defaults(settings || {}, _.templateSettings);
// Compile the template source, taking care to escape characters that
// cannot be included in a string literal and then unescape them in code
// blocks.
var source = "__p+='" + text
.replace(escaper, function(match) {
return '\\' + escapes[match];
})
.replace(settings.escape || noMatch, function(match, code) {
return "'+\n_.escape(" + unescape(code) + ")+\n'";
})
.replace(settings.interpolate || noMatch, function(match, code) {
return "'+\n(" + unescape(code) + ")+\n'";
})
.replace(settings.evaluate || noMatch, function(match, code) {
return "';\n" + unescape(code) + "\n;__p+='";
}) + "';\n";
// If a variable is not specified, place data values in local scope.
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
source = "var __p='';" +
"var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n" +
source + "return __p;\n";
var render = new Function(settings.variable || 'obj', '_', source);
if (data) return render(data, _);
var template = function(data) {
return render.call(this, data, _);
};
// Provide the compiled function source as a convenience for build time
// precompilation.
template.source = 'function(' + (settings.variable || 'obj') + '){\n' +
source + '}';
return template;
};
// Add a "chain" function, which will delegate to the wrapper.
_.chain = function(obj) {
return _(obj).chain();
};
// The OOP Wrapper

@@ -980,4 +1078,7 @@ // ---------------

wrapper.prototype[name] = function() {
method.apply(this._wrapped, arguments);
return result(this._wrapped, this._chain);
var wrapped = this._wrapped;
method.apply(wrapped, arguments);
var length = wrapped.length;
if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
return result(wrapped, this._chain);
};

@@ -1005,2 +1106,2 @@ });

})();
}).call(this);

@@ -1,3 +0,1 @@

if(typeof environment == 'undefined') environment = 'default'; // Override me!

@@ -164,3 +162,7 @@

if(environment == 'node') {
this.totalFailures = 0
// displayResults will increment totalFailures by 1 for each failed test encountered
displayResults();
// will exit now setting the status to the number of failed tests
process.exit(this.totalFailures);
}

@@ -174,3 +176,3 @@ results = [];

totalAssertions += results[i].assertions;
totalFailures += results[i].failures.length;
this.totalFailures += results[i].failures.length;
for(j = 0; j < results[i].failures.length; j++) {

@@ -185,3 +187,3 @@ failure = results[i].failures[j];

var time = (runtime / 1000);
console.info(results.length + ' tests, ' + totalAssertions + ' assertions, ' + totalFailures + ' failures, ' + time + 's\n');
console.info(results.length + ' tests, ' + totalAssertions + ' assertions, ' + this.totalFailures + ' failures, ' + time + 's\n');
}

@@ -188,0 +190,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc