Merged in chore/remove-lodash (pull request #2983)
chore: Remove lodash-es * lodash-es is not edge safe so replace it with native functions Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -82,7 +82,6 @@
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@scandic-hotels/typescript-config": "workspace:*",
|
||||
"@t3-oss/env-nextjs": "^0.13.4",
|
||||
"@types/lodash-es": "^4",
|
||||
"@types/react": "19.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
||||
"@typescript-eslint/parser": "^8.32.0",
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
"deepmerge": "^4.3.1",
|
||||
"flat": "^6.0.1",
|
||||
"libphonenumber-js": "^1.12.7",
|
||||
"lodash-es": "^4.17.21",
|
||||
"nanoid": "^5.1.5",
|
||||
"zod": "^3.24.4",
|
||||
"zustand": "^4.5.2"
|
||||
@@ -86,7 +85,6 @@
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@scandic-hotels/typescript-config": "workspace:*",
|
||||
"@types/lodash-es": "^4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
||||
"@typescript-eslint/parser": "^8.32.0",
|
||||
"dotenv": "^16.5.0",
|
||||
|
||||
@@ -8,20 +8,6 @@ import {
|
||||
} from "@opentelemetry/api"
|
||||
import deepmerge from "deepmerge"
|
||||
import { flatten } from "flat"
|
||||
import {
|
||||
every,
|
||||
isArray,
|
||||
isBoolean,
|
||||
isFunction,
|
||||
isNull,
|
||||
isNumber,
|
||||
isObject,
|
||||
isPlainObject,
|
||||
isString,
|
||||
isUndefined,
|
||||
keys,
|
||||
mapValues,
|
||||
} from "lodash-es"
|
||||
|
||||
import { logger } from "../logger"
|
||||
|
||||
@@ -32,10 +18,10 @@ type AttributesInput = Record<string, unknown>
|
||||
function isAttributesInput(value: unknown): value is AttributesInput {
|
||||
return (
|
||||
isObject(value) &&
|
||||
!isArray(value) &&
|
||||
!Array.isArray(value) &&
|
||||
!isNull(value) &&
|
||||
keys(value).length > 0 &&
|
||||
every(keys(value), isString)
|
||||
Object.keys(value).length > 0 &&
|
||||
Object.keys(value).every(isString)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,9 +37,8 @@ export function isValidAttributeValue(value: unknown): value is AttributeValue {
|
||||
if (isString(value) || isNumber(value) || isBoolean(value)) {
|
||||
return true
|
||||
}
|
||||
if (isArray(value)) {
|
||||
return every(
|
||||
value,
|
||||
if (Array.isArray(value)) {
|
||||
return value.every(
|
||||
(item) =>
|
||||
isNull(item) ||
|
||||
isUndefined(item) ||
|
||||
@@ -309,3 +294,31 @@ export function createCounter(meterName: string, counterName: string) {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const isBoolean = (v: unknown): v is boolean => typeof v === "boolean"
|
||||
const isFunction = (v: unknown): v is Function => typeof v === "function"
|
||||
const isNull = (v: unknown): v is null => v === null
|
||||
const isNumber = (v: unknown): v is number =>
|
||||
typeof v === "number" && Number.isFinite(v as number)
|
||||
const isObject = (v: unknown): v is Record<string, unknown> =>
|
||||
typeof v === "object" && v !== null
|
||||
const isString = (v: unknown): v is string => typeof v === "string"
|
||||
const isUndefined = (v: unknown): v is undefined => typeof v === "undefined"
|
||||
const isPlainObject = (v: unknown): v is Record<string, unknown> => {
|
||||
if (!isObject(v)) return false
|
||||
const proto = Object.getPrototypeOf(v)
|
||||
return proto === Object.prototype || proto === null
|
||||
}
|
||||
|
||||
const mapValues = <T extends Record<string, any>, R>(
|
||||
obj: T,
|
||||
iteratee: (value: T[keyof T], key: keyof T) => R
|
||||
): Record<keyof T, R> => {
|
||||
const out: Partial<Record<keyof T, R>> = {}
|
||||
for (const k in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
||||
out[k] = iteratee(obj[k], k)
|
||||
}
|
||||
}
|
||||
return out as Record<keyof T, R>
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@scandic-hotels/typescript-config": "workspace:*",
|
||||
"@types/lodash-es": "^4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
||||
"@typescript-eslint/parser": "^8.32.0",
|
||||
"dotenv": "^16.5.0",
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@scandic-hotels/typescript-config": "workspace:*",
|
||||
"@types/lodash-es": "^4",
|
||||
"@types/react": "19.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
||||
"@typescript-eslint/parser": "^8.32.0",
|
||||
|
||||
Reference in New Issue
Block a user