@3bdo0319/lotide 中文文档教程
Lotide
Lodash 库的迷你克隆。
Purpose
注意:此库是出于学习目的而发布的。 它不旨在用于生产级软件。
这个项目是我创建和发布的,是我在 Lighthouse Labs 学习的一部分。
Usage
安装它:
npm install @hass0319/lotide
需要它:
const _ = require('@hass0319/lotide');< /code>
调用它:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
当前实现了以下函数:
assertArraysEqual()
:接收两个数组,检查是否相等,并记录相应的消息。EqArrays()
:接收两个数组并返回 true 或 false 值。Head()
:检索数组的第一个元素。tail(arr)
:检索除头部之外的所有其他元素。middle()
:接受一个数组并返回最中间的元素assertObjectEqual ()
:接受两个对象并根据完美匹配返回失败或通过的断言。countOnly()
:接受一个对象并返回对象特定子集的计数countletters()
:接受一个句子(作为字符串)然后返回一个计数该句子中的每个字母。eqobjects()
:接收两个对象并根据完美匹配返回 true 或 false。findKey()
:接受一个对象和一个回调。 它将遍历对象并返回回调返回真值的第一个键。 如果没有找到键,那么它将返回 undefined。findKeyByValue()
:接受一个对象和一个值。 它应该扫描对象并返回包含给定值的第一个键,如果不是,则返回未定义。letterPositions()
:返回字符串中每个字符所在的所有索引。Map()
:接受一个数组和一个回调,并根据回调函数的结果返回一个新数组。(): 接受一个字符串,并反向打印它
reverseString 直到回调函数返回真值。
without()
:接受一个数组,itemsToRemove 返回给定数组的一个子集,删除不需要的元素。
version "1.0.0"
description
author
hass0319
head(arr)
:检索数组的第一个元素。tail(arr)
:检索除头部之外的所有其他元素。middle(array)
:接受一个数组并返回最中间的元素。flatten(array)
:接收一个数组并返回一个数组。
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 @hass0319/lotide
Require it:
const _ = require('@hass0319/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual()
: Takes in two arrays, checks if Equal, and logs the appropriate message.EqArrays()
: Takes in two arrays and returns a true or false value.Head()
: Retrieves the first element of an array.tail(arr)
: Retrieves all other elements except the head.middle()
: Takes in an array and returns the middle-most elementsassertObjectEqual ()
: Takes in two objects and returns failed or passed assertions, based on a perfect match.countOnly()
: Takes in an object and return counts for a specific subset of the objectcountletters()
: Takes in a sentence (as a string) and then return a count of each of the letters in that sentence.eqobjects()
: take in two objects and returns true or false, based on a perfect match.findKey()
: Takes in an object and a callback. It will traverse the object and return the first key for which the callback returns a truthy value. If no key is found, then it will return undefined.findKeyByValue()
: Takes in an object and a value. It should scan the object and return the first key which contains the given value, if not , returns undefined.letterPositions()
: returns all the indicies in the string where each character is found.Map()
: Takes in an array and a callback and returns a new array based on the results of the callback function.reverseString()
: takes in a string, and prints it in reversetakeUntil()
: Takes in an Array and a Callback, returns a slice of the array taken from the beginning until the callback function returns a truthy value.without()
: Takes in an array and itemsToRemove returning a subset of a given array, removing unwanted elements.
version "1.0.0"
description
author
hass0319
head(arr)
: Retrieves the first element of an array.tail(arr)
: Retrieves all other elements except the head.middle(array)
: Takes in an array and returns the middle-most elements.flatten(array)
: Takes in an array of arrays and returns a single array.