Skip to content

findhit/util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"}'

About

Library of daily-needed utils for javascript developers.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors