Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.26 KB

README.md

File metadata and controls

60 lines (42 loc) · 1.26 KB

intercept-entity

simple intercept,encode,decode entity

How to install

npm install intercept-entity

Usage

intercept

  • 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

  • encode
var entities = require("intercept-entity");

entities.encode('Love中国'); //Love中国

decode

  • decode
var entities = require("intercept-entity");

entities.decode('Love中国'); //Love中国