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

Commit c70c3af

Browse files
Replace @ndhoule/includes with lodash.includes (#211)
1 parent 6e33d3d commit c70c3af

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

HISTORY.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 4.1.4 / 2020-09-16
2+
3+
- Replace `@ndhoule/includes` with `lodash.includes`
4+
15
# 4.1.3 / 2020-09-16
26

37
- Replace `@ndhoule/pick` with `lodash.pick`

lib/normalize.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
'use strict';
2-
31
import { Message } from './types';
2+
import includes from 'lodash.includes'
43

54
/**
65
* Module Dependencies.
76
*/
87

98
var debug = require('debug')('analytics.js:normalize');
109
var defaults = require('@ndhoule/defaults');
11-
var includes = require('@ndhoule/includes');
1210
var type = require('component-type');
1311
var uuid = require('uuid/v4');
1412
var md5 = require('spark-md5').hash;
@@ -43,14 +41,14 @@ interface NormalizedMessage {
4341
}
4442

4543
function normalize(msg: Message, list: Array<any>): NormalizedMessage {
46-
var lower = list?.map(function(s) {
44+
const lower = list?.map(function(s) {
4745
return s.toLowerCase();
4846
});
49-
var opts: Message = msg.options || {};
50-
var integrations = opts.integrations || {};
51-
var providers = opts.providers || {};
52-
var context = opts.context || {};
53-
var ret: {
47+
const opts: Message = msg.options || {};
48+
const integrations = opts.integrations || {};
49+
const providers = opts.providers || {};
50+
const context = opts.context || {};
51+
let ret: {
5452
integrations?: { [key: string]: string };
5553
context?: unknown;
5654
} = {};
@@ -76,7 +74,7 @@ function normalize(msg: Message, list: Array<any>): NormalizedMessage {
7674
// move all toplevel options to msg
7775
// and the rest to context.
7876
Object.keys(opts).forEach(key => {
79-
if (includes(key, toplevel)) {
77+
if (includes(toplevel, key)) {
8078
ret[key] = opts[key];
8179
} else {
8280
context[key] = opts[key];
@@ -96,9 +94,9 @@ function normalize(msg: Message, list: Array<any>): NormalizedMessage {
9694

9795
function integration(name: string) {
9896
return !!(
99-
includes(name, list) ||
97+
includes(list, name) ||
10098
name.toLowerCase() === 'all' ||
101-
includes(name.toLowerCase(), lower)
99+
includes(lower, name.toLowerCase())
102100
);
103101
}
104102
}

lib/pageDefaults.ts

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
'use strict';
2-
31
import { PageDefaults } from './types';
4-
5-
/*
6-
* Module dependencies.
7-
*/
8-
9-
var canonical = require('@segment/canonical');
10-
var includes = require('@ndhoule/includes');
11-
var url = require('component-url');
2+
import includes from 'lodash.includes'
3+
import canonical from '@segment/canonical'
4+
import url from 'component-url'
125

136
/**
147
* Return a default `options.context.page` object.
@@ -31,9 +24,9 @@ function pageDefaults(): PageDefaults {
3124
*/
3225

3326
function canonicalPath(): string {
34-
var canon = canonical();
27+
const canon = canonical();
3528
if (!canon) return window.location.pathname;
36-
var parsed = url.parse(canon);
29+
const parsed = url.parse(canon);
3730
return parsed.pathname;
3831
}
3932

@@ -43,10 +36,10 @@ function canonicalPath(): string {
4336
*/
4437

4538
function canonicalUrl(search: string): string {
46-
var canon = canonical();
47-
if (canon) return includes('?', canon) ? canon : canon + search;
48-
var url = window.location.href;
49-
var i = url.indexOf('#');
39+
const canon = canonical();
40+
if (canon) return includes(canon, '?') ? canon : canon + search;
41+
const url = window.location.href;
42+
const i = url.indexOf('#');
5043
return i === -1 ? url : url.slice(0, i);
5144
}
5245

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-core",
33
"author": "Segment <[email protected]>",
4-
"version": "4.1.3",
4+
"version": "4.1.4",
55
"description": "The hassle-free way to integrate analytics into any web application.",
66
"types": "lib/index.d.ts",
77
"keywords": [
@@ -31,7 +31,6 @@
3131
"homepage": "https://github.com/segmentio/analytics.js-core#readme",
3232
"dependencies": {
3333
"@ndhoule/defaults": "^2.0.1",
34-
"@ndhoule/includes": "^2.0.1",
3534
"@segment/canonical": "^1.0.0",
3635
"@segment/cookie": "^1.1.5",
3736
"@segment/is-meta": "^1.0.0",
@@ -54,6 +53,7 @@
5453
"is": "^3.1.0",
5554
"lodash.assignin": "^4.2.0",
5655
"lodash.clonedeep": "^4.5.0",
56+
"lodash.includes": "^4.3.0",
5757
"lodash.pick": "^4.4.0",
5858
"new-date": "^1.0.0",
5959
"next-tick": "^0.2.2",

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -6049,6 +6049,11 @@ lodash.has@^4.5.2:
60496049
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
60506050
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=
60516051

6052+
lodash.includes@^4.3.0:
6053+
version "4.3.0"
6054+
resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f"
6055+
integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=
6056+
60526057
lodash.isarray@^4.0.0:
60536058
version "4.0.0"
60546059
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-4.0.0.tgz#2aca496b28c4ca6d726715313590c02e6ea34403"

0 commit comments

Comments
 (0)