Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Replace @ndhoule/extend with lodash.assignin (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmikaelian authored Sep 16, 2020
1 parent d1adf60 commit 017124b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 4.1.2 / 2020-09-16

- Replaces `@ndhoule/extend` with `lodash.assignin`

# 4.1.1 / 2020-09-15

- Enable `esModuleInterop` in `tsconfig.json`
Expand Down
16 changes: 11 additions & 5 deletions lib/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { InitOptions } from './types';
import cloneDeep from 'lodash.clonedeep'
import assignIn from 'lodash.assignin'

/*
* Module dependencies.
Expand All @@ -10,7 +11,6 @@ import cloneDeep from 'lodash.clonedeep'
var cookie = require('./cookie');
var debug = require('debug')('analytics:entity');
var defaults = require('@ndhoule/defaults');
var extend = require('@ndhoule/extend');
var memory = require('./memory');
var store = require('./store');
var isodateTraverse = require('@segment/isodate-traverse');
Expand Down Expand Up @@ -221,10 +221,16 @@ Entity.prototype._setTraits = function(traits: object) {

Entity.prototype.identify = function(id?: string, traits?: object) {
traits = traits || {};
var current = this.id();
if (current === null || current === id)
traits = extend(this.traits(), traits);
if (id) this.id(id);
const current = this.id();

if (current === null || current === id) {
traits = assignIn(this.traits(), traits);
}

if (id) {
this.id(id);
}

this.debug('identify %o, %o', id, traits);
this.traits(traits);
this.save();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-core",
"author": "Segment <[email protected]>",
"version": "4.1.1",
"version": "4.1.2",
"description": "The hassle-free way to integrate analytics into any web application.",
"types": "lib/index.d.ts",
"keywords": [
Expand Down Expand Up @@ -31,7 +31,6 @@
"homepage": "https://github.com/segmentio/analytics.js-core#readme",
"dependencies": {
"@ndhoule/defaults": "^2.0.1",
"@ndhoule/extend": "^2.0.0",
"@ndhoule/includes": "^2.0.1",
"@ndhoule/pick": "^2.0.0",
"@segment/canonical": "^1.0.0",
Expand All @@ -54,6 +53,7 @@
"inherits": "^2.0.1",
"install": "^0.7.3",
"is": "^3.1.0",
"lodash.assignin": "^4.2.0",
"lodash.clonedeep": "^4.5.0",
"new-date": "^1.0.0",
"next-tick": "^0.2.2",
Expand Down
5 changes: 2 additions & 3 deletions test/analytics.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';
import assignIn from 'lodash.assignin'

var Analytics = require('../build').constructor;
var Facade = require('segmentio-facade');
var analytics = require('../build');
var assert = require('proclaim');
var bind = require('component-event').bind;
var createIntegration = require('@segment/analytics.js-integration');
var extend = require('@ndhoule/extend');
var type = require('component-type');
var pageDefaults = require('../build/pageDefaults');
var sinon = require('sinon');
Expand Down Expand Up @@ -836,7 +835,7 @@ describe('Analytics', function() {
assert.deepEqual(opts, { context: { page: defaults } });
assert.deepEqual(
props,
extend(defaults, { category: 'category', name: 'name' })
assignIn({ category: 'category', name: 'name' }, defaults)
);
done();
});
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5994,6 +5994,7 @@ lodash.assign@^4.2.0:
lodash.assignin@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2"
integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI=

lodash.clone@^4.5.0:
version "4.5.0"
Expand Down

0 comments on commit 017124b

Please sign in to comment.