Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gram-data/gram-value

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gram-data/gram-value - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

2

dist/gram-value.cjs.development.js

@@ -140,3 +140,3 @@ 'use strict';

function assertNever(x) {
throw new Error("Unexpected object: " + x);
throw new Error('Unexpected object: ' + x);
}

@@ -143,0 +143,0 @@

@@ -1,2 +0,2 @@

import { BooleanLiteral, StringLiteral, TaggedLiteral, DateLiteral, IntegerLiteral, MeasurementLiteral, DecimalLiteral, HexadecimalLiteral, OctalLiteral, TimeLiteral, DurationLiteral, GramRecordValue, AnyGramLiteral } from '@gram-data/gram-ast';
import { BooleanLiteral, StringLiteral, TaggedLiteral, DateLiteral, IntegerLiteral, MeasurementLiteral, DecimalLiteral, HexadecimalLiteral, OctalLiteral, TimeLiteral, DurationLiteral, GramRecordValue, GramLiteral } from '@gram-data/gram-ast';
export declare const iso8601Year: RegExp;

@@ -13,3 +13,3 @@ export declare const iso8601YearMonth: RegExp;

export declare const valueOf: (recordValue: GramRecordValue) => any;
export declare const valueOfLiteral: (ast: AnyGramLiteral) => any;
export declare const valueOfLiteral: (ast: GramLiteral) => any;
export declare const valueOfBoolean: (ast: BooleanLiteral) => boolean;

@@ -16,0 +16,0 @@ export declare const valueOfString: (ast: StringLiteral) => string;

@@ -136,3 +136,3 @@ import { isGramLiteralArray, isLiteral, isGramRecord } from '@gram-data/gram-ast';

function assertNever(x) {
throw new Error("Unexpected object: " + x);
throw new Error('Unexpected object: ' + x);
}

@@ -139,0 +139,0 @@

@@ -176,3 +176,3 @@ (function (global, factory) {

function assertNever(x) {
throw new Error("Unexpected object: " + x);
throw new Error('Unexpected object: ' + x);
}

@@ -179,0 +179,0 @@

@@ -8,3 +8,3 @@ {

],
"version": "0.2.9",
"version": "0.2.10",
"license": "MIT",

@@ -52,3 +52,3 @@ "repository": {

"devDependencies": {
"@gram-data/gram-builder": "^0.2.9",
"@gram-data/gram-builder": "^0.2.10",
"@types/jest": "^26.0.15",

@@ -69,3 +69,3 @@ "@types/unist": "^2.0.3",

"dependencies": {
"@gram-data/gram-ast": "^0.2.9"
"@gram-data/gram-ast": "^0.2.10"
},

@@ -75,3 +75,3 @@ "publishConfig": {

},
"gitHead": "1ff6bdb1c799a29a95540314bdb5b2a881971774"
"gitHead": "5ab0f6f900db922abaf69906f62d6cf23e12215e"
}

@@ -1,3 +0,25 @@

# Gram Value
Evaluate data graph AST values, producing Javascript primitive or object values.
Evaluate data graph AST values, producing Javascript primitive or object values.
## How to gram-value
### Install:
``` bash
npm install @gram-data/gram-value
```
### Build an AST using [[gram-builder]]:
``` TypeScript
import { node, edge } from '@gram-data/gram-builder';
const left = node('a');
const right = node('b');
const ast = edge([left, right], 'right');
```
## Next Steps
- Transform to js objects using [[gram-value]]
- Write back to a string using [[gram-stringify]]
- Introspect the AST using [[gram-ast]]

@@ -17,3 +17,2 @@ import {

isLiteral,
AnyGramLiteral,
isGramRecord,

@@ -51,5 +50,5 @@ } from '@gram-data/gram-ast';

if (isGramLiteralArray(recordValue)) {
return recordValue.map((v:GramLiteral) => valueOf(v));
return recordValue.map((v: GramLiteral) => valueOf(v));
} else if (isLiteral(recordValue)) {
return valueOfLiteral(recordValue as AnyGramLiteral);
return valueOfLiteral(recordValue as GramLiteral);
} else if (isGramRecord(recordValue)) {

@@ -64,18 +63,26 @@ return recordValue.reduce((acc, property) => {

function assertNever(x: never): never {
throw new Error("Unexpected object: " + x);
throw new Error('Unexpected object: ' + x);
}
export const valueOfLiteral = (ast:AnyGramLiteral):any => {
export const valueOfLiteral = (ast: GramLiteral): any => {
switch (ast.type) {
case 'boolean': return valueOfBoolean(ast);
case 'string': return valueOfString(ast);
case 'integer': return valueOfInteger(ast);
case 'decimal': return valueOfDecimal(ast);
case 'hexadecimal': return valueOfHexadecimal(ast);
case 'octal': return valueOfOctal(ast);
case 'tagged': return 'tag, you are it!';
case 'measurement': return 'measure by measure';
default:
return assertNever(ast)
case 'boolean':
return valueOfBoolean(ast);
case 'string':
return valueOfString(ast);
case 'integer':
return valueOfInteger(ast);
case 'decimal':
return valueOfDecimal(ast);
case 'hexadecimal':
return valueOfHexadecimal(ast);
case 'octal':
return valueOfOctal(ast);
case 'tagged':
return 'tag, you are it!';
case 'measurement':
return 'measure by measure';
default:
return assertNever(ast);
}
}
};

@@ -82,0 +89,0 @@ export const valueOfBoolean = (ast: BooleanLiteral) =>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc