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

underline

v1.0.4

Published

Bound underscore functions

Downloads

455

Readme

Underline.js - Underscore.js for modern Javascript

npm package Dependency Status

Using modern ES7 functional bind :: syntax you can now call the underscore.js function the 'right' or non-functional way. underline.js is a thin layer between your code and underscore.js which binds all underscore functions called to the target object.

Example

import { difference, all, keys, pluck } from 'underline'; // Require functions needed

// Differece of arrays
[12, 1, 2, 3, 10, 11]::difference([10, 11, 12])
// => [1, 2, 3]

// Check for all elements are less than 10
[1, 2, 3, 10]::all((e) => e < 10)
// => false

// Extract Keys
{ a: 1, b: 2 }::keys()
// => ["a", "b"]

// Pluck property
[
  {name: 'moe', age: 40},
  {name: 'larry', age: 50},
  {name: 'curly', age: 60}
]::pluck('name')
// => ["moe", "larry", "curly"]

/////
// VS
/////

// Underscore way for difference
_.difference([12, 1, 2, 3, 10, 11], [10, 11, 12])

// all
_.all([1, 2, 3, 10], (e) => e < 10)

// keys
_.keys({ a: 1, b: 2})
// OR
Object.keys({ a: 1, b: 2})

// and pluck
_.pluck([
  {name: 'moe', age: 40},
  {name: 'larry', age: 50},
  {name: 'curly', age: 60}
], 'name')

Underline supports chaining without wrapping like underscore

// Chaining difference and all
[12, 1, 2, 3, 10, 11]::difference([10, 11, 12])
                     ::all((e) => e < 10)
// => true

/////
// VS
/////

// Too much typing to chain in underscore and get its value
_.chain([12, 1, 2, 3, 10, 11]).difference([10, 11, 12])
                              .all((e) => e < 10)
                              .value()

Try it

Try it out in the REPL

Usage

To get started you will need to use Babel transpiler with experimental feature es7.functionBind enabled. Then:

  1. Install this library using npm - npm install --save underline
  2. Import functions as needed - import { map } from 'underline'
  3. Call a function using :: operator as such [1, 2, 3]::map((e) => e * 10)

Functions Available

All of the functions available in underscore.js are available in underline.js.

  • iteratee
  • forEach
  • each
  • collect
  • map
  • inject
  • foldl
  • reduce
  • foldr
  • reduceRight
  • detect
  • find
  • select
  • filter
  • reject
  • all
  • every
  • any
  • some
  • include
  • includes
  • contains
  • invoke
  • pluck
  • where
  • findWhere
  • max
  • min
  • shuffle
  • sample
  • sortBy
  • groupBy
  • indexBy
  • countBy
  • toArray
  • size
  • partition
  • take
  • head
  • first
  • initial
  • last
  • drop
  • tail
  • rest
  • compact
  • flatten
  • without
  • unique
  • uniq
  • union
  • intersection
  • difference
  • zip
  • unzip
  • object
  • findIndex
  • findLastIndex
  • sortedIndex
  • indexOf
  • lastIndexOf
  • range
  • bind
  • partial
  • bindAll
  • memoize
  • delay
  • defer
  • throttle
  • debounce
  • wrap
  • negate
  • compose
  • after
  • before
  • once
  • keys
  • allKeys
  • values
  • mapObject
  • pairs
  • invert
  • methods
  • functions
  • extend
  • assign
  • extendOwn
  • findKey
  • pick
  • omit
  • defaults
  • create
  • clone
  • tap
  • isMatch
  • isEqual
  • isEmpty
  • isElement
  • isArray
  • isObject
  • isArguments
  • isFunction
  • isString
  • isNumber
  • isDate
  • isRegExp
  • isError
  • isFinite
  • isNaN
  • isBoolean
  • isNull
  • isUndefined
  • has
  • noConflict
  • identity
  • constant
  • noop
  • property
  • propertyOf
  • matches
  • matcher
  • times
  • random
  • now
  • escape
  • unescape
  • result
  • uniqueId
  • templateSettings
  • template
  • chain
  • mixin