a looooot
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { anyPass, isEmpty, isNil, reject } from 'ramda';
|
||||
import { anyPass, assocPath, isEmpty, isNil, reject } from 'ramda';
|
||||
|
||||
export function toDots(
|
||||
obj: Record<string, unknown>,
|
||||
@@ -19,6 +19,16 @@ export function toDots(
|
||||
}, {});
|
||||
}
|
||||
|
||||
export function toObject(
|
||||
obj: Record<string, string | undefined>
|
||||
): Record<string, unknown> {
|
||||
let result: Record<string, unknown> = {};
|
||||
Object.entries(obj).forEach(([key, value]) => {
|
||||
result = assocPath(key.split('.'), value, result);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export const strip = reject(anyPass([isEmpty, isNil]));
|
||||
|
||||
export function getSafeJson<T>(str: string): T | null {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { createHash } from './crypto';
|
||||
|
||||
interface GenerateProfileIdOptions {
|
||||
interface GenerateDeviceIdOptions {
|
||||
salt: string;
|
||||
ua: string;
|
||||
ip: string;
|
||||
origin: string;
|
||||
}
|
||||
|
||||
export function generateProfileId({
|
||||
export function generateDeviceId({
|
||||
salt,
|
||||
ua,
|
||||
ip,
|
||||
origin,
|
||||
}: GenerateProfileIdOptions) {
|
||||
}: GenerateDeviceIdOptions) {
|
||||
return createHash(`${ua}:${ip}:${origin}:${salt}`, 16);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user