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

@fauna-labs/fql-utilities

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fauna-labs/fql-utilities - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

babel.config.js

34

dist/collections/tail.d.ts
import faunadb from 'faunadb';
/**
* @param {Array<any>} array - The array to take the tail from.
* @returns {Array<any>} - The tail of the array.
*
* Tail() accepts a Fauna Array and returns a new array consisting of every
* element except the first. If the array is empty, Tail() returns an empty array.
*
* ### Consumes per call
* * 0 Read Ops
* * 0 Write Ops
* * 1 ComputeOp (19 FQL verbs)
*
* ### Dependencies:
* none
*
* ### Usage in Fauna Schema Migrate:
* ```js
* import { Tail } from '@fauna-labs/fql-utilities/collections';
* export default Tail();
* ```
*
* ### Usage in FQL:
* ```fql
* Let(
* {
* array: [0, 1, 2],
* shortArray: Call("Tail", Var("array"))
* },
* Equals(Count(Var("shortArray")), 2) // true
* )
*```
*/
export declare function Tail(): faunadb.Expr;
export declare function Tail(replace?: boolean): faunadb.Expr;

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

const q = faunadb_1.default.query;
const { Abort, Count, If, IsArray, Lambda, Let, LT, Query, Reverse, Subtract, Take, Var } = q;
const { Abort, Count, Exists, If, IsArray, Lambda, Let, LT, Query, Update, Reverse, Subtract, Take, Var } = q;
/**

@@ -61,6 +61,14 @@ * @param {Array<any>} array - The array to take the tail from.

*/
function Tail() {
const body = Query(Lambda(["array"], If(IsArray(Var("array")), Let({ tail_length: Subtract(Count(Var("array")), 1) }, If(LT(Var("tail_length"), 0), Var("array"), Reverse(Take(Var("tail_length"), Reverse(Var("array")))))), Abort("Tail() requires one argument that is an array."))));
// export function Tail(): faunadb.Expr {
// return If(
// Exists(Function("Tail")),
// Update(Function("Tail"), { body: body }),
// CreateFunction({ name: "Tail", body: body })
// );
// }
function Tail(replace = false) {
return (0, faunadb_1.CreateFunction)({
name: "Tail",
body: Query(Lambda(["array"], If(IsArray(Var("array")), Let({ tail_length: Subtract(Count(Var("array")), 1) }, If(LT(Var("tail_length"), 0), Var("array"), Reverse(Take(Var("tail_length"), Reverse(Var("array")))))), Abort("Tail() requires one argument that is an array."))))
body: body
});

@@ -67,0 +75,0 @@ }

{
"name": "@fauna-labs/fql-utilities",
"version": "0.1.1",
"version": "0.1.2",
"description": "A library of FQL utilities for Fauna Schema Migrate, implemented in TypeScript.",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"prepare": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},

@@ -37,4 +37,10 @@ "repository": {

"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^27.0.2",
"babel-jest": "^27.2.5",
"jest": "^27.2.5",
"typescript": "^4.4.3"
}
}

@@ -16,3 +16,3 @@ {

"exclude": ["node_modules", "test", "dist"],
"include": ["src/**/*"]
"include": ["src/**/*", "tests/index.test.ts"]
}

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