Skip to content

Commit

Permalink
feat(TypeScript): add JsonCompatible type
Browse files Browse the repository at this point in the history
More general than Object -- modern JSON serializers also support direct
string, number, boolean, etc.
  • Loading branch information
thewtex committed Aug 22, 2023
1 parent 9187cd4 commit 4959c42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/core/JsonCompatible.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type JsonCompatible =
| string
| number
| boolean
| { [x: string]: JsonCompatible }
| JsonCompatible[]

export default JsonCompatible
4 changes: 3 additions & 1 deletion src/core/JsonObject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import JsonCompatible from './JsonCompatible.js'

interface JsonObject {
data: Object
data: JsonCompatible
}

export default JsonObject
1 change: 1 addition & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { default as BinaryStream } from './BinaryStream.js'
export { default as TextFile } from './TextFile.js'
export { default as BinaryFile } from './BinaryFile.js'
export { default as JsonObject } from './JsonObject.js'
export { default as JsonCompatible } from './JsonCompatible.js'

export { default as TypedArray } from './TypedArray.js'
export { default as IntTypes } from './IntTypes.js'
Expand Down

0 comments on commit 4959c42

Please sign in to comment.