Catalog npm
Back to packageRELEASE DETAILS

0.2.0

npm

2belt

Useful utility functions with strong FP support

Published9 Jan 2019
Direct dependencies8
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 8

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@babel/cli
Environment
{
  "local_name": "@babel/cli",
  "alias": false,
  "peer_metadata": null
}
^7.2.3development
@babel/core
Environment
{
  "local_name": "@babel/core",
  "alias": false,
  "peer_metadata": null
}
^7.2.2development
@babel/preset-env
Environment
{
  "local_name": "@babel/preset-env",
  "alias": false,
  "peer_metadata": null
}
^7.2.3development
babel-preset-minify
Environment
{
  "local_name": "babel-preset-minify",
  "alias": false,
  "peer_metadata": null
}
^0.5.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^5.3.0development
eslint-config-airbnb-base
Environment
{
  "local_name": "eslint-config-airbnb-base",
  "alias": false,
  "peer_metadata": null
}
^13.1.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.14.0development
undefined
Environment
{
  "local_name": "undefined",
  "alias": false,
  "peer_metadata": null
}
^0.1.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-7r/cqcBseS6fYcKowtL7/4MDfK5EabzKWHvhlgMqTo9tVpzTTAy69/3ZydUWYar/34SPfCb0fwuhKR7/tHhWUw==",
  "shasum": "49b30c3e6db62966d5cf0405d2411d2a7a80f1bc",
  "tarball": "https://registry.npmjs.org/2belt/-/2belt-0.2.0.tgz",
  "fileCount": 23,
  "unpackedSize": 9202,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcNlLFCRA9TVsSAnZWagAAlRUP/3sQ+HLgwBNTLle32wsx\n2LVHfC6M4FgjYSCZSL8hhqU4VMdnwpx3Ctw+VLK7IZWKQKilyJYUTkSKt91+\nE28Jbw9JKgDZCd2MJhdsrxihhf9sEGn4+8jZ1t02XO4hUJD9YasMn3vh56/f\n7yCBtaMp/FbliokCEDf7Vs0GTFVNdFbJfqXVkvIzs43YvPPHOIAC7vukSBSw\nypSt/pnVIAbI/xcUYBgvZ5WOFzcxRGxMQdi4wKIHBGQHEyGZg1W4jnIoMb0N\npKJ5VeMZfIzxkeNbFMGCSj1N8Ex6fGkh18Z5rhqLyg+U4nSA+wXGZkB+eG96\n2x+0NxVJYcm02pvvBIMlbkKYjZEM7WKca5+3w05uZwqYCL7iKDSjEFiZQmZp\nFfltWXs21lJVJ38D6iSdTNm9JazbRyV5TL2lfm8FQs0nn/l5RiTXwL8Xx9TG\nybMgmfXHlnGRhFZM3tOZidLtcgtNuebvYLnNkVZAE6qenwbrSRHKDn797EJz\ntbsjhiyhc7MgDFWsdGNrNnMY5N/Dgn+3p/hmk8sP48Jn3H7klMwNG7ykHdyM\nRBTYUrTJ/e0yJYAgpjqm25LFknaMuIAfKiqcYHB8D5SWupeiGYDHfOwCpzeF\nKAHd1rTx0WBYSSQWAMo0BSl+97kTEB5ed1k/ZlR9AAk63fZ32BwH3wYzTcUT\nYvx7\r\n=HJbD\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIDJTHizGfSZW/iIlAr/J0C0A52l4DwstgvTxgDq0pKOOAiBxyjA9I8teU8WXIqhdQs2ru0YW/yJKDdDv0fcBR0LNhw=="
    }
  ]
}

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:4d6384189b1f024dff7bdfde1998d77dfc5c7f0296943c24ffc4654c0d045cb5

Other collected versions

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