crisp-create

0.2.13 • Public • Published

Crisp.CreateJS

represent a Class design pattern for JavaScript included multible namespaces, options and functions

Build Status NPM Downloads NPM Version

// create object
var myObject = Crisp.utilCreate();
 
// initialice object
myObject.objIni();
 
// get object option
myObject._('myoption');
 
// clone object without data
var cloneObject = myObject.objClone();

Index Table

Getting Started

Server-Nodes

Use Node Package Manager (npm) to install crisp-create for Node.js and io.js

$ npm install crisp-create
// use package
require("crisp-create");

or use the OpenCrisp UtilJS wraper

$ npm install crisp-util
// use package
require("crisp-util");

Web-Clients

Use Bower to install crisp-create for Browsers APP's and other front-end workflows.

$ bower install crisp-create
<!-- use package -->
<script type="text/javascript" src="dist/crisp-create.min.js"></script>

or use the OpenCrisp UtilJS wraper

$ bower install crisp-util
<!-- use package -->
<script type="text/javascript" src="dist/crisp-util.min.js"></script>

Development

Use Git to clone Crisp.CreateJS from GitHub to develop the repository with Grunt

# Clone:
$ git clone https://github.com/OpenCrisp/Crisp.CreateJS.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.CreateJS function in JavaScript.

Crisp.utilCreate()

How to use Crisp.utilCreate( option ) with util.create namespace.

var myObject = Crisp.utilCreate({
    ns: []
    options: {},
    prototypes: {},
    properties: {}
});

option.ns utilCreate()

var myObject = Crisp.utilCreate({
    ns: ['util.event']
}).objIni();
 
myObject.objNs('util.event');   // true
myObject.xTo();                 // '{}'

option.options utilCreate()

var myObject = Crisp.utilCreate({
    options: {
        a: { proWri: true }
    }
}).objIni({ a: 'A' });
 
myObject._('a'); // 'A'
myObject.xTo();  // '{}'

option.properties utilCreate()

var myObject = Crisp.utilCreate({
    properties: {
        b: {
            proEnu: true,
            proGet: function() { return 'B'; }
        }
    }
}).objIni();
 
myObject.b;      // 'B'
myObject.xTo();  // '{"b":"B"}'

option.prototypes utilCreate()

var myObject = Crisp.utilCreate({
    prototypes: {
        c: function() { return 'C'; }
    }
}).objIni();
 
myObject.c();    // 'C'
myObject.xTo();  // '{}'

CreateJS function

.objIni()

How to use .objIni( option ) function on utilCreate object.

var myObject = Crisp.utilCreate({
  options: {
    test: {}
  }
}).objIni({
    test: 0
});
 
myObject._('test');     // 0

._()

How to use ._( name OR option ) function on utilCreate object.

// get the value of `test`
myObject._('test');
// or with option
myObject._({ name: 'test' });
 
// returns preset if option is undefined
myObject._({ name: 'test', preset: 0 });
// or preset of function
myObject._({ name: 'test', preset: function() { return 0; } });
 
// returns preset if option is undefined and save the value on option
myObject._({ name: 'test', insert: true, preset: 0 });
// or preset of function
myObject._({ name: 'test', insert: true, preset: function() { return 0; } });

.objSet()

How to use .objSet( name, value ) function on utilCreate object.

myObject.objSet('test', 1 );

.objData()

How to use .objData( option ) function on utilCreate object.

myObject.objData({
    a: 'A'
});
 
myObject.a;  // 'A'

.objClone()

How to use .objClone() function on utilCreate object.

var cloneObject = myObject.objClone();

.objNs()

How to use .objNs( name ) function on utilCreate object.

myObject.objNs('util.create');  // true

'util.create' is an default namespace

Links

Package Sidebar

Install

npm i crisp-create

Weekly Downloads

1

Version

0.2.13

License

MIT

Last publish

Collaborators

  • fabian.schmid