CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
isJSONValue.js49 linesDownload Raw Back to predicate
1'use strict';2 3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });4 5const isPlainObject = require('./isPlainObject.js');6 7function isJSONValue(value) {8    switch (typeof value) {9        case 'object': {10            return value === null || isJSONArray(value) || isJSONObject(value);11        }12        case 'string':13        case 'number':14        case 'boolean': {15            return true;16        }17        default: {18            return false;19        }20    }21}22function isJSONArray(value) {23    if (!Array.isArray(value)) {24        return false;25    }26    return value.every(item => isJSONValue(item));27}28function isJSONObject(obj) {29    if (!isPlainObject.isPlainObject(obj)) {30        return false;31    }32    const keys = Reflect.ownKeys(obj);33    for (let i = 0; i < keys.length; i++) {34        const key = keys[i];35        const value = obj[key];36        if (typeof key !== 'string') {37            return false;38        }39        if (!isJSONValue(value)) {40            return false;41        }42    }43    return true;44}45 46exports.isJSONArray = isJSONArray;47exports.isJSONObject = isJSONObject;48exports.isJSONValue = isJSONValue;49 
basant307/AI_Governance_Project · CoolFace