Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
obj-each-break
Advanced tools
Readme
Small utility library implementing each
, map
, filter
, and their reverse versions for
Arrays and Objects on all own properties not just integer indexed ones. Uses for-each-break
to
create break and return emulation as if it was a regular for
or while
loop.
To simulate break return BREAK
or RETURN
, to simulate return
return BREAK(value)
or
RETURN(value)
both are equivalent but the one communicating the right intent should be used.
The functions assume this
is an array or object so they should be invoked with
.call(arrayLike, callback)
defines:
eachProp
- invoke callback for each own property, order looping over the properties is not definedhasOwnProperties
- true if has any own non-undefined propertiesarrayObjectKeys
- collect array like indexed values and keys from both objects and arrays returns { arrayValues: [], objectKeys: [], }
where arrayValues
is an array of property values for integer>=0 props and objectKeys other own property keyseachDir
- property looping where direction is provided as an argumenteach
- invoke callback for each own property, first array index like properties in increasing index order then own properties in natural sort ordereachRight
- invoke callback for each own property, first own properties in reverse natural sort order then array index like properties in decreasing index ordercloneArrayObject
- clone array or object with all own propertiesdeleteItems
- delete items in an array, arguments are deep flattenedarrayLength
- return array like length for an object or arraydeepClone
- deep clone array or objectmergeDefaults
- merge defaults into object propertiescopyFiltered
- copy properties chosen by filtercopyFilteredNot
- copy properties not chosen by filterobjFiltered
- filter for object/array own properties, not only integer indexed properties, result is object/array depending on this for callobjFilter
- filter for object/array own properties, not only integer indexed properties, result is an arrayobjMapped
- object map for object/array own properties, not only integer indexed properties, result is object/array depending on this for callobjMap
- map for object/array own properties, not only integer indexed properties, result is arrayobjSome
- some for object/array own propertiesobjEvery
- some for object/array own propertiesobjReduceIterated
- reduce taking iteration functions and callbackobjReduce
- reduce for object/array own properties, order of looping over properties not definedobjReduceLeft
- reduce for object/array own properties, order of looping over properties is same as each
objReduceRight
- reduce for object/array own properties, order of looping over properties same as eachRight
For convenience for-each-break
module's exports are re-exported:
BREAK
- used to break or return from loop, using BREAK
to break out of loop is preferred since it communicates clear intentionRETURN
- used to break or return from loop, using RETURN
to break out of loop and return a value is preferred since it communicates clear intentionfilter
- use to filter array like object, with early break or return: filter.call(arrayLike, callback, thisArg)
forEach
- use to loop over array like object: forEach.call(arrayLike, callback, thisArg, defaultReturn)
map
- use to map array like object, with early break or return: map.call(arrayLike, callback, thisArg)
filterRight
- use to filter array like object in reverse, with early break or return: filter.call(arrayLike, callback, thisArg)
forEachRight
- use to loop over array like object in reverse: forEach.call(arrayLike, callback, thisArg, defaultReturn)
mapRight
- use to map array like object in reverse, with early break or return: map.call(arrayLike, callback, thisArg)
Use npm to install.
npm install obj-each-break --save
MIT, see LICENSE.md for details.
FAQs
each, map, filter, reduce and reverse version with break and return emulation adapted to objects
The npm package obj-each-break receives a total of 40 weekly downloads. As such, obj-each-break popularity was classified as not popular.
We found that obj-each-break demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.