UNPKG

@gear-js/api

Version:

A JavaScript library that provides functionality to connect GEAR Component APIs.

31 lines (28 loc) 487 B
'use strict'; function isJSON(data) { try { JSON.parse(data); } catch (_) { try { if (JSON.stringify(data)[0] !== '{') { return false; } } catch (_) { return false; } return true; } return true; } function toJSON(data) { try { return JSON.parse(data); } catch (_) { return data; } } exports.isJSON = isJSON; exports.toJSON = toJSON;