Skip to content
Permalink
Browse files

runtime: Construct 'builtInKeys' lazily

  • Loading branch information
mvila committed Mar 8, 2019
1 parent 4bb61e9 commit d8c1b6da53ec9dbb7175c010d0748702b730e5ac
Showing with 50 additions and 12 deletions.
  1. +0 −1 .gitignore
  2. +0 −1 packages/runtime/.gitignore
  3. +1 −1 packages/runtime/@resource.json
  4. +34 −0 packages/runtime/package.json
  5. +15 −9 packages/runtime/src/parser.js
@@ -1,5 +1,4 @@
.DS_Store
package.json
node_modules
npm-debug.log
_private
@@ -1,5 +1,4 @@
.DS_STORE
node_modules
*.log
/package.json
/dist
@@ -1,7 +1,7 @@
{
"@import": "medmain/npm-package#^0.1.0",
"name": "@deepr/runtime",
"version": "0.1.1",
"version": "0.1.2",
"description": "Simple Deepr runtime",
"tests": {
"@include": "./tests"
@@ -0,0 +1,34 @@
{
"name": "@deepr/runtime",
"version": "0.1.2",
"description": "Simple Deepr runtime",
"files": [
"dist"
],
"main": "dist/node/cjs",
"module": "dist/node/esm",
"browser": "dist/browser/esm",
"@managed": {
"warning": "This file contains properties managed by a Resource. You should not modify them directly or use a command such as `npm install <name>`.",
"properties": [
"name",
"version",
"description",
"keywords",
"homepage",
"author",
"contributors",
"license",
"repository",
"files",
"main",
"module",
"browser",
"bin",
"dependencies",
"peerDependencies",
"optionalDependencies",
"devDependencies"
]
}
}
@@ -95,7 +95,7 @@ function _parseQuery(

const {sourceKey, targetKey, isOptional} = parseKey(key);

if (ignoreBuiltInKeys && builtInKeys.includes(sourceKey)) {
if (ignoreBuiltInKeys && getBuiltInKeys().includes(sourceKey)) {
continue;
}

@@ -173,15 +173,21 @@ function testKey(key, patterns) {
);
}

const builtInKeys = [];
class Obj {}
const obj = new Obj();
const func = function () {};
addKeys(builtInKeys, obj);
addKeys(builtInKeys, func);
addKeys(builtInKeys, Obj);
let _builtInKeys;
function getBuiltInKeys() {
if (!_builtInKeys) {
_builtInKeys = [];
class Obj {}
const obj = new Obj();
const func = function () {};
_addKeys(_builtInKeys, obj);
_addKeys(_builtInKeys, func);
_addKeys(_builtInKeys, Obj);
}
return _builtInKeys;
}

function addKeys(array, object) {
function _addKeys(array, object) {
while (object) {
for (const key of Object.getOwnPropertyNames(object)) {
if (!(key === 'name' || key === 'length' || array.indexOf(key) !== -1)) {

0 comments on commit d8c1b6d

Please sign in to comment.
You can’t perform that action at this time.