MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / get

Function get

sdk/src/CloudSocketClientLib.js:7707–7792  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

7705
7706 // Internal: Parses a JSON `value` token.
7707 var get = function(value) {
7708 var results,
7709 hasMembers;
7710 if (value == "$") {
7711 // Unexpected end of input.
7712 abort();
7713 }
7714 if (typeof value == "string") {
7715 if ((charIndexBuggy
7716 ? value.charAt(0)
7717 : value[0]) == "@") {
7718 // Remove the sentinel `@` character.
7719 return value.slice(1);
7720 }
7721 // Parse object and array literals.
7722 if (value == "[") {
7723 // Parses a JSON array, returning a new JavaScript array.
7724 results = [];
7725 for (;; hasMembers || (hasMembers = true)) {
7726 value = lex();
7727 // A closing square bracket marks the end of the array literal.
7728 if (value == "]") {
7729 break;
7730 }
7731 // If the array literal contains elements, the current token
7732 // should be a comma separating the previous element from the
7733 // next.
7734 if (hasMembers) {
7735 if (value == ",") {
7736 value = lex();
7737 if (value == "]") {
7738 // Unexpected trailing `,` in array literal.
7739 abort();
7740 }
7741 } else {
7742 // A `,` must separate each array element.
7743 abort();
7744 }
7745 }
7746 // Elisions and leading commas are not permitted.
7747 if (value == ",") {
7748 abort();
7749 }
7750 results.push(get(value));
7751 }
7752 return results;
7753 } else if (value == "{") {
7754 // Parses a JSON object, returning a new JavaScript object.
7755 results = {};
7756 for (;; hasMembers || (hasMembers = true)) {
7757 value = lex();
7758 // A closing curly brace marks the end of the object literal.
7759 if (value == "}") {
7760 break;
7761 }
7762 // If the object literal contains members, the current token
7763 // should be a comma separator.
7764 if (hasMembers) {

Callers 1

runInContextFunction · 0.70

Calls 2

abortFunction · 0.70
lexFunction · 0.70

Tested by

no test coverage detected