romancow / extra-sugar

Extra methods and definitions for Sugar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ExtraSugar

Adds extra native object methods using the Sugar Javascript utility library. It also corrects and enhances existing Sugar typescript definitions.

Sugar repo

https://github.com/andrewplummer/Sugar

Methods

Object

Object.isDefined(obj)
Returns false if obj is undefined, otherwise true.
.mapKeys(obj, map, [skipNull])
.cordon(obj, [deep])
.collect(obj, collectFn)
.replace(obj, key, replacer)
.selectValues(obj, keys)
.getWithDefault(obj, key, default, [inherited])
.duplicate(obj, [duplicateFn])
.when(obj, condition, whenFn)

String

.canBeNumber()
.compare(str)
.splice(start, [deleteCount], [...items])

Array

Array.ensure(arr, [ignoreNull])
.move(fromIndex, toIndex)
.indexesOf(items)
.sift(search)
.tapEach(eachFn, [context])
.toObject(mapFn)
.indexes()
.normalizeIndex(index, [loop])
.expel(items)
.transpose(items, [missing])

Function

.isA(classType)

Boolean

Boolean.parse(value)

Date

Date.earliest(dates)
Date.latest(dates)

Range

start
end

Types

primitive
UnensuredArray<T>

About

Extra methods and definitions for Sugar

License:MIT License


Languages

Language:TypeScript 97.7%Language:JavaScript 2.3%