funpermaproxy
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,12 +6,9 @@ /*** | ||
* | ||
* 1. No construct and apply proxy traps. | ||
* 2. Instead of an object reference and property name, uses getter function. | ||
* 3. Rewritten in arrow functions | ||
* 1. Instead of an object reference and property name, uses getter function. | ||
* 2. Rewritten in arrow functions | ||
*/ | ||
function permaproxy(directGetter) { | ||
const target = {}; | ||
const getter = () => directGetter() || target; | ||
const bound = new WeakMap(); | ||
function _permaproxy(directGetter, fallbackTarget) { | ||
const getter = () => directGetter() || fallbackTarget; | ||
return new Proxy(target, { | ||
return new Proxy(fallbackTarget, { | ||
getPrototypeOf: (_) => Reflect.getPrototypeOf(getter()), | ||
@@ -33,5 +30,7 @@ setPrototypeOf: (_, prototype) => Reflect.setPrototypeOf(getter(), prototype), | ||
ownKeys: (_) => Reflect.ownKeys(getter()), | ||
construct: (_, argArray, newTarget) => Reflect.construct(getter(), argArray, newTarget), | ||
apply: (_, thisArg, args) => Reflect.apply(getter(), thisArg, args), | ||
}); | ||
} | ||
module.exports = permaproxy; | ||
module.exports = (getter) => _permaproxy(getter, {}); | ||
module.exports.callable = (getter) => _permaproxy(getter, function () {}); |
{ | ||
"name": "funpermaproxy", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Functional permaproxy — proxying an object mediated through a getter function", | ||
"main": "index.js", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"scripts": { | ||
@@ -28,5 +29,5 @@ "test": "jest --verbose --coverage", | ||
"devDependencies": { | ||
"jest": "^24.8.0", | ||
"semantic-release": "^15.13.12" | ||
"jest": "^28.1.1", | ||
"semantic-release": "^19.0.2" | ||
} | ||
} |
# funpermaproxy | ||
[![npm version](https://badge.fury.io/js/funpermaproxy.svg)](https://badge.fury.io/js/funpermaproxy) | ||
[![Build Status](https://travis-ci.org/wix-incubator/funpermaproxy.svg?branch=master)](https://travis-ci.org/wix-incubator/funpermaproxy) | ||
**funpermaproxy** is a fork of [MatrixAI/js-permaproxy](https://github.com/MatrixAI/js-permaproxy) with some key differences and a continous integration suite. | ||
**funpermaproxy** (functional permaproxy) is about proxying an object mediated through a getter function. | ||
In itself, it is a fork of [MatrixAI/js-permaproxy](https://github.com/MatrixAI/js-permaproxy) with some key differences and a continous integration suite. | ||
The original repository was licensed under **Apache-2.0**, and this fork inherits [the license](LICENSE). | ||
@@ -8,0 +11,0 @@ |
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
17791
8
41
73