Skip to content

Commit 6e80123

Browse files
committed
Remove lodash depencdency
1 parent 1ec2a55 commit 6e80123

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

package-lock.json

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@highmobility/auto-api-javascript",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"description": "Auto API for JavaScript - the parsing library for the Auto API vehicle data model",
55
"main": "lib/index.js",
66
"module": "es/index.js",
@@ -36,7 +36,6 @@
3636
"homepage": "https://github.com/highmobility/auto-api-javascript#readme",
3737
"devDependencies": {
3838
"@tsconfig/node10": "^1.0.8",
39-
"@types/lodash": "^4.14.170",
4039
"@types/node": "^16.0.0",
4140
"@types/yamljs": "^0.2.31",
4241
"@typescript-eslint/eslint-plugin": "^4.28.1",
@@ -60,7 +59,6 @@
6059
},
6160
"dependencies": {
6261
"ieee754": "^1.2.1",
63-
"lodash": "^4.17.21",
6462
"tslib": "^2.3.0"
6563
},
6664
"husky": {

src/utils/misc.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { isFinite, isPlainObject } from 'lodash';
2-
31
export function getArray<T>(value: T | T[]): T[] {
42
return Array.isArray(value) ? value : [value];
53
}
@@ -18,14 +16,22 @@ export function isEmptyObject(value: Record<string, unknown>) {
1816
return true;
1917
}
2018

19+
export function isString(value: unknown): value is string {
20+
return typeof value === 'string' || value instanceof String;
21+
}
22+
2123
export function isInteger(value: unknown): value is number {
2224
return Number.isInteger(value);
2325
}
2426

2527
export function isNumber(value: unknown): value is number {
26-
return isFinite(value);
28+
return Number.isFinite(value);
2729
}
2830

2931
export function isObject(value: unknown): value is Record<string, unknown> {
30-
return isPlainObject(value);
32+
return Object.prototype.toString.call(value) === '[object Object]';
33+
}
34+
35+
export function last<T>(array: ArrayLike<T>): T {
36+
return array[array.length - 1];
3137
}

src/values/CustomValue.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { last } from 'lodash';
2-
31
import { Configuration } from '../configuration';
42
import { FormatError } from '../core/Error';
53
import { NamedEntity } from '../core/NamedEntity';
@@ -8,7 +6,7 @@ import { Value } from '../core/Value';
86
import { TypeDefinition, TypeDefinitionType } from '../types';
97
import { ValueFactory } from '../factories/ValueFactory';
108

11-
import { bytesToChunk, bytesWithSize, getKeyValuePairFromObject, isObject } from '../utils';
9+
import { bytesToChunk, bytesWithSize, getKeyValuePairFromObject, isObject, last } from '../utils';
1210

1311
type CustomValueItems = Record<string, Value>;
1412
type CustomValueData = Value | CustomValueItems;

src/values/StringValue.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { isString } from 'lodash';
2-
31
import { FormatError } from '../core/Error';
42
import { Value } from '../core/Value';
53

6-
import { utfStringToByteArray } from '../utils';
4+
import { isString, utfStringToByteArray } from '../utils';
75

86
export class StringValue extends Value<string> {
97
public encode() {

src/values/TimestampValue.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { isString } from 'lodash';
2-
31
import { FormatError } from '../core/Error';
42
import { Value } from '../core/Value';
53

6-
import { bytesToInt, decimalToHexArray } from '../utils';
4+
import { bytesToInt, decimalToHexArray, isString } from '../utils';
75

86
export class TimestampValue extends Value<Date, Date | string> {
97
public constructor(value = new Date()) {

0 commit comments

Comments
 (0)