diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ea490..d69c32f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index d4e180d..13ed2f2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/JSON/JSONFromString.ts b/src/JSON/JSONFromString.ts index 13f572b..bde88a2 100644 --- a/src/JSON/JSONFromString.ts +++ b/src/JSON/JSONFromString.ts @@ -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') diff --git a/src/index.ts b/src/index.ts index 0bc9e39..ebe5441 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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' diff --git a/src/monocle-ts/StringJSONPrism.ts b/src/monocle-ts/StringJSONPrism.ts index 56fef76..3547a34 100644 --- a/src/monocle-ts/StringJSONPrism.ts +++ b/src/monocle-ts/StringJSONPrism.ts @@ -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 {} -export type JSON = null | string | number | boolean | JSONArray | JSONObject +export type JSONObject = { [key: string]: JSONType } +export interface JSONArray extends Array {} +export type JSONType = null | string | number | boolean | JSONArray | JSONObject -export const StringJSONPrism = new Prism( +export const StringJSONPrism = new Prism( s => tryCatch(() => JSON.parse(s)).toOption(), a => JSON.stringify(a) )