This package has been deprecated

Author message:

WARNING: This project has been renamed to @gik/tools. Install that package instead.

feliz.util

0.0.21 • Public • Published

Build Status Coverage Status npm

feliz.util

Various utilities ready to use for any project, but if you use feliz.js you'll be extra happy.

API Documentation (WIP)

util.is(target) ⇒ checkers

Type checker for feliz.util

Kind: static method of util
Returns: checkers - Functions that will validate the target.

Param Type Description
target mixed The target value to be checked.

Example

const is = require('feliz.util/is');
const str = 'hello world';
if (is(str).string()) console.log(str); // will log 'hello world'

is~checkers

Available type-checkers for given target.

Kind: inner class of is

checkers.object() ⇒ boolean

Kind: instance method of checkers
Example

is({}).object()           // true
is(new Object()).object() // true
is(new String()).object() // true

checkers.string() ⇒ boolean

Kind: instance method of checkers
Example

is('').string()                 // true
is(newString()).string()        // true
is('hello').string()            // true
is(new String('hola')).string() // true

checkers.array() ⇒ boolean

Kind: instance method of checkers
Example

is([]).array()          // true
is(['hola']).array()    // true
is(new Array()).array() // true

checkers.number() ⇒ boolean

Kind: instance method of checkers

checkers.date() ⇒ boolean

Kind: instance method of checkers

checkers.regex() ⇒ boolean

Kind: instance method of checkers

checkers.function() ⇒ boolean

Kind: instance method of checkers

checkers.null() ⇒ boolean

Kind: instance method of checkers

checkers.undefined() ⇒ boolean

Kind: instance method of checkers

checkers.arrayish() ⇒ boolean

An array, but not strictly an array.

Kind: instance method of checkers
Example

const ex1 = [];
const ex2 = new Array();
const ex3 = new (class Test extends Array {});
const is = require('feliz.util/is');
// prints: true true false
console.log(is(ex1).array(), is(ex2).array(), is(ex3).array())
// prints: true true true
console.log(is(ex1).arrayish(), is(ex2).arrayish(), is(ex3).arrayish())

checkers.objectish() ⇒ boolean

An object, but not strictly an object.

Kind: instance method of checkers
Example

const ex1 = {};
const ex2 = new Object();
const ex3 = new (class Test extends Object {});
const is = require('feliz.util/is');
// prints: true true false
console.log(is(ex1).object(), is(ex2).object(), is(ex3).object())
// prints: true true true
console.log(is(ex1).objectish(), is(ex2).objectish(), is(ex3).objectish())

checkers.feliz() ⇒ boolean

A feliz instance.

Kind: instance method of checkers

util.object(target) ⇒ actions

Given a target, operate using actions

Kind: static method of util

Param Type Description
target object The object used as target/source.

object~actions

Available actions for the target object.

Kind: inner class of object

actions.merge(...reference) ⇒ object

Recursively merge reference(s) with target.

Kind: instance method of actions
Returns: object - The resulting object.

Param Type Description
...reference object Objects to be merged with target.

util.string(target) ⇒ actions

String utilities for feliz.util

Kind: static method of util

Param Type Description
target string The string to target.

Example

const str = require('feliz.util/string');
const ops = str('hello world');
// returns object with actions for target string

string~actions

Actions to be applied to given string target.

Kind: inner class of string

actions.template(context)

Allows given string to be converted according to a context.

Kind: instance method of actions

Param Type Description
context object The object defining the context to resolve.

Example

const str = require('feliz.util/string');
const foo = str('Hello ${name}').template({name:'Bar'}); // Hello Bar

License

The MIT License (MIT)

Copyright (c) 2016 Héctor Adán Menéndez Rivera

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i feliz.util

Weekly Downloads

12

Version

0.0.21

License

MIT

Last publish

Collaborators

  • etor