2.0.1 • Published 3 years ago

fleck-js v2.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

fleck-js

fleck-js is a collection of javascript functions and utilities to help developers code faster, bigger and better apps. It does not have dependencies, it is written entirely in vanilla javascript, so it will not install unnecessary packages and libraries increasing your project's bundle size.

Installation

npm install fleck-js

Import or Require

const fleck = require('fleck-js');
console.log(fleck.isArray([1,2,3])); // true

or

import {isArray} from 'fleck-js';
console.log(isArray([1,2,3])); // true

Categories

fleck-js focuses on everyday pieces of code developers write over and over again, which we have separated in three different categories:

  • Validations
  • Formatting
  • Utilities

Validations

isArray

It determines if the given value is an array or not.

Syntax

isArray(array, strictMode)

Parameters
ParameterDescription
arrayRequired. The value to be tested.
strictModeOptional. Defaults to true. Validation strategy, it determines if an empty array is valid or not.
Examples
isArray([1,2,3])       // true
isArray([])            // false
isArray([1,2,3],false) // true
isArray([],false)      // true
isArray('')            // false
isArray(123)           // false

isBoolean

It determines if the given value is a boolean or not.

Syntax

isBoolean(boolean, strictMode)

Parameters
ParameterDescription
booleanRequired. The value to be tested.
strictModeOptional. Defaults to true. Validation strategy, it determines if strings containing 'true' or 'false', uppercase or lowercase are valid or not.
Examples
isBoolean(true)         // true
isBoolean(false)        // true
isBoolean('true')       // false
isBoolean('true',false) // true
isBoolean('TRUE',false) // true
isBoolean(123)          // false

isNumber

It determines if the given value is a number or not.

Syntax

isNumber(number, strictMode)

Parameters
ParameterDescription
numberRequired. The value to be tested.
strictModeOptional. Defaults to true. Validation strategy, it determines if strings containing numbers are valid or not.
Examples
isNumber(123.45)         // true
isNumber('123.45')       // false
isNumber(true)           // false
isNumber([])             // false
isNumber(new Date())     // false
isNumber('123.45',false) // true

isFunction

It determines if the given value is a function or not.

Syntax

isFunction(func)

Parameters
ParameterDescription
funcRequired. The value to be tested.
Examples
isFunction(function(){})   // true
isFunction(() => {})       // true
isFunction(true)           // false
isFunction([])             // false
isFunction('() => {}')     // false
isFunction('function(){}') // false

isObject

It determines if the given value is a object or not.

Syntax

isObject(object, strictMode)

Parameters
ParameterDescription
isObjectRequired. The value to be tested.
strictModeOptional. Defaults to true. Validation strategy, it determines if an empty object is valid or not.
Examples
isObject({foo:123.45})    // true
isObject({})              // false
isObject({foo:123},false) // true
isObject({},false)        // true
isObject("")              // false
isObject(123.45)          // false

isDate

It determines if the given value is an instance of Date or not.

Syntax

isDate(date)

Parameters
ParameterDescription
dateRequired. The value to be tested.
Examples
isDate(new Date())   // true
isDate("01/01/2000") // false
isDate(123.45)       // false
isDate("")           // false
isDate([])           // false
isDate(() => {})     // false

isString

It determines if the given value is a string or not.

Syntax

isString(string, strictMode)

Parameters
ParameterDescription
stringRequired. The value to be tested.
strictModeOptional. Defaults to true. Validation strategy, it determines if an empty string is valid or not.
Examples
isString("foo")       // true
isString("")          // false
isString("foo",false) // true
isString("",false)    // true
isString("123.45")    // true
isString(123.45)      // false
2.0.1

3 years ago

2.0.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago