New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ui-utils

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ui-utils

A library of common interface and performant utilities.

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

UI Utilities

A small ES6 library of common utility functions.

Use

Install

npm install ui-utils --save

Import

import { each } from 'ui-utils';

API

camelToDash()

Convert camelCase strings to dash-case

camelToDash('camelCase'); // 'camel-case'

currentTime()

Get current page timestamp

Uses performance.now() if available, falls back to Date().

createBuffer()

Create a buffer array

Create a FIFO buffer array. Default maximum size is 3 items.

Currently only push checks for maximum size.

Set maximum size
const buffer = createBuffer(2);
buffer.push(1, 2, 3);
buffer[1]; // 3

each()

Iterate over an object

function callback(value, key, fullObject) {}

each(object, callback);

Checks for hasOwnProperty before firing callback.

hasChanged()

Compare two iterations of the same object and return true if different

const a = { foo: 1 };
const b = { foo: 1 };
const c = { foo: 2 };

hasChanged(a, b); // false
hasChanged(a, c); // true

isArray()

Check if provided variable is an array

isArray([]); // true
isArray(''); // false

isFunc()

Check if provided variable is a function

isFunc(function () {}); // true
isFunc(''); // false

isNum()

Check if provided variable is a number

isNum(0); // true
isNum(''); // false

isObj()

Check if provided variable is an object

isObj({}); // true
isObj(''); // false

isRelativeValue()

Check if provided variable is a relative value

isRelativeValue('+=200'); // true
isRelativeValue('200'); // false

isString()

Check if provided variable is a string

isString(''); // true
isString(0); // false

toDecimal()

Round number to x decimal places

const pi = 3.14159265359;

toDecimal(pi); // 3.14
toDecimal(pi, 5); // 3.14159

splitValueUnit()

Split a value with a unit into an object with value and unit props

splitValueUnit('200px');
/*
    Returns: {
        value: 200,
        unit: 'px'
    }
*/

Keywords

requestAnimationFrame

FAQs

Package last updated on 14 Jan 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