Skip to content

Commit

Permalink
Use more allKeys().
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jul 10, 2019
1 parent 99a1beb commit 4f35a24
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/safe/vm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import allKeys from "../util/all-keys.js"
import copyProperty from "../util/copy-property.js"
import getPrototypeOf from "../util/get-prototype-of.js"
import has from "../util/has.js"
import ownKeys from "../util/own-keys.js"
import realVM from "../real/vm.js"
import safe from "../util/safe.js"
import setProperty from "../util/set-property.js"
Expand All @@ -15,7 +15,7 @@ function init() {
const SafeProto = SafeScript.prototype

const contextifyProto = getPrototypeOf(Script.prototype)
const names = ownKeys(contextifyProto)
const names = allKeys(contextifyProto)

for (const name of names) {
if (! has(SafeProto, name)) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/prepare-context.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Script } from "../safe/vm.js"

import allKeys from "./all-keys.js"
import { deprecate } from "../safe/util.js"
import getPrototypeOf from "./get-prototype-of.js"
import has from "./has.js"
import instanceOf from "./instance-of.js"
import isObjectLike from "./is-object-like.js"
import ownKeys from "./own-keys.js"
import setPrototypeOf from "./set-prototype-of.js"
import shared from "../shared.js"

Expand Down Expand Up @@ -42,7 +42,7 @@ function init() {
return context
}

const names = ownKeys(defaultGlobal)
const names = allKeys(defaultGlobal)

for (const name of names) {
let descriptor
Expand Down
29 changes: 0 additions & 29 deletions src/util/safe-assign-properties.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/util/safe.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import allKeys from "./all-keys.js"
import isObject from "./is-object.js"
import ownKeys from "./own-keys.js"
import safeAssignProperties from "./safe-assign-properties.js"
import safeAssignPropertiesIn from "./safe-assign-properties-in.js"
import safeCopyProperty from "./safe-copy-property.js"
import setPrototypeOf from "./set-prototype-of.js"
import shared from "../shared.js"
Expand All @@ -13,7 +13,7 @@ function init() {
}

return isObject(value)
? safeAssignProperties({}, value)
? safeAssignPropertiesIn({}, value)
: value
}

Expand All @@ -27,7 +27,7 @@ function init() {
return result
}

const SuperNames = ownKeys(Super)
const SuperNames = allKeys(Super)

for (const name of SuperNames) {
if (name !== "prototype") {
Expand All @@ -38,7 +38,7 @@ function init() {
const SafeProto = Safe.prototype

setPrototypeOf(SafeProto, null)
safeAssignProperties(SafeProto, Super.prototype)
safeAssignPropertiesIn(SafeProto, Super.prototype)

return Safe
}
Expand Down

0 comments on commit 4f35a24

Please sign in to comment.