
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Thener is a library that mimics the then portion of a promise, allowing stateful capture of a value and uni-directional transfer function passed to then.
Thener is a library that mimics the then portion of a promise, allowing stateful capture of a value and uni-directional transfer using functions passed to then.
const thn = new Thener(1);
const thn2 = thn.then(e => 2 * e);
console.log(thn2.value); // 2
npm install thener
Import and Construct
import Thener from "thener";
const thn = new Thener(3);
console.log(thn.value) // 3
Then
const thn2 = thn.then(e => 2 * e);
console.log(thn2.value); // 6
Finally
thn2.finally(() => console.log("No Change to value"));
console.log(thn2.value); // 6
Then Again
const thn3 = thn2.then(e => 2 * e);
console.log(thn3.value); // 12
Errors
thn2.then(() => { throw "Er1" }).then(() => { throw "Er2" });
thn2.catch(e => console.log(e)); // print errors
Thener accepts any type and will store it internally. Thener's are immutable, any action will return a clone, or Thener with new value and carried over errors.
import Thener from "thener";
const thn = new Thener(3);
console.log(thn.value) // 3
then allows you to pass in a function to process the internal Thener data with. then checks if the passed in value is a function, if it is not, it clones the current then. then wraps your function in a try/catch block, if an error occurs, it is stored internally in an error array for processing using catch. If you would like to change what error value is stored, wrap your function in a try/catch block and throw the value you wish to capture. Errors on the current Thener will be added to the new Thener.
import Thener from "thener";
const thn = new Thener(3);
const thn2 = thn.then(e => 2 * e);
console.log(thn2.value); // 6
finally allows you to execute a function that isn't connected to internal data.
import Thener from "thener";
const thn = new Thener(3);
thn.finally(e => 2*e);
console.log(thn.value) // 3
catch allows you to process all of the stored errors by passing in a function.
thn.then(() => { throw "Er1" }).then(() => { throw "Er2" });
thn.catch(e => console.log(e)); // print errors
A read only property returning the current internal value.
import Thener from "thener";
const thn = new Thener(3);
console.log(thn.value) // 3
To run mocha/chai tests. npm run test
To run the main example. npm run ex
Thener.js is relased under the MIT license.
FAQs
Thener is a library that mimics the then portion of a promise, allowing stateful capture of a value and uni-directional transfer function passed to then.
We found that thener demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.