0.0.1 • Published 7 years ago

wrapjs v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

WrapJS

Version 0.0.1 Documentation

WrapJS is a javascript library, and it's main purpose is to simplify and unify javascript. WrapJS uses 'global wrappers' in order to make javascript more strict, type based and make it compatible with most browsers and platforms.

Install (npm)

$ npm install wrapjs

Install (bower)

$ bower install wrapjs

Install (browser)

<script src="scripts/wrap.min.js"></script>

Usage (Node)

var wrap = require('wrapjs')(false);
var $arr = wrap.$arr;
var $str = wrap.$str;
...

Usage (ES6)

import wrap from 'wrapjs';
let {$arr, $str, ...} = wrap(false);

Node (Dom included)

Using jsdom in this exmaple usage.

import wrap from 'wrapjs';
import jsdom from 'jsdom';

jsdom.env({
    html: content,
    done: function (err, window) {
        if(err)
            console.log(err);

        var document = window.document || {};
        let {$el, $arr, ...} = wrap(false, window, document);
    }
});

Node (Global Object)

Importing the module and calling it with the parameter setGlobals set to TRUE.

import wrap from 'wrapjs';
wrap(true);

Example

//Right
var list = $arr([1,2,3]);

list.forEach(function(value, index){
    console.log(index, value);
});
//Wrong
var list = $arr({a:1,b:2,c:3});

list.forEach(function(value, index){
    console.log(index, value);
});

Output

//Right
0,1
1,2
2,3
//Wrong
TypeError: Array type - argument provided is not an array type