From 01ed824b5c7a17e75e4bc3d6e68776e7927e5d09 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 4 Mar 2015 21:02:36 +0800 Subject: [PATCH] modularize `util.toFastProperties()` https://github.com/sindresorhus/to-fast-properties --- package.json | 1 + src/babel/helpers/to-fast-properties.js | 15 --------------- src/babel/types/index.js | 2 +- 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 src/babel/helpers/to-fast-properties.js diff --git a/package.json b/package.json index 921bb8c5b3..99494bd89e 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "source-map": "^0.4.0", "source-map-support": "^0.2.9", "source-map-to-comment": "^1.0.0", + "to-fast-properties": "^1.0.0", "trim-right": "^1.0.0" }, "devDependencies": { diff --git a/src/babel/helpers/to-fast-properties.js b/src/babel/helpers/to-fast-properties.js deleted file mode 100644 index a7499fdff5..0000000000 --- a/src/babel/helpers/to-fast-properties.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * A trick from Bluebird to force V8 to use fast properties for an object. - * Read more: http://stackoverflow.com/questions/24987896/ - * - * Use %HasFastProperties(obj) and --allow-natives-syntax to check whether - * a particular object already has fast properties. - */ - -module.exports = function toFastProperties(obj) { - /*jshint -W027*/ - function f() {} - f.prototype = obj; - return f; - eval(obj); -}; diff --git a/src/babel/types/index.js b/src/babel/types/index.js index 91c36ed9e3..62ad08f545 100644 --- a/src/babel/types/index.js +++ b/src/babel/types/index.js @@ -1,4 +1,4 @@ -import toFastProperties from "../helpers/to-fast-properties"; +import toFastProperties from "to-fast-properties"; import isPlainObject from "lodash/lang/isPlainObject"; import isNumber from "lodash/lang/isNumber"; import isRegExp from "lodash/lang/isRegExp";