Skip to content

Commit

Permalink
Delete step
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Kirmas committed Mar 10, 2021
1 parent 990751b commit a003bbd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 51 deletions.
2 changes: 1 addition & 1 deletion __tests__/index.miss-use.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("ctx", () => {
classnames: global_css
})
}).toStrictEqual({
className: ""
className: "[object Object]"
}))
})

Expand Down
30 changes: 1 addition & 29 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { emptize, stringifyClassNamed } from "../src/utils";
import { stringifyClassNamed } from "../src/utils";

describe(stringifyClassNamed.name, () => {
it("works", () => expect(
Expand All @@ -15,31 +15,3 @@ describe(stringifyClassNamed.name, () => {
)
})
})

describe(emptize.name, () => {
it("default behavious", () => expect(
`${{}}`
).toBe(
"[object Object]"
))
it("stringified", () => expect(
`${emptize({})}`
).toBe(
""
))

it("enumerable check", () => expect(
emptize({})
).toStrictEqual(
{}
))

it("no overwrite - for coverage", () => {
const source = emptize({})
expect(
emptize(source)
).toStrictEqual(
{}
)
})
})
8 changes: 1 addition & 7 deletions src/naming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ import {
resolver,
wrapper
} from "./core"
import { emptize } from "./utils"
import { EMPTY_OBJECT } from "./consts.json"
import type {
ClassNamingFn,
ClassNaming
} from "./index-types.defs"

emptize(classes)

export { classNaming }

/** Set context
Expand All @@ -38,8 +35,7 @@ function classNaming<
>(
context: Ctx = EMPTY_OBJECT as Ctx
): ClassNaming<WithClassName, {}, Source> {
const {classnames, className} = context
classnames && emptize(classnames)
const {className} = context

const host: ClassNamingFn<Source, {}, WithClassName> = (arg0?, arg1?) => classes(
context,
Expand Down Expand Up @@ -85,8 +81,6 @@ function classes<
arg1
)

classnames && emptize(classnames)

return wrapper(
host,
result,
Expand Down
14 changes: 0 additions & 14 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const stringifyProperty: SymbolConstructor["toPrimitive"] | "valueOf" | "toStrin
const {
defineProperty: $defineProperty
} = Object
, EmptyDescriptor = {value: emptyLambda}
, StringifyDescriptor = {value: classNamedToString}

export {
emptize,
stringifyClassNamed,
}
// TODO move to `core`
Expand All @@ -24,15 +22,3 @@ function classNamedToString(this: ClassNamed) {
//TODO `?? ""`
return this.className
}

//TODO delete
function emptize(source: Record<string, any>) {
if (!source.hasOwnProperty(stringifyProperty))
$defineProperty(source, stringifyProperty, EmptyDescriptor)

return source
}

function emptyLambda() {
return "" as const
}

0 comments on commit a003bbd

Please sign in to comment.