simple intercept,encode,decode entity
npm install intercept-entity
- Param
intercept([String|Array|Object],[Number],[Number|does not exist],callback);
example:
intercept(obj,1,20,callback);
intercept(obj,1,callback);
- String
var entities = require("intercept-entity");
//String
entities.intercept('中abc国©üÿ',1,5,function (result) {
console.log(result); //abc国
});
- Array and Object
var entities = require("intercept-entity");
//Array
var obj ={first:'中国abc©üÿ',second:[{first:'a中国b©ücÿ'},{second:'中国©üabcÿ'}]};
entities.intercept(obj,3,function (result) {
console.log(result); //{ first: 'bc©üÿ',second:[ { first: 'b©ücÿ' },{ second: 'üabcÿ' } ] }
});
- encode
var entities = require("intercept-entity");
entities.encode('Love中国'); //Love中国
- decode
var entities = require("intercept-entity");
entities.decode('Love中国'); //Love中国