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

3xpr

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

3xpr - npm Package Compare versions

Comparing version 1.6.10 to 1.6.11

expression/operand/library.d.ts

6

expression/expressions.d.ts

@@ -30,2 +30,8 @@ import { Operand, IExpressions, IParameterManager, IBuilder, Parameter, Format, IOperandBuilder, OperatorMetadata, ITypeManager, IModelManager, ActionObserver, FunctionAdditionalInfo, OperatorAdditionalInfo } from './contract';

/**
* Convert a lambda expression to a query expression
* @param lambda lambda expression
* @returns Expression manager
*/
toExpression(func: Function): string;
/**
* Get parameters of expression

@@ -32,0 +38,0 @@ * @param expression expression

39

expression/expressions.js

@@ -8,2 +8,3 @@ "use strict";

const h3lp_1 = require("h3lp");
const helper_1 = require("./helper");
const _1 = require(".");

@@ -79,2 +80,34 @@ // eslint-disable-next-line no-use-before-define

/**
* Convert a lambda expression to a query expression
* @param lambda lambda expression
* @returns Expression manager
*/
// eslint-disable-next-line @typescript-eslint/ban-types
toExpression(func) {
if (!func) {
throw new Error('empty lambda function}');
}
const expression = helper_1.helper.expression.clearLambda(func);
const operand = this.build(expression);
let aux = operand;
while (aux.type !== contract_1.OperandType.Var) {
if (aux.children.length > 0) {
aux = aux.children[0];
}
}
if (aux.name.includes('.')) {
// Example: __model_1.Products.map(p=>p) => Products.map(p=>p)
// Example: __model_1.Orders.details.map(p=>p) => Orders.details.map(p=>p)
const names = aux.name.split('.');
if (names[0].startsWith('__')) {
// aux.name = names.slice(1).join('.')
const result = expression.replace(names[0] + '.', '');
return result;
}
}
// Example: Products.map(p=>p) => Products.map(p=>p)
// Example: Orders.details.map(p=>p) => Orders.details.map(p=>p)
return expression;
}
/**
* Get parameters of expression

@@ -147,3 +180,3 @@ * @param expression expression

try {
const key = h3lp_1.h3lp.utils.hashCode(expression);
const key = helper_1.helper.utils.hashCode(expression);
const value = this.cache.get(key);

@@ -165,3 +198,3 @@ if (!value) {

try {
const key = h3lp_1.h3lp.utils.hashCode(expression);
const key = helper_1.helper.utils.hashCode(expression);
const value = this.processCache.get(key);

@@ -182,3 +215,3 @@ if (!value) {

typed(expression) {
const key = h3lp_1.h3lp.utils.hashCode(expression);
const key = helper_1.helper.utils.hashCode(expression);
const value = this.cache.get(key);

@@ -185,0 +218,0 @@ if (!value) {

@@ -1,7 +0,13 @@

import { H3lp } from 'h3lp';
import { H3lp, StringHelper } from 'h3lp';
import { OperandHelper } from './operand';
export declare class ExpressionHelper {
private readonly str;
constructor(str: StringHelper);
clearLambda(func: Function): string;
}
export declare class ExpHelper extends H3lp {
operand: OperandHelper;
expression: ExpressionHelper;
constructor();
}
export declare const helper: ExpHelper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.helper = exports.ExpHelper = void 0;
exports.helper = exports.ExpHelper = exports.ExpressionHelper = void 0;
const h3lp_1 = require("h3lp");
const operand_1 = require("./operand");
class ExpressionHelper {
// eslint-disable-next-line no-useless-constructor
constructor(str) {
this.str = str;
}
// eslint-disable-next-line @typescript-eslint/ban-types
clearLambda(func) {
let str = func.toString().trim();
let index = str.indexOf('=>') + 2;
str = str.substring(index, str.length).trim();
index = str.indexOf('(');
if (index > -1) {
// Example: xxx.Products.map()
const form = str.substring(0, index).trim();
const parts = form.split('.');
if (parts.length > 2) {
return this.str.replace(str, parts[0] + '.', '');
}
}
else {
// Example: xxx.Products
const parts = str.split('.');
if (parts.length > 1) {
return this.str.replace(str, parts[0] + '.', '');
}
}
return str;
}
}
exports.ExpressionHelper = ExpressionHelper;
class ExpHelper extends h3lp_1.H3lp {

@@ -10,2 +40,3 @@ constructor() {

this.operand = operand_1.operandHelper;
this.expression = new ExpressionHelper(this.str);
}

@@ -12,0 +43,0 @@ }

2

expression/operand/index.d.ts

@@ -7,3 +7,3 @@ export * from './evaluators';

export * from './parameters';
export * from './coreLibrary';
export * from './library';
export * from './model';

@@ -10,0 +10,0 @@ export * from './helper';

@@ -23,3 +23,3 @@ "use strict";

__exportStar(require("./parameters"), exports);
__exportStar(require("./coreLibrary"), exports);
__exportStar(require("./library"), exports);
__exportStar(require("./model"), exports);

@@ -26,0 +26,0 @@ __exportStar(require("./helper"), exports);

{
"name": "3xpr",
"version": "1.6.10",
"version": "1.6.11",
"description": "expressions",

@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>",

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