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

deeply

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deeply - npm Package Compare versions

Comparing version 2.0.3 to 3.0.0

yarn.lock

3

flags.js

@@ -5,3 +5,4 @@ // list of available flags

// to prevent (reduce chance of) accidental leaking of the global variables into runtime flags
useCustomAdapters: 'deeply:useCustomAdapters:' + Math.random()
useCustomAdapters: 'deeply:useCustomAdapters:' + Math.random(),
useCustomTypeOf: 'deeply:useCustomTypeOf:' + Math.random()
};

@@ -23,4 +23,5 @@ var preciseTypeOf = require('precise-typeof')

var result = from
, type = preciseTypeOf(from)
, adapter = getTypeAdapter.call(this, type)
, typeOf = getTypeOfAdapter.call(this)
, type = typeOf(from)
, adapter = getMergeByTypeAdapter.call(this, type)
;

@@ -30,3 +31,3 @@

// then override with new instance of the same type
if (preciseTypeOf(to) != type)
if (typeOf(to) != type)
{

@@ -44,2 +45,21 @@ to = getInitialValue(type, adapter);

/**
* Returns typeof adapter, either default one or custom one if provided
*
* @returns {function} - typeof custom adapter or default one
*/
function getTypeOfAdapter()
{
var adapter = preciseTypeOf;
// only if usage of custom adapters is authorized
// to prevent global context leaking in
if (this.useCustomTypeOf === behaviors.useCustomTypeOf)
{
adapter = this['typeof'];
}
return adapter;
}
/**
* Returns merge adapter for the requested type

@@ -51,3 +71,3 @@ * either default one or custom one if provided

*/
function getTypeAdapter(type)
function getMergeByTypeAdapter(type)
{

@@ -59,4 +79,4 @@ var adapter = adapters[type] || passThru;

if (this.useCustomAdapters === behaviors.useCustomAdapters
&& typeof this[type] == 'function'
)
&& typeof this[type] == 'function'
)
{

@@ -79,5 +99,5 @@ adapter = this[type];

var value
// should be either `window` or `global`
// should be either `window` or `global`
, glob = typeof window == 'object' ? window : global
// capitalize the first letter to make object constructor
// capitalize the first letter to make object constructor
, objectType = type[0].toUpperCase() + type.substr(1)

@@ -84,0 +104,0 @@ ;

{
"name": "deeply",
"version": "2.0.3",
"version": "3.0.0",
"description": "A toolkit for deep structure manipulations, provides deep merge/clone functionality out of the box, and exposes hooks and custom adapters for more control and greater flexibility.",

@@ -9,10 +9,9 @@ "main": "index.js",

"lint": "eslint *.js adapters/*.js test/*.js",
"test": "tape test/*.js | tap-spec",
"cover": "istanbul cover --reporter=json tape -- test/*.js | tap-spec",
"browser": "browserify -t browserify-istanbul test/compatibility.js | obake --coverage | tap-spec",
"test": "nyc --reporter=json tape test/test-*.js | tap-spec",
"browser": "browserify -t browserify-istanbul test/test-compatibility.js | obake --coverage | tap-spec",
"report": "istanbul report lcov text",
"size": "browserify index.js | size-table deeply",
"toc": "toc-md README.md",
"files": "pkgfiles --sort=name",
"debug": "tape test/*.js | tap-spec"
"debug": "tape test/*.js | tap-spec",
"testall": "npm run clean && npm run test && npm run browser && npm run report"
},

@@ -22,11 +21,10 @@ "pre-commit": [

"lint",
"cover",
"test",
"browser",
"report",
"size",
"toc",
"files"
"toc"
],
"engines": {
"node": ">= 0.10"
"node": ">= 6"
},

@@ -59,8 +57,10 @@ "repository": {

"devDependencies": {
"browserify": "^13.1.0",
"browserify-istanbul": "^2.0.0",
"coveralls": "^2.11.12",
"eslint": "^2.13.1",
"browserify": "^16.2.3",
"browserify-istanbul": "^3.0.1",
"coveralls": "^3.0.2",
"eslint": "^5.9.0",
"istanbul": "^0.4.5",
"lodash.partialright": "^4.2.1",
"moment": "^2.22.2",
"nyc": "^13.1.0",
"obake": "^0.1.2",

@@ -72,3 +72,3 @@ "phantomjs-prebuilt": "^2.1.12",

"size-table": "^0.2.0",
"tap-spec": "^4.1.1",
"tap-spec": "^5.0.0",
"tape": "^4.6.0",

@@ -78,5 +78,5 @@ "toc-md": "^0.2.0"

"dependencies": {
"fulcon": "^1.0.1",
"precise-typeof": "^1.0.2"
"fulcon": "^2.0.0",
"precise-typeof": "^2.0.0"
}
}

@@ -7,8 +7,9 @@ # Deeply [![NPM Module](https://img.shields.io/npm/v/deeply.svg?style=flat)](https://www.npmjs.com/package/deeply)

[![PhantomJS Build](https://img.shields.io/travis/alexindigo/deeply/master.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/deeply)
[![Linux Build](https://img.shields.io/travis/alexindigo/deeply/master.svg?label=linux:0.10-6.x&style=flat)](https://travis-ci.org/alexindigo/deeply)
[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/deeply/master.svg?label=windows:0.10-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/deeply)
[![Linux Build](https://img.shields.io/travis/alexindigo/deeply/master.svg?label=linux:6.x-11.x&style=flat)](https://travis-ci.org/alexindigo/deeply)
[![MacOS Build](https://img.shields.io/travis/alexindigo/deeply/master.svg?label=macos:6.x-11.x&style=flat)](https://travis-ci.org/alexindigo/deeply)
[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/deeply/master.svg?label=windows:6.x-11.x&style=flat)](https://ci.appveyor.com/project/alexindigo/deeply)
[![Coverage Status](https://img.shields.io/coveralls/alexindigo/deeply/master.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/deeply?branch=master)
[![Dependency Status](https://img.shields.io/david/alexindigo/deeply.svg?style=flat)](https://david-dm.org/alexindigo/deeply)
[![bitHound Overall Score](https://www.bithound.io/github/alexindigo/deeply/badges/score.svg)](https://www.bithound.io/github/alexindigo/deeply)
[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://opensource.org/licenses/MIT)

@@ -19,5 +20,5 @@ [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde)

| :--------------- | ------: |
| deeply.js | 15.1 kB |
| deeply.min.js | 4.98 kB |
| deeply.min.js.gz | 1.51 kB |
| deeply.js | 15.6 kB |
| deeply.min.js | 5.11 kB |
| deeply.min.js.gz | 1.53 kB |

@@ -42,2 +43,4 @@

- [Custom hooks](#custom-hooks)
- [`useCustomAdapters`](#usecustomadapters)
- [`useCustomTypeOf`](#usecustomtypeof)
- [Mutable Operations](#mutable-operations)

@@ -273,3 +276,3 @@ - [Ludicrous Mode](#ludicrous-mode)

// instances
// instances
var s1 = new Subj();

@@ -350,3 +353,3 @@ var s2 = new result.class();

// instances
// instances
var s1 = new Subj();

@@ -367,2 +370,4 @@ var s2 = new result.class();

#### `useCustomAdapters`
As shown in [Custom Merge Function](#custom-merge-function) example,

@@ -396,2 +401,29 @@ you can add custom adapters for any data type

#### `useCustomTypeOf`
In some cases you might need to have more control over type detection,
for that you can supply your own type detection function.
In following example we'd use same `precise-typeof` library,
but with `pojoOnly: true` flag:
```javascript
var merge = require('deeply');
var typeOf = require('precise-typeof');
var moment = require('moment');
var context =
{
useCustomTypeOf: merge.behaviors.useCustomTypeOf,
'typeof' : (input) => typeOf(input, {pojoOnly: true})
};
var result = merge.call(context, { a: {someField: 'value'}, b: 'other thing'}, { a: moment.utc('2018-11-27') });
assert.equal(result, { a: moment.utc('2018-11-27'), b: 'other thing' });
```
In the above example, it would treat `moment` object as atomic,
and won't mix it's properties with other properties.
### Mutable Operations

@@ -398,0 +430,0 @@

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