From 7358c51b9bc32b5e0560f3064dae8be93d174ee0 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Fri, 12 Apr 2024 03:10:42 -0700 Subject: [PATCH] init --- boilerplates/telescope-module/scripts/codegen.js | 2 +- boilerplates/telescope-module/src/get.ts | 11 ----------- boilerplates/telescope-module/src/has.ts | 11 ----------- boilerplates/telescope-module/src/index.ts | 3 --- boilerplates/telescope-module/src/set.ts | 16 ---------------- 5 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 boilerplates/telescope-module/src/get.ts delete mode 100644 boilerplates/telescope-module/src/has.ts delete mode 100644 boilerplates/telescope-module/src/index.ts delete mode 100644 boilerplates/telescope-module/src/set.ts diff --git a/boilerplates/telescope-module/scripts/codegen.js b/boilerplates/telescope-module/scripts/codegen.js index 2a6843676..1c0761be7 100644 --- a/boilerplates/telescope-module/scripts/codegen.js +++ b/boilerplates/telescope-module/scripts/codegen.js @@ -4,7 +4,7 @@ const rimraf = require('rimraf').rimrafSync; const { AMINO_MAP } = require('./aminos'); const protoDirs = [join(__dirname, '/../proto')]; -const outPath = join(__dirname, '../src/codegen'); +const outPath = join(__dirname, '../codegen'); rimraf(outPath); telescope({ diff --git a/boilerplates/telescope-module/src/get.ts b/boilerplates/telescope-module/src/get.ts deleted file mode 100644 index 7b578eb49..000000000 --- a/boilerplates/telescope-module/src/get.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function get(obj: Record, path: string): T | undefined { - const keys = path.replace(/\[(\w+)\]/g, '.$1').split('.'); - let result: any = obj; - for (const key of keys) { - if (result == null) { - return undefined; - } - result = result[key]; - } - return result as T; -}; \ No newline at end of file diff --git a/boilerplates/telescope-module/src/has.ts b/boilerplates/telescope-module/src/has.ts deleted file mode 100644 index 15de7f039..000000000 --- a/boilerplates/telescope-module/src/has.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function has(obj: Record, path: string): boolean { - const keys = path.replace(/\[(\w+)\]/g, '.$1').split('.'); - let current = obj; - for (const key of keys) { - if (current == null || !(key in current)) { - return false; - } - current = current[key]; - } - return true; -}; diff --git a/boilerplates/telescope-module/src/index.ts b/boilerplates/telescope-module/src/index.ts deleted file mode 100644 index 183064e1e..000000000 --- a/boilerplates/telescope-module/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './get'; -export * from './set'; -export * from './has'; \ No newline at end of file diff --git a/boilerplates/telescope-module/src/set.ts b/boilerplates/telescope-module/src/set.ts deleted file mode 100644 index 982dcf566..000000000 --- a/boilerplates/telescope-module/src/set.ts +++ /dev/null @@ -1,16 +0,0 @@ -export function set(obj: Record, path: string, value: any): void { - if (value === undefined) { - return; - } - - const keys = path.replace(/\[(\w+)\]/g, '.$1').split('.'); - let current = obj; - for (let i = 0; i < keys.length - 1; i++) { - const key = keys[i]; - if (typeof current[key] !== 'object') { - current[key] = {}; - } - current = current[key]; - } - current[keys[keys.length - 1]] = value; -}; \ No newline at end of file