Skip to content

Commit

Permalink
fix(types): remove strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 28, 2020
1 parent 5411e71 commit 1513a48
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
12 changes: 0 additions & 12 deletions README.md
Expand Up @@ -99,18 +99,6 @@ JSON.parse(input)
destr(input)
```

**Better types:**

```ts
interface JSON {
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any
}
```

```ts
function destr(val: string | any): JSONValue | undefined
```

## License

MIT. Made with 馃挅
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
@@ -1,6 +1,3 @@
export type JSONObject = { [key: string]: JSONValue }
export type JSONValue = true | false | null | string | Number | JSONObject | JSONValue[]

// https://github.com/fastify/secure-json-parse
// https://github.com/hapijs/bourne
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/
Expand All @@ -15,7 +12,7 @@ function jsonParseTransform (key: string, value: any): any {
return value
}

export default function destr (val: string | any): JSONValue | undefined {
export default function destr (val: any): any {
if (typeof val !== 'string') {
return val
}
Expand Down

0 comments on commit 1513a48

Please sign in to comment.