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 11.0.0 to 11.1.0

39

lib/props.js

@@ -134,7 +134,10 @@ (function() {

},
"@isa.boolean x.seal": function(x) {
return this.isa.boolean(x.seal);
},
"@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.boolean x.oneshot": function(x) {
return this.isa.boolean(x.oneshot);
},

@@ -144,2 +147,5 @@ "@isa_optional.boolean x.reset": function(x) {

},
// "reassignable object cannot be frozen": ( x ) ->
// return false if x.oneshot and x.freeze
// return true
"x.reset is deprecated": function(x) {

@@ -162,3 +168,4 @@ if (x.reset != null) {

seal: false,
freeze: false
freeze: false,
oneshot: false
};

@@ -283,3 +290,3 @@

//---------------------------------------------------------------------------------------------------------
static _get_strict_owner_handlers(instance) {
static _get_proxy_cfg(instance) {
return {

@@ -303,2 +310,10 @@ //.......................................................................................................

return value;
},
//.......................................................................................................
set: (target, key, value) => {
console.log('^5535434^', {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);
}

@@ -308,11 +323,5 @@ };

// #.........................................................................................................
// 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;
var R, proxy_cfg;
cfg = {

@@ -323,3 +332,7 @@ target: this,

H.types.validate.guy_props_strict_owner_cfg(cfg = {...H.types.defaults.guy_props_strict_owner_cfg, ...cfg});
R = new Proxy(cfg.target, this.constructor._get_strict_owner_handlers(this));
proxy_cfg = this.constructor._get_proxy_cfg(this);
if (!cfg.oneshot) {
delete proxy_cfg.set;
}
R = new Proxy(cfg.target, proxy_cfg);
if (cfg.freeze) {

@@ -326,0 +339,0 @@ Object.freeze(R);

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

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

@@ -273,4 +273,29 @@

In addition, when property `oneshot` is set (and neither `seal` nor `freeze`), properties can be set *once*,
but not get re-assigned. In case non-re-assignable values should also be immutable, consider to set frozen
objects:
```coffee
d = { x: 42, }
dso = new GUY.props.Strict_owner { target: d, oneshot: true, }
dso.xy = new GUY.props.Strict_owner { target: { foo: 'bar', }, freeze: true, }
# dso.x = 123 # Strict_owner instance already has property 'x'
# dso.xy = {} # Strict_owner instance already has property 'xy'
# dso.xy.foo = 'gnu' # TypeError: Cannot assign to read only property 'foo'
```
Observe that because all of the sealing, freezing and one-shot business is performed on the proxy, not on
the target object, we can still manipulate that one:
```coffee
debug '^35345^', dso # { x: 42, xy: { foo: 'bar' } }
debug '^35345^', d # { x: 42, xy: { foo: 'bar' } }
# we *can* still manipulate the underlying object:
d.x = 123
debug '^35345^', dso # { x: 123, xy: { foo: 'bar' } }
debug '^35345^', d # { x: 123, xy: { foo: 'bar' } }
```
### `GUY.async`: Asynchronous Helpers

@@ -277,0 +302,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