0model

0.4.2 • Public • Published

Codacy

npm -g install 0model

  • Coverage: +
  • Browser: +

Browser

  • Include: //raw.githack.com/Daeren/0model/master/index.js

Global var: zm

Examples

var zm = require("0model");
 
 
zm(" D ").string().get().trim();            // <-- "D"
zm(" 13.").to.int().it.is.required();       // <-- true
 
zm({x: 1, y: 2}).to.have("x", "z");         // <-- false
zm({}).it.is.empty();                       // <-- true
 
 
zm("[1,2]").to.json().get();                // <-- [1, 2]
zm("[1,").to.json().to.string().get();      // <-- ''
zm("[1,").json().string().get();            // <-- ''
 
zm(5.9).int().str() + 10;                   // <-- '510'
zm(5.9).to.integer() + " num";              // <-- '5 num'
zm(zm('d0' / 1)).empty();                   // <-- true
 
 
zm([1, 2, 3]).set(x => x.reduce((a, b) => a + b)).get(console.log);
zm(3.14159).set(x => x.toFixed(0)).str().get(console.log);
 
 
zm("hello 2 world").to.string().then.remove(/\d+/).it.is.required();
zm("hello 2 world").to.string().then.remove(/\d+/).get();
zm("hello 2 world").to.string().then.remove(d => d.substr(2)) + "!";

Instance

Attribute Type Note
-
to, then, is, it object this
-
set function(v) return: this
get function([callback]) return: current value
-
lastError -
value - current value
[T]
bool, boolean function (true, on, yes, 1) = true
str, string function (NaN, null, undefined, []) = ""
int, integer function(radix)
float, number function
-
date function
symbol function
-
table, hashTable function(notParse)
array function(notParse)
json function
[M]
remove function(t) t: string, regEx (string), function(elem)
abs function
clamp function(min, max)
[V]
required function false: NaN, [], null, undefined, "", Invalid Date, {}
empty function true: NaN, [], null, undefined, "", Invalid Date, {}
has, have function(...) for: string, array, object

License

MIT


@ Daeren

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.4.22latest

Version History

VersionDownloads (Last 7 Days)Published
0.4.22
0.4.11
0.3.14
0.3.01
0.2.01
0.1.01
0.0.124
0.0.114
0.0.101
0.0.91
0.0.81
0.0.73
0.0.61
0.0.51
0.0.41
0.0.34
0.0.22
0.0.11

Package Sidebar

Install

npm i 0model

Homepage

666.io

Weekly Downloads

34

Version

0.4.2

License

MIT

Last publish

Collaborators

  • daeren