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

@getlang/get

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getlang/get - npm Package Compare versions

Comparing version 0.0.34 to 0.0.35

65

dist/execute.js

@@ -7,14 +7,3 @@ import { mapValues } from 'lodash-es';

import { http, html, json, js, headers, cookies } from '@getlang/lib';
import { invariant, NullSelectionError, QuerySyntaxError, ValueReferenceError, ImportError, NullInputError, } from '@getlang/utils';
class NullSelection {
selector;
constructor(selector) {
this.selector = selector;
}
}
function assert(value) {
if (value instanceof NullSelection) {
throw new NullSelectionError(value.selector);
}
}
import { invariant, NullSelectionError, QuerySyntaxError, ValueReferenceError, ImportError, NullInputError, NullSelection, } from '@getlang/utils';
function toValue(value, typeInfo) {

@@ -34,2 +23,4 @@ switch (typeInfo.type) {

return mapValues(value, (v, k) => toValue(v, typeInfo.schema[k]));
case Type.Maybe:
return toValue(value, typeInfo.option);
case Type.Value:

@@ -75,8 +66,6 @@ return value;

}
else {
context && scope.pushContext(context.value);
const value = await cb(context);
context && scope.popContext();
return value;
}
context && scope.pushContext(context.value);
const value = await cb(context);
context && scope.popContext();
return value;
}

@@ -90,5 +79,9 @@ let context;

}
return context?.value instanceof NullSelection
? context.value
: await unwrap(context, cb);
if (context?.value instanceof NullSelection) {
if (node.typeInfo.type === Type.Maybe) {
return context.value;
}
throw new NullSelectionError(context.value.selector);
}
return unwrap(context, cb);
}

@@ -130,3 +123,11 @@ const visitor = {

const value = await hooks.slice(slice.value, context ? toValue(context.value, context.typeInfo) : {}, context?.value ?? {});
return value === undefined ? new NullSelection(fauxSelector) : value;
if (value !== undefined) {
return value;
}
else if (node.typeInfo.type === Type.Maybe) {
return new NullSelection(fauxSelector);
}
else {
throw new NullSelectionError(fauxSelector);
}
});

@@ -143,4 +144,6 @@ },

const args = [context.value, selector, node.expand];
function select() {
switch (context.typeInfo.type) {
function select(typeInfo) {
switch (typeInfo.type) {
case Type.Maybe:
return select(typeInfo.option);
case Type.Html:

@@ -158,4 +161,8 @@ return html.select(...args);

}
const result = select();
return result === undefined ? new NullSelection(selector) : result;
const result = select(context.typeInfo);
if (result instanceof NullSelection &&
node.typeInfo.type !== Type.Maybe) {
throw new NullSelectionError(selector);
}
return result;
});

@@ -195,3 +202,2 @@ },

const value = await visit(entry.value);
entry.optional || assert(value);
if (!(value instanceof NullSelection)) {

@@ -252,3 +258,2 @@ const key = await visit(entry.key);

AssignmentStmt(node) {
node.optional || assert(node.value);
scope.vars[node.name.value] = node.value;

@@ -260,3 +265,5 @@ },

ExtractStmt(node) {
assert(node.value);
if (node.value instanceof NullSelection) {
throw new NullSelectionError(node.value.selector);
}
scope.extracted = node.value;

@@ -263,0 +270,0 @@ },

@@ -17,2 +17,3 @@ import { mapValues } from 'lodash-es'

NullInputError,
NullSelection,
} from '@getlang/utils'

@@ -28,12 +29,2 @@

class NullSelection {
constructor(public selector: string) {}
}
function assert(value: any) {
if (value instanceof NullSelection) {
throw new NullSelectionError(value.selector)
}
}
function toValue(value: any, typeInfo: TypeInfo): any {

@@ -53,2 +44,4 @@ switch (typeInfo.type) {

return mapValues(value, (v, k) => toValue(v, typeInfo.schema[k]!))
case Type.Maybe:
return toValue(value, typeInfo.option)
case Type.Value:

@@ -112,8 +105,8 @@ return value

return list
} else {
context && scope.pushContext(context.value)
const value = await cb(context)
context && scope.popContext()
return value
}
context && scope.pushContext(context.value)
const value = await cb(context)
context && scope.popContext()
return value
}

@@ -129,5 +122,10 @@

return context?.value instanceof NullSelection
? context.value
: await unwrap(context, cb)
if (context?.value instanceof NullSelection) {
if (node.typeInfo.type === Type.Maybe) {
return context.value
}
throw new NullSelectionError(context.value.selector)
}
return unwrap(context, cb)
}

@@ -179,3 +177,9 @@

)
return value === undefined ? new NullSelection(fauxSelector) : value
if (value !== undefined) {
return value
} else if (node.typeInfo.type === Type.Maybe) {
return new NullSelection(fauxSelector)
} else {
throw new NullSelectionError(fauxSelector)
}
})

@@ -194,4 +198,6 @@ },

function select() {
switch (context!.typeInfo.type) {
function select(typeInfo: TypeInfo) {
switch (typeInfo.type) {
case Type.Maybe:
return select(typeInfo.option)
case Type.Html:

@@ -210,4 +216,10 @@ return html.select(...args)

const result = select()
return result === undefined ? new NullSelection(selector) : result
const result = select(context!.typeInfo)
if (
result instanceof NullSelection &&
node.typeInfo.type !== Type.Maybe
) {
throw new NullSelectionError(selector)
}
return result
})

@@ -254,3 +266,2 @@ },

const value = await visit(entry.value)
entry.optional || assert(value)
if (!(value instanceof NullSelection)) {

@@ -327,3 +338,2 @@ const key = await visit(entry.key)

AssignmentStmt(node) {
node.optional || assert(node.value)
scope.vars[node.name.value] = node.value

@@ -337,3 +347,5 @@ },

ExtractStmt(node) {
assert(node.value)
if (node.value instanceof NullSelection) {
throw new NullSelectionError(node.value.selector)
}
scope.extracted = node.value

@@ -340,0 +352,0 @@ },

{
"name": "@getlang/get",
"version": "0.0.34",
"version": "0.0.35",
"license": "Apache-2.0",

@@ -20,5 +20,5 @@ "type": "module",

"dependencies": {
"@getlang/lib": "^0.0.15",
"@getlang/utils": "^0.0.14",
"@getlang/parser": "^0.0.24",
"@getlang/lib": "^0.0.16",
"@getlang/utils": "^0.0.15",
"@getlang/parser": "^0.0.25",
"lodash-es": "^4.17.21"

@@ -25,0 +25,0 @@ },

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