Skip to content

πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’» Some handy javascript utilities we use

License

Notifications You must be signed in to change notification settings

publicstrategies/js-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

js-utils

Build Status Coverage Status

Functions

arrayOf(array, key) β‡’ Array.<any>

Takes an array of any objects and accumulates an array of a shared property between them.

sumOf(array, ...keys) β‡’ number

Takes an array of any objects and recursively adds a shallow or complex property shared between them.

arrayOf(array, key) β‡’ Array.<any>

Takes an array of any objects and accumulates an array of a shared property between them.

Param Type Description
array Array.<any>

The array of objects with a shared property.

key string

The property accessor for the objects in the array.

Example

const data = [{ name: "John", id: 1 }, { name: "Jane", id: 2 }];

arrayOf(data, "name"); // ["John", "Jane"]
arrayOf(data, "id"); // [1, 2]

sumOf(array, ...keys) β‡’ number

Takes an array of any objects and recursively adds a shallow or complex property shared between them.

Param Type Description
array Array.<any>

The array of objects with a shared shallow or nested property.

...keys string

The property accessor(s) for the objects in the array.

Example

const data = [{ nested: { value: 12 } }, { nested: { value: 34 } }];

sumOf(data, "nested", "value"); // 46

About

πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’» Some handy javascript utilities we use

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published