pax_global_header00006660000000000000000000000064143215660410014514gustar00rootroot0000000000000052 comment=8c91c7c37eb89cf47bddfc4b4f7aac813fa11abe concat-map-0.0.2/000077500000000000000000000000001432156604100135355ustar00rootroot00000000000000concat-map-0.0.2/.eslintrc000066400000000000000000000002731432156604100153630ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "array-bracket-newline": 0, }, "overrides": [ { "files": "example/**", "rules": { "no-console": 0, }, }, ], } concat-map-0.0.2/.github/000077500000000000000000000000001432156604100150755ustar00rootroot00000000000000concat-map-0.0.2/.github/FUNDING.yml000066400000000000000000000011051432156604100167070ustar00rootroot00000000000000# 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/concat-map 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'] concat-map-0.0.2/.github/workflows/000077500000000000000000000000001432156604100171325ustar00rootroot00000000000000concat-map-0.0.2/.github/workflows/node-aught.yml000066400000000000000000000005161432156604100217120ustar00rootroot00000000000000name: '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' concat-map-0.0.2/.github/workflows/node-pretest.yml000066400000000000000000000002061432156604100222640ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main concat-map-0.0.2/.github/workflows/node-tens.yml000066400000000000000000000005211432156604100215470ustar00rootroot00000000000000name: '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' concat-map-0.0.2/.github/workflows/rebase.yml000066400000000000000000000004111432156604100211120ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: name: "Automatic Rebase" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/rebase@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} concat-map-0.0.2/.github/workflows/require-allow-edits.yml000066400000000000000000000003031432156604100235470ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main concat-map-0.0.2/.gitignore000066400000000000000000000001721432156604100155250ustar00rootroot00000000000000# gitignore node_modules/ # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock .npmignore concat-map-0.0.2/.npmrc000066400000000000000000000000671432156604100146600ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s concat-map-0.0.2/CHANGELOG.md000066400000000000000000000100171432156604100153450ustar00rootroot00000000000000# 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). ## [v0.0.2](https://github.com/ljharb/node-concat-map/compare/v0.0.1...v0.0.2) - 2022-10-12 ### Commits - [eslint] fix indentation [`7015b7b`](https://github.com/ljharb/node-concat-map/commit/7015b7bf8a893d381e919eb68143d75c7fa85994) - [readme] rename, add badges [`e31ccb4`](https://github.com/ljharb/node-concat-map/commit/e31ccb443914785600eb7e1340c13808ab7f4722) - [actions] add reusable workflows [`95b4764`](https://github.com/ljharb/node-concat-map/commit/95b47641677a95369272389ac838f1bd5122c4f3) - [Dev Deps] update `tape` [`a068899`](https://github.com/ljharb/node-concat-map/commit/a068899e29a5263857a68984bfbea3fa85340766) - [eslint] add eslint [`e965df9`](https://github.com/ljharb/node-concat-map/commit/e965df9657255fc0be9352310d9c0cc96daf1be8) - [meta] add `auto-changelog` [`eee5dc2`](https://github.com/ljharb/node-concat-map/commit/eee5dc2946ee52a5e068862076fb78bc81dfca81) - [meta] use `npmignore` to autogenerate an npmignore file [`4a8e034`](https://github.com/ljharb/node-concat-map/commit/4a8e034e33f99490e7d0122c9d599ddc8ecf0d10) - Only apps should have lockfiles [`c39fa6c`](https://github.com/ljharb/node-concat-map/commit/c39fa6c0092600b744ceba645ff7abd94ef26abc) - [meta] update URLs [`a321524`](https://github.com/ljharb/node-concat-map/commit/a3215244d293bba7497732f90b127a2775863000) - [meta] add `safe-publish-latest` [`bd95e66`](https://github.com/ljharb/node-concat-map/commit/bd95e665a927c68c5351f6189e96959a55980de2) - [Tests] add `aud` in `posttest` [`075e7f9`](https://github.com/ljharb/node-concat-map/commit/075e7f9e6dee29f5a73ad9f5fc35368ec5bf2fbc) - upgrade node versions [`ac5bd7a`](https://github.com/ljharb/node-concat-map/commit/ac5bd7a95c76a862fb26d8bddfbef19821b7ec95) - [meta] create FUNDING.yml; add `funding` in package.json [`717b783`](https://github.com/ljharb/node-concat-map/commit/717b78381853cfb06458b6d70693a43b95f8a396) ## [v0.0.1](https://github.com/ljharb/node-concat-map/compare/v0.0.0...v0.0.1) - 2014-01-29 ### Commits - license file [`91472cd`](https://github.com/ljharb/node-concat-map/commit/91472cd322299c7f8059be3ca4aabc07f7b4b15a) - using testling-ci [`e5f90f8`](https://github.com/ljharb/node-concat-map/commit/e5f90f8933516e94ec746aed85d3b175c5d69745) - upgrade tape [`fb6cd24`](https://github.com/ljharb/node-concat-map/commit/fb6cd24d57bc77aaab2ed4d3c475dbf749d618a0) - fixes for ie6-8 [`27b9a4a`](https://github.com/ljharb/node-concat-map/commit/27b9a4a19eb2c3501bc40b633d54a8e99c08765b) - using tape [`c1a4e78`](https://github.com/ljharb/node-concat-map/commit/c1a4e788eedd984f36d2c76cb197ede18082bfeb) - more firefoxes [`22b491e`](https://github.com/ljharb/node-concat-map/commit/22b491e7a72cbad300fba8c3885dbcead4fa3607) ## v0.0.0 - 2012-06-07 ### Commits - and a readme [`5f7ca89`](https://github.com/ljharb/node-concat-map/commit/5f7ca89bdf221110b6c291be24bbfd38ab8e8643) - and a package.json [`b0a752e`](https://github.com/ljharb/node-concat-map/commit/b0a752e4d7ce9a9ce95364e29f468aefb6c336ee) - more passing tests [`9bf7939`](https://github.com/ljharb/node-concat-map/commit/9bf793982ca938be6d95800e545835a362d62c56) - document methods [`ded159b`](https://github.com/ljharb/node-concat-map/commit/ded159b52fcb147ee065f2816d452b2112b52a14) - initial code and an example [`5c26bd4`](https://github.com/ljharb/node-concat-map/commit/5c26bd4f03574a792e63fc0b5c5bdf681667ac99) - passing map test [`1fe6107`](https://github.com/ljharb/node-concat-map/commit/1fe61071594a9bb76e206f90be45fb33b0a0b738) - using travis [`600c950`](https://github.com/ljharb/node-concat-map/commit/600c9505a6bcaa3b125cc22ce931824b985ec382) - failing test for i param [`123d4d6`](https://github.com/ljharb/node-concat-map/commit/123d4d64f737831f46adb1b12c3c33e291774307) - i param test passes [`4b53eee`](https://github.com/ljharb/node-concat-map/commit/4b53eee40a441cc752e2db093be6c44a92560189) concat-map-0.0.2/LICENSE000066400000000000000000000020611432156604100145410ustar00rootroot00000000000000This software is released under the MIT license: 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. concat-map-0.0.2/README.md000066400000000000000000000041601432156604100150150ustar00rootroot00000000000000# concat-map [![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] Concatenative mapdashery. ## example ``` js var concatMap = require('concat-map'); var xs = [ 1, 2, 3, 4, 5, 6 ]; var ys = concatMap(xs, function (x) { return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; }); console.dir(ys); ``` ```js [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] ``` ## methods ```js var concatMap = require('concat-map') ``` concatMap(xs, fn) ----------------- Return an array of concatenated elements by calling `fn(x, i)` for each element `x` and each index `i` in the array `xs`. When `fn(x, i)` returns an array, its result will be concatenated with the result array. If `fn(x, i)` returns anything else, that value will be pushed onto the end of the result array. ## install With [npm](http://npmjs.org) do: ```sh npm install concat-map ``` ## license MIT ## notes This module was written while sitting high above the ground in a tree. [package-url]: https://npmjs.org/package/concat-map [npm-version-svg]: https://versionbadg.es/ljharb/concat-map.svg [deps-svg]: https://david-dm.org/ljharb/concat-map.svg [deps-url]: https://david-dm.org/ljharb/concat-map [dev-deps-svg]: https://david-dm.org/ljharb/concat-map/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/concat-map#info=devDependencies [npm-badge-png]: https://nodei.co/npm/concat-map.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/concat-map.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/concat-map.svg [downloads-url]: https://npm-stat.com/charts.html?package=concat-map [codecov-image]: https://codecov.io/gh/ljharb/concat-map/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/ljharb/concat-map/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/concat-map [actions-url]: https://github.com/ljharb/concat-map/actions concat-map-0.0.2/example/000077500000000000000000000000001432156604100151705ustar00rootroot00000000000000concat-map-0.0.2/example/map.js000066400000000000000000000002631432156604100163040ustar00rootroot00000000000000'use strict'; var concatMap = require('../'); var xs = [1, 2, 3, 4, 5, 6]; var ys = concatMap(xs, function (x) { return x % 2 ? [x - 0.1, x, x + 0.1] : []; }); console.dir(ys); concat-map-0.0.2/index.js000066400000000000000000000005271432156604100152060ustar00rootroot00000000000000'use strict'; var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; module.exports = function (xs, fn) { var res = []; for (var i = 0; i < xs.length; i++) { var x = fn(xs[i], i); if (isArray(x)) { res.push.apply(res, x); } else { res.push(x); } } return res; }; concat-map-0.0.2/package.json000066400000000000000000000034631432156604100160310ustar00rootroot00000000000000{ "name": "concat-map", "description": "concatenative mapdashery", "version": "0.0.2", "repository": { "type": "git", "url": "git://github.com/ljharb/concat-map.git" }, "main": "index.js", "keywords": [ "concat", "concatMap", "map", "functional", "higher-order" ], "directories": { "example": "example", "test": "test" }, "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": "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)\")\"" }, "devDependencies": { "@ljharb/eslint-config": "^21.0.0", "aud": "^2.0.1", "auto-changelog": "^2.4.0", "eslint": "=8.8.0", "in-publish": "^2.0.1", "npmignore": "^0.3.0", "safe-publish-latest": "^2.0.0", "tape": "^5.6.1" }, "license": "MIT", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "funding": { "url": "https://github.com/sponsors/ljharb" }, "testling": { "files": "test/*.js", "browsers": { "ie": [ 6, 7, 8, 9 ], "ff": [ 3.5, 10, 15 ], "chrome": [ 10, 22 ], "safari": [ 5.1 ], "opera": [ 12 ] } }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] } } concat-map-0.0.2/test/000077500000000000000000000000001432156604100145145ustar00rootroot00000000000000concat-map-0.0.2/test/map.js000066400000000000000000000017211432156604100156300ustar00rootroot00000000000000'use strict'; var concatMap = require('../'); var test = require('tape'); test('empty or not', function (t) { var xs = [1, 2, 3, 4, 5, 6]; var ixes = []; var ys = concatMap(xs, function (x, ix) { ixes.push(ix); return x % 2 ? [x - 0.1, x, x + 0.1] : []; }); t.same(ys, [0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1]); t.same(ixes, [0, 1, 2, 3, 4, 5]); t.end(); }); test('always something', function (t) { var xs = ['a', 'b', 'c', 'd']; var ys = concatMap(xs, function (x) { return x === 'b' ? ['B', 'B', 'B'] : [x]; }); t.same(ys, ['a', 'B', 'B', 'B', 'c', 'd']); t.end(); }); test('scalars', function (t) { var xs = ['a', 'b', 'c', 'd']; var ys = concatMap(xs, function (x) { return x === 'b' ? ['B', 'B', 'B'] : x; }); t.same(ys, ['a', 'B', 'B', 'B', 'c', 'd']); t.end(); }); test('undefs', function (t) { var xs = ['a', 'b', 'c', 'd']; var ys = concatMap(xs, function () {}); t.same(ys, [undefined, undefined, undefined, undefined]); t.end(); });