Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
reverse-iterable-map
Advanced tools
A reverse-iterable map implementation based on the built-in Map object
A reverse-iterable map implementation based on the built-in Map object.
Downloads an ES module file.
curl -O https://github.com/kleinfreund/reverse-iterable-map.js/blob/master/src/reverse-iterable-map.js
import { ReverseIterableMap } from './src/reverse-iterable-map.js';
const map = new ReverseIterableMap();
Installs the node package as a dependency. It doesn’t have any non-development dependencies itself.
npm install --save reverse-iterable-map
import { ReverseIterableMap } from 'reverse-iterable-map';
const map = new ReverseIterableMap();
Note, that Node.js version 8.5 or higher is required, as it comes with support for ES modules. If you don’t want to use it as an ES module, you will need to transpile the package yourself.
… on the website::
kleinfreund.github.io/reverse-iterable-map.js
Prints test results to the console.
… on a local HTTP server:
npm run example
Prints test results to the console.
… with Node’s experimental ES module feature:
npm test
Part of the additions to ECMAScript 2015 are the iteration protocols: Iterable and iterator. The former allows arbitrary objects to become iterable. Following the rules of the protocol gives one iteration capabilities via the following techniques:
However, only the iteration in one direction is considered by the specification at the time. This means that we only get forward-iteration by default.
Now, with the iteration protocols, we could redefine the iteration behavior for our purpose and make an object backwards-iterable. At the same time, this means losing the ability to iterate forwards.
If you need both a forwards- and backwards-iterable object, this implementation might be for you.
That’s what I needed. To be precise, I needed to access an iterator at a specific location in my data structure and be able to iterate in both directions.
I tried to stick to the Map
interface as close as possible.
Implementing a reverse-iterable array, for example, can be accomplished by using the same techniques of this implementation.
FAQs
A reverse-iterable map implementation based on the built-in Map object
The npm package reverse-iterable-map receives a total of 3 weekly downloads. As such, reverse-iterable-map popularity was classified as not popular.
We found that reverse-iterable-map 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.