Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

673
static/js/ketcher2/node_modules/nyc/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,673 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="11.2.1"></a>
## [11.2.1](https://github.com/istanbuljs/nyc/compare/v11.2.0...v11.2.1) (2017-09-06)
### Bug Fixes
* apply exclude logic before remapping coverage ([#667](https://github.com/istanbuljs/nyc/issues/667)) ([a10d478](https://github.com/istanbuljs/nyc/commit/a10d478))
* create temp directory when --no-clean flag is set [#663](https://github.com/istanbuljs/nyc/issues/663) ([#664](https://github.com/istanbuljs/nyc/issues/664)) ([3bd1527](https://github.com/istanbuljs/nyc/commit/3bd1527))
<a name="11.2.0"></a>
# [11.2.0](https://github.com/istanbuljs/nyc/compare/v11.1.0...v11.2.0) (2017-09-05)
### Bug Fixes
* remove excluded files from coverage before writing ([#649](https://github.com/istanbuljs/nyc/issues/649)) ([658dba4](https://github.com/istanbuljs/nyc/commit/658dba4))
### Features
* add possibility to filter coverage-maps ([#637](https://github.com/istanbuljs/nyc/issues/637)) ([dd40dc5](https://github.com/istanbuljs/nyc/commit/dd40dc5))
* allow cwd to be configured see [#620](https://github.com/istanbuljs/nyc/issues/620) ([0dcceda](https://github.com/istanbuljs/nyc/commit/0dcceda))
<a name="11.1.0"></a>
# [11.1.0](https://github.com/istanbuljs/nyc/compare/v11.0.3...v11.1.0) (2017-07-16)
### Features
* add support for per file coverage checking ([#591](https://github.com/istanbuljs/nyc/issues/591)) ([bbadc1f](https://github.com/istanbuljs/nyc/commit/bbadc1f))
* upgrade to version of spawn-wrap that supports .EXE ([#626](https://github.com/istanbuljs/nyc/issues/626)) ([8768afe](https://github.com/istanbuljs/nyc/commit/8768afe))
<a name="11.0.3"></a>
## [11.0.3](https://github.com/istanbuljs/nyc/compare/v11.0.2...v11.0.3) (2017-06-25)
### Bug Fixes
* update help link to list of reporters ([#601](https://github.com/istanbuljs/nyc/issues/601)) ([b1eb4d6](https://github.com/istanbuljs/nyc/commit/b1eb4d6))
* upgrade to spawn-wrap version that works with babel-register ([#617](https://github.com/istanbuljs/nyc/issues/617)) ([923b062](https://github.com/istanbuljs/nyc/commit/923b062))
<a name="11.0.2"></a>
## [11.0.2](https://github.com/istanbuljs/nyc/compare/v11.0.1...v11.0.2) (2017-06-02)
<a name="11.0.1"></a>
## [11.0.1](https://github.com/istanbuljs/nyc/compare/v11.0.0...v11.0.1) (2017-06-01)
<a name="11.0.0"></a>
# [11.0.0](https://github.com/istanbuljs/nyc/compare/v10.3.2...v11.0.0) (2017-05-31)
### Bug Fixes
* add support for ES6 modules ([f18f780](https://github.com/istanbuljs/nyc/commit/f18f780))
### Features
* allow .nycrc.json ([#580](https://github.com/istanbuljs/nyc/issues/580)) ([a1a457f](https://github.com/istanbuljs/nyc/commit/a1a457f))
* upgrade to version of yargs with support for presets ([33829b8](https://github.com/istanbuljs/nyc/commit/33829b8))
### BREAKING CHANGES
* new version of find-up requires dropping 0.10/0.12 support (which we had already been planning).
<a name="10.3.2"></a>
## [10.3.2](https://github.com/istanbuljs/nyc/compare/v10.3.1...v10.3.2) (2017-05-05)
### Bug Fixes
* we should not create a cache folder if cache is false ([#567](https://github.com/istanbuljs/nyc/issues/567)) ([213206f](https://github.com/istanbuljs/nyc/commit/213206f))
<a name="10.3.1"></a>
## [10.3.1](https://github.com/istanbuljs/nyc/compare/v10.3.0...v10.3.1) (2017-05-04)
### Bug Fixes
* introduced a bug that resulted in source-maps not being loaded approriately on second test run ([#566](https://github.com/istanbuljs/nyc/issues/566)) ([1bf74fd](https://github.com/istanbuljs/nyc/commit/1bf74fd))
<a name="10.3.0"></a>
# [10.3.0](https://github.com/istanbuljs/nyc/compare/v10.2.0...v10.3.0) (2017-04-29)
### Bug Fixes
* source-maps were not being cached in the parent process when --all was being used ([#556](https://github.com/istanbuljs/nyc/issues/556)) ([ff73b18](https://github.com/istanbuljs/nyc/commit/ff73b18))
### Features
* add support for --no-clean, to disable deleting raw coverage output ([#558](https://github.com/istanbuljs/nyc/issues/558)) ([1887d1c](https://github.com/istanbuljs/nyc/commit/1887d1c))
<a name="10.2.0"></a>
# [10.2.0](https://github.com/istanbuljs/nyc/compare/v10.1.0...v10.2.0) (2017-03-28)
### Bug Fixes
* fix bug related to merging coverage reports see [#482](https://github.com/istanbuljs/nyc/issues/482) ([81229a0](https://github.com/istanbuljs/nyc/commit/81229a0))
* revert defaulting to empty file-coverage report, this caused too many issues ([25aec77](https://github.com/istanbuljs/nyc/commit/25aec77))
### Features
* allow babel cache to be enabled ([#517](https://github.com/istanbuljs/nyc/issues/517)) ([98ebdff](https://github.com/istanbuljs/nyc/commit/98ebdff))
* exclude the coverage/ folder by default 🚀 ([#502](https://github.com/istanbuljs/nyc/issues/502)) ([50adde4](https://github.com/istanbuljs/nyc/commit/50adde4))
* upgrade to version of yargs with extend support ([#541](https://github.com/istanbuljs/nyc/issues/541)) ([95cc09a](https://github.com/istanbuljs/nyc/commit/95cc09a))
<a name="10.1.2"></a>
## [10.1.2](https://github.com/istanbuljs/nyc/compare/v10.1.1...v10.1.2) (2017-01-18)
### Bug Fixes
* revert defaulting to empty file-coverage report, this caused too many issues ([25aec77](https://github.com/istanbuljs/nyc/commit/25aec77))
<a name="10.1.1"></a>
## [10.1.1](https://github.com/istanbuljs/nyc/compare/v10.1.0...v10.1.1) (2017-01-18)
### Bug Fixes
* fix bug related to merging coverage reports see [#482](https://github.com/istanbuljs/nyc/issues/482) ([81229a0](https://github.com/istanbuljs/nyc/commit/81229a0))
<a name="10.1.0"></a>
# [10.1.0](https://github.com/istanbuljs/nyc/compare/v10.0.2...v10.1.0) (2017-01-17)
### Bug Fixes
* address edge-cases related to --all when instrumentation is disabled ([#482](https://github.com/istanbuljs/nyc/issues/482)) ([8c58d68](https://github.com/istanbuljs/nyc/commit/8c58d68))
* pass configuration options to --check-coverage ([#483](https://github.com/istanbuljs/nyc/issues/483)) ([1022b16](https://github.com/istanbuljs/nyc/commit/1022b16))
### Features
* allow eager instantiation of instrumenter ([#490](https://github.com/istanbuljs/nyc/issues/490)) ([8b58c05](https://github.com/istanbuljs/nyc/commit/8b58c05))
* reporting watermarks can now be set in nyc config stanza ([#469](https://github.com/istanbuljs/nyc/issues/469)) ([0a1d72a](https://github.com/istanbuljs/nyc/commit/0a1d72a))
* upgrade to istanbul-lib-instrument with support for 'const foo = function () {}' name preservation. upgrade to istanbul-lib-hook with fix for ts-node. ([#494](https://github.com/istanbuljs/nyc/issues/494)) ([d8d2de0](https://github.com/istanbuljs/nyc/commit/d8d2de0))
<a name="10.0.2"></a>
## [10.0.2](https://github.com/istanbuljs/nyc/compare/v10.0.1...v10.0.2) (2017-01-02)
### Bug Fixes
* upgrade to newer istanbul-lib-instrument, with fixes for inferred function names ([#479](https://github.com/istanbuljs/nyc/issues/479)) ([e01ec8c](https://github.com/istanbuljs/nyc/commit/e01ec8c))
<a name="10.0.1"></a>
## [10.0.1](https://github.com/istanbuljs/nyc/compare/v10.0.0...v10.0.1) (2016-12-27)
### Bug Fixes
* upgrade spawn-wrap and istanbul-lib-instrument ([#477](https://github.com/istanbuljs/nyc/issues/477)) ([e0ef1d5](https://github.com/istanbuljs/nyc/commit/e0ef1d5))
<a name="10.0.0"></a>
# [10.0.0](https://github.com/istanbuljs/nyc/compare/v9.0.1...v10.0.0) (2016-11-22)
### Bug Fixes
* debug-log should be production dependency ([a3c7f83](https://github.com/istanbuljs/nyc/commit/a3c7f83))
### Features
* cache now turned on by default ([#454](https://github.com/istanbuljs/nyc/issues/454)) ([0dd970c](https://github.com/istanbuljs/nyc/commit/0dd970c))
### BREAKING CHANGES
* nyc's cache is now enabled by default
<a name="9.0.1"></a>
## [9.0.1](https://github.com/istanbuljs/nyc/compare/v9.0.0...v9.0.1) (2016-11-14)
### Bug Fixes
* addresses several test-exclude edge-cases. addresses perf issue with yargs ([#442](https://github.com/istanbuljs/nyc/issues/444))
<a name="9.0.0"></a>
# [9.0.0](https://github.com/istanbuljs/nyc/compare/v8.4.0...v9.0.0) (2016-11-13)
### Features
* adds support for source-map production ([#439](https://github.com/istanbuljs/nyc/issues/439)) ([31488f5](https://github.com/istanbuljs/nyc/commit/31488f5))
* allow an alternate cache folder to be provided ([#443](https://github.com/istanbuljs/nyc/issues/443)) ([b6713a3](https://github.com/istanbuljs/nyc/commit/b6713a3))
* node_modules is again excluded by default when custom exclude is provided ([#442](https://github.com/istanbuljs/nyc/issues/442)) ([2828538](https://github.com/istanbuljs/nyc/commit/2828538))
### BREAKING CHANGES
* **/node_modules/** is again excluded by default.
<a name="8.4.0"></a>
# [8.4.0](https://github.com/istanbuljs/nyc/compare/v8.3.1...v8.4.0) (2016-10-30)
### Bug Fixes
* hot-fix bad release of nyc ([c487eb3](https://github.com/istanbuljs/nyc/commit/c487eb3))
* reverts _maybeInstrumentSource logic, so that exclude is still applied ([#429](https://github.com/istanbuljs/nyc/issues/429)) ([b90d26f](https://github.com/istanbuljs/nyc/commit/b90d26f))
* update core istanbul libraries ([#426](https://github.com/istanbuljs/nyc/issues/426)) ([4945dac](https://github.com/istanbuljs/nyc/commit/4945dac))
### Features
* coverage information is now returned for process tree ([#416](https://github.com/istanbuljs/nyc/issues/416)) ([92dedda](https://github.com/istanbuljs/nyc/commit/92dedda))
* read coverage header when using "noop" instrumenter ([#420](https://github.com/istanbuljs/nyc/issues/420)) ([63a8758](https://github.com/istanbuljs/nyc/commit/63a8758))
<a name="8.3.1"></a>
## [8.3.1](https://github.com/istanbuljs/nyc/compare/v8.3.0...v8.3.1) (2016-10-06)
### Bug Fixes
* swap to version of test-exclude that does not warn ([#410](https://github.com/istanbuljs/nyc/issues/410)) ([78aac45](https://github.com/istanbuljs/nyc/commit/78aac45))
* update istanbul-lib-source-maps to 1.0.2 ([#411](https://github.com/istanbuljs/nyc/issues/411)) ([9c89945](https://github.com/istanbuljs/nyc/commit/9c89945))
<a name="8.3.0"></a>
# [8.3.0](https://github.com/istanbuljs/nyc/compare/v8.2.0...v8.3.0) (2016-09-15)
### Bug Fixes
* add a feature which allows us to bust the cache when breaking changes are introduced ([#394](https://github.com/istanbuljs/nyc/issues/394)) ([b7a413a](https://github.com/istanbuljs/nyc/commit/b7a413a))
* add shim for check-coverage on node 0.10 ([#386](https://github.com/istanbuljs/nyc/issues/386)) ([9ebaea8](https://github.com/istanbuljs/nyc/commit/9ebaea8))
* upgrade to newer versions of source-map, signal-exit, and instrument ([#389](https://github.com/istanbuljs/nyc/issues/389)) ([a9bdf0f](https://github.com/istanbuljs/nyc/commit/a9bdf0f)), closes [#379](https://github.com/istanbuljs/nyc/issues/379)
### Features
* add support for .nycrc ([#391](https://github.com/istanbuljs/nyc/issues/391)) ([1c2349b](https://github.com/istanbuljs/nyc/commit/1c2349b))
* refactored config to fix precedence of config vs. args ([#388](https://github.com/istanbuljs/nyc/issues/388)) ([99dbbb3](https://github.com/istanbuljs/nyc/commit/99dbbb3)), closes [#379](https://github.com/istanbuljs/nyc/issues/379)
<a name="8.2.0"></a>
# [8.2.0](https://github.com/istanbuljs/nyc/compare/v8.1.0...v8.2.0) (2016-09-02)
### Bug Fixes
* upgrade standard, and a few other dependencies. fix standard nits ([#375](https://github.com/istanbuljs/nyc/issues/375)) ([64c68b7](https://github.com/istanbuljs/nyc/commit/64c68b7))
### Features
* gather process tree information ([#364](https://github.com/istanbuljs/nyc/issues/364)) ([fabe5f3](https://github.com/istanbuljs/nyc/commit/fabe5f3))
<a name="8.1.0"></a>
# [8.1.0](https://github.com/bcoe/nyc/compare/v8.0.0...v8.1.0) (2016-08-14)
### Bug Fixes
* serialization using ',' was breaking globs ([#353](https://github.com/bcoe/nyc/issues/353)) ([22929db](https://github.com/bcoe/nyc/commit/22929db))
### Features
* implicitly assume `node` when the command starts with an option ([#350](https://github.com/bcoe/nyc/issues/350)) ([2bb52cd](https://github.com/bcoe/nyc/commit/2bb52cd))
<a name="8.0.0"></a>
# [8.0.0](https://github.com/bcoe/nyc/compare/v7.1.0...v8.0.0) (2016-08-12)
### Bug Fixes
* make `nyc instrument` work in subdirectories ([#343](https://github.com/bcoe/nyc/issues/343)) ([a82cf49](https://github.com/bcoe/nyc/commit/a82cf49))
* upgrade to versions of coverage/instrument that solve out-of-bound errors ([#349](https://github.com/bcoe/nyc/issues/349)) ([bee0328](https://github.com/bcoe/nyc/commit/bee0328))
### Features
* upgrade to new test-exclude; with suppport for node_modules, and empty exclude ([#348](https://github.com/bcoe/nyc/issues/348)) ([d616ffc](https://github.com/bcoe/nyc/commit/d616ffc))
### BREAKING CHANGES
* node_modules is no longer automatically excluded, and an empty array of exclude rules can now be provided.
<a name="7.1.0"></a>
# [7.1.0](https://github.com/bcoe/nyc/compare/v7.0.0...v7.1.0) (2016-07-24)
### Bug Fixes
* make --all flag work with files with extensions other than .js ([#326](https://github.com/bcoe/nyc/issues/326)) ([d0a8674](https://github.com/bcoe/nyc/commit/d0a8674))
* work around for Windows path issue nodejs/node[#6624](https://github.com/bcoe/nyc/issues/6624) ([6b1fed0](https://github.com/bcoe/nyc/commit/6b1fed0))
### Features
* nyc no longer tries to run arguments passed to the instrumented bin ([#322](https://github.com/bcoe/nyc/issues/322)) ([e0a8c0b](https://github.com/bcoe/nyc/commit/e0a8c0b))
* use istanbul-lib-hook to wrap require and support vm hooks ([#308](https://github.com/bcoe/nyc/issues/308)) ([2b64cf8](https://github.com/bcoe/nyc/commit/2b64cf8))
<a name="7.0.0"></a>
# [7.0.0](https://github.com/bcoe/nyc/compare/v6.6.1...v7.0.0) (2016-07-09)
### Bug Fixes
* avoid pid collisions. ([#301](https://github.com/bcoe/nyc/issues/301)) ([f67bff7](https://github.com/bcoe/nyc/commit/f67bff7))
* disable the babel/nyc cache ([#303](https://github.com/bcoe/nyc/issues/303)) ([104b3da](https://github.com/bcoe/nyc/commit/104b3da))
### Features
* adds instrument command line option ([#298](https://github.com/bcoe/nyc/issues/298)) ([e45b51b](https://github.com/bcoe/nyc/commit/e45b51b))
* nyc is being refactored to become the official Istanbul 1.0 bin ([#286](https://github.com/bcoe/nyc/issues/286)) ([61a05ea](https://github.com/bcoe/nyc/commit/61a05ea))
### BREAKING CHANGES
* significant chunks of nyc's API have been reworked, to use the Istanbul 1.0 API: source-map support, instrumentation, the check-coverage command, etc.
<a name="6.6.1"></a>
## [6.6.1](https://github.com/bcoe/nyc/compare/v6.6.0...v6.6.1) (2016-06-14)
### Bug Fixes
* the package tree of bundled dependencies was incorrect ([7bdccf5](https://github.com/bcoe/nyc/commit/7bdccf5))
<a name="6.6.0"></a>
# [6.6.0](https://github.com/bcoe/nyc/compare/v6.5.1...v6.6.0) (2016-06-14)
### Features
* add "instrument" option as alternative to specifying noop instrumenter ([#278](https://github.com/bcoe/nyc/issues/278)) ([ea028b9](https://github.com/bcoe/nyc/commit/ea028b9))
<a name="6.5.1"></a>
## [6.5.1](https://github.com/bcoe/nyc/compare/v6.5.0...v6.5.1) (2016-06-14)
### Bug Fixes
* upgrade foreground-child dependency ([#276](https://github.com/bcoe/nyc/issues/276)) ([1b9e4a8](https://github.com/bcoe/nyc/commit/1b9e4a8))
<a name="6.5.0"></a>
# [6.5.0](https://github.com/bcoe/nyc/compare/v6.4.4...v6.5.0) (2016-06-13)
### Bug Fixes
* cleanup dependencies ([#254](https://github.com/bcoe/nyc/issues/254)) ([a20d03d](https://github.com/bcoe/nyc/commit/a20d03d))
* discard more bad source map positions ([#255](https://github.com/bcoe/nyc/issues/255)) ([0838a0e](https://github.com/bcoe/nyc/commit/0838a0e))
* Update AppVeyor config with ~faster npm install ([#252](https://github.com/bcoe/nyc/issues/252)) ([df591f4](https://github.com/bcoe/nyc/commit/df591f4))
### Features
* make `__coverage__` the default approach we advocate for ES2015 coverage ([#268](https://github.com/bcoe/nyc/issues/268)) ([9fd2295](https://github.com/bcoe/nyc/commit/9fd2295))
<a name="6.4.4"></a>
## [6.4.4](https://github.com/bcoe/nyc/compare/v6.4.3...v6.4.4) (2016-05-07)
### Bug Fixes
* upgraded dependencies, add missing lodash bundled dependency ([#250](https://github.com/bcoe/nyc/issues/250))([32042fc](https://github.com/bcoe/nyc/commit/32042fc))
<a name="6.4.3"></a>
## [6.4.3](https://github.com/bcoe/nyc/compare/v6.4.2...v6.4.3) (2016-05-06)
### Bug Fixes
* must bundle dependencies on npm<3.x or they will flatten (we need a better long-term solution)([9826f11](https://github.com/bcoe/nyc/commit/9826f11))
<a name="6.4.2"></a>
## [6.4.2](https://github.com/bcoe/nyc/compare/v6.4.1...v6.4.2) (2016-05-02)
### Bug Fixes
* **update:** update strip-bom to version 3.0.0 ([#240](https://github.com/bcoe/nyc/issues/240))([24f55e7](https://github.com/bcoe/nyc/commit/24f55e7))
* upgrade spawn-wrap to version that works with new shelljs ([#242](https://github.com/bcoe/nyc/issues/242))([b16053c](https://github.com/bcoe/nyc/commit/b16053c))
<a name="6.4.1"></a>
## [6.4.1](https://github.com/bcoe/nyc/compare/v6.4.0...v6.4.1) (2016-04-27)
### Bug Fixes
* strip any duplicate extensions from --extension ([#237](https://github.com/bcoe/nyc/issues/237)) ([0946f82](https://github.com/bcoe/nyc/commit/0946f82))
<a name="6.4.0"></a>
# [6.4.0](https://github.com/bcoe/nyc/compare/v6.3.0...v6.4.0) (2016-04-11)
### Bug Fixes
* adds CLI integration testing, where there was no integration testing before. ([3403ca1](https://github.com/bcoe/nyc/commit/3403ca1))
### Features
* **cli:** --include and --exclude are now accepted as CLI options, thanks [@rpominov](https://github.com/rpominov) \o/ see [#207](https://github.com/bcoe/nyc/issues/207) ([f8a02b4](https://github.com/bcoe/nyc/commit/f8a02b4))
<a name="6.3.0"></a>
# [6.3.0](https://github.com/bcoe/nyc/compare/v6.2.1...v6.3.0) (2016-04-08)
### Features
* better docs for excluding, thanks @kentdodds \o/ ([22b06fe](https://github.com/bcoe/nyc/commit/22b06fe))
* updating dependencies (spawn wrap with npm patches \o/) ([ac841b8](https://github.com/bcoe/nyc/commit/ac841b8))
<a name="6.2.1"></a>
## [6.2.1](https://github.com/bcoe/nyc/compare/v6.2.0...v6.2.1) (2016-04-05)
### Bug Fixes
* **bundling:** .gitignore was interfering with bundle ([0e4adae](https://github.com/bcoe/nyc/commit/0e4adae))
<a name="6.2.0"></a>
# [6.2.0](https://github.com/bcoe/nyc/compare/v6.1.1...v6.2.0) (2016-04-05)
### Bug Fixes
* **bundle dependencies:** start bundling dependencies, which should address some issues we have seen with ([6116077](https://github.com/bcoe/nyc/commit/6116077))
* **exit code:** use test programs exit code even with `--check-coverage` ([00bbeb2](https://github.com/bcoe/nyc/commit/00bbeb2))
### Features
* **conventional changelog:** introducing conventional-changelog for changelog generation ([f594c5e](https://github.com/bcoe/nyc/commit/f594c5e))
* **exclude patterns:** introduces new exclude-patterns based on @kentcdodds' coding conventions. ([51b1777](https://github.com/bcoe/nyc/commit/51b1777))
* **update dependencies:** new foreground-child and spawn-wrap have landed \o/ ([1a0ad0b](https://github.com/bcoe/nyc/commit/1a0ad0b))
### v6.1.1 (2016/03/13 14:23 +7:00)
- [#194](https://github.com/bcoe/nyc/pull/194) hot-fix for --all with multiple extensions (@bcoe)
### v6.1.0 (2016/03/12 15:00 +7:00)
- [#191](https://github.com/bcoe/nyc/pull/191) upgrade to non-singleton verison of yargs (@bcoe)
- [#185](https://github.com/bcoe/nyc/pull/185) default to long-form option names so that they can be overridden in package.json (@rapzo)
- [#180](https://github.com/bcoe/nyc/pull/180) fix bug with findUp (@bcoe)
- [#178](https://github.com/bcoe/nyc/pull/178) --all should handle extensions other than .js. (@lloydcotten)
- [#177](https://github.com/bcoe/nyc/pull/177) add .editorconfig (@JaKXz)
### v6.0.0 (2016/02/20 +7:00)
- [#167](https://github.com/bcoe/nyc/pull/167) all of nyc's settings can now
be configured in package.json (@bcoe)
- [#164](https://github.com/bcoe/nyc/pull/164) coverage tracking now uses absolute paths, awesome \o/ (@novemberborn)
- [#163](https://github.com/bcoe/nyc/pull/163) support for extensions other than .js (@lloydcotten)
### v5.6.0 (2016/02/03 +7:00)
- [#159](https://github.com/bcoe/nyc/pull/159) skip should continue working with source-maps (@novemberborn)
- [#160](https://github.com/bcoe/nyc/pull/160) don't instrument files outside of the current working directory (@novemberborn)
### v5.5.0 (2016/01/24 +07:00)
- [#152](https://github.com/bcoe/nyc/pull/152) upgrade to newest version of foreground-child (@isaacs)
- [#150](https://github.com/bcoe/nyc/pull/150) guard against illegal positions in source-map (@novemberborn)
### v5.4.0 (2016/01/20 +07:00)
- [#147](https://github.com/bcoe/nyc/pull/147) fix for foreground-child on Windows (@isaacs)
- [#145](https://github.com/bcoe/nyc/pull/145) allow coverage output directory to be specified (@bcoe)
- [#143](https://github.com/bcoe/nyc/pull/143) run files included via --all through transpilers (@bcoe)
- [#139](https://github.com/bcoe/nyc/pull/139) documentation updates (@tcurdt)
- [#138](https://github.com/bcoe/nyc/pull/138) Split CLI from spawn wrapper (@isaacs)
### v5.3.0 (2016/01/05 14:07 -08:00)
- [#132](https://github.com/bcoe/nyc/pull/132/files) Move config to top level nyc argument. (@jamestalmage)
### v5.2.0 (2016/01/02 17:13 -08:00)
- [#126](https://github.com/bcoe/nyc/pull/126) Add --check-coverage shorthand, which fails tests if coverage slips below threshold (@bcoe)
- [#123](https://github.com/bcoe/nyc/pull/123) Upgrade spawn-wrap, foreground-child (@isaacs)
- [#122](https://github.com/bcoe/nyc/pull/122) Use module for finding cache directory (@jamestalmage)
### v5.1.1 (2015/12/30 14:52 -08:00)
- [#121](https://github.com/bcoe/nyc/pull/121) Fix for --all functionality. (@jamestalmage)
### v5.1.0 (2015/12/27 20:36 -08:00)
- [#108](https://github.com/bcoe/nyc/pull/108) Adds cache functionality. this is a big one, thanks! (@jamestalmage)
- [#118](https://github.com/bcoe/nyc/pull/118) Stop bundling spawn-wrap dependency (@bcoe)
- [#114](https://github.com/bcoe/nyc/pull/114) Update to latest versions of tap, glob, rimraf (@isaacs)
- [#107](https://github.com/bcoe/nyc/pull/107) Get test-suite running on Windows (@bcoe)
### v5.0.1 (2015/12/14 09:09 -07:00)
- [#94](https://github.com/bcoe/nyc/pull/93) Windows failed if argument had no replace() method. (@bcoe)
### v5.0.0 (2015/12/09 11:03 -07:00)
- [#87](https://github.com/bcoe/nyc/pull/87) make spawn() work on Windows (@bcoe)
- [#84](https://github.com/bcoe/nyc/pull/84) glob based include/exclude of files (@Lalem001)
- [#78](https://github.com/bcoe/nyc/pull/78) improvements to sourcemap tests (@novemberborn)
- [#73](https://github.com/bcoe/nyc/pull/73) improvements to require tests (@novemberborn)
- [#65](https://github.com/bcoe/nyc/pull/65) significant improvements to require hooks (@novemberborn)
- [#64](https://github.com/bcoe/nyc/pull/64) upgrade Istanbul (@novemberborn)
### v4.0.0 (2015/11/29 10:13 -07:00)
- [#58](https://github.com/bcoe/nyc/pull/58) adds support for Babel (@bcoe)
### v3.2.2 (2015/09/11 22:02 -07:00)
- [#47](https://github.com/bcoe/nyc/pull/47) make the default exclude rules work on Windows (@bcoe)
- [#45](https://github.com/bcoe/nyc/pull/45) pull in patched versions of spawn-wrap and foreground-child, which support Windows (@bcoe)
- [#44](https://github.com/bcoe/nyc/pull/44) Adds --all option which adds 0% coverage reports for all files in project, regardless of whether code touches them (@ronkorving)
### v3.1.0 (2015/08/02 19:04 +00:00)
- [#38](https://github.com/bcoe/nyc/pull/38) fixes for windows spawning (@rmg)
### v3.0.1 (2015/07/25 20:51 +00:00)
- [#33](https://github.com/bcoe/nyc/pull/33) spawn istanbul in a way that is less likely to break npm@3.x (@bcoe)
### v3.0.0 (2015/06/28 19:49 +00:00)
- [#31](https://github.com/bcoe/nyc/pull/31) Combine instrumentation and reporting steps, based
on @Raynos' suggestion (@bcoe)
### v2.4.0 (2015/06/24 15:57 +00:00)
- [#30](https://github.com/bcoe/nyc/pull/30) Added check-coverage functionality, thanks
@Raynos! (@bcoe)
### v2.3.0 (2015/06/04 06:43 +00:00)
- [#27](https://github.com/bcoe/nyc/pull/27) upgraded tap, and switched tests to using tap --coverage (@bcoe)
- [#25](https://github.com/bcoe/nyc/pull/25) support added for multiple reporters, thanks @jasisk! (@jasisk)
### v2.2.0 (2015/05/25 21:05 +00:00)
- [b2e4707](https://github.com/bcoe/nyc/commit/b2e4707ca16750fe274f61039baf1cabdd6b0149) change location of nyc_output to .nyc_output. Added note about coveralls comments. (@sindresorhus)
### v2.1.3 (2015/05/25 06:30 +00:00)
- [376e328](https://github.com/bcoe/nyc/commit/376e32871d2d65ca31e7d8ba691293ac3ba6117e) handle corrupt JSON files in nyc_output (@bcoe)
### v2.1.1 (2015/05/25 02:52 +00:00)
- [b39dec5](https://github.com/bcoe/nyc/commit/b39dec5a7fb9004be72d024d5d1df2984dd21a52) new signal-exit handles process.exit() in process.on('exit') (@isaacs)
### v2.1.0 (2015/05/23 20:55 +00:00)
- [ad13b30](https://github.com/bcoe/nyc/commit/ad13b30cf263ccc3607e1707ebdf582345ce90fe) added CHANGELOG.md \o/ (@bcoe)
- [53fef48](https://github.com/bcoe/nyc/commit/53fef4820e7b502d00561fb5d16f5bfb4b641192) put tests around @shackpank's work on .istanbul.yml (@bcoe)
- [da81c54](https://github.com/bcoe/nyc/commit/da81c5427c2dee38496def9741fdde5524fa0942) upgrade spawn-wrap and foreground-child (@isaacs)
- [4f69327](https://github.com/bcoe/nyc/commit/4f69327b5e6247770bf299fab86abb67a042b26a) pin tap until new version of nyc can be pulled in (@bcoe)
### v2.0.6 (2015/05/23 06:52 +00:00)
- [cd70a41](https://github.com/bcoe/nyc/commit/cd70a414adc12b79770eaca9e8ca0e5f954924f3) upgrade signal-exit (@bcoe)
### v2.0.5 (2015/05/20 05:44 +00:00)
- [#11](https://github.com/bcoe/nyc/pull/11) Merge pull request #11 from bcoe/exlude-docs (@bcoe)
### v2.0.4 (2015/05/19 04:58 +00:00)
- [4d920ef](https://github.com/bcoe/nyc/commit/4d920ef6e0843729a911ca1cf6deaf6645e21f60) ensure that writing code coverage always happens last (@bcoe)
### v2.0.3 (2015/05/18 01:52 +00:00)
- [94d2693](https://github.com/bcoe/nyc/commit/94d2693739cf7145333d941c88e0d3af9592c1d6) spawn-wrap@0.1.1 (@isaacs)
### v2.0.1 (2015/05/18 01:46 +00:00)
- [62c2cb0](https://github.com/bcoe/nyc/commit/62c2cb0941fbda8aa5ef6ba4877c02a046b68c6c) upgrade signal-exit dependency (@bcoe)
### v2.0.0 (2015/05/16 21:38 +00:00)
- [d27794e](https://github.com/bcoe/nyc/commit/d27794e3c527ccf743501f328b9749f1bcf9cefe) got rid of nyc-report bin (@bcoe)
- [64c9824](https://github.com/bcoe/nyc/commit/64c98241db36331b611cf990343da40d5f45685a) added better documentation and CLI. (@bcoe)
### v1.4.1 (2015/05/16 19:23 +00:00)
- [ae05346](https://github.com/bcoe/nyc/commit/ae0534617a59c86905f1da290d067945bf7d1bb9) pulled in new version of signal-exit (@bcoe)
### v1.4.0 (2015/05/16 09:11 +00:00)
- [8ca6e16](https://github.com/bcoe/nyc/commit/8ca6e16f6ecb7fa488944cd00d84ae5d355345d2) pulled in signal-exit module (@bcoe)
### v1.3.0 (2015/05/15 15:56 +00:00)
- [0f701da](https://github.com/bcoe/nyc/commit/0f701da5aa3ad8a02872c4c6c8c37d0deb2c5877) pulled in new spawn-wrap, various bug fixes (@isaacs)
### v1.2.0 (2015/05/13 20:21 +00:00)
- [2611ba4](https://github.com/bcoe/nyc/commit/2611ba44f12a25c12c0f95a9bdcfbf905dbb070f) handle signals when writing coverage report (@bcoe)
### v1.1.3 (2015/05/11 18:31 +00:00)
- [8b362d6](https://github.com/bcoe/nyc/commit/8b362d600845722943c1da8213f0406d6b3a3874) istanbul has a text lcov report now \o/ (@bcoe)
### v1.1.2 (2015/05/11 06:52 +00:00)
- [48b21cf](https://github.com/bcoe/nyc/commit/48b21cf3b35f6d14d35ac9afdd423ead09a2368e) added coverage and build badges (@bcoe)
### v1.1.0 (2015/05/10 01:32 +00:00)
- [6c3f8a6](https://github.com/bcoe/nyc/commit/6c3f8a6147c376e87a22c4a72a1ab28ab4177349) pulled in @isaacs spawn-wrap module (@isaacs)
- [d8956f1](https://github.com/bcoe/nyc/commit/d8956f170f12a8a27cc3f7611f78230393bf105b) we now pass cwd around using the process.env.NYC_CWD variable (@bcoe)

16
static/js/ketcher2/node_modules/nyc/LICENSE.txt generated vendored Normal file
View File

@ -0,0 +1,16 @@
ISC License
Copyright (c) 2015, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

401
static/js/ketcher2/node_modules/nyc/README.md generated vendored Normal file
View File

@ -0,0 +1,401 @@
# nyc
[![Build Status](https://travis-ci.org/istanbuljs/nyc.svg?branch=master)](https://travis-ci.org/istanbuljs/nyc)
[![Coverage Status](https://coveralls.io/repos/bcoe/nyc/badge.svg?branch=)](https://coveralls.io/r/bcoe/nyc?branch=master)
[![NPM version](https://img.shields.io/npm/v/nyc.svg)](https://www.npmjs.com/package/nyc)
[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/nyc-ilw23/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/nyc-ilw23)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
Istanbul's state of the art command line interface, with support for:
* applications that spawn subprocesses.
* ES2015 transforms, via [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), or source-maps.
## Instrumenting your code
You can install nyc as a development dependency and add it to the test stanza
in your package.json.
```shell
npm i nyc --save-dev
```
```json
{
"script": {
"test": "nyc mocha"
}
}
```
Alternatively, you can install nyc globally and use it to execute `npm test`:
```shell
npm i nyc -g
```
```shell
nyc npm test
```
nyc accepts a wide variety of configuration arguments, run `nyc --help` for
thorough documentation.
Configuration arguments should be provided prior to the program that nyc
is executing. As an example, the following command executes `npm test`,
and indicates to nyc that it should output both an `lcov`
and a `text-lcov` coverage report.
```shell
nyc --reporter=lcov --reporter=text-lcov npm test
```
### Accurate stack traces using source maps
When `produce-source-map` is set to true, then the instrumented source files will
include inline source maps for the instrumenter transform. When combined with
[source-map-support](https://github.com/evanw/node-source-map-support),
stack traces for instrumented code will reflect their original lines.
### Support for custom require hooks (babel, webpack, etc.)
nyc supports custom require hooks like
[`babel-register`](http://babeljs.io/docs/usage/require/). nyc can
load the hooks for you, [using the `--require`
flag](#require-additional-modules).
Source maps are used to map coverage information back to the appropriate lines
of the pre-transpiled code. You'll have to configure your custom require hook
to inline the source map in the transpiled code. For Babel that means setting
the `sourceMaps` option to `inline`.
## Use with `babel-plugin-istanbul` for Babel Support
We recommend using [`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) if your
project uses the babel tool chain:
1. enable the `babel-plugin-istanbul` plugin:
```json
{
"babel": {
"presets": ["es2015"],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
}
}
```
Note: With this configuration, the Istanbul instrumentation will only be active when `NODE_ENV` or `BABEL_ENV` is `test`.
We recommend using the [`cross-env`](https://npmjs.com/package/cross-env) package to set these environment variables
in your `package.json` scripts in a way that works cross-platform.
2. disable nyc's instrumentation and source-maps, e.g. in `package.json`:
```json
{
"nyc": {
"require": [
"babel-register"
],
"sourceMap": false,
"instrument": false
},
"scripts": {
"test": "cross-env NODE_ENV=test nyc mocha"
}
}
```
That's all there is to it, better ES2015+ syntax highlighting awaits:
<img width="500" src="screen2.png">
## Support for alternate file extensions (.jsx, .es6)
Supporting file extensions can be configured through either the configuration arguments or with the `nyc` config section in `package.json`.
```shell
nyc --extension .jsx --extension .es6 npm test
```
```json
{
"nyc": {
"extension": [
".jsx",
".es6"
]
}
}
```
## Checking coverage
nyc can fail tests if coverage falls below a threshold.
After running your tests with nyc, simply run:
```shell
nyc check-coverage --lines 95 --functions 95 --branches 95
```
nyc also accepts a `--check-coverage` shorthand, which can be used to
both run tests and check that coverage falls within the threshold provided:
```shell
nyc --check-coverage --lines 100 npm test
```
The above check fails if coverage falls below 100%.
To check thresholds on a per-file basis run:
```shell
nyc check-coverage --lines 95 --per-file
```
## Running reports
Once you've run your tests with nyc, simply run:
```bash
nyc report
```
To view your coverage report:
<img width="500" src="screen.png">
you can use [any reporters that are supported by `istanbul`](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib):
```bash
nyc report --reporter=lcov
```
## Excluding files
You can tell nyc to exclude specific files and directories by adding
an `nyc.exclude` array to your `package.json`. Each element of
the array is a glob pattern indicating which paths should be omitted.
Globs are matched using [micromatch](https://www.npmjs.com/package/micromatch).
For example, the following config will exclude any files with the extension `.spec.js`,
and anything in the `build` directory:
```json
{
"nyc": {
"exclude": [
"**/*.spec.js",
"build"
]
}
}
```
> Note: Since version 9.0 files under `node_modules/` are excluded by default.
add the exclude rule `!**/node_modules/` to stop this.
> Note: exclude defaults to `['test', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**', '**/node_modules/**']`,
which would exclude `test`/`__tests__` directories as well as `test.js`, `*.test.js`,
and `test-*.js` files. Specifying your own exclude property overrides these defaults.
## Including files
As an alternative to providing a list of files to `exclude`, you can provide
an `include` key with a list of globs to specify specific files that should be covered:
```json
{
"nyc": {
"include": ["**/build/umd/moment.js"]
}
}
```
> Note: include defaults to `['**']`
> ### Use the `--all` flag to include files that have not been required in your tests.
## Require additional modules
The `--require` flag can be provided to `nyc` to indicate that additional
modules should be required in the subprocess collecting coverage:
`nyc --require babel-register --require babel-polyfill mocha`
## Caching
You can run `nyc` with the optional `--cache` flag, to prevent it from
instrumenting the same files multiple times. This can significantly
improve runtime performance.
## Configuring `nyc`
Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc` file:
**package.json:**
```json
{
"description": "These are just examples for demonstration, nothing prescriptive",
"nyc": {
"check-coverage": true,
"per-file": true,
"lines": 99,
"statements": 99,
"functions": 99,
"branches": 99,
"include": [
"src/**/*.js"
],
"exclude": [
"src/**/*.spec.js"
],
"reporter": [
"lcov",
"text-summary"
],
"require": [
"./test/helpers/some-helper.js"
],
"extension": [
".jsx"
],
"cache": true,
"all": true,
"report-dir": "./alternative"
}
}
```
### Publish, and reuse, your nyc configuration
nyc allows you to inherit other configurations using the key `extends`. As an example,
an alternative way to configure nyc for `babel-plugin-istanbul` would be to use the
[@istanbuljs/nyc-config-babel preset](https://www.npmjs.com/package/@istanbuljs/nyc-config-babel):
```json
{
"nyc": {
"extends": "@istanbuljs/nyc-config-babel"
}
}
```
To publish and resuse your own `nyc` configuration, simply create an npm module that
exports an `index.json` with your `nyc` config.
## High and low watermarks
Several of the coverage reporters supported by nyc display special information
for high and low watermarks:
* high-watermarks represent healthy test coverage (in many reports
this is represented with green highlighting).
* low-watermarks represent sub-optimal coverage levels (in many reports
this is represented with red highlighting).
You can specify custom high and low watermarks in nyc's configuration:
```json
{
"nyc": {
"watermarks": {
"lines": [80, 95],
"functions": [80, 95],
"branches": [80, 95],
"statements": [80, 95]
}
}
}
```
## Other advanced features
Take a look at http://istanbul.js.org/docs/advanced/ and please feel free to [contribute documentation](https://github.com/istanbuljs/istanbuljs.github.io/tree/development/content).
## Integrating with coveralls
[coveralls.io](https://coveralls.io) is a great tool for adding
coverage reports to your GitHub project. Here's how to get nyc
integrated with coveralls and travis-ci.org:
1. add the coveralls and nyc dependencies to your module:
```shell
npm install coveralls nyc --save-dev
```
2. update the scripts in your package.json to include these bins:
```json
{
"script": {
"test": "nyc mocha",
"coverage": "nyc report --reporter=text-lcov | coveralls"
}
}
```
3. For private repos, add the environment variable `COVERALLS_REPO_TOKEN` to travis.
4. add the following to your `.travis.yml`:
```yaml
after_success: npm run coverage
```
That's all there is to it!
> Note: by default coveralls.io adds comments to pull-requests on GitHub, this can feel intrusive. To disable this, click on your repo on coveralls.io and uncheck `LEAVE COMMENTS?`.
## Integrating with codecov
`nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov`
[codecov](https://codecov.io/) is a great tool for adding
coverage reports to your GitHub project, even viewing them inline on GitHub with a browser extension:
Here's how to get `nyc` integrated with codecov and travis-ci.org:
1. add the codecov and nyc dependencies to your module:
```shell
npm install codecov nyc --save-dev
```
2. update the scripts in your package.json to include these bins:
```json
{
"script": {
"test": "nyc tap ./test/*.js",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
}
}
```
3. For private repos, add the environment variable `CODECOV_TOKEN` to travis.
4. add the following to your `.travis.yml`:
```yaml
after_success: npm run coverage
```
That's all there is to it!
## Integrating with TAP formatters
Many testing frameworks (Mocha, Tape, Tap, etc.) can produce [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol) output. [tap-nyc](https://github.com/MegaArman/tap-nyc) is a TAP formatter designed to look nice with nyc.
## More tutorials
You can find more tutorials at http://istanbul.js.org/docs/tutorials

105
static/js/ketcher2/node_modules/nyc/bin/nyc.js generated vendored Executable file
View File

@ -0,0 +1,105 @@
#!/usr/bin/env node
var configUtil = require('../lib/config-util')
var foreground = require('foreground-child')
var NYC
try {
NYC = require('../index.covered.js')
} catch (e) {
NYC = require('../index.js')
}
var processArgs = require('../lib/process-args')
var sw = require('spawn-wrap')
var wrapper = require.resolve('./wrap.js')
// parse configuration and command-line arguments;
// we keep these values in a few different forms,
// used in the various execution contexts of nyc:
// reporting, instrumenting subprocesses, etc.
var yargs = configUtil.decorateYargs(configUtil.buildYargs())
var instrumenterArgs = processArgs.hideInstrumenteeArgs()
var argv = yargs.parse(instrumenterArgs)
var config = configUtil.loadConfig(instrumenterArgs)
if (argv._[0] === 'report') {
// run a report.
process.env.NYC_CWD = process.cwd()
report(config)
} else if (argv._[0] === 'check-coverage') {
checkCoverage(config)
} else if (argv._[0] === 'instrument') {
// look in lib/commands/instrument.js for logic.
} else if (argv._.length) {
// if instrument is set to false,
// enable a noop instrumenter.
if (!config.instrument) config.instrumenter = './lib/instrumenters/noop'
else config.instrumenter = './lib/instrumenters/istanbul'
var nyc = (new NYC(config))
if (config.clean) {
nyc.reset()
} else {
nyc.createTempDirectory()
}
if (config.all) nyc.addAllFiles()
var env = {
NYC_CONFIG: JSON.stringify(config),
NYC_CWD: process.cwd(),
NYC_ROOT_ID: nyc.rootId,
NYC_INSTRUMENTER: config.instrumenter
}
if (config['babel-cache'] === false) {
// babel's cache interferes with some configurations, so is
// disabled by default. opt in by setting babel-cache=true.
env.BABEL_DISABLE_CACHE = process.env.BABEL_DISABLE_CACHE = '1'
}
sw([wrapper], env)
// Both running the test script invocation and the check-coverage run may
// set process.exitCode. Keep track so that both children are run, but
// a non-zero exit codes in either one leads to an overall non-zero exit code.
process.exitCode = 0
foreground(processArgs.hideInstrumenterArgs(
// use the same argv descrption, but don't exit
// for flags like --help.
configUtil.buildYargs().parse(process.argv.slice(2))
), function (done) {
var mainChildExitCode = process.exitCode
if (config.checkCoverage) {
checkCoverage(config)
process.exitCode = process.exitCode || mainChildExitCode
if (!config.silent) report(config)
return done()
} else {
if (!config.silent) report(config)
return done()
}
})
} else {
// I don't have a clue what you're doing.
yargs.showHelp()
}
function report (argv) {
process.env.NYC_CWD = process.cwd()
var nyc = new NYC(argv)
nyc.report()
}
function checkCoverage (argv, cb) {
process.env.NYC_CWD = process.cwd()
;(new NYC(argv)).checkCoverage({
lines: argv.lines,
functions: argv.functions,
branches: argv.branches,
statements: argv.statements
}, argv['per-file'])
}

23
static/js/ketcher2/node_modules/nyc/bin/wrap.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
var sw = require('spawn-wrap')
var NYC
try {
NYC = require('../index.covered.js')
} catch (e) {
NYC = require('../index.js')
}
var parentPid = process.env.NYC_PARENT_PID || '0'
process.env.NYC_PARENT_PID = process.pid
var config = {}
if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG)
config.isChildProcess = true
config._processInfo = {
ppid: parentPid,
root: process.env.NYC_ROOT_ID
}
;(new NYC(config)).wrap()
sw.runMain()

531
static/js/ketcher2/node_modules/nyc/index.js generated vendored Executable file
View File

@ -0,0 +1,531 @@
/* global __coverage__ */
const arrify = require('arrify')
const cachingTransform = require('caching-transform')
const debugLog = require('debug-log')('nyc')
const findCacheDir = require('find-cache-dir')
const fs = require('fs')
const glob = require('glob')
const Hash = require('./lib/hash')
const js = require('default-require-extensions/js')
const libCoverage = require('istanbul-lib-coverage')
const libHook = require('istanbul-lib-hook')
const libReport = require('istanbul-lib-report')
const md5hex = require('md5-hex')
const mkdirp = require('mkdirp')
const Module = require('module')
const onExit = require('signal-exit')
const path = require('path')
const reports = require('istanbul-reports')
const resolveFrom = require('resolve-from')
const rimraf = require('rimraf')
const SourceMaps = require('./lib/source-maps')
const testExclude = require('test-exclude')
var ProcessInfo
try {
ProcessInfo = require('./lib/process.covered.js')
} catch (e) {
/* istanbul ignore next */
ProcessInfo = require('./lib/process.js')
}
/* istanbul ignore next */
if (/index\.covered\.js$/.test(__filename)) {
require('./lib/self-coverage-helper')
}
function NYC (config) {
config = config || {}
this.config = config
this.subprocessBin = config.subprocessBin || path.resolve(__dirname, './bin/nyc.js')
this._tempDirectory = config.tempDirectory || './.nyc_output'
this._instrumenterLib = require(config.instrumenter || './lib/instrumenters/istanbul')
this._reportDir = config.reportDir || 'coverage'
this._sourceMap = typeof config.sourceMap === 'boolean' ? config.sourceMap : true
this._showProcessTree = config.showProcessTree || false
this._eagerInstantiation = config.eager || false
this.cwd = config.cwd || process.cwd()
this.reporter = arrify(config.reporter || 'text')
this.cacheDirectory = config.cacheDir || findCacheDir({name: 'nyc', cwd: this.cwd})
this.cache = Boolean(this.cacheDirectory && config.cache)
this.exclude = testExclude({
cwd: this.cwd,
include: config.include,
exclude: config.exclude
})
this.sourceMaps = new SourceMaps({
cache: this.cache,
cacheDirectory: this.cacheDirectory
})
// require extensions can be provided as config in package.json.
this.require = arrify(config.require)
this.extensions = arrify(config.extension).concat('.js').map(function (ext) {
return ext.toLowerCase()
}).filter(function (item, pos, arr) {
// avoid duplicate extensions
return arr.indexOf(item) === pos
})
this.transforms = this.extensions.reduce(function (transforms, ext) {
transforms[ext] = this._createTransform(ext)
return transforms
}.bind(this), {})
this.hookRunInContext = config.hookRunInContext
this.fakeRequire = null
this.processInfo = new ProcessInfo(config && config._processInfo)
this.rootId = this.processInfo.root || this.generateUniqueID()
this.hashCache = {}
}
NYC.prototype._createTransform = function (ext) {
var _this = this
var opts = {
salt: Hash.salt,
hash: function (code, metadata, salt) {
var hash = Hash(code, metadata.filename)
_this.hashCache[metadata.filename] = hash
return hash
},
cacheDir: this.cacheDirectory,
// when running --all we should not load source-file from
// cache, we want to instead return the fake source.
disableCache: this._disableCachingTransform(),
ext: ext
}
if (this._eagerInstantiation) {
opts.transform = this._transformFactory(this.cacheDirectory)
} else {
opts.factory = this._transformFactory.bind(this)
}
return cachingTransform(opts)
}
NYC.prototype._disableCachingTransform = function () {
return !(this.cache && this.config.isChildProcess)
}
NYC.prototype._loadAdditionalModules = function () {
var _this = this
this.require.forEach(function (r) {
// first attempt to require the module relative to
// the directory being instrumented.
var p = resolveFrom(_this.cwd, r)
if (p) {
require(p)
return
}
// now try other locations, .e.g, the nyc node_modules folder.
require(r)
})
}
NYC.prototype.instrumenter = function () {
return this._instrumenter || (this._instrumenter = this._createInstrumenter())
}
NYC.prototype._createInstrumenter = function () {
return this._instrumenterLib(this.cwd, {
produceSourceMap: this.config.produceSourceMap
})
}
NYC.prototype.addFile = function (filename) {
var relFile = path.relative(this.cwd, filename)
var source = this._readTranspiledSource(path.resolve(this.cwd, filename))
var instrumentedSource = this._maybeInstrumentSource(source, filename, relFile)
return {
instrument: !!instrumentedSource,
relFile: relFile,
content: instrumentedSource || source
}
}
NYC.prototype._readTranspiledSource = function (filePath) {
var source = null
var ext = path.extname(filePath)
if (typeof Module._extensions[ext] === 'undefined') {
ext = '.js'
}
Module._extensions[ext]({
_compile: function (content, filename) {
source = content
}
}, filePath)
return source
}
NYC.prototype.addAllFiles = function () {
var _this = this
this._loadAdditionalModules()
this.fakeRequire = true
this.walkAllFiles(this.cwd, function (filename) {
filename = path.resolve(_this.cwd, filename)
_this.addFile(filename)
var coverage = coverageFinder()
var lastCoverage = _this.instrumenter().lastFileCoverage()
if (lastCoverage) {
filename = lastCoverage.path
}
if (lastCoverage && _this.exclude.shouldInstrument(filename)) {
coverage[filename] = lastCoverage
}
})
this.fakeRequire = false
this.writeCoverageFile()
}
NYC.prototype.instrumentAllFiles = function (input, output, cb) {
var _this = this
var inputDir = '.' + path.sep
var visitor = function (filename) {
var ext
var transform
var inFile = path.resolve(inputDir, filename)
var code = fs.readFileSync(inFile, 'utf-8')
for (ext in _this.transforms) {
if (filename.toLowerCase().substr(-ext.length) === ext) {
transform = _this.transforms[ext]
break
}
}
if (transform) {
code = transform(code, {filename: filename, relFile: inFile})
}
if (!output) {
console.log(code)
} else {
var outFile = path.resolve(output, filename)
mkdirp.sync(path.dirname(outFile))
fs.writeFileSync(outFile, code, 'utf-8')
}
}
this._loadAdditionalModules()
try {
var stats = fs.lstatSync(input)
if (stats.isDirectory()) {
inputDir = input
this.walkAllFiles(input, visitor)
} else {
visitor(input)
}
} catch (err) {
return cb(err)
}
}
NYC.prototype.walkAllFiles = function (dir, visitor) {
var pattern = null
if (this.extensions.length === 1) {
pattern = '**/*' + this.extensions[0]
} else {
pattern = '**/*{' + this.extensions.join() + '}'
}
glob.sync(pattern, {cwd: dir, nodir: true, ignore: this.exclude.exclude}).forEach(function (filename) {
visitor(filename)
})
}
NYC.prototype._maybeInstrumentSource = function (code, filename, relFile) {
var instrument = this.exclude.shouldInstrument(filename, relFile)
if (!instrument) {
return null
}
var ext, transform
for (ext in this.transforms) {
if (filename.toLowerCase().substr(-ext.length) === ext) {
transform = this.transforms[ext]
break
}
}
return transform ? transform(code, {filename: filename, relFile: relFile}) : null
}
NYC.prototype._transformFactory = function (cacheDir) {
var _this = this
var instrumenter = this.instrumenter()
var instrumented
return function (code, metadata, hash) {
var filename = metadata.filename
var sourceMap = null
if (_this._sourceMap) sourceMap = _this.sourceMaps.extractAndRegister(code, filename, hash)
try {
instrumented = instrumenter.instrumentSync(code, filename, sourceMap)
} catch (e) {
// don't fail external tests due to instrumentation bugs.
debugLog('failed to instrument ' + filename + 'with error: ' + e.stack)
instrumented = code
}
if (_this.fakeRequire) {
return 'function x () {}'
} else {
return instrumented
}
}
}
NYC.prototype._handleJs = function (code, filename) {
var relFile = path.relative(this.cwd, filename)
// ensure the path has correct casing (see istanbuljs/nyc#269 and nodejs/node#6624)
filename = path.resolve(this.cwd, relFile)
return this._maybeInstrumentSource(code, filename, relFile) || code
}
NYC.prototype._addHook = function (type) {
var handleJs = this._handleJs.bind(this)
var dummyMatcher = function () { return true } // we do all processing in transformer
libHook['hook' + type](dummyMatcher, handleJs, { extensions: this.extensions })
}
NYC.prototype._wrapRequire = function () {
this.extensions.forEach(function (ext) {
require.extensions[ext] = js
})
this._addHook('Require')
}
NYC.prototype._addOtherHooks = function () {
if (this.hookRunInContext) {
this._addHook('RunInThisContext')
}
}
NYC.prototype.cleanup = function () {
if (!process.env.NYC_CWD) rimraf.sync(this.tempDirectory())
}
NYC.prototype.clearCache = function () {
if (this.cache) {
rimraf.sync(this.cacheDirectory)
}
}
NYC.prototype.createTempDirectory = function () {
mkdirp.sync(this.tempDirectory())
if (this.cache) mkdirp.sync(this.cacheDirectory)
if (this._showProcessTree) {
mkdirp.sync(this.processInfoDirectory())
}
}
NYC.prototype.reset = function () {
this.cleanup()
this.createTempDirectory()
}
NYC.prototype._wrapExit = function () {
var _this = this
// we always want to write coverage
// regardless of how the process exits.
onExit(function () {
_this.writeCoverageFile()
}, {alwaysLast: true})
}
NYC.prototype.wrap = function (bin) {
this._wrapRequire()
this._addOtherHooks()
this._wrapExit()
this._loadAdditionalModules()
return this
}
NYC.prototype.generateUniqueID = function () {
return md5hex(
process.hrtime().concat(process.pid).map(String)
)
}
NYC.prototype.writeCoverageFile = function () {
var coverage = coverageFinder()
if (!coverage) return
// Remove any files that should be excluded but snuck into the coverage
Object.keys(coverage).forEach(function (absFile) {
if (!this.exclude.shouldInstrument(absFile)) {
delete coverage[absFile]
}
}, this)
if (this.cache) {
Object.keys(coverage).forEach(function (absFile) {
if (this.hashCache[absFile] && coverage[absFile]) {
coverage[absFile].contentHash = this.hashCache[absFile]
}
}, this)
} else {
coverage = this.sourceMaps.remapCoverage(coverage)
}
var id = this.generateUniqueID()
var coverageFilename = path.resolve(this.tempDirectory(), id + '.json')
fs.writeFileSync(
coverageFilename,
JSON.stringify(coverage),
'utf-8'
)
if (!this._showProcessTree) {
return
}
this.processInfo.coverageFilename = coverageFilename
fs.writeFileSync(
path.resolve(this.processInfoDirectory(), id + '.json'),
JSON.stringify(this.processInfo),
'utf-8'
)
}
function coverageFinder () {
var coverage = global.__coverage__
if (typeof __coverage__ === 'object') coverage = __coverage__
if (!coverage) coverage = global['__coverage__'] = {}
return coverage
}
NYC.prototype._getCoverageMapFromAllCoverageFiles = function () {
var _this = this
var map = libCoverage.createCoverageMap({})
this.loadReports().forEach(function (report) {
map.merge(report)
})
map.filter(function (filename) {
return _this.exclude.shouldInstrument(filename)
})
map.data = this.sourceMaps.remapCoverage(map.data)
return map
}
NYC.prototype.report = function () {
var tree
var map = this._getCoverageMapFromAllCoverageFiles()
var context = libReport.createContext({
dir: this._reportDir,
watermarks: this.config.watermarks
})
tree = libReport.summarizers.pkg(map)
this.reporter.forEach(function (_reporter) {
tree.visit(reports.create(_reporter), context)
})
if (this._showProcessTree) {
this.showProcessTree()
}
}
NYC.prototype.showProcessTree = function () {
var processTree = ProcessInfo.buildProcessTree(this._loadProcessInfos())
console.log(processTree.render(this))
}
NYC.prototype.checkCoverage = function (thresholds, perFile) {
var map = this._getCoverageMapFromAllCoverageFiles()
var nyc = this
if (perFile) {
map.files().forEach(function (file) {
// ERROR: Coverage for lines (90.12%) does not meet threshold (120%) for index.js
nyc._checkCoverage(map.fileCoverageFor(file).toSummary(), thresholds, file)
})
} else {
// ERROR: Coverage for lines (90.12%) does not meet global threshold (120%)
nyc._checkCoverage(map.getCoverageSummary(), thresholds)
}
// process.exitCode was not implemented until v0.11.8.
if (/^v0\.(1[0-1]\.|[0-9]\.)/.test(process.version) && process.exitCode !== 0) process.exit(process.exitCode)
}
NYC.prototype._checkCoverage = function (summary, thresholds, file) {
Object.keys(thresholds).forEach(function (key) {
var coverage = summary[key].pct
if (coverage < thresholds[key]) {
process.exitCode = 1
if (file) {
console.error('ERROR: Coverage for ' + key + ' (' + coverage + '%) does not meet threshold (' + thresholds[key] + '%) for ' + file)
} else {
console.error('ERROR: Coverage for ' + key + ' (' + coverage + '%) does not meet global threshold (' + thresholds[key] + '%)')
}
}
})
}
NYC.prototype._loadProcessInfos = function () {
var _this = this
var files = fs.readdirSync(this.processInfoDirectory())
return files.map(function (f) {
try {
return new ProcessInfo(JSON.parse(fs.readFileSync(
path.resolve(_this.processInfoDirectory(), f),
'utf-8'
)))
} catch (e) { // handle corrupt JSON output.
return {}
}
})
}
NYC.prototype.loadReports = function (filenames) {
var _this = this
var files = filenames || fs.readdirSync(this.tempDirectory())
return files.map(function (f) {
var report
try {
report = JSON.parse(fs.readFileSync(
path.resolve(_this.tempDirectory(), f),
'utf-8'
))
} catch (e) { // handle corrupt JSON output.
return {}
}
_this.sourceMaps.reloadCachedSourceMaps(report)
return report
})
}
NYC.prototype.tempDirectory = function () {
return path.resolve(this.cwd, this._tempDirectory)
}
NYC.prototype.processInfoDirectory = function () {
return path.resolve(this.tempDirectory(), 'processinfo')
}
module.exports = NYC

View File

@ -0,0 +1,55 @@
var NYC
try {
NYC = require('../../index.covered.js')
} catch (e) {
NYC = require('../../index.js')
}
exports.command = 'instrument <input> [output]'
exports.describe = 'instruments a file or a directory tree and writes the instrumented code to the desired output location'
exports.builder = function (yargs) {
return yargs
.usage('$0 instrument <input> [output]')
.option('require', {
alias: 'i',
default: [],
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.'
})
.option('extension', {
alias: 'e',
default: [],
describe: 'a list of extensions that nyc should handle in addition to .js'
})
.option('source-map', {
default: true,
type: 'boolean',
description: 'should nyc detect and handle source maps?'
})
.option('instrument', {
default: true,
type: 'boolean',
description: 'should nyc handle instrumentation?'
})
.example('$0 instrument ./lib ./output', 'instrument all .js files in ./lib with coverage and output in ./output')
}
exports.handler = function (argv) {
// if instrument is set to false,
// enable a noop instrumenter.
if (!argv.instrument) argv.instrumenter = './lib/instrumenters/noop'
else argv.instrumenter = './lib/instrumenters/istanbul'
var nyc = new NYC({
instrumenter: argv.instrumenter,
sourceMap: argv.sourceMap,
extension: argv.extension,
require: argv.require
})
nyc.instrumentAllFiles(argv.input, argv.output, function (err) {
if (err) console.error(err.message)
process.exit(1)
})
}

263
static/js/ketcher2/node_modules/nyc/lib/config-util.js generated vendored Normal file
View File

@ -0,0 +1,263 @@
const arrify = require('arrify')
const fs = require('fs')
const path = require('path')
const findUp = require('find-up')
const testExclude = require('test-exclude')
const Yargs = require('yargs/yargs')
var Config = {}
// load config from a cascade of sources:
// * command line arguments
// * package.json
// * .nycrc
Config.loadConfig = function (argv, cwd) {
cwd = cwd || process.env.NYC_CWD || process.cwd()
var pkgPath = findUp.sync('package.json', {cwd: cwd})
var rcPath = findUp.sync(['.nycrc', '.nycrc.json'], {cwd: cwd})
var rcConfig = null
if (rcPath) {
rcConfig = JSON.parse(
fs.readFileSync(rcPath, 'utf-8')
)
}
if (pkgPath) {
cwd = path.dirname(pkgPath)
}
var config = Config.buildYargs(cwd)
if (rcConfig) config.config(rcConfig)
config = config.parse(argv || [])
// post-hoc, we convert several of the
// configuration settings to arrays, providing
// a consistent contract to index.js.
config.require = arrify(config.require)
config.extension = arrify(config.extension)
config.exclude = arrify(config.exclude)
config.include = arrify(config.include)
return config
}
// build a yargs object, omitting any settings
// that would cause the application to exit early.
Config.buildYargs = function (cwd) {
return Yargs([])
.usage('$0 [command] [options]\n\nrun your tests with the nyc bin to instrument them with coverage')
.command('report', 'run coverage report for .nyc_output', function (yargs) {
return yargs
.usage('$0 report [options]')
.option('reporter', {
alias: 'r',
describe: 'coverage reporter(s) to use',
default: 'text'
})
.option('report-dir', {
describe: 'directory to output coverage reports in',
default: 'coverage'
})
.option('temp-directory', {
describe: 'directory to read raw coverage information from',
default: './.nyc_output'
})
.option('show-process-tree', {
describe: 'display the tree of spawned processes',
default: false,
type: 'boolean'
})
.example('$0 report --reporter=lcov', 'output an HTML lcov report to ./coverage')
})
.command('check-coverage', 'check whether coverage is within thresholds provided', function (yargs) {
return yargs
.usage('$0 check-coverage [options]')
.option('branches', {
default: 0,
description: 'what % of branches must be covered?'
})
.option('functions', {
default: 0,
description: 'what % of functions must be covered?'
})
.option('lines', {
default: 90,
description: 'what % of lines must be covered?'
})
.option('statements', {
default: 0,
description: 'what % of statements must be covered?'
})
.option('per-file', {
default: false,
description: 'check thresholds per file'
})
.example('$0 check-coverage --lines 95', "check whether the JSON in nyc's output folder meets the thresholds provided")
})
.option('reporter', {
alias: 'r',
describe: 'coverage reporter(s) to use',
default: 'text',
globa: false
})
.option('report-dir', {
describe: 'directory to output coverage reports in',
default: 'coverage',
global: false
})
.option('silent', {
alias: 's',
default: false,
type: 'boolean',
describe: "don't output a report after tests finish running",
global: false
})
.option('all', {
alias: 'a',
default: false,
type: 'boolean',
describe: 'whether or not to instrument all files of the project (not just the ones touched by your test suite)',
global: false
})
.option('exclude', {
alias: 'x',
default: testExclude.defaultExclude,
describe: 'a list of specific files and directories that should be excluded from coverage, glob patterns are supported, node_modules is always excluded',
global: false
})
.option('include', {
alias: 'n',
default: [],
describe: 'a list of specific files that should be covered, glob patterns are supported',
global: false
})
.option('cwd', {
describe: 'working directory used when resolving paths',
default: cwd
})
.option('require', {
alias: 'i',
default: [],
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.',
global: false
})
.option('eager', {
default: false,
type: 'boolean',
describe: 'instantiate the instrumenter at startup (see https://git.io/vMKZ9)',
global: false
})
.option('cache', {
alias: 'c',
default: true,
type: 'boolean',
describe: 'cache instrumentation results for improved performance',
global: false
})
.option('babel-cache', {
default: false,
type: 'boolean',
describe: 'cache babel transpilation results for improved performance',
global: false
})
.option('extension', {
alias: 'e',
default: [],
describe: 'a list of extensions that nyc should handle in addition to .js',
global: false
})
.option('check-coverage', {
type: 'boolean',
default: false,
describe: 'check whether coverage is within thresholds provided',
global: false
})
.option('branches', {
default: 0,
description: 'what % of branches must be covered?',
global: false
})
.option('functions', {
default: 0,
description: 'what % of functions must be covered?',
global: false
})
.option('lines', {
default: 90,
description: 'what % of lines must be covered?',
global: false
})
.option('statements', {
default: 0,
description: 'what % of statements must be covered?',
global: false
})
.option('source-map', {
default: true,
type: 'boolean',
description: 'should nyc detect and handle source maps?',
global: false
})
.option('per-file', {
default: false,
type: 'boolean',
description: 'check thresholds per file',
global: false
})
.option('produce-source-map', {
default: false,
type: 'boolean',
description: "should nyc's instrumenter produce source maps?",
global: false
})
.option('instrument', {
default: true,
type: 'boolean',
description: 'should nyc handle instrumentation?',
global: false
})
.option('hook-run-in-context', {
default: true,
type: 'boolean',
description: 'should nyc wrap vm.runInThisContext?',
global: false
})
.option('show-process-tree', {
describe: 'display the tree of spawned processes',
default: false,
type: 'boolean',
global: false
})
.option('clean', {
describe: 'should the .nyc_output folder be cleaned before executing tests',
default: true,
type: 'boolean',
global: false
})
.option('temp-directory', {
describe: 'directory to output raw coverage information to',
default: './.nyc_output',
global: false
})
.pkgConf('nyc', cwd || process.cwd())
.example('$0 npm test', 'instrument your tests with coverage')
.example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and babel')
.example('$0 report --reporter=text-lcov', 'output lcov report after running your tests')
.epilog('visit https://git.io/vHysA for list of available reporters')
.boolean('help')
.boolean('h')
.boolean('version')
}
// decorate yargs with all the actions
// that would make it exit: help, version, command.
Config.decorateYargs = function (yargs) {
return yargs
.help('h')
.alias('h', 'help')
.version()
.command(require('../lib/commands/instrument'))
}
module.exports = Config

14
static/js/ketcher2/node_modules/nyc/lib/hash.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
const CACHE_VERSION = require('../package.json').version
const md5hex = require('md5-hex')
const salt = JSON.stringify({
istanbul: require('istanbul-lib-coverage/package.json').version,
nyc: CACHE_VERSION
})
function Hash (code, filename) {
return md5hex([code, filename, salt]) + '_' + CACHE_VERSION
}
Hash.salt = salt
module.exports = Hash

View File

@ -0,0 +1,50 @@
'use strict'
var convertSourceMap = require('convert-source-map')
var mergeSourceMap = require('merge-source-map')
function InstrumenterIstanbul (cwd, options) {
var istanbul = InstrumenterIstanbul.istanbul()
var instrumenter = istanbul.createInstrumenter({
autoWrap: true,
coverageVariable: '__coverage__',
embedSource: true,
noCompact: false,
preserveComments: true,
produceSourceMap: options.produceSourceMap,
esModules: true
})
return {
instrumentSync: function (code, filename, sourceMap) {
var instrumented = instrumenter.instrumentSync(code, filename)
// the instrumenter can optionally produce source maps,
// this is useful for features like remapping stack-traces.
// TODO: test source-map merging logic.
if (options.produceSourceMap) {
var lastSourceMap = instrumenter.lastSourceMap()
if (lastSourceMap) {
if (sourceMap) {
lastSourceMap = mergeSourceMap(
sourceMap.toObject(),
lastSourceMap
)
}
instrumented += '\n' + convertSourceMap.fromObject(lastSourceMap).toComment()
}
}
return instrumented
},
lastFileCoverage: function () {
return instrumenter.lastFileCoverage()
}
}
}
InstrumenterIstanbul.istanbul = function () {
InstrumenterIstanbul._istanbul || (InstrumenterIstanbul._istanbul = require('istanbul-lib-instrument'))
return InstrumenterIstanbul._istanbul || (InstrumenterIstanbul._istanbul = require('istanbul'))
}
module.exports = InstrumenterIstanbul

View File

@ -0,0 +1,21 @@
var FileCoverage = require('istanbul-lib-coverage').classes.FileCoverage
var readInitialCoverage = require('istanbul-lib-instrument').readInitialCoverage
function NOOP () {
return {
instrumentSync: function (code, filename) {
var extracted = readInitialCoverage(code)
if (extracted) {
this.fileCoverage = new FileCoverage(extracted.coverageData)
} else {
this.fileCoverage = null
}
return code
},
lastFileCoverage: function () {
return this.fileCoverage
}
}
}
module.exports = NOOP

View File

@ -0,0 +1,36 @@
const parser = require('yargs-parser')
const commands = [
'report',
'check-coverage',
'instrument'
]
module.exports = {
// don't pass arguments that are meant
// for nyc to the bin being instrumented.
hideInstrumenterArgs: function (yargv) {
var argv = process.argv.slice(1)
argv = argv.slice(argv.indexOf(yargv._[0]))
if (argv[0][0] === '-') {
argv.unshift(process.execPath)
}
return argv
},
// don't pass arguments for the bin being
// instrumented to nyc.
hideInstrumenteeArgs: function () {
var argv = process.argv.slice(2)
var yargv = parser(argv)
if (!yargv._.length) return argv
for (var i = 0, command; (command = yargv._[i]) !== undefined; i++) {
if (~commands.indexOf(command)) return argv
}
// drop all the arguments after the bin being
// instrumented by nyc.
argv = argv.slice(0, argv.indexOf(yargv._[0]))
argv.push(yargv._[0])
return argv
}
}

98
static/js/ketcher2/node_modules/nyc/lib/process.js generated vendored Normal file
View File

@ -0,0 +1,98 @@
const archy = require('archy')
const libCoverage = require('istanbul-lib-coverage')
function ProcessInfo (defaults) {
defaults = defaults || {}
this.pid = String(process.pid)
this.argv = process.argv
this.execArgv = process.execArgv
this.cwd = process.cwd()
this.time = Date.now()
this.ppid = null
this.root = null
this.coverageFilename = null
this.nodes = [] // list of children, filled by buildProcessTree()
this._coverageMap = null
for (var key in defaults) {
this[key] = defaults[key]
}
}
Object.defineProperty(ProcessInfo.prototype, 'label', {
get: function () {
if (this._label) {
return this._label
}
var covInfo = ''
if (this._coverageMap) {
covInfo = '\n ' + this._coverageMap.getCoverageSummary().lines.pct + ' % Lines'
}
return this.argv.join(' ') + covInfo
}
})
ProcessInfo.buildProcessTree = function (infos) {
var treeRoot = new ProcessInfo({ _label: 'nyc' })
var nodes = { }
infos = infos.sort(function (a, b) {
return a.time - b.time
})
infos.forEach(function (p) {
nodes[p.root + ':' + p.pid] = p
})
infos.forEach(function (p) {
if (!p.ppid) {
return
}
var parent = nodes[p.root + ':' + p.ppid]
if (!parent) {
parent = treeRoot
}
parent.nodes.push(p)
})
return treeRoot
}
ProcessInfo.prototype.getCoverageMap = function (merger) {
if (this._coverageMap) {
return this._coverageMap
}
var childMaps = this.nodes.map(function (child) {
return child.getCoverageMap(merger)
})
this._coverageMap = merger([this.coverageFilename], childMaps)
return this._coverageMap
}
ProcessInfo.prototype.render = function (nyc) {
this.getCoverageMap(function (filenames, maps) {
var map = libCoverage.createCoverageMap({})
nyc.loadReports(filenames).forEach(function (report) {
map.merge(report)
})
maps.forEach(function (otherMap) {
map.merge(otherMap)
})
return map
})
return archy(this)
}
module.exports = ProcessInfo

View File

@ -0,0 +1,20 @@
/* global ___NYC_SELF_COVERAGE___ */
const path = require('path')
const fs = require('fs')
const mkdirp = require('mkdirp')
const onExit = require('signal-exit')
onExit(function () {
var coverage = global.___NYC_SELF_COVERAGE___
if (typeof ___NYC_SELF_COVERAGE___ === 'object') coverage = ___NYC_SELF_COVERAGE___
if (!coverage) return
var selfCoverageDir = path.join(__dirname, '../.self_coverage')
mkdirp.sync(selfCoverageDir)
fs.writeFileSync(
path.join(selfCoverageDir, process.pid + '.json'),
JSON.stringify(coverage),
'utf-8'
)
})

57
static/js/ketcher2/node_modules/nyc/lib/source-maps.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
const convertSourceMap = require('convert-source-map')
const libCoverage = require('istanbul-lib-coverage')
const libSourceMaps = require('istanbul-lib-source-maps')
const fs = require('fs')
const path = require('path')
// TODO: write some unit tests for this class.
function SourceMaps (opts) {
this.cache = opts.cache
this.cacheDirectory = opts.cacheDirectory
this.sourceMapCache = libSourceMaps.createSourceMapStore()
this.loadedMaps = {}
}
SourceMaps.prototype.extractAndRegister = function (code, filename, hash) {
var sourceMap = convertSourceMap.fromSource(code) || convertSourceMap.fromMapFileSource(code, path.dirname(filename))
if (sourceMap) {
if (this.cache && hash) {
var mapPath = path.join(this.cacheDirectory, hash + '.map')
fs.writeFileSync(mapPath, sourceMap.toJSON())
} else {
this.sourceMapCache.registerMap(filename, sourceMap.sourcemap)
}
}
return sourceMap
}
SourceMaps.prototype.remapCoverage = function (obj) {
var transformed = this.sourceMapCache.transformCoverage(
libCoverage.createCoverageMap(obj)
)
return transformed.map.data
}
SourceMaps.prototype.reloadCachedSourceMaps = function (report) {
var _this = this
Object.keys(report).forEach(function (absFile) {
var fileReport = report[absFile]
if (fileReport && fileReport.contentHash) {
var hash = fileReport.contentHash
if (!(hash in _this.loadedMaps)) {
try {
var mapPath = path.join(_this.cacheDirectory, hash + '.map')
_this.loadedMaps[hash] = JSON.parse(fs.readFileSync(mapPath, 'utf8'))
} catch (e) {
// set to false to avoid repeatedly trying to load the map
_this.loadedMaps[hash] = false
}
}
if (_this.loadedMaps[hash]) {
_this.sourceMapCache.registerMap(absFile, _this.loadedMaps[hash])
}
}
})
}
module.exports = SourceMaps

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015, Jon Schlinkert.
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.

View File

@ -0,0 +1,236 @@
# align-text [![NPM version](https://badge.fury.io/js/align-text.svg)](http://badge.fury.io/js/align-text) [![Build Status](https://travis-ci.org/jonschlinkert/align-text.svg)](https://travis-ci.org/jonschlinkert/align-text)
> Align the text in a string.
**Examples**
Align text values in an array:
```js
align([1, 2, 3, 100]);
//=> [' 1', ' 2', ' 3', '100']
```
Or [do stuff like this](./example.js):
[![screen shot 2015-06-09 at 2 08 34 am](https://cloud.githubusercontent.com/assets/383994/8051597/7b716fbc-0e4c-11e5-9aef-4493fd22db58.png)](./example.js)
Visit [the example](./example.js) to see how this works.
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i align-text --save
```
## Usage
```js
var align = require('align-text');
align(text, callback_function_or_integer);
```
**Params**
* `text` can be a **string or array**. If a string is passed, a string will be returned. If an array is passed, an array will be returned.
* `callback|integer`: if an integer, the text will be indented by that amount. If a function, it must return an integer representing the amount of leading indentation to use as `align` loops over each line.
**Example**
```js
align(text, 4);
```
Would align:
```
abc
abc
abc
```
To:
```
abc
abc
abc
```
## callback
### params
The callback is used to determine the indentation of each line and gets the following params:
* `len` the length of the "current" line
* `longest` the length of the longest line
* `line` the current line (string) being aligned
* `lines` the array of all lines
### return
The callback may return:
* an integer that represents the number of spaces to use for padding,
* or an object with the following properties:
- `indent`: **{Number}** the amount of indentation to use. Default is `0` when an object is returned.
- `character`: **{String}** the character to use for indentation. Default is `''` (empty string) when an object is returned.
- `prefix`: **{String}** leading characters to use at the beginning of each line. `''` (empty string) when an object is returned.
**Integer example:**
```js
// calculate half the difference between the length
// of the current line and the longest line
function centerAlign(len, longest, line, lines) {
return Math.floor((longest - len) / 2);
}
```
**Object example:**
```js
function centerAlign(len, longest, line, lines) {
return {
character: '\t',
indent: Math.floor((longest - len) / 2),
prefix: '~ ',
}
}
```
## Usage examples
### Center align
Using the `centerAlign` function from above:
```js
align(text, centerAlign);
```
Would align this text:
```js
Lorem ipsum dolor sit amet
consectetur adipiscin
elit, sed do eiusmod tempor incididun
ut labore et dolor
magna aliqua. Ut enim ad mini
veniam, quis
```
Resulting in this:
```
Lorem ipsum dolor sit amet,
consectetur adipiscing
elit, sed do eiusmod tempor incididunt
ut labore et dolore
magna aliqua. Ut enim ad minim
veniam, quis
```
**Customize**
If you wanted to add more padding on the left, just pass the number in the callback.
For example, to add 4 spaces before every line:
```js
function centerAlign(len, longest, line, lines) {
return 4 + Math.floor((longest - len) / 2);
}
```
Would result in:
```
Lorem ipsum dolor sit amet,
consectetur adipiscing
elit, sed do eiusmod tempor incididunt
ut labore et dolore
magna aliqua. Ut enim ad minim
veniam, quis
```
### Bullets
```js
align(text, function (len, max, line, lines) {
return {prefix: ' - '};
});
```
Would return:
```
- Lorem ipsum dolor sit amet,
- consectetur adipiscing
- elit, sed do eiusmod tempor incididunt
- ut labore et dolore
- magna aliqua. Ut enim ad minim
- veniam, quis
```
### Different indent character
```js
align(text, function (len, max, line, lines) {
return {
indent: Math.floor((max - len) / 2),
character: '~',
};
});
```
Would return
```
~~~~~Lorem ipsum dolor sit amet,
~~~~~~~~consectetur adipiscing
elit, sed do eiusmod tempor incididunt
~~~~~~~~~ut labore et dolore
~~~~magna aliqua. Ut enim ad minim
~~~~~~~~~~~~~veniam, quis
```
## Related projects
* [center-align](https://github.com/jonschlinkert/center-align): Center-align the text in a string.
* [justify](https://github.com/bahamas10/node-justify): Left or right (or both) justify text using a custom width and character
* [longest](https://github.com/jonschlinkert/longest): Get the longest item in an array.
* [right-align](https://github.com/jonschlinkert/right-align): Right-align the text in a string.
* [repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string.
* [word-wrap](https://github.com/jonschlinkert/word-wrap): Wrap words to a specified length.
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/align-text/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 09, 2015._

View File

@ -0,0 +1,52 @@
/*!
* align-text <https://github.com/jonschlinkert/align-text>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var typeOf = require('kind-of');
var repeat = require('repeat-string');
var longest = require('longest');
module.exports = function alignText(val, fn) {
var lines, type = typeOf(val);
if (type === 'array') {
lines = val;
} else if (type === 'string') {
lines = val.split(/(?:\r\n|\n)/);
} else {
throw new TypeError('align-text expects a string or array.');
}
var fnType = typeOf(fn);
var len = lines.length;
var max = longest(lines);
var res = [], i = 0;
while (len--) {
var line = String(lines[i++]);
var diff;
if (fnType === 'function') {
diff = fn(line.length, max.length, line, lines, i);
} else if (fnType === 'number') {
diff = fn;
} else {
diff = max.length - line.length;
}
if (typeOf(diff) === 'number') {
res.push(repeat(' ', diff) + line);
} else if (typeOf(diff) === 'object') {
var result = repeat(diff.character || ' ', diff.indent || 0);
res.push((diff.prefix || '') + result + line);
}
}
if (type === 'array') return res;
return res.join('\n');
};

View File

@ -0,0 +1,117 @@
{
"_args": [
[
{
"raw": "align-text@^0.1.3",
"scope": null,
"escapedName": "align-text",
"name": "align-text",
"rawSpec": "^0.1.3",
"spec": ">=0.1.3 <0.2.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/center-align"
]
],
"_from": "align-text@>=0.1.3 <0.2.0",
"_id": "align-text@0.1.4",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/align-text",
"_nodeVersion": "5.5.0",
"_npmOperationalInternal": {
"host": "packages-9-west.internal.npmjs.com",
"tmp": "tmp/align-text-0.1.4.tgz_1454377856920_0.9624228512402624"
},
"_npmUser": {
"name": "shinnn",
"email": "snnskwtnb@gmail.com"
},
"_npmVersion": "3.6.0",
"_phantomChildren": {},
"_requested": {
"raw": "align-text@^0.1.3",
"scope": null,
"escapedName": "align-text",
"name": "align-text",
"rawSpec": "^0.1.3",
"spec": ">=0.1.3 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/nyc/center-align",
"/nyc/right-align"
],
"_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
"_shasum": "0cd90a561093f35d0a99256c22b7069433fad117",
"_shrinkwrap": null,
"_spec": "align-text@^0.1.3",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/center-align",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/align-text/issues"
},
"dependencies": {
"kind-of": "^3.0.2",
"longest": "^1.0.1",
"repeat-string": "^1.5.2"
},
"description": "Align the text in a string.",
"devDependencies": {
"mocha": "*",
"should": "*",
"word-wrap": "^1.0.3"
},
"directories": {},
"dist": {
"shasum": "0cd90a561093f35d0a99256c22b7069433fad117",
"tarball": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "7f08e823a54c6bda319d875895813537a66a4c5e",
"homepage": "https://github.com/jonschlinkert/align-text",
"keywords": [
"align",
"align-center",
"alignment",
"center",
"center-align",
"indent",
"pad",
"padding",
"right",
"right-align",
"text",
"typography"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "jonschlinkert",
"email": "github@sellside.com"
},
{
"name": "shinnn",
"email": "snnskwtnb@gmail.com"
}
],
"name": "align-text",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/align-text.git"
},
"scripts": {
"test": "mocha"
},
"version": "0.1.4"
}

View File

@ -0,0 +1,58 @@
amdefine is released under two licenses: new BSD, and MIT. You may pick the
license that best suits your development needs. The text of both licenses are
provided below.
The "New" BSD License:
----------------------
Copyright (c) 2011-2016, The Dojo Foundation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Dojo Foundation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MIT License
-----------
Copyright (c) 2011-2016, The Dojo Foundation
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.

View File

@ -0,0 +1,171 @@
# amdefine
A module that can be used to implement AMD's define() in Node. This allows you
to code to the AMD API and have the module work in node programs without
requiring those other programs to use AMD.
## Usage
**1)** Update your package.json to indicate amdefine as a dependency:
```javascript
"dependencies": {
"amdefine": ">=0.1.0"
}
```
Then run `npm install` to get amdefine into your project.
**2)** At the top of each module that uses define(), place this code:
```javascript
if (typeof define !== 'function') { var define = require('amdefine')(module) }
```
**Only use these snippets** when loading amdefine. If you preserve the basic structure,
with the braces, it will be stripped out when using the [RequireJS optimizer](#optimizer).
You can add spaces, line breaks and even require amdefine with a local path, but
keep the rest of the structure to get the stripping behavior.
As you may know, because `if` statements in JavaScript don't have their own scope, the var
declaration in the above snippet is made whether the `if` expression is truthy or not. If
RequireJS is loaded then the declaration is superfluous because `define` is already already
declared in the same scope in RequireJS. Fortunately JavaScript handles multiple `var`
declarations of the same variable in the same scope gracefully.
If you want to deliver amdefine.js with your code rather than specifying it as a dependency
with npm, then just download the latest release and refer to it using a relative path:
[Latest Version](https://github.com/jrburke/amdefine/raw/latest/amdefine.js)
### amdefine/intercept
Consider this very experimental.
Instead of pasting the piece of text for the amdefine setup of a `define`
variable in each module you create or consume, you can use `amdefine/intercept`
instead. It will automatically insert the above snippet in each .js file loaded
by Node.
**Warning**: you should only use this if you are creating an application that
is consuming AMD style defined()'d modules that are distributed via npm and want
to run that code in Node.
For library code where you are not sure if it will be used by others in Node or
in the browser, then explicitly depending on amdefine and placing the code
snippet above is suggested path, instead of using `amdefine/intercept`. The
intercept module affects all .js files loaded in the Node app, and it is
inconsiderate to modify global state like that unless you are also controlling
the top level app.
#### Why distribute AMD-style modules via npm?
npm has a lot of weaknesses for front-end use (installed layout is not great,
should have better support for the `baseUrl + moduleID + '.js' style of loading,
single file JS installs), but some people want a JS package manager and are
willing to live with those constraints. If that is you, but still want to author
in AMD style modules to get dynamic require([]), better direct source usage and
powerful loader plugin support in the browser, then this tool can help.
#### amdefine/intercept usage
Just require it in your top level app module (for example index.js, server.js):
```javascript
require('amdefine/intercept');
```
The module does not return a value, so no need to assign the result to a local
variable.
Then just require() code as you normally would with Node's require(). Any .js
loaded after the intercept require will have the amdefine check injected in
the .js source as it is loaded. It does not modify the source on disk, just
prepends some content to the text of the module as it is loaded by Node.
#### How amdefine/intercept works
It overrides the `Module._extensions['.js']` in Node to automatically prepend
the amdefine snippet above. So, it will affect any .js file loaded by your
app.
## define() usage
It is best if you use the anonymous forms of define() in your module:
```javascript
define(function (require) {
var dependency = require('dependency');
});
```
or
```javascript
define(['dependency'], function (dependency) {
});
```
## RequireJS optimizer integration. <a name="optimizer"></name>
Version 1.0.3 of the [RequireJS optimizer](http://requirejs.org/docs/optimization.html)
will have support for stripping the `if (typeof define !== 'function')` check
mentioned above, so you can include this snippet for code that runs in the
browser, but avoid taking the cost of the if() statement once the code is
optimized for deployment.
## Node 0.4 Support
If you want to support Node 0.4, then add `require` as the second parameter to amdefine:
```javascript
//Only if you want Node 0.4. If using 0.5 or later, use the above snippet.
if (typeof define !== 'function') { var define = require('amdefine')(module, require) }
```
## Limitations
### Synchronous vs Asynchronous
amdefine creates a define() function that is callable by your code. It will
execute and trace dependencies and call the factory function *synchronously*,
to keep the behavior in line with Node's synchronous dependency tracing.
The exception: calling AMD's callback-style require() from inside a factory
function. The require callback is called on process.nextTick():
```javascript
define(function (require) {
require(['a'], function(a) {
//'a' is loaded synchronously, but
//this callback is called on process.nextTick().
});
});
```
### Loader Plugins
Loader plugins are supported as long as they call their load() callbacks
synchronously. So ones that do network requests will not work. However plugins
like [text](http://requirejs.org/docs/api.html#text) can load text files locally.
The plugin API's `load.fromText()` is **not supported** in amdefine, so this means
transpiler plugins like the [CoffeeScript loader plugin](https://github.com/jrburke/require-cs)
will not work. This may be fixable, but it is a bit complex, and I do not have
enough node-fu to figure it out yet. See the source for amdefine.js if you want
to get an idea of the issues involved.
## Tests
To run the tests, cd to **tests** and run:
```
node all.js
node all-intercept.js
```
## License
New BSD and MIT. Check the LICENSE file for all the details.

View File

@ -0,0 +1,301 @@
/** vim: et:ts=4:sw=4:sts=4
* @license amdefine 1.0.1 Copyright (c) 2011-2016, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/amdefine for details
*/
/*jslint node: true */
/*global module, process */
'use strict';
/**
* Creates a define for node.
* @param {Object} module the "module" object that is defined by Node for the
* current module.
* @param {Function} [requireFn]. Node's require function for the current module.
* It only needs to be passed in Node versions before 0.5, when module.require
* did not exist.
* @returns {Function} a define function that is usable for the current node
* module.
*/
function amdefine(module, requireFn) {
'use strict';
var defineCache = {},
loaderCache = {},
alreadyCalled = false,
path = require('path'),
makeRequire, stringRequire;
/**
* Trims the . and .. from an array of path segments.
* It will keep a leading path segment if a .. will become
* the first path segment, to help with module name lookups,
* which act like paths, but can be remapped. But the end result,
* all paths that use this function should look normalized.
* NOTE: this method MODIFIES the input array.
* @param {Array} ary the array of path segments.
*/
function trimDots(ary) {
var i, part;
for (i = 0; ary[i]; i+= 1) {
part = ary[i];
if (part === '.') {
ary.splice(i, 1);
i -= 1;
} else if (part === '..') {
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
//End of the line. Keep at least one non-dot
//path segment at the front so it can be mapped
//correctly to disk. Otherwise, there is likely
//no path mapping for a path starting with '..'.
//This can still fail, but catches the most reasonable
//uses of ..
break;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
}
}
function normalize(name, baseName) {
var baseParts;
//Adjust any relative paths.
if (name && name.charAt(0) === '.') {
//If have a base name, try to normalize against it,
//otherwise, assume it is a top-level require that will
//be relative to baseUrl in the end.
if (baseName) {
baseParts = baseName.split('/');
baseParts = baseParts.slice(0, baseParts.length - 1);
baseParts = baseParts.concat(name.split('/'));
trimDots(baseParts);
name = baseParts.join('/');
}
}
return name;
}
/**
* Create the normalize() function passed to a loader plugin's
* normalize method.
*/
function makeNormalize(relName) {
return function (name) {
return normalize(name, relName);
};
}
function makeLoad(id) {
function load(value) {
loaderCache[id] = value;
}
load.fromText = function (id, text) {
//This one is difficult because the text can/probably uses
//define, and any relative paths and requires should be relative
//to that id was it would be found on disk. But this would require
//bootstrapping a module/require fairly deeply from node core.
//Not sure how best to go about that yet.
throw new Error('amdefine does not implement load.fromText');
};
return load;
}
makeRequire = function (systemRequire, exports, module, relId) {
function amdRequire(deps, callback) {
if (typeof deps === 'string') {
//Synchronous, single module require('')
return stringRequire(systemRequire, exports, module, deps, relId);
} else {
//Array of dependencies with a callback.
//Convert the dependencies to modules.
deps = deps.map(function (depName) {
return stringRequire(systemRequire, exports, module, depName, relId);
});
//Wait for next tick to call back the require call.
if (callback) {
process.nextTick(function () {
callback.apply(null, deps);
});
}
}
}
amdRequire.toUrl = function (filePath) {
if (filePath.indexOf('.') === 0) {
return normalize(filePath, path.dirname(module.filename));
} else {
return filePath;
}
};
return amdRequire;
};
//Favor explicit value, passed in if the module wants to support Node 0.4.
requireFn = requireFn || function req() {
return module.require.apply(module, arguments);
};
function runFactory(id, deps, factory) {
var r, e, m, result;
if (id) {
e = loaderCache[id] = {};
m = {
id: id,
uri: __filename,
exports: e
};
r = makeRequire(requireFn, e, m, id);
} else {
//Only support one define call per file
if (alreadyCalled) {
throw new Error('amdefine with no module ID cannot be called more than once per file.');
}
alreadyCalled = true;
//Use the real variables from node
//Use module.exports for exports, since
//the exports in here is amdefine exports.
e = module.exports;
m = module;
r = makeRequire(requireFn, e, m, module.id);
}
//If there are dependencies, they are strings, so need
//to convert them to dependency values.
if (deps) {
deps = deps.map(function (depName) {
return r(depName);
});
}
//Call the factory with the right dependencies.
if (typeof factory === 'function') {
result = factory.apply(m.exports, deps);
} else {
result = factory;
}
if (result !== undefined) {
m.exports = result;
if (id) {
loaderCache[id] = m.exports;
}
}
}
stringRequire = function (systemRequire, exports, module, id, relId) {
//Split the ID by a ! so that
var index = id.indexOf('!'),
originalId = id,
prefix, plugin;
if (index === -1) {
id = normalize(id, relId);
//Straight module lookup. If it is one of the special dependencies,
//deal with it, otherwise, delegate to node.
if (id === 'require') {
return makeRequire(systemRequire, exports, module, relId);
} else if (id === 'exports') {
return exports;
} else if (id === 'module') {
return module;
} else if (loaderCache.hasOwnProperty(id)) {
return loaderCache[id];
} else if (defineCache[id]) {
runFactory.apply(null, defineCache[id]);
return loaderCache[id];
} else {
if(systemRequire) {
return systemRequire(originalId);
} else {
throw new Error('No module with ID: ' + id);
}
}
} else {
//There is a plugin in play.
prefix = id.substring(0, index);
id = id.substring(index + 1, id.length);
plugin = stringRequire(systemRequire, exports, module, prefix, relId);
if (plugin.normalize) {
id = plugin.normalize(id, makeNormalize(relId));
} else {
//Normalize the ID normally.
id = normalize(id, relId);
}
if (loaderCache[id]) {
return loaderCache[id];
} else {
plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
return loaderCache[id];
}
}
};
//Create a define function specific to the module asking for amdefine.
function define(id, deps, factory) {
if (Array.isArray(id)) {
factory = deps;
deps = id;
id = undefined;
} else if (typeof id !== 'string') {
factory = id;
id = deps = undefined;
}
if (deps && !Array.isArray(deps)) {
factory = deps;
deps = undefined;
}
if (!deps) {
deps = ['require', 'exports', 'module'];
}
//Set up properties for this module. If an ID, then use
//internal cache. If no ID, then use the external variables
//for this node module.
if (id) {
//Put the module in deep freeze until there is a
//require call for it.
defineCache[id] = [id, deps, factory];
} else {
runFactory(id, deps, factory);
}
}
//define.require, which has access to all the values in the
//cache. Useful for AMD modules that all have IDs in the file,
//but need to finally export a value to node based on one of those
//IDs.
define.require = function (id) {
if (loaderCache[id]) {
return loaderCache[id];
}
if (defineCache[id]) {
runFactory.apply(null, defineCache[id]);
return loaderCache[id];
}
};
define.amd = {};
return define;
}
module.exports = amdefine;

View File

@ -0,0 +1,36 @@
/*jshint node: true */
var inserted,
Module = require('module'),
fs = require('fs'),
existingExtFn = Module._extensions['.js'],
amdefineRegExp = /amdefine\.js/;
inserted = "if (typeof define !== 'function') {var define = require('amdefine')(module)}";
//From the node/lib/module.js source:
function stripBOM(content) {
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
// because the buffer-to-string conversion in `fs.readFileSync()`
// translates it to FEFF, the UTF-16 BOM.
if (content.charCodeAt(0) === 0xFEFF) {
content = content.slice(1);
}
return content;
}
//Also adapted from the node/lib/module.js source:
function intercept(module, filename) {
var content = stripBOM(fs.readFileSync(filename, 'utf8'));
if (!amdefineRegExp.test(module.id)) {
content = inserted + content;
}
module._compile(content, filename);
}
intercept._id = 'amdefine/intercept';
if (!existingExtFn._id || existingExtFn._id !== intercept._id) {
Module._extensions['.js'] = intercept;
}

View File

@ -0,0 +1,86 @@
{
"_args": [
[
{
"raw": "amdefine@>=0.0.4",
"scope": null,
"escapedName": "amdefine",
"name": "amdefine",
"rawSpec": ">=0.0.4",
"spec": ">=0.0.4",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/handlebars/node_modules/source-map"
]
],
"_from": "amdefine@>=0.0.4",
"_id": "amdefine@1.0.1",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/amdefine",
"_nodeVersion": "6.7.0",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/amdefine-1.0.1.tgz_1478062849665_0.19916908955201507"
},
"_npmUser": {
"name": "jrburke",
"email": "jrburke@gmail.com"
},
"_npmVersion": "3.10.3",
"_phantomChildren": {},
"_requested": {
"raw": "amdefine@>=0.0.4",
"scope": null,
"escapedName": "amdefine",
"name": "amdefine",
"rawSpec": ">=0.0.4",
"spec": ">=0.0.4",
"type": "range"
},
"_requiredBy": [
"/nyc/handlebars/source-map"
],
"_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
"_shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5",
"_shrinkwrap": null,
"_spec": "amdefine@>=0.0.4",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/handlebars/node_modules/source-map",
"author": {
"name": "James Burke",
"email": "jrburke@gmail.com",
"url": "http://github.com/jrburke"
},
"bugs": {
"url": "https://github.com/jrburke/amdefine/issues"
},
"dependencies": {},
"description": "Provide AMD's define() API for declaring modules in the AMD format",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5",
"tarball": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz"
},
"engines": {
"node": ">=0.4.2"
},
"gitHead": "e59edc9da24404ec7937098e3992f8fb0e260be7",
"homepage": "http://github.com/jrburke/amdefine",
"license": "BSD-3-Clause OR MIT",
"main": "./amdefine.js",
"maintainers": [
{
"name": "jrburke",
"email": "jrburke@gmail.com"
}
],
"name": "amdefine",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/jrburke/amdefine.git"
},
"scripts": {},
"version": "1.0.1"
}

View File

@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g;
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View File

@ -0,0 +1,139 @@
{
"_args": [
[
{
"raw": "ansi-regex@^2.0.0",
"scope": null,
"escapedName": "ansi-regex",
"name": "ansi-regex",
"rawSpec": "^2.0.0",
"spec": ">=2.0.0 <3.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/has-ansi"
]
],
"_from": "ansi-regex@>=2.0.0 <3.0.0",
"_id": "ansi-regex@2.1.1",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/ansi-regex",
"_nodeVersion": "0.10.32",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/ansi-regex-2.1.1.tgz_1484363378013_0.4482989883981645"
},
"_npmUser": {
"name": "qix",
"email": "i.am.qix@gmail.com"
},
"_npmVersion": "2.14.2",
"_phantomChildren": {},
"_requested": {
"raw": "ansi-regex@^2.0.0",
"scope": null,
"escapedName": "ansi-regex",
"name": "ansi-regex",
"rawSpec": "^2.0.0",
"spec": ">=2.0.0 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/has-ansi",
"/nyc/strip-ansi"
],
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df",
"_shrinkwrap": null,
"_spec": "ansi-regex@^2.0.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/has-ansi",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/ansi-regex/issues"
},
"dependencies": {},
"description": "Regular expression for matching ANSI escape codes",
"devDependencies": {
"ava": "0.17.0",
"xo": "0.16.0"
},
"directories": {},
"dist": {
"shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df",
"tarball": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "7c908e7b4eb6cd82bfe1295e33fdf6d166c7ed85",
"homepage": "https://github.com/chalk/ansi-regex#readme",
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
},
{
"name": "JD Ballard",
"email": "i.am.qix@gmail.com",
"url": "github.com/qix-"
}
],
"name": "ansi-regex",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-regex.git"
},
"scripts": {
"test": "xo && ava --verbose",
"view-supported": "node fixtures/view-codes.js"
},
"version": "2.1.1",
"xo": {
"rules": {
"guard-for-in": 0,
"no-loop-func": 0
}
}
}

View File

@ -0,0 +1,39 @@
# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install --save ansi-regex
```
## Usage
```js
const ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
## FAQ
### Why do you test for codes not in the ECMA 48 standard?
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,65 @@
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View File

@ -0,0 +1,120 @@
{
"_args": [
[
{
"raw": "ansi-styles@^2.2.1",
"scope": null,
"escapedName": "ansi-styles",
"name": "ansi-styles",
"rawSpec": "^2.2.1",
"spec": ">=2.2.1 <3.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/chalk"
]
],
"_from": "ansi-styles@>=2.2.1 <3.0.0",
"_id": "ansi-styles@2.2.1",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/ansi-styles",
"_nodeVersion": "4.3.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/ansi-styles-2.2.1.tgz_1459197317833_0.9694824463222176"
},
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "3.8.3",
"_phantomChildren": {},
"_requested": {
"raw": "ansi-styles@^2.2.1",
"scope": null,
"escapedName": "ansi-styles",
"name": "ansi-styles",
"rawSpec": "^2.2.1",
"spec": ">=2.2.1 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/chalk"
],
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"_shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
"_shrinkwrap": null,
"_spec": "ansi-styles@^2.2.1",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/chalk",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/ansi-styles/issues"
},
"dependencies": {},
"description": "ANSI escape codes for styling strings in the terminal",
"devDependencies": {
"mocha": "*"
},
"directories": {},
"dist": {
"shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
"tarball": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "95c59b23be760108b6530ca1c89477c21b258032",
"homepage": "https://github.com/chalk/ansi-styles#readme",
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
}
],
"name": "ansi-styles",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-styles.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.2.1"
}

View File

@ -0,0 +1,86 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
![](screenshot.png)
## Install
```
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## Advanced usage
By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `ansi.modifiers`
- `ansi.colors`
- `ansi.bgColors`
###### Example
```js
console.log(ansi.colors.green.open);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,88 @@
'use strict';
var js = require('default-require-extensions/js');
module.exports = appendTransform;
var count = 0;
function appendTransform(transform, ext, extensions) {
// Generate a unique key for this transform
var key = __dirname + count; // eslint-disable-line
count++;
ext = ext || '.js';
extensions = extensions || require.extensions;
var forwardGet;
var forwardSet;
var descriptor = Object.getOwnPropertyDescriptor(extensions, ext) || {value: js, configurable: true};
if (
((descriptor.get || descriptor.set) && !(descriptor.get && descriptor.set)) ||
!descriptor.configurable
) {
throw new Error('Somebody did bad things to require.extensions["' + ext + '"]');
}
if (descriptor.get) {
// wrap a previous append-transform install and pass through to the getter/setter pair it created
forwardGet = function () {
return descriptor.get();
};
forwardSet = function (val) {
descriptor.set(val);
return forwardGet();
};
} else {
forwardGet = function () {
return descriptor.value;
};
forwardSet = function (val) {
descriptor.value = val;
return val;
};
}
function wrapCustomHook(hook) {
return function (module, filename) {
// We wrap every added extension, but we only apply the transform to the one on top of the stack
if (!module[key]) {
module[key] = true;
var originalCompile = module._compile;
module._compile = function replacementCompile(code, filename) {
module._compile = originalCompile;
code = transform(code, filename);
module._compile(code, filename);
};
}
hook(module, filename);
};
}
// wrap the original
forwardSet(wrapCustomHook(forwardGet()));
var hooks = [forwardGet()];
function setCurrentHook(hook) {
var restoreIndex = hooks.indexOf(hook);
if (restoreIndex === -1) {
hooks.push(forwardSet(wrapCustomHook(hook)));
} else {
// we have already scene this hook, and it is being reverted (proxyquire, etc) - don't wrap again.
hooks.splice(restoreIndex + 1, hooks.length);
forwardSet(hook);
}
}
Object.defineProperty(extensions, ext, {
configurable: true,
enumerable: true,
get: forwardGet,
set: setCurrentHook
});
}

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
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.

View File

@ -0,0 +1,109 @@
{
"_args": [
[
{
"raw": "append-transform@^0.4.0",
"scope": null,
"escapedName": "append-transform",
"name": "append-transform",
"rawSpec": "^0.4.0",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/istanbul-lib-hook"
]
],
"_from": "append-transform@>=0.4.0 <0.5.0",
"_id": "append-transform@0.4.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/append-transform",
"_nodeVersion": "0.10.40",
"_npmUser": {
"name": "jamestalmage",
"email": "james@talmage.io"
},
"_npmVersion": "3.4.0",
"_phantomChildren": {},
"_requested": {
"raw": "append-transform@^0.4.0",
"scope": null,
"escapedName": "append-transform",
"name": "append-transform",
"rawSpec": "^0.4.0",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/nyc/istanbul-lib-hook"
],
"_resolved": "https://registry.npmjs.org/append-transform/-/append-transform-0.4.0.tgz",
"_shasum": "d76ebf8ca94d276e247a36bad44a4b74ab611991",
"_shrinkwrap": null,
"_spec": "append-transform@^0.4.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/istanbul-lib-hook",
"author": {
"name": "James Talmage",
"email": "james@talmage.io",
"url": "github.com/jamestalmage"
},
"bugs": {
"url": "https://github.com/jamestalmage/append-transform/issues"
},
"dependencies": {
"default-require-extensions": "^1.0.0"
},
"description": "Install a transform to `require.extensions` that always runs last, even if additional extensions are added later.",
"devDependencies": {
"ava": "^0.7.0",
"coveralls": "^2.11.6",
"fake-module-system": "^0.3.0",
"nyc": "^4.0.1",
"xo": "^0.11.2"
},
"directories": {},
"dist": {
"shasum": "d76ebf8ca94d276e247a36bad44a4b74ab611991",
"tarball": "https://registry.npmjs.org/append-transform/-/append-transform-0.4.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "0b737d26fdebbdfb8ed4be096535099ed7da9ab1",
"homepage": "https://github.com/jamestalmage/append-transform#readme",
"keywords": [
"transform",
"require",
"append",
"last",
"coverage",
"source-map",
"extension",
"module"
],
"license": "MIT",
"maintainers": [
{
"name": "jamestalmage",
"email": "james@talmage.io"
}
],
"name": "append-transform",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/jamestalmage/append-transform.git"
},
"scripts": {
"test": "xo && nyc --reporter=lcov --reporter=text ava"
},
"version": "0.4.0",
"xo": {
"ignores": [
"test.js"
]
}
}

View File

@ -0,0 +1,72 @@
# append-transform [![Build Status](https://travis-ci.org/jamestalmage/append-transform.svg?branch=master)](https://travis-ci.org/jamestalmage/append-transform) [![Coverage Status](https://coveralls.io/repos/jamestalmage/append-transform/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamestalmage/append-transform?branch=master)
> Install a transform to `require.extensions` that always runs last, even if additional extensions are added later.
The [typical require extension](https://gist.github.com/jamestalmage/df922691475cff66c7e6) looks something like this:
```js
var myTransform = require('my-transform');
var oldExtension = require.extensions['.js'];
require.extensions['.js'] = function (module, filename) {
var oldCompile = module._compile;
module._compile = function (code, filename) {
code = myTransform(code);
module._compile = oldCompile;
module._compile(code, filename);
};
oldExtension(module, filename);
};
```
In **almost** all cases, that is sufficient and is the method that should be used (check out [`pirates`](https://www.npmjs.com/package/pirates) for an easy way to do it correctly). In **rare** cases you must ensure your transform remains the last one, even if other transforms are added later. For example, `nyc` uses this module to ensure its transform is applied last so it can capture the final source-map information, and ensure any language extensions it can't understand are already transpiled (ES2015 via `babel` for instance).
*WARNING:* You should be sure you *actually* need this, as it takes control away from the user. Your transform remains the last one applied, even as users continue to add more transforms. This is potentially confusing. Coverage libraries like `nyc` (and `istanbul` on which it relies) have valid reasons for doing this, but you should prefer conventional transform installation via [`pirates`](https://www.npmjs.com/package/pirates).
References:
- [Detailed Breakdown of How Require Extensions Work](https://gist.github.com/jamestalmage/df922691475cff66c7e6)
- The [test suite](https://github.com/jamestalmage/append-transform/blob/master/test/execution-order.js) provides a good overview of how this library manipulates the order in which transforms are applied.
## Install
```
$ npm install --save append-transform
```
## Usage
```js
var appendTransform = require('append-transform');
var myTransform = require('my-transform');
appendTransform(function (code, filename) {
if (myTransform.shouldTransform(filename)) {
code = myTransform.transform(code);
}
return code;
});
```
## API
### appendTransform(transformFn, [extension])
#### transformFn
Type: `function(code: string, filename: string)`
*Required*
A callback that modifies the incoming `code` argument in some way, and returns the transformed result. `filename` is provided to filter which files the transform applies to. If a transform should not manipulate a particular file, just return `code` without modifying it. It is fairly common to avoid transforming files in `node_modules`. In that case you may want to use [`node-modules-regexp`](https://www.npmjs.com/package/node-modules-regexp) to help reliably detect `node_modules` paths and avoid transforming them.
#### extension
Type: `string`
Default: `".js"`
The extension for the types of files this transform is capable of handling.
## License
MIT © [James Talmage](http://github.com/jamestalmage)

View File

@ -0,0 +1,18 @@
This 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.

View File

@ -0,0 +1,24 @@
var archy = require('../');
var s = archy({
label : 'beep',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny' ]
},
'human'
]
},
'party\ntime!'
]
}
]
});
console.log(s);

View File

@ -0,0 +1,25 @@
var archy = require('../');
var s = archy({
label : 'beep\none\ntwo',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O\nwheee',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny\nmeat' ]
},
'creature'
]
},
'party\ntime!'
]
}
]
});
console.log(s);

View File

@ -0,0 +1,35 @@
module.exports = function archy (obj, prefix, opts) {
if (prefix === undefined) prefix = '';
if (!opts) opts = {};
var chr = function (s) {
var chars = {
'│' : '|',
'└' : '`',
'├' : '+',
'─' : '-',
'┬' : '-'
};
return opts.unicode === false ? chars[s] : s;
};
if (typeof obj === 'string') obj = { label : obj };
var nodes = obj.nodes || [];
var lines = (obj.label || '').split('\n');
var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' ';
return prefix
+ lines.join(splitter) + '\n'
+ nodes.map(function (node, ix) {
var last = ix === nodes.length - 1;
var more = node.nodes && node.nodes.length;
var prefix_ = prefix + (last ? ' ' : chr('│')) + ' ';
return prefix
+ (last ? chr('└') : chr('├')) + chr('─')
+ (more ? chr('┬') : chr('─')) + ' '
+ archy(node, prefix_, opts).slice(prefix.length + 2)
;
}).join('')
;
};

View File

@ -0,0 +1,114 @@
{
"_args": [
[
{
"raw": "archy@^1.0.0",
"scope": null,
"escapedName": "archy",
"name": "archy",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc"
]
],
"_from": "archy@>=1.0.0 <2.0.0",
"_id": "archy@1.0.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/archy",
"_npmUser": {
"name": "substack",
"email": "mail@substack.net"
},
"_npmVersion": "1.4.25",
"_phantomChildren": {},
"_requested": {
"raw": "archy@^1.0.0",
"scope": null,
"escapedName": "archy",
"name": "archy",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc"
],
"_resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz",
"_shasum": "f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40",
"_shrinkwrap": null,
"_spec": "archy@^1.0.0",
"_where": "/Users/benjamincoe/bcoe/nyc",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/node-archy/issues"
},
"dependencies": {},
"description": "render nested hierarchies `npm ls` style with unicode pipes",
"devDependencies": {
"tap": "~0.3.3",
"tape": "~0.1.1"
},
"directories": {},
"dist": {
"shasum": "f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40",
"tarball": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz"
},
"gitHead": "30223c16191e877bf027b15b12daf077b9b55b84",
"homepage": "https://github.com/substack/node-archy#readme",
"keywords": [
"hierarchy",
"npm ls",
"unicode",
"pretty",
"print"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"name": "archy",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/substack/node-archy.git"
},
"scripts": {
"test": "tap test"
},
"testling": {
"files": "test/*.js",
"browsers": {
"iexplore": [
"6.0",
"7.0",
"8.0",
"9.0"
],
"chrome": [
"20.0"
],
"firefox": [
"10.0",
"15.0"
],
"safari": [
"5.1"
],
"opera": [
"12.0"
]
}
},
"version": "1.0.0"
}

View File

@ -0,0 +1,88 @@
# archy
Render nested hierarchies `npm ls` style with unicode pipes.
[![browser support](http://ci.testling.com/substack/node-archy.png)](http://ci.testling.com/substack/node-archy)
[![build status](https://secure.travis-ci.org/substack/node-archy.png)](http://travis-ci.org/substack/node-archy)
# example
``` js
var archy = require('archy');
var s = archy({
label : 'beep',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny' ]
},
'human'
]
},
'party\ntime!'
]
}
]
});
console.log(s);
```
output
```
beep
├── ity
└─┬ boop
├─┬ o_O
│ ├─┬ oh
│ │ ├── hello
│ │ └── puny
│ └── human
└── party
time!
```
# methods
var archy = require('archy')
## archy(obj, prefix='', opts={})
Return a string representation of `obj` with unicode pipe characters like how
`npm ls` looks.
`obj` should be a tree of nested objects with `'label'` and `'nodes'` fields.
`'label'` is a string of text to display at a node level and `'nodes'` is an
array of the descendents of the current node.
If a node is a string, that string will be used as the `'label'` and an empty
array of `'nodes'` will be used.
`prefix` gets prepended to all the lines and is used by the algorithm to
recursively update.
If `'label'` has newlines they will be indented at the present indentation level
with the current prefix.
To disable unicode results in favor of all-ansi output set `opts.unicode` to
`false`.
# install
With [npm](http://npmjs.org) do:
```
npm install archy
```
# license
MIT

View File

@ -0,0 +1,40 @@
var test = require('tape');
var archy = require('../');
test('beep', function (t) {
var s = archy({
label : 'beep',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny' ]
},
'human'
]
},
'party!'
]
}
]
});
t.equal(s, [
'beep',
'├── ity',
'└─┬ boop',
' ├─┬ o_O',
' │ ├─┬ oh',
' │ │ ├── hello',
' │ │ └── puny',
' │ └── human',
' └── party!',
''
].join('\n'));
t.end();
});

View File

@ -0,0 +1,45 @@
var test = require('tape');
var archy = require('../');
test('multi-line', function (t) {
var s = archy({
label : 'beep\none\ntwo',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O\nwheee',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny\nmeat' ]
},
'creature'
]
},
'party\ntime!'
]
}
]
});
t.equal(s, [
'beep',
'│ one',
'│ two',
'├── ity',
'└─┬ boop',
' ├─┬ o_O',
' │ │ wheee',
' │ ├─┬ oh',
' │ │ ├── hello',
' │ │ └── puny',
' │ │ meat',
' │ └── creature',
' └── party',
' time!',
''
].join('\n'));
t.end();
});

View File

@ -0,0 +1,40 @@
var test = require('tape');
var archy = require('../');
test('beep', function (t) {
var s = archy({
label : 'beep',
nodes : [
'ity',
{
label : 'boop',
nodes : [
{
label : 'o_O',
nodes : [
{
label : 'oh',
nodes : [ 'hello', 'puny' ]
},
'human'
]
},
'party!'
]
}
]
}, '', { unicode : false });
t.equal(s, [
'beep',
'+-- ity',
'`-- boop',
' +-- o_O',
' | +-- oh',
' | | +-- hello',
' | | `-- puny',
' | `-- human',
' `-- party!',
''
].join('\n'));
t.end();
});

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2015, Jon Schlinkert.
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.

View File

@ -0,0 +1,74 @@
# arr-diff [![NPM version](https://img.shields.io/npm/v/arr-diff.svg)](https://www.npmjs.com/package/arr-diff) [![Build Status](https://img.shields.io/travis/jonschlinkert/base.svg)](https://travis-ci.org/jonschlinkert/base)
> Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i arr-diff --save
```
Install with [bower](http://bower.io/)
```sh
$ bower install arr-diff --save
```
## API
### [diff](index.js#L33)
Return the difference between the first array and additional arrays.
**Params**
* `a` **{Array}**
* `b` **{Array}**
* `returns` **{Array}**
**Example**
```js
var diff = require('arr-diff');
var a = ['a', 'b', 'c', 'd'];
var b = ['b', 'c'];
console.log(diff(a, b))
//=> ['a', 'd']
```
## Related projects
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten)
* [array-filter](https://www.npmjs.com/package/array-filter): Array#filter for older browsers. | [homepage](https://github.com/juliangruber/array-filter)
* [array-intersection](https://www.npmjs.com/package/array-intersection): Return an array with the unique values present in _all_ given arrays using strict equality… [more](https://www.npmjs.com/package/array-intersection) | [homepage](https://github.com/jonschlinkert/array-intersection)
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-diff/issues/new).
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.
***
_This file was generated by [verb](https://github.com/verbose/verb) on Sat Dec 05 2015 23:24:53 GMT-0500 (EST)._

View File

@ -0,0 +1,58 @@
/*!
* arr-diff <https://github.com/jonschlinkert/arr-diff>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
var flatten = require('arr-flatten');
var slice = [].slice;
/**
* Return the difference between the first array and
* additional arrays.
*
* ```js
* var diff = require('{%= name %}');
*
* var a = ['a', 'b', 'c', 'd'];
* var b = ['b', 'c'];
*
* console.log(diff(a, b))
* //=> ['a', 'd']
* ```
*
* @param {Array} `a`
* @param {Array} `b`
* @return {Array}
* @api public
*/
function diff(arr, arrays) {
var argsLen = arguments.length;
var len = arr.length, i = -1;
var res = [], arrays;
if (argsLen === 1) {
return arr;
}
if (argsLen > 2) {
arrays = flatten(slice.call(arguments, 1));
}
while (++i < len) {
if (!~arrays.indexOf(arr[i])) {
res.push(arr[i]);
}
}
return res;
}
/**
* Expose `diff`
*/
module.exports = diff;

View File

@ -0,0 +1,119 @@
{
"_args": [
[
{
"raw": "arr-diff@^2.0.0",
"scope": null,
"escapedName": "arr-diff",
"name": "arr-diff",
"rawSpec": "^2.0.0",
"spec": ">=2.0.0 <3.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/micromatch"
]
],
"_from": "arr-diff@>=2.0.0 <3.0.0",
"_id": "arr-diff@2.0.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/arr-diff",
"_nodeVersion": "5.0.0",
"_npmUser": {
"name": "jonschlinkert",
"email": "github@sellside.com"
},
"_npmVersion": "3.3.6",
"_phantomChildren": {},
"_requested": {
"raw": "arr-diff@^2.0.0",
"scope": null,
"escapedName": "arr-diff",
"name": "arr-diff",
"rawSpec": "^2.0.0",
"spec": ">=2.0.0 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/micromatch"
],
"_resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
"_shasum": "8f3b827f955a8bd669697e4a4256ac3ceae356cf",
"_shrinkwrap": null,
"_spec": "arr-diff@^2.0.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/micromatch",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-diff/issues"
},
"dependencies": {
"arr-flatten": "^1.0.1"
},
"description": "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.",
"devDependencies": {
"array-differ": "^1.0.0",
"array-slice": "^0.2.3",
"benchmarked": "^0.1.4",
"chalk": "^1.1.1",
"mocha": "*",
"should": "*"
},
"directories": {},
"dist": {
"shasum": "8f3b827f955a8bd669697e4a4256ac3ceae356cf",
"tarball": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "b89f54eb88ca51afd0e0ea6be9a4a63e5ccecf27",
"homepage": "https://github.com/jonschlinkert/arr-diff",
"keywords": [
"arr",
"array",
"diff",
"differ",
"difference"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "doowb",
"email": "brian.woodward@gmail.com"
},
{
"name": "jonschlinkert",
"email": "github@sellside.com"
},
{
"name": "paulmillr",
"email": "paul@paulmillr.com"
}
],
"name": "arr-diff",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/arr-diff.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"related": {
"list": [
"arr-flatten",
"array-filter",
"array-intersection"
]
}
},
"version": "2.0.0"
}

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2017, Jon Schlinkert.
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.

View File

@ -0,0 +1,86 @@
# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![NPM total downloads](https://img.shields.io/npm/dt/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten)
> Recursively flatten an array or arrays.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save arr-flatten
```
## Install
Install with [bower](https://bower.io/)
```sh
$ bower install arr-flatten --save
```
## Usage
```js
var flatten = require('arr-flatten');
flatten(['a', ['b', ['c']], 'd', ['e']]);
//=> ['a', 'b', 'c', 'd', 'e']
```
## Why another flatten utility?
I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%.
## About
### Related projects
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.")
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.")
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 20 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [lukeed](https://github.com/lukeed) |
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._

View File

@ -0,0 +1,22 @@
/*!
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
module.exports = function (arr) {
return flat(arr, []);
};
function flat(arr, res) {
var i = 0, cur;
var len = arr.length;
for (; i < len; i++) {
cur = arr[i];
Array.isArray(cur) ? flat(cur, res) : res.push(cur);
}
return res;
}

View File

@ -0,0 +1,150 @@
{
"_args": [
[
{
"raw": "arr-flatten@^1.0.1",
"scope": null,
"escapedName": "arr-flatten",
"name": "arr-flatten",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/arr-diff"
]
],
"_from": "arr-flatten@>=1.0.1 <2.0.0",
"_id": "arr-flatten@1.1.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/arr-flatten",
"_nodeVersion": "7.7.3",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/arr-flatten-1.1.0.tgz_1499280630530_0.4138362631201744"
},
"_npmUser": {
"name": "jonschlinkert",
"email": "github@sellside.com"
},
"_npmVersion": "5.0.4",
"_phantomChildren": {},
"_requested": {
"raw": "arr-flatten@^1.0.1",
"scope": null,
"escapedName": "arr-flatten",
"name": "arr-flatten",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/arr-diff"
],
"_resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
"_shasum": "36048bbff4e7b47e136644316c99669ea5ae91f1",
"_shrinkwrap": null,
"_spec": "arr-flatten@^1.0.1",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/arr-diff",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-flatten/issues"
},
"contributors": [
{
"name": "Jon Schlinkert",
"url": "http://twitter.com/jonschlinkert"
},
{
"name": "Luke Edwards",
"url": "https://lukeed.com"
}
],
"dependencies": {},
"description": "Recursively flatten an array or arrays.",
"devDependencies": {
"ansi-bold": "^0.1.1",
"array-flatten": "^2.1.1",
"array-slice": "^1.0.0",
"benchmarked": "^1.0.0",
"compute-flatten": "^1.0.0",
"flatit": "^1.1.1",
"flatten": "^1.0.2",
"flatten-array": "^1.0.0",
"glob": "^7.1.1",
"gulp-format-md": "^0.1.12",
"just-flatten-it": "^1.1.23",
"lodash.flattendeep": "^4.4.0",
"m_flattened": "^1.0.1",
"mocha": "^3.2.0",
"utils-flatten": "^1.0.0",
"write": "^0.3.3"
},
"directories": {},
"dist": {
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
"shasum": "36048bbff4e7b47e136644316c99669ea5ae91f1",
"tarball": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "76a1ae28b03fdb1cbe5d49fa521bc4807b9f94d3",
"homepage": "https://github.com/jonschlinkert/arr-flatten",
"keywords": [
"arr",
"array",
"elements",
"flat",
"flatten",
"nested",
"recurse",
"recursive",
"recursively"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "jonschlinkert",
"email": "github@sellside.com"
}
],
"name": "arr-flatten",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/arr-flatten.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"arr-filter",
"arr-union",
"array-each",
"array-unique"
]
},
"lint": {
"reflinks": true
}
},
"version": "1.1.0"
}

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2015, Jon Schlinkert.
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.

View File

@ -0,0 +1,51 @@
# array-unique [![NPM version](https://badge.fury.io/js/array-unique.svg)](http://badge.fury.io/js/array-unique) [![Build Status](https://travis-ci.org/jonschlinkert/array-unique.svg)](https://travis-ci.org/jonschlinkert/array-unique)
> Return an array free of duplicate values. Fastest ES5 implementation.
## Install with [npm](npmjs.org)
```bash
npm i array-unique --save
```
## Usage
```js
var unique = require('array-unique');
unique(['a', 'b', 'c', 'c']);
//=> ['a', 'b', 'c']
```
## Related
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
* [arr-union](https://github.com/jonschlinkert/arr-union): Returns an array of unique values using strict equality for comparisons.
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
* [arr-reduce](https://github.com/jonschlinkert/arr-reduce): Fast array reduce that also loops over sparse elements.
* [arr-map](https://github.com/jonschlinkert/arr-map): Faster, node.js focused alternative to JavaScript's native array map.
* [arr-pluck](https://github.com/jonschlinkert/arr-pluck): Retrieves the value of a specified property from all elements in the collection.
## Run tests
Install dev dependencies.
```bash
npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/array-unique/issues)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 24, 2015._

View File

@ -0,0 +1,28 @@
/*!
* array-unique <https://github.com/jonschlinkert/array-unique>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
module.exports = function unique(arr) {
if (!Array.isArray(arr)) {
throw new TypeError('array-unique expects an array.');
}
var len = arr.length;
var i = -1;
while (i++ < len) {
var j = i + 1;
for (; j < arr.length; ++j) {
if (arr[i] === arr[j]) {
arr.splice(j--, 1);
}
}
}
return arr;
};

View File

@ -0,0 +1,94 @@
{
"_args": [
[
{
"raw": "array-unique@^0.2.1",
"scope": null,
"escapedName": "array-unique",
"name": "array-unique",
"rawSpec": "^0.2.1",
"spec": ">=0.2.1 <0.3.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/micromatch"
]
],
"_from": "array-unique@>=0.2.1 <0.3.0",
"_id": "array-unique@0.2.1",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/array-unique",
"_nodeVersion": "1.6.2",
"_npmUser": {
"name": "jonschlinkert",
"email": "github@sellside.com"
},
"_npmVersion": "2.7.1",
"_phantomChildren": {},
"_requested": {
"raw": "array-unique@^0.2.1",
"scope": null,
"escapedName": "array-unique",
"name": "array-unique",
"rawSpec": "^0.2.1",
"spec": ">=0.2.1 <0.3.0",
"type": "range"
},
"_requiredBy": [
"/nyc/micromatch"
],
"_resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
"_shasum": "a1d97ccafcbc2625cc70fadceb36a50c58b01a53",
"_shrinkwrap": null,
"_spec": "array-unique@^0.2.1",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/micromatch",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/array-unique/issues"
},
"dependencies": {},
"description": "Return an array free of duplicate values. Fastest ES5 implementation.",
"devDependencies": {
"array-uniq": "^1.0.2",
"benchmarked": "^0.1.3",
"mocha": "*",
"should": "*"
},
"directories": {},
"dist": {
"shasum": "a1d97ccafcbc2625cc70fadceb36a50c58b01a53",
"tarball": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "36fde8e586fb7cf880b8b3aa6515df889e64ed85",
"homepage": "https://github.com/jonschlinkert/array-unique",
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/array-unique/blob/master/LICENSE"
},
"main": "index.js",
"maintainers": [
{
"name": "jonschlinkert",
"email": "github@sellside.com"
}
],
"name": "array-unique",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/array-unique.git"
},
"scripts": {
"test": "mocha"
},
"version": "0.2.1"
}

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = function (val) {
if (val === null || val === undefined) {
return [];
}
return Array.isArray(val) ? val : [val];
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.

View File

@ -0,0 +1,98 @@
{
"_args": [
[
{
"raw": "arrify@^1.0.1",
"scope": null,
"escapedName": "arrify",
"name": "arrify",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc"
]
],
"_from": "arrify@>=1.0.1 <2.0.0",
"_id": "arrify@1.0.1",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/arrify",
"_nodeVersion": "4.2.1",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "3.5.2",
"_phantomChildren": {},
"_requested": {
"raw": "arrify@^1.0.1",
"scope": null,
"escapedName": "arrify",
"name": "arrify",
"rawSpec": "^1.0.1",
"spec": ">=1.0.1 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc",
"/nyc/test-exclude"
],
"_resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
"_shasum": "898508da2226f380df904728456849c1501a4b0d",
"_shrinkwrap": null,
"_spec": "arrify@^1.0.1",
"_where": "/Users/benjamincoe/bcoe/nyc",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/arrify/issues"
},
"dependencies": {},
"description": "Convert a value to an array",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "898508da2226f380df904728456849c1501a4b0d",
"tarball": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "087edee1a58d5adaac6cae5a107886121ef43783",
"homepage": "https://github.com/sindresorhus/arrify#readme",
"keywords": [
"array",
"arr",
"arrify",
"arrayify",
"convert",
"value"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "arrify",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/arrify.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "1.0.1"
}

View File

@ -0,0 +1,36 @@
# arrify [![Build Status](https://travis-ci.org/sindresorhus/arrify.svg?branch=master)](https://travis-ci.org/sindresorhus/arrify)
> Convert a value to an array
## Install
```
$ npm install --save arrify
```
## Usage
```js
const arrify = require('arrify');
arrify('unicorn');
//=> ['unicorn']
arrify(['unicorn']);
//=> ['unicorn']
arrify(null);
//=> []
arrify(undefined);
//=> []
```
*Supplying `null` or `undefined` results in an empty array.*
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,125 @@
# v1.5.2
- Allow using `"consructor"` as an argument in `memoize` (#998)
- Give a better error messsage when `auto` dependency checking fails (#994)
- Various doc updates (#936, #956, #979, #1002)
# v1.5.1
- Fix issue with `pause` in `queue` with concurrency enabled (#946)
- `while` and `until` now pass the final result to callback (#963)
- `auto` will properly handle concurrency when there is no callback (#966)
- `auto` will now properly stop execution when an error occurs (#988, #993)
- Various doc fixes (#971, #980)
# v1.5.0
- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) (#892)
- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. (#873)
- `auto` now accepts an optional `concurrency` argument to limit the number of running tasks (#637)
- Added `queue#workersList()`, to retrieve the list of currently running tasks. (#891)
- Various code simplifications (#896, #904)
- Various doc fixes :scroll: (#890, #894, #903, #905, #912)
# v1.4.2
- Ensure coverage files don't get published on npm (#879)
# v1.4.1
- Add in overlooked `detectLimit` method (#866)
- Removed unnecessary files from npm releases (#861)
- Removed usage of a reserved word to prevent :boom: in older environments (#870)
# v1.4.0
- `asyncify` now supports promises (#840)
- Added `Limit` versions of `filter` and `reject` (#836)
- Add `Limit` versions of `detect`, `some` and `every` (#828, #829)
- `some`, `every` and `detect` now short circuit early (#828, #829)
- Improve detection of the global object (#804), enabling use in WebWorkers
- `whilst` now called with arguments from iterator (#823)
- `during` now gets called with arguments from iterator (#824)
- Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0))
# v1.3.0
New Features:
- Added `constant`
- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. (#671, #806)
- Added `during` and `doDuring`, which are like `whilst` with an async truth test. (#800)
- `retry` now accepts an `interval` parameter to specify a delay between retries. (#793)
- `async` should work better in Web Workers due to better `root` detection (#804)
- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642)
- Various internal updates (#786, #801, #802, #803)
- Various doc fixes (#790, #794)
Bug Fixes:
- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. (#740, #744, #783)
# v1.2.1
Bug Fix:
- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782)
# v1.2.0
New Features:
- Added `timesLimit` (#743)
- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. (#747, #772)
Bug Fixes:
- Fixed a regression in `each` and family with empty arrays that have additional properties. (#775, #777)
# v1.1.1
Bug Fix:
- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782)
# v1.1.0
New Features:
- `cargo` now supports all of the same methods and event callbacks as `queue`.
- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. (#769)
- Optimized `map`, `eachOf`, and `waterfall` families of functions
- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array (#667).
- The callback is now optional for the composed results of `compose` and `seq`. (#618)
- Reduced file size by 4kb, (minified version by 1kb)
- Added code coverage through `nyc` and `coveralls` (#768)
Bug Fixes:
- `forever` will no longer stack overflow with a synchronous iterator (#622)
- `eachLimit` and other limit functions will stop iterating once an error occurs (#754)
- Always pass `null` in callbacks when there is no error (#439)
- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668)
- `each` and family will properly handle an empty array (#578)
- `eachSeries` and family will finish if the underlying array is modified during execution (#557)
- `queue` will throw if a non-function is passed to `q.push()` (#593)
- Doc fixes (#629, #766)
# v1.0.0
No known breaking changes, we are simply complying with semver from here on out.
Changes:
- Start using a changelog!
- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321)
- Detect deadlocks in `auto` (#663)
- Better support for require.js (#527)
- Throw if queue created with concurrency `0` (#714)
- Fix unneeded iteration in `queue.resume()` (#758)
- Guard against timer mocking overriding `setImmediate` (#609 #611)
- Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729)
- Use single noop function internally (#546)
- Optimize internal `_each`, `_map` and `_keys` functions.

View File

@ -0,0 +1,19 @@
Copyright (c) 2010-2014 Caolan McMahon
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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,157 @@
{
"_args": [
[
{
"raw": "async@^1.4.0",
"scope": null,
"escapedName": "async",
"name": "async",
"rawSpec": "^1.4.0",
"spec": ">=1.4.0 <2.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/handlebars"
]
],
"_from": "async@>=1.4.0 <2.0.0",
"_id": "async@1.5.2",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/async",
"_nodeVersion": "4.2.3",
"_npmUser": {
"name": "aearly",
"email": "alexander.early@gmail.com"
},
"_npmVersion": "3.5.2",
"_phantomChildren": {},
"_requested": {
"raw": "async@^1.4.0",
"scope": null,
"escapedName": "async",
"name": "async",
"rawSpec": "^1.4.0",
"spec": ">=1.4.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/handlebars"
],
"_resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"_shasum": "ec6a61ae56480c0c3cb241c95618e20892f9672a",
"_shrinkwrap": null,
"_spec": "async@^1.4.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/handlebars",
"author": {
"name": "Caolan McMahon"
},
"bugs": {
"url": "https://github.com/caolan/async/issues"
},
"dependencies": {},
"description": "Higher-order functions and common patterns for asynchronous code",
"devDependencies": {
"benchmark": "github:bestiejs/benchmark.js",
"bluebird": "^2.9.32",
"chai": "^3.1.0",
"coveralls": "^2.11.2",
"es6-promise": "^2.3.0",
"jscs": "^1.13.1",
"jshint": "~2.8.0",
"karma": "^0.13.2",
"karma-browserify": "^4.2.1",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.0.2",
"lodash": "^3.9.0",
"mkdirp": "~0.5.1",
"mocha": "^2.2.5",
"native-promise-only": "^0.8.0-a",
"nodeunit": ">0.0.0",
"nyc": "^2.1.0",
"rsvp": "^3.0.18",
"semver": "^4.3.6",
"uglify-js": "~2.4.0",
"xyz": "^0.5.0",
"yargs": "~3.9.1"
},
"directories": {},
"dist": {
"shasum": "ec6a61ae56480c0c3cb241c95618e20892f9672a",
"tarball": "https://registry.npmjs.org/async/-/async-1.5.2.tgz"
},
"files": [
"lib",
"dist/async.js",
"dist/async.min.js"
],
"gitHead": "9ab5c67b7cb3a4c3dad4a2d4552a2f6775545d6c",
"homepage": "https://github.com/caolan/async#readme",
"jam": {
"main": "lib/async.js",
"include": [
"lib/async.js",
"README.md",
"LICENSE"
],
"categories": [
"Utilities"
]
},
"keywords": [
"async",
"callback",
"utility",
"module"
],
"license": "MIT",
"main": "lib/async.js",
"maintainers": [
{
"name": "caolan",
"email": "caolan.mcmahon@gmail.com"
},
{
"name": "beaugunderson",
"email": "beau@beaugunderson.com"
},
{
"name": "aearly",
"email": "alexander.early@gmail.com"
},
{
"name": "megawac",
"email": "megawac@gmail.com"
}
],
"name": "async",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/caolan/async.git"
},
"scripts": {
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js",
"mocha-browser-test": "karma start",
"mocha-node-test": "mocha mocha_test/",
"mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
"nodeunit-test": "nodeunit test/test-async.js",
"test": "npm run-script lint && npm run nodeunit-test && npm run mocha-test"
},
"spm": {
"main": "lib/async.js"
},
"version": "1.5.2",
"volo": {
"main": "lib/async.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
}

View File

@ -0,0 +1,60 @@
# babel-code-frame
> Generate errors that contain a code frame that point to source locations.
## Install
```sh
npm install --save-dev babel-code-frame
```
## Usage
```js
import codeFrame from 'babel-code-frame';
const rawLines = `class Foo {
constructor()
}`;
const lineNumber = 2;
const colNumber = 16;
const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ });
console.log(result);
```
```sh
1 | class Foo {
> 2 | constructor()
| ^
3 | }
```
If the column number is not known, you may pass `null` instead.
## Options
### `highlightCode`
`boolean`, defaults to `false`.
Toggles syntax highlighting the code as JavaScript for terminals.
### `linesAbove`
`number`, defaults to `2`.
Adjust the number of lines to show above the error.
### `linesBelow`
`number`, defaults to `3`.
Adjust the number of lines to show below the error.
### `forceColor`
`boolean`, defaults to `false`.
Enable this to forcibly syntax highlight the code as JavaScript (for non-terminals); overrides `highlightCode`.

View File

@ -0,0 +1,141 @@
"use strict";
exports.__esModule = true;
exports.default = function (rawLines, lineNumber, colNumber) {
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
colNumber = Math.max(colNumber, 0);
var highlighted = opts.highlightCode && _chalk2.default.supportsColor || opts.forceColor;
var chalk = _chalk2.default;
if (opts.forceColor) {
chalk = new _chalk2.default.constructor({ enabled: true });
}
var maybeHighlight = function maybeHighlight(chalkFn, string) {
return highlighted ? chalkFn(string) : string;
};
var defs = getDefs(chalk);
if (highlighted) rawLines = highlight(defs, rawLines);
var linesAbove = opts.linesAbove || 2;
var linesBelow = opts.linesBelow || 3;
var lines = rawLines.split(NEWLINE);
var start = Math.max(lineNumber - (linesAbove + 1), 0);
var end = Math.min(lines.length, lineNumber + linesBelow);
if (!lineNumber && !colNumber) {
start = 0;
end = lines.length;
}
var numberMaxWidth = String(end).length;
var frame = lines.slice(start, end).map(function (line, index) {
var number = start + 1 + index;
var paddedNumber = (" " + number).slice(-numberMaxWidth);
var gutter = " " + paddedNumber + " | ";
if (number === lineNumber) {
var markerLine = "";
if (colNumber) {
var markerSpacing = line.slice(0, colNumber - 1).replace(/[^\t]/g, " ");
markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^")].join("");
}
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
} else {
return " " + maybeHighlight(defs.gutter, gutter) + line;
}
}).join("\n");
if (highlighted) {
return chalk.reset(frame);
} else {
return frame;
}
};
var _jsTokens = require("js-tokens");
var _jsTokens2 = _interopRequireDefault(_jsTokens);
var _esutils = require("esutils");
var _esutils2 = _interopRequireDefault(_esutils);
var _chalk = require("chalk");
var _chalk2 = _interopRequireDefault(_chalk);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getDefs(chalk) {
return {
keyword: chalk.cyan,
capitalized: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold,
gutter: chalk.grey,
marker: chalk.red.bold
};
}
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
var JSX_TAG = /^[a-z][\w-]*$/i;
var BRACKET = /^[()\[\]{}]$/;
function getTokenType(match) {
var _match$slice = match.slice(-2),
offset = _match$slice[0],
text = _match$slice[1];
var token = (0, _jsTokens.matchToToken)(match);
if (token.type === "name") {
if (_esutils2.default.keyword.isReservedWordES6(token.value)) {
return "keyword";
}
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
return "jsx_tag";
}
if (token.value[0] !== token.value[0].toLowerCase()) {
return "capitalized";
}
}
if (token.type === "punctuator" && BRACKET.test(token.value)) {
return "bracket";
}
return token.type;
}
function highlight(defs, text) {
return text.replace(_jsTokens2.default, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var type = getTokenType(args);
var colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(function (str) {
return colorize(str);
}).join("\n");
} else {
return args[0];
}
});
}
module.exports = exports["default"];

View File

@ -0,0 +1,66 @@
{
"name": "babel-code-frame",
"version": "6.22.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"esutils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
},
"has-ansi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
"requires": {
"ansi-regex": "2.1.1"
}
},
"js-tokens": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "2.1.1"
}
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
}
}
}

View File

@ -0,0 +1,98 @@
{
"_args": [
[
{
"raw": "babel-code-frame@^6.26.0",
"scope": null,
"escapedName": "babel-code-frame",
"name": "babel-code-frame",
"rawSpec": "^6.26.0",
"spec": ">=6.26.0 <7.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/babel-traverse"
]
],
"_from": "babel-code-frame@>=6.26.0 <7.0.0",
"_id": "babel-code-frame@6.26.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/babel-code-frame",
"_nodeVersion": "6.9.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/babel-code-frame-6.26.0.tgz_1502898849653_0.8458143274765462"
},
"_npmUser": {
"name": "hzoo",
"email": "hi@henryzoo.com"
},
"_npmVersion": "4.6.1",
"_phantomChildren": {},
"_requested": {
"raw": "babel-code-frame@^6.26.0",
"scope": null,
"escapedName": "babel-code-frame",
"name": "babel-code-frame",
"rawSpec": "^6.26.0",
"spec": ">=6.26.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/babel-traverse"
],
"_resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
"_shasum": "63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b",
"_shrinkwrap": null,
"_spec": "babel-code-frame@^6.26.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/babel-traverse",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"dependencies": {
"chalk": "^1.1.3",
"esutils": "^2.0.2",
"js-tokens": "^3.0.2"
},
"description": "Generate errors that contain a code frame that point to source locations.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b",
"tarball": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "thejameskyle",
"email": "me@thejameskyle.com"
},
{
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"name": "danez",
"email": "daniel@tschinder.de"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
}
],
"name": "babel-code-frame",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame"
},
"scripts": {},
"version": "6.26.0"
}

View File

@ -0,0 +1,81 @@
# babel-generator
> Turns an AST into code.
## Install
```sh
npm install --save-dev babel-generator
```
## Usage
```js
import {parse} from 'babylon';
import generate from 'babel-generator';
const code = 'class Example {}';
const ast = parse(code);
const output = generate(ast, { /* options */ }, code);
```
## Options
Options for formatting output:
name | type | default | description
-----------------------|----------|-----------------|--------------------------------------------------------------------------
auxiliaryCommentBefore | string | | Optional string to add as a block comment at the start of the output file
auxiliaryCommentAfter | string | | Optional string to add as a block comment at the end of the output file
shouldPrintComment | function | `opts.comments` | Function that takes a comment (as a string) and returns `true` if the comment should be included in the output. By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment contains `@preserve` or `@license`
retainLines | boolean | `false` | Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces)
retainFunctionParens | boolean | `false` | Retain parens around function expressions (could be used to change engine parsing behavior)
comments | boolean | `true` | Should comments be included in output
compact | boolean or `'auto'` | `opts.minified` | Set to `true` to avoid adding whitespace for formatting
minified | boolean | `false` | Should the output be minified
concise | boolean | `false` | Set to `true` to reduce whitespace (but not as much as `opts.compact`)
quotes | `'single'` or `'double'` | autodetect based on `ast.tokens` | The type of quote to use in the output
filename | string | | Used in warning messages
flowCommaSeparator | boolean | `false` | Set to `true` to use commas instead of semicolons as Flow property separators
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©";
Options for source maps:
name | type | default | description
-----------------------|----------|-----------------|--------------------------------------------------------------------------
sourceMaps | boolean | `false` | Enable generating source maps
sourceMapTarget | string | | The filename of the generated code that the source map will be associated with
sourceRoot | string | | A root for all relative URLs in the source map
sourceFileName | string | | The filename for the source code (i.e. the code in the `code` argument). This will only be used if `code` is a string.
## AST from Multiple Sources
In most cases, Babel does a 1:1 transformation of input-file to output-file. However,
you may be dealing with AST constructed from multiple sources - JS files, templates, etc.
If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need
to pass an object to `generate` as the `code` parameter. Keys
should be the source filenames, and values should be the source content.
Here's an example of what that might look like:
```js
import {parse} from 'babylon';
import generate from 'babel-generator';
const a = 'var a = 1;';
const b = 'var b = 2;';
const astA = parse(a, { sourceFilename: 'a.js' });
const astB = parse(b, { sourceFilename: 'b.js' });
const ast = {
type: 'Program',
body: [].concat(astA.program.body, astB.program.body)
};
const { code, map } = generate(ast, { sourceMaps: true }, {
'a.js': a,
'b.js': b
});
// Sourcemap will point to both a.js and b.js where appropriate.
```

View File

@ -0,0 +1,202 @@
"use strict";
exports.__esModule = true;
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _trimRight = require("trim-right");
var _trimRight2 = _interopRequireDefault(_trimRight);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SPACES_RE = /^[ \t]+$/;
var Buffer = function () {
function Buffer(map) {
(0, _classCallCheck3.default)(this, Buffer);
this._map = null;
this._buf = [];
this._last = "";
this._queue = [];
this._position = {
line: 1,
column: 0
};
this._sourcePosition = {
identifierName: null,
line: null,
column: null,
filename: null
};
this._map = map;
}
Buffer.prototype.get = function get() {
this._flush();
var map = this._map;
var result = {
code: (0, _trimRight2.default)(this._buf.join("")),
map: null,
rawMappings: map && map.getRawMappings()
};
if (map) {
Object.defineProperty(result, "map", {
configurable: true,
enumerable: true,
get: function get() {
return this.map = map.get();
},
set: function set(value) {
Object.defineProperty(this, "map", { value: value, writable: true });
}
});
}
return result;
};
Buffer.prototype.append = function append(str) {
this._flush();
var _sourcePosition = this._sourcePosition,
line = _sourcePosition.line,
column = _sourcePosition.column,
filename = _sourcePosition.filename,
identifierName = _sourcePosition.identifierName;
this._append(str, line, column, identifierName, filename);
};
Buffer.prototype.queue = function queue(str) {
if (str === "\n") while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {
this._queue.shift();
}var _sourcePosition2 = this._sourcePosition,
line = _sourcePosition2.line,
column = _sourcePosition2.column,
filename = _sourcePosition2.filename,
identifierName = _sourcePosition2.identifierName;
this._queue.unshift([str, line, column, identifierName, filename]);
};
Buffer.prototype._flush = function _flush() {
var item = void 0;
while (item = this._queue.pop()) {
this._append.apply(this, item);
}
};
Buffer.prototype._append = function _append(str, line, column, identifierName, filename) {
if (this._map && str[0] !== "\n") {
this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename);
}
this._buf.push(str);
this._last = str[str.length - 1];
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this._position.line++;
this._position.column = 0;
} else {
this._position.column++;
}
}
};
Buffer.prototype.removeTrailingNewline = function removeTrailingNewline() {
if (this._queue.length > 0 && this._queue[0][0] === "\n") this._queue.shift();
};
Buffer.prototype.removeLastSemicolon = function removeLastSemicolon() {
if (this._queue.length > 0 && this._queue[0][0] === ";") this._queue.shift();
};
Buffer.prototype.endsWith = function endsWith(suffix) {
if (suffix.length === 1) {
var last = void 0;
if (this._queue.length > 0) {
var str = this._queue[0][0];
last = str[str.length - 1];
} else {
last = this._last;
}
return last === suffix;
}
var end = this._last + this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");
if (suffix.length <= end.length) {
return end.slice(-suffix.length) === suffix;
}
return false;
};
Buffer.prototype.hasContent = function hasContent() {
return this._queue.length > 0 || !!this._last;
};
Buffer.prototype.source = function source(prop, loc) {
if (prop && !loc) return;
var pos = loc ? loc[prop] : null;
this._sourcePosition.identifierName = loc && loc.identifierName || null;
this._sourcePosition.line = pos ? pos.line : null;
this._sourcePosition.column = pos ? pos.column : null;
this._sourcePosition.filename = loc && loc.filename || null;
};
Buffer.prototype.withSource = function withSource(prop, loc, cb) {
if (!this._map) return cb();
var originalLine = this._sourcePosition.line;
var originalColumn = this._sourcePosition.column;
var originalFilename = this._sourcePosition.filename;
var originalIdentifierName = this._sourcePosition.identifierName;
this.source(prop, loc);
cb();
this._sourcePosition.line = originalLine;
this._sourcePosition.column = originalColumn;
this._sourcePosition.filename = originalFilename;
this._sourcePosition.identifierName = originalIdentifierName;
};
Buffer.prototype.getCurrentColumn = function getCurrentColumn() {
var extra = this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");
var lastIndex = extra.lastIndexOf("\n");
return lastIndex === -1 ? this._position.column + extra.length : extra.length - 1 - lastIndex;
};
Buffer.prototype.getCurrentLine = function getCurrentLine() {
var extra = this._queue.reduce(function (acc, item) {
return item[0] + acc;
}, "");
var count = 0;
for (var i = 0; i < extra.length; i++) {
if (extra[i] === "\n") count++;
}
return this._position.line + count;
};
return Buffer;
}();
exports.default = Buffer;
module.exports = exports["default"];

View File

@ -0,0 +1,62 @@
"use strict";
exports.__esModule = true;
exports.File = File;
exports.Program = Program;
exports.BlockStatement = BlockStatement;
exports.Noop = Noop;
exports.Directive = Directive;
var _types = require("./types");
Object.defineProperty(exports, "DirectiveLiteral", {
enumerable: true,
get: function get() {
return _types.StringLiteral;
}
});
function File(node) {
this.print(node.program, node);
}
function Program(node) {
this.printInnerComments(node, false);
this.printSequence(node.directives, node);
if (node.directives && node.directives.length) this.newline();
this.printSequence(node.body, node);
}
function BlockStatement(node) {
this.token("{");
this.printInnerComments(node);
var hasDirectives = node.directives && node.directives.length;
if (node.body.length || hasDirectives) {
this.newline();
this.printSequence(node.directives, node, { indent: true });
if (hasDirectives) this.newline();
this.printSequence(node.body, node, { indent: true });
this.removeTrailingNewline();
this.source("end", node.loc);
if (!this.endsWith("\n")) this.newline();
this.rightBrace();
} else {
this.source("end", node.loc);
this.token("}");
}
}
function Noop() {}
function Directive(node) {
this.print(node.value, node);
this.semicolon();
}

View File

@ -0,0 +1,96 @@
"use strict";
exports.__esModule = true;
exports.ClassDeclaration = ClassDeclaration;
exports.ClassBody = ClassBody;
exports.ClassProperty = ClassProperty;
exports.ClassMethod = ClassMethod;
function ClassDeclaration(node) {
this.printJoin(node.decorators, node);
this.word("class");
if (node.id) {
this.space();
this.print(node.id, node);
}
this.print(node.typeParameters, node);
if (node.superClass) {
this.space();
this.word("extends");
this.space();
this.print(node.superClass, node);
this.print(node.superTypeParameters, node);
}
if (node.implements) {
this.space();
this.word("implements");
this.space();
this.printList(node.implements, node);
}
this.space();
this.print(node.body, node);
}
exports.ClassExpression = ClassDeclaration;
function ClassBody(node) {
this.token("{");
this.printInnerComments(node);
if (node.body.length === 0) {
this.token("}");
} else {
this.newline();
this.indent();
this.printSequence(node.body, node);
this.dedent();
if (!this.endsWith("\n")) this.newline();
this.rightBrace();
}
}
function ClassProperty(node) {
this.printJoin(node.decorators, node);
if (node.static) {
this.word("static");
this.space();
}
if (node.computed) {
this.token("[");
this.print(node.key, node);
this.token("]");
} else {
this._variance(node);
this.print(node.key, node);
}
this.print(node.typeAnnotation, node);
if (node.value) {
this.space();
this.token("=");
this.space();
this.print(node.value, node);
}
this.semicolon();
}
function ClassMethod(node) {
this.printJoin(node.decorators, node);
if (node.static) {
this.word("static");
this.space();
}
if (node.kind === "constructorCall") {
this.word("call");
this.space();
}
this._method(node);
}

View File

@ -0,0 +1,241 @@
"use strict";
exports.__esModule = true;
exports.LogicalExpression = exports.BinaryExpression = exports.AwaitExpression = exports.YieldExpression = undefined;
exports.UnaryExpression = UnaryExpression;
exports.DoExpression = DoExpression;
exports.ParenthesizedExpression = ParenthesizedExpression;
exports.UpdateExpression = UpdateExpression;
exports.ConditionalExpression = ConditionalExpression;
exports.NewExpression = NewExpression;
exports.SequenceExpression = SequenceExpression;
exports.ThisExpression = ThisExpression;
exports.Super = Super;
exports.Decorator = Decorator;
exports.CallExpression = CallExpression;
exports.Import = Import;
exports.EmptyStatement = EmptyStatement;
exports.ExpressionStatement = ExpressionStatement;
exports.AssignmentPattern = AssignmentPattern;
exports.AssignmentExpression = AssignmentExpression;
exports.BindExpression = BindExpression;
exports.MemberExpression = MemberExpression;
exports.MetaProperty = MetaProperty;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _node = require("../node");
var n = _interopRequireWildcard(_node);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function UnaryExpression(node) {
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof") {
this.word(node.operator);
this.space();
} else {
this.token(node.operator);
}
this.print(node.argument, node);
}
function DoExpression(node) {
this.word("do");
this.space();
this.print(node.body, node);
}
function ParenthesizedExpression(node) {
this.token("(");
this.print(node.expression, node);
this.token(")");
}
function UpdateExpression(node) {
if (node.prefix) {
this.token(node.operator);
this.print(node.argument, node);
} else {
this.print(node.argument, node);
this.token(node.operator);
}
}
function ConditionalExpression(node) {
this.print(node.test, node);
this.space();
this.token("?");
this.space();
this.print(node.consequent, node);
this.space();
this.token(":");
this.space();
this.print(node.alternate, node);
}
function NewExpression(node, parent) {
this.word("new");
this.space();
this.print(node.callee, node);
if (node.arguments.length === 0 && this.format.minified && !t.isCallExpression(parent, { callee: node }) && !t.isMemberExpression(parent) && !t.isNewExpression(parent)) return;
this.token("(");
this.printList(node.arguments, node);
this.token(")");
}
function SequenceExpression(node) {
this.printList(node.expressions, node);
}
function ThisExpression() {
this.word("this");
}
function Super() {
this.word("super");
}
function Decorator(node) {
this.token("@");
this.print(node.expression, node);
this.newline();
}
function commaSeparatorNewline() {
this.token(",");
this.newline();
if (!this.endsWith("\n")) this.space();
}
function CallExpression(node) {
this.print(node.callee, node);
this.token("(");
var isPrettyCall = node._prettyCall;
var separator = void 0;
if (isPrettyCall) {
separator = commaSeparatorNewline;
this.newline();
this.indent();
}
this.printList(node.arguments, node, { separator: separator });
if (isPrettyCall) {
this.newline();
this.dedent();
}
this.token(")");
}
function Import() {
this.word("import");
}
function buildYieldAwait(keyword) {
return function (node) {
this.word(keyword);
if (node.delegate) {
this.token("*");
}
if (node.argument) {
this.space();
var terminatorState = this.startTerminatorless();
this.print(node.argument, node);
this.endTerminatorless(terminatorState);
}
};
}
var YieldExpression = exports.YieldExpression = buildYieldAwait("yield");
var AwaitExpression = exports.AwaitExpression = buildYieldAwait("await");
function EmptyStatement() {
this.semicolon(true);
}
function ExpressionStatement(node) {
this.print(node.expression, node);
this.semicolon();
}
function AssignmentPattern(node) {
this.print(node.left, node);
if (node.left.optional) this.token("?");
this.print(node.left.typeAnnotation, node);
this.space();
this.token("=");
this.space();
this.print(node.right, node);
}
function AssignmentExpression(node, parent) {
var parens = this.inForStatementInitCounter && node.operator === "in" && !n.needsParens(node, parent);
if (parens) {
this.token("(");
}
this.print(node.left, node);
this.space();
if (node.operator === "in" || node.operator === "instanceof") {
this.word(node.operator);
} else {
this.token(node.operator);
}
this.space();
this.print(node.right, node);
if (parens) {
this.token(")");
}
}
function BindExpression(node) {
this.print(node.object, node);
this.token("::");
this.print(node.callee, node);
}
exports.BinaryExpression = AssignmentExpression;
exports.LogicalExpression = AssignmentExpression;
function MemberExpression(node) {
this.print(node.object, node);
if (!node.computed && t.isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property");
}
var computed = node.computed;
if (t.isLiteral(node.property) && typeof node.property.value === "number") {
computed = true;
}
if (computed) {
this.token("[");
this.print(node.property, node);
this.token("]");
} else {
this.token(".");
this.print(node.property, node);
}
}
function MetaProperty(node) {
this.print(node.meta, node);
this.token(".");
this.print(node.property, node);
}

View File

@ -0,0 +1,504 @@
"use strict";
exports.__esModule = true;
exports.TypeParameterDeclaration = exports.StringLiteralTypeAnnotation = exports.NumericLiteralTypeAnnotation = exports.GenericTypeAnnotation = exports.ClassImplements = undefined;
exports.AnyTypeAnnotation = AnyTypeAnnotation;
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
exports.DeclareClass = DeclareClass;
exports.DeclareFunction = DeclareFunction;
exports.DeclareInterface = DeclareInterface;
exports.DeclareModule = DeclareModule;
exports.DeclareModuleExports = DeclareModuleExports;
exports.DeclareTypeAlias = DeclareTypeAlias;
exports.DeclareOpaqueType = DeclareOpaqueType;
exports.DeclareVariable = DeclareVariable;
exports.DeclareExportDeclaration = DeclareExportDeclaration;
exports.ExistentialTypeParam = ExistentialTypeParam;
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
exports.FunctionTypeParam = FunctionTypeParam;
exports.InterfaceExtends = InterfaceExtends;
exports._interfaceish = _interfaceish;
exports._variance = _variance;
exports.InterfaceDeclaration = InterfaceDeclaration;
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
exports.MixedTypeAnnotation = MixedTypeAnnotation;
exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
var _types = require("./types");
Object.defineProperty(exports, "NumericLiteralTypeAnnotation", {
enumerable: true,
get: function get() {
return _types.NumericLiteral;
}
});
Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
enumerable: true,
get: function get() {
return _types.StringLiteral;
}
});
exports.NumberTypeAnnotation = NumberTypeAnnotation;
exports.StringTypeAnnotation = StringTypeAnnotation;
exports.ThisTypeAnnotation = ThisTypeAnnotation;
exports.TupleTypeAnnotation = TupleTypeAnnotation;
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
exports.TypeAlias = TypeAlias;
exports.OpaqueType = OpaqueType;
exports.TypeAnnotation = TypeAnnotation;
exports.TypeParameter = TypeParameter;
exports.TypeParameterInstantiation = TypeParameterInstantiation;
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
exports.ObjectTypeIndexer = ObjectTypeIndexer;
exports.ObjectTypeProperty = ObjectTypeProperty;
exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
exports.UnionTypeAnnotation = UnionTypeAnnotation;
exports.TypeCastExpression = TypeCastExpression;
exports.VoidTypeAnnotation = VoidTypeAnnotation;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function AnyTypeAnnotation() {
this.word("any");
}
function ArrayTypeAnnotation(node) {
this.print(node.elementType, node);
this.token("[");
this.token("]");
}
function BooleanTypeAnnotation() {
this.word("boolean");
}
function BooleanLiteralTypeAnnotation(node) {
this.word(node.value ? "true" : "false");
}
function NullLiteralTypeAnnotation() {
this.word("null");
}
function DeclareClass(node, parent) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
this.space();
}
this.word("class");
this.space();
this._interfaceish(node);
}
function DeclareFunction(node, parent) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
this.space();
}
this.word("function");
this.space();
this.print(node.id, node);
this.print(node.id.typeAnnotation.typeAnnotation, node);
this.semicolon();
}
function DeclareInterface(node) {
this.word("declare");
this.space();
this.InterfaceDeclaration(node);
}
function DeclareModule(node) {
this.word("declare");
this.space();
this.word("module");
this.space();
this.print(node.id, node);
this.space();
this.print(node.body, node);
}
function DeclareModuleExports(node) {
this.word("declare");
this.space();
this.word("module");
this.token(".");
this.word("exports");
this.print(node.typeAnnotation, node);
}
function DeclareTypeAlias(node) {
this.word("declare");
this.space();
this.TypeAlias(node);
}
function DeclareOpaqueType(node, parent) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
this.space();
}
this.OpaqueType(node);
}
function DeclareVariable(node, parent) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
this.space();
}
this.word("var");
this.space();
this.print(node.id, node);
this.print(node.id.typeAnnotation, node);
this.semicolon();
}
function DeclareExportDeclaration(node) {
this.word("declare");
this.space();
this.word("export");
this.space();
if (node.default) {
this.word("default");
this.space();
}
FlowExportDeclaration.apply(this, arguments);
}
function FlowExportDeclaration(node) {
if (node.declaration) {
var declar = node.declaration;
this.print(declar, node);
if (!t.isStatement(declar)) this.semicolon();
} else {
this.token("{");
if (node.specifiers.length) {
this.space();
this.printList(node.specifiers, node);
this.space();
}
this.token("}");
if (node.source) {
this.space();
this.word("from");
this.space();
this.print(node.source, node);
}
this.semicolon();
}
}
function ExistentialTypeParam() {
this.token("*");
}
function FunctionTypeAnnotation(node, parent) {
this.print(node.typeParameters, node);
this.token("(");
this.printList(node.params, node);
if (node.rest) {
if (node.params.length) {
this.token(",");
this.space();
}
this.token("...");
this.print(node.rest, node);
}
this.token(")");
if (parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
this.token(":");
} else {
this.space();
this.token("=>");
}
this.space();
this.print(node.returnType, node);
}
function FunctionTypeParam(node) {
this.print(node.name, node);
if (node.optional) this.token("?");
this.token(":");
this.space();
this.print(node.typeAnnotation, node);
}
function InterfaceExtends(node) {
this.print(node.id, node);
this.print(node.typeParameters, node);
}
exports.ClassImplements = InterfaceExtends;
exports.GenericTypeAnnotation = InterfaceExtends;
function _interfaceish(node) {
this.print(node.id, node);
this.print(node.typeParameters, node);
if (node.extends.length) {
this.space();
this.word("extends");
this.space();
this.printList(node.extends, node);
}
if (node.mixins && node.mixins.length) {
this.space();
this.word("mixins");
this.space();
this.printList(node.mixins, node);
}
this.space();
this.print(node.body, node);
}
function _variance(node) {
if (node.variance === "plus") {
this.token("+");
} else if (node.variance === "minus") {
this.token("-");
}
}
function InterfaceDeclaration(node) {
this.word("interface");
this.space();
this._interfaceish(node);
}
function andSeparator() {
this.space();
this.token("&");
this.space();
}
function IntersectionTypeAnnotation(node) {
this.printJoin(node.types, node, { separator: andSeparator });
}
function MixedTypeAnnotation() {
this.word("mixed");
}
function EmptyTypeAnnotation() {
this.word("empty");
}
function NullableTypeAnnotation(node) {
this.token("?");
this.print(node.typeAnnotation, node);
}
function NumberTypeAnnotation() {
this.word("number");
}
function StringTypeAnnotation() {
this.word("string");
}
function ThisTypeAnnotation() {
this.word("this");
}
function TupleTypeAnnotation(node) {
this.token("[");
this.printList(node.types, node);
this.token("]");
}
function TypeofTypeAnnotation(node) {
this.word("typeof");
this.space();
this.print(node.argument, node);
}
function TypeAlias(node) {
this.word("type");
this.space();
this.print(node.id, node);
this.print(node.typeParameters, node);
this.space();
this.token("=");
this.space();
this.print(node.right, node);
this.semicolon();
}
function OpaqueType(node) {
this.word("opaque");
this.space();
this.word("type");
this.space();
this.print(node.id, node);
this.print(node.typeParameters, node);
if (node.supertype) {
this.token(":");
this.space();
this.print(node.supertype, node);
}
if (node.impltype) {
this.space();
this.token("=");
this.space();
this.print(node.impltype, node);
}
this.semicolon();
}
function TypeAnnotation(node) {
this.token(":");
this.space();
if (node.optional) this.token("?");
this.print(node.typeAnnotation, node);
}
function TypeParameter(node) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
}
if (node.default) {
this.space();
this.token("=");
this.space();
this.print(node.default, node);
}
}
function TypeParameterInstantiation(node) {
this.token("<");
this.printList(node.params, node, {});
this.token(">");
}
exports.TypeParameterDeclaration = TypeParameterInstantiation;
function ObjectTypeAnnotation(node) {
var _this = this;
if (node.exact) {
this.token("{|");
} else {
this.token("{");
}
var props = node.properties.concat(node.callProperties, node.indexers);
if (props.length) {
this.space();
this.printJoin(props, node, {
addNewlines: function addNewlines(leading) {
if (leading && !props[0]) return 1;
},
indent: true,
statement: true,
iterator: function iterator() {
if (props.length !== 1) {
if (_this.format.flowCommaSeparator) {
_this.token(",");
} else {
_this.semicolon();
}
_this.space();
}
}
});
this.space();
}
if (node.exact) {
this.token("|}");
} else {
this.token("}");
}
}
function ObjectTypeCallProperty(node) {
if (node.static) {
this.word("static");
this.space();
}
this.print(node.value, node);
}
function ObjectTypeIndexer(node) {
if (node.static) {
this.word("static");
this.space();
}
this._variance(node);
this.token("[");
this.print(node.id, node);
this.token(":");
this.space();
this.print(node.key, node);
this.token("]");
this.token(":");
this.space();
this.print(node.value, node);
}
function ObjectTypeProperty(node) {
if (node.static) {
this.word("static");
this.space();
}
this._variance(node);
this.print(node.key, node);
if (node.optional) this.token("?");
this.token(":");
this.space();
this.print(node.value, node);
}
function ObjectTypeSpreadProperty(node) {
this.token("...");
this.print(node.argument, node);
}
function QualifiedTypeIdentifier(node) {
this.print(node.qualification, node);
this.token(".");
this.print(node.id, node);
}
function orSeparator() {
this.space();
this.token("|");
this.space();
}
function UnionTypeAnnotation(node) {
this.printJoin(node.types, node, { separator: orSeparator });
}
function TypeCastExpression(node) {
this.token("(");
this.print(node.expression, node);
this.print(node.typeAnnotation, node);
this.token(")");
}
function VoidTypeAnnotation() {
this.word("void");
}

View File

@ -0,0 +1,124 @@
"use strict";
exports.__esModule = true;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.JSXAttribute = JSXAttribute;
exports.JSXIdentifier = JSXIdentifier;
exports.JSXNamespacedName = JSXNamespacedName;
exports.JSXMemberExpression = JSXMemberExpression;
exports.JSXSpreadAttribute = JSXSpreadAttribute;
exports.JSXExpressionContainer = JSXExpressionContainer;
exports.JSXSpreadChild = JSXSpreadChild;
exports.JSXText = JSXText;
exports.JSXElement = JSXElement;
exports.JSXOpeningElement = JSXOpeningElement;
exports.JSXClosingElement = JSXClosingElement;
exports.JSXEmptyExpression = JSXEmptyExpression;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function JSXAttribute(node) {
this.print(node.name, node);
if (node.value) {
this.token("=");
this.print(node.value, node);
}
}
function JSXIdentifier(node) {
this.word(node.name);
}
function JSXNamespacedName(node) {
this.print(node.namespace, node);
this.token(":");
this.print(node.name, node);
}
function JSXMemberExpression(node) {
this.print(node.object, node);
this.token(".");
this.print(node.property, node);
}
function JSXSpreadAttribute(node) {
this.token("{");
this.token("...");
this.print(node.argument, node);
this.token("}");
}
function JSXExpressionContainer(node) {
this.token("{");
this.print(node.expression, node);
this.token("}");
}
function JSXSpreadChild(node) {
this.token("{");
this.token("...");
this.print(node.expression, node);
this.token("}");
}
function JSXText(node) {
this.token(node.value);
}
function JSXElement(node) {
var open = node.openingElement;
this.print(open, node);
if (open.selfClosing) return;
this.indent();
for (var _iterator = node.children, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var child = _ref;
this.print(child, node);
}
this.dedent();
this.print(node.closingElement, node);
}
function spaceSeparator() {
this.space();
}
function JSXOpeningElement(node) {
this.token("<");
this.print(node.name, node);
if (node.attributes.length > 0) {
this.space();
this.printJoin(node.attributes, node, { separator: spaceSeparator });
}
if (node.selfClosing) {
this.space();
this.token("/>");
} else {
this.token(">");
}
}
function JSXClosingElement(node) {
this.token("</");
this.print(node.name, node);
this.token(">");
}
function JSXEmptyExpression() {}

View File

@ -0,0 +1,111 @@
"use strict";
exports.__esModule = true;
exports.FunctionDeclaration = undefined;
exports._params = _params;
exports._method = _method;
exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _params(node) {
var _this = this;
this.print(node.typeParameters, node);
this.token("(");
this.printList(node.params, node, {
iterator: function iterator(node) {
if (node.optional) _this.token("?");
_this.print(node.typeAnnotation, node);
}
});
this.token(")");
if (node.returnType) {
this.print(node.returnType, node);
}
}
function _method(node) {
var kind = node.kind;
var key = node.key;
if (kind === "method" || kind === "init") {
if (node.generator) {
this.token("*");
}
}
if (kind === "get" || kind === "set") {
this.word(kind);
this.space();
}
if (node.async) {
this.word("async");
this.space();
}
if (node.computed) {
this.token("[");
this.print(key, node);
this.token("]");
} else {
this.print(key, node);
}
this._params(node);
this.space();
this.print(node.body, node);
}
function FunctionExpression(node) {
if (node.async) {
this.word("async");
this.space();
}
this.word("function");
if (node.generator) this.token("*");
if (node.id) {
this.space();
this.print(node.id, node);
} else {
this.space();
}
this._params(node);
this.space();
this.print(node.body, node);
}
exports.FunctionDeclaration = FunctionExpression;
function ArrowFunctionExpression(node) {
if (node.async) {
this.word("async");
this.space();
}
var firstParam = node.params[0];
if (node.params.length === 1 && t.isIdentifier(firstParam) && !hasTypes(node, firstParam)) {
this.print(firstParam, node);
} else {
this._params(node);
}
this.space();
this.token("=>");
this.space();
this.print(node.body, node);
}
function hasTypes(node, param) {
return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || param.trailingComments;
}

View File

@ -0,0 +1,183 @@
"use strict";
exports.__esModule = true;
exports.ImportSpecifier = ImportSpecifier;
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
exports.ExportSpecifier = ExportSpecifier;
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
exports.ExportAllDeclaration = ExportAllDeclaration;
exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ImportDeclaration = ImportDeclaration;
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function ImportSpecifier(node) {
if (node.importKind === "type" || node.importKind === "typeof") {
this.word(node.importKind);
this.space();
}
this.print(node.imported, node);
if (node.local && node.local.name !== node.imported.name) {
this.space();
this.word("as");
this.space();
this.print(node.local, node);
}
}
function ImportDefaultSpecifier(node) {
this.print(node.local, node);
}
function ExportDefaultSpecifier(node) {
this.print(node.exported, node);
}
function ExportSpecifier(node) {
this.print(node.local, node);
if (node.exported && node.local.name !== node.exported.name) {
this.space();
this.word("as");
this.space();
this.print(node.exported, node);
}
}
function ExportNamespaceSpecifier(node) {
this.token("*");
this.space();
this.word("as");
this.space();
this.print(node.exported, node);
}
function ExportAllDeclaration(node) {
this.word("export");
this.space();
this.token("*");
this.space();
this.word("from");
this.space();
this.print(node.source, node);
this.semicolon();
}
function ExportNamedDeclaration() {
this.word("export");
this.space();
ExportDeclaration.apply(this, arguments);
}
function ExportDefaultDeclaration() {
this.word("export");
this.space();
this.word("default");
this.space();
ExportDeclaration.apply(this, arguments);
}
function ExportDeclaration(node) {
if (node.declaration) {
var declar = node.declaration;
this.print(declar, node);
if (!t.isStatement(declar)) this.semicolon();
} else {
if (node.exportKind === "type") {
this.word("type");
this.space();
}
var specifiers = node.specifiers.slice(0);
var hasSpecial = false;
while (true) {
var first = specifiers[0];
if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
hasSpecial = true;
this.print(specifiers.shift(), node);
if (specifiers.length) {
this.token(",");
this.space();
}
} else {
break;
}
}
if (specifiers.length || !specifiers.length && !hasSpecial) {
this.token("{");
if (specifiers.length) {
this.space();
this.printList(specifiers, node);
this.space();
}
this.token("}");
}
if (node.source) {
this.space();
this.word("from");
this.space();
this.print(node.source, node);
}
this.semicolon();
}
}
function ImportDeclaration(node) {
this.word("import");
this.space();
if (node.importKind === "type" || node.importKind === "typeof") {
this.word(node.importKind);
this.space();
}
var specifiers = node.specifiers.slice(0);
if (specifiers && specifiers.length) {
while (true) {
var first = specifiers[0];
if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
this.print(specifiers.shift(), node);
if (specifiers.length) {
this.token(",");
this.space();
}
} else {
break;
}
}
if (specifiers.length) {
this.token("{");
this.space();
this.printList(specifiers, node);
this.space();
this.token("}");
}
this.space();
this.word("from");
this.space();
}
this.print(node.source, node);
this.semicolon();
}
function ImportNamespaceSpecifier(node) {
this.token("*");
this.space();
this.word("as");
this.space();
this.print(node.local, node);
}

View File

@ -0,0 +1,316 @@
"use strict";
exports.__esModule = true;
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForAwaitStatement = exports.ForOfStatement = exports.ForInStatement = undefined;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.WithStatement = WithStatement;
exports.IfStatement = IfStatement;
exports.ForStatement = ForStatement;
exports.WhileStatement = WhileStatement;
exports.DoWhileStatement = DoWhileStatement;
exports.LabeledStatement = LabeledStatement;
exports.TryStatement = TryStatement;
exports.CatchClause = CatchClause;
exports.SwitchStatement = SwitchStatement;
exports.SwitchCase = SwitchCase;
exports.DebuggerStatement = DebuggerStatement;
exports.VariableDeclaration = VariableDeclaration;
exports.VariableDeclarator = VariableDeclarator;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function WithStatement(node) {
this.word("with");
this.space();
this.token("(");
this.print(node.object, node);
this.token(")");
this.printBlock(node);
}
function IfStatement(node) {
this.word("if");
this.space();
this.token("(");
this.print(node.test, node);
this.token(")");
this.space();
var needsBlock = node.alternate && t.isIfStatement(getLastStatement(node.consequent));
if (needsBlock) {
this.token("{");
this.newline();
this.indent();
}
this.printAndIndentOnComments(node.consequent, node);
if (needsBlock) {
this.dedent();
this.newline();
this.token("}");
}
if (node.alternate) {
if (this.endsWith("}")) this.space();
this.word("else");
this.space();
this.printAndIndentOnComments(node.alternate, node);
}
}
function getLastStatement(statement) {
if (!t.isStatement(statement.body)) return statement;
return getLastStatement(statement.body);
}
function ForStatement(node) {
this.word("for");
this.space();
this.token("(");
this.inForStatementInitCounter++;
this.print(node.init, node);
this.inForStatementInitCounter--;
this.token(";");
if (node.test) {
this.space();
this.print(node.test, node);
}
this.token(";");
if (node.update) {
this.space();
this.print(node.update, node);
}
this.token(")");
this.printBlock(node);
}
function WhileStatement(node) {
this.word("while");
this.space();
this.token("(");
this.print(node.test, node);
this.token(")");
this.printBlock(node);
}
var buildForXStatement = function buildForXStatement(op) {
return function (node) {
this.word("for");
this.space();
if (op === "await") {
this.word("await");
this.space();
}
this.token("(");
this.print(node.left, node);
this.space();
this.word(op === "await" ? "of" : op);
this.space();
this.print(node.right, node);
this.token(")");
this.printBlock(node);
};
};
var ForInStatement = exports.ForInStatement = buildForXStatement("in");
var ForOfStatement = exports.ForOfStatement = buildForXStatement("of");
var ForAwaitStatement = exports.ForAwaitStatement = buildForXStatement("await");
function DoWhileStatement(node) {
this.word("do");
this.space();
this.print(node.body, node);
this.space();
this.word("while");
this.space();
this.token("(");
this.print(node.test, node);
this.token(")");
this.semicolon();
}
function buildLabelStatement(prefix) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "label";
return function (node) {
this.word(prefix);
var label = node[key];
if (label) {
this.space();
var terminatorState = this.startTerminatorless();
this.print(label, node);
this.endTerminatorless(terminatorState);
}
this.semicolon();
};
}
var ContinueStatement = exports.ContinueStatement = buildLabelStatement("continue");
var ReturnStatement = exports.ReturnStatement = buildLabelStatement("return", "argument");
var BreakStatement = exports.BreakStatement = buildLabelStatement("break");
var ThrowStatement = exports.ThrowStatement = buildLabelStatement("throw", "argument");
function LabeledStatement(node) {
this.print(node.label, node);
this.token(":");
this.space();
this.print(node.body, node);
}
function TryStatement(node) {
this.word("try");
this.space();
this.print(node.block, node);
this.space();
if (node.handlers) {
this.print(node.handlers[0], node);
} else {
this.print(node.handler, node);
}
if (node.finalizer) {
this.space();
this.word("finally");
this.space();
this.print(node.finalizer, node);
}
}
function CatchClause(node) {
this.word("catch");
this.space();
this.token("(");
this.print(node.param, node);
this.token(")");
this.space();
this.print(node.body, node);
}
function SwitchStatement(node) {
this.word("switch");
this.space();
this.token("(");
this.print(node.discriminant, node);
this.token(")");
this.space();
this.token("{");
this.printSequence(node.cases, node, {
indent: true,
addNewlines: function addNewlines(leading, cas) {
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
}
});
this.token("}");
}
function SwitchCase(node) {
if (node.test) {
this.word("case");
this.space();
this.print(node.test, node);
this.token(":");
} else {
this.word("default");
this.token(":");
}
if (node.consequent.length) {
this.newline();
this.printSequence(node.consequent, node, { indent: true });
}
}
function DebuggerStatement() {
this.word("debugger");
this.semicolon();
}
function variableDeclarationIdent() {
this.token(",");
this.newline();
if (this.endsWith("\n")) for (var i = 0; i < 4; i++) {
this.space(true);
}
}
function constDeclarationIdent() {
this.token(",");
this.newline();
if (this.endsWith("\n")) for (var i = 0; i < 6; i++) {
this.space(true);
}
}
function VariableDeclaration(node, parent) {
this.word(node.kind);
this.space();
var hasInits = false;
if (!t.isFor(parent)) {
for (var _iterator = node.declarations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var declar = _ref;
if (declar.init) {
hasInits = true;
}
}
}
var separator = void 0;
if (hasInits) {
separator = node.kind === "const" ? constDeclarationIdent : variableDeclarationIdent;
}
this.printList(node.declarations, node, { separator: separator });
if (t.isFor(parent)) {
if (parent.left === node || parent.init === node) return;
}
this.semicolon();
}
function VariableDeclarator(node) {
this.print(node.id, node);
this.print(node.id.typeAnnotation, node);
if (node.init) {
this.space();
this.token("=");
this.space();
this.print(node.init, node);
}
}

View File

@ -0,0 +1,31 @@
"use strict";
exports.__esModule = true;
exports.TaggedTemplateExpression = TaggedTemplateExpression;
exports.TemplateElement = TemplateElement;
exports.TemplateLiteral = TemplateLiteral;
function TaggedTemplateExpression(node) {
this.print(node.tag, node);
this.print(node.quasi, node);
}
function TemplateElement(node, parent) {
var isFirst = parent.quasis[0] === node;
var isLast = parent.quasis[parent.quasis.length - 1] === node;
var value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
this.token(value);
}
function TemplateLiteral(node) {
var quasis = node.quasis;
for (var i = 0; i < quasis.length; i++) {
this.print(quasis[i], node);
if (i + 1 < quasis.length) {
this.print(node.expressions[i], node);
}
}
}

View File

@ -0,0 +1,158 @@
"use strict";
exports.__esModule = true;
exports.ArrayPattern = exports.ObjectPattern = exports.RestProperty = exports.SpreadProperty = exports.SpreadElement = undefined;
exports.Identifier = Identifier;
exports.RestElement = RestElement;
exports.ObjectExpression = ObjectExpression;
exports.ObjectMethod = ObjectMethod;
exports.ObjectProperty = ObjectProperty;
exports.ArrayExpression = ArrayExpression;
exports.RegExpLiteral = RegExpLiteral;
exports.BooleanLiteral = BooleanLiteral;
exports.NullLiteral = NullLiteral;
exports.NumericLiteral = NumericLiteral;
exports.StringLiteral = StringLiteral;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _jsesc = require("jsesc");
var _jsesc2 = _interopRequireDefault(_jsesc);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function Identifier(node) {
if (node.variance) {
if (node.variance === "plus") {
this.token("+");
} else if (node.variance === "minus") {
this.token("-");
}
}
this.word(node.name);
}
function RestElement(node) {
this.token("...");
this.print(node.argument, node);
}
exports.SpreadElement = RestElement;
exports.SpreadProperty = RestElement;
exports.RestProperty = RestElement;
function ObjectExpression(node) {
var props = node.properties;
this.token("{");
this.printInnerComments(node);
if (props.length) {
this.space();
this.printList(props, node, { indent: true, statement: true });
this.space();
}
this.token("}");
}
exports.ObjectPattern = ObjectExpression;
function ObjectMethod(node) {
this.printJoin(node.decorators, node);
this._method(node);
}
function ObjectProperty(node) {
this.printJoin(node.decorators, node);
if (node.computed) {
this.token("[");
this.print(node.key, node);
this.token("]");
} else {
if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
this.print(node.value, node);
return;
}
this.print(node.key, node);
if (node.shorthand && t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name) {
return;
}
}
this.token(":");
this.space();
this.print(node.value, node);
}
function ArrayExpression(node) {
var elems = node.elements;
var len = elems.length;
this.token("[");
this.printInnerComments(node);
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
if (elem) {
if (i > 0) this.space();
this.print(elem, node);
if (i < len - 1) this.token(",");
} else {
this.token(",");
}
}
this.token("]");
}
exports.ArrayPattern = ArrayExpression;
function RegExpLiteral(node) {
this.word("/" + node.pattern + "/" + node.flags);
}
function BooleanLiteral(node) {
this.word(node.value ? "true" : "false");
}
function NullLiteral() {
this.word("null");
}
function NumericLiteral(node) {
var raw = this.getPossibleRaw(node);
var value = node.value + "";
if (raw == null) {
this.number(value);
} else if (this.format.minified) {
this.number(raw.length < value.length ? raw : value);
} else {
this.number(raw);
}
}
function StringLiteral(node, parent) {
var raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) {
this.token(raw);
return;
}
var opts = {
quotes: t.isJSX(parent) ? "double" : this.format.quotes,
wrap: true
};
if (this.format.jsonCompatibleStrings) {
opts.json = true;
}
var val = (0, _jsesc2.default)(node.value, opts);
return this.token(val);
}

View File

@ -0,0 +1,168 @@
"use strict";
exports.__esModule = true;
exports.CodeGenerator = undefined;
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require("babel-runtime/helpers/inherits");
var _inherits3 = _interopRequireDefault(_inherits2);
exports.default = function (ast, opts, code) {
var gen = new Generator(ast, opts, code);
return gen.generate();
};
var _detectIndent = require("detect-indent");
var _detectIndent2 = _interopRequireDefault(_detectIndent);
var _sourceMap = require("./source-map");
var _sourceMap2 = _interopRequireDefault(_sourceMap);
var _babelMessages = require("babel-messages");
var messages = _interopRequireWildcard(_babelMessages);
var _printer = require("./printer");
var _printer2 = _interopRequireDefault(_printer);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Generator = function (_Printer) {
(0, _inherits3.default)(Generator, _Printer);
function Generator(ast) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var code = arguments[2];
(0, _classCallCheck3.default)(this, Generator);
var tokens = ast.tokens || [];
var format = normalizeOptions(code, opts, tokens);
var map = opts.sourceMaps ? new _sourceMap2.default(opts, code) : null;
var _this = (0, _possibleConstructorReturn3.default)(this, _Printer.call(this, format, map, tokens));
_this.ast = ast;
return _this;
}
Generator.prototype.generate = function generate() {
return _Printer.prototype.generate.call(this, this.ast);
};
return Generator;
}(_printer2.default);
function normalizeOptions(code, opts, tokens) {
var style = " ";
if (code && typeof code === "string") {
var indent = (0, _detectIndent2.default)(code).indent;
if (indent && indent !== " ") style = indent;
}
var format = {
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
shouldPrintComment: opts.shouldPrintComment,
retainLines: opts.retainLines,
retainFunctionParens: opts.retainFunctionParens,
comments: opts.comments == null || opts.comments,
compact: opts.compact,
minified: opts.minified,
concise: opts.concise,
quotes: opts.quotes || findCommonStringDelimiter(code, tokens),
jsonCompatibleStrings: opts.jsonCompatibleStrings,
indent: {
adjustMultilineComment: true,
style: style,
base: 0
},
flowCommaSeparator: opts.flowCommaSeparator
};
if (format.minified) {
format.compact = true;
format.shouldPrintComment = format.shouldPrintComment || function () {
return format.comments;
};
} else {
format.shouldPrintComment = format.shouldPrintComment || function (value) {
return format.comments || value.indexOf("@license") >= 0 || value.indexOf("@preserve") >= 0;
};
}
if (format.compact === "auto") {
format.compact = code.length > 500000;
if (format.compact) {
console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "500KB"));
}
}
if (format.compact) {
format.indent.adjustMultilineComment = false;
}
return format;
}
function findCommonStringDelimiter(code, tokens) {
var DEFAULT_STRING_DELIMITER = "double";
if (!code) {
return DEFAULT_STRING_DELIMITER;
}
var occurrences = {
single: 0,
double: 0
};
var checked = 0;
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type.label !== "string") continue;
var raw = code.slice(token.start, token.end);
if (raw[0] === "'") {
occurrences.single++;
} else {
occurrences.double++;
}
checked++;
if (checked >= 3) break;
}
if (occurrences.single > occurrences.double) {
return "single";
} else {
return "double";
}
}
var CodeGenerator = exports.CodeGenerator = function () {
function CodeGenerator(ast, opts, code) {
(0, _classCallCheck3.default)(this, CodeGenerator);
this._generator = new Generator(ast, opts, code);
}
CodeGenerator.prototype.generate = function generate() {
return this._generator.generate();
};
return CodeGenerator;
}();

View File

@ -0,0 +1,146 @@
"use strict";
exports.__esModule = true;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
exports.needsWhitespace = needsWhitespace;
exports.needsWhitespaceBefore = needsWhitespaceBefore;
exports.needsWhitespaceAfter = needsWhitespaceAfter;
exports.needsParens = needsParens;
var _whitespace = require("./whitespace");
var _whitespace2 = _interopRequireDefault(_whitespace);
var _parentheses = require("./parentheses");
var parens = _interopRequireWildcard(_parentheses);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function expandAliases(obj) {
var newObj = {};
function add(type, func) {
var fn = newObj[type];
newObj[type] = fn ? function (node, parent, stack) {
var result = fn(node, parent, stack);
return result == null ? func(node, parent, stack) : result;
} : func;
}
for (var _iterator = (0, _keys2.default)(obj), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var type = _ref;
var aliases = t.FLIPPED_ALIAS_KEYS[type];
if (aliases) {
for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var alias = _ref2;
add(alias, obj[type]);
}
} else {
add(type, obj[type]);
}
}
return newObj;
}
var expandedParens = expandAliases(parens);
var expandedWhitespaceNodes = expandAliases(_whitespace2.default.nodes);
var expandedWhitespaceList = expandAliases(_whitespace2.default.list);
function find(obj, node, parent, printStack) {
var fn = obj[node.type];
return fn ? fn(node, parent, printStack) : null;
}
function isOrHasCallExpression(node) {
if (t.isCallExpression(node)) {
return true;
}
if (t.isMemberExpression(node)) {
return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property);
} else {
return false;
}
}
function needsWhitespace(node, parent, type) {
if (!node) return 0;
if (t.isExpressionStatement(node)) {
node = node.expression;
}
var linesInfo = find(expandedWhitespaceNodes, node, parent);
if (!linesInfo) {
var items = find(expandedWhitespaceList, node, parent);
if (items) {
for (var i = 0; i < items.length; i++) {
linesInfo = needsWhitespace(items[i], node, type);
if (linesInfo) break;
}
}
}
return linesInfo && linesInfo[type] || 0;
}
function needsWhitespaceBefore(node, parent) {
return needsWhitespace(node, parent, "before");
}
function needsWhitespaceAfter(node, parent) {
return needsWhitespace(node, parent, "after");
}
function needsParens(node, parent, printStack) {
if (!parent) return false;
if (t.isNewExpression(parent) && parent.callee === node) {
if (isOrHasCallExpression(node)) return true;
}
return find(expandedParens, node, parent, printStack);
}

View File

@ -0,0 +1,170 @@
"use strict";
exports.__esModule = true;
exports.AwaitExpression = exports.FunctionTypeAnnotation = undefined;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.UpdateExpression = UpdateExpression;
exports.ObjectExpression = ObjectExpression;
exports.DoExpression = DoExpression;
exports.Binary = Binary;
exports.BinaryExpression = BinaryExpression;
exports.SequenceExpression = SequenceExpression;
exports.YieldExpression = YieldExpression;
exports.ClassExpression = ClassExpression;
exports.UnaryLike = UnaryLike;
exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression;
exports.ConditionalExpression = ConditionalExpression;
exports.AssignmentExpression = AssignmentExpression;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var PRECEDENCE = {
"||": 0,
"&&": 1,
"|": 2,
"^": 3,
"&": 4,
"==": 5,
"===": 5,
"!=": 5,
"!==": 5,
"<": 6,
">": 6,
"<=": 6,
">=": 6,
in: 6,
instanceof: 6,
">>": 7,
"<<": 7,
">>>": 7,
"+": 8,
"-": 8,
"*": 9,
"/": 9,
"%": 9,
"**": 10
};
function NullableTypeAnnotation(node, parent) {
return t.isArrayTypeAnnotation(parent);
}
exports.FunctionTypeAnnotation = NullableTypeAnnotation;
function UpdateExpression(node, parent) {
return t.isMemberExpression(parent) && parent.object === node;
}
function ObjectExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { considerArrow: true });
}
function DoExpression(node, parent, printStack) {
return isFirstInStatement(printStack);
}
function Binary(node, parent) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) {
return true;
}
if (t.isBinary(parent)) {
var parentOp = parent.operator;
var parentPos = PRECEDENCE[parentOp];
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];
if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) {
return true;
}
}
return false;
}
function BinaryExpression(node, parent) {
return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
}
function SequenceExpression(node, parent) {
if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
return true;
}
function YieldExpression(node, parent) {
return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isConditionalExpression(parent) && node === parent.test;
}
exports.AwaitExpression = YieldExpression;
function ClassExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { considerDefaultExports: true });
}
function UnaryLike(node, parent) {
return t.isMemberExpression(parent, { object: node }) || t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node });
}
function FunctionExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { considerDefaultExports: true });
}
function ArrowFunctionExpression(node, parent) {
if (t.isExportDeclaration(parent) || t.isBinaryExpression(parent) || t.isLogicalExpression(parent) || t.isUnaryExpression(parent) || t.isTaggedTemplateExpression(parent)) {
return true;
}
return UnaryLike(node, parent);
}
function ConditionalExpression(node, parent) {
if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { test: node }) || t.isAwaitExpression(parent)) {
return true;
}
return UnaryLike(node, parent);
}
function AssignmentExpression(node) {
if (t.isObjectPattern(node.left)) {
return true;
} else {
return ConditionalExpression.apply(undefined, arguments);
}
}
function isFirstInStatement(printStack) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$considerArrow = _ref.considerArrow,
considerArrow = _ref$considerArrow === undefined ? false : _ref$considerArrow,
_ref$considerDefaultE = _ref.considerDefaultExports,
considerDefaultExports = _ref$considerDefaultE === undefined ? false : _ref$considerDefaultE;
var i = printStack.length - 1;
var node = printStack[i];
i--;
var parent = printStack[i];
while (i > 0) {
if (t.isExpressionStatement(parent, { expression: node }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
return true;
}
if (t.isCallExpression(parent, { callee: node }) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isMemberExpression(parent, { object: node }) || t.isConditional(parent, { test: node }) || t.isBinary(parent, { left: node }) || t.isAssignmentExpression(parent, { left: node })) {
node = parent;
i--;
parent = printStack[i];
} else {
return false;
}
}
return false;
}

View File

@ -0,0 +1,151 @@
"use strict";
var _map = require("lodash/map");
var _map2 = _interopRequireDefault(_map);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function crawl(node) {
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (t.isMemberExpression(node)) {
crawl(node.object, state);
if (node.computed) crawl(node.property, state);
} else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
crawl(node.left, state);
crawl(node.right, state);
} else if (t.isCallExpression(node)) {
state.hasCall = true;
crawl(node.callee, state);
} else if (t.isFunction(node)) {
state.hasFunction = true;
} else if (t.isIdentifier(node)) {
state.hasHelper = state.hasHelper || isHelper(node.callee);
}
return state;
}
function isHelper(node) {
if (t.isMemberExpression(node)) {
return isHelper(node.object) || isHelper(node.property);
} else if (t.isIdentifier(node)) {
return node.name === "require" || node.name[0] === "_";
} else if (t.isCallExpression(node)) {
return isHelper(node.callee);
} else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
} else {
return false;
}
}
function isType(node) {
return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
}
exports.nodes = {
AssignmentExpression: function AssignmentExpression(node) {
var state = crawl(node.right);
if (state.hasCall && state.hasHelper || state.hasFunction) {
return {
before: state.hasFunction,
after: true
};
}
},
SwitchCase: function SwitchCase(node, parent) {
return {
before: node.consequent.length || parent.cases[0] === node
};
},
LogicalExpression: function LogicalExpression(node) {
if (t.isFunction(node.left) || t.isFunction(node.right)) {
return {
after: true
};
}
},
Literal: function Literal(node) {
if (node.value === "use strict") {
return {
after: true
};
}
},
CallExpression: function CallExpression(node) {
if (t.isFunction(node.callee) || isHelper(node)) {
return {
before: true,
after: true
};
}
},
VariableDeclaration: function VariableDeclaration(node) {
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
var enabled = isHelper(declar.id) && !isType(declar.init);
if (!enabled) {
var state = crawl(declar.init);
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
}
if (enabled) {
return {
before: true,
after: true
};
}
}
},
IfStatement: function IfStatement(node) {
if (t.isBlockStatement(node.consequent)) {
return {
before: true,
after: true
};
}
}
};
exports.nodes.ObjectProperty = exports.nodes.ObjectTypeProperty = exports.nodes.ObjectMethod = exports.nodes.SpreadProperty = function (node, parent) {
if (parent.properties[0] === node) {
return {
before: true
};
}
};
exports.list = {
VariableDeclaration: function VariableDeclaration(node) {
return (0, _map2.default)(node.declarations, "init");
},
ArrayExpression: function ArrayExpression(node) {
return node.elements;
},
ObjectExpression: function ObjectExpression(node) {
return node.properties;
}
};
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function (_ref) {
var type = _ref[0],
amounts = _ref[1];
if (typeof amounts === "boolean") {
amounts = { after: amounts, before: amounts };
}
[type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
exports.nodes[type] = function () {
return amounts;
};
});
});

View File

@ -0,0 +1,555 @@
"use strict";
exports.__esModule = true;
var _assign = require("babel-runtime/core-js/object/assign");
var _assign2 = _interopRequireDefault(_assign);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
var _weakSet = require("babel-runtime/core-js/weak-set");
var _weakSet2 = _interopRequireDefault(_weakSet);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _find = require("lodash/find");
var _find2 = _interopRequireDefault(_find);
var _findLast = require("lodash/findLast");
var _findLast2 = _interopRequireDefault(_findLast);
var _isInteger = require("lodash/isInteger");
var _isInteger2 = _interopRequireDefault(_isInteger);
var _repeat = require("lodash/repeat");
var _repeat2 = _interopRequireDefault(_repeat);
var _buffer = require("./buffer");
var _buffer2 = _interopRequireDefault(_buffer);
var _node = require("./node");
var n = _interopRequireWildcard(_node);
var _whitespace = require("./whitespace");
var _whitespace2 = _interopRequireDefault(_whitespace);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SCIENTIFIC_NOTATION = /e/i;
var ZERO_DECIMAL_INTEGER = /\.0+$/;
var NON_DECIMAL_LITERAL = /^0[box]/;
var Printer = function () {
function Printer(format, map, tokens) {
(0, _classCallCheck3.default)(this, Printer);
this.inForStatementInitCounter = 0;
this._printStack = [];
this._indent = 0;
this._insideAux = false;
this._printedCommentStarts = {};
this._parenPushNewlineState = null;
this._printAuxAfterOnNextUserNode = false;
this._printedComments = new _weakSet2.default();
this._endsWithInteger = false;
this._endsWithWord = false;
this.format = format || {};
this._buf = new _buffer2.default(map);
this._whitespace = tokens.length > 0 ? new _whitespace2.default(tokens) : null;
}
Printer.prototype.generate = function generate(ast) {
this.print(ast);
this._maybeAddAuxComment();
return this._buf.get();
};
Printer.prototype.indent = function indent() {
if (this.format.compact || this.format.concise) return;
this._indent++;
};
Printer.prototype.dedent = function dedent() {
if (this.format.compact || this.format.concise) return;
this._indent--;
};
Printer.prototype.semicolon = function semicolon() {
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this._maybeAddAuxComment();
this._append(";", !force);
};
Printer.prototype.rightBrace = function rightBrace() {
if (this.format.minified) {
this._buf.removeLastSemicolon();
}
this.token("}");
};
Printer.prototype.space = function space() {
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (this.format.compact) return;
if (this._buf.hasContent() && !this.endsWith(" ") && !this.endsWith("\n") || force) {
this._space();
}
};
Printer.prototype.word = function word(str) {
if (this._endsWithWord) this._space();
this._maybeAddAuxComment();
this._append(str);
this._endsWithWord = true;
};
Printer.prototype.number = function number(str) {
this.word(str);
this._endsWithInteger = (0, _isInteger2.default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== ".";
};
Printer.prototype.token = function token(str) {
if (str === "--" && this.endsWith("!") || str[0] === "+" && this.endsWith("+") || str[0] === "-" && this.endsWith("-") || str[0] === "." && this._endsWithInteger) {
this._space();
}
this._maybeAddAuxComment();
this._append(str);
};
Printer.prototype.newline = function newline(i) {
if (this.format.retainLines || this.format.compact) return;
if (this.format.concise) {
this.space();
return;
}
if (this.endsWith("\n\n")) return;
if (typeof i !== "number") i = 1;
i = Math.min(2, i);
if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
if (i <= 0) return;
for (var j = 0; j < i; j++) {
this._newline();
}
};
Printer.prototype.endsWith = function endsWith(str) {
return this._buf.endsWith(str);
};
Printer.prototype.removeTrailingNewline = function removeTrailingNewline() {
this._buf.removeTrailingNewline();
};
Printer.prototype.source = function source(prop, loc) {
this._catchUp(prop, loc);
this._buf.source(prop, loc);
};
Printer.prototype.withSource = function withSource(prop, loc, cb) {
this._catchUp(prop, loc);
this._buf.withSource(prop, loc, cb);
};
Printer.prototype._space = function _space() {
this._append(" ", true);
};
Printer.prototype._newline = function _newline() {
this._append("\n", true);
};
Printer.prototype._append = function _append(str) {
var queue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this._maybeAddParen(str);
this._maybeIndent(str);
if (queue) this._buf.queue(str);else this._buf.append(str);
this._endsWithWord = false;
this._endsWithInteger = false;
};
Printer.prototype._maybeIndent = function _maybeIndent(str) {
if (this._indent && this.endsWith("\n") && str[0] !== "\n") {
this._buf.queue(this._getIndent());
}
};
Printer.prototype._maybeAddParen = function _maybeAddParen(str) {
var parenPushNewlineState = this._parenPushNewlineState;
if (!parenPushNewlineState) return;
this._parenPushNewlineState = null;
var i = void 0;
for (i = 0; i < str.length && str[i] === " "; i++) {
continue;
}if (i === str.length) return;
var cha = str[i];
if (cha === "\n" || cha === "/") {
this.token("(");
this.indent();
parenPushNewlineState.printed = true;
}
};
Printer.prototype._catchUp = function _catchUp(prop, loc) {
if (!this.format.retainLines) return;
var pos = loc ? loc[prop] : null;
if (pos && pos.line !== null) {
var count = pos.line - this._buf.getCurrentLine();
for (var i = 0; i < count; i++) {
this._newline();
}
}
};
Printer.prototype._getIndent = function _getIndent() {
return (0, _repeat2.default)(this.format.indent.style, this._indent);
};
Printer.prototype.startTerminatorless = function startTerminatorless() {
return this._parenPushNewlineState = {
printed: false
};
};
Printer.prototype.endTerminatorless = function endTerminatorless(state) {
if (state.printed) {
this.dedent();
this.newline();
this.token(")");
}
};
Printer.prototype.print = function print(node, parent) {
var _this = this;
if (!node) return;
var oldConcise = this.format.concise;
if (node._compact) {
this.format.concise = true;
}
var printMethod = this[node.type];
if (!printMethod) {
throw new ReferenceError("unknown node of type " + (0, _stringify2.default)(node.type) + " with constructor " + (0, _stringify2.default)(node && node.constructor.name));
}
this._printStack.push(node);
var oldInAux = this._insideAux;
this._insideAux = !node.loc;
this._maybeAddAuxComment(this._insideAux && !oldInAux);
var needsParens = n.needsParens(node, parent, this._printStack);
if (this.format.retainFunctionParens && node.type === "FunctionExpression" && node.extra && node.extra.parenthesized) {
needsParens = true;
}
if (needsParens) this.token("(");
this._printLeadingComments(node, parent);
var loc = t.isProgram(node) || t.isFile(node) ? null : node.loc;
this.withSource("start", loc, function () {
_this[node.type](node, parent);
});
this._printTrailingComments(node, parent);
if (needsParens) this.token(")");
this._printStack.pop();
this.format.concise = oldConcise;
this._insideAux = oldInAux;
};
Printer.prototype._maybeAddAuxComment = function _maybeAddAuxComment(enteredPositionlessNode) {
if (enteredPositionlessNode) this._printAuxBeforeComment();
if (!this._insideAux) this._printAuxAfterComment();
};
Printer.prototype._printAuxBeforeComment = function _printAuxBeforeComment() {
if (this._printAuxAfterOnNextUserNode) return;
this._printAuxAfterOnNextUserNode = true;
var comment = this.format.auxiliaryCommentBefore;
if (comment) {
this._printComment({
type: "CommentBlock",
value: comment
});
}
};
Printer.prototype._printAuxAfterComment = function _printAuxAfterComment() {
if (!this._printAuxAfterOnNextUserNode) return;
this._printAuxAfterOnNextUserNode = false;
var comment = this.format.auxiliaryCommentAfter;
if (comment) {
this._printComment({
type: "CommentBlock",
value: comment
});
}
};
Printer.prototype.getPossibleRaw = function getPossibleRaw(node) {
var extra = node.extra;
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
return extra.raw;
}
};
Printer.prototype.printJoin = function printJoin(nodes, parent) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!nodes || !nodes.length) return;
if (opts.indent) this.indent();
var newlineOpts = {
addNewlines: opts.addNewlines
};
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) continue;
if (opts.statement) this._printNewline(true, node, parent, newlineOpts);
this.print(node, parent);
if (opts.iterator) {
opts.iterator(node, i);
}
if (opts.separator && i < nodes.length - 1) {
opts.separator.call(this);
}
if (opts.statement) this._printNewline(false, node, parent, newlineOpts);
}
if (opts.indent) this.dedent();
};
Printer.prototype.printAndIndentOnComments = function printAndIndentOnComments(node, parent) {
var indent = !!node.leadingComments;
if (indent) this.indent();
this.print(node, parent);
if (indent) this.dedent();
};
Printer.prototype.printBlock = function printBlock(parent) {
var node = parent.body;
if (!t.isEmptyStatement(node)) {
this.space();
}
this.print(node, parent);
};
Printer.prototype._printTrailingComments = function _printTrailingComments(node, parent) {
this._printComments(this._getComments(false, node, parent));
};
Printer.prototype._printLeadingComments = function _printLeadingComments(node, parent) {
this._printComments(this._getComments(true, node, parent));
};
Printer.prototype.printInnerComments = function printInnerComments(node) {
var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (!node.innerComments) return;
if (indent) this.indent();
this._printComments(node.innerComments);
if (indent) this.dedent();
};
Printer.prototype.printSequence = function printSequence(nodes, parent) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
opts.statement = true;
return this.printJoin(nodes, parent, opts);
};
Printer.prototype.printList = function printList(items, parent) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (opts.separator == null) {
opts.separator = commaSeparator;
}
return this.printJoin(items, parent, opts);
};
Printer.prototype._printNewline = function _printNewline(leading, node, parent, opts) {
var _this2 = this;
if (this.format.retainLines || this.format.compact) return;
if (this.format.concise) {
this.space();
return;
}
var lines = 0;
if (node.start != null && !node._ignoreUserWhitespace && this._whitespace) {
if (leading) {
var _comments = node.leadingComments;
var _comment = _comments && (0, _find2.default)(_comments, function (comment) {
return !!comment.loc && _this2.format.shouldPrintComment(comment.value);
});
lines = this._whitespace.getNewlinesBefore(_comment || node);
} else {
var _comments2 = node.trailingComments;
var _comment2 = _comments2 && (0, _findLast2.default)(_comments2, function (comment) {
return !!comment.loc && _this2.format.shouldPrintComment(comment.value);
});
lines = this._whitespace.getNewlinesAfter(_comment2 || node);
}
} else {
if (!leading) lines++;
if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
var needs = n.needsWhitespaceAfter;
if (leading) needs = n.needsWhitespaceBefore;
if (needs(node, parent)) lines++;
if (!this._buf.hasContent()) lines = 0;
}
this.newline(lines);
};
Printer.prototype._getComments = function _getComments(leading, node) {
return node && (leading ? node.leadingComments : node.trailingComments) || [];
};
Printer.prototype._printComment = function _printComment(comment) {
var _this3 = this;
if (!this.format.shouldPrintComment(comment.value)) return;
if (comment.ignore) return;
if (this._printedComments.has(comment)) return;
this._printedComments.add(comment);
if (comment.start != null) {
if (this._printedCommentStarts[comment.start]) return;
this._printedCommentStarts[comment.start] = true;
}
this.newline(this._whitespace ? this._whitespace.getNewlinesBefore(comment) : 0);
if (!this.endsWith("[") && !this.endsWith("{")) this.space();
var val = comment.type === "CommentLine" ? "//" + comment.value + "\n" : "/*" + comment.value + "*/";
if (comment.type === "CommentBlock" && this.format.indent.adjustMultilineComment) {
var offset = comment.loc && comment.loc.start.column;
if (offset) {
var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n");
}
var indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn());
val = val.replace(/\n(?!$)/g, "\n" + (0, _repeat2.default)(" ", indentSize));
}
this.withSource("start", comment.loc, function () {
_this3._append(val);
});
this.newline((this._whitespace ? this._whitespace.getNewlinesAfter(comment) : 0) + (comment.type === "CommentLine" ? -1 : 0));
};
Printer.prototype._printComments = function _printComments(comments) {
if (!comments || !comments.length) return;
for (var _iterator = comments, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var _comment3 = _ref;
this._printComment(_comment3);
}
};
return Printer;
}();
exports.default = Printer;
function commaSeparator() {
this.token(",");
this.space();
}
var _arr = [require("./generators/template-literals"), require("./generators/expressions"), require("./generators/statements"), require("./generators/classes"), require("./generators/methods"), require("./generators/modules"), require("./generators/types"), require("./generators/flow"), require("./generators/base"), require("./generators/jsx")];
for (var _i2 = 0; _i2 < _arr.length; _i2++) {
var generator = _arr[_i2];
(0, _assign2.default)(Printer.prototype, generator);
}
module.exports = exports["default"];

View File

@ -0,0 +1,89 @@
"use strict";
exports.__esModule = true;
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _typeof2 = require("babel-runtime/helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _sourceMap = require("source-map");
var _sourceMap2 = _interopRequireDefault(_sourceMap);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SourceMap = function () {
function SourceMap(opts, code) {
(0, _classCallCheck3.default)(this, SourceMap);
this._cachedMap = null;
this._code = code;
this._opts = opts;
this._rawMappings = [];
}
SourceMap.prototype.get = function get() {
if (!this._cachedMap) {
var map = this._cachedMap = new _sourceMap2.default.SourceMapGenerator({
file: this._opts.sourceMapTarget,
sourceRoot: this._opts.sourceRoot
});
var code = this._code;
if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
map.setSourceContent(sourceFileName, code[sourceFileName]);
});
}
this._rawMappings.forEach(map.addMapping, map);
}
return this._cachedMap.toJSON();
};
SourceMap.prototype.getRawMappings = function getRawMappings() {
return this._rawMappings.slice();
};
SourceMap.prototype.mark = function mark(generatedLine, generatedColumn, line, column, identifierName, filename) {
if (this._lastGenLine !== generatedLine && line === null) return;
if (this._lastGenLine === generatedLine && this._lastSourceLine === line && this._lastSourceColumn === column) {
return;
}
this._cachedMap = null;
this._lastGenLine = generatedLine;
this._lastSourceLine = line;
this._lastSourceColumn = column;
this._rawMappings.push({
name: identifierName || undefined,
generated: {
line: generatedLine,
column: generatedColumn
},
source: line == null ? undefined : filename || this._opts.sourceFileName,
original: line == null ? undefined : {
line: line,
column: column
}
});
};
return SourceMap;
}();
exports.default = SourceMap;
module.exports = exports["default"];

View File

@ -0,0 +1,95 @@
"use strict";
exports.__esModule = true;
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Whitespace = function () {
function Whitespace(tokens) {
(0, _classCallCheck3.default)(this, Whitespace);
this.tokens = tokens;
this.used = {};
}
Whitespace.prototype.getNewlinesBefore = function getNewlinesBefore(node) {
var startToken = void 0;
var endToken = void 0;
var tokens = this.tokens;
var index = this._findToken(function (token) {
return token.start - node.start;
}, 0, tokens.length);
if (index >= 0) {
while (index && node.start === tokens[index - 1].start) {
--index;
}startToken = tokens[index - 1];
endToken = tokens[index];
}
return this._getNewlinesBetween(startToken, endToken);
};
Whitespace.prototype.getNewlinesAfter = function getNewlinesAfter(node) {
var startToken = void 0;
var endToken = void 0;
var tokens = this.tokens;
var index = this._findToken(function (token) {
return token.end - node.end;
}, 0, tokens.length);
if (index >= 0) {
while (index && node.end === tokens[index - 1].end) {
--index;
}startToken = tokens[index];
endToken = tokens[index + 1];
if (endToken.type.label === ",") endToken = tokens[index + 2];
}
if (endToken && endToken.type.label === "eof") {
return 1;
} else {
return this._getNewlinesBetween(startToken, endToken);
}
};
Whitespace.prototype._getNewlinesBetween = function _getNewlinesBetween(startToken, endToken) {
if (!endToken || !endToken.loc) return 0;
var start = startToken ? startToken.loc.end.line : 1;
var end = endToken.loc.start.line;
var lines = 0;
for (var line = start; line < end; line++) {
if (typeof this.used[line] === "undefined") {
this.used[line] = true;
lines++;
}
}
return lines;
};
Whitespace.prototype._findToken = function _findToken(test, start, end) {
if (start >= end) return -1;
var middle = start + end >>> 1;
var match = test(this.tokens[middle]);
if (match < 0) {
return this._findToken(test, middle + 1, end);
} else if (match > 0) {
return this._findToken(test, start, middle);
} else if (match === 0) {
return middle;
}
return -1;
};
return Whitespace;
}();
exports.default = Whitespace;
module.exports = exports["default"];

View File

@ -0,0 +1,109 @@
{
"_args": [
[
{
"raw": "babel-generator@^6.18.0",
"scope": null,
"escapedName": "babel-generator",
"name": "babel-generator",
"rawSpec": "^6.18.0",
"spec": ">=6.18.0 <7.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/istanbul-lib-instrument"
]
],
"_from": "babel-generator@>=6.18.0 <7.0.0",
"_id": "babel-generator@6.26.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/babel-generator",
"_nodeVersion": "6.9.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/babel-generator-6.26.0.tgz_1502898854668_0.4309290638193488"
},
"_npmUser": {
"name": "hzoo",
"email": "hi@henryzoo.com"
},
"_npmVersion": "4.6.1",
"_phantomChildren": {},
"_requested": {
"raw": "babel-generator@^6.18.0",
"scope": null,
"escapedName": "babel-generator",
"name": "babel-generator",
"rawSpec": "^6.18.0",
"spec": ">=6.18.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/istanbul-lib-instrument"
],
"_resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz",
"_shasum": "ac1ae20070b79f6e3ca1d3269613053774f20dc5",
"_shrinkwrap": null,
"_spec": "babel-generator@^6.18.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/istanbul-lib-instrument",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"dependencies": {
"babel-messages": "^6.23.0",
"babel-runtime": "^6.26.0",
"babel-types": "^6.26.0",
"detect-indent": "^4.0.0",
"jsesc": "^1.3.0",
"lodash": "^4.17.4",
"source-map": "^0.5.6",
"trim-right": "^1.0.1"
},
"description": "Turns an AST into code.",
"devDependencies": {
"babel-helper-fixtures": "^6.26.0",
"babylon": "^6.18.0"
},
"directories": {},
"dist": {
"shasum": "ac1ae20070b79f6e3ca1d3269613053774f20dc5",
"tarball": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.0.tgz"
},
"files": [
"lib"
],
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "thejameskyle",
"email": "me@thejameskyle.com"
},
{
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"name": "danez",
"email": "daniel@tschinder.de"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
}
],
"name": "babel-generator",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-generator"
},
"scripts": {},
"version": "6.26.0"
}

View File

@ -0,0 +1,18 @@
# babel-messages
> Collection of debug messages used by Babel.
## Install
```sh
npm install --save-dev babel-messages
```
## Usage
```js
import * as messages from 'babel-messages';
messages.get('tailCallReassignmentDeopt');
// > "Function reference has been..."
```

View File

@ -0,0 +1,84 @@
"use strict";
exports.__esModule = true;
exports.MESSAGES = undefined;
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
exports.get = get;
exports.parseArgs = parseArgs;
var _util = require("util");
var util = _interopRequireWildcard(_util);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MESSAGES = exports.MESSAGES = {
tailCallReassignmentDeopt: "Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",
classesIllegalBareSuper: "Illegal use of bare super",
classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
scopeDuplicateDeclaration: "Duplicate declaration $1",
settersNoRest: "Setters aren't allowed to have a rest",
noAssignmentsInForHead: "No assignments allowed in for-in/of head",
expectedMemberExpressionOrIdentifier: "Expected type MemberExpression or Identifier",
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
readOnly: "$1 is read-only",
unknownForHead: "Unknown node type $1 in ForStatement",
didYouMean: "Did you mean $1?",
codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
unsupportedOutputType: "Unsupported output type $1",
illegalMethodName: "Illegal method name $1",
lostTrackNodePath: "We lost track of this node's position, likely because the AST was directly manipulated",
modulesIllegalExportName: "Illegal export $1",
modulesDuplicateDeclarations: "Duplicate module declarations with the same source but in different scopes",
undeclaredVariable: "Reference to undeclared variable $1",
undeclaredVariableType: "Referencing a type alias outside of a type annotation",
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
traverseNeedsParent: "You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a $1 node without passing scope and parentPath.",
traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",
traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",
traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type",
pluginNotObject: "Plugin $2 specified in $1 was expected to return an object when invoked but returned $3",
pluginNotFunction: "Plugin $2 specified in $1 was expected to return a function but returned $3",
pluginUnknown: "Unknown plugin $1 specified in $2 at $3, attempted to resolve relative to $4",
pluginInvalidProperty: "Plugin $2 specified in $1 provided an invalid property of $3"
};
function get(key) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var msg = MESSAGES[key];
if (!msg) throw new ReferenceError("Unknown message " + (0, _stringify2.default)(key));
args = parseArgs(args);
return msg.replace(/\$(\d+)/g, function (str, i) {
return args[i - 1];
});
}
function parseArgs(args) {
return args.map(function (val) {
if (val != null && val.inspect) {
return val.inspect();
} else {
try {
return (0, _stringify2.default)(val) || val + "";
} catch (e) {
return util.inspect(val);
}
}
});
}

View File

@ -0,0 +1,101 @@
{
"_args": [
[
{
"raw": "babel-messages@^6.23.0",
"scope": null,
"escapedName": "babel-messages",
"name": "babel-messages",
"rawSpec": "^6.23.0",
"spec": ">=6.23.0 <7.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc/node_modules/babel-generator"
]
],
"_from": "babel-messages@>=6.23.0 <7.0.0",
"_id": "babel-messages@6.23.0",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/babel-messages",
"_nodeVersion": "6.9.1",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/babel-messages-6.23.0.tgz_1487027061100_0.7234047667589039"
},
"_npmUser": {
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
"_npmVersion": "3.10.8",
"_phantomChildren": {},
"_requested": {
"raw": "babel-messages@^6.23.0",
"scope": null,
"escapedName": "babel-messages",
"name": "babel-messages",
"rawSpec": "^6.23.0",
"spec": ">=6.23.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc/babel-generator",
"/nyc/babel-traverse"
],
"_resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz",
"_shasum": "f3cdf4703858035b2a2951c6ec5edf6c62f2630e",
"_shrinkwrap": null,
"_spec": "babel-messages@^6.23.0",
"_where": "/Users/benjamincoe/bcoe/nyc/node_modules/babel-generator",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"dependencies": {
"babel-runtime": "^6.22.0"
},
"description": "Collection of debug messages used by Babel.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "f3cdf4703858035b2a2951c6ec5edf6c62f2630e",
"tarball": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "amasad",
"email": "amjad.masad@gmail.com"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "jmm",
"email": "npm-public@jessemccarthy.net"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
{
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"name": "thejameskyle",
"email": "me@thejameskyle.com"
}
],
"name": "babel-messages",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-messages"
},
"scripts": {},
"version": "6.23.0"
}

View File

@ -0,0 +1,2 @@
# babel-runtime

View File

@ -0,0 +1,4 @@
module.exports = {
"default": require("core-js/library"),
__esModule: true
};

View File

@ -0,0 +1 @@
module.exports = { "default": require("core-js/library/fn/array/concat"), __esModule: true };

View File

@ -0,0 +1 @@
module.exports = { "default": require("core-js/library/fn/array/copy-within"), __esModule: true };

View File

@ -0,0 +1 @@
module.exports = { "default": require("core-js/library/fn/array/entries"), __esModule: true };

Some files were not shown because too many files have changed in this diff Show More