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

@rimbu/deep

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rimbu/deep - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

5

dist/main/path.js

@@ -62,4 +62,5 @@ "use strict";

var item = items_2_1.value;
current[item] = {};
current = current[item];
var next = {};
current[item] = (0, internal_1.patchNested)(next);
current = next;
}

@@ -66,0 +67,0 @@ }

14

dist/main/protected.js

@@ -5,4 +5,16 @@ "use strict";

/**
* Returns the same value wrapped in the Protected type
* Returns the same value wrapped in the `Protected` type.
* @param value - the value to wrap
* @note does not perform any runtime protection, it is only a utility to easily add the `Protected`
* type to a value
* @example
* ```ts
* const obj = Protected({ a: 1, b: { c: true, d: [1] } })
* obj.a = 2 // compiler error: a is readonly
* obj.b.c = false // compiler error: c is readonly
* obj.b.d.push(2) // compiler error: d is a readonly array
* (obj as any).b.d.push(2) // will actually mutate the object
* ```
* '
*/

@@ -9,0 +21,0 @@ function Protected(value) {

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

import { patch } from './internal';
import { patch, patchNested } from './internal';
export var Path;

@@ -44,4 +44,5 @@ (function (Path) {

for (const item of items) {
current[item] = {};
current = current[item];
const next = {};
current[item] = patchNested(next);
current = next;
}

@@ -48,0 +49,0 @@ current[last] = value;

/**
* Returns the same value wrapped in the Protected type
* Returns the same value wrapped in the `Protected` type.
* @param value - the value to wrap
* @note does not perform any runtime protection, it is only a utility to easily add the `Protected`
* type to a value
* @example
* ```ts
* const obj = Protected({ a: 1, b: { c: true, d: [1] } })
* obj.a = 2 // compiler error: a is readonly
* obj.b.c = false // compiler error: c is readonly
* obj.b.d.push(2) // compiler error: d is a readonly array
* (obj as any).b.d.push(2) // will actually mutate the object
* ```
* '
*/

@@ -5,0 +17,0 @@ export function Protected(value) {

@@ -1,13 +0,34 @@

import type { IsPlainObj } from '@rimbu/base';
import type { IsAny, IsPlainObj } from '@rimbu/base';
/**
* A deep readonly typed version of given type T. Makes all properties or elements read only.
* It maps types using the following rules:
* - arrays and tuples become readonly counterparts, and all element types are wrapped in `Protected` if applicable
* - Maps of key type K and value type V become Maps of key type `Protected<K>` and value type `Protected<V>`
* - Sets of element type E become Sets of element type `Protected<E>`
* - Promises of value type E become Promises of value type `Protected<E>`
* - Objects that have only simple properties (no functions or iterators) will have all the properties as Protected if applicable
* - Any other type will not be mapped
* @typeparam T - the input type
*/
export declare type Protected<T> = T extends readonly (infer E)[] ? readonly Protected<E>[] : T extends Map<infer K, infer V> ? Map<Protected<K>, Protected<V>> : T extends Set<infer E> ? Set<Protected<E>> : T extends Promise<infer E> ? Promise<Protected<E>> : IsPlainObj<T> extends true ? {
export declare type Protected<T> = IsAny<T> extends true ? T : T extends readonly any[] & infer A ? {
readonly [K in keyof A]: Protected<A[K]>;
} : T extends Map<infer K, infer V> ? Map<Protected<K>, Protected<V>> : T extends Set<infer E> ? Set<Protected<E>> : T extends Promise<infer E> ? Promise<Protected<E>> : IsPlainObj<T> extends true ? {
readonly [K in keyof T]: Protected<T[K]>;
} : T;
/**
* Returns the same value wrapped in the Protected type
* Returns the same value wrapped in the `Protected` type.
* @param value - the value to wrap
* @note does not perform any runtime protection, it is only a utility to easily add the `Protected`
* type to a value
* @example
* ```ts
* const obj = Protected({ a: 1, b: { c: true, d: [1] } })
* obj.a = 2 // compiler error: a is readonly
* obj.b.c = false // compiler error: c is readonly
* obj.b.d.push(2) // compiler error: d is a readonly array
* (obj as any).b.d.push(2) // will actually mutate the object
* ```
* '
*/
export declare function Protected<T>(value: T): Protected<T>;
{
"name": "@rimbu/deep",
"version": "0.10.0",
"version": "0.10.1",
"description": "Tools to use handle plain JS objects as immutable objects",

@@ -60,4 +60,4 @@ "keywords": [

"dependencies": {
"@rimbu/base": "^0.9.0",
"@rimbu/common": "^0.9.3",
"@rimbu/base": "^0.9.1",
"@rimbu/common": "^0.9.4",
"tslib": "^2.4.0"

@@ -72,3 +72,3 @@ },

},
"gitHead": "4efaf8c469d606381517984436383fd6b1b61ec0"
"gitHead": "60d3b52050fc30f10921cbf92d637362d663d7e0"
}

@@ -87,3 +87,3 @@ <p align="center">

Feel very welcome to contribute to further improve Rimbu. Please read our [Contributing guide](../../CONTRIBUTING.md).
Feel very welcome to contribute to further improve Rimbu. Please read our [Contributing guide](https://github.com/rimbu-org/rimbu/blob/main/CONTRIBUTING.md).

@@ -90,0 +90,0 @@ ## Contributors

import type { Update } from '@rimbu/common';
import type { IsPlainObj, PlainObj } from '@rimbu/base';
import { patch } from './internal';
import { patch, patchNested } from './internal';

@@ -95,4 +95,5 @@ /**

for (const item of items) {
current[item] = {};
current = current[item];
const next = {};
current[item] = patchNested(next);
current = next;
}

@@ -99,0 +100,0 @@

@@ -1,9 +0,18 @@

import type { IsPlainObj } from '@rimbu/base';
import type { IsAny, IsPlainObj } from '@rimbu/base';
/**
* A deep readonly typed version of given type T. Makes all properties or elements read only.
* It maps types using the following rules:
* - arrays and tuples become readonly counterparts, and all element types are wrapped in `Protected` if applicable
* - Maps of key type K and value type V become Maps of key type `Protected<K>` and value type `Protected<V>`
* - Sets of element type E become Sets of element type `Protected<E>`
* - Promises of value type E become Promises of value type `Protected<E>`
* - Objects that have only simple properties (no functions or iterators) will have all the properties as Protected if applicable
* - Any other type will not be mapped
* @typeparam T - the input type
*/
export type Protected<T> = T extends readonly (infer E)[]
? readonly Protected<E>[]
export type Protected<T> = IsAny<T> extends true
? T
: T extends readonly any[] & infer A
? { readonly [K in keyof A]: Protected<A[K]> }
: T extends Map<infer K, infer V>

@@ -20,4 +29,16 @@ ? Map<Protected<K>, Protected<V>>

/**
* Returns the same value wrapped in the Protected type
* Returns the same value wrapped in the `Protected` type.
* @param value - the value to wrap
* @note does not perform any runtime protection, it is only a utility to easily add the `Protected`
* type to a value
* @example
* ```ts
* const obj = Protected({ a: 1, b: { c: true, d: [1] } })
* obj.a = 2 // compiler error: a is readonly
* obj.b.c = false // compiler error: c is readonly
* obj.b.d.push(2) // compiler error: d is a readonly array
* (obj as any).b.d.push(2) // will actually mutate the object
* ```
* '
*/

@@ -24,0 +45,0 @@ export function Protected<T>(value: T): Protected<T> {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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