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

vigour-util

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vigour-util

Utils from vigour

  • 1.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-78.38%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status

vigour-util

npm install vigour-util

This is a collection of small utility functions which can be required individually.

get

reference

(Specific to vigour-base) Get's the referenced object

var Base = require('vigour-base')
var getReference = require('../../get/reference')

var a = new Base({})
var b = new Base(a)
getReference(b) // a

is

email

Checks whether provided parameter looks like a valid e-mail address

var isEmail = require('vigour-util/is/email')
isEmail('dev@vigour..io') // false
isEmail('dev@vigour.io') // true

empty

(Specific to vigour-base) Checks if a Base object is empty

var isEmpty = require('vigour-util/is/empty')
var Base = require('vigour-base')
isEmpty(new Base({})) // true
isEmpty(new Base({ awesome: true })) // false

hash

Checks is a string looks like a hash generated by the hash utility

var isHash = require('vigour-util/is/hash')
isHash('asd654') // true

node

Check whether we're running in node

var isNode = require('vigour-util/is/node')
isNode() // true or false

number

Checks whether provided parameter is a number

var isNumber = require('vigour-util/is/number')
isNumber(2) // true
isNumber('2') // false

numberlike

Checks whether provided parameter looks like a number

var isNumberLike = require('vigour-util/is/numberlike')
isNumberLike('2') // true
isNumberLike('a') // false

plainobj

Checks whether an object is a plain object. (Compatible with vigour-base)

var isPlainObj = require('vigour/util/is/plainobj')
isPlainObj({}) // true
isPlainObj(new Base({})) // false

removed

(Specific to vigour-base) Checks if a property has been removed

var isRemoved = require('vigour-util/is/removed')
var Base = require('vigour-base')
var base = new Base({ bad: true })
base.bad.remove()
isRemoved(base.bad) // true

stream

Checks whether provided argument is a stream

var stream = require('stream')
var rs = new stream.Readable()
var isStream = require('vigour-util/is/stream')
isStream(rs) // true

touch

Checks if we're running in a touch-enabled context.

var isTouch = require('vigour-util/is/touch')
isTouch() // false unless you're using a touch-enabled device

url

Checks if a string is a valid url

var isUrl = require('vigour-util/is/url')
isUrl('http://perdu.com') // true
isUrl('boom') // false

path

contains

Checks whether a key is part of an array, allowing for prefixed keys

var pathContains = require('vigour-util/path/contains')
pathContains(['a','awesome:b','c'], 'b') // true

Others

define

Defines new or modifies existing properties (using Object.defineProperty) on an object, setting configurable: true by default.

var define = require('vigour-util/define')
var subject = {}
var props = [
  { one: true },
  { two: function () {
      console.log('do nothing')
    }
  }
]
define.apply(subject, props)

descriptors

Like Object.getOwnPropertyDescriptor, but goes along the prototype chain and get's the descriptors for all properties.

var descriptors = require('vigour-util/descriptors')
descriptors({ a: 'a', b: 'b' })
/*
  {
    a: {
      value: 'a',
      writable: true,
      enumerable: true,
      configurable: true
    },
    b: {
      value: 'a',
      writable: true,
      enumerable: true,
      configurable: true
    }
  }
*/

flatten

Transforms a deep object into an object of single depth where keys are a path and values are leafs or the original object.

var flatten = require('vigour-util/flatten')
flatten({ a: { b: 'c', d: 'e' } }) // { 'a.b': 'c', 'a.d': 'e'}
flatten({ a: { b: 'c', d: 'e' } }, '/') // { 'a/b': 'c', 'a/d': 'e'}

hash

Hashing utility optimized for speed, not collision avoidance. Produces alpha-numeric hashes between 5 and 7 characters long inclusively.

var hash = require('vigour-util')
hash('Any sting in the world!!!') // '16hck72'

include

merge

Deprecated: consider using lodash.merge

var merge = require('vigour-util/merge')
merge({ a: { b: 'b' } }, { a: { c: 'c' } }) // { a: { b: 'b', c: 'c' } }

regenerator

Like Babel's regenerator, but much more compact. Brought to you by Facebook, but bundled in vigour-util for ease-of-use.

setwithpath

Deprecated: consider using lodash.set

unflatten

Opposite of flatten

var unflatten = require('vigour-util')
unflatten({
  'a.b.c': 'd'
})
/*
{
  a: {
    b: {
      c: 'd'
    }
  }
}
*/

Keywords

FAQs

Package last updated on 13 Mar 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