Crisp.BaseJS
Base OpenCrisp JavaScript functions for Web-Clients and Server-Nodes
// return namespace objectsCrisp; // apply a function with arguments optional asyncronousCrisp; // return the small JavaScript object nameCrisptype; // 'Object' // check the JavaScript object type with a smaller nameCrisptype; // true
Index Table
Getting Started
Server-Nodes
Use Node Package Manager (npm) to install crisp-base
for Node.js and io.js
$ npm install crisp-base
// use package;
or use the OpenCrisp UtilJS wraper
$ npm install crisp-util
// use package;
Web-Clients
Use Bower to install crisp-base
for Browsers APP's and other front-end workflows.
$ bower install crisp-base
<!-- use package -->
or use the OpenCrisp UtilJS wraper
$ bower install crisp-util
<!-- use package -->
Development
Use Git to clone Crisp.BaseJS from GitHub to develop the repository with Grunt
# Clone:
$ git clone https://github.com/OpenCrisp/Crisp.BaseJS.git
# Build: test, concat, test, minify, test
$ grunt
# Test: original sourcecode for developer (included in build)
$ grunt t
# Run all test-scripts on Unix
$ sh grunt-tests.sh
Usage
How to use Crisp.BaseJS
function in JavaScript
// global value of Crispvar $$ = Crisp; // private function { // code}Crisp;
Crisp.ns()
How to use Crisp.ns( name [, object ])
namespaces in JavaScript
// GET namespaceCrisp; // return reference of a = {} // SET and GET namespacesCrisp; // return reference of b = { a: 'A' }
Why namespaces for OpenCrisp?
You can manged youre modules in namespaces an inherit one or more with
Crisp.utilCreate(option)
in JavaScript. Example: include Crisp.EventJS and Crisp.PathJS with Crisp.CreateJSvar myObject = Crisp;// now you can use the functions of Crisp.EventJS on your objectmyObject;myObject;// or the functions of Crisp.PathJSmyObject;myObject;
Crisp.utilTick()
How to use Crisp.utilTick( this, callback, options, async=false )
in JavaScript
// synchronous execution of an anonymous functionCrisp; console;// logs:// { "a": "A" }// END
// asynchronous exetution of an named function { console;} Crisp; console;// logs:// END// { "a": "A" }
Why utilTick event loop for OpenCrisp?
You have one interface for apply functions one behind the other (sync) or parallel (async). You must only set the default option of
async=false
toasync=true
Crisp.to
How to use Crisp.to.call( this )
in JavaScript
Crispto; // '"a"'Crispto; // '{"a":"A"}'
Crisp.parse
How to use Crisp.parse.call( this )
in JavaScript
Crispparse; // 'a'Crispparse; // { a: 'A' }
Crisp.type
How to use Crisp.type.call( this [, name ])
in JavaScript
// GET the small type name of JavaScript objectsCrisptype; // 'String'Crisptype; // 'Number'Crisptype; // 'Boolean'Crisptype; // 'Date'Crisptype; // 'Object'Crisptype; // 'Array'Crisptype; // 'RegExp' Crisptype; // 'Undefined'Crisptype; // 'Undefined' // CHECK the small type name of JavaScript objectsCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // true Crisptype; // trueCrisptype; // true // CHECK group of object typeCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // trueCrisptype; // true
Crisp.math()
How to use Crisp.math()
in JavaScript
Crispmath; // 1
Global object functions
.xType()
How to use .xType([ name ])
prototype functions on JavaScript objects.
@implements Crisp.type
// GET the small type name of JavaScript objects ''; // 'String' 0; // 'Number'true; // 'Boolean'Date; // 'Date' {}; // 'Object' ; // 'Array'/a/g; // 'RegExp' // CHECK the small type name of JavaScript objects ''; // true 0; // truetrue; // trueDate; // true {}; // true ; // true/a/g; // true
.xTo()
How to use .xTo()
prototype function on JavaScript objects.
@implements Crisp.to
<< JSON.stringify
// GET the JSON string of JavaScript objects 'a'; // '"a"' 0; // '0' true; // 'true'Date'2015-07-13'; // '"2015-07-13T00:00:00.000Z"' a: "a" ; // '{"a":"a"}' 1 0 ; // '[1,2]' /a/g; // '"/a/g"'
.xParse()
How to use String().xParse()
prototype function on JavaScript.
@implements Crisp.parse
<< JSON.parse
Parse the given JSON typed string
'"a"'; // 'a' String '"b\\"c"'; // 'b"c' String '1.5'; // 1.5 Number 'true'; // true Boolean'"2015-07-13T00:00:00.000Z"'; // Date() Date '{"a":"A"}'; // { a: 'A' } Object '["a"]'; // ['a'] Array
.xAdd()
How to use Array().xAdd( list [, list ])
prototype functions on JavaScript.
// standard; // ['a']; // ['a','b']; // ['a','b']; // ['a','b'] // empty items; // []; // []; // ['a'] // undefined items; // []; // ['b']; // ['a']; // ['a']
Why xAdd concatenation for OpenCrisp?
.xAdd()
combines the given arguments of anArray
and includes all items. The difference to[].concat()
is to ignoreundefined
items of lists.
.xEach()
How to use .xEach( option )
prototype functions on JavaScript objects.
// use `throw new Break()` to stop xEach and go to callback.completevar Break = Crisp;
// synchronus Object.xEach()a:'A'b:'B';console; // logs:// Success: a A// Success: b B// Complete// End
// asynchronus Object.xEach()a:'A'b:'B';console; // logs:// End// Success: a A// Success: b B// Complete
// syncronus Array.xEach()'A''B';console; // logs:// Success: 0 A// Success: 1 B// Complete// End
// asynchronus Array.xEach()'A''B';console; // logs:// End// Success: 0 A// Success: 1 B// Complete
.xMath()
How to use .xMath( name )
prototype function on JavaScript objects.
@implements Crisp.math
<< Math[function name]( args )
// GET the return of `Math[name].call(this)` function 1; // 1 -1; // 1-01; // 0.1 '1'; // 1 '-1'; // 1'-0.1'; // 0.1
Why xMath on global object of
String
andNumber
for OpenCrisp?You can use the function directly in
Crisp.PathJS
without external coding.// example with Crisp.PathJSvar myObject = 2049 205 20 21 ;Crisp;myObject;console;// logs:// Success: 20.5// Success: 21// Complete// End
Number.isInteger()
How to use ES6 Number.isInteger( number )
function on JavaScript.
Number; // trueNumber; // false
RegExp.escape()
How to use RegExp.escape( string )
function on JavaScript.
RegExp; // 'a\\.b'