pax_global_header00006660000000000000000000000064136152442000014507gustar00rootroot0000000000000052 comment=0bf7f28526345346de3e0be1b2b8b3c03891c04f to-fast-properties-3.0.1/000077500000000000000000000000001361524420000152575ustar00rootroot00000000000000to-fast-properties-3.0.1/.editorconfig000066400000000000000000000002571361524420000177400ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 to-fast-properties-3.0.1/.gitattributes000066400000000000000000000000231361524420000201450ustar00rootroot00000000000000* text=auto eol=lf to-fast-properties-3.0.1/.github/000077500000000000000000000000001361524420000166175ustar00rootroot00000000000000to-fast-properties-3.0.1/.github/funding.yml000066400000000000000000000000661361524420000207760ustar00rootroot00000000000000github: sindresorhus tidelift: npm/to-fast-properties to-fast-properties-3.0.1/.github/security.md000066400000000000000000000002631361524420000210110ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. to-fast-properties-3.0.1/.gitignore000066400000000000000000000000271361524420000172460ustar00rootroot00000000000000node_modules yarn.lock to-fast-properties-3.0.1/.npmrc000066400000000000000000000000231361524420000163720ustar00rootroot00000000000000package-lock=false to-fast-properties-3.0.1/.travis.yml000066400000000000000000000000541361524420000173670ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' to-fast-properties-3.0.1/index.d.ts000066400000000000000000000003771361524420000171670ustar00rootroot00000000000000/** Force V8 to use fast properties for an object. @param object - Object to be made fast. @returns A shallow copy of the original object, but uncallable. */ declare function toFastProperties(object?: T): T; export = toFastProperties; to-fast-properties-3.0.1/index.js000066400000000000000000000020751361524420000167300ustar00rootroot00000000000000'use strict'; let fastProto = null; // Creates an object with permanently fast properties in V8. See Toon Verwaest's // post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62 // for more details. Use %HasFastProperties(object) and the Node.js flag // --allow-natives-syntax to check whether an object has fast properties. function FastObject(o) { // A prototype object will have "fast properties" enabled once it is checked // against the inline property cache of a function, e.g. fastProto.property: // https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63 if (fastProto !== null && typeof fastProto.property) { const result = fastProto; fastProto = FastObject.prototype = null; return result; } fastProto = FastObject.prototype = o == null ? Object.create(null) : o; return new FastObject; } const inlineCacheCutoff = 10; // Initialize the inline property cache of FastObject. for (let i = 0; i <= inlineCacheCutoff; i++) { FastObject(); } module.exports = function toFastproperties(o) { return FastObject(o); }; to-fast-properties-3.0.1/index.test-d.ts000066400000000000000000000003731361524420000201400ustar00rootroot00000000000000import {expectType} from 'tsd'; import toFastProperties = require('.'); expectType<{}>(toFastProperties()); type Fixture = { a: boolean; b: number; }; const fixture: Fixture = { a: true, b: 1 }; expectType(toFastProperties(fixture)); to-fast-properties-3.0.1/license000066400000000000000000000022061361524420000166240ustar00rootroot00000000000000MIT License Copyright (c) Petka Antonov Benjamin Gruenbaum John-David Dalton Sindre Sorhus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. to-fast-properties-3.0.1/package.json000066400000000000000000000012511361524420000175440ustar00rootroot00000000000000{ "name": "to-fast-properties", "version": "3.0.1", "description": "Force V8 to use fast properties for an object", "license": "MIT", "repository": "sindresorhus/to-fast-properties", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "node --allow-natives-syntax test.js && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "object", "properties", "props", "v8", "optimize", "fast", "convert", "mode" ], "devDependencies": { "ava": "0.0.4", "tsd": "^0.10.0" } } to-fast-properties-3.0.1/readme.md000066400000000000000000000012621361524420000170370ustar00rootroot00000000000000# to-fast-properties [![Build Status](https://travis-ci.org/sindresorhus/to-fast-properties.svg?branch=master)](https://travis-ci.org/sindresorhus/to-fast-properties) > Force V8 to use fast properties for an object [Read more.](https://stackoverflow.com/questions/24987896/) Use `%HasFastProperties(object)` and `--allow-natives-syntax` to check whether an object already has fast properties. ## Install ``` $ npm install to-fast-properties ``` ## Usage ```js const toFastProperties = require('to-fast-properties'); const object = { foo: true, bar: true }; delete object.foo; // `object` now has slow properties toFastProperties(object); // `object` now has fast properties ``` to-fast-properties-3.0.1/test.js000066400000000000000000000010211361524420000165660ustar00rootroot00000000000000'use strict'; const test = require('ava'); const toFastProperties = require('.'); const toSlowProperties = object => { for (let i = 0; i < 1000; i++) { object[`foo${i}`] = 'foo'; } return object; }; test('main', t => { const object = toSlowProperties({}); object.foo = 'foo'; t.assert(!%HasFastProperties(object), 'object has slow properties'); toFastProperties(object); t.assert(%HasFastProperties(object), 'object has fast properties'); t.assert(object.foo === 'foo', 'object has the same keys'); t.end(); });