Crisp.BaseJS
Base JavaScript functions for OpenCrisp in NodeJS/IOjs and Browser Clients
What is CRISP? Configuration Result In Simplified Programming
Index Table
Getting Started
NodeJS
Use the Node Package Manager (npm) for install crisp-base
npm install crisp-base
or use all of OpenCrisp Utils
npm install crisp-util
Browsers
<script type="text/javascript" src="dist/crisp-base.min.js"></script>
Usage
// global value of Crisp
var $$ = Crisp;
// private function
(function($$) {
// code
})(Crisp);
Namespace example
// GET Namespace
Crisp.ns('a'); // return reference of a = {}
// SET and GET Namespaces
Crisp.ns('b', { a: 'A' }); // return reference of b = { a: 'A' }
utilTick example
synchronous execution of an anonymous function
Crisp.utilTick({ a: 'A' }, function() {
console.log(this);
});
console.log('end');
// logs:
// { "a": "A" }
// end
asynchronous exetution of an named function
function test( b ) {
console.log( b.c );
}
Crisp.utilTick( { a: 'A' }, test, { args: 'C' }, true );
console.log('end');
// logs:
// end
// { "a": "A" }
type example
// get the type name
assert.strictEqual( Crisp.type.call( {} ), 'Object' );
assert.strictEqual( Crisp.type.call( '' ), 'String' );
assert.strictEqual( Crisp.type.call( 0 ), 'Number' );
assert.strictEqual( {}.xType(), 'Object' );
assert.strictEqual( ''.xType(), 'String' );
assert.strictEqual( (0).xType(), 'Number' );
// check of type name
assert.ok( Crisp.type.call( {}, 'Object' ) );
assert.ok( Crisp.type.call( '', 'String' ) );
assert.ok( Crisp.type.call( 0, 'Number' ) );
assert.ok( {}.xType( 'Object' ) );
assert.ok( ''.xType( 'String' ) );
assert.ok( (0).xType( 'Number' ) );