šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

fmrs

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fmrs

filters/finds, maps, reduces, and sorts

2.0.4
latest
Source
npm
Version published
Weekly downloads
1.9K
13.7%
Maintainers
0
Weekly downloads
Ā 
Created
Source

filter/find, map, reduce, sort

CI/CD version downloads

fmrs is a collection of utility functions that filter/find, map, reduce, and sort JavaScript primitives and built-ins between each other.

For example:

  • Mapping the boolean true to a string would be 'true'.
  • Reducing the entries [['key', 'value']] to a record would be { key: 'value' }.
  • Sorting the values 1 and 2 would be -1.

Filters and finders

  • boolean (value is boolean)
    • arr.every(isBoolean)
    • arr.filter(filterByBoolean)
    • arr.find(findBoolean)
  • defined
    • arr.every(isDefined)
    • arr.filter(filterByDefined)
    • arr.find(findDefined)
  • number (value is number)
    • arr.every(isNumber)
    • arr.filter(filterByNumber)
    • arr.find(findNumber)
  • object (value is object)
    • arr.every(isObject)
    • arr.filter(filterByObject)
    • arr.find(findObject)
  • record (value is Record<number | string | symbol, unknown>)
    • arr.every(isRecord)
    • arr.filter(filterByRecord)
    • arr.find(findRecord)
  • string
    • arr.every(isString)
    • arr.filter(filterByString)
    • arr.find(findString)
  • undefined (value is undefined)
    • arr.every(isUndefined)
    • arr.filter(filterByUndefined)
    • arr.find(findUndefined)

Mappers

fromtoexample
booleannumber[false, true].map(mapBooleanToNumber)
entriesRecord ({})mapEntriesToRecord([['key', 'value']])
entrykeymapEntryToKey(['key', 'value'])
entryvaluemapEntryToValue(['key', 'value'])
MapentriesmapMapToEntries(new Map())
MapRecord ({})mapMapToRecord(new Map())
unknownErrorarr.map(mapToError)
unknownindexarr.map(mapToIndex)
unknownstringarr.map(mapToString)

Reducers

fromtoexample
entriesRecord ({})Object.entries(record).reduce(reduceEntriesToRecord, {})

Sorters

itemsexample
ArrayarrOfArrs.sort(sortByIndex(0))
numberarr.sort(sortNumbers)
stringarr.sort(sortStrings)
unknownarr.sort(sort)

Utilities

functionexample
is['a', 'b'].filter(is('a'))
isNot['a', 'b'].filter(isNot('a'))
not['a', 'b'].filter(not(is('a')))

FAQs

Package last updated on 11 Mar 2025

Did you know?

Socket

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.

Install

Related posts