{"name":"regextras","version":"0.8.0","license":"MIT","author":{"name":"Brett Zamir"},"contributors":[],"repository":{"type":"git","url":"git+https://github.com/brettz9/regextras.git"},"homepage":"https://github.com/brettz9/regextras","bugs":{"url":"https://github.com/brettz9/regextras/issues"},"scripts":{"eslint":"eslint --ext=js,md,html .","lint":"npm run eslint","rollup":"rollup -c","start":"static -p 8081","coverage":"open-cli http://localhost:8081/coverage && npm start","mocha":"mocha --require esm --require chai/register-assert --require chai/register-expect test/test.*.js --exit","nyc":"rm -Rf ./node_modules/.cache && nyc npm run mocha","test":"npm run eslint && npm run rollup && npm run nyc","test-browser":"npm run eslint && npm run rollup && open-cli http://127.0.0.1:8081/tests/regextras.html && npm start"},"nyc":{"reporter":["html","text"],"exclude":[".eslintrc.js","rollup.config.js","dist","node_modules","test","tests"]},"browserslist":["cover 100%"],"main":"dist/index-umd.js","module":"dist/index-es.js","keywords":["regex","regexp","regular expression"],"description":"Array extras for regular expressions","engines":{"node":">=0.1.14"},"dependencies":{},"devDependencies":{"@babel/core":"^7.14.3","@babel/preset-env":"^7.14.2","@brettz9/eslint-plugin":"^1.0.3","@brettz9/node-static":"^0.1.1","@rollup/plugin-babel":"^5.3.0","chai":"^4.3.4","core-js-bundle":"^3.12.1","eslint":"^7.27.0","eslint-config-ash-nazg":"^29.16.0","eslint-config-standard":"^16.0.2","eslint-plugin-array-func":"^3.1.7","eslint-plugin-chai-expect":"^2.2.0","eslint-plugin-chai-friendly":"^0.7.1","eslint-plugin-compat":"^3.9.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-html":"^6.1.2","eslint-plugin-import":"^2.23.3","eslint-plugin-jsdoc":"^35.0.0","eslint-plugin-markdown":"^2.1.0","eslint-plugin-no-unsanitized":"^3.1.5","eslint-plugin-no-use-extend-native":"^0.5.0","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0","eslint-plugin-radar":"^0.2.1","eslint-plugin-standard":"^4.1.0","eslint-plugin-unicorn":"^32.0.1","esm":"^3.2.25","mocha":"^8.4.0","nyc":"^15.1.0","open-cli":"^6.0.1","regenerator-runtime":"^0.13.7","rollup":"2.49.0","rollup-plugin-terser":"^7.0.2"},"gitHead":"2eca7bd2e81d891c63f5915157cd7b177395e26a","_id":"regextras@0.8.0","_nodeVersion":"14.15.5","_npmVersion":"7.13.0","dist":{"integrity":"sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==","shasum":"ec0f99853d4912839321172f608b544814b02217","tarball":"http://registry-npm.ywwl.com/regextras/download/regextras-0.8.0.tgz","fileCount":31,"unpackedSize":285149,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgq5oRCRA9TVsSAnZWagAAKdMQAKQ8yyxPbAFeXHyV1FiA\nCKNloKp3q+XMZlA5MV/jEPPFGHNt39qqdwTmYpAD1c7udTEhW+mIQ05es5vY\nJo5s+F9Rc1vgmV+N80doYOn7I4IQ74QDytMv1wZogO2LL5/7C3tZ5JSplp82\nTBZc3kDj8PmKo4WioFyJcmx2+y8wnE5fi9uZM0J8n3Dl94CX+HPs/LOlAL6L\nYyPZSk56YJAzU2SkcshnzNxL0+Xl0Qnvj8dlqXDZFk/9Lcx69Kbfv0XxBuPW\n6EdKUc7fZ1z2ujMj9Evm7evFyMBLRBkO3treXzAzN6pdtIifG36yaSA8HkJb\n5AQ+/BotGxijko5vqETv7ZoB0a/+El8O+iZE6D+yrXMUBqYRxK0iGWcwNIL+\nBlhqDfa79JST836YpijlcZcqQcK4wfl9dexh9dmp0O/2AjYqGL9RDGRFpGmN\nr17RNCTXOA9wEAIFLeFgYI+fqqRT03hgao+opscI9DtquzWK2B1DpiEyJh+T\nb3KMCGHIpNN4wlROwBjTIqqjnEQKhs1WRctgOHVMFQusvFcB2Z2qHCBHa0kH\nHJPEz0OFK3PLKB4/AAYOSGj6u5OyfeXbDwyfH0XaEzGNEThATm2F5Cbom9bc\ndXca3p7hXU4+ZOhRw2ZuhwtXf7AUt3ZND7kvEqXANtwtaupTeWHqxGPua+qZ\nQ7c7\r\n=JeG4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgihGnlawjdqt44j2RiNQo/7Y1eerFMYFjJF9/FWaLuAIhAJH/xJgNEobpGpX8kWycpKRl7SyWlIbPgZuU9LrL2xYK"}],"size":65988,"noattachment":false,"key":"/regextras/-/regextras-0.8.0.tgz"},"_npmUser":{"name":"brettz9","email":"brettz9@yahoo.com"},"directories":{},"maintainers":[{"name":"brettz9","email":"brettz9@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/regextras_0.8.0_1621858833118_0.5147473620456904"},"_hasShrinkwrap":false,"readme":"# regextras\n\nArray extras for regular expressions.\n\nAlso provides optional `String` and `RegExp` prototype extensions.\n\nNo more writing the implementation-detail-leaking, non-semantic, and\notherwise ugly:\n\n```js\nlet matches;\nwhile ((matches = regex.exec(str)) !== null) {\n  // Do something\n  if (condition) {\n    break;\n  }\n}\n```\n\nWhile all of the array extras could be useful, `some`, might be the most\ngeneral purpose as it (as with `every`) allows short-circuiting (breaking).\n\nThe following is equivalent to that above (though with `matches` as local):\n\n```js\nRegExtras(regex).some(str, (matches) => {\n  // Do something\n  if (condition) {\n    return true;\n  }\n  return false;\n});\n```\n\nAnd if the condition is at the end of the loop, just this:\n\n```js\nRegExtras(regex).some(str, (matches) => {\n  // Do something\n  return condition;\n});\n```\n\n## Installation\n\nNode:\n\n```js\nconst RegExtras = require('regextras');\n```\n\nModern browsers:\n\n```js\nimport {RegExtras} from './node_modules/regextras/dist/index-es.js';\n```\n\nOlder browsers:\n\n```html\n<script src=\"regextras/dist/index-umd.js\"></script>\n```\n\nThe prototype versions must be required or included separately.\n\nIf you need the generator methods, you should also add the following:\n\n```html\n<script src=\"regextras/dist/index-generators-umd.js\"></script>\n```\n\n## API\n\n### Constructor\n\n`new RegExtras(regex, flags, newLastIndex)`\n\nExample:\n\n```js\nconst piglatinArray = RegExtras(/\\w*w?ay/).reduce('ouyay areway illysay', function (arr, i, word) {\n  if (word.endsWith('way')) { arr.push(word.replace(/way$/, '')); } else { arr.push(word.slice(-3, -2) + word.slice(0, -3)); }\n  return arr;\n}, []);\n```\n\nAll arguments but the first are optional, and the first argument can be\nexpressed as a string.\n\nThe `new` keywords is not required.\n\n### Instance methods\n\nThese methods (and their callbacks) behave like the [array extra](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Iteration_methods)\nto which they correspond with exceptions detailed below.\n\n-   ***forEach(str, callback, thisObject)*** - Unlike the other extras, this\n    method returns the RegExtras object (to enable chaining).\n\n-   ***some(str, callback, thisObject)***\n\n-   ***every(str, callback, thisObject)***\n\n-   ***map(str, callback, thisObject)***\n\n-   ***filter(str, callback, thisObject)***\n\n-   ***reduce(str, cb, prev, thisObj)*** - Unlike the array extras, allows a\n    fourth argument to set an alternative value for `this` within the callback.\n\n-   ***reduceRight(str, cb, prev, thisObj)*** - Unlike the array extras,\n    allows a fourth argument to set an alternative value for `this` within\n    the callback.\n\n-   ***find(str, cb, thisObj)***\n\n-   ***findIndex(str, cb, thisObj)***\n\nAlso adds the following methods:\n\n-   ***findExec(str, cb, thisObj)*** - Operates like `find()` except that it\n    returns the `exec` result array (with `index` and `input` as well as\n    numeric properties as returned by [RegExp.prototype.exec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)).\n\n-   ***filterExec(str, cb, thisObj)*** - Operates like `filter()` except that\n    the resulting array will contain the full `exec` results.\n\nIf you are using the Node version (or if, for the browser, you add the\n`index-generators.js` file and you are only supporting modern browsers), one\ncan use the following generator methods:\n\n-   ***values(str)*** - Returns an iterator with the array of matches (for each\n    `RegExp.prototype.exec` result)\n\n-   ***keys(str)*** - Returns an iterator with 0-based indexes (from\n    `RegExp.prototype.exec` result)\n\n-   ***entries(str)*** - Returns an iterator with an array containing the\n    key and the array of matches (for each `RegExp.prototype.exec` result)\n\n### Class methods\n\n-   ***mixinRegex(regex, newFlags='', newLastIndex=regex.lastIndex)*** -\n    Makes a copy of a regular expression.\n\n### Callbacks\n\nAll callbacks follow the signature:\n\n`cb(n1, n2..., i, n0);`\n\n...except for the `reduce` and `reduceRight` callbacks which follow:\n\n`cb(prev, n1, n2..., i, n0);`\n\n### Prototype versions\n\n`String` and `RegExp` versions of the above methods are also available.\n\nThe `RegExp` prototype version acts in the same way as `RegExtra` just\nwithout the need for a separate constructor call.\n\nThe `String` prototype version differs in that instead of the first argument\nbeing a string, it is the regular expression.\n\n## Todos\n\n1.  Could add [Array accessor methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Accessor_methods)\n    like `slice()`, with an additional supplied regular expression to gather\n    the `exec` results into an array.\n\n2.  Utilize `nodeunit` browser testing (and add `mixinRegex` tests)\n\n    1. Convert nodeunit tests to ES6 modules running through babel-register?;\n        streamline as sole set of tests, reconciling `test` with `tests` folder\n\n3.  Add generators for prototype versions\n","publish_time":1621858833330,"_cnpm_publish_time":1621858833330,"dist-tags":{"latest":"0.8.0"}}