source: trip-planner-front/node_modules/to-fast-properties/index.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1001 bytes
Line 
1'use strict';
2
3let fastProto = null;
4
5// Creates an object with permanently fast properties in V8. See Toon Verwaest's
6// post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62
7// for more details. Use %HasFastProperties(object) and the Node.js flag
8// --allow-natives-syntax to check whether an object has fast properties.
9function FastObject(o) {
10 // A prototype object will have "fast properties" enabled once it is checked
11 // against the inline property cache of a function, e.g. fastProto.property:
12 // https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63
13 if (fastProto !== null && typeof fastProto.property) {
14 const result = fastProto;
15 fastProto = FastObject.prototype = null;
16 return result;
17 }
18 fastProto = FastObject.prototype = o == null ? Object.create(null) : o;
19 return new FastObject;
20}
21
22// Initialize the inline property cache of FastObject
23FastObject();
24
25module.exports = function toFastproperties(o) {
26 return FastObject(o);
27};
Note: See TracBrowser for help on using the repository browser.