
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Something like Ruby port of immer.js
Add this line to your application's Gemfile:
gem 'zanzou'
And then execute:
$ bundle
Or install it yourself as:
$ gem install zanzou
With Zanzou.with_updates
, you can create a modified copy of orig_obj
with
imperative style.
require 'zanzou'
orig_obj = {a: 1, b: 2}
p Zanzou.with_updates(orig_obj){|o| o[:b] = 3}
# => {a: 1, b: 3}
p orig_obj
# => {a: 1, b: 2}
Or you can just call .with_updates
by requir'ing zanzou/install
.
require 'zanzou/install'
orig_obj = {a: 1, b: 2}
p orig_obj.with_updates{|o| o[:b] = 3}
p orig_obj
Zanzou should work well with these objects.
Normally other objects, say a Range, should be OK too. However, container classes (i.e. objects which contains other objects in it) need special treatment to be used with Zanzou.
Steps to add support for a container class:
class XxxShadow < Zanzou::ShadowNode
See spec/zanzou_spec.rb for an example.
Some methods of Array/Hash may does not work well. See the pending specs (git grep pending
).
FYI immer.js does not have such problems because ES6 Proxy is very powerful - it reports object set/get even for methods like Array sort.
const hooks = {
get(target, prop, receiver) {
console.log({hook: "get", prop})
return target[prop];
},
set(target, prop, value) {
console.log({hook: "set", prop, value})
return target[prop] = value;
}
};
const obj = [5613,2348,2987,2387,7823,1987];
const pxy = new Proxy(obj, hooks);
pxy.sort();
// Output:
// ...
// { hook: 'get', prop: '4' }
// { hook: 'get', prop: '5' }
// { hook: 'set', prop: '0', value: 1987 } // It reports all the set/get operations
// { hook: 'set', prop: '1', value: 2348 } // sort() does and thus immer.js can
// { hook: 'set', prop: '2', value: 2387 } // track movements of child elements.
// { hook: 'set', prop: '3', value: 2987 }
// { hook: 'set', prop: '4', value: 5613 }
// { hook: 'set', prop: '5', value: 7823 }
Bug reports and pull requests are welcome on GitHub at https://github.com/yhara/zanzou.
bundle exec rspec
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that zanzou demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.