Catalog npm
Back to packageRELEASE DETAILS

0.0.7

npm

0model

Lightweight module for data control

datajustdoitstrong typingdata-modelmodelvalidatevalidation
Published1 Dec 2015
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

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

AttributeTypeNote
-
to, then, is, itobjectthis
-
setfunction(v)return: this
getfunction([callback])return: current value
-
lastError-
value-current value
[T]
bool, booleanfunction(true, on, yes, 1) = true
str, stringfunction(NaN, null, undefined, []) = ""
int, integerfunction(radix)
float, numberfunction
-
datefunction
symbolfunction
-
table, hashTablefunction(notParse)
arrayfunction(notParse)
jsonfunction
[M]
removefunction(t)t: string, regEx (string), function(elem)
absfunction
clampfunction(min, max)
[V]
requiredfunctionfalse: NaN, [], null, undefined, "", Invalid Date, {}
emptyfunctiontrue: NaN, [], null, undefined, "", Invalid Date, {}
has, havefunction(...)for: string, array, object

License

MIT


@ Daeren

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "f67d7efc61aed45ef10b4c94400f2b0e8c3d7461",
  "tarball": "https://registry.npmjs.org/0model/-/0model-0.0.7.tgz",
  "integrity": "sha512-NjslZN51HmNDZ1kcN2HnI0ABFAiSbSrFyFTGmaIhVTKi49Eg3SiLssfOcF8BFq9diU7fGZySFii0TXx84ufkDw==",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQCMHGjqYjt88Ip9vj8Yd8+4m7t9jyfUmsl5qvQiVQ4wswIgWMo0HbPmvcQpuQv747qUP11prlazhjeLPK7Jf7+suNk="
    }
  ]
}

Repository

PENDING
daeren/0model

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:6f85d5a8aaddd5a0a71fe4b133ca5233c8adc871f04d11897b50d595e960165d

Other collected versions

0.4.219 Oct0.4.119 Oct0.3.119 Oct0.3.019 Oct0.2.019 Oct0.1.019 OctView all collected versions →