Skip to content

Commit

Permalink
Merge pull request #139 from segmentio/component-type
Browse files Browse the repository at this point in the history
Remove type-component in favor of native functions
  • Loading branch information
Julio Farah authored Nov 9, 2020
2 parents 9ae5059 + 076b69a commit 9a3eaef
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.3.1 / 2020-11-06
==================

* Remove third party library "type-component" in favor of native JS functions

3.3.0 / 2020-09-23
==================
Expand Down
7 changes: 3 additions & 4 deletions lib/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import isEnabled from "./is-enabled";
import newDate from "new-date";
import objCase from "obj-case";
import traverse from "@segment/isodate-traverse";
import type from "type-component";

/**
* A *Facade* is an object meant for creating convience wrappers around
Expand Down Expand Up @@ -143,7 +142,7 @@ Facade.field = function (field) {
Facade.multi = function (path) {
return function () {
let multi = this.proxy(path + "s");
if (type(multi) === "array") return multi;
if (Array.isArray(multi)) return multi;
let one = this.proxy(path);
if (one) one = [this.opts.clone ? clone(one) : one];
return one || [];
Expand All @@ -170,7 +169,7 @@ Facade.one = function (path) {
let one = this.proxy(path);
if (one) return one;
let multi = this.proxy(path + "s");
if (type(multi) === "array") return multi[0];
if (Array.isArray(multi)) return multi[0];
};
};

Expand Down Expand Up @@ -386,7 +385,7 @@ f.library = function () {
*/
f.device = function () {
let device = this.proxy("context.device");
if (type(device) !== "object") device = {};
if (typeof device !== "object") device = {};
let library = this.library().name;
if (device.type) return device;

Expand Down
3 changes: 1 addition & 2 deletions lib/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import get from "obj-case";
import inherit from "inherits";
import isEmail from "is-email";
import newDate from "new-date";
import type from "type-component";

let trim = (str) => str.trim();

Expand Down Expand Up @@ -255,7 +254,7 @@ i.age = function () {
let date = this.birthday();
let age = get(this.traits(), "age");
if (age != null) return age;
if (type(date) !== "date") return;
if (!(date instanceof Date)) return;
let now = new Date();
return now.getFullYear() - date.getFullYear();
};
Expand Down
3 changes: 1 addition & 2 deletions lib/track.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

import inherit from "inherits";
import type from "type-component";
import { Facade } from "./facade";
import { Identify } from "./identify";
import isEmail from "is-email";
Expand Down Expand Up @@ -407,7 +406,7 @@ t.subtotal = function () {
t.products = function () {
let props = this.properties();
let products = get(props, "products");
return type(products) === "array" ? products : [];
return Array.isArray(products) ? products : [];
};

/**
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@segment/facade",
"version": "3.3.1",
"version": "3.3.2",
"description": "Providing common fields for analytics integrations",
"keywords": [],
"main": "dist/index.js",
"types": "index.d.ts",
"scripts": {
"tdd": "jest --watch",
"test": "make test",
"build": "rm -rf dist && yarn tsc"
},
Expand All @@ -25,8 +26,7 @@
"inherits": "^2.0.1",
"is-email": "0.1.0",
"new-date": "github://segmentio/new-date",
"obj-case": "0.x",
"type-component": "0.0.1"
"obj-case": "0.x"
},
"devDependencies": {
"@segment/isodate": "^1.0.2",
Expand Down

0 comments on commit 9a3eaef

Please sign in to comment.