UNPKG

@neo4j/cypher-builder

Version:

A programmatic API for building Cypher queries for Neo4j

275 lines (274 loc) 9.61 kB
"use strict"; /* * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] */ Object.defineProperty(exports, "__esModule", { value: true }); exports.abs = abs; exports.ceil = ceil; exports.floor = floor; exports.cypherIsNaN = cypherIsNaN; exports.rand = rand; exports.round = round; exports.sign = sign; exports.e = e; exports.exp = exp; exports.log = log; exports.log10 = log10; exports.sqrt = sqrt; exports.acos = acos; exports.asin = asin; exports.atan = atan; exports.atan2 = atan2; exports.cos = cos; exports.cot = cot; exports.degrees = degrees; exports.haversin = haversin; exports.pi = pi; exports.radians = radians; exports.sin = sin; exports.tan = tan; exports.cosh = cosh; exports.coth = coth; exports.sinh = sinh; exports.tanh = tanh; const Cypher_1 = require("../../Cypher"); const filter_truthy_1 = require("../../utils/filter-truthy"); const CypherFunctions_1 = require("./CypherFunctions"); /** Returns the absolute value of an `INTEGER` or `FLOAT` * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-abs | Cypher Documentation} * @group Functions * @category Math */ function abs(expr) { return new CypherFunctions_1.CypherFunction("abs", [expr]); } /** Returns the smallest FLOAT that is greater than or equal to a number and equal to an `INTEGER` * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-ceil | Cypher Documentation} * @group Functions * @category Math */ function ceil(expr) { return new CypherFunctions_1.CypherFunction("ceil", [expr]); } /** Returns the largest `FLOAT` that is less than or equal to a number and equal to an `INTEGER` * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-floor | Cypher Documentation} * @group Functions * @category Math */ function floor(expr) { return new CypherFunctions_1.CypherFunction("floor", [expr]); } /** Returns whether the given `INTEGER` or `FLOAT` is `NaN` * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-isnan | Cypher Documentation} * @group Functions * @category Math */ function cypherIsNaN(expr) { return new CypherFunctions_1.CypherFunction("isNaN", [expr]); } /** Returns a random `FLOAT` in the range from 0 (inclusive) to 1 (exclusive) * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-rand | Cypher Documentation} * @group Functions * @category Math */ function rand() { return new CypherFunctions_1.CypherFunction("rand"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-round | Cypher Documentation} * @group Functions * @category Math */ function round(expr, precision, mode) { let precisionExpr; const modeExpr = mode ? new Cypher_1.Literal(mode) : undefined; if (typeof precision === "number") { precisionExpr = new Cypher_1.Literal(precision); } else { precisionExpr = precision; } return new CypherFunctions_1.CypherFunction("round", (0, filter_truthy_1.filterTruthy)([expr, precisionExpr, modeExpr])); } /** Returns the signum of an `INTEGER` or `FLOAT`: 0 if the number is 0, -1 for any negative number, and 1 for any positive number * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-sign | Cypher Documentation} * @group Functions * @category Math */ function sign(expr) { return new CypherFunctions_1.CypherFunction("sign", [expr]); } /** Cypher function `e()` that returns the returns the base of the natural logarithm. * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-e | Cypher Documentation} * @group Functions * @category Math */ function e() { return new CypherFunctions_1.CypherFunction("e"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-exp | Cypher Documentation} * @group Functions * @category Math */ function exp(expr) { return new CypherFunctions_1.CypherFunction("exp", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-log | Cypher Documentation} * @group Functions * @category Math */ function log(expr) { return new CypherFunctions_1.CypherFunction("log", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-log10 | Cypher Documentation} * @group Functions * @category Math */ function log10(expr) { return new CypherFunctions_1.CypherFunction("log10", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-sqrt | Cypher Documentation} * @group Functions * @category Math */ function sqrt(expr) { return new CypherFunctions_1.CypherFunction("sqrt", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-acos | Cypher Documentation} * @group Functions * @category Math */ function acos(expr) { return new CypherFunctions_1.CypherFunction("acos", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-asin | Cypher Documentation} * @group Functions * @category Math */ function asin(expr) { return new CypherFunctions_1.CypherFunction("asin", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-atan | Cypher Documentation} * @group Functions * @category Math */ function atan(expr) { return new CypherFunctions_1.CypherFunction("atan", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-atan2 | Cypher Documentation} * @group Functions * @category Math */ function atan2(expr) { return new CypherFunctions_1.CypherFunction("atan2", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-cos | Cypher Documentation} * @group Functions * @category Math */ function cos(expr) { return new CypherFunctions_1.CypherFunction("cos", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-cot | Cypher Documentation} * @group Functions * @category Math */ function cot(expr) { return new CypherFunctions_1.CypherFunction("cot", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-degrees | Cypher Documentation} * @group Functions * @category Math */ function degrees(expr) { return new CypherFunctions_1.CypherFunction("degrees", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-haversin | Cypher Documentation} * @group Functions * @category Math */ function haversin(expr) { return new CypherFunctions_1.CypherFunction("haversin", [expr]); } /** 3.141592653589793 * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-pi | Cypher Documentation} * @see https://www.piday.org/ * @group Functions * @category Math */ function pi() { return new CypherFunctions_1.CypherFunction("pi"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-radians | Cypher Documentation} * @group Functions * @category Math */ function radians(expr) { return new CypherFunctions_1.CypherFunction("radians", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-sin | Cypher Documentation} * @group Functions * @category Math */ function sin(expr) { return new CypherFunctions_1.CypherFunction("sin", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-tan | Cypher Documentation} * @group Functions * @category Math */ function tan(expr) { return new CypherFunctions_1.CypherFunction("tan", [expr]); } /** Returns the hyperbolic cosine * @see {@link https://neo4j.com/docs/cypher-manual/25/functions/mathematical-trigonometric/#functions-cosh | Cypher Documentation} * @group Functions * @category Math * @since Neo4j 2025.06 */ function cosh(expr) { return new CypherFunctions_1.CypherFunction("cosh", [expr]); } /** Returns the hyperbolic cotangent * @see {@link https://neo4j.com/docs/cypher-manual/25/functions/mathematical-trigonometric/#functions-coth | Cypher Documentation} * @group Functions * @category Math * @since Neo4j 2025.06 */ function coth(expr) { return new CypherFunctions_1.CypherFunction("coth", [expr]); } /** Returns the hyperbolic sine * @see {@link https://neo4j.com/docs/cypher-manual/25/functions/mathematical-trigonometric/#functions-sinh | Cypher Documentation} * @group Functions * @category Math * @since Neo4j 2025.06 */ function sinh(expr) { return new CypherFunctions_1.CypherFunction("sinh", [expr]); } /** Returns the hyperbolic tangent * @see {@link https://neo4j.com/docs/cypher-manual/25/functions/mathematical-trigonometric/#functions-tanh | Cypher Documentation} * @group Functions * @category Math * @since Neo4j 2025.06 */ function tanh(expr) { return new CypherFunctions_1.CypherFunction("tanh", [expr]); }