@agoric/make-hardener
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -28,2 +28,4 @@ (function (global, factory) { | ||
// @ts-check | ||
const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object; | ||
@@ -33,3 +35,9 @@ const { ownKeys } = Reflect; | ||
/** | ||
* @typedef {<T>(root: T) => T} Hardener | ||
*/ | ||
/** | ||
* Create a `harden` function. | ||
* | ||
* @returns {Hardener} | ||
*/ | ||
@@ -40,2 +48,7 @@ function makeHardener() { | ||
const { harden } = { | ||
/** | ||
* @template T | ||
* @param {T} root | ||
* @returns {T} | ||
*/ | ||
harden(root) { | ||
@@ -47,3 +60,7 @@ const toFreeze = new Set(); | ||
// add it to toFreeze. | ||
function enqueue(val, path) { | ||
/** | ||
* @param {any} val | ||
* @param {string} [path] | ||
*/ | ||
function enqueue(val, path = undefined) { | ||
if (Object(val) !== val) { | ||
@@ -67,2 +84,5 @@ // ignore primitives | ||
/** | ||
* @param {any} obj | ||
*/ | ||
function freezeAndTraverse(obj) { | ||
@@ -97,3 +117,6 @@ // Now freeze the object to ensure reactive | ||
// this is a data property. | ||
const desc = descs[name]; | ||
// The 'name' may be a symbol, and TypeScript doesn't like us to | ||
// index arbitrary symbols on objects, so we pretend they're just | ||
// strings. | ||
const desc = descs[/** @type {string} */ (name)]; | ||
if ('value' in desc) { | ||
@@ -100,0 +123,0 @@ // todo uncurried form |
{ | ||
"name": "@agoric/make-hardener", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Create a 'hardener' which freezes the API surface of a set of objects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,2 +22,4 @@ // Adapted from SES/Caja - Copyright (C) 2011 Google Inc. | ||
// @ts-check | ||
const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object; | ||
@@ -27,3 +29,9 @@ const { ownKeys } = Reflect; | ||
/** | ||
* @typedef {<T>(root: T) => T} Hardener | ||
*/ | ||
/** | ||
* Create a `harden` function. | ||
* | ||
* @returns {Hardener} | ||
*/ | ||
@@ -34,2 +42,7 @@ function makeHardener() { | ||
const { harden } = { | ||
/** | ||
* @template T | ||
* @param {T} root | ||
* @returns {T} | ||
*/ | ||
harden(root) { | ||
@@ -41,3 +54,7 @@ const toFreeze = new Set(); | ||
// add it to toFreeze. | ||
function enqueue(val, path) { | ||
/** | ||
* @param {any} val | ||
* @param {string} [path] | ||
*/ | ||
function enqueue(val, path = undefined) { | ||
if (Object(val) !== val) { | ||
@@ -61,2 +78,5 @@ // ignore primitives | ||
/** | ||
* @param {any} obj | ||
*/ | ||
function freezeAndTraverse(obj) { | ||
@@ -91,3 +111,6 @@ // Now freeze the object to ensure reactive | ||
// this is a data property. | ||
const desc = descs[name]; | ||
// The 'name' may be a symbol, and TypeScript doesn't like us to | ||
// index arbitrary symbols on objects, so we pretend they're just | ||
// strings. | ||
const desc = descs[/** @type {string} */ (name)]; | ||
if ('value' in desc) { | ||
@@ -94,0 +117,0 @@ // todo uncurried form |
export default makeHardener; | ||
export type Hardener = <T>(root: T) => T; | ||
/** | ||
* @typedef {<T>(root: T) => T} Hardener | ||
*/ | ||
/** | ||
* Create a `harden` function. | ||
* | ||
* @returns {Hardener} | ||
*/ | ||
declare function makeHardener(): (root: any) => any; | ||
declare function makeHardener(): Hardener; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36863
526