npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stunsail

v1.0.0-rc.8

Published

Super opinionated, functional utility collection.

Downloads

31

Readme

stunsail · Version License Travis CI JavaScript Standard Style

Super opinionated, functional utility collection.

installation

# using yarn:
yarn add stunsail

# or npm:
npm i stunsail

usage

import S from 'stunsail'

// commonjs / ES5
const S = require('stunsail')

A module version is also available if you use ES modules:

import S from 'stunsail/es'

You can also selectively import just what you need, which is especially recommended if you use the babel plugin as this is much more efficient.

import { defaults, kebabCase, matches, toArray } from 'stunsail'

const { defaults, kebabCase, matches, toArray } = require('stunsail')

api

See the documentation here for a more complete reference.

overview

import {
  clamp,
  map,
  filter,
  first,
  matches,
  pipe,
  toNumber
} from 'stunsail'

const number = pipe(
  '36',
  num => toNumber(num),      // -> 36
  num => clamp(num, 10, 30), // -> 30
  num => console.log(num)    // -> 'number = 30'
)

const found = pipe(
  map([1, 2, 3, 4, 5], num => ({ value: num * 2 })),
  // -> [{ value: 2 }, { value: 4 }, ... ]
  objects => filter(objects, obj => matches(obj, { value: 6 })),
  // -> [{ value: 6 }]
  objects => first(objects),
  // -> { value: 6 }
  obj => console.log(obj.value)
  // -> 6
)

with param.macro

stunsail is really fun to use alongside param.macro — a Babel plugin that lets you partially apply functions at compile time. You can make the above example look like this:

import { _, it } from 'param.macro'
import {
  clamp,
  map,
  filter,
  first,
  matches,
  pipe,
  toNumber
} from 'stunsail'

const number = pipe(
  '36',
  toNumber(_),
  clamp(_, 10, 30),
  console.log(`number = ${_}`)
)

const found = pipe(
  map([1, 2, 3, 4, 5], { value: it * 2 }),
  filter(_, matches(_, { value: 6 })),
  first(_),
  console.log(_.value)
)

This combo allows you to use stunsail like you would lodash/fp or Ramda, but without the runtime performance hit that comes with an auto-curried library.

babel plugin

stunsail ships with a babel plugin included. It can be used like so:

babel v7

.babelrc.js

module.exports = {
  presets: [],
  plugins: ['module:stunsail/babel']
}

babel v6

.babelrc

{
  "presets": [],
  "plugins": ["stunsail/babel"]
}

This will allow you to write simpler imports but output and still benefit from more efficient alternatives, ie:

import { partition } from 'stunsail'

// commonjs / ES5
const { partition } = require('stunsail')

... will be compiled to:

import partition from 'stunsail/partition'

// commonjs / ES5
const partition = require('stunsail/partition')

import statements can optionally be compiled to equivalent require calls to avoid adding a module transformer separately.

configuration

Optionally configure the plugin by using an Array of [pluginName, optionsObject]:

module.exports = {
  presets: [],
  plugins: [
    ['module:stunsail/babel', {
      useRequire: false,
      useModules: true
    }]
  ]
}

| property | type | default | description | | :----------: | :-------: | :-----: | ----------- | | useRequire | Boolean | false | Whether to convert import statements to requires. Has no effect on require calls. | | useModules | Boolean | false | Redirect stunsail imports to stunsail/es. Ignored if useRequire is set to true. |

see also

  • param.macro – Babel plugin for compile-time partial application and lambda parameters
  • tryad – Monadic mashup of Maybe & Either (Option/Result) for more functional null & error handling

contributing

Search the issues if you come across any trouble, open a new one if it hasn't been posted, or, if you're able, open a pull request. Contributions of any kind are welcome in this project.

license

MIT © Bo Lingen / citycide