pax_global_header 0000666 0000000 0000000 00000000064 14360204625 0014514 g ustar 00root root 0000000 0000000 52 comment=863e1da087856bfaeccd72593b258728e09b964c
stop-iteration-iterator-1.0.0/ 0000775 0000000 0000000 00000000000 14360204625 0016322 5 ustar 00root root 0000000 0000000 stop-iteration-iterator-1.0.0/.eslintrc 0000664 0000000 0000000 00000000242 14360204625 0020144 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"globals": {
"StopIteration": false,
},
"rules": {
"func-name-matching": [2, "always"],
"id-length": 0,
},
}
stop-iteration-iterator-1.0.0/.github/ 0000775 0000000 0000000 00000000000 14360204625 0017662 5 ustar 00root root 0000000 0000000 stop-iteration-iterator-1.0.0/.github/FUNDING.yml 0000664 0000000 0000000 00000001122 14360204625 0021473 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/stop-iteration-iterator
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
stop-iteration-iterator-1.0.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14360204625 0021717 5 ustar 00root root 0000000 0000000 stop-iteration-iterator-1.0.0/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000516 14360204625 0024477 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '< 10'
type: minors
command: npm run tests-only
node:
name: 'node < 10'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
stop-iteration-iterator-1.0.0/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000206 14360204625 0025051 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
stop-iteration-iterator-1.0.0/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000521 14360204625 0024334 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 10'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10'
type: minors
command: npm run tests-only
node:
name: 'node >= 10'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
stop-iteration-iterator-1.0.0/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000700 14360204625 0023700 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
permissions:
contents: read
jobs:
_:
permissions:
contents: write # for ljharb/rebase to push code to rebase
pull-requests: read # for ljharb/rebase to get info about PR
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
stop-iteration-iterator-1.0.0/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 14360204625 0026334 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
stop-iteration-iterator-1.0.0/.gitignore 0000664 0000000 0000000 00000003251 14360204625 0020313 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
.npmignore
stop-iteration-iterator-1.0.0/.npmrc 0000664 0000000 0000000 00000000067 14360204625 0017445 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
stop-iteration-iterator-1.0.0/.nycrc 0000664 0000000 0000000 00000000330 14360204625 0017435 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}
stop-iteration-iterator-1.0.0/CHANGELOG.md 0000664 0000000 0000000 00000001621 14360204625 0020133 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
## v1.0.0 - 2023-01-12
### Commits
- Initial implementation, tests, readme [`43e8109`](https://github.com/ljharb/stop-iteration-iterator/commit/43e81099d2f2b63ff3a8a253ad13dd8279c9e2dc)
- Initial commit [`23929ce`](https://github.com/ljharb/stop-iteration-iterator/commit/23929ce525165bfe54f053284fd066dce8598486)
- npm init [`a9847ab`](https://github.com/ljharb/stop-iteration-iterator/commit/a9847ab637a7c223fb7478d47caf04e89ba283ff)
- Only apps should have lockfiles [`4e41f3f`](https://github.com/ljharb/stop-iteration-iterator/commit/4e41f3fbbaf8a1d32b12514d7296961e5df73e4b)
stop-iteration-iterator-1.0.0/LICENSE 0000664 0000000 0000000 00000002057 14360204625 0017333 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2023 Jordan Harband
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
stop-iteration-iterator-1.0.0/README.md 0000664 0000000 0000000 00000003475 14360204625 0017612 0 ustar 00root root 0000000 0000000 # stop-iteration-iterator [![Version Badge][npm-version-svg]][package-url]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
Firefox 17-26 iterators throw a StopIteration object to indicate "done". This normalizes it.
# Usage
```js
var stopIterationIterator = require('stop-iteration-iterator');
var s = new Set([1, 2]);
var iterator = stopIterationIterator(s.keys());
iterator.next(); // { done: false, value: 1 }
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/stop-iteration-iterator
[npm-version-svg]: https://versionbadg.es/ljharb/stop-iteration-iterator.svg
[deps-svg]: https://david-dm.org/ljharb/stop-iteration-iterator.svg
[deps-url]: https://david-dm.org/ljharb/stop-iteration-iterator
[dev-deps-svg]: https://david-dm.org/ljharb/stop-iteration-iterator/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/stop-iteration-iterator#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/stop-iteration-iterator.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/stop-iteration-iterator.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/stop-iteration-iterator.svg
[downloads-url]: https://npm-stat.com/charts.html?package=stop-iteration-iterator
[codecov-image]: https://codecov.io/gh/ljharb/stop-iteration-iterator/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/stop-iteration-iterator/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/stop-iteration-iterator
[actions-url]: https://github.com/ljharb/stop-iteration-iterator/actions
stop-iteration-iterator-1.0.0/index.js 0000664 0000000 0000000 00000001555 14360204625 0017775 0 ustar 00root root 0000000 0000000 'use strict';
var SLOT = require('internal-slot');
var $SyntaxError = SyntaxError;
var $StopIteration = typeof StopIteration === 'object' ? StopIteration : null;
module.exports = function getStopIterationIterator(origIterator) {
if (!$StopIteration) {
throw new $SyntaxError('this environment lacks StopIteration');
}
SLOT.set(origIterator, '[[Done]]', false);
var siIterator = {
next: function next() {
var iterator = SLOT.get(this, '[[Iterator]]');
var done = SLOT.get(iterator, '[[Done]]');
try {
return {
done: done,
value: done ? void undefined : iterator.next()
};
} catch (e) {
SLOT.set(iterator, '[[Done]]', true);
if (e !== $StopIteration) {
throw e;
}
return {
done: true,
value: void undefined
};
}
}
};
SLOT.set(siIterator, '[[Iterator]]', origIterator);
return siIterator;
};
stop-iteration-iterator-1.0.0/package.json 0000664 0000000 0000000 00000003455 14360204625 0020617 0 ustar 00root root 0000000 0000000 {
"name": "stop-iteration-iterator",
"version": "1.0.0",
"description": "Firefox 17-26 iterators throw a StopIteration object to indicate \"done\". This normalizes it.",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/stop-iteration-iterator.git"
},
"keywords": [
"stopiteration",
"iterator",
"firefox"
],
"author": "Jordan Harband ",
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/stop-iteration-iterator/issues"
},
"homepage": "https://github.com/ljharb/stop-iteration-iterator#readme",
"dependencies": {
"internal-slot": "^1.0.4"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.0.1",
"aud": "^2.0.2",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.1"
},
"engines": {
"node": ">= 0.4"
},
"testling": {
"files": "test/index.js"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}
stop-iteration-iterator-1.0.0/test/ 0000775 0000000 0000000 00000000000 14360204625 0017301 5 ustar 00root root 0000000 0000000 stop-iteration-iterator-1.0.0/test/index.js 0000664 0000000 0000000 00000002217 14360204625 0020750 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var stopIterationIterator = require('../');
test('stopIterationIterator', function (t) {
t.equal(typeof stopIterationIterator, 'function', 'stopIterationIterator is a function');
t.test('no StopIteration support', { skip: typeof StopIteration === 'object' }, function (st) {
st['throws'](
function () { stopIterationIterator(); },
SyntaxError,
'throws a SyntaxError when StopIteration is not supported'
);
st.end();
});
t.test('StopIteration support', { skip: typeof StopIteration !== 'object' }, function (st) {
var s = new Set([1, 2]);
var i = s.iterator();
st.equal(i.next(), 1, 'first item is 1');
st.equal(i.next(), 2, 'second item is 2');
try {
i.next();
st.fail();
} catch (e) {
st.equal(e, StopIteration, 'StopIteration thrown');
}
var m = new Map([[1, 'a'], [2, 'b']]);
var mi = m.iterator();
st.deepEqual(mi.next(), [1, 'a'], 'first item is 1 and a');
st.deepEqual(mi.next(), [2, 'b'], 'second item is 2 and b');
try {
mi.next();
st.fail();
} catch (e) {
st.equal(e, StopIteration, 'StopIteration thrown');
}
st.end();
});
t.end();
});