Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
obj-each-break
Advanced tools
each, map, filter, reduce and reverse version with break and return emulation adapted to objects
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 113 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.