@aal-brown/lotide 中文文档教程
Lotide
Lodash 库的迷你克隆。
Purpose
注意:此库是出于学习目的而发布的。 它不旨在用于生产级软件。
这个项目是我创建和发布的,是我在 Lighthouse Labs 学习的一部分。
Usage
安装它:
npm install @username/lotide
需要它:
const _ = require('@username/lotide');< /code>
调用它:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
目前实现了以下功能:
head:
Returns the first item of an array.tail:
Returns all except the first item of an array.middle:
Returns the middle item/s of an array.assertArraysEqual:
Assert equal function that works for arrays.assertObjectsEqual:
Assert equal function that works for objects.assertEqual:
Assert equal function for primitive data types.countLetters:
Counts the number of characters in a string.eqArrays:
Returns true or false based on whether two arrays are identical.eqObjects:
Returns true or false based on whether two arrays are identical.findKey:
Takes in an object and a callback and returns the first key for which the callback returns a truthy value.findKeyByValue:
Takes in an object and a value, it will scan the object and return the first key which contains the given value.flatten:
Takes in an array that may contain nested arrays and returns an array without nesting.letterPositions:
Take in a string and return an object where the position of each character is stored.map:
Maps the elements from one array to another based on a provided callback function.takeUntil:
Populates a new array with elements from an existing array until a truthy value is returned by the callback function.without:
Takes in two arrays, the elements from the second one are removed from the first, and the resultant array is returned.
Lotide
A mini clone of the Lodash library.
Purpose
BEWARE: This library was published for learning purposes. It is not intended for use in production-grade software.
This project was created and published by me as part of my learnings at Lighthouse Labs.
Usage
Install it:
npm install @username/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head:
Returns the first item of an array.tail:
Returns all except the first item of an array.middle:
Returns the middle item/s of an array.assertArraysEqual:
Assert equal function that works for arrays.assertObjectsEqual:
Assert equal function that works for objects.assertEqual:
Assert equal function for primitive data types.countLetters:
Counts the number of characters in a string.eqArrays:
Returns true or false based on whether two arrays are identical.eqObjects:
Returns true or false based on whether two arrays are identical.findKey:
Takes in an object and a callback and returns the first key for which the callback returns a truthy value.findKeyByValue:
Takes in an object and a value, it will scan the object and return the first key which contains the given value.flatten:
Takes in an array that may contain nested arrays and returns an array without nesting.letterPositions:
Take in a string and return an object where the position of each character is stored.map:
Maps the elements from one array to another based on a provided callback function.takeUntil:
Populates a new array with elements from an existing array until a truthy value is returned by the callback function.without:
Takes in two arrays, the elements from the second one are removed from the first, and the resultant array is returned.