Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-util

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-util

This module provides the functionality to perfrom the basic operations on strings, arrays, and objects.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
47
decreased by-50.53%
Maintainers
1
Weekly downloads
 
Created
Source

type-util

Version Build Status
ISSUES FORKS STARS Downloads
License

A utility package which provides the basic functions based on arrays, strings, and objetcs

Table of Contents

Installation
Usage
Issues or Suggestions
License

Installation

Install stable version from NPM:

npm install type-util --save

Usage

###isEmpty(data) returns if an array, string , or object is empty

var util = require('type-util');
if(util.isEmpty([])) console.log('isEmpty'); else console.log('!isEmpty'); 
if(util.isEmpty('')) console.log('isEmpty'); else console.log('!isEmpty'); 
if(util.isEmpty({})) console.log('isEmpty'); else console.log('!isEmpty'); 

###isString(data) returns if data is a string

var util = require('type-util');
if(util.isString(['key1','key2'])) console.log('isString'); else console.log('!isString'); 
if(util.isString({key:'value'})) console.log('isString'); else console.log('!isString'); 
if(util.isString('here is the string')) console.log('isString'); else console.log('!isString'); 

###isObject(data) returns if data is an object

var util = require('type-util');
if(util.isObject({a:'b'})) console.log('isObject'); else console.log('!isObject'); 
if(util.isObject(['key'])) console.log('isObject'); else console.log('!isObject'); 
if(util.isObject('key')) console.log('isObject'); else console.log('!isObject'); 

###isArray(data) returns if data is an array

var util = require('type-util');
if(util.isArray([0,2,8])) console.log('isArray'); else console.log('!isArray'); 
if(util.isArray('0,2,8')) console.log('isArray'); else console.log('!isArray'); 
if(util.isArray({a:'b'})) console.log('isArray'); else console.log('!isArray'); 

###isFunction(data) returns if data is a function

var util = require('type-util');
if(util.isFunction(function(example){ /*Just an example*/  })) console.log('isFunction'); else console.log('!isFunction'); 
if(util.isFunction({})) console.log('isFunction'); else console.log('!isFunction'); 
if(util.isFunction('')) console.log('isFunction'); else console.log('!isFunction'); 

###lengthOf(data) returns if length of data whether it's a string, an array, or an object

var util = require('type-util');
console.log(util.lengthOf({a:'b',c:'d',e:{f:{g:'h'}}}));
console.log(util.lengthOf([5,6,4,8,9,77,84,90,7]));
console.log(util.lengthOf('this is a string'));

###find(data, key) returns if a string, property, or key is found in data.

var util = require('type-util');
console.log(util.find({a:'b',c:'d',e:{f:{g:'h'}}},'g'));
console.log(util.find({a:'b',c:'d',e:{f:{g:['i','j','h']}}},'h'));

###maxKey(data) returns maximum element existing.

var util = require('type-util');
console.log(util.maxKey({a:2,c:5,d:9));

Issues or Suggestions

Everything is welcome, if there are any issues, or suggestions please raise them.

License

MIT

Keywords

FAQs

Package last updated on 28 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc