JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29407
  • Score
    100M100P100Q145738F
  • License GPL v3

general propose utils for javascript

Package Exports

  • findhit-util

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (findhit-util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

findhit-util

general propose utils for javascript, to score on top of underscore!

Used on multiple libraries, no one want to reinvent the wheel everytime we need it.

Instalation

npm install findhit/findhit-util --save

Usage

var Util = require('findhit-util');

Core


var id = Util.uniqId();

Util.forEach( obj, function ( key ) {
    // ...
});

Util.map( obj, function ( key ) {
    // return ...
});

Is / Isn't

// Fast variable checks

if( Util.is.function( callback ) ) {
    // ...
}

if( Util.isnt.function( callback ) ) {
    // throw new Error
}

/*

    We also support other checks like:

    - Util.is.array
    - Util.is.object
    - Util.is.error
    - Util.is.string
    - Util.is.number // Util.is.numeric

*/

From

// Parse from a variable type to the most probably type

var obj = Util.from.String( '{"foo":"bar"}' ); // returns (object) { foo: 'bar' }

var bool = Util.from.String( 'true' ); // returns (bool) true

To

// Convert to a variable to a specific type

var json = Util.to.String( { foo: 'bar' } ); // returns (string) '{"foo":"bar"}'