New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rosma

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rosma - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

2

index.js

@@ -1,1 +0,1 @@

import{useState as t,useRef as e,useEffect as r,memo as s}from"react";function n(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var i,o,a,f,c,h,u,l,d;class m{constructor(t){i.add(this),o.set(this,{}),a.set(this,new Map),f.set(this,{}),n(this,i,"m",c).call(this,"*"),n(this,i,"m",u).call(this,t)}subscribe(t,e){if("function"!=typeof e)return r=["listener must be a function"],console.warn(r.join("\n")),()=>!1;var r;Array.isArray(t)||(t=[t]),n(this,i,"m",h).call(this,e);const s=t.map(y);return s.forEach((t=>{n(this,i,"m",c).call(this,t),n(this,a,"f").get(e).add(t),n(this,o,"f")[t].listeners.add(e)})),()=>{n(this,a,"f").delete(e),s.forEach((t=>n(this,o,"f")[t].listeners.delete(e)))}}set(t,{silent:e}={silent:!1}){if("function"==typeof t&&(t=t(p(n(this,f,"f")))),"object"!=typeof t)return;const r=n(this,i,"m",u).call(this,t);!e&&r&&n(this,i,"m",l).call(this,r)}get(t){return"string"==typeof t?n(this,f,"f")[t.toLowerCase()]:Array.isArray(t)?Object.fromEntries(t.map((t=>[t,n(this,f,"f")[y(t)]]))):void 0}get state(){return p(n(this,f,"f"))}isValid(t){return void 0!==n(this,o,"f")[t.toLowerCase()]}}o=new WeakMap,a=new WeakMap,f=new WeakMap,i=new WeakSet,c=function(t){n(this,o,"f")[t]||(n(this,o,"f")[t]={listeners:new Set})},h=function(t){n(this,a,"f").has(t)||n(this,a,"f").set(t,new Set)},u=function(t){if("object"!=typeof t)return;const e=Object.keys(t),r=e.map(y);return r.forEach(((r,s)=>{n(this,i,"m",c).call(this,r),n(this,f,"f")[r]=t[e[s]]})),r},l=function(t){const e=new Set;n(this,o,"f")["*"].listeners.forEach((t=>e.add(t))),t.forEach((t=>{n(this,o,"f")[t.toLowerCase()].listeners.forEach((t=>e.add(t)))})),e.forEach((t=>t(n(this,i,"m",d).call(this,t))))},d=function(t){if(n(this,o,"f")["*"].listeners.has(t))return this.state;const e=Array.from(n(this,a,"f").get(t));return 1===e.length?n(this,f,"f")[e[0]]:Object.fromEntries(e.map((t=>[t,n(this,f,"f")[t]])))};const w=new m;function p(t){return new Proxy(t,{get:(t,e)=>t[y(e)],set:(t,e,r)=>(t[y(e)]=r,!0)})}function y(t){return t.toString().toLowerCase()}function b(s=undefined){const n=s instanceof m,i=n?void 0:s,o=n?s:w,a=t({}),f=e({keys:new Set});return r((()=>{const{keys:t}=f.current;if(0===t.size)return;const e=o.subscribe(Array.from(t),(function(t){a[1]({value:t})}));return()=>e()}),[]),new Proxy({},{get(t,e){const{keys:r}=f.current,s=e.toLowerCase();if("set"===s)return(...t)=>{o.set(...t)};if(s.startsWith("set")){const t=s.replace("set","");return void 0!==i&&c(t),e=>{o.set({[t]:h(e,t)})}}return t[e]?t[e]:(r.add(s),c(s))},defineProperty:(t,e,r)=>(t[e]=r.value,!0)});function c(t){let e=o.get(t);return o.isValid(t)||(e=h(i,t),o.set({[t]:e})),e}function h(t,e){return"function"==typeof t?t(o.get(e)):t}}function g(t,e){function r(r){const s=b(e);return Object.defineProperties(s,Object.fromEntries(Object.entries(r).map((([t,e])=>[t,{value:e}])))),t(s)}return s(r)}export{m as Observer,w as observer,b as useObserver,g as withState};
import{useState as t,useRef as e,useEffect as r,memo as s}from"react";function n(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var i,o,a,f,c,h,u,l,d;class m{constructor(t){i.add(this),o.set(this,{}),a.set(this,new Map),f.set(this,{}),n(this,i,"m",c).call(this,"*"),n(this,i,"m",u).call(this,t)}subscribe(t,e){if("function"!=typeof e)return r=["listener must be a function"],console.warn(r.join("\n")),()=>!1;var r;const s=Array.isArray(t)?Array.from(new Set(t)).filter((t=>"*"!==t)):[t];n(this,i,"m",h).call(this,e);const f=s.map(y);return f.forEach((t=>{n(this,i,"m",c).call(this,t),n(this,a,"f").get(e).add(t),n(this,o,"f")[t].listeners.add(e)})),()=>{n(this,a,"f").delete(e),f.forEach((t=>n(this,o,"f")[t].listeners.delete(e)))}}set(t,{silent:e}={silent:!1}){if("function"==typeof t&&(t=t(p(n(this,f,"f")))),"object"!=typeof t)return;const r=n(this,i,"m",u).call(this,t);!e&&r&&n(this,i,"m",l).call(this,r)}get(t){return"string"==typeof t?n(this,f,"f")[t.toLowerCase()]:Array.isArray(t)?Object.fromEntries(t.map((t=>[t,n(this,f,"f")[y(t)]]))):void 0}get state(){return p(n(this,f,"f"))}isValid(t){return void 0!==n(this,o,"f")[t.toLowerCase()]}}o=new WeakMap,a=new WeakMap,f=new WeakMap,i=new WeakSet,c=function(t){n(this,o,"f")[t]||(n(this,o,"f")[t]={listeners:new Set})},h=function(t){n(this,a,"f").has(t)||n(this,a,"f").set(t,new Set)},u=function(t){if("object"!=typeof t)return;const e=Object.keys(t),r=e.map(y);return r.forEach(((r,s)=>{n(this,i,"m",c).call(this,r),n(this,f,"f")[r]=t[e[s]]})),r},l=function(t){const e=new Set;n(this,o,"f")["*"].listeners.forEach((t=>e.add(t))),t.forEach((t=>{n(this,o,"f")[t.toLowerCase()].listeners.forEach((t=>e.add(t)))})),e.forEach((t=>t(n(this,i,"m",d).call(this,t))))},d=function(t){if(n(this,o,"f")["*"].listeners.has(t))return this.state;const e=Array.from(n(this,a,"f").get(t));return 1===e.length?n(this,f,"f")[e[0]]:Object.fromEntries(e.map((t=>[t,n(this,f,"f")[t]])))};const w=new m;function p(t){return new Proxy(t,{get:(t,e)=>t[y(e)],set:(t,e,r)=>(t[y(e)]=r,!0)})}function y(t){return t.toString().toLowerCase()}function b(s=undefined){const n=s instanceof m,i=n?void 0:s,o=n?s:w,a=t({}),f=e({keys:new Set});return r((()=>{const{keys:t}=f.current;if(0===t.size)return;const e=o.subscribe(Array.from(t),(function(t){a[1]({value:t})}));return()=>e()}),[]),new Proxy({},{get(t,e){const{keys:r}=f.current,s=e.toLowerCase();if("set"===s)return(...t)=>{o.set(...t)};if(s.startsWith("set")){const t=s.replace("set","");return void 0!==i&&c(t),e=>{o.set({[t]:h(e,t)})}}return t[e]?t[e]:(r.add(s),c(s))},defineProperty:(t,e,r)=>(t[e]=r.value,!0)});function c(t){let e=o.get(t);return o.isValid(t)||(e=h(i,t),o.set({[t]:e})),e}function h(t,e){return"function"==typeof t?t(o.get(e)):t}}function g(t,e){function r(r){const s=b(e);return Object.defineProperties(s,Object.fromEntries(Object.entries(r).map((([t,e])=>[t,{value:e}])))),t(s)}return s(r)}export{m as Observer,w as observer,b as useObserver,g as withState};
{
"name": "rosma",
"version": "1.4.1",
"version": "1.4.2",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -5,5 +5,5 @@ import { Listener, ObserverValues, SetOptions, StarOrKey } from '../types';

constructor(initialValues?: T);
subscribe<K extends keyof T>(key: StarOrKey<K> | Array<StarOrKey<K>>, listener: Listener): () => void;
subscribe<StateType extends T>(key: StarOrKey<keyof StateType> | Array<keyof StateType>, listener: Listener): () => void;
set<StateType>(values: ObserverValues<StateType, T>, { silent }?: SetOptions): void;
get<K extends keyof T>(key: K | Array<K>): any;
get<StateType extends T>(key: keyof StateType | Array<keyof StateType>): any;
get state(): T;

@@ -10,0 +10,0 @@ isValid(key: string): boolean;

@@ -19,3 +19,3 @@ export declare type Listener = (value: any) => void;

} & T & {
set: (values: ObserverValues<T, Record<string, any>>, options?: SetOptions) => void;
set?: (values: ObserverValues<T, Record<string, any>>, options?: SetOptions) => void;
} : T;

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