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

ufunc

v2.0.1

Published

Ufunc is a set of JavaScript functional methods

Downloads

207

Readme

Ufunc

Ufunc is a set of JavaScript functional methods.

NOTE: No longer depends on Ramda;

Installation

$ npm install ufunc

Usage

Add the module to the script via ES5 or ES6

ES6
import ufunc from 'ufunc';

ES5
var ufunc = require('ufunc');

Functions

clean

Revome all null and undefined items from array.

clean([0, 1, null, 2, undefined, 3]);
//=> [0, 1, 2, 3]

cleanAll

Revome all null and undefined items from list.

utils.cleanAll([0, 1, null, 2, undefined, 3]);
//=> [1, 2, 3]

cleanObj

Revome all null, undefined and 0 Key/value pairs from object.

cleanObj({a: 1, b: undefined, c: null, d: 'otis', e: 0});
//=> {a: 1, d: 'otis', e:0}

cleanObjAll

Revome all null, undefined and 0 Key/value pairs from object.

cleanObjAll({a: 1, b: undefined, c: null, d: 'otis', e: 0});
//=> {a: 1, d: 'otis'}

filterObjetsInList

Filters a list of objects by using another list of objects as the criteria.

var fn = (c, s) => {
  if (c.user === s.name) {
    return s;
  }
};

var criteria = [
  {user: 'Otis'}
];

var search = [
  {name: 'Otis', message: 'hello'},
  {name: 'Ania', message: 'hi'},
  {name: 'Otis', message: 'What time do you finish work'},
  {name: 'Ania', message: 'around 6pm'}
];

filterObjetsInList(fn, criteria, search)();
//=>
// [
//   {name: 'Otis', message: 'hello'},
//   {name: 'Otis', message: 'What time do you finish work'}
// ]

fmap

Maps a function over a container and returns a new container.

fmap(x => x + 3, container, 10)();
//=> { value: 13 }


fmap(x => x + 3, container)();
//=> { value: null }

either

Executes left if any of the condition are true, else right if false.

either('left', 'right')(true),
//=> 'left'


either(() => 'left', () => 'right')(true);
//=> 'left'


either('left', 'right')(false);
//=> 'right'


either(() => 'left', () => 'right')(false);
//=> 'right'


either([true, false])('left', 'right');
//=> 'left'


either([true, false])(() => 'left', () => 'right');
//=> 'left'


either([false, false])('left', 'right'),
// 'right'


either([false, false])(() => 'left', () => 'right');
//=> 'right'

maybe

Returns if value is truthy, else null.
An optional second argument can be passed to be used as the return value if false.

maybe()('Jack Bower');
//=> 'Jack Bower'


maybe()(null);
//=> null


maybe([])(null);
//=> []

maybeIf

Returns if value is condition is truthy, else null.
An optional second argument can be passed to be used as the return value if false.

maybeIf('Jack Bower')(true);
//=> 'Jack Bower'


utils.maybeIf(null)();
//=> null


maybeIf(null)(false, []),;
//=> []

pickPairsFromList

Picks keys/values out of an array of objects.

var fixtures = [
  {user: 'user1', id: 'id1', email: '[email protected]', status: 'online', name: 'Bill'},
  {user: 'user2', id: 'id2', email: '[email protected]', status: 'online', name: 'Jane'},
  {user: 'user3', id: 'id3', email: '[email protected]', status: 'offline', name: 'Marry'},
  {user: 'user4', id: 'id4', email: '[email protected]', status: 'offline', name: 'Larry'}
];

pickKeyValuesFromList(['id', 'email', 'status'], fixtures);
//=>
// [
//   {id: 'id1', email: '[email protected]', status: 'online'},
//   {id: 'id2', email: '[email protected]', status: 'online'},
//   {id: 'id3', email: '[email protected]', status: 'offline'},
//   {id: 'id4', email: '[email protected]', status: 'offline'}
// ]

License

MIT