PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/cordova_controller/platforms/ios/cordova/node_modules/lodash-node/compat/index.js

https://gitlab.com/bafang/cordova_controller
JavaScript | 376 lines | 246 code | 25 blank | 105 comment | 21 complexity | 0713819f2f60eee5446816e253d2dd41 MD5 | raw file
  1. /**
  2. * @license
  3. * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
  4. * Build: `lodash modularize exports="node" -o ./compat/`
  5. * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
  6. * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
  7. * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  8. * Available under MIT license <http://lodash.com/license>
  9. */
  10. var arrays = require('./arrays'),
  11. chaining = require('./chaining'),
  12. collections = require('./collections'),
  13. functions = require('./functions'),
  14. objects = require('./objects'),
  15. utilities = require('./utilities'),
  16. baseEach = require('./internals/baseEach'),
  17. forOwn = require('./objects/forOwn'),
  18. isArray = require('./objects/isArray'),
  19. lodashWrapper = require('./internals/lodashWrapper'),
  20. mixin = require('./utilities/mixin'),
  21. support = require('./support'),
  22. templateSettings = require('./utilities/templateSettings');
  23. /**
  24. * Used for `Array` method references.
  25. *
  26. * Normally `Array.prototype` would suffice, however, using an array literal
  27. * avoids issues in Narwhal.
  28. */
  29. var arrayRef = [];
  30. /** Used for native method references */
  31. var objectProto = Object.prototype;
  32. /** Native method shortcuts */
  33. var hasOwnProperty = objectProto.hasOwnProperty;
  34. /**
  35. * Creates a `lodash` object which wraps the given value to enable intuitive
  36. * method chaining.
  37. *
  38. * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
  39. * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
  40. * and `unshift`
  41. *
  42. * Chaining is supported in custom builds as long as the `value` method is
  43. * implicitly or explicitly included in the build.
  44. *
  45. * The chainable wrapper functions are:
  46. * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
  47. * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
  48. * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
  49. * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
  50. * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
  51. * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
  52. * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
  53. * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
  54. * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
  55. * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
  56. * and `zip`
  57. *
  58. * The non-chainable wrapper functions are:
  59. * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
  60. * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`,
  61. * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
  62. * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`,
  63. * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`,
  64. * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`,
  65. * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`,
  66. * `template`, `unescape`, `uniqueId`, and `value`
  67. *
  68. * The wrapper functions `first` and `last` return wrapped values when `n` is
  69. * provided, otherwise they return unwrapped values.
  70. *
  71. * Explicit chaining can be enabled by using the `_.chain` method.
  72. *
  73. * @name _
  74. * @constructor
  75. * @category Chaining
  76. * @param {*} value The value to wrap in a `lodash` instance.
  77. * @returns {Object} Returns a `lodash` instance.
  78. * @example
  79. *
  80. * var wrapped = _([1, 2, 3]);
  81. *
  82. * // returns an unwrapped value
  83. * wrapped.reduce(function(sum, num) {
  84. * return sum + num;
  85. * });
  86. * // => 6
  87. *
  88. * // returns a wrapped value
  89. * var squares = wrapped.map(function(num) {
  90. * return num * num;
  91. * });
  92. *
  93. * _.isArray(squares);
  94. * // => false
  95. *
  96. * _.isArray(squares.value());
  97. * // => true
  98. */
  99. function lodash(value) {
  100. // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
  101. return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
  102. ? value
  103. : new lodashWrapper(value);
  104. }
  105. // ensure `new lodashWrapper` is an instance of `lodash`
  106. lodashWrapper.prototype = lodash.prototype;
  107. // wrap `_.mixin` so it works when provided only one argument
  108. mixin = (function(fn) {
  109. var functions = objects.functions;
  110. return function(object, source, options) {
  111. if (!source || (!options && !functions(source).length)) {
  112. if (options == null) {
  113. options = source;
  114. }
  115. source = object;
  116. object = lodash;
  117. }
  118. return fn(object, source, options);
  119. };
  120. }(mixin));
  121. // add functions that return wrapped values when chaining
  122. lodash.after = functions.after;
  123. lodash.assign = objects.assign;
  124. lodash.at = collections.at;
  125. lodash.bind = functions.bind;
  126. lodash.bindAll = functions.bindAll;
  127. lodash.bindKey = functions.bindKey;
  128. lodash.chain = chaining.chain;
  129. lodash.compact = arrays.compact;
  130. lodash.compose = functions.compose;
  131. lodash.constant = utilities.constant;
  132. lodash.countBy = collections.countBy;
  133. lodash.create = objects.create;
  134. lodash.createCallback = functions.createCallback;
  135. lodash.curry = functions.curry;
  136. lodash.debounce = functions.debounce;
  137. lodash.defaults = objects.defaults;
  138. lodash.defer = functions.defer;
  139. lodash.delay = functions.delay;
  140. lodash.difference = arrays.difference;
  141. lodash.filter = collections.filter;
  142. lodash.flatten = arrays.flatten;
  143. lodash.forEach = collections.forEach;
  144. lodash.forEachRight = collections.forEachRight;
  145. lodash.forIn = objects.forIn;
  146. lodash.forInRight = objects.forInRight;
  147. lodash.forOwn = forOwn;
  148. lodash.forOwnRight = objects.forOwnRight;
  149. lodash.functions = objects.functions;
  150. lodash.groupBy = collections.groupBy;
  151. lodash.indexBy = collections.indexBy;
  152. lodash.initial = arrays.initial;
  153. lodash.intersection = arrays.intersection;
  154. lodash.invert = objects.invert;
  155. lodash.invoke = collections.invoke;
  156. lodash.keys = objects.keys;
  157. lodash.map = collections.map;
  158. lodash.mapValues = objects.mapValues;
  159. lodash.max = collections.max;
  160. lodash.memoize = functions.memoize;
  161. lodash.merge = objects.merge;
  162. lodash.min = collections.min;
  163. lodash.omit = objects.omit;
  164. lodash.once = functions.once;
  165. lodash.pairs = objects.pairs;
  166. lodash.partial = functions.partial;
  167. lodash.partialRight = functions.partialRight;
  168. lodash.pick = objects.pick;
  169. lodash.pluck = collections.pluck;
  170. lodash.property = utilities.property;
  171. lodash.pull = arrays.pull;
  172. lodash.range = arrays.range;
  173. lodash.reject = collections.reject;
  174. lodash.remove = arrays.remove;
  175. lodash.rest = arrays.rest;
  176. lodash.shuffle = collections.shuffle;
  177. lodash.sortBy = collections.sortBy;
  178. lodash.tap = chaining.tap;
  179. lodash.throttle = functions.throttle;
  180. lodash.times = utilities.times;
  181. lodash.toArray = collections.toArray;
  182. lodash.transform = objects.transform;
  183. lodash.union = arrays.union;
  184. lodash.uniq = arrays.uniq;
  185. lodash.values = objects.values;
  186. lodash.where = collections.where;
  187. lodash.without = arrays.without;
  188. lodash.wrap = functions.wrap;
  189. lodash.xor = arrays.xor;
  190. lodash.zip = arrays.zip;
  191. lodash.zipObject = arrays.zipObject;
  192. // add aliases
  193. lodash.collect = collections.map;
  194. lodash.drop = arrays.rest;
  195. lodash.each = collections.forEach;
  196. lodash.eachRight = collections.forEachRight;
  197. lodash.extend = objects.assign;
  198. lodash.methods = objects.functions;
  199. lodash.object = arrays.zipObject;
  200. lodash.select = collections.filter;
  201. lodash.tail = arrays.rest;
  202. lodash.unique = arrays.uniq;
  203. lodash.unzip = arrays.zip;
  204. // add functions to `lodash.prototype`
  205. mixin(lodash);
  206. // add functions that return unwrapped values when chaining
  207. lodash.clone = objects.clone;
  208. lodash.cloneDeep = objects.cloneDeep;
  209. lodash.contains = collections.contains;
  210. lodash.escape = utilities.escape;
  211. lodash.every = collections.every;
  212. lodash.find = collections.find;
  213. lodash.findIndex = arrays.findIndex;
  214. lodash.findKey = objects.findKey;
  215. lodash.findLast = collections.findLast;
  216. lodash.findLastIndex = arrays.findLastIndex;
  217. lodash.findLastKey = objects.findLastKey;
  218. lodash.has = objects.has;
  219. lodash.identity = utilities.identity;
  220. lodash.indexOf = arrays.indexOf;
  221. lodash.isArguments = objects.isArguments;
  222. lodash.isArray = isArray;
  223. lodash.isBoolean = objects.isBoolean;
  224. lodash.isDate = objects.isDate;
  225. lodash.isElement = objects.isElement;
  226. lodash.isEmpty = objects.isEmpty;
  227. lodash.isEqual = objects.isEqual;
  228. lodash.isFinite = objects.isFinite;
  229. lodash.isFunction = objects.isFunction;
  230. lodash.isNaN = objects.isNaN;
  231. lodash.isNull = objects.isNull;
  232. lodash.isNumber = objects.isNumber;
  233. lodash.isObject = objects.isObject;
  234. lodash.isPlainObject = objects.isPlainObject;
  235. lodash.isRegExp = objects.isRegExp;
  236. lodash.isString = objects.isString;
  237. lodash.isUndefined = objects.isUndefined;
  238. lodash.lastIndexOf = arrays.lastIndexOf;
  239. lodash.mixin = mixin;
  240. lodash.noConflict = utilities.noConflict;
  241. lodash.noop = utilities.noop;
  242. lodash.now = utilities.now;
  243. lodash.parseInt = utilities.parseInt;
  244. lodash.random = utilities.random;
  245. lodash.reduce = collections.reduce;
  246. lodash.reduceRight = collections.reduceRight;
  247. lodash.result = utilities.result;
  248. lodash.size = collections.size;
  249. lodash.some = collections.some;
  250. lodash.sortedIndex = arrays.sortedIndex;
  251. lodash.template = utilities.template;
  252. lodash.unescape = utilities.unescape;
  253. lodash.uniqueId = utilities.uniqueId;
  254. // add aliases
  255. lodash.all = collections.every;
  256. lodash.any = collections.some;
  257. lodash.detect = collections.find;
  258. lodash.findWhere = collections.find;
  259. lodash.foldl = collections.reduce;
  260. lodash.foldr = collections.reduceRight;
  261. lodash.include = collections.contains;
  262. lodash.inject = collections.reduce;
  263. mixin(function() {
  264. var source = {}
  265. forOwn(lodash, function(func, methodName) {
  266. if (!lodash.prototype[methodName]) {
  267. source[methodName] = func;
  268. }
  269. });
  270. return source;
  271. }(), false);
  272. // add functions capable of returning wrapped and unwrapped values when chaining
  273. lodash.first = arrays.first;
  274. lodash.last = arrays.last;
  275. lodash.sample = collections.sample;
  276. // add aliases
  277. lodash.take = arrays.first;
  278. lodash.head = arrays.first;
  279. forOwn(lodash, function(func, methodName) {
  280. var callbackable = methodName !== 'sample';
  281. if (!lodash.prototype[methodName]) {
  282. lodash.prototype[methodName]= function(n, guard) {
  283. var chainAll = this.__chain__,
  284. result = func(this.__wrapped__, n, guard);
  285. return !chainAll && (n == null || (guard && !(callbackable && typeof n == 'function')))
  286. ? result
  287. : new lodashWrapper(result, chainAll);
  288. };
  289. }
  290. });
  291. /**
  292. * The semantic version number.
  293. *
  294. * @static
  295. * @memberOf _
  296. * @type string
  297. */
  298. lodash.VERSION = '2.4.1';
  299. // add "Chaining" functions to the wrapper
  300. lodash.prototype.chain = chaining.wrapperChain;
  301. lodash.prototype.toString = chaining.wrapperToString;
  302. lodash.prototype.value = chaining.wrapperValueOf;
  303. lodash.prototype.valueOf = chaining.wrapperValueOf;
  304. // add `Array` functions that return unwrapped values
  305. baseEach(['join', 'pop', 'shift'], function(methodName) {
  306. var func = arrayRef[methodName];
  307. lodash.prototype[methodName] = function() {
  308. var chainAll = this.__chain__,
  309. result = func.apply(this.__wrapped__, arguments);
  310. return chainAll
  311. ? new lodashWrapper(result, chainAll)
  312. : result;
  313. };
  314. });
  315. // add `Array` functions that return the existing wrapped value
  316. baseEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
  317. var func = arrayRef[methodName];
  318. lodash.prototype[methodName] = function() {
  319. func.apply(this.__wrapped__, arguments);
  320. return this;
  321. };
  322. });
  323. // add `Array` functions that return new wrapped values
  324. baseEach(['concat', 'slice', 'splice'], function(methodName) {
  325. var func = arrayRef[methodName];
  326. lodash.prototype[methodName] = function() {
  327. return new lodashWrapper(func.apply(this.__wrapped__, arguments), this.__chain__);
  328. };
  329. });
  330. // avoid array-like object bugs with `Array#shift` and `Array#splice`
  331. // in IE < 9, Firefox < 10, Narwhal, and RingoJS
  332. if (!support.spliceObjects) {
  333. baseEach(['pop', 'shift', 'splice'], function(methodName) {
  334. var func = arrayRef[methodName],
  335. isSplice = methodName == 'splice';
  336. lodash.prototype[methodName] = function() {
  337. var chainAll = this.__chain__,
  338. value = this.__wrapped__,
  339. result = func.apply(value, arguments);
  340. if (value.length === 0) {
  341. delete value[0];
  342. }
  343. return (chainAll || isSplice)
  344. ? new lodashWrapper(result, chainAll)
  345. : result;
  346. };
  347. });
  348. }
  349. lodash.support = support;
  350. (lodash.templateSettings = utilities.templateSettings).imports._ = lodash;
  351. module.exports = lodash;