From 4ba0f8b6124062836af257dae8d208976b0e05b7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 15 Jun 2018 06:15:16 -0400 Subject: [PATCH] Remove more methods. --- ary.js | 25 ----- assignWith.js | 35 ------- bindKey.js | 66 ------------ curry.js | 53 ---------- curryRight.js | 50 ---------- find.js | 40 -------- template.js | 238 -------------------------------------------- templateSettings.js | 65 ------------ 8 files changed, 572 deletions(-) delete mode 100644 ary.js delete mode 100644 assignWith.js delete mode 100644 bindKey.js delete mode 100644 curry.js delete mode 100644 curryRight.js delete mode 100644 find.js delete mode 100644 template.js delete mode 100644 templateSettings.js diff --git a/ary.js b/ary.js deleted file mode 100644 index 367ee8789..000000000 --- a/ary.js +++ /dev/null @@ -1,25 +0,0 @@ -import createWrap from './.internal/createWrap.js' - -/** Used to compose bitmasks for function metadata. */ -const WRAP_ARY_FLAG = 128 - -/** - * Creates a function that invokes `func`, with up to `n` arguments, - * ignoring any additional arguments. - * - * @since 3.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @returns {Function} Returns the new capped function. - * @example - * - * map(['6', '8', '10'], ary(parseInt, 1)) - * // => [6, 8, 10] - */ -function ary(func, n) { - n = (func && n == null) ? func.length : n - return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n) -} - -export default ary diff --git a/assignWith.js b/assignWith.js deleted file mode 100644 index 8aac3f2ba..000000000 --- a/assignWith.js +++ /dev/null @@ -1,35 +0,0 @@ -import copyObject from './.internal/copyObject.js' -import createAssigner from './.internal/createAssigner.js' -import keys from './keys.js' - -/** - * This method is like `assign` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see assignInWith - * @example - * - * function customizer(objValue, srcValue) { - * return isUndefined(objValue) ? srcValue : objValue - * } - * - * const defaults = partialRight(assignWith, customizer) - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }) - * // => { 'a': 1, 'b': 2 } - */ -const assignWith = createAssigner((object, source, srcIndex, customizer) => { - copyObject(source, keys(source), object, customizer) -}) - -export default assignWith diff --git a/bindKey.js b/bindKey.js deleted file mode 100644 index 4b24d3c71..000000000 --- a/bindKey.js +++ /dev/null @@ -1,66 +0,0 @@ -import createWrap from './.internal/createWrap.js' -import getHolder from './.internal/getHolder.js' -import replaceHolders from './.internal/replaceHolders.js' - -/** Used to compose bitmasks for function metadata. */ -const WRAP_BIND_FLAG = 1 -const WRAP_BIND_KEY_FLAG = 2 -const WRAP_PARTIAL_FLAG = 32 - -/** - * Creates a function that invokes the method at `object[key]` with `partials` - * prepended to the arguments it receives. - * - * This method differs from `bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. See - * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @since 0.10.0 - * @category Function - * @param {Object} object The object to invoke the method on. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * const object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation - * } - * } - * - * const bound = bindKey(object, 'greet', 'hi') - * bound('!') - * // => 'hi fred!' - * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation - * } - * - * bound('!') - * // => 'hiya fred!' - * - * // Bound with placeholders. - * const bound = bindKey(object, 'greet', _, '!') - * bound('hi') - * // => 'hiya fred!' - */ -function bindKey(object, key, ...partials) { - let holders - let bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG - if (partials.length) { - holders = replaceHolders(partials, getHolder(bindKey)) - bitmask |= WRAP_PARTIAL_FLAG - } - return createWrap(key, bitmask, object, partials, holders) -} - -// Assign default placeholders. -bindKey.placeholder = {} - -export default bindKey diff --git a/curry.js b/curry.js deleted file mode 100644 index fa46aac74..000000000 --- a/curry.js +++ /dev/null @@ -1,53 +0,0 @@ -import createWrap from './.internal/createWrap.js' - -/** Used to compose bitmasks for function metadata. */ -const WRAP_CURRY_FLAG = 8 - -/** - * Creates a function that accepts arguments of `func` and either invokes - * `func` returning its result, if at least `arity` number of arguments have - * been provided, or returns a function that accepts the remaining `func` - * arguments, and so on. The arity of `func` may be specified if `func.length` - * is not sufficient. - * - * The `curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @since 2.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @returns {Function} Returns the new curried function. - * @example - * - * const abc = function(a, b, c) { - * return [a, b, c] - * } - * - * const curried = curry(abc) - * - * curried(1)(2)(3) - * // => [1, 2, 3] - * - * curried(1, 2)(3) - * // => [1, 2, 3] - * - * curried(1, 2, 3) - * // => [1, 2, 3] - * - * // Curried with placeholders. - * curried(1)(_, 3)(2) - * // => [1, 2, 3] - */ -function curry(func, arity) { - const result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity) - result.placeholder = curry.placeholder - return result -} - -// Assign default placeholders. -curry.placeholder = {} - -export default curry diff --git a/curryRight.js b/curryRight.js deleted file mode 100644 index c01246914..000000000 --- a/curryRight.js +++ /dev/null @@ -1,50 +0,0 @@ -import createWrap from './.internal/createWrap.js' - -/** Used to compose bitmasks for function metadata. */ -const WRAP_CURRY_RIGHT_FLAG = 16 - -/** - * This method is like `curry` except that arguments are applied to `func` - * in the manner of `partialRight` instead of `partial`. - * - * The `curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. - * - * @since 3.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @returns {Function} Returns the new curried function. - * @example - * - * const abc = function(a, b, c) { - * return [a, b, c] - * } - * - * const curried = curryRight(abc) - * - * curried(3)(2)(1) - * // => [1, 2, 3] - * - * curried(2, 3)(1) - * // => [1, 2, 3] - * - * curried(1, 2, 3) - * // => [1, 2, 3] - * - * // Curried with placeholders. - * curried(3)(1, _)(2) - * // => [1, 2, 3] - */ -function curryRight(func, arity) { - const result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity) - result.placeholder = curryRight.placeholder - return result -} - -// Assign default placeholders. -curryRight.placeholder = {} - -export default curryRight diff --git a/find.js b/find.js deleted file mode 100644 index b96b8c2a1..000000000 --- a/find.js +++ /dev/null @@ -1,40 +0,0 @@ -import findIndex from './findIndex.js' -import isArrayLike from './isArrayLike' -import keys from './keys' - -/** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @see findIndex, findKey, findLast, findLastIndex, findLastKey - * @example - * - * const users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ] - * - * find(users, ({ age }) => age < 40) - * // => object for 'barney' - */ -function find(collection, predicate, fromIndex) { - let iteratee - const iterable = Object(collection) - - if (!isArrayLike(collection)) { - collection = keys(collection) - iteratee = (key) => predicate(iterable[key], key, iterable) - } - const index = findIndex(collection, predicate, fromIndex) - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined -} - -export default find diff --git a/template.js b/template.js deleted file mode 100644 index a7e0335b9..000000000 --- a/template.js +++ /dev/null @@ -1,238 +0,0 @@ -import assignInWith from './assignInWith.js' -import attempt from './attempt.js' -import baseValues from './.internal/baseValues.js' -import customDefaultsAssignIn from './.internal/customDefaultsAssignIn.js' -import isError from './isError.js' -import keys from './keys.js' -import reInterpolate from './.internal/reInterpolate.js' -import templateSettings from './templateSettings.js' - -/** Used to match empty string literals in compiled template source. */ -const reEmptyStringLeading = /\b__p \+= '';/g -const reEmptyStringMiddle = /\b(__p \+=) '' \+/g -const reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g - -/** - * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). - */ -const reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g - -/** Used to ensure capturing order of template delimiters. */ -const reNoMatch = /($^)/ - -/** Used to match unescaped characters in compiled string literals. */ -const reUnescapedString = /['\n\r\u2028\u2029\\]/g - -/** Used to escape characters for inclusion in compiled string literals. */ -const stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' -} - -/** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is given, it takes precedence over `templateSettings` values. - * - * **Note:** In the development build `template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. - * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). - * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). - * - * @since 0.1.0 - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options={}] The options object. - * @param {RegExp} [options.escape=templateSettings.escape] - * The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate=templateSettings.evaluate] - * The "evaluate" delimiter. - * @param {Object} [options.imports=templateSettings.imports] - * An object to import into the template as free variables. - * @param {RegExp} [options.interpolate=templateSettings.interpolate] - * The "interpolate" delimiter. - * @param {string} [options.sourceURL='templateSources[n]'] - * The sourceURL of the compiled template. - * @param {string} [options.variable='obj'] - * The data object variable name. - * @returns {Function} Returns the compiled template function. - * @example - * - * // Use the "interpolate" delimiter to create a compiled template. - * let compiled = template('hello <%= user %>!') - * compiled({ 'user': 'fred' }) - * // => 'hello fred!' - * - * // Use the HTML "escape" delimiter to escape data property values. - * let compiled = template('<%- value %>') - * compiled({ 'value': '