Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

2belt

Useful utility functions with strong FP support

Published27 Apr 2022
Direct dependencies9
Transitive dependenciesNot calculated

README

Current package documentation

2belt

A library of higher order functions that is immutable, minimalist and versatile

Under construction

This module is still under internal development. We are working on:

  • firming up the API
  • tree shaking
  • usable in all browsers

Available functions

  • filter(obj, fn(val, key))
  • reject(obj, fn(val, key))
  • map(obj, fn(val, key))
  • remap(obj, fn(val, key))
  • shuffle(arr)
  • sortBy(arr, key, desc?)
  • toPairs(obj)
  • fromPairs(arr)
  • groupBy(arr, keyFn, valFn)

How to use

Let's try to make it compatible with both CommonJS and ES6 module systems, with the following emphasis:

  • Default is CommonJS
  • CommonJS allows cherry pick
  • We'll keep it this way for 2belt foreverish, so users are not screwed by breaking changes

Possible usage patterns are:

const { filter, reject } = require('2belt');
const filter = require('2belt/filter');
const belt = require('2belt');

import * as belt from '2belt/es';
import { filter, reject } from '2belt/es';

If we ever decide to use module names like Enum, List etc, it would become

const { Enum, List } = require('2belt');
const { filter, reject } = require('2belt/Enum');
const Enum = require('2belt/Enum');
const filter = require('2belt/Enum/filter');

import { Enum, List } from '2belt/es';

Likelihood of using module names

For a standard library, making the user import each function individually is somewhat inconvenient. For example, if there are only 4 modules total, the user can always just import those 4 modules and be done, like in Elixir. The downside of housing the functions under modules is that the user has to search through the different modules for a function. Also it is somewhat convenient to have functions that work across different object types.

Decision:

  • let's stay with no module name for now
  • if the number of functions grow, we should move into modules because
    • there would be too many functions for users to import individually
    • it would be harder to remember without organization
  • unless we decide we want user to do import * as belt from '2belt/es';

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 9

Native requirements
9 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
terser
Environment
{
  "local_name": "terser",
  "alias": false,
  "peer_metadata": null
}
^5.13.0runtime
@babel/cli
Environment
{
  "local_name": "@babel/cli",
  "alias": false,
  "peer_metadata": null
}
^7.17.6development
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
^7.17.9development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
^7.16.11development
babel-preset-minify
Environment
{
  "local_name": "babel-preset-minify",
  "alias": false,
  "peer_metadata": null
}
^0.5.1development
es-check
Environment
{
  "local_name": "es-check",
  "alias": false,
  "peer_metadata": null
}
^6.2.1development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.14.0development
eslint-plugin-es5
Environment
{
  "local_name": "eslint-plugin-es5",
  "alias": false,
  "peer_metadata": null
}
^1.5.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.26.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-TVvJhYcL8FkcVV2oTwnilseKk5VMFKDcXtoR83P3XIiP69NGMds14wYWZ7g2qCmmeUm2Ck1LkNZACsnqKk2Mow==",
  "shasum": "c633e55e47e1a571c146424ab8565cd7affdce70",
  "tarball": "https://registry.npmjs.org/2belt/-/2belt-1.0.0.tgz",
  "fileCount": 5,
  "unpackedSize": 5170,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIApjWY64vYBLOGtjqO/gDs04vsOKwEZo3Kgofuy0HSzQAiEA63HE7NUKs+AYDSLtRGC4ogH2VGmaxMdwF/3qC1HLbMg="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiabNwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqHixAAh+xScZG2CixFzRsnLdJDM3IzB9dyi6AZZaknLbIsffVBu/kx\r\n9Fe6QLwbcATLGPbPrM3vRs8rJ9TKA0QJI3JTvG2H3GSY04CB02dIZGSuHRGe\r\nc9hZpgqbBVJqVNc2DnAEkv3OLQi8eGEYyySgjjpBPgD1xglhHVRnGHRzY2VP\r\ngty4zXDYs11c4djmxSZJwA4APQVok7+p8ekz1p+GLeHmgF/5HDj1nwuuPaKF\r\nMEgI8+5eUWnWiq4Nf8UDxjNmpzpiqA4ish0mCZGXQ5BIKVhNuPVqgMsS8XOU\r\n0GpDaulzaAkljfmHbyScaHI5Lci4hJ26z8koZFTaLCE9G8Zv5uku7js+/Xiy\r\nnijeQVNVNhmPdHmkop0mIU6Syssu/dTx221st725XUEIqP8CpFfQTsN+9dQH\r\nwsQIUHy1TEjOYLTcjGKedFFkGfH2F2kk0HwOZ5/FlNeWF0R+QKnFKlGGOUSU\r\nTcHipDNeRv4Smg2ZkRmhCKzZDAh8bRyMo8SiLORINclN2uz78w/8sOFj/rv3\r\nxO04iH5zvMkQ5uelSTipcr+GJvGqFnZGPgjK4TGC7nN96BVYB6jjHdDXBF0G\r\njtL67JPdC80Ote+pzYooMLLYrJdlpV08piW330hKZCWAA1a9FWtdO+FkuKo5\r\nXNF9ZclOkRfOHziyAqa40bhoFZDrVUg/PWI=\r\n=rkOD\r\n-----END PGP SIGNATURE-----\r\n"
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:08 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:5fcab73dbd893bedd942f75c446b092f4db1af207c59a585b7d50392b473a8dd

Other collected versions

1.0.128 Apr0.2.110 Jan0.2.09 Jan0.1.314 Apr0.1.213 Apr0.1.121 MarView all collected versions →