Skip to content

Commit

Permalink
change name from JSON to JSONType and add export, fix #8 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored Oct 28, 2017
1 parent d62c0a2 commit 8d1a132
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
**Note**: Gaps between patch versions are faulty/broken releases.
**Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.

# 0.1.0
# 0.1.1

- **Breaking Change**
- upgrade to fp-ts 0.6, io-ts 0.8, monocle.ts 0.5 (@gcanti)
- change name from `JSON` to `JSONType` and add export, fix #8 (@gcanti)

# 0.0.2

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-ts-types",
"version": "0.1.0",
"version": "0.1.1",
"description": "A collection of runtime types for use with io-ts",
"files": ["lib"],
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/JSON/JSONFromString.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as t from 'io-ts'
import { JSON, StringJSONPrism } from '../monocle-ts/StringJSONPrism'
import { JSONType, StringJSONPrism } from '../monocle-ts/StringJSONPrism'

export type JSON = JSON
export type JSONType = JSONType

export const JSONFromString = t.prism(t.string, StringJSONPrism.getOption, 'JSONFromString')
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { createOption } from './fp-ts/createOption'
export { createOptionFromJSON } from './fp-ts/createOptionFromJSON'
export { createOptionFromNullable } from './fp-ts/createOptionFromNullable'

export { JSONFromString } from './JSON/JSONFromString'
export { JSONFromString, JSONType } from './JSON/JSONFromString'

export { AnyNumberPrism } from './monocle-ts/AnyNumberPrism'
export { AnyStringPrism } from './monocle-ts/AnyStringPrism'
Expand Down
8 changes: 4 additions & 4 deletions src/monocle-ts/StringJSONPrism.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Prism } from 'monocle-ts'
import { tryCatch } from 'fp-ts/lib/Either'

export type JSONObject = { [key: string]: JSON }
export interface JSONArray extends Array<JSON> {}
export type JSON = null | string | number | boolean | JSONArray | JSONObject
export type JSONObject = { [key: string]: JSONType }
export interface JSONArray extends Array<JSONType> {}
export type JSONType = null | string | number | boolean | JSONArray | JSONObject

export const StringJSONPrism = new Prism<string, JSON>(
export const StringJSONPrism = new Prism<string, JSONType>(
s => tryCatch(() => JSON.parse(s)).toOption(),
a => JSON.stringify(a)
)

0 comments on commit 8d1a132

Please sign in to comment.