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.
$ npm install wrapjs
$ bower install wrapjs
<script src="scripts/wrap.min.js"></script>
var wrap = require('wrapjs')(false);
var $arr = wrap.$arr;
var $str = wrap.$str;
...
import wrap from 'wrapjs';
let {$arr, $str, ...} = wrap(false);
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);
}
});
Importing the module and calling it with the parameter setGlobals
set to TRUE.
import wrap from 'wrapjs';
wrap(true);
//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