@a_fairlie/lotide 中文文档教程
Lotide
Lodash 库的迷你克隆。
Purpose
注意:此库是出于学习目的而发布的。 它不旨在用于生产级软件。
这个项目是我创建和发布的,是我在 Lighthouse Labs 学习的一部分。
Usage
安装它:
npm install @a_fairlie/lotide
需要它:
const _ = require('@a_fairlie/lotide');< /code>
调用它:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
目前实现了以下函数:
✔️ assertArraysEqual (arr1, arr2) | console.log 断言两个数组深度相等。
✔️ assertEqual(实际,预期)| console.log 断言两个数组深度相等。
✔️ assertObjectsEqual (obj1, obj2) | console.log 断言对象中的键值对很深等于
✔️ countLetters (string) | 计算字符串中每个字母出现的
次数 ✔️ countOnly (array, obj{key: true, key: true, etc.}) | 接收一个数组和一个对象。 它将返回一个对象,其中包含输入对象列出的所有内容的计数。
✔️ eqArrays (arr1, arr2) | 检查两个数组是否深度相等。 返回真/假
✔️ eqObjects (obj1, obj2) | 检查对象中的键值对是否深度相等。 返回真/假
✔️ findKey(对象,回调)| 扫描对象并返回所提供的回调为其返回真值的第一个键。 如果没有找到键,那么它应该返回 undefined。
✔️ findKeyByValue(对象,值)| 可以对象并返回包含给定值的第一个键。 如果没有找到具有该给定值的键,那么它应该返回未定义。
✔️ 头(数组)| 返回数组的第一项
✔️ letterPositions(字符串)| 返回字符串中找到每个字符的所有索引(从零开始的位置)。
✔️ 地图(数组、回调)| 返回由回调函数改变的新数组
✔️ middle (array) | 接受一个数组并返回给定数组的最中间元素。
✔️ 尾巴(数组) | 接受一个数组并返回排除第一个值
✔️ takeUntil (array, callback) | 接收数组并根据回调返回数组的副本
✔️没有(数组,回调)| 返回给定数组的子集,删除不需要的元素。
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 @a_fairlie/lotide
Require it:
const _ = require('@a_fairlie/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
✔️ assertArraysEqual (arr1, arr2) | console.log assertion that two arrays are deep equals.
✔️ assertEqual (actual, expected) | console.log assertion that two arrays are deep equals.
✔️ assertObjectsEqual (obj1, obj2) | console.log assertion that key-value pairs in an object are deep equals
✔️ countLetters (string) | count the number of times each letter of a string occurs
✔️ countOnly (array, obj{key: true, key: true, etc.}) | receive an array and an object. It will return an object containing counts of everything that the input object listed.
✔️ eqArrays (arr1, arr2) | check that two arrays are deep equals. return true/false
✔️ eqObjects (obj1, obj2) | check that key-value pairs in an object are deep equals. return true/false
✔️ findKey (object, callback) | scan an object and return the first key for which the provided callback returns a truthy value. If no key is found, then it should return undefined.
✔️ findKeyByValue (object, value) | can the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.
✔️ head (array) | return the first item of an array
✔️ letterPositions (string) | return all the indices (zero-based positions) in the string where each character is found.
✔️ map (array, callback) | return new array mutated by callback function
✔️ middle (array) | take in an array and return the middle-most element(s) of the given array.
✔️ tail (array) | take in an array and return exluding first value
✔️ takeUntil (array, callback) | receive array and return copy of array based on callback
✔️ without (array, callback) | return a subset of a given array, removing unwanted elements.