repair

2019-06-19 admin

repair是什么

什么是repair,Repair broken instances of native constructors.

repair使用教程帮助文档

Repair

Version npmBuild StatusDependenciesCoverage Status

Repair broken instances of native JS constructors, making instanceof work! Running code in different VMs will break the instance’s reference. Simply pass an instance or collection of instances to repair and instanceof checks will run again. Although this sounds silly, consider a configuration with multiple RegExp instances or dependencies that assume instanceof checks to work.

Install

npm install --save repair

Example

var repair = require('repair')
  , vm = require('vm')
  , config = {};

vm.createContext(config);
vm.runInContext('date=new Date', config);

assert.equal(config.date instanceof Date, true, 'Different instance');
assert.equal(repair(config.date) instanceof Date, true);

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-67671.html

文章标题:repair

回到顶部