Skip to content

Commit

Permalink
fix: remove dependencies (#149)
Browse files Browse the repository at this point in the history
* fix: downgrade type-fest

* fix: remove dependency: type-fest

* Create tough-roses-ring.md
  • Loading branch information
mew-ton authored Feb 6, 2024
1 parent 4fc864f commit afde67c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-roses-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"json-origami": patch
---

fix: remove dependencies
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"format": "biome format --write ./src ./test",
"lint": "biome check --apply ./src ./test"
},
"dependencies": {
"type-fest": "^3.13.0"
},
"devDependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/starlight": "^0.17.2",
Expand Down
3 changes: 0 additions & 3 deletions src/lib/modifier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Get } from 'type-fest'
import type { Dictionary, DictionaryLeaf } from '~/type'
import { type KeyOption, splitHead, splitTails } from './string'

Expand Down Expand Up @@ -34,7 +33,6 @@ interface ObjectModifier<T extends Dictionary = Dictionary> {
* modifier.get('a.b.c') // 'd'
* ```
*/
get<K extends string>(key: K): Get<T, K>
get(key: string): unknown

/**
Expand Down Expand Up @@ -64,7 +62,6 @@ interface ObjectModifier<T extends Dictionary = Dictionary> {
* modifier.set('a.b.c', 'e')
* ```
*/
set<K extends string>(key: K, value: Get<T, K>): boolean
set(key: string, value: unknown): boolean

/**
Expand Down
4 changes: 2 additions & 2 deletions test/omit.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { JsonObject } from 'type-fest'
import { bench, describe } from 'vitest'
import { fold } from '~/fold'
import { omit } from '~/omit'
import type { Dictionary } from '~/type'
import {
BENCHMARK_TARGET_LIGHT_OBJECT_VALUES,
BENCHMARK_TARGET_OBJECT_VALUES,
Expand All @@ -24,7 +24,7 @@ interface TestCaseOption {
}

interface TestCase {
object: JsonObject
object: Dictionary
keys: string[]
}

Expand Down
4 changes: 2 additions & 2 deletions test/pick.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { JsonObject } from 'type-fest'
import { bench, describe } from 'vitest'
import { fold } from '~/fold'
import { pick } from '~/pick'
import type { Dictionary } from '~/type'
import {
BENCHMARK_TARGET_LIGHT_OBJECT_VALUES,
BENCHMARK_TARGET_OBJECT_VALUES,
Expand All @@ -24,7 +24,7 @@ interface TestCaseOption {
}

interface TestCase {
object: JsonObject
object: Dictionary
keys: string[]
}

Expand Down
16 changes: 8 additions & 8 deletions test/utils/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { JsonArray, JsonObject, JsonValue, Writable } from 'type-fest'
import type { Dictionary } from '~/type'
import { createRandomWord, dice, randomChoice } from './random'

const DEFAULT_LEAFS = 1000
Expand All @@ -7,7 +7,7 @@ interface RandomObjectOption {
leafs: number
}

export function createRandomObject({ leafs }: RandomObjectOption): JsonObject {
export function createRandomObject({ leafs }: RandomObjectOption): Dictionary {
let leafCount = 0

if (leafs % 1 !== 0) {
Expand All @@ -31,8 +31,8 @@ export function createRandomObject({ leafs }: RandomObjectOption): JsonObject {
return leafCount % 2 === 0
}

function createObject({ root }: { root?: boolean } = {}): JsonObject {
const obj: JsonObject = {}
function createObject({ root }: { root?: boolean } = {}): Dictionary {
const obj: Dictionary = {}

while ((root || dice(0.6)) && leafCount < maxLeafs) {
const key = createRandomWord()
Expand All @@ -52,8 +52,8 @@ export function createRandomObject({ leafs }: RandomObjectOption): JsonObject {
return obj
}

function createArray(): JsonArray {
const arr: Writable<JsonArray> = []
function createArray(): Dictionary {
const arr: Dictionary = []

while (dice(0.3) && leafCount < maxLeafs) {
const value = createValue()
Expand All @@ -67,7 +67,7 @@ export function createRandomObject({ leafs }: RandomObjectOption): JsonObject {
return arr
}

function createValue(): JsonValue {
function createValue(): Dictionary {
type ValueType = 'number' | 'string' | 'boolean' | 'object' | 'array'

const map = {
Expand All @@ -76,7 +76,7 @@ export function createRandomObject({ leafs }: RandomObjectOption): JsonObject {
boolean: createBooleanLeaf,
object: createObject,
array: createArray,
} satisfies Record<ValueType, () => JsonValue>
} satisfies Record<ValueType, () => Dictionary>

return map[
randomChoice([
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
}
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*", "tests/**/*"]
"include": ["./src/**/*", "./tests/**/*"]
}
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5154,7 +5154,6 @@ __metadata:
defu: "npm:^6.1.4"
sharp: "npm:^0.33.2"
tsup: "npm:^8.0.1"
type-fest: "npm:^3.13.0"
typescript: "npm:^5.3.3"
vitest: "npm:^1.2.2"
peerDependencies:
Expand Down Expand Up @@ -8791,13 +8790,6 @@ __metadata:
languageName: node
linkType: hard

"type-fest@npm:^3.13.0":
version: 3.13.1
resolution: "type-fest@npm:3.13.1"
checksum: 10/9a8a2359ada34c9b3affcaf3a8f73ee14c52779e89950db337ce66fb74c3399776c697c99f2532e9b16e10e61cfdba3b1c19daffb93b338b742f0acd0117ce12
languageName: node
linkType: hard

"typed-array-buffer@npm:^1.0.0":
version: 1.0.0
resolution: "typed-array-buffer@npm:1.0.0"
Expand Down

0 comments on commit afde67c

Please sign in to comment.