|
|
@@ -0,0 +1,744 @@
|
|
|
+/**
|
|
|
+ * @license
|
|
|
+ * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
|
|
|
+ * Build: `lodash modern exports="amd" include="extend" --debug --output src/lib/lodash/lodash-ckeditor.js`
|
|
|
+ * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
|
|
|
+ * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
|
|
|
+ * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
|
+ * Available under MIT license <http://lodash.com/license>
|
|
|
+ */
|
|
|
+;(function() {
|
|
|
+
|
|
|
+ /** Used to detected named functions */
|
|
|
+ var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
|
|
+
|
|
|
+ /** Used to detect functions containing a `this` reference */
|
|
|
+ var reThis = /\bthis\b/;
|
|
|
+
|
|
|
+ /** Used as the property descriptor for `__bindData__` */
|
|
|
+ var descriptor = {
|
|
|
+ 'configurable': false,
|
|
|
+ 'enumerable': false,
|
|
|
+ 'value': null,
|
|
|
+ 'writable': false
|
|
|
+ };
|
|
|
+
|
|
|
+ /** Used to determine if values are of the language type Object */
|
|
|
+ var objectTypes = {
|
|
|
+ 'boolean': false,
|
|
|
+ 'function': true,
|
|
|
+ 'object': true,
|
|
|
+ 'number': false,
|
|
|
+ 'string': false,
|
|
|
+ 'undefined': false
|
|
|
+ };
|
|
|
+
|
|
|
+ /** Used as a reference to the global object */
|
|
|
+ var root = (objectTypes[typeof window] && window) || this;
|
|
|
+
|
|
|
+ /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
|
|
|
+ var freeGlobal = objectTypes[typeof global] && global;
|
|
|
+ if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
|
|
+ root = freeGlobal;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Slices the `collection` from the `start` index up to, but not including,
|
|
|
+ * the `end` index.
|
|
|
+ *
|
|
|
+ * Note: This function is used instead of `Array#slice` to support node lists
|
|
|
+ * in IE < 9 and to ensure dense arrays are returned.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Array|Object|string} collection The collection to slice.
|
|
|
+ * @param {number} start The start index.
|
|
|
+ * @param {number} end The end index.
|
|
|
+ * @returns {Array} Returns the new array.
|
|
|
+ */
|
|
|
+ function slice(array, start, end) {
|
|
|
+ start || (start = 0);
|
|
|
+ if (typeof end == 'undefined') {
|
|
|
+ end = array ? array.length : 0;
|
|
|
+ }
|
|
|
+ var index = -1,
|
|
|
+ length = end - start || 0,
|
|
|
+ result = Array(length < 0 ? 0 : length);
|
|
|
+
|
|
|
+ while (++index < length) {
|
|
|
+ result[index] = array[start + index];
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Used for `Array` method references.
|
|
|
+ *
|
|
|
+ * Normally `Array.prototype` would suffice, however, using an array literal
|
|
|
+ * avoids issues in Narwhal.
|
|
|
+ */
|
|
|
+ var arrayRef = [];
|
|
|
+
|
|
|
+ /** Used for native method references */
|
|
|
+ var objectProto = Object.prototype;
|
|
|
+
|
|
|
+ /** Used to resolve the internal [[Class]] of values */
|
|
|
+ var toString = objectProto.toString;
|
|
|
+
|
|
|
+ /** Used to detect if a method is native */
|
|
|
+ var reNative = RegExp('^' +
|
|
|
+ String(toString)
|
|
|
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
|
+ .replace(/toString| for [^\]]+/g, '.*?') + '$'
|
|
|
+ );
|
|
|
+
|
|
|
+ /** Native method shortcuts */
|
|
|
+ var fnToString = Function.prototype.toString,
|
|
|
+ hasOwnProperty = objectProto.hasOwnProperty,
|
|
|
+ push = arrayRef.push,
|
|
|
+ unshift = arrayRef.unshift;
|
|
|
+
|
|
|
+ /** Used to set meta data on functions */
|
|
|
+ var defineProperty = (function() {
|
|
|
+ // IE 8 only accepts DOM elements
|
|
|
+ try {
|
|
|
+ var o = {},
|
|
|
+ func = isNative(func = Object.defineProperty) && func,
|
|
|
+ result = func(o, o, o) && func;
|
|
|
+ } catch(e) { }
|
|
|
+ return result;
|
|
|
+ }());
|
|
|
+
|
|
|
+ /* Native method shortcuts for methods with the same name as other `lodash` methods */
|
|
|
+ var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate,
|
|
|
+ nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a `lodash` object which wraps the given value to enable intuitive
|
|
|
+ * method chaining.
|
|
|
+ *
|
|
|
+ * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
|
|
|
+ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
|
|
|
+ * and `unshift`
|
|
|
+ *
|
|
|
+ * Chaining is supported in custom builds as long as the `value` method is
|
|
|
+ * implicitly or explicitly included in the build.
|
|
|
+ *
|
|
|
+ * The chainable wrapper functions are:
|
|
|
+ * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
|
|
|
+ * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
|
|
|
+ * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
|
|
|
+ * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
|
|
+ * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
|
|
|
+ * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
|
|
+ * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
|
|
|
+ * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
|
|
|
+ * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
|
|
|
+ * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
|
|
|
+ * and `zip`
|
|
|
+ *
|
|
|
+ * The non-chainable wrapper functions are:
|
|
|
+ * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
|
|
|
+ * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`,
|
|
|
+ * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
|
|
|
+ * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`,
|
|
|
+ * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`,
|
|
|
+ * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`,
|
|
|
+ * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`,
|
|
|
+ * `template`, `unescape`, `uniqueId`, and `value`
|
|
|
+ *
|
|
|
+ * The wrapper functions `first` and `last` return wrapped values when `n` is
|
|
|
+ * provided, otherwise they return unwrapped values.
|
|
|
+ *
|
|
|
+ * Explicit chaining can be enabled by using the `_.chain` method.
|
|
|
+ *
|
|
|
+ * @name _
|
|
|
+ * @constructor
|
|
|
+ * @category Chaining
|
|
|
+ * @param {*} value The value to wrap in a `lodash` instance.
|
|
|
+ * @returns {Object} Returns a `lodash` instance.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * var wrapped = _([1, 2, 3]);
|
|
|
+ *
|
|
|
+ * // returns an unwrapped value
|
|
|
+ * wrapped.reduce(function(sum, num) {
|
|
|
+ * return sum + num;
|
|
|
+ * });
|
|
|
+ * // => 6
|
|
|
+ *
|
|
|
+ * // returns a wrapped value
|
|
|
+ * var squares = wrapped.map(function(num) {
|
|
|
+ * return num * num;
|
|
|
+ * });
|
|
|
+ *
|
|
|
+ * _.isArray(squares);
|
|
|
+ * // => false
|
|
|
+ *
|
|
|
+ * _.isArray(squares.value());
|
|
|
+ * // => true
|
|
|
+ */
|
|
|
+ function lodash() {
|
|
|
+ // no operation performed
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * An object used to flag environments features.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @type Object
|
|
|
+ */
|
|
|
+ var support = lodash.support = {};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Detect if functions can be decompiled by `Function#toString`
|
|
|
+ * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
|
|
|
+ *
|
|
|
+ * @memberOf _.support
|
|
|
+ * @type boolean
|
|
|
+ */
|
|
|
+ support.funcDecomp = !isNative(root.WinRTError) && reThis.test(function() { return this; });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Detect if `Function#name` is supported (all but IE).
|
|
|
+ *
|
|
|
+ * @memberOf _.support
|
|
|
+ * @type boolean
|
|
|
+ */
|
|
|
+ support.funcNames = typeof Function.name == 'string';
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The base implementation of `_.bind` that creates the bound function and
|
|
|
+ * sets its meta data.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Array} bindData The bind data array.
|
|
|
+ * @returns {Function} Returns the new bound function.
|
|
|
+ */
|
|
|
+ function baseBind(bindData) {
|
|
|
+ var func = bindData[0],
|
|
|
+ partialArgs = bindData[2],
|
|
|
+ thisArg = bindData[4];
|
|
|
+
|
|
|
+ function bound() {
|
|
|
+ // `Function#bind` spec
|
|
|
+ // http://es5.github.io/#x15.3.4.5
|
|
|
+ if (partialArgs) {
|
|
|
+ // avoid `arguments` object deoptimizations by using `slice` instead
|
|
|
+ // of `Array.prototype.slice.call` and not assigning `arguments` to a
|
|
|
+ // variable as a ternary expression
|
|
|
+ var args = slice(partialArgs);
|
|
|
+ push.apply(args, arguments);
|
|
|
+ }
|
|
|
+ // mimic the constructor's `return` behavior
|
|
|
+ // http://es5.github.io/#x13.2.2
|
|
|
+ if (this instanceof bound) {
|
|
|
+ // ensure `new bound` is an instance of `func`
|
|
|
+ var thisBinding = baseCreate(func.prototype),
|
|
|
+ result = func.apply(thisBinding, args || arguments);
|
|
|
+ return isObject(result) ? result : thisBinding;
|
|
|
+ }
|
|
|
+ return func.apply(thisArg, args || arguments);
|
|
|
+ }
|
|
|
+ setBindData(bound, bindData);
|
|
|
+ return bound;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The base implementation of `_.create` without support for assigning
|
|
|
+ * properties to the created object.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Object} prototype The object to inherit from.
|
|
|
+ * @returns {Object} Returns the new object.
|
|
|
+ */
|
|
|
+ function baseCreate(prototype, properties) {
|
|
|
+ return isObject(prototype) ? nativeCreate(prototype) : {};
|
|
|
+ }
|
|
|
+ // fallback for browsers without `Object.create`
|
|
|
+ if (!nativeCreate) {
|
|
|
+ baseCreate = (function() {
|
|
|
+ function Object() {}
|
|
|
+ return function(prototype) {
|
|
|
+ if (isObject(prototype)) {
|
|
|
+ Object.prototype = prototype;
|
|
|
+ var result = new Object;
|
|
|
+ Object.prototype = null;
|
|
|
+ }
|
|
|
+ return result || root.Object();
|
|
|
+ };
|
|
|
+ }());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The base implementation of `_.createCallback` without support for creating
|
|
|
+ * "_.pluck" or "_.where" style callbacks.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {*} [func=identity] The value to convert to a callback.
|
|
|
+ * @param {*} [thisArg] The `this` binding of the created callback.
|
|
|
+ * @param {number} [argCount] The number of arguments the callback accepts.
|
|
|
+ * @returns {Function} Returns a callback function.
|
|
|
+ */
|
|
|
+ function baseCreateCallback(func, thisArg, argCount) {
|
|
|
+ if (typeof func != 'function') {
|
|
|
+ return identity;
|
|
|
+ }
|
|
|
+ // exit early for no `thisArg` or already bound by `Function#bind`
|
|
|
+ if (typeof thisArg == 'undefined' || !('prototype' in func)) {
|
|
|
+ return func;
|
|
|
+ }
|
|
|
+ var bindData = func.__bindData__;
|
|
|
+ if (typeof bindData == 'undefined') {
|
|
|
+ if (support.funcNames) {
|
|
|
+ bindData = !func.name;
|
|
|
+ }
|
|
|
+ bindData = bindData || !support.funcDecomp;
|
|
|
+ if (!bindData) {
|
|
|
+ var source = fnToString.call(func);
|
|
|
+ if (!support.funcNames) {
|
|
|
+ bindData = !reFuncName.test(source);
|
|
|
+ }
|
|
|
+ if (!bindData) {
|
|
|
+ // checks if `func` references the `this` keyword and stores the result
|
|
|
+ bindData = reThis.test(source);
|
|
|
+ setBindData(func, bindData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // exit early if there are no `this` references or `func` is bound
|
|
|
+ if (bindData === false || (bindData !== true && bindData[1] & 1)) {
|
|
|
+ return func;
|
|
|
+ }
|
|
|
+ switch (argCount) {
|
|
|
+ case 1: return function(value) {
|
|
|
+ return func.call(thisArg, value);
|
|
|
+ };
|
|
|
+ case 2: return function(a, b) {
|
|
|
+ return func.call(thisArg, a, b);
|
|
|
+ };
|
|
|
+ case 3: return function(value, index, collection) {
|
|
|
+ return func.call(thisArg, value, index, collection);
|
|
|
+ };
|
|
|
+ case 4: return function(accumulator, value, index, collection) {
|
|
|
+ return func.call(thisArg, accumulator, value, index, collection);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return bind(func, thisArg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The base implementation of `createWrapper` that creates the wrapper and
|
|
|
+ * sets its meta data.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Array} bindData The bind data array.
|
|
|
+ * @returns {Function} Returns the new function.
|
|
|
+ */
|
|
|
+ function baseCreateWrapper(bindData) {
|
|
|
+ var func = bindData[0],
|
|
|
+ bitmask = bindData[1],
|
|
|
+ partialArgs = bindData[2],
|
|
|
+ partialRightArgs = bindData[3],
|
|
|
+ thisArg = bindData[4],
|
|
|
+ arity = bindData[5];
|
|
|
+
|
|
|
+ var isBind = bitmask & 1,
|
|
|
+ isBindKey = bitmask & 2,
|
|
|
+ isCurry = bitmask & 4,
|
|
|
+ isCurryBound = bitmask & 8,
|
|
|
+ key = func;
|
|
|
+
|
|
|
+ function bound() {
|
|
|
+ var thisBinding = isBind ? thisArg : this;
|
|
|
+ if (partialArgs) {
|
|
|
+ var args = slice(partialArgs);
|
|
|
+ push.apply(args, arguments);
|
|
|
+ }
|
|
|
+ if (partialRightArgs || isCurry) {
|
|
|
+ args || (args = slice(arguments));
|
|
|
+ if (partialRightArgs) {
|
|
|
+ push.apply(args, partialRightArgs);
|
|
|
+ }
|
|
|
+ if (isCurry && args.length < arity) {
|
|
|
+ bitmask |= 16 & ~32;
|
|
|
+ return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ args || (args = arguments);
|
|
|
+ if (isBindKey) {
|
|
|
+ func = thisBinding[key];
|
|
|
+ }
|
|
|
+ if (this instanceof bound) {
|
|
|
+ thisBinding = baseCreate(func.prototype);
|
|
|
+ var result = func.apply(thisBinding, args);
|
|
|
+ return isObject(result) ? result : thisBinding;
|
|
|
+ }
|
|
|
+ return func.apply(thisBinding, args);
|
|
|
+ }
|
|
|
+ setBindData(bound, bindData);
|
|
|
+ return bound;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a function that, when called, either curries or invokes `func`
|
|
|
+ * with an optional `this` binding and partially applied arguments.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Function|string} func The function or method name to reference.
|
|
|
+ * @param {number} bitmask The bitmask of method flags to compose.
|
|
|
+ * The bitmask may be composed of the following flags:
|
|
|
+ * 1 - `_.bind`
|
|
|
+ * 2 - `_.bindKey`
|
|
|
+ * 4 - `_.curry`
|
|
|
+ * 8 - `_.curry` (bound)
|
|
|
+ * 16 - `_.partial`
|
|
|
+ * 32 - `_.partialRight`
|
|
|
+ * @param {Array} [partialArgs] An array of arguments to prepend to those
|
|
|
+ * provided to the new function.
|
|
|
+ * @param {Array} [partialRightArgs] An array of arguments to append to those
|
|
|
+ * provided to the new function.
|
|
|
+ * @param {*} [thisArg] The `this` binding of `func`.
|
|
|
+ * @param {number} [arity] The arity of `func`.
|
|
|
+ * @returns {Function} Returns the new function.
|
|
|
+ */
|
|
|
+ function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
|
|
|
+ var isBind = bitmask & 1,
|
|
|
+ isBindKey = bitmask & 2,
|
|
|
+ isCurry = bitmask & 4,
|
|
|
+ isCurryBound = bitmask & 8,
|
|
|
+ isPartial = bitmask & 16,
|
|
|
+ isPartialRight = bitmask & 32;
|
|
|
+
|
|
|
+ if (!isBindKey && !isFunction(func)) {
|
|
|
+ throw new TypeError;
|
|
|
+ }
|
|
|
+ if (isPartial && !partialArgs.length) {
|
|
|
+ bitmask &= ~16;
|
|
|
+ isPartial = partialArgs = false;
|
|
|
+ }
|
|
|
+ if (isPartialRight && !partialRightArgs.length) {
|
|
|
+ bitmask &= ~32;
|
|
|
+ isPartialRight = partialRightArgs = false;
|
|
|
+ }
|
|
|
+ var bindData = func && func.__bindData__;
|
|
|
+ if (bindData && bindData !== true) {
|
|
|
+ // clone `bindData`
|
|
|
+ bindData = slice(bindData);
|
|
|
+ if (bindData[2]) {
|
|
|
+ bindData[2] = slice(bindData[2]);
|
|
|
+ }
|
|
|
+ if (bindData[3]) {
|
|
|
+ bindData[3] = slice(bindData[3]);
|
|
|
+ }
|
|
|
+ // set `thisBinding` is not previously bound
|
|
|
+ if (isBind && !(bindData[1] & 1)) {
|
|
|
+ bindData[4] = thisArg;
|
|
|
+ }
|
|
|
+ // set if previously bound but not currently (subsequent curried functions)
|
|
|
+ if (!isBind && bindData[1] & 1) {
|
|
|
+ bitmask |= 8;
|
|
|
+ }
|
|
|
+ // set curried arity if not yet set
|
|
|
+ if (isCurry && !(bindData[1] & 4)) {
|
|
|
+ bindData[5] = arity;
|
|
|
+ }
|
|
|
+ // append partial left arguments
|
|
|
+ if (isPartial) {
|
|
|
+ push.apply(bindData[2] || (bindData[2] = []), partialArgs);
|
|
|
+ }
|
|
|
+ // append partial right arguments
|
|
|
+ if (isPartialRight) {
|
|
|
+ unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs);
|
|
|
+ }
|
|
|
+ // merge flags
|
|
|
+ bindData[1] |= bitmask;
|
|
|
+ return createWrapper.apply(null, bindData);
|
|
|
+ }
|
|
|
+ // fast path for `_.bind`
|
|
|
+ var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper;
|
|
|
+ return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if `value` is a native function.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {*} value The value to check.
|
|
|
+ * @returns {boolean} Returns `true` if the `value` is a native function, else `false`.
|
|
|
+ */
|
|
|
+ function isNative(value) {
|
|
|
+ return typeof value == 'function' && reNative.test(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets `this` binding data on a given function.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {Function} func The function to set data on.
|
|
|
+ * @param {Array} value The data array to set.
|
|
|
+ */
|
|
|
+ var setBindData = !defineProperty ? noop : function(func, value) {
|
|
|
+ descriptor.value = value;
|
|
|
+ defineProperty(func, '__bindData__', descriptor);
|
|
|
+ };
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * A fallback implementation of `Object.keys` which produces an array of the
|
|
|
+ * given object's own enumerable property names.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @type Function
|
|
|
+ * @param {Object} object The object to inspect.
|
|
|
+ * @returns {Array} Returns an array of property names.
|
|
|
+ */
|
|
|
+ var shimKeys = function(object) {
|
|
|
+ var index, iterable = object, result = [];
|
|
|
+ if (!iterable) return result;
|
|
|
+ if (!(objectTypes[typeof object])) return result;
|
|
|
+ for (index in iterable) {
|
|
|
+ if (hasOwnProperty.call(iterable, index)) {
|
|
|
+ result.push(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates an array composed of the own enumerable property names of an object.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Objects
|
|
|
+ * @param {Object} object The object to inspect.
|
|
|
+ * @returns {Array} Returns an array of property names.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
|
|
+ * // => ['one', 'two', 'three'] (property order is not guaranteed across environments)
|
|
|
+ */
|
|
|
+ var keys = !nativeKeys ? shimKeys : function(object) {
|
|
|
+ if (!isObject(object)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ return nativeKeys(object);
|
|
|
+ };
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Assigns own enumerable properties of source object(s) to the destination
|
|
|
+ * object. Subsequent sources will overwrite property assignments of previous
|
|
|
+ * sources. If a callback is provided it will be executed to produce the
|
|
|
+ * assigned values. The callback is bound to `thisArg` and invoked with two
|
|
|
+ * arguments; (objectValue, sourceValue).
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @type Function
|
|
|
+ * @alias extend
|
|
|
+ * @category Objects
|
|
|
+ * @param {Object} object The destination object.
|
|
|
+ * @param {...Object} [source] The source objects.
|
|
|
+ * @param {Function} [callback] The function to customize assigning values.
|
|
|
+ * @param {*} [thisArg] The `this` binding of `callback`.
|
|
|
+ * @returns {Object} Returns the destination object.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * _.assign({ 'name': 'fred' }, { 'employer': 'slate' });
|
|
|
+ * // => { 'name': 'fred', 'employer': 'slate' }
|
|
|
+ *
|
|
|
+ * var defaults = _.partialRight(_.assign, function(a, b) {
|
|
|
+ * return typeof a == 'undefined' ? b : a;
|
|
|
+ * });
|
|
|
+ *
|
|
|
+ * var object = { 'name': 'barney' };
|
|
|
+ * defaults(object, { 'name': 'fred', 'employer': 'slate' });
|
|
|
+ * // => { 'name': 'barney', 'employer': 'slate' }
|
|
|
+ */
|
|
|
+ var assign = function(object, source, guard) {
|
|
|
+ var index, iterable = object, result = iterable;
|
|
|
+ if (!iterable) return result;
|
|
|
+ var args = arguments,
|
|
|
+ argsIndex = 0,
|
|
|
+ argsLength = typeof guard == 'number' ? 2 : args.length;
|
|
|
+ if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {
|
|
|
+ var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);
|
|
|
+ } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {
|
|
|
+ callback = args[--argsLength];
|
|
|
+ }
|
|
|
+ while (++argsIndex < argsLength) {
|
|
|
+ iterable = args[argsIndex];
|
|
|
+ if (iterable && objectTypes[typeof iterable]) {
|
|
|
+ var ownIndex = -1,
|
|
|
+ ownProps = objectTypes[typeof iterable] && keys(iterable),
|
|
|
+ length = ownProps ? ownProps.length : 0;
|
|
|
+
|
|
|
+ while (++ownIndex < length) {
|
|
|
+ index = ownProps[ownIndex];
|
|
|
+ result[index] = callback ? callback(result[index], iterable[index]) : iterable[index];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if `value` is a function.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Objects
|
|
|
+ * @param {*} value The value to check.
|
|
|
+ * @returns {boolean} Returns `true` if the `value` is a function, else `false`.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * _.isFunction(_);
|
|
|
+ * // => true
|
|
|
+ */
|
|
|
+ function isFunction(value) {
|
|
|
+ return typeof value == 'function';
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if `value` is the language type of Object.
|
|
|
+ * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Objects
|
|
|
+ * @param {*} value The value to check.
|
|
|
+ * @returns {boolean} Returns `true` if the `value` is an object, else `false`.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * _.isObject({});
|
|
|
+ * // => true
|
|
|
+ *
|
|
|
+ * _.isObject([1, 2, 3]);
|
|
|
+ * // => true
|
|
|
+ *
|
|
|
+ * _.isObject(1);
|
|
|
+ * // => false
|
|
|
+ */
|
|
|
+ function isObject(value) {
|
|
|
+ // check if the value is the ECMAScript language type of Object
|
|
|
+ // http://es5.github.io/#x8
|
|
|
+ // and avoid a V8 bug
|
|
|
+ // http://code.google.com/p/v8/issues/detail?id=2291
|
|
|
+ return !!(value && objectTypes[typeof value]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a function that, when called, invokes `func` with the `this`
|
|
|
+ * binding of `thisArg` and prepends any additional `bind` arguments to those
|
|
|
+ * provided to the bound function.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Functions
|
|
|
+ * @param {Function} func The function to bind.
|
|
|
+ * @param {*} [thisArg] The `this` binding of `func`.
|
|
|
+ * @param {...*} [arg] Arguments to be partially applied.
|
|
|
+ * @returns {Function} Returns the new bound function.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * var func = function(greeting) {
|
|
|
+ * return greeting + ' ' + this.name;
|
|
|
+ * };
|
|
|
+ *
|
|
|
+ * func = _.bind(func, { 'name': 'fred' }, 'hi');
|
|
|
+ * func();
|
|
|
+ * // => 'hi fred'
|
|
|
+ */
|
|
|
+ function bind(func, thisArg) {
|
|
|
+ return arguments.length > 2
|
|
|
+ ? createWrapper(func, 17, slice(arguments, 2), null, thisArg)
|
|
|
+ : createWrapper(func, 1, null, null, thisArg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method returns the first argument provided to it.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Utilities
|
|
|
+ * @param {*} value Any value.
|
|
|
+ * @returns {*} Returns `value`.
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * var object = { 'name': 'fred' };
|
|
|
+ * _.identity(object) === object;
|
|
|
+ * // => true
|
|
|
+ */
|
|
|
+ function identity(value) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * A no-operation function.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @category Utilities
|
|
|
+ * @example
|
|
|
+ *
|
|
|
+ * var object = { 'name': 'fred' };
|
|
|
+ * _.noop(object) === undefined;
|
|
|
+ * // => true
|
|
|
+ */
|
|
|
+ function noop() {
|
|
|
+ // no operation performed
|
|
|
+ }
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ lodash.assign = assign;
|
|
|
+ lodash.bind = bind;
|
|
|
+ lodash.keys = keys;
|
|
|
+
|
|
|
+ lodash.extend = assign;
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ lodash.identity = identity;
|
|
|
+ lodash.isFunction = isFunction;
|
|
|
+ lodash.isObject = isObject;
|
|
|
+ lodash.noop = noop;
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The semantic version number.
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @memberOf _
|
|
|
+ * @type string
|
|
|
+ */
|
|
|
+ lodash.VERSION = '2.4.1';
|
|
|
+
|
|
|
+ /*--------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+ // some AMD build optimizers like r.js check for condition patterns like the following:
|
|
|
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
|
+ // define as an anonymous module so, through path mapping, it can be
|
|
|
+ // referenced as the "underscore" module
|
|
|
+ define(function() {
|
|
|
+ return lodash;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}.call(this));
|