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

smob

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smob - npm Package Compare versions

Comparing version 1.3.0-alpha.2 to 1.3.0

dist/presets.d.ts

1

dist/index.d.ts
export * from './constants';
export * from './module';
export * from './utils';
export * from './presets';
export * from './type';

3

dist/module.d.ts

@@ -1,4 +0,3 @@

import type { Merger, MergerResult, OptionsInput } from './type';
import type { Merger, OptionsInput } from './type';
export declare function createMerger(input?: OptionsInput): Merger;
export declare const merge: Merger;
export declare function assign<A extends Record<string, any>, B extends Record<string, any>[]>(target: A, ...sources: B): A & MergerResult<B>;

@@ -9,7 +9,11 @@ import type { PriorityName } from './constants';

/**
* Merge array object attributes?
* Merge object array properties.
*
* default: true
*/
array: boolean;
/**
* Remove duplicates in array.
* Remove duplicates, when merging array elements.
*
* default: false
*/

@@ -27,10 +31,16 @@ arrayDistinct: boolean;

* Merge sources in place.
*
* default: false
*/
inPlace?: boolean;
/**
* Deep clone input arrays/objects.
* Deep clone input sources.
*
* default: false
*/
clone?: boolean;
/**
* Merge sources from left-right or left-right.
* Merge sources from left-to-right or right-to-left.
*
* default: left
*/

@@ -37,0 +47,0 @@ priority: `${PriorityName}`;

{
"name": "smob",
"version": "1.3.0-alpha.2",
"version": "1.3.0",
"description": "Zero dependency library to safe merge objects.",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

@@ -9,3 +9,3 @@ # SMOB 🧪

Zero dependency library to **s**afe **m**erge **ob**jects.
Zero dependency library to **s**afe **m**erge **ob**jects and arrays.

@@ -35,6 +35,7 @@ **Table of Contents**

The following merge options are set by default:
- **priority**: `left`
The source aka leftmost array/object has by **default** the highest priority.
- **array**: `true` Merge object array properties.
- **distinct**: `false` Remove duplicates, when merging array elements.
- **arrayDistinct**: `false` Remove duplicates, when merging array elements.
- **clone**: `false` Deep clone input sources.
- **inPlace**: `false` Merge sources in place.
- **priority**: `left` The source aka leftmost array/object has by **default** the highest priority.

@@ -49,4 +50,8 @@ The merge behaviour can be changed by creating a custom [merger](#merger).

console.log(merge({ a: 1 }, { b: 2 }, { c: 3 }));
// => { a: 1, b: 2, c: 3 }
merge({ a: 1 }, { b: 2 }, { c: 3 });
// { a: 1, b: 2, c: 3 }
merge(['foo'], ['bar']);
// ['foo', 'bar']
```

@@ -58,30 +63,30 @@

**Priority**
**Array**
```typescript
import { createMerger } from 'smob';
const merge = createMerger({ priority: 'right' });
const merge = createMerger({ array: false });
console.log(merge({ a: 1 }, { a: 2 }, { a: 3 }));
// => { a: 3 }
merge({ a: [1,2,3] }, { a: [4,5,6] });
// { a: [1,2,3] }
```
**Array**
**ArrayDistinct**
```typescript
import { createMerger } from 'smob';
const merge = createMerger({ array: false });
const merge = createMerger({ arrayDistinct: true });
console.log(merge({ a: [1,2,3] }, { a: [4,5,6] }));
// => { a: [1,2,3] }
merge({ a: [1,2,3] }, { a: [3,4,5] });
// { a: [1,2,3,4,5] }
```
**Distinct**
**Priority**
```typescript
import { createMerger } from 'smob';
const merge = createMerger({ distinct: true });
const merge = createMerger({ priority: 'right' });
console.log(merge({ a: [1,2,3] }, { a: [3,4,5] }));
// => { a: [1,2,3,4,5] }
merge({ a: 1 }, { a: 2 }, { a: 3 })
// { a: 3 }
```

@@ -105,4 +110,4 @@

console.log(merge({ a: 1 }, { a: 2 }, { a: 3 }));
// => { a: 6 }
merge({ a: 1 }, { a: 2 }, { a: 3 });
// { a: 6 }
```

@@ -109,0 +114,0 @@

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