0.8.1 • Published 8 years ago
chitu v0.8.1
chitu (Chuck Her In The Ute)

youtube.com/watch?v=9i2eZaJsC7g
JavaScript Utilities
Installation
via npm
> npm install chitu --savevia yarn
> yarn add chituModules available
Chitu exports 3 module types:
- ES Module (
dist/chitu.es.js) https://unpkg.com/chitu@latest/dist/chitu.es.js
import chitu from 'chitu'
import { type, round } from 'chitu'- Common JS (
dist/chitu.js) https://unpkg.com/chitu@latest/dist/chitu.js
const chitu = require('chitu')- UMD (
dist/chitu.umd.js) https://unpkg.com/chitu@latest/dist/chitu.umd.js
// Available on
window.chituUsage
type
A module to check the type of a given value.
import { type } from 'chitu'
type.isArray(['foo', 'bar']) // = true
type.isObject({ foo: 'bar' }) // = true
type.isString('foo') // = true
type.isDate(new Date()) // = true
type.isRegExp(/foo/g) // = true
type.isFunction(function() {}) // = true
type.isBoolean(false) // = true
type.isNumber(123) // = true
type.isError(new Error()) // = true
type.isNull(null) // = true
type.isUndefined(void 0) // = true
// or for anything else
type.is('Symbol', Symbol('foo')) // = true
type.is('Map', new Map([])) // = true
type.is('Set', new Set([])) // = true
// etcvalue
Check if the value is a function and execute it (with provided parameters) or simply return the value.
import { value } from 'chitu'
const foo = (a, b, c) => a * b * c
const bar = ['baz']
const fooVal = value(foo, 2, 2, 2) // = 8
const barVal = value(bar) // = ['baz']round
Round a number to a given number of decimal places.
import { round } from 'chitu'
round(123.456) // = 123.46
round(1, 2) // = 1.00
round(1.937) // = 1.94
// etcordinal
Return the ordinal value for a given number.
import { ordinal } from 'chitu'
ordinal(1) // = '1st'
ordinal(2) // = '2nd'
ordinal(3) // = '3rd'
ordinal(4) // = '4th'
ordinal(12) // = '12th'
ordinal(101) // = '101st'
// etctime
Return the human readable time string for a given number of seconds.
import { time } from 'chitu'
time(25) // = '00:25'
time(100) // = '01:40'
time(5000) // = '01:23:20'
// etcdot
Get an item from a given object using string dot notation.
import { dot } from 'chitu'
const obj = {
foo: {
bar: 'lorem',
baz: {
bob: true,
qux: null
}
}
}
dot(obj, 'foo.bar') // = 'lorem'
dot(obj, 'foo.baz.bob') // = true
dot(obj, ['foo', 'baz', 'bob']) // = true
dot(obj, 'foo.baz.bar', 'someDefault') // = 'someDefault'
dot(obj, 'foo.foo.foo') // = undefined
// etcrandom
Generate a "random" alpha-numeric string.
import { random } from 'chitu'
random() // = 'Ky6zJuGnGyrnvw1y'
random(32) // = 'nKusDo5JIFrI1tJswwzpEyGLpvML1Mxp'
// etc0.8.1
8 years ago
0.8.0
8 years ago
0.7.0
8 years ago
0.6.1
8 years ago
0.6.0
8 years ago
0.5.0
8 years ago
0.4.2
8 years ago
0.4.1
8 years ago
0.4.0
8 years ago
0.3.0
8 years ago
0.2.0
9 years ago
0.1.8
10 years ago
0.1.7
10 years ago
0.1.6
10 years ago
0.1.5
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago