Download .opencode/node_modules/@ai-sdk/provider/src/json-value/is-json.ts from Chenloong999/opencode-data: direct link, hf CLI and curl.
- Browser
- Download file 967 Bytes
-
https://huggingface.co/datasets/Chenloong999/opencode-data/resolve/main/.opencode/node_modules/%40ai-sdk/provider/src/json-value/is-json.ts
- Command line
-
hf download hf://datasets/Chenloong999/opencode-data/.opencode/node_modules/@ai-sdk/provider/src/json-value/is-json.ts
-
curl -L -o is-json.ts https://huggingface.co/datasets/Chenloong999/opencode-data/resolve/main/.opencode/node_modules/%40ai-sdk/provider/src/json-value/is-json.ts
967 Bytes
| import { JSONArray, JSONObject, JSONValue } from './json-value'; | |
| export function isJSONValue(value: unknown): value is JSONValue { | |
| if ( | |
| value === null || | |
| typeof value === 'string' || | |
| typeof value === 'number' || | |
| typeof value === 'boolean' | |
| ) { | |
| return true; | |
| } | |
| if (Array.isArray(value)) { | |
| return value.every(isJSONValue); | |
| } | |
| if (typeof value === 'object') { | |
| return Object.entries(value).every( | |
| ([key, val]) => | |
| typeof key === 'string' && (val === undefined || isJSONValue(val)), | |
| ); | |
| } | |
| return false; | |
| } | |
| export function isJSONArray(value: unknown): value is JSONArray { | |
| return Array.isArray(value) && value.every(isJSONValue); | |
| } | |
| export function isJSONObject(value: unknown): value is JSONObject { | |
| return ( | |
| value != null && | |
| typeof value === 'object' && | |
| Object.entries(value).every( | |
| ([key, val]) => | |
| typeof key === 'string' && (val === undefined || isJSONValue(val)), | |
| ) | |
| ); | |
| } | |