Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

guy

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guy - npm Package Compare versions

Comparing version 10.2.0 to 11.0.0

57

lib/props.js

@@ -134,4 +134,19 @@ (function() {

},
"@isa.boolean x.reset": function(x) {
return this.isa.boolean(x.reset);
"@isa.boolean x.freeze": function(x) {
return this.isa.boolean(x.freeze);
},
"@isa.boolean x.seal": function(x) {
return this.isa.boolean(x.seal);
},
"@isa_optional.boolean x.reset": function(x) {
return this.isa_optional.boolean(x.reset);
},
"x.reset is deprecated": function(x) {
if (x.reset != null) {
return true;
}
if (x.reset === true) {
return true;
}
throw new Error("^guy.props.Strict_owner@1^ `cfg.reset: false` is deprecated; use `cfg.seal: true` instead");
}

@@ -144,3 +159,5 @@ }

target: null,
reset: true
reset: true,
seal: false,
freeze: false
};

@@ -267,7 +284,7 @@

return {
//.........................................................................................................
//.......................................................................................................
ownKeys: (target) => {
return Reflect.ownKeys(target);
},
//.........................................................................................................
//.......................................................................................................
get: (target, key) => {

@@ -285,9 +302,2 @@ var value;

return value;
},
//.........................................................................................................
set: (target, key, value) => {
if (GUY_props.has(target, key)) {
throw new Error(`^guy.props.Strict_owner@1^ ${instance.constructor.name} instance already has property ${H.rpr(key)}`);
}
return Reflect.set(target, key, value);
}

@@ -297,5 +307,11 @@ };

//---------------------------------------------------------------------------------------------------------
// #.........................................................................................................
// set: ( target, key, value ) =>
// if GUY_props.has target, key
// throw new Error "^guy.props.Strict_owner@1^ #{instance.constructor.name} instance already has property #{H.rpr key}"
// return Reflect.set target, key, value
//---------------------------------------------------------------------------------------------------------
constructor(cfg) {
var R, get, ownKeys, set;
var R;
cfg = {

@@ -306,10 +322,9 @@ target: this,

H.types.validate.guy_props_strict_owner_cfg(cfg = {...H.types.defaults.guy_props_strict_owner_cfg, ...cfg});
({get, set, ownKeys} = this.constructor._get_strict_owner_handlers(this));
//.......................................................................................................
if (cfg.reset) {
R = new Proxy(cfg.target, {ownKeys, get});
} else {
R = new Proxy(cfg.target, {ownKeys, get, set});
R = new Proxy(cfg.target, this.constructor._get_strict_owner_handlers(this));
if (cfg.freeze) {
Object.freeze(R);
}
//.......................................................................................................
if (cfg.seal) {
Object.seal(R);
}
return R;

@@ -316,0 +331,0 @@ }

{
"name": "guy",
"version": "10.2.0",
"version": "11.0.0",
"description": "npm dependencies checker",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

@@ -252,3 +252,25 @@

In order to get an object which is sealed and or frozen, use properties `seal` and `freeze`, respectively:
```coffee
d = { x: 42, }
dso = new GUY.props.Strict_owner { target: d, seal: true, freeze: true, }
# this works:
dso.x # 42
# but none of these work:
# Strict owner ship means unknown properties cannot be accessed:
dso.y # Strict_owner instance does not have property 'y'
# Properties of a frozen object cannot be re-assigned:
dso.x = 48 # TypeError: Cannot assign to read only property 'x'
# Properties cannot be added to a sealed object (also implied by being frozen):
dso.y = 'something' # TypeError: Cannot define property y, object is not extensible
```
### `GUY.async`: Asynchronous Helpers

@@ -533,4 +555,43 @@

* **[–]** turn `GUY`, submodules into `Strict_owner` instances
* **[–]** move deep freezing, deep sealing from `lft` to `props`?
* **[–]** concerning `Strict_owner`: in
[`hengist/dev/intertype/_ng.test.coffee`](https://github.com/loveencounterflow/hengist/commit/b16acfcf57b2868849d74afc5073c632fb9eccbf#diff-fa6070699391fb27bafd4df9db13ee8288be4399d939863b689f8a6c711ef3c3R1378)
we have found a way to build custom-named functions with strict ownership:
```coffee
@_demo_type_cfgs_as_funmctions_2 = ->
class Intertype
create_type_cfg: ( cfg ) ->
defaults = { extras: true, collection: false, type: null, }
cfg = { defaults..., cfg..., }
name = cfg.type
R = ( ( x ) -> x ** 2 ).bind @
Object.defineProperty R, 'name', { value: name, }
R[ k ] = v for k, v of cfg
R = new GUY.props.Strict_owner target: R
Object.seal R
# R = GUY.lft.freeze R1 = R # <== doesn't freeze???
Object.freeze R # <== works as expected
return R
types = new Intertype()
urge '^982-1^', f = types.create_type_cfg { type: 'foobar', }
# Object is frozen, sealed, and has a strict `get()`ter:
urge '^982-2^', Object.isFrozen f
urge '^982-3^', Object.isSealed f
try f.collection = true catch error then warn rvr error.message # Cannot assign to read only property 'collection' of function 'function () { [native code] }'
try f.xxx catch error then warn rvr error.message # ^guy.props.Strict_owner@1^ Strict_owner instance does not have property 'xxx'
try f.xxx = 111 catch error then warn rvr error.message # Cannot define property xxx, object is not extensible
info '^982-4^', f.name
info '^982-5^', f 42
return null
```
This should lead to the following:
* **[–]** fix the apparent bug that `GUY.lft.freeze()` does not freeze a function
* **[–]** an extension of `GUY.props.Strict_owner`:
* **[+]** incorporate (deep?) `seal`ing (next to `freeze`ing)
* **[–]** allow to pass in a 'deep target' such that properties not found on the immediate target (the
named function in the above) will also be searched in the deep target (such as the `Intertype` or
`Dbay` instance), mimicking a prototype chain
## Is Done

@@ -537,0 +598,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc