You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fmrs

Package Overview
Dependencies
Maintainers
1
Versions
10
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.5
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
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 23 Jun 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