Skip to content

Commit 3c68e09

Browse files
bryanmikaelianhbrls
authored andcommitted
Replace @ndhoule/extend with lodash.assignin (segmentio#206)
1 parent a6f6b8e commit 3c68e09

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

Diff for: HISTORY.md

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
- Fix Potential DOM-based XSS via prototype pollution
1212

13+
# 4.1.2 / 2020-09-16
14+
15+
- Replaces `@ndhoule/extend` with `lodash.assignin`
16+
1317
# 4.1.1 / 2020-09-15
1418

1519
- Enable `esModuleInterop` in `tsconfig.json`

Diff for: lib/entity.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { InitOptions } from './types';
44
import cloneDeep from 'lodash.clonedeep'
5+
import assignIn from 'lodash.assignin'
56

67
/*
78
* Module dependencies.
@@ -10,7 +11,6 @@ import cloneDeep from 'lodash.clonedeep'
1011
var cookie = require('./cookie');
1112
var debug = require('debug')('analytics:entity');
1213
var defaults = require('@ndhoule/defaults');
13-
var extend = require('@ndhoule/extend');
1414
var memory = require('./memory');
1515
var store = require('./store');
1616
var isodateTraverse = require('@segment/isodate-traverse');
@@ -221,10 +221,16 @@ Entity.prototype._setTraits = function(traits: object) {
221221

222222
Entity.prototype.identify = function(id?: string, traits?: object) {
223223
traits = traits || {};
224-
var current = this.id();
225-
if (current === null || current === id)
226-
traits = extend(this.traits(), traits);
227-
if (id) this.id(id);
224+
const current = this.id();
225+
226+
if (current === null || current === id) {
227+
traits = assignIn(this.traits(), traits);
228+
}
229+
230+
if (id) {
231+
this.id(id);
232+
}
233+
228234
this.debug('identify %o, %o', id, traits);
229235
this.traits(traits);
230236
this.save();

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"homepage": "https://github.com/segmentio/analytics.js-core#readme",
3232
"dependencies": {
3333
"@ndhoule/defaults": "^2.0.1",
34-
"@ndhoule/extend": "^2.0.0",
3534
"@ndhoule/includes": "^2.0.1",
3635
"@ndhoule/pick": "^2.0.0",
3736
"@segment/canonical": "^1.0.0",
@@ -53,6 +52,7 @@
5352
"inherits": "^2.0.1",
5453
"install": "^0.7.3",
5554
"is": "^3.1.0",
55+
"lodash.assignin": "^4.2.0",
5656
"lodash.clonedeep": "^4.5.0",
5757
"new-date": "^1.0.0",
5858
"next-tick": "^0.2.2",

Diff for: test/analytics.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
'use strict';
1+
import assignIn from 'lodash.assignin'
22

33
var Analytics = require('../build').constructor;
44
var Facade = require('segmentio-facade');
55
var analytics = require('../build');
66
var assert = require('proclaim');
77
var bind = require('component-event').bind;
88
var createIntegration = require('@segment/analytics.js-integration');
9-
var extend = require('@ndhoule/extend');
109
var type = require('component-type');
1110
var pageDefaults = require('../build/pageDefaults');
1211
var sinon = require('sinon');
@@ -836,7 +835,7 @@ describe('Analytics', function() {
836835
assert.deepEqual(opts, { context: { page: defaults } });
837836
assert.deepEqual(
838837
props,
839-
extend(defaults, { category: 'category', name: 'name' })
838+
assignIn({ category: 'category', name: 'name' }, defaults)
840839
);
841840
done();
842841
});

Diff for: yarn.lock

+1
Original file line numberDiff line numberDiff line change
@@ -5977,6 +5977,7 @@ lodash.assign@^4.2.0:
59775977
lodash.assignin@^4.2.0:
59785978
version "4.2.0"
59795979
resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2"
5980+
integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI=
59805981

59815982
lodash.clone@^4.5.0:
59825983
version "4.5.0"

0 commit comments

Comments
 (0)