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

tallstack

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tallstack - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

15

index.js

@@ -45,6 +45,2 @@ /*

shouldDelayExecution() {
return Boolean(this.numberOfPendingArguments);
}
pushUnevaluatedArguments(stack) {

@@ -110,19 +106,20 @@ const L = this.args.length;

let cur;
let result;
OUTER:
while (this.frames.length !== 0) {
cur = this.frames[this.frames.length - 1];
if (cur.shouldDelayExecution()) {
if (cur.numberOfPendingArguments > 0) {
cur.pushUnevaluatedArguments(this.frames);
continue;
}
cur = this.frames.pop();
this.frames.pop();
let result = cur.evaluate();
result = cur.evaluate();
while (result === NULL) {
cur = this.frames[this.frames.length - 1];
if (cur.shouldDelayExecution()) {
if (cur.numberOfPendingArguments > 0) {
cur.pushUnevaluatedArguments(this.frames);
continue OUTER;
}
cur = this.frames.pop();
this.frames.pop();
result = cur.evaluate();

@@ -129,0 +126,0 @@ }

2

package.json
{
"name": "tallstack",
"version": "0.0.4",
"version": "0.0.5",
"description": "A library that allows you to define recursive functions in JavaScript without stack overflow.",

@@ -5,0 +5,0 @@ "main": "index.js",

# tallstack
A small libarary which allows you to define tail recursive functions
A small library which allows you to define tail recursive functions
in JavaScript that will not cause stack overflow.

@@ -10,4 +10,4 @@

1. [How do I use it?](#how-do-i-use-it?)
2. [How does it work?](#how-does-it-work?)
1. [How do I use it?](#how-do-i-use-it)
2. [How does it work?](#how-does-it-work)
3. [What are the drawbacks?](#what-are-the-drawbacks)

@@ -20,3 +20,3 @@ 4. [License](#license)

The library only exports 3 functions, `call`, `callWithContext`, and `recursive`.
Let's look at an example function which computes the `N`th factorial number:
Let's look at an example function which computes the `N` factorial:

@@ -66,3 +66,3 @@ ```javascript

```javascript
const { call, callWithContext } = require('tallstack');
const { recursive, call, callWithContext } = require('tallstack');

@@ -119,3 +119,3 @@ const obj = { multiply: (x, y) => (x * y) };

So far this library does not evaluate functions as quickly as native JavaScript recursion.
To some extent this is to be expected, due to the added complexity added to just normal function
To some extent this is to be expected, due to the added complexity on top of normal function
evaluation. Right now the performance seems to degrade as your recursion tree gets wider (i.e. each

@@ -122,0 +122,0 @@ call has many recursive calls). I have done some work to speed it up but it is not quite as fast as

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