@activimetrics/utils-composite 中文文档教程
@activimetrics/utils-composite
复合实用程序(不可变性、fp 助手)
注意:API 中描述的所有函数都是科里化的
注意:从 jumpn 派生/utils-composite 以升级依赖
- Installation
- Using npm
- Using yarn
- Types
- API
- get
- getIn
- getKeys
- hasIn
- hasKey
- haveSameProps
- is
- isEmpty
- map
- arrayRemove
- remove
- removeIn
- set
- setIn
- shallowCopy
- shallowEqual
- toUndefinedIfEmpty
- updateIn
- License
Installation
Using npm
$ npm install --save @activimetrics/utils-composite
Using yarn
$ yarn add @activimetrics/utils-composite
Types
type Composite = Array<*> | Object;
type Key = number | string;
type Path = Array<Key>;
API
get
项获取给定键的属性值。
Parameters
key
Keycomposite
Composite
返回 any
getIn
返回位于给定路径或未定义的值。
Parameters
path
Pathcomposite
Composite
返回 any
getKeys
获取自己的可枚举键。
Parameters
composite
Composite
返回 Array
hasIn
如果找到值则返回真at given path 深深地等于那个 指定的。
Parameters
path
Pathvalue
anycomposite
Composite
返回 boolean
hasKey
如果键包含在组合自身中,则返回 true可数的, 否则为假。
Parameters
key
Keycomposite
Composite
返回 boolean
haveSameProps
如果两个组合具有相同的属性则返回 true否则为假。
Parameters
c1
Compositec2
Composite
返回 boolean
is
如果参数是 Composite 或 false,则返回 true otherwise
Parameters
thing
any
isEmpty
如果 composite 没有自己的可枚举键(为空)或 false,则返回 true 否则
Parameters
composite
Composite
返回 boolean
map
使用映射器映射给定组合的值
Parameters
mapper
function (value: any, key: Key, composite: $Supertype<C>): anycomposite
C
返回 $Supertype
arrayRemove
返回一个新数组,其中包含已删除指定数量的结果 给定索引处的(计数)元素。
Parameters
remove
返回一个新的组合,其结果是删除了属性 给定的键。
Parameters
key
Keycomposite
Composite
返回 Composite
removeIn
返回一个新的组合,其结果是删除了属性 位于给定路径。
(这与使用更新程序调用 updateIn 的效果相同: <代码>() => updateIn.remove)
Parameters
path
Pathcomposite
Composite
返回 Composite
set
返回一个新的组合,其结果是更新了属性 具有指定值的给定键。
Parameters
key
Keyvalue
anycomposite
Composite
返回 Composite
setIn
返回具有更新属性结果的新组合 位于具有指定值的给定路径。
(这与使用更新器调用 updateIn 的效果相同:() => value
Parameters
path
Pathvalue
anycomposite
Composite
>
shallowCopy
)给定的道具。
Parameters
composite
C
返回 C
shallowEqual
如果两个组合的类型相同(数组或对象)并且 它们的属性严格相等。
Parameters
c1
Compositec2
Composite
返回 boolean
toUndefinedIfEmpty
返回给定的组合,如果它有任何自己的可枚举键(不为空)或 undefined otherwise
Parameters
composite
Composite
Returns Composite
updateIn
返回一个新的组合,其结果是更新了属性值 在给定路径上调用更新程序函数的结果。
通过在更新程序上返回 updateIn.remove
符号来支持条目删除 功能。
Parameters
path
Pathupdater
function (prev: any): anycomposite
Composite
返回 Composite
License
MIT :copyright: 2020 James Marca / (), 2017 Jumpn Limited
@activimetrics/utils-composite
Composite utilities (immutability, fp helpers)
NOTE: All the functions described in API are curried
NOTE: forked from jumpn/utils-composite in order to upgrade dependencies
- Installation
- Using npm
- Using yarn
- Types
- API
- get
- getIn
- getKeys
- hasIn
- hasKey
- haveSameProps
- is
- isEmpty
- map
- arrayRemove
- remove
- removeIn
- set
- setIn
- shallowCopy
- shallowEqual
- toUndefinedIfEmpty
- updateIn
- License
Installation
Using npm
$ npm install --save @activimetrics/utils-composite
Using yarn
$ yarn add @activimetrics/utils-composite
Types
type Composite = Array<*> | Object;
type Key = number | string;
type Path = Array<Key>;
API
get
Get property value of given key.
Parameters
key
Keycomposite
Composite
Returns any
getIn
Returns value located at the given path or undefined otherwise.
Parameters
path
Pathcomposite
Composite
Returns any
getKeys
Get own enumerable keys.
Parameters
composite
Composite
Returns Array<Key>
hasIn
Returns true if value located at given path is deeply equal to the one specified.
Parameters
path
Pathvalue
anycomposite
Composite
Returns boolean
hasKey
Returns true if key is included in composite's own enumerable ones, or false otherwise.
Parameters
key
Keycomposite
Composite
Returns boolean
haveSameProps
Returns true if both composites have the same props or false otherwise.
Parameters
c1
Compositec2
Composite
Returns boolean
is
Returns true if parameter is a Composite or false otherwise
Parameters
thing
any
isEmpty
Returns true if composite has no own enumerable keys (is empty) or false otherwise
Parameters
composite
Composite
Returns boolean
map
Maps values of the given composite using mapper
Parameters
mapper
function (value: any, key: Key, composite: $Supertype<C>): anycomposite
C
Returns $Supertype<C>
arrayRemove
Returns a new Array with the result of having removed the specified amount (count) of elements at the given index.
Parameters
remove
Returns a new composite with the result of having removed the property with the given key.
Parameters
key
Keycomposite
Composite
Returns Composite
removeIn
Returns a new composite with the result of having removed the property located at the given path.
(This does the same as calling updateIn with updater: () => updateIn.remove
)
Parameters
path
Pathcomposite
Composite
Returns Composite
set
Returns a new composite with the result of having updated the property with the given key with the specified value.
Parameters
key
Keyvalue
anycomposite
Composite
Returns Composite
setIn
Returns a new composite with the result of having updated the property located at the given path with the specified value.
(This does the same as calling updateIn with updater: () => value
)
Parameters
path
Pathvalue
anycomposite
Composite
Returns Composite
shallowCopy
Returns a new composite with the same own enumerable props of the one given.
Parameters
composite
C
Returns C
shallowEqual
Returns true if both composites are of the same type (Array or Object) and their properties are strictly equal.
Parameters
c1
Compositec2
Composite
Returns boolean
toUndefinedIfEmpty
Returns given composite if it has any own enumerable keys (is not empty) or undefined otherwise
Parameters
composite
Composite
Returns Composite
updateIn
Returns a new composite with the result of having updated the property value at the given path with the result of the call to updater function.
Entry removal is supported by returning updateIn.remove
symbol on updater function.
Parameters
path
Pathupdater
function (prev: any): anycomposite
Composite
Returns Composite
License
MIT :copyright: 2020 James Marca / (), 2017 Jumpn Limited
你可能也喜欢
- 2d-spirograph 中文文档教程
- 6nimmt-utils 中文文档教程
- @2hats/react-native-photo-view 中文文档教程
- @2o3t/koa2-proxy-middleware 中文文档教程
- @3dprogramin/tasktracker 中文文档教程
- @3yourmind/sass-node-modules-importer 中文文档教程
- @a-cloud-guru/serverless-import-tags 中文文档教程
- @a-soul/extractor-douyin 中文文档教程
- @aaronlutze/nine-immersive-header 中文文档教程
- @aasaanjobs/style42 中文文档教程