diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/.npmignore b/javascript/base/exercices/tests-unitaires/.gitignore similarity index 100% rename from javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/.npmignore rename to javascript/base/exercices/tests-unitaires/.gitignore diff --git a/javascript/base/exercices/tests-unitaires/README.md b/javascript/base/exercices/tests-unitaires/README.md new file mode 100644 index 0000000..663d4c8 --- /dev/null +++ b/javascript/base/exercices/tests-unitaires/README.md @@ -0,0 +1,6 @@ +# Tests unitiaires, exemple NodeUnit + +``` +npm install +./node_modules/.bin/nodeunit math-suite.js +``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/.bin/nodeunit b/javascript/base/exercices/tests-unitaires/node_modules/.bin/nodeunit deleted file mode 120000 index f31cdbe..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/.bin/nodeunit +++ /dev/null @@ -1 +0,0 @@ -../nodeunit/bin/nodeunit \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/.npmignore deleted file mode 100644 index 1a82501..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -dist -stamp-build -test/fixtures/dir2 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/CONTRIBUTORS.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/CONTRIBUTORS.md deleted file mode 100644 index fba3609..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/CONTRIBUTORS.md +++ /dev/null @@ -1,68 +0,0 @@ -Nodeunit contributors (sorted alphabeticaly) -============================================ - -* **[Alex Gorbatchev](https://github.com/alexgorbatchev)** - - * Deeper default object inspection - * Timeout to ensure flushing of console output (default reporter) - -* **[Alex Wolfe](https://github.com/alexkwolfe)** - - * HTML test reporter - -* **[Caolan McMahon](https://github.com/caolan)** - - * Author and maintainer - * Most features develpopment - -* **[Carl Fürstenberg](https://github.com/azatoth)** - - * Debian-friendly Makefile, supports both 'node' and 'nodejs' executables - * Sandbox utility - * Minimal test reporter - -* **[Gerad Suyderhoud](https://github.com/gerad)** - - * First comand-line tool - -* **[Kadir Pekel](https://github.com/kadirpekel)** - - * Improvements to default test reporter - * HTTP test utility - -* **[Λlisue](https://github.com/lambdalisue)** - - * Add machineout reporter - -* **[Matthias Lübken](https://github.com/luebken)** - - * Utility functions for tracking incomplete tests on exit - -* **[Oleg Efimov](https://github.com/Sannis)** - - * Adding 'make lint' and fixing nodelint errors - * Option parsing, --help text and config file support - * Reporters option for command-line tool - -* **[Orlando Vazquez](https://github.com/orlandov)** - - * Added jUnit XML reporter - -* **[Ryan Dahl](https://github.com/ry)** - - * Add package.json - -* **[Sam Stephenson](https://github.com/sstephenson)** - - * Coffee-script support - -* **[Thomas Mayfield](https://github.com/thegreatape)** - - * Async setUp and tearDown support for testCase - -* **[Maciej Małecki](https://github.com/mmalecki)** - - * Removal of `testCase` - -**[Full contributors list](https://github.com/caolan/nodeunit/contributors).** - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/LICENSE deleted file mode 100644 index b7f9d50..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/Makefile b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/Makefile deleted file mode 100644 index 8f8d8cb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/Makefile +++ /dev/null @@ -1,177 +0,0 @@ -PACKAGE = nodeunit -NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node) - -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -DATADIR ?= $(PREFIX)/share -MANDIR ?= $(PREFIX)/share/man -LIBDIR ?= $(PREFIX)/lib -NODEJSLIBDIR ?= $(LIBDIR)/$(NODEJS) - -BUILDDIR = dist - -DOCS = $(shell find doc -name '*.md' \ - |sed 's|.md|.1|g' \ - |sed 's|doc/|man1/|g' \ - ) - - -$(shell if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi) - -all: build doc - -browser: - # super hacky build script for browser version! - mkdir -p $(BUILDDIR)/browser - rm -rf $(BUILDDIR)/browser/* - # build browser version of nodeunit.js - cat share/license.js >> $(BUILDDIR)/browser/nodeunit.js - echo "nodeunit = (function(){" >> $(BUILDDIR)/browser/nodeunit.js - cat deps/json2.js >> $(BUILDDIR)/browser/nodeunit.js - # make assert global - echo "var assert = this.assert = {};" >> $(BUILDDIR)/browser/nodeunit.js - echo "var types = {};" >> $(BUILDDIR)/browser/nodeunit.js - echo "var core = {};" >> $(BUILDDIR)/browser/nodeunit.js - echo "var nodeunit = {};" >> $(BUILDDIR)/browser/nodeunit.js - echo "var reporter = {};" >> $(BUILDDIR)/browser/nodeunit.js - cat deps/async.js >> $(BUILDDIR)/browser/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js - cat lib/assert.js >> $(BUILDDIR)/browser/nodeunit.js - echo "})(assert);" >> $(BUILDDIR)/browser/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js - cat lib/types.js >> $(BUILDDIR)/browser/nodeunit.js - echo "})(types);" >> $(BUILDDIR)/browser/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js - cat lib/core.js >> $(BUILDDIR)/browser/nodeunit.js - echo "})(core);" >> $(BUILDDIR)/browser/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js - cat lib/reporters/browser.js >> $(BUILDDIR)/browser/nodeunit.js - echo "})(reporter);" >> $(BUILDDIR)/browser/nodeunit.js - echo "nodeunit = core;" >> $(BUILDDIR)/browser/nodeunit.js - echo "nodeunit.assert = assert;" >> $(BUILDDIR)/browser/nodeunit.js - echo "nodeunit.reporter = reporter;" >> $(BUILDDIR)/browser/nodeunit.js - echo "nodeunit.run = reporter.run;" >> $(BUILDDIR)/browser/nodeunit.js - echo "return nodeunit; })();" >> $(BUILDDIR)/browser/nodeunit.js - cp $(BUILDDIR)/browser/nodeunit.js $(BUILDDIR)/browser/.nodeunit.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.nodeunit.js > $(BUILDDIR)/browser/nodeunit.js - rm $(BUILDDIR)/browser/.nodeunit.js - # copy nodeunit.css - cp share/nodeunit.css $(BUILDDIR)/browser/nodeunit.css - # create nodeunit.min.js - node_modules/uglify-js/bin/uglifyjs $(BUILDDIR)/browser/nodeunit.js > $(BUILDDIR)/browser/nodeunit.min.js - # create test scripts - mkdir -p $(BUILDDIR)/browser/test - cp test/test.html $(BUILDDIR)/browser/test/test.html - # test-base.js - echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-base.js - cat test/test-base.js >> $(BUILDDIR)/browser/test/test-base.js - echo "})(this.test_base = {});" >> $(BUILDDIR)/browser/test/test-base.js - cp $(BUILDDIR)/browser/test/test-base.js $(BUILDDIR)/browser/.test-base.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.test-base.js > $(BUILDDIR)/browser/test/test-base.js - rm $(BUILDDIR)/browser/.test-base.js - # test-runmodule.js - echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runmodule.js - cat test/test-runmodule.js >> $(BUILDDIR)/browser/test/test-runmodule.js - echo "})(this.test_runmodule = {});" >> $(BUILDDIR)/browser/test/test-runmodule.js - cp $(BUILDDIR)/browser/test/test-runmodule.js $(BUILDDIR)/browser/.test-runmodule.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.test-runmodule.js > $(BUILDDIR)/browser/test/test-runmodule.js - rm $(BUILDDIR)/browser/.test-runmodule.js - # test-runtest.js - echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runtest.js - cat test/test-runtest.js >> $(BUILDDIR)/browser/test/test-runtest.js - echo "})(this.test_runtest = {});" >> $(BUILDDIR)/browser/test/test-runtest.js - cp $(BUILDDIR)/browser/test/test-runtest.js $(BUILDDIR)/browser/.test-runtest.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.test-runtest.js > $(BUILDDIR)/browser/test/test-runtest.js - rm $(BUILDDIR)/browser/.test-runtest.js - # test-testcase.js - echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-testcase.js - cat test/test-testcase.js >> $(BUILDDIR)/browser/test/test-testcase.js - echo "})(this.test_testcase = {});" >> $(BUILDDIR)/browser/test/test-testcase.js - cp $(BUILDDIR)/browser/test/test-testcase.js $(BUILDDIR)/browser/.test-testcase.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.test-testcase.js > $(BUILDDIR)/browser/test/test-testcase.js - rm $(BUILDDIR)/browser/.test-testcase.js - # test-testcase-legacy.js - echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-testcase-legacy.js - cat test/test-testcase-legacy.js >> $(BUILDDIR)/browser/test/test-testcase-legacy.js - echo "})(this.test_testcase_legacy = {});" >> $(BUILDDIR)/browser/test/test-testcase-legacy.js - cp $(BUILDDIR)/browser/test/test-testcase-legacy.js $(BUILDDIR)/browser/.test-testcase-legacy.js - sed "/\@REMOVE_LINE_FOR_BROWSER/d" <$(BUILDDIR)/browser/.test-testcase-legacy.js > $(BUILDDIR)/browser/test/test-testcase-legacy.js - rm $(BUILDDIR)/browser/.test-testcase-legacy.js - # copy nodeunit.js to dist/browser/test to make it easier for me to host and - # run on windows VMs with IE - cp $(BUILDDIR)/browser/nodeunit.js $(BUILDDIR)/browser/test/nodeunit.js - cp $(BUILDDIR)/browser/nodeunit.css $(BUILDDIR)/browser/test/nodeunit.css - -commonjs: - # super hacky build script for browser commonjs version! - ##### make commonjs browser module ###### - mkdir -p $(BUILDDIR)/commonjs - rm -rf $(BUILDDIR)/commonjs/* - mkdir -p $(BUILDDIR)/commonjs/deps - cp deps/json2.js $(BUILDDIR)/commonjs/deps - cp deps/async.js $(BUILDDIR)/commonjs/deps - echo "var async = require('async');" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "var assert = {};" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "var types = {};" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "var core = {};" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "var nodeunit = {};" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "var reporter = {};" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/commonjs/nodeunit.js - cat lib/assert.js >> $(BUILDDIR)/commonjs/nodeunit.js - echo "})(assert);" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/commonjs/nodeunit.js - cat lib/types.js >> $(BUILDDIR)/commonjs/nodeunit.js - echo "})(types);" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "(function(exports){" >> $(BUILDDIR)/commonjs/nodeunit.js - cat lib/core.js >> $(BUILDDIR)/commonjs/nodeunit.js - echo "})(core);" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "module.exports = core;" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "(function(exports, nodeunit){" >> $(BUILDDIR)/commonjs/nodeunit.js - cat lib/reporters/browser.js >> $(BUILDDIR)/commonjs/nodeunit.js - echo "})(reporter, module.exports);" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "module.exports.assert = assert;" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "module.exports.reporter = reporter;" >> $(BUILDDIR)/commonjs/nodeunit.js - echo "module.exports.run = reporter.run;" >> $(BUILDDIR)/commonjs/nodeunit.js - sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/commonjs/nodeunit.js - sed -i "/\@REMOVE_LINE_FOR_COMMONJS/d" $(BUILDDIR)/commonjs/nodeunit.js - ##### end of commonjs browser module ##### - -build: stamp-build - -stamp-build: $(wildcard deps/* lib/*.js) - touch $@; - mkdir -p $(BUILDDIR)/nodeunit - cp -R bin node_modules deps index.js lib package.json share $(BUILDDIR)/nodeunit - printf '#!/bin/sh\n$(NODEJS) $(NODEJSLIBDIR)/$(PACKAGE)/bin/nodeunit $$@' > $(BUILDDIR)/nodeunit.sh - -test: - $(NODEJS) ./bin/nodeunit test - -install: build - install -d $(NODEJSLIBDIR) - cp -a $(BUILDDIR)/nodeunit $(NODEJSLIBDIR) - install -m 0755 $(BUILDDIR)/nodeunit.sh $(BINDIR)/nodeunit - install -d $(MANDIR)/man1/ - cp -a man1/nodeunit.1 $(MANDIR)/man1/ - -uninstall: - rm -rf $(NODEJSLIBDIR)/nodeunit $(NODEJSLIBDIR)/nodeunit.js $(BINDIR)/nodeunit - rm -rf $(MANDIR)/man1/nodeunit.1 - -clean: - rm -rf $(BUILDDIR) stamp-build - -lint: - nodelint --config nodelint.cfg ./index.js ./bin/nodeunit ./bin/nodeunit.json ./lib/*.js ./lib/reporters/*.js ./test/*.js - -doc: man1 $(DOCS) - @true - -man1: - @if ! test -d man1 ; then mkdir -p man1 ; fi - -# use `npm install ronn` for this to work. -man1/%.1: doc/%.md - ronn --roff $< > $@ - -.PHONY: browser test install uninstall build all diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/README.md deleted file mode 100644 index 43605b1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/README.md +++ /dev/null @@ -1,468 +0,0 @@ -Nodeunit -======== - -Simple syntax, powerful tools. Nodeunit provides easy async unit testing for -node.js and the browser. - -* Simple to use -* Just export the tests from a module -* Works with node.js and in the browser -* Helps you avoid common pitfalls when testing asynchronous code -* Easy to add test cases with setUp and tearDown functions if you wish -* Flexible reporters for custom output, built-in support for HTML and jUnit XML -* Allows the use of mocks and stubs - -__Contributors__ - -* [alexgorbatchev](https://github.com/alexgorbatchev) -* [alexkwolfe](https://github.com/alexkwolfe) -* [azatoth](https://github.com/azatoth) -* [kadirpekel](https://github.com/kadirpekel) -* [lambdalisue](https://github.com/lambdalisue) -* [luebken](https://github.com/luebken) -* [orlandov](https://github.com/orlandov) -* [Sannis](https://github.com/Sannis) -* [sstephenson](https://github.com/sstephenson) -* [thegreatape](https://github.com/thegreatape) -* [mmalecki](https://github.com/mmalecki) -* and thanks to [cjohansen](https://github.com/cjohansen) for input and advice - on implementing setUp and tearDown functions. See - [cjohansen's fork](https://github.com/cjohansen/nodeunit). - -Also, check out gerad's [nodeunit-dsl](https://github.com/gerad/nodeunit-dsl) -project, which implements a 'pretty dsl on top of nodeunit'. - -More contributor information can be found in the -[CONTRIBUTORS.md](https://github.com/caolan/nodeunit/blob/master/CONTRIBUTORS.md) -file. - -Usage ------ - -Here is an example unit test module: - - exports.testSomething = function(test){ - test.expect(1); - test.ok(true, "this assertion should pass"); - test.done(); - }; - - exports.testSomethingElse = function(test){ - test.ok(false, "this assertion should fail"); - test.done(); - }; - -When run using the included test runner, this will output the following: - - - -Installation ------------- - -There are two options for installing nodeunit: - -1. Clone / download nodeunit from [github](https://github.com/caolan/nodeunit), - then: - - make && sudo make install - -2. Install via npm: - - npm install nodeunit -g - -API Documentation ------------------ - -Nodeunit uses the functions available in the node.js -[assert module](http://nodejs.org/docs/v0.4.2/api/assert.html): - -* __ok(value, [message])__ - Tests if value is a true value. -* __equal(actual, expected, [message])__ - Tests shallow, coercive equality - with the equal comparison operator ( == ). -* __notEqual(actual, expected, [message])__ - Tests shallow, coercive - non-equality with the not equal comparison operator ( != ). -* __deepEqual(actual, expected, [message])__ - Tests for deep equality. -* __notDeepEqual(actual, expected, [message])__ - Tests for any deep - inequality. -* __strictEqual(actual, expected, [message])__ - Tests strict equality, as - determined by the strict equality operator ( === ) -* __notStrictEqual(actual, expected, [message])__ - Tests strict non-equality, - as determined by the strict not equal operator ( !== ) -* __throws(block, [error], [message])__ - Expects block to throw an error. -* __doesNotThrow(block, [error], [message])__ - Expects block not to throw an - error. -* __ifError(value)__ - Tests if value is not a false value, throws if it is a - true value. Useful when testing the first argument, error in callbacks. - -Nodeunit also provides the following functions within tests: - -* __expect(amount)__ - Specify how many assertions are expected to run within a - test. Very useful for ensuring that all your callbacks and assertions are - run. -* __done()__ - Finish the current test function, and move on to the next. ALL - tests should call this! - -Nodeunit aims to be simple and easy to learn. This is achieved through using -existing structures (such as node.js modules) to maximum effect, and reducing -the API where possible, to make it easier to digest. - -Tests are simply exported from a module, but they are still run in the order -they are defined. - -__Note:__ Users of old nodeunit versions may remember using `ok`, `equals` and -`same` in the style of qunit, instead of the assert functions above. These -functions still exist for backwards compatibility, and are simply aliases to -their assert module counterparts. - - -Asynchronous Testing --------------------- - -When testing asynchronous code, there are a number of sharp edges to watch out -for. Thankfully, nodeunit is designed to help you avoid as many of these -pitfalls as possible. For the most part, testing asynchronous code in nodeunit -_just works_. - - -### Tests run in series - -While running tests in parallel seems like a good idea for speeding up your -test suite, in practice I've found it means writing much more complicated -tests. Because of node's module cache, running tests in parallel means mocking -and stubbing is pretty much impossible. One of the nicest things about testing -in javascript is the ease of doing stubs: - - var _readFile = fs.readFile; - fs.readFile = function(path, callback){ - // it's a stub! - }; - // test function that uses fs.readFile - - // we're done - fs.readFile = _readFile; - -You cannot do this when running tests in parallel. In order to keep testing as -simple as possible, nodeunit avoids it. Thankfully, most unit-test suites run -fast anyway. - - -### Explicit ending of tests - -When testing async code it's important that tests end at the correct point, not -just after a given number of assertions. Otherwise your tests can run short, -ending before all assertions have completed. It's important to detect too -many assertions as well as too few. Combining explicit ending of tests with -an expected number of assertions helps to avoid false test passes, so be sure -to use the `test.expect()` method at the start of your test functions, and -`test.done()` when finished. - - -Groups, setUp and tearDown --------------------------- - -Nodeunit allows the nesting of test functions: - - exports.test1 = function (test) { - ... - } - - exports.group = { - test2: function (test) { - ... - }, - test3: function (test) { - ... - } - } - -This would be run as: - - test1 - group - test2 - group - test3 - -Using these groups, Nodeunit allows you to define a `setUp` function, which is -run before each test, and a `tearDown` function, which is run after each test -calls `test.done()`: - - module.exports = { - setUp: function (callback) { - this.foo = 'bar'; - callback(); - }, - tearDown: function (callback) { - // clean up - callback(); - }, - test1: function (test) { - test.equals(this.foo, 'bar'); - test.done(); - } - }; - -In this way, it's possible to have multiple groups of tests in a module, each -group with its own setUp and tearDown functions. - - -Running Tests -------------- - -Nodeunit comes with a basic command-line test runner, which can be installed -using `sudo make install`. Example usage: - - nodeunit testmodule1.js testfolder [...] - -If no entry file specified, `test` defaults. - -The default test reporter uses color output, because I think that's more fun :) I -intend to add a no-color option in future. To give you a feeling of the fun you'll -be having writing tests, lets fix the example at the start of the README: - - - -Ahhh, Doesn't that feel better? - -When using the included test runner, it will exit using the failed number of -assertions as the exit code. This means it exits with 0 when all tests pass. - - -### Command-line Options - -* __--reporter FILE__ - you can set the test reporter to a custom module or -on of the modules in nodeunit/lib/reporters, when omitted, the default test runner -is used. -* __--list-reporters__ - list available built-in reporters. -* __--config FILE__ - load config options from a JSON file, allows -the customisation of color schemes for the default test reporter etc. See -bin/nodeunit.json for current available options. -* __-t testName__ - run specifc test only. -* __-f fullTestName__ - run specific test only. fullTestName is built so: "outerGroup - .. - innerGroup - testName". -* __--version__ or __-v__ - report nodeunit version -* __--help__ - show nodeunit help - - -Running tests in the browser ----------------------------- - -Nodeunit tests can also be run inside the browser. For example usage, see -the examples/browser folder. The basic syntax is as follows: - -__test.html__ - - - - Example Test Suite - - - - - - -

Example Test Suite

- - - - -Here, `suite1` and `suite2` are just object literals containing test functions -or groups, as would be returned if you did `require('test-suite')` in node.js: - -__suite1.js__ - - this.suite1 = { - 'example test': function (test) { - test.ok(true, 'everything is ok'); - test.done(); - } - }; - -If you wish to use a commonjs format for your test suites (using exports), it is -up to you to define the commonjs tools for the browser. There are a number of -alternatives and it's important it fits with your existing code, which is -why nodeunit does not currently provide this out of the box. - -In the example above, the tests will run when the page is loaded. - -The browser-version of nodeunit.js is created in dist/browser when you do, `make -browser`. You'll need [UglifyJS](https://github.com/mishoo/UglifyJS) installed in -order for it to automatically create nodeunit.min.js. - - -Adding nodeunit to Your Projects --------------------------------- - -If you don't want people to have to install the nodeunit command-line tool, -you'll want to create a script that runs the tests for your project with the -correct require paths set up. Here's an example test script, that assumes you -have nodeunit in a suitably located node_modules directory. - - #!/usr/bin/env node - var reporter = require('nodeunit').reporters.default; - reporter.run(['test']); - -If you're using git, you might find it useful to include nodeunit as a -submodule. Using submodules makes it easy for developers to download nodeunit -and run your test suite, without cluttering up your repository with -the source code. To add nodeunit as a git submodule do the following: - - git submodule add git://github.com/caolan/nodeunit.git node_modules/nodeunit - -This will add nodeunit to the node_modules folder of your project. Now, when -cloning the repository, nodeunit can be downloaded by doing the following: - - git submodule init - git submodule update - -Let's update the test script above with a helpful hint on how to get nodeunit, -if it's missing: - - #!/usr/bin/env node - try { - var reporter = require('nodeunit').reporters.default; - } - catch(e) { - console.log("Cannot find nodeunit module."); - console.log("You can download submodules for this project by doing:"); - console.log(""); - console.log(" git submodule init"); - console.log(" git submodule update"); - console.log(""); - process.exit(); - } - - process.chdir(__dirname); - reporter.run(['test']); - -Now if someone attempts to run your test suite without nodeunit installed they -will be prompted to download the submodules for your project. - - -Built-in Test Reporters ------------------------ - -* __default__ - The standard reporter seen in the nodeunit screenshots -* __minimal__ - Pretty, minimal output, shows errors and progress only -* __html__ - Outputs a HTML report to stdout -* __junit__ - Creates jUnit compatible XML reports, which can be used with - continuous integration tools such as [Hudson](http://hudson-ci.org/). -* __machineout__ - Simple reporter for machine analysis. There is - [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) which is useful for TDD on VIM. - - -Writing a Test Reporter ---------------------- - -Nodeunit exports runTest(fn, options), runModule(mod, options) and -runFiles(paths, options). You'll most likely want to run test suites from -files, which can be done using the latter function. The _options_ argument can -contain callbacks which run during testing. Nodeunit provides the following -callbacks: - -* __moduleStart(name)__ - called before a module is tested -* __moduleDone(name, assertions)__ - called once all test functions within the - module have completed (see assertions object reference below) - ALL tests within the module -* __testStart(name)__ - called before a test function is run -* __testReady(test)__ - called before a test function is run with the test object that will be passed to the test function -* __testDone(name, assertions)__ - called once a test function has completed - (by calling test.done()) -* __log(assertion)__ - called whenever an assertion is made (see assertion - object reference below) -* __done(assertions)__ - called after all tests/modules are complete - -The __assertion__ object: - -* __passed()__ - did the assertion pass? -* __failed()__ - did the assertion fail? -* __error__ - the AssertionError if the assertion failed -* __method__ - the nodeunit assertion method used (ok, same, equals...) -* __message__ - the message the assertion method was called with (optional) - -The __assertionList__ object: - -* An array-like object with the following new attributes: - * __failures()__ - the number of assertions which failed - * __duration__ - the time taken for the test to complete in msecs - -For a reference implementation of a test reporter, see lib/reporters/default.js in -the nodeunit project directory. - - -Sandbox utility ---------------- - -This is a function which evaluates JavaScript files in a sandbox and returns the -context. The sandbox function can be used for testing client-side code or private -un-exported functions within a module. - - var sandbox = require('nodeunit').utils.sandbox; - var example = sandbox('example.js'); - -__sandbox(files, sandbox)__ - Evaluates JavaScript files in a sandbox, returning -the context. The first argument can either be a single filename or an array of -filenames. If multiple filenames are given their contents are concatenated before -evaluation. The second argument is an optional context to use for the sandbox. - -Note: When working with the sandbox if your script depends on outside sources -(i.e. using `require`) then you will want to pass that into the optional -context when setting up the sandbox. - - var sandbox = require('nodeunit').utils.sandbox; - // pass in some node globals - var box_globals = { - // Passing module.exports into the sandbox will give your code access to it. - module: {exports: exports}, - // Passing require into the sandbox will give your code access to use it AND - // will share the cache with modules already required from outside the sandbox. - require: require, - // Passing console into the sandbox will give your code access to it - console: console - }; - var example = sandbox('example.js', box_globals); - - -Running the nodeunit Tests --------------------------- - -The tests for nodeunit are written using nodeunit itself as the test framework. -However, the module test-base.js first does some basic tests using the assert -module to ensure that test functions are actually run, and a basic level of -nodeunit functionality is available. - -To run the nodeunit tests do: - - make test - -__Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading -to v0.2.1 fixes this. - - -__machineout__ reporter ----------------------------------------------- - -The default reporter is readable for human but not for machine analysis. -When you want to analyze the output of nodeunit, use __machineout__ reporter and you will get - - - - -nodeunit with vim ----------------------------------- -There is [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) so you can use -nodeunit with VIM. - -That compiler uses __machineout__ reporter and it is useful to use -with [vim-makegreen](https://github.com/reinh/vim-makegreen). - - - -Contributing ------------- - -Contributions to the project are most welcome, so feel free to fork and improve. -When submitting a pull request, please run `make lint` first to ensure -we're following a consistent coding style. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit deleted file mode 100755 index e3e15b5..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env node - -var - fs = require('fs'), - path = require('path'); - -// TODO: remove this when https://github.com/joyent/node/pull/1312 -// lands in core. -// -// Until then, use console.log from npm (https://gist.github.com/1077544) -require('../deps/console.log'); - -//require.paths.push(process.cwd()); -var args = (process.ARGV || process.argv).slice(2); - -var files = []; - -var testrunner, - config_file, - config_param_found = false, - output_param_found = false, - reporter_file = 'default', - reporter_param_found = false, - testspec_param_found = false; - testFullSpec_param_found = false; - -var usage = "Usage: nodeunit [options] testmodule1.js testfolder [...] \n" + - "Options:\n\n" + - " --config FILE the path to a JSON file with options\n" + - " --reporter FILE optional path to a reporter file to customize the output\n" + - " --list-reporters list available build-in reporters\n" + - " -t testName, specify a test to run\n" + - " -f fullTestName, specify a specific test to run. fullTestName is built so: \"outerGroup - .. - innerGroup - testName\"\n" + - " -h, --help display this help and exit\n" + - " -v, --version output version information and exit"; - - - -// load default options -var content = fs.readFileSync(__dirname + '/nodeunit.json', 'utf8'); -var options = JSON.parse(content); - -// a very basic pseudo --options parser -args.forEach(function (arg) { - if (arg.slice(0, 9) === "--config=") { - config_file = arg.slice(9); - } else if (arg === '--config') { - config_param_found = true; - } else if (config_param_found) { - config_file = arg; - config_param_found = false; - } else if (arg.slice(0, 9) === "--output=") { - options.output = arg.slice(9); - } else if (arg === '--output') { - output_param_found = true; - } else if (output_param_found) { - options.output = arg; - output_param_found = false; - } else if (arg.slice(0, 11) === "--reporter=") { - reporter_file = arg.slice(11); - } else if (arg === '--reporter') { - reporter_param_found = true; - } else if (reporter_param_found) { - reporter_file = arg; - reporter_param_found = false; - } else if (arg === '-t') { - testspec_param_found = true; - } else if (testspec_param_found) { - options.testspec = arg; - testspec_param_found = false; - } else if (arg === '-f') { - testFullSpec_param_found = true; - } else if (testFullSpec_param_found) { - options.testFullSpec= arg; - testFullSpec_param_found = false; - } else if (arg === '--list-reporters') { - var reporters = fs.readdirSync(__dirname + '/../lib/reporters'); - reporters = reporters.filter(function (reporter_file) { - return (/\.js$/).test(reporter_file); - }).map(function (reporter_file) { - return reporter_file.replace(/\.js$/, ''); - }).filter(function (reporter_file) { - return reporter_file !== 'index'; - }); - console.log('Build-in reporters: '); - reporters.forEach(function (reporter_file) { - var reporter = require('../lib/reporters/' + reporter_file); - console.log(' * ' + reporter_file + (reporter.info ? ': ' + reporter.info : '')); - }); - process.exit(0); - } else if ((arg === '-v') || (arg === '--version')) { - var content = fs.readFileSync(__dirname + '/../package.json', 'utf8'); - var pkg = JSON.parse(content); - console.log(pkg.version); - process.exit(0); - } else if ((arg === '-h') || (arg === '--help')) { - console.log(usage); - process.exit(0); - } else { - files.push(arg); - } -}); - -// defaults to `test` -if (files.length === 0) { - files = ['test']; -} - -if (config_file) { - content = fs.readFileSync(config_file, 'utf8'); - var custom_options = JSON.parse(content); - - for (var option in custom_options) { - if (typeof option === 'string') { - options[option] = custom_options[option]; - } - } -} - -var builtin_reporters = require(__dirname + '/../lib/reporters'); -if (reporter_file in builtin_reporters) { - testrunner = builtin_reporters[reporter_file]; -} -else { - testrunner = require(reporter_file); -} - -testrunner.run(files, options, function(err) { - if (err) { - process.exit(1); - } -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit.json deleted file mode 100644 index 5c7778f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/bin/nodeunit.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "error_prefix": "\u001B[31m", - "error_suffix": "\u001B[39m", - "ok_prefix": "\u001B[32m", - "ok_suffix": "\u001B[39m", - "bold_prefix": "\u001B[1m", - "bold_suffix": "\u001B[22m", - "assertion_prefix": "\u001B[35m", - "assertion_suffix": "\u001B[39m" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/async.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/async.js deleted file mode 100644 index f65be61..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/async.js +++ /dev/null @@ -1,628 +0,0 @@ -/*global setTimeout: false, console: false */ -(function () { - - var async = {}; - - // global on the server, window in the browser - var root = this, - previous_async = root.async; - - if (typeof module !== 'undefined' && module.exports) { - module.exports = async; - } - else { - root.async = async; - } - - async.noConflict = function () { - root.async = previous_async; - return async; - }; - - //// cross-browser compatiblity functions //// - - var _forEach = function (arr, iterator) { - if (arr.forEach) { - return arr.forEach(iterator); - } - for (var i = 0; i < arr.length; i += 1) { - iterator(arr[i], i, arr); - } - }; - - var _map = function (arr, iterator) { - if (arr.map) { - return arr.map(iterator); - } - var results = []; - _forEach(arr, function (x, i, a) { - results.push(iterator(x, i, a)); - }); - return results; - }; - - var _reduce = function (arr, iterator, memo) { - if (arr.reduce) { - return arr.reduce(iterator, memo); - } - _forEach(arr, function (x, i, a) { - memo = iterator(memo, x, i, a); - }); - return memo; - }; - - var _keys = function (obj) { - if (Object.keys) { - return Object.keys(obj); - } - var keys = []; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - keys.push(k); - } - } - return keys; - }; - - var _indexOf = function (arr, item) { - if (arr.indexOf) { - return arr.indexOf(item); - } - for (var i = 0; i < arr.length; i += 1) { - if (arr[i] === item) { - return i; - } - } - return -1; - }; - - //// exported async module functions //// - - //// nextTick implementation with browser-compatible fallback //// - if (typeof setImmediate === 'function') { - async.nextTick = function (fn) { - setImmediate(fn); - }; - } - else if (typeof process !== 'undefined' && process.nextTick) { - async.nextTick = process.nextTick; - } - else { - async.nextTick = function (fn) { - setTimeout(fn, 0); - }; - } - - async.forEach = function (arr, iterator, callback) { - if (!arr.length) { - return callback(); - } - var completed = 0; - _forEach(arr, function (x) { - iterator(x, function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed === arr.length) { - callback(); - } - } - }); - }); - }; - - async.forEachSeries = function (arr, iterator, callback) { - if (!arr.length) { - return callback(); - } - var completed = 0; - var iterate = function () { - iterator(arr[completed], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed === arr.length) { - callback(); - } - else { - iterate(); - } - } - }); - }; - iterate(); - }; - - - var doParallel = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.forEach].concat(args)); - }; - }; - var doSeries = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.forEachSeries].concat(args)); - }; - }; - - - var _asyncMap = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (err, v) { - results[x.index] = v; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - }; - async.map = doParallel(_asyncMap); - async.mapSeries = doSeries(_asyncMap); - - - // reduce only has a series version, as doing reduce in parallel won't - // work in many situations. - async.reduce = function (arr, memo, iterator, callback) { - async.forEachSeries(arr, function (x, callback) { - iterator(memo, x, function (err, v) { - memo = v; - callback(err); - }); - }, function (err) { - callback(err, memo); - }); - }; - // inject alias - async.inject = async.reduce; - // foldl alias - async.foldl = async.reduce; - - async.reduceRight = function (arr, memo, iterator, callback) { - var reversed = _map(arr, function (x) { - return x; - }).reverse(); - async.reduce(reversed, memo, iterator, callback); - }; - // foldr alias - async.foldr = async.reduceRight; - - var _filter = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.filter = doParallel(_filter); - async.filterSeries = doSeries(_filter); - // select alias - async.select = async.filter; - async.selectSeries = async.filterSeries; - - var _reject = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (!v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.reject = doParallel(_reject); - async.rejectSeries = doSeries(_reject); - - var _detect = function (eachfn, arr, iterator, main_callback) { - eachfn(arr, function (x, callback) { - iterator(x, function (result) { - if (result) { - main_callback(x); - } - else { - callback(); - } - }); - }, function (err) { - main_callback(); - }); - }; - async.detect = doParallel(_detect); - async.detectSeries = doSeries(_detect); - - async.some = function (arr, iterator, main_callback) { - async.forEach(arr, function (x, callback) { - iterator(x, function (v) { - if (v) { - main_callback(true); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(false); - }); - }; - // any alias - async.any = async.some; - - async.every = function (arr, iterator, main_callback) { - async.forEach(arr, function (x, callback) { - iterator(x, function (v) { - if (!v) { - main_callback(false); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(true); - }); - }; - // all alias - async.all = async.every; - - async.sortBy = function (arr, iterator, callback) { - async.map(arr, function (x, callback) { - iterator(x, function (err, criteria) { - if (err) { - callback(err); - } - else { - callback(null, {value: x, criteria: criteria}); - } - }); - }, function (err, results) { - if (err) { - return callback(err); - } - else { - var fn = function (left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }; - callback(null, _map(results.sort(fn), function (x) { - return x.value; - })); - } - }); - }; - - async.auto = function (tasks, callback) { - callback = callback || function () {}; - var keys = _keys(tasks); - if (!keys.length) { - return callback(null); - } - - var completed = []; - - var listeners = []; - var addListener = function (fn) { - listeners.unshift(fn); - }; - var removeListener = function (fn) { - for (var i = 0; i < listeners.length; i += 1) { - if (listeners[i] === fn) { - listeners.splice(i, 1); - return; - } - } - }; - var taskComplete = function () { - _forEach(listeners, function (fn) { - fn(); - }); - }; - - addListener(function () { - if (completed.length === keys.length) { - callback(null); - } - }); - - _forEach(keys, function (k) { - var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; - var taskCallback = function (err) { - if (err) { - callback(err); - // stop subsequent errors hitting callback multiple times - callback = function () {}; - } - else { - completed.push(k); - taskComplete(); - } - }; - var requires = task.slice(0, Math.abs(task.length - 1)) || []; - var ready = function () { - return _reduce(requires, function (a, x) { - return (a && _indexOf(completed, x) !== -1); - }, true); - }; - if (ready()) { - task[task.length - 1](taskCallback); - } - else { - var listener = function () { - if (ready()) { - removeListener(listener); - task[task.length - 1](taskCallback); - } - }; - addListener(listener); - } - }); - }; - - async.waterfall = function (tasks, callback) { - if (!tasks.length) { - return callback(); - } - callback = callback || function () {}; - var wrapIterator = function (iterator) { - return function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - var args = Array.prototype.slice.call(arguments, 1); - var next = iterator.next(); - if (next) { - args.push(wrapIterator(next)); - } - else { - args.push(callback); - } - async.nextTick(function () { - iterator.apply(null, args); - }); - } - }; - }; - wrapIterator(async.iterator(tasks))(); - }; - - async.parallel = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.map(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args || null); - }); - } - }, callback); - } - else { - var results = {}; - async.forEach(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.series = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.mapSeries(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args || null); - }); - } - }, callback); - } - else { - var results = {}; - async.forEachSeries(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.iterator = function (tasks) { - var makeCallback = function (index) { - var fn = function () { - if (tasks.length) { - tasks[index].apply(null, arguments); - } - return fn.next(); - }; - fn.next = function () { - return (index < tasks.length - 1) ? makeCallback(index + 1): null; - }; - return fn; - }; - return makeCallback(0); - }; - - async.apply = function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - return function () { - return fn.apply( - null, args.concat(Array.prototype.slice.call(arguments)) - ); - }; - }; - - var _concat = function (eachfn, arr, fn, callback) { - var r = []; - eachfn(arr, function (x, cb) { - fn(x, function (err, y) { - r = r.concat(y || []); - cb(err); - }); - }, function (err) { - callback(err, r); - }); - }; - async.concat = doParallel(_concat); - async.concatSeries = doSeries(_concat); - - async.whilst = function (test, iterator, callback) { - if (test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.whilst(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.until = function (test, iterator, callback) { - if (!test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.until(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.queue = function (worker, concurrency) { - var workers = 0; - var tasks = []; - var q = { - concurrency: concurrency, - push: function (data, callback) { - tasks.push({data: data, callback: callback}); - async.nextTick(q.process); - }, - process: function () { - if (workers < q.concurrency && tasks.length) { - var task = tasks.splice(0, 1)[0]; - workers += 1; - worker(task.data, function () { - workers -= 1; - if (task.callback) { - task.callback.apply(task, arguments); - } - q.process(); - }); - } - }, - length: function () { - return tasks.length; - } - }; - return q; - }; - - var _console_fn = function (name) { - return function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - fn.apply(null, args.concat([function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (typeof console !== 'undefined') { - if (err) { - if (console.error) { - console.error(err); - } - } - else if (console[name]) { - _forEach(args, function (x) { - console[name](x); - }); - } - } - }])); - }; - }; - async.log = _console_fn('log'); - async.dir = _console_fn('dir'); - /*async.info = _console_fn('info'); - async.warn = _console_fn('warn'); - async.error = _console_fn('error');*/ - - async.memoize = function (fn, hasher) { - var memo = {}; - hasher = hasher || function (x) { - return x; - }; - return function () { - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - var key = hasher.apply(null, args); - if (key in memo) { - callback.apply(null, memo[key]); - } - else { - fn.apply(null, args.concat([function () { - memo[key] = arguments; - callback.apply(null, arguments); - }])); - } - }; - }; - -}()); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/console.log.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/console.log.js deleted file mode 100644 index fe146c1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/console.log.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - A console.log that won't leave you hanging when node exits - 90% of this file was ripped from node.js - - License: see: https://github.com/joyent/node/blob/master/lib/console.js - */ - - // console object -var formatRegExp = /%[sdj]/g; -function format(f) { - var util = require('util'); - - if (typeof f !== 'string') { - var objects = []; - for (var i = 0; i < arguments.length; i++) { - objects.push(util.inspect(arguments[i])); - } - return objects.join(' '); - } - - - var i = 1; - var args = arguments; - var str = String(f).replace(formatRegExp, function(x) { - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': return JSON.stringify(args[i++]); - default: - return x; - } - }); - for (var len = args.length, x = args[i]; i < len; x = args[++i]) { - if (x === null || typeof x !== 'object') { - str += ' ' + x; - } else { - str += ' ' + util.inspect(x); - } - } - return str; -} - -console.log = function() { - var res = process.stdout.write(format.apply(this, arguments) + '\n'); - - // this is the first time stdout got backed up - if (!res && !process.stdout.pendingWrite) { - process.stdout.pendingWrite = true; - - // magic sauce: keep node alive until stdout has flushed - process.stdout.once('drain', function () { - process.stdout.draining = false; - }); - } -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/History.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/History.md deleted file mode 100644 index 00d2b5b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/History.md +++ /dev/null @@ -1,70 +0,0 @@ - -0.4.3 / 2011-06-20 -================== - - * Fixed stacktraces line number when used multiline js expressions [Octave] - -0.4.2 / 2011-05-11 -================== - - * Added client side support - -0.4.1 / 2011-04-21 -================== - - * Fixed error context - -0.4.0 / 2011-04-21 -================== - - * Added; ported jade's error reporting to ejs. [slaskis] - -0.3.1 / 2011-02-23 -================== - - * Fixed optional `compile()` options - -0.3.0 / 2011-02-14 -================== - - * Added 'json' filter [Yuriy Bogdanov] - * Use exported version of parse function to allow monkey-patching [Anatoliy Chakkaev] - -0.2.1 / 2010-10-07 -================== - - * Added filter support - * Fixed _cache_ option. ~4x performance increase - -0.2.0 / 2010-08-05 -================== - - * Added support for global tag config - * Added custom tag support. Closes #5 - * Fixed whitespace bug. Closes #4 - -0.1.0 / 2010-08-04 -================== - - * Faster implementation [ashleydev] - -0.0.4 / 2010-08-02 -================== - - * Fixed single quotes for content outside of template tags. [aniero] - * Changed; `exports.compile()` now expects only "locals" - -0.0.3 / 2010-07-15 -================== - - * Fixed single quotes - -0.0.2 / 2010-07-09 -================== - - * Fixed newline preservation - -0.0.1 / 2010-07-09 -================== - - * Initial release diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Makefile b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Makefile deleted file mode 100644 index a8b00d9..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -SRC = $(shell find lib -name "*.js" -type f) -UGLIFY_FLAGS = --no-mangle - -test: - @./node_modules/.bin/expresso test/*.test.js - -ejs.js: $(SRC) - @node support/compile.js $^ - -ejs.min.js: ejs.js - @uglifyjs $(UGLIFY_FLAGS) $< > $@ \ - && du ejs.min.js \ - && du ejs.js - -clean: - rm -f ejs.js - rm -f ejs.min.js - -.PHONY: test \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Readme.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Readme.md deleted file mode 100644 index 58cb10a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/Readme.md +++ /dev/null @@ -1,152 +0,0 @@ - -# EJS - -Embedded JavaScript templates. - -## Installation - - $ npm install ejs - -## Features - - * Complies with the [Express](http://expressjs.com) view system - * Static caching of intermediate JavaScript - * Unbuffered code for conditionals etc `<% code %>` - * Escapes html by default with `<%= code %>` - * Unescaped buffering with `<%- code %>` - * Supports tag customization - * Filter support for designer-friendly templates - * Client-side support - -## Example - - <% if (user) { %> -

<%= user.name %>

- <% } %> - -## Usage - - ejs.compile(str, options); - // => Function - - ejs.render(str, options); - // => str - -## Options - - - `locals` Local variables object - - `cache` Compiled functions are cached, requires `filename` - - `filename` Used by `cache` to key caches - - `scope` Function execution context - - `debug` Output generated function body - - `open` Open tag, defaulting to "<%" - - `close` Closing tag, defaulting to "%>" - -## Custom tags - -Custom tags can also be applied globally: - - var ejs = require('ejs'); - ejs.open = '{{'; - ejs.close = '}}'; - -Which would make the following a valid template: - -

{{= title }}

- -## Filters - -EJS conditionally supports the concept of "filters". A "filter chain" -is a designer friendly api for manipulating data, without writing JavaScript. - -Filters can be applied by supplying the _:_ modifier, so for example if we wish to take the array `[{ name: 'tj' }, { name: 'mape' }, { name: 'guillermo' }]` and output a list of names we can do this simply with filters: - -Template: - -

<%=: users | map:'name' | join %>

- -Output: - -

Tj, Mape, Guillermo

- -Render call: - - ejs.render(str, { - locals: { - users: [ - { name: 'tj' }, - { name: 'mape' }, - { name: 'guillermo' } - ] - } - }); - -Or perhaps capitalize the first user's name for display: - -

<%=: users | first | capitalize %>

- -## Filter list - -Currently these filters are available: - - - first - - last - - capitalize - - downcase - - upcase - - sort - - sort_by:'prop' - - size - - length - - plus:n - - minus:n - - times:n - - divided_by:n - - join:'val' - - truncate:n - - truncate_words:n - - replace:pattern,substitution - - prepend:val - - append:val - - map:'prop' - - reverse - - get:'prop' - -## Adding filters - - To add a filter simply add a method to the `.filters` object: - -```js -ejs.filters.last = function(obj) { - return obj[obj.length - 1]; -}; -``` - -## client-side support - - include `./ejs.js` or `./ejs.min.js` and `require("ejs").compile(str)`. - -## License - -(The MIT License) - -Copyright (c) 2009-2010 TJ Holowaychuk <tj@vision-media.ca> - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/benchmark.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/benchmark.js deleted file mode 100644 index 7b267e1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/benchmark.js +++ /dev/null @@ -1,14 +0,0 @@ - - -var ejs = require('./lib/ejs'), - str = '<% if (foo) { %>

<%= foo %>

<% } %>', - times = 50000; - -console.log('rendering ' + times + ' times'); - -var start = new Date; -while (times--) { - ejs.render(str, { cache: true, filename: 'test', locals: { foo: 'bar' }}); -} - -console.log('took ' + (new Date - start) + 'ms'); \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.js deleted file mode 100644 index b8c6aa1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.js +++ /dev/null @@ -1,531 +0,0 @@ - -// CommonJS require() - -function require(p){ - var path = require.resolve(p) - , mod = require.modules[path]; - if (!mod) throw new Error('failed to require "' + p + '"'); - if (!mod.exports) { - mod.exports = {}; - mod.call(mod.exports, mod, mod.exports, require.relative(path)); - } - return mod.exports; - } - -require.modules = {}; - -require.resolve = function (path){ - var orig = path - , reg = path + '.js' - , index = path + '/index.js'; - return require.modules[reg] && reg - || require.modules[index] && index - || orig; - }; - -require.register = function (path, fn){ - require.modules[path] = fn; - }; - -require.relative = function (parent) { - return function(p){ - if ('.' != p[0]) return require(p); - - var path = parent.split('/') - , segs = p.split('/'); - path.pop(); - - for (var i = 0; i < segs.length; i++) { - var seg = segs[i]; - if ('..' == seg) path.pop(); - else if ('.' != seg) path.push(seg); - } - - return require(path.join('/')); - }; - }; - - -require.register("ejs.js", function(module, exports, require){ - -/*! - * EJS - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var utils = require('./utils'); - -/** - * Library version. - */ - -exports.version = '0.4.2'; - -/** - * Filters. - * - * @type Object - */ - -var filters = exports.filters = require('./filters'); - -/** - * Intermediate js cache. - * - * @type Object - */ - -var cache = {}; - -/** - * Clear intermediate js cache. - * - * @api public - */ - -exports.clearCache = function(){ - cache = {}; -}; - -/** - * Translate filtered code into function calls. - * - * @param {String} js - * @return {String} - * @api private - */ - -function filtered(js) { - return js.substr(1).split('|').reduce(function(js, filter){ - var parts = filter.split(':') - , name = parts.shift() - , args = parts.shift() || ''; - if (args) args = ', ' + args; - return 'filters.' + name + '(' + js + args + ')'; - }); -}; - -/** - * Re-throw the given `err` in context to the - * `str` of ejs, `filename`, and `lineno`. - * - * @param {Error} err - * @param {String} str - * @param {String} filename - * @param {String} lineno - * @api private - */ - -function rethrow(err, str, filename, lineno){ - var lines = str.split('\n') - , start = Math.max(lineno - 3, 0) - , end = Math.min(lines.length, lineno + 3); - - // Error context - var context = lines.slice(start, end).map(function(line, i){ - var curr = i + start + 1; - return (curr == lineno ? ' >> ' : ' ') - + curr - + '| ' - + line; - }).join('\n'); - - // Alter exception message - err.path = filename; - err.message = (filename || 'ejs') + ':' - + lineno + '\n' - + context + '\n\n' - + err.message; - - throw err; -} - -/** - * Parse the given `str` of ejs, returning the function body. - * - * @param {String} str - * @return {String} - * @api public - */ - -var parse = exports.parse = function(str, options){ - var options = options || {} - , open = options.open || exports.open || '<%' - , close = options.close || exports.close || '%>'; - - var buf = [ - "var buf = [];" - , "\nwith (locals) {" - , "\n buf.push('" - ]; - - var lineno = 1; - - for (var i = 0, len = str.length; i < len; ++i) { - if (str.slice(i, open.length + i) == open) { - i += open.length - - var prefix, postfix, line = '__stack.lineno=' + lineno; - switch (str[i]) { - case '=': - prefix = "', escape((" + line + ', '; - postfix = ")), '"; - ++i; - break; - case '-': - prefix = "', (" + line + ', '; - postfix = "), '"; - ++i; - break; - default: - prefix = "');" + line + ';'; - postfix = "; buf.push('"; - } - - var start = i; - var end = str.indexOf(close, i); - var js = str.substring(i, end); - var n = 0; - while ((n = js.indexOf("\n", n)) > -1) { - n++; - lineno++; - } - if (js[0] == ':') js = filtered(js); - buf.push(prefix, js, postfix); - i += end - start + close.length - 1; - - } else if (str[i] == "\\") { - buf.push("\\\\"); - } else if (str[i] == "'") { - buf.push("\\'"); - } else if (str[i] == "\r") { - buf.push(" "); - } else if (str[i] == "\n") { - buf.push("\\n"); - lineno++; - } else { - buf.push(str[i]); - } - } - - buf.push("');\n}\nreturn buf.join('');"); - return buf.join(''); -}; - -/** - * Compile the given `str` of ejs into a `Function`. - * - * @param {String} str - * @param {Object} options - * @return {Function} - * @api public - */ - -var compile = exports.compile = function(str, options){ - options = options || {}; - - var input = JSON.stringify(str) - , filename = options.filename - ? JSON.stringify(options.filename) - : 'undefined'; - - // Adds the fancy stack trace meta info - str = [ - 'var __stack = { lineno: 1, input: ' + input + ', filename: ' + filename + ' };', - rethrow.toString(), - 'try {', - exports.parse(str, options), - '} catch (err) {', - ' rethrow(err, __stack.input, __stack.filename, __stack.lineno);', - '}' - ].join("\n"); - - if (options.debug) console.log(str); - var fn = new Function('locals, filters, escape', str); - return function(locals){ - return fn.call(this, locals, filters, utils.escape); - } -}; - -/** - * Render the given `str` of ejs. - * - * Options: - * - * - `locals` Local variables object - * - `cache` Compiled functions are cached, requires `filename` - * - `filename` Used by `cache` to key caches - * - `scope` Function execution context - * - `debug` Output generated function body - * - `open` Open tag, defaulting to "<%" - * - `close` Closing tag, defaulting to "%>" - * - * @param {String} str - * @param {Object} options - * @return {String} - * @api public - */ - -exports.render = function(str, options){ - var fn - , options = options || {}; - if (options.cache) { - if (options.filename) { - fn = cache[options.filename] || (cache[options.filename] = compile(str, options)); - } else { - throw new Error('"cache" option requires "filename".'); - } - } else { - fn = compile(str, options); - } - return fn.call(options.scope, options.locals || {}); -}; - -/** - * Expose to require(). - */ - -if (require.extensions) { - require.extensions['.ejs'] = function(module, filename) { - source = require('fs').readFileSync(filename, 'utf-8'); - module._compile(compile(source, {}), filename); - }; -} else if (require.registerExtension) { - require.registerExtension('.ejs', function(src) { - return compile(src, {}); - }); -} - -}); // module: ejs.js - -require.register("filters.js", function(module, exports, require){ - -/*! - * EJS - Filters - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * First element of the target `obj`. - */ - -exports.first = function(obj) { - return obj[0]; -}; - -/** - * Last element of the target `obj`. - */ - -exports.last = function(obj) { - return obj[obj.length - 1]; -}; - -/** - * Capitalize the first letter of the target `str`. - */ - -exports.capitalize = function(str){ - str = String(str); - return str[0].toUpperCase() + str.substr(1, str.length); -}; - -/** - * Downcase the target `str`. - */ - -exports.downcase = function(str){ - return String(str).toLowerCase(); -}; - -/** - * Uppercase the target `str`. - */ - -exports.upcase = function(str){ - return String(str).toUpperCase(); -}; - -/** - * Sort the target `obj`. - */ - -exports.sort = function(obj){ - return Object.create(obj).sort(); -}; - -/** - * Sort the target `obj` by the given `prop` ascending. - */ - -exports.sort_by = function(obj, prop){ - return Object.create(obj).sort(function(a, b){ - a = a[prop], b = b[prop]; - if (a > b) return 1; - if (a < b) return -1; - return 0; - }); -}; - -/** - * Size or length of the target `obj`. - */ - -exports.size = exports.length = function(obj) { - return obj.length; -}; - -/** - * Add `a` and `b`. - */ - -exports.plus = function(a, b){ - return Number(a) + Number(b); -}; - -/** - * Subtract `b` from `a`. - */ - -exports.minus = function(a, b){ - return Number(a) - Number(b); -}; - -/** - * Multiply `a` by `b`. - */ - -exports.times = function(a, b){ - return Number(a) * Number(b); -}; - -/** - * Divide `a` by `b`. - */ - -exports.divided_by = function(a, b){ - return Number(a) / Number(b); -}; - -/** - * Join `obj` with the given `str`. - */ - -exports.join = function(obj, str){ - return obj.join(str || ', '); -}; - -/** - * Truncate `str` to `len`. - */ - -exports.truncate = function(str, len){ - str = String(str); - return str.substr(0, len); -}; - -/** - * Truncate `str` to `n` words. - */ - -exports.truncate_words = function(str, n){ - var str = String(str) - , words = str.split(/ +/); - return words.slice(0, n).join(' '); -}; - -/** - * Replace `pattern` with `substitution` in `str`. - */ - -exports.replace = function(str, pattern, substitution){ - return String(str).replace(pattern, substitution || ''); -}; - -/** - * Prepend `val` to `obj`. - */ - -exports.prepend = function(obj, val){ - return Array.isArray(obj) - ? [val].concat(obj) - : val + obj; -}; - -/** - * Append `val` to `obj`. - */ - -exports.append = function(obj, val){ - return Array.isArray(obj) - ? obj.concat(val) - : obj + val; -}; - -/** - * Map the given `prop`. - */ - -exports.map = function(arr, prop){ - return arr.map(function(obj){ - return obj[prop]; - }); -}; - -/** - * Reverse the given `obj`. - */ - -exports.reverse = function(obj){ - return Array.isArray(obj) - ? obj.reverse() - : String(obj).split('').reverse().join(''); -}; - -/** - * Get `prop` of the given `obj`. - */ - -exports.get = function(obj, prop){ - return obj[prop]; -}; - -/** - * Packs the given `obj` into json string - */ -exports.json = function(obj){ - return JSON.stringify(obj); -}; -}); // module: filters.js - -require.register("utils.js", function(module, exports, require){ - -/*! - * EJS - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Escape the given string of `html`. - * - * @param {String} html - * @return {String} - * @api private - */ - -exports.escape = function(html){ - return String(html) - .replace(/&(?!\w+;)/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); -}; - -}); // module: utils.js diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.min.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.min.js deleted file mode 100644 index 6b72d94..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/ejs.min.js +++ /dev/null @@ -1,2 +0,0 @@ -// CommonJS require() -function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');mod.exports||(mod.exports={},mod.call(mod.exports,mod,mod.exports,require.relative(path)));return mod.exports}require.modules={},require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&®||require.modules[index]&&index||orig},require.register=function(path,fn){require.modules[path]=fn},require.relative=function(parent){return function(p){if("."!=p[0])return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i> ":" ")+curr+"| "+line}).join("\n");err.path=filename,err.message=(filename||"ejs")+":"+lineno+"\n"+context+"\n\n"+err.message;throw err}var parse=exports.parse=function(str,options){var options=options||{},open=options.open||exports.open||"<%",close=options.close||exports.close||"%>",buf=["var buf = [];","\nwith (locals) {","\n buf.push('"],lineno=1;for(var i=0,len=str.length;ib)return 1;if(a/g,">").replace(/"/g,""")}}) \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/client.html b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/client.html deleted file mode 100644 index 7081a04..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/client.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.ejs b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.ejs deleted file mode 100644 index d571330..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.ejs +++ /dev/null @@ -1,7 +0,0 @@ -<% if (names.length) { %> -
    - <% names.forEach(function(name){ %> -
  • <%= name %>
  • - <% }) %> -
-<% } %> \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.js deleted file mode 100644 index 9cd7168..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/examples/list.js +++ /dev/null @@ -1,16 +0,0 @@ - -/** - * Module dependencies. - */ - -var ejs = require('../') - , fs = require('fs') - , str = fs.readFileSync(__dirname + '/list.ejs', 'utf8'); - -var ret = ejs.render(str, { - locals: { - names: ['foo', 'bar', 'baz'] - } -}); - -console.log(ret); \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/index.js deleted file mode 100644 index 20bf71a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/index.js +++ /dev/null @@ -1,2 +0,0 @@ - -module.exports = require('./lib/ejs'); \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/ejs.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/ejs.js deleted file mode 100644 index 46afa74..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/ejs.js +++ /dev/null @@ -1,251 +0,0 @@ - -/*! - * EJS - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var utils = require('./utils'); - -/** - * Library version. - */ - -exports.version = '0.4.3'; - -/** - * Filters. - * - * @type Object - */ - -var filters = exports.filters = require('./filters'); - -/** - * Intermediate js cache. - * - * @type Object - */ - -var cache = {}; - -/** - * Clear intermediate js cache. - * - * @api public - */ - -exports.clearCache = function(){ - cache = {}; -}; - -/** - * Translate filtered code into function calls. - * - * @param {String} js - * @return {String} - * @api private - */ - -function filtered(js) { - return js.substr(1).split('|').reduce(function(js, filter){ - var parts = filter.split(':') - , name = parts.shift() - , args = parts.shift() || ''; - if (args) args = ', ' + args; - return 'filters.' + name + '(' + js + args + ')'; - }); -}; - -/** - * Re-throw the given `err` in context to the - * `str` of ejs, `filename`, and `lineno`. - * - * @param {Error} err - * @param {String} str - * @param {String} filename - * @param {String} lineno - * @api private - */ - -function rethrow(err, str, filename, lineno){ - var lines = str.split('\n') - , start = Math.max(lineno - 3, 0) - , end = Math.min(lines.length, lineno + 3); - - // Error context - var context = lines.slice(start, end).map(function(line, i){ - var curr = i + start + 1; - return (curr == lineno ? ' >> ' : ' ') - + curr - + '| ' - + line; - }).join('\n'); - - // Alter exception message - err.path = filename; - err.message = (filename || 'ejs') + ':' - + lineno + '\n' - + context + '\n\n' - + err.message; - - throw err; -} - -/** - * Parse the given `str` of ejs, returning the function body. - * - * @param {String} str - * @return {String} - * @api public - */ - -var parse = exports.parse = function(str, options){ - var options = options || {} - , open = options.open || exports.open || '<%' - , close = options.close || exports.close || '%>'; - - var buf = [ - "var buf = [];" - , "\nwith (locals) {" - , "\n buf.push('" - ]; - - var lineno = 1; - - for (var i = 0, len = str.length; i < len; ++i) { - if (str.slice(i, open.length + i) == open) { - i += open.length - - var prefix, postfix, line = '__stack.lineno=' + lineno; - switch (str.substr(i, 1)) { - case '=': - prefix = "', escape((" + line + ', '; - postfix = ")), '"; - ++i; - break; - case '-': - prefix = "', (" + line + ', '; - postfix = "), '"; - ++i; - break; - default: - prefix = "');" + line + ';'; - postfix = "; buf.push('"; - } - - var end = str.indexOf(close, i) - , js = str.substring(i, end) - , start = i - , n = 0; - - while (~(n = js.indexOf("\n", n))) n++, lineno++; - if (js.substr(0, 1) == ':') js = filtered(js); - buf.push(prefix, js, postfix); - i += end - start + close.length - 1; - - } else if (str.substr(i, 1) == "\\") { - buf.push("\\\\"); - } else if (str.substr(i, 1) == "'") { - buf.push("\\'"); - } else if (str.substr(i, 1) == "\r") { - buf.push(" "); - } else if (str.substr(i, 1) == "\n") { - buf.push("\\n"); - lineno++; - } else { - buf.push(str.substr(i, 1)); - } - } - - buf.push("');\n}\nreturn buf.join('');"); - return buf.join(''); -}; - -/** - * Compile the given `str` of ejs into a `Function`. - * - * @param {String} str - * @param {Object} options - * @return {Function} - * @api public - */ - -var compile = exports.compile = function(str, options){ - options = options || {}; - - var input = JSON.stringify(str) - , filename = options.filename - ? JSON.stringify(options.filename) - : 'undefined'; - - // Adds the fancy stack trace meta info - str = [ - 'var __stack = { lineno: 1, input: ' + input + ', filename: ' + filename + ' };', - rethrow.toString(), - 'try {', - exports.parse(str, options), - '} catch (err) {', - ' rethrow(err, __stack.input, __stack.filename, __stack.lineno);', - '}' - ].join("\n"); - - if (options.debug) console.log(str); - var fn = new Function('locals, filters, escape', str); - return function(locals){ - return fn.call(this, locals, filters, utils.escape); - } -}; - -/** - * Render the given `str` of ejs. - * - * Options: - * - * - `locals` Local variables object - * - `cache` Compiled functions are cached, requires `filename` - * - `filename` Used by `cache` to key caches - * - `scope` Function execution context - * - `debug` Output generated function body - * - `open` Open tag, defaulting to "<%" - * - `close` Closing tag, defaulting to "%>" - * - * @param {String} str - * @param {Object} options - * @return {String} - * @api public - */ - -exports.render = function(str, options){ - var fn - , options = options || {}; - if (options.cache) { - if (options.filename) { - fn = cache[options.filename] || (cache[options.filename] = compile(str, options)); - } else { - throw new Error('"cache" option requires "filename".'); - } - } else { - fn = compile(str, options); - } - return fn.call(options.scope, options.locals || {}); -}; - -/** - * Expose to require(). - */ - -if (require.extensions) { - require.extensions['.ejs'] = function(module, filename) { - source = require('fs').readFileSync(filename, 'utf-8'); - module._compile(compile(source, {}), filename); - }; -} else if (require.registerExtension) { - require.registerExtension('.ejs', function(src) { - return compile(src, {}); - }); -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/filters.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/filters.js deleted file mode 100644 index d425c8d..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/filters.js +++ /dev/null @@ -1,198 +0,0 @@ - -/*! - * EJS - Filters - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * First element of the target `obj`. - */ - -exports.first = function(obj) { - return obj[0]; -}; - -/** - * Last element of the target `obj`. - */ - -exports.last = function(obj) { - return obj[obj.length - 1]; -}; - -/** - * Capitalize the first letter of the target `str`. - */ - -exports.capitalize = function(str){ - str = String(str); - return str[0].toUpperCase() + str.substr(1, str.length); -}; - -/** - * Downcase the target `str`. - */ - -exports.downcase = function(str){ - return String(str).toLowerCase(); -}; - -/** - * Uppercase the target `str`. - */ - -exports.upcase = function(str){ - return String(str).toUpperCase(); -}; - -/** - * Sort the target `obj`. - */ - -exports.sort = function(obj){ - return Object.create(obj).sort(); -}; - -/** - * Sort the target `obj` by the given `prop` ascending. - */ - -exports.sort_by = function(obj, prop){ - return Object.create(obj).sort(function(a, b){ - a = a[prop], b = b[prop]; - if (a > b) return 1; - if (a < b) return -1; - return 0; - }); -}; - -/** - * Size or length of the target `obj`. - */ - -exports.size = exports.length = function(obj) { - return obj.length; -}; - -/** - * Add `a` and `b`. - */ - -exports.plus = function(a, b){ - return Number(a) + Number(b); -}; - -/** - * Subtract `b` from `a`. - */ - -exports.minus = function(a, b){ - return Number(a) - Number(b); -}; - -/** - * Multiply `a` by `b`. - */ - -exports.times = function(a, b){ - return Number(a) * Number(b); -}; - -/** - * Divide `a` by `b`. - */ - -exports.divided_by = function(a, b){ - return Number(a) / Number(b); -}; - -/** - * Join `obj` with the given `str`. - */ - -exports.join = function(obj, str){ - return obj.join(str || ', '); -}; - -/** - * Truncate `str` to `len`. - */ - -exports.truncate = function(str, len){ - str = String(str); - return str.substr(0, len); -}; - -/** - * Truncate `str` to `n` words. - */ - -exports.truncate_words = function(str, n){ - var str = String(str) - , words = str.split(/ +/); - return words.slice(0, n).join(' '); -}; - -/** - * Replace `pattern` with `substitution` in `str`. - */ - -exports.replace = function(str, pattern, substitution){ - return String(str).replace(pattern, substitution || ''); -}; - -/** - * Prepend `val` to `obj`. - */ - -exports.prepend = function(obj, val){ - return Array.isArray(obj) - ? [val].concat(obj) - : val + obj; -}; - -/** - * Append `val` to `obj`. - */ - -exports.append = function(obj, val){ - return Array.isArray(obj) - ? obj.concat(val) - : obj + val; -}; - -/** - * Map the given `prop`. - */ - -exports.map = function(arr, prop){ - return arr.map(function(obj){ - return obj[prop]; - }); -}; - -/** - * Reverse the given `obj`. - */ - -exports.reverse = function(obj){ - return Array.isArray(obj) - ? obj.reverse() - : String(obj).split('').reverse().join(''); -}; - -/** - * Get `prop` of the given `obj`. - */ - -exports.get = function(obj, prop){ - return obj[prop]; -}; - -/** - * Packs the given `obj` into json string - */ -exports.json = function(obj){ - return JSON.stringify(obj); -}; \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/utils.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/utils.js deleted file mode 100644 index 8d569d6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/lib/utils.js +++ /dev/null @@ -1,23 +0,0 @@ - -/*! - * EJS - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Escape the given string of `html`. - * - * @param {String} html - * @return {String} - * @api private - */ - -exports.escape = function(html){ - return String(html) - .replace(/&(?!\w+;)/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); -}; - \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/package.json deleted file mode 100644 index 224b4ff..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "ejs", - "description": "Embedded JavaScript templates", - "version": "0.4.3", - "author": "TJ Holowaychuk ", - "keywords": ["template", "engine", "ejs"], - "devDependencies": { - "expresso": "0.9.2" - }, - "main": "./lib/ejs.js" -} \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/support/compile.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/support/compile.js deleted file mode 100644 index edd3815..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/support/compile.js +++ /dev/null @@ -1,173 +0,0 @@ - -/** - * Module dependencies. - */ - -var fs = require('fs'); - -/** - * Arguments. - */ - -var args = process.argv.slice(2) - , pending = args.length - , files = {}; - -console.log(''); - -// parse arguments - -args.forEach(function(file){ - var mod = file.replace('lib/', ''); - fs.readFile(file, 'utf8', function(err, js){ - if (err) throw err; - console.log(' \033[90mcompile : \033[0m\033[36m%s\033[0m', file); - files[file] = parse(js); - --pending || compile(); - }); -}); - -/** - * Parse the given `js`. - */ - -function parse(js) { - return parseInheritance(parseConditionals(js)); -} - -/** - * Parse __proto__. - */ - -function parseInheritance(js) { - return js - .replace(/^ *(\w+)\.prototype\.__proto__ * = *(\w+)\.prototype *;?/gm, function(_, child, parent){ - return child + '.prototype = new ' + parent + ';\n' - + child + '.prototype.constructor = '+ child + ';\n'; - }); -} - -/** - * Parse the given `js`, currently supporting: - * - * 'if' ['node' | 'browser'] - * 'end' - * - */ - -function parseConditionals(js) { - var lines = js.split('\n') - , len = lines.length - , buffer = true - , browser = false - , buf = [] - , line - , cond; - - for (var i = 0; i < len; ++i) { - line = lines[i]; - if (/^ *\/\/ *if *(node|browser)/gm.exec(line)) { - cond = RegExp.$1; - buffer = browser = 'browser' == cond; - } else if (/^ *\/\/ *end/.test(line)) { - buffer = true; - browser = false; - } else if (browser) { - buf.push(line.replace(/^( *)\/\//, '$1')); - } else if (buffer) { - buf.push(line); - } - } - - return buf.join('\n'); -} - -/** - * Compile the files. - */ - -function compile() { - var buf = ''; - buf += '\n// CommonJS require()\n\n'; - buf += browser.require + '\n\n'; - buf += 'require.modules = {};\n\n'; - buf += 'require.resolve = ' + browser.resolve + ';\n\n'; - buf += 'require.register = ' + browser.register + ';\n\n'; - buf += 'require.relative = ' + browser.relative + ';\n\n'; - args.forEach(function(file){ - var js = files[file]; - file = file.replace('lib/', ''); - buf += '\nrequire.register("' + file + '", function(module, exports, require){\n'; - buf += js; - buf += '\n}); // module: ' + file + '\n'; - }); - fs.writeFile('ejs.js', buf, function(err){ - if (err) throw err; - console.log(' \033[90m create : \033[0m\033[36m%s\033[0m', 'ejs.js'); - console.log(); - }); -} - -// refactored version of weepy's -// https://github.com/weepy/brequire/blob/master/browser/brequire.js - -var browser = { - - /** - * Require a module. - */ - - require: function require(p){ - var path = require.resolve(p) - , mod = require.modules[path]; - if (!mod) throw new Error('failed to require "' + p + '"'); - if (!mod.exports) { - mod.exports = {}; - mod.call(mod.exports, mod, mod.exports, require.relative(path)); - } - return mod.exports; - }, - - /** - * Resolve module path. - */ - - resolve: function(path){ - var orig = path - , reg = path + '.js' - , index = path + '/index.js'; - return require.modules[reg] && reg - || require.modules[index] && index - || orig; - }, - - /** - * Return relative require(). - */ - - relative: function(parent) { - return function(p){ - if ('.' != p.substr(0, 1)) return require(p); - - var path = parent.split('/') - , segs = p.split('/'); - path.pop(); - - for (var i = 0; i < segs.length; i++) { - var seg = segs[i]; - if ('..' == seg) path.pop(); - else if ('.' != seg) path.push(seg); - } - - return require(path.join('/')); - }; - }, - - /** - * Register a module. - */ - - register: function(path, fn){ - require.modules[path] = fn; - } -}; \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/test/ejs.test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/test/ejs.test.js deleted file mode 100644 index 624157d..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/deps/ejs/test/ejs.test.js +++ /dev/null @@ -1,269 +0,0 @@ - -/** - * Module dependencies. - */ - -var ejs = require('../') - , assert = require('assert'); - -module.exports = { - 'test .version': function(){ - assert.ok(/^\d+\.\d+\.\d+$/.test(ejs.version), 'Test .version format'); - }, - - 'test html': function(){ - assert.equal('

yay

', ejs.render('

yay

')); - }, - - 'test buffered code': function(){ - var html = '

tj

', - str = '

<%= name %>

', - locals = { name: 'tj' }; - assert.equal(html, ejs.render(str, { locals: locals })); - }, - - 'test unbuffered code': function(){ - var html = '

tj

', - str = '<% if (name) { %>

<%= name %>

<% } %>', - locals = { name: 'tj' }; - assert.equal(html, ejs.render(str, { locals: locals })); - }, - - 'test `scope` option': function(){ - var html = '

tj

', - str = '

<%= this %>

'; - assert.equal(html, ejs.render(str, { scope: 'tj' })); - }, - - 'test escaping': function(){ - assert.equal('<script>', ejs.render('<%= " - - - - - - - - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/examples/nested/nested_reporter_test.unit.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/examples/nested/nested_reporter_test.unit.js deleted file mode 100644 index 612adcd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/examples/nested/nested_reporter_test.unit.js +++ /dev/null @@ -1,94 +0,0 @@ -var testCase = require('nodeunit').testCase; -/* - This is an example test suite to demonstrate the nested test reporter. - Run with --reporter nested, e.g., - nodeunit --reporter nested nested_reporter_test.unit.js - - The test output should be something like: - - nested_reporter_test.unit.js - Test 0.1 (pass) - TC 1 - TC 1.1 - Test 1.1.1 (pass) - TC 2 - TC 2.1 - TC 2.1.1 - Test 2.1.1.1 (pass) - Test 2.1.1.2 (pass) - TC 2.2.1 - Test 2.2.1.1 (pass) - TC 2.2.1.1 - Test 2.2.1.1.1 (pass) - Test 2.2.1.2 (pass) - TC 3 - TC 3.1 - TC 3.1.1 - Test 3.1.1.1 (should fail) (fail) ✖ - AssertionError: false == true - // stack trace here. - - FAILURES: 1/8 assertions failed (6ms) -*/ - -module.exports = testCase({ - "Test 0.1": function(test) { - test.ok(true); - test.done(); - }, - - "TC 1": testCase({ - "TC 1.1": testCase({ - "Test 1.1.1": function(test) { - test.ok(true); - test.done(); - } - }) - }), - - "TC 2": testCase({ - "TC 2.1": testCase({ - "TC 2.1.1": testCase({ - "Test 2.1.1.1": function(test) { - test.ok(true); - test.done(); - }, - - "Test 2.1.1.2": function(test) { - test.ok(true); - test.done(); - } - }), - - "TC 2.2.1": testCase({ - "Test 2.2.1.1": function(test) { - test.ok(true); - test.done(); - }, - - "TC 2.2.1.1": testCase({ - "Test 2.2.1.1.1": function(test) { - test.ok(true); - test.done(); - }, - }), - - "Test 2.2.1.2": function(test) { - test.ok(true); - test.done(); - } - }) - }) - }), - - "TC 3": testCase({ - "TC 3.1": testCase({ - "TC 3.1.1": testCase({ - "Test 3.1.1.1 (should fail)": function(test) { - test.ok(false); - test.done(); - } - }) - }) - }) -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_fail.png b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_fail.png deleted file mode 100644 index 78ff425..0000000 Binary files a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_fail.png and /dev/null differ diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_machineout.png b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_machineout.png deleted file mode 100644 index c6bfa27..0000000 Binary files a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_machineout.png and /dev/null differ diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_pass.png b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_pass.png deleted file mode 100644 index 069d716..0000000 Binary files a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/img/example_pass.png and /dev/null differ diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/index.js deleted file mode 100644 index 07867d0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// This file is just added for convenience so this repository can be -// directly checked out into a project's deps folder -module.exports = require('./lib/nodeunit'); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/assert.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/assert.js deleted file mode 100644 index 55ef744..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/assert.js +++ /dev/null @@ -1,354 +0,0 @@ -/** - * This file is based on the node.js assert module, but with some small - * changes for browser-compatibility - * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS! - */ - - -/** - * Added for browser compatibility - */ - -var _keys = function(obj){ - if(Object.keys) return Object.keys(obj); - if (typeof obj != 'object' && typeof obj != 'function') { - throw new TypeError('-'); - } - var keys = []; - for(var k in obj){ - if(obj.hasOwnProperty(k)) keys.push(k); - } - return keys; -}; - - - -// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 -// -// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! -// -// Originally from narwhal.js (http://narwhaljs.org) -// Copyright (c) 2009 Thomas Robinson <280north.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 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. - - -var pSlice = Array.prototype.slice; - -// 1. The assert module provides functions that throw -// AssertionError's when particular conditions are not met. The -// assert module must conform to the following interface. - -var assert = exports; - -// 2. The AssertionError is defined in assert. -// new assert.AssertionError({message: message, actual: actual, expected: expected}) - -assert.AssertionError = function AssertionError (options) { - this.name = "AssertionError"; - this.message = options.message; - this.actual = options.actual; - this.expected = options.expected; - this.operator = options.operator; - var stackStartFunction = options.stackStartFunction || fail; - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); - } -}; -// code from util.inherits in node -assert.AssertionError.super_ = Error; - - -// EDITED FOR BROWSER COMPATIBILITY: replaced Object.create call -// TODO: test what effect this may have -var ctor = function () { this.constructor = assert.AssertionError; }; -ctor.prototype = Error.prototype; -assert.AssertionError.prototype = new ctor(); - - -assert.AssertionError.prototype.toString = function() { - if (this.message) { - return [this.name+":", this.message].join(' '); - } else { - return [ this.name+":" - , typeof this.expected !== 'undefined' ? JSON.stringify(this.expected) : 'undefined' - , this.operator - , typeof this.actual !== 'undefined' ? JSON.stringify(this.actual) : 'undefined' - ].join(" "); - } -}; - -// assert.AssertionError instanceof Error - -assert.AssertionError.__proto__ = Error.prototype; - -// At present only the three keys mentioned above are used and -// understood by the spec. Implementations or sub modules can pass -// other keys to the AssertionError's constructor - they will be -// ignored. - -// 3. All of the following functions must throw an AssertionError -// when a corresponding condition is not met, with a message that -// may be undefined if not provided. All assertion methods provide -// both the actual and expected values to the assertion error for -// display purposes. - -function fail(actual, expected, message, operator, stackStartFunction) { - throw new assert.AssertionError({ - message: message, - actual: actual, - expected: expected, - operator: operator, - stackStartFunction: stackStartFunction - }); -} - -// EXTENSION! allows for well behaved errors defined elsewhere. -assert.fail = fail; - -// 4. Pure assertion tests whether a value is truthy, as determined -// by !!guard. -// assert.ok(guard, message_opt); -// This statement is equivalent to assert.equal(true, guard, -// message_opt);. To test strictly for the value true, use -// assert.strictEqual(true, guard, message_opt);. - -assert.ok = function ok(value, message) { - if (!!!value) fail(value, true, message, "==", assert.ok); -}; - -// 5. The equality assertion tests shallow, coercive equality with -// ==. -// assert.equal(actual, expected, message_opt); - -assert.equal = function equal(actual, expected, message) { - if (actual != expected) fail(actual, expected, message, "==", assert.equal); -}; - -// 6. The non-equality assertion tests for whether two objects are not equal -// with != assert.notEqual(actual, expected, message_opt); - -assert.notEqual = function notEqual(actual, expected, message) { - if (actual == expected) { - fail(actual, expected, message, "!=", assert.notEqual); - } -}; - -// 7. The equivalence assertion tests a deep equality relation. -// assert.deepEqual(actual, expected, message_opt); - -assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected)) { - fail(actual, expected, message, "deepEqual", assert.deepEqual); - } -}; - -var Buffer = null; -if (typeof require !== 'undefined' && typeof process !== 'undefined') { - try { - Buffer = require('buffer').Buffer; - } - catch (e) { - // May be a CommonJS environment other than Node.js - Buffer = null; - } -} - -function _deepEqual(actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.2.1 If the expcted value is a RegExp object, the actual value is - // equivalent if it is also a RegExp object that refers to the same source and options - } else if (actual instanceof RegExp && expected instanceof RegExp) { - return actual.source === expected.source && - actual.global === expected.global && - actual.ignoreCase === expected.ignoreCase && - actual.multiline === expected.multiline; - - } else if (Buffer && actual instanceof Buffer && expected instanceof Buffer) { - return (function() { - var i, len; - - for (i = 0, len = expected.length; i < len; i++) { - if (actual[i] !== expected[i]) { - return false; - } - } - return actual.length === expected.length; - })(); - // 7.3. Other pairs that do not both pass typeof value == "object", - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical "prototype" property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -} - -function isUndefinedOrNull (value) { - return value === null || value === undefined; -} - -function isArguments (object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function objEquiv (a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical "prototype" property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b); - } - try{ - var ka = _keys(a), - kb = _keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key] )) - return false; - } - return true; -} - -// 8. The non-equivalence assertion tests for any deep inequality. -// assert.notDeepEqual(actual, expected, message_opt); - -assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected)) { - fail(actual, expected, message, "notDeepEqual", assert.notDeepEqual); - } -}; - -// 9. The strict equality assertion tests strict equality, as determined by ===. -// assert.strictEqual(actual, expected, message_opt); - -assert.strictEqual = function strictEqual(actual, expected, message) { - if (actual !== expected) { - fail(actual, expected, message, "===", assert.strictEqual); - } -}; - -// 10. The strict non-equality assertion tests for strict inequality, as determined by !==. -// assert.notStrictEqual(actual, expected, message_opt); - -assert.notStrictEqual = function notStrictEqual(actual, expected, message) { - if (actual === expected) { - fail(actual, expected, message, "!==", assert.notStrictEqual); - } -}; - -function expectedException(actual, expected) { - if (!actual || !expected) { - return false; - } - - if (expected instanceof RegExp) { - return expected.test(actual.message || actual); - } else if (actual instanceof expected) { - return true; - } else if (expected.call({}, actual) === true) { - return true; - } - - return false; -} - -function _throws(shouldThrow, block, expected, message) { - var actual; - - if (typeof expected === 'string') { - message = expected; - expected = null; - } - - try { - block(); - } catch (e) { - actual = e; - } - - message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + - (message ? ' ' + message : '.'); - - if (shouldThrow && !actual) { - fail('Missing expected exception' + message); - } - - if (!shouldThrow && expectedException(actual, expected)) { - fail('Got unwanted exception' + message); - } - - if ((shouldThrow && actual && expected && - !expectedException(actual, expected)) || (!shouldThrow && actual)) { - throw actual; - } -} - -// 11. Expected to throw an error: -// assert.throws(block, Error_opt, message_opt); - -assert.throws = function(block, /*optional*/error, /*optional*/message) { - _throws.apply(this, [true].concat(pSlice.call(arguments))); -}; - -// EXTENSION! This is annoying to write outside this module. -assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { - _throws.apply(this, [false].concat(pSlice.call(arguments))); -}; - -assert.ifError = function (err) { if (err) {throw err;}}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/core.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/core.js deleted file mode 100644 index 8ff031b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/core.js +++ /dev/null @@ -1,319 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - * - * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS! - * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build. - * Only code on that line will be removed, it's mostly to avoid requiring code - * that is node specific - */ - -/** - * Module dependencies - */ - -var async = require('../deps/async'), //@REMOVE_LINE_FOR_BROWSER - nodeunit = require('./nodeunit'), //@REMOVE_LINE_FOR_BROWSER - types = require('./types'); //@REMOVE_LINE_FOR_BROWSER - - -/** - * Added for browser compatibility - */ - -var _keys = function (obj) { - if (Object.keys) { - return Object.keys(obj); - } - var keys = []; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - keys.push(k); - } - } - return keys; -}; - - -var _copy = function (obj) { - var nobj = {}; - var keys = _keys(obj); - for (var i = 0; i < keys.length; i += 1) { - nobj[keys[i]] = obj[keys[i]]; - } - return nobj; -}; - - -/** - * Runs a test function (fn) from a loaded module. After the test function - * calls test.done(), the callback is executed with an assertionList as its - * second argument. - * - * @param {String} name - * @param {Function} fn - * @param {Object} opt - * @param {Function} callback - * @api public - */ - -exports.runTest = function (name, fn, opt, callback) { - var options = types.options(opt); - - options.testStart(name); - var start = new Date().getTime(); - var test = types.test(name, start, options, callback); - - options.testReady(test); - try { - fn(test); - } - catch (e) { - test.done(e); - } -}; - -/** - * Takes an object containing test functions or other test suites as properties - * and runs each in series. After all tests have completed, the callback is - * called with a list of all assertions as the second argument. - * - * If a name is passed to this function it is prepended to all test and suite - * names that run within it. - * - * @param {String} name - * @param {Object} suite - * @param {Object} opt - * @param {Function} callback - * @api public - */ - -exports.runSuite = function (name, suite, opt, callback) { - suite = wrapGroup(suite); - var keys = _keys(suite); - - async.concatSeries(keys, function (k, cb) { - var prop = suite[k], _name; - - _name = name ? [].concat(name, k) : [k]; - _name.toString = function () { - // fallback for old one - return this.join(' - '); - }; - - if (typeof prop === 'function') { - var in_name = false, - in_specific_test = (_name.toString() === opt.testFullSpec) ? true : false; - for (var i = 0; i < _name.length; i += 1) { - if (_name[i] === opt.testspec) { - in_name = true; - } - } - - if ((!opt.testFullSpec || in_specific_test) && (!opt.testspec || in_name)) { - if (opt.moduleStart) { - opt.moduleStart(); - } - exports.runTest(_name, suite[k], opt, cb); - } - else { - return cb(); - } - } - else { - exports.runSuite(_name, suite[k], opt, cb); - } - }, callback); -}; - -/** - * Run each exported test function or test suite from a loaded module. - * - * @param {String} name - * @param {Object} mod - * @param {Object} opt - * @param {Function} callback - * @api public - */ - -exports.runModule = function (name, mod, opt, callback) { - var options = _copy(types.options(opt)); - - var _run = false; - var _moduleStart = options.moduleStart; - - mod = wrapGroup(mod); - - function run_once() { - if (!_run) { - _run = true; - _moduleStart(name); - } - } - options.moduleStart = run_once; - - var start = new Date().getTime(); - - exports.runSuite(null, mod, options, function (err, a_list) { - var end = new Date().getTime(); - var assertion_list = types.assertionList(a_list, end - start); - options.moduleDone(name, assertion_list); - if (nodeunit.complete) { - nodeunit.complete(name, assertion_list); - } - callback(null, a_list); - }); -}; - -/** - * Treats an object literal as a list of modules keyed by name. Runs each - * module and finished with calling 'done'. You can think of this as a browser - * safe alternative to runFiles in the nodeunit module. - * - * @param {Object} modules - * @param {Object} opt - * @api public - */ - -// TODO: add proper unit tests for this function -exports.runModules = function (modules, opt) { - var all_assertions = []; - var options = types.options(opt); - var start = new Date().getTime(); - - async.concatSeries(_keys(modules), function (k, cb) { - exports.runModule(k, modules[k], options, cb); - }, - function (err, all_assertions) { - var end = new Date().getTime(); - options.done(types.assertionList(all_assertions, end - start)); - }); -}; - - -/** - * Wraps a test function with setUp and tearDown functions. - * Used by testCase. - * - * @param {Function} setUp - * @param {Function} tearDown - * @param {Function} fn - * @api private - */ - -var wrapTest = function (setUp, tearDown, fn) { - return function (test) { - var context = {}; - if (tearDown) { - var done = test.done; - test.done = function (err) { - try { - tearDown.call(context, function (err2) { - if (err && err2) { - test._assertion_list.push( - types.assertion({error: err}) - ); - return done(err2); - } - done(err || err2); - }); - } - catch (e) { - done(e); - } - }; - } - if (setUp) { - setUp.call(context, function (err) { - if (err) { - return test.done(err); - } - fn.call(context, test); - }); - } - else { - fn.call(context, test); - } - }; -}; - - -/** - * Returns a serial callback from two functions. - * - * @param {Function} funcFirst - * @param {Function} funcSecond - * @api private - */ - -var getSerialCallback = function (fns) { - if (!fns.length) { - return null; - } - return function (callback) { - var that = this; - var bound_fns = []; - for (var i = 0, len = fns.length; i < len; i++) { - (function (j) { - bound_fns.push(function () { - return fns[j].apply(that, arguments); - }); - })(i); - } - return async.series(bound_fns, callback); - }; -}; - - -/** - * Wraps a group of tests with setUp and tearDown functions. - * Used by testCase. - * - * @param {Object} group - * @param {Array} setUps - parent setUp functions - * @param {Array} tearDowns - parent tearDown functions - * @api private - */ - -var wrapGroup = function (group, setUps, tearDowns) { - var tests = {}; - - var setUps = setUps ? setUps.slice(): []; - var tearDowns = tearDowns ? tearDowns.slice(): []; - - if (group.setUp) { - setUps.push(group.setUp); - delete group.setUp; - } - if (group.tearDown) { - tearDowns.unshift(group.tearDown); - delete group.tearDown; - } - - var keys = _keys(group); - - for (var i = 0; i < keys.length; i += 1) { - var k = keys[i]; - if (typeof group[k] === 'function') { - tests[k] = wrapTest( - getSerialCallback(setUps), - getSerialCallback(tearDowns), - group[k] - ); - } - else if (typeof group[k] === 'object') { - tests[k] = wrapGroup(group[k], setUps, tearDowns); - } - } - return tests; -}; - - -/** - * Backwards compatibility for test suites using old testCase API - */ - -exports.testCase = function (suite) { - return suite; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/nodeunit.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/nodeunit.js deleted file mode 100644 index 7d33c7b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/nodeunit.js +++ /dev/null @@ -1,104 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var async = require('../deps/async'), - types = require('./types'), - utils = require('./utils'), - core = require('./core'), - reporters = require('./reporters'), - assert = require('./assert'), - path = require('path'), - events = require('events'); - - -/** - * Export sub-modules. - */ - -exports.types = types; -exports.utils = utils; -exports.reporters = reporters; -exports.assert = assert; - -// backwards compatibility -exports.testrunner = { - run: function () { - console.log( - 'WARNING: nodeunit.testrunner is going to be deprecated, please ' + - 'use nodeunit.reporters.default instead!' - ); - return reporters['default'].run.apply(this, arguments); - } -}; - - -/** - * Export all core functions - */ - -for (var k in core) { - exports[k] = core[k]; -}; - - -/** - * Load modules from paths array and run all exported tests in series. If a path - * is a directory, load all supported file types inside it as modules. This only - * reads 1 level deep in the directory and does not recurse through - * sub-directories. - * - * @param {Array} paths - * @param {Object} opt - * @api public - */ - -exports.runFiles = function (paths, opt) { - var all_assertions = []; - var options = types.options(opt); - var start = new Date().getTime(); - - if (!paths.length) { - return options.done(types.assertionList(all_assertions)); - } - - utils.modulePaths(paths, function (err, files) { - if (err) throw err; - async.concatSeries(files, function (file, cb) { - var name = path.basename(file); - exports.runModule(name, require(file), options, cb); - }, - function (err, all_assertions) { - var end = new Date().getTime(); - exports.done() - options.done(types.assertionList(all_assertions, end - start)); - }); - }); - -}; - -/* Export all prototypes from events.EventEmitter */ -var label; -for (label in events.EventEmitter.prototype) { - exports[label] = events.EventEmitter.prototype[label]; -} - -/* Emit event 'complete' on completion of a test suite. */ -exports.complete = function(name, assertions) -{ - exports.emit('complete', name, assertions); -}; - -/* Emit event 'complete' on completion of all tests. */ -exports.done = function() -{ - exports.emit('done'); -}; - -module.exports = exports; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/browser.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/browser.js deleted file mode 100644 index c769c41..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/browser.js +++ /dev/null @@ -1,123 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - * - * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS! - * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build. - * Only code on that line will be removed, its mostly to avoid requiring code - * that is node specific - */ - - -/** - * NOTE: this test runner is not listed in index.js because it cannot be - * used with the command-line tool, only inside the browser. - */ - - -/** - * Reporter info string - */ - -exports.info = "Browser-based test reporter"; - - -/** - * Run all tests within each module, reporting the results - * - * @param {Array} files - * @api public - */ - -exports.run = function (modules, options, callback) { - var start = new Date().getTime(), div; - options = options || {}; - div = options.div || document.body; - - function setText(el, txt) { - if ('innerText' in el) { - el.innerText = txt; - } - else if ('textContent' in el){ - el.textContent = txt; - } - } - - function getOrCreate(tag, id) { - var el = document.getElementById(id); - if (!el) { - el = document.createElement(tag); - el.id = id; - div.appendChild(el); - } - return el; - }; - - var header = getOrCreate('h1', 'nodeunit-header'); - var banner = getOrCreate('h2', 'nodeunit-banner'); - var userAgent = getOrCreate('h2', 'nodeunit-userAgent'); - var tests = getOrCreate('ol', 'nodeunit-tests'); - var result = getOrCreate('p', 'nodeunit-testresult'); - - setText(userAgent, navigator.userAgent); - - nodeunit.runModules(modules, { - moduleStart: function (name) { - /*var mheading = document.createElement('h2'); - mheading.innerText = name; - results.appendChild(mheading); - module = document.createElement('ol'); - results.appendChild(module);*/ - }, - testDone: function (name, assertions) { - var test = document.createElement('li'); - var strong = document.createElement('strong'); - strong.innerHTML = name + ' (' + - '' + assertions.failures() + ', ' + - '' + assertions.passes() + ', ' + - assertions.length + - ')'; - test.className = assertions.failures() ? 'fail': 'pass'; - test.appendChild(strong); - - var aList = document.createElement('ol'); - aList.style.display = 'none'; - test.onclick = function () { - var d = aList.style.display; - aList.style.display = (d == 'none') ? 'block': 'none'; - }; - for (var i=0; i' + (a.error.stack || a.error) + ''; - li.className = 'fail'; - } - else { - li.innerHTML = a.message || a.method || 'no message'; - li.className = 'pass'; - } - aList.appendChild(li); - } - test.appendChild(aList); - tests.appendChild(test); - }, - done: function (assertions) { - var end = new Date().getTime(); - var duration = end - start; - - var failures = assertions.failures(); - banner.className = failures ? 'fail': 'pass'; - - result.innerHTML = 'Tests completed in ' + duration + - ' milliseconds.
' + - assertions.passes() + ' assertions of ' + - '' + assertions.length + ' passed, ' + - assertions.failures() + ' failed.'; - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/default.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/default.js deleted file mode 100644 index 0de3f23..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/default.js +++ /dev/null @@ -1,131 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - track = require('../track'), - path = require('path'), - AssertionError = require('../assert').AssertionError; - -/** - * Reporter info string - */ - -exports.info = "Default tests reporter"; - - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - if (!options) { - // load default options - var content = fs.readFileSync( - __dirname + '/../../bin/nodeunit.json', 'utf8' - ); - options = JSON.parse(content); - } - - var error = function (str) { - return options.error_prefix + str + options.error_suffix; - }; - var ok = function (str) { - return options.ok_prefix + str + options.ok_suffix; - }; - var bold = function (str) { - return options.bold_prefix + str + options.bold_suffix; - }; - var assertion_message = function (str) { - return options.assertion_prefix + str + options.assertion_suffix; - }; - - var start = new Date().getTime(); - var tracker = track.createTracker(function (tracker) { - if (tracker.unfinished()) { - console.log(''); - console.log(error(bold( - 'FAILURES: Undone tests (or their setups/teardowns): ' - ))); - var names = tracker.names(); - for (var i = 0; i < names.length; i += 1) { - console.log('- ' + names[i]); - } - console.log(''); - console.log('To fix this, make sure all tests call test.done()'); - process.reallyExit(tracker.unfinished()); - } - }); - - var opts = { - testspec: options.testspec, - testFullSpec: options.testFullSpec, - moduleStart: function (name) { - console.log('\n' + bold(name)); - }, - testDone: function (name, assertions) { - tracker.remove(name); - - if (!assertions.failures()) { - console.log('✔ ' + name); - } - else { - console.log(error('✖ ' + name) + '\n'); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log( - 'Assertion Message: ' + - assertion_message(a.message) - ); - } - console.log(a.error.stack + '\n'); - } - }); - } - }, - done: function (assertions, end) { - var end = end || new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '\n' + bold(error('FAILURES: ')) + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)' - ); - } - else { - console.log( - '\n' + bold(ok('OK: ')) + assertions.length + - ' assertions (' + assertions.duration + 'ms)' - ); - } - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - }, - testStart: function(name) { - tracker.put(name); - } - }; - if (files && files.length) { - var paths = files.map(function (p) { - return path.resolve(p); - }); - nodeunit.runFiles(paths, opts); - } else { - nodeunit.runModules(files,opts); - } -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/eclipse.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/eclipse.js deleted file mode 100644 index c56a4b8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/eclipse.js +++ /dev/null @@ -1,104 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - track = require('../track'), - path = require('path'), - AssertionError = require('../assert').AssertionError; - -/** - * Reporter info string - */ - -exports.info = "Reporter for eclipse plugin"; - - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - var start = new Date().getTime(); - var paths = files.map(function (p) { - if (p.indexOf('/') === 0) { - return p; - } - return path.resolve(p); - }); - var tracker = track.createTracker(function (tracker) { - if (tracker.unfinished()) { - console.log(''); - console.log('FAILURES: Undone tests (or their setups/teardowns): '); - var names = tracker.names(); - for (var i = 0; i < names.length; i += 1) { - console.log('- ' + names[i]); - } - console.log(''); - console.log('To fix this, make sure all tests call test.done()'); - process.reallyExit(tracker.unfinished()); - } - }); - - nodeunit.runFiles(paths, { - testspec: undefined, - moduleStart: function (name) { - console.log('\n' + name); - }, - testDone: function (name, assertions) { - tracker.remove(name); - - if (!assertions.failures()) { - console.log('✔ ' + name); - } - else { - console.log('✖ ' + name + '\n'); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log( - 'Assertion Message: ' + a.message - ); - } - console.log(a.error.stack + '\n'); - } - }); - } - }, - done: function (assertions, end) { - var end = end || new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '\n' + 'FAILURES: ' + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)' - ); - } - else { - console.log( - '\n' + 'OK: ' + assertions.length + - ' assertions (' + assertions.duration + 'ms)' - ); - } - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - }, - testStart: function (name) { - tracker.put(name); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/html.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/html.js deleted file mode 100644 index ac64650..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/html.js +++ /dev/null @@ -1,110 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - path = require('path'), - AssertionError = require('assert').AssertionError; - -/** - * Reporter info string - */ - -exports.info = "Report tests result as HTML"; - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - var start = new Date().getTime(); - var paths = files.map(function (p) { - return path.resolve(p); - }); - - console.log(''); - console.log(''); - console.log(''); - console.log(''); - console.log(''); - console.log(''); - nodeunit.runFiles(paths, { - testspec: options.testspec, - testFullSpec: options.testFullSpec, - moduleStart: function (name) { - console.log('

' + name + '

'); - console.log('
    '); - }, - testDone: function (name, assertions) { - if (!assertions.failures()) { - console.log('
  1. ' + name + '
  2. '); - } - else { - console.log('
  3. ' + name); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log('
    ' + - 'Assertion Message: ' + a.message + - '
    '); - } - console.log('
    ');
    -                        console.log(a.error.stack);
    -                        console.log('
    '); - } - }); - console.log('
  4. '); - } - }, - moduleDone: function () { - console.log('
'); - }, - done: function (assertions) { - var end = new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '

FAILURES: ' + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)

' - ); - } - else { - console.log( - '

OK: ' + assertions.length + - ' assertions (' + assertions.duration + 'ms)

' - ); - } - console.log(''); - console.log(''); - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/index.js deleted file mode 100644 index 10eff3c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// This is a hack to make browserify skip tap -var tap; -try { - tap = require('./' + 'tap'); -} catch (ex) { - tap = { - run: function() { - throw new Error('Sorry, tap reporter not available'); - } - }; -} - -module.exports = { - 'junit': require('./junit'), - 'default': require('./default'), - 'skip_passed': require('./skip_passed'), - 'minimal': require('./minimal'), - 'html': require('./html'), - 'eclipse': require('./eclipse'), - 'machineout': require('./machineout'), - 'tap': tap, - 'nested': require('./nested'), - 'verbose' : require('./verbose'), - 'lcov' : require('./lcov') - // browser test reporter is not listed because it cannot be used - // with the command line tool, only inside a browser. -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/junit.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/junit.js deleted file mode 100644 index 5400526..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/junit.js +++ /dev/null @@ -1,180 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - path = require('path'), - async = require('../../deps/async'), - AssertionError = require('assert').AssertionError, - child_process = require('child_process'), - ejs = require('../../deps/ejs'); - - -/** - * Reporter info string - */ - -exports.info = "jUnit XML test reports"; - - -/** - * Ensures a directory exists using mkdir -p. - * - * @param {String} path - * @param {Function} callback - * @api private - */ - -var ensureDir = function (path, callback) { - var mkdir = child_process.spawn('mkdir', ['-p', path]); - mkdir.on('error', function (err) { - callback(err); - callback = function(){}; - }); - mkdir.on('exit', function (code) { - if (code === 0) callback(); - else callback(new Error('mkdir exited with code: ' + code)); - }); -}; - - -/** - * Returns absolute version of a path. Relative paths are interpreted - * relative to process.cwd() or the cwd parameter. Paths that are already - * absolute are returned unaltered. - * - * @param {String} p - * @param {String} cwd - * @return {String} - * @api public - */ - -var abspath = function (p, /*optional*/cwd) { - if (p[0] === '/') return p; - cwd = cwd || process.cwd(); - return path.normalize(path.resolve(p)); -}; - - -/** - * Run all tests within each module, reporting the results to the command-line, - * then writes out junit-compatible xml documents. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, opts, callback) { - if (!opts.output) { - console.error( - 'Error: No output directory defined.\n' + - '\tEither add an "output" property to your nodeunit.json config ' + - 'file, or\n\tuse the --output command line option.' - ); - return; - } - opts.output = abspath(opts.output); - var error = function (str) { - return opts.error_prefix + str + opts.error_suffix; - }; - var ok = function (str) { - return opts.ok_prefix + str + opts.ok_suffix; - }; - var bold = function (str) { - return opts.bold_prefix + str + opts.bold_suffix; - }; - - var start = new Date().getTime(); - var paths = files.map(function (p) { - return path.resolve(p); - }); - - var modules = {} - var curModule; - - nodeunit.runFiles(paths, { - testspec: opts.testspec, - testFullSpec: opts.testFullSpec, - moduleStart: function (name) { - curModule = { - errorCount: 0, - failureCount: 0, - tests: 0, - testcases: [], - name: name - }; - modules[name] = curModule; - }, - testDone: function (name, assertions) { - var testcase = {name: name}; - for (var i=0; i name_slice(['TC1', 'TC1.1', 'mytest'], 1); - * "TC1,TC1.1" - */ - var name_slice = function (name_arr, end_index) { - return name_arr.slice(0, end_index + 1).join(","); - }; - - var indent = (function () { - var txt = ''; - var i; - for (i = 0; i < spaces_per_indent; i++) { - txt += ' '; - } - return txt; - }()); - - // Indent once for each indent_level - var add_indent = function (txt, indent_level) { - var k; - for (k = 0; k < indent_level; k++) { - txt += indent; - } - return txt; - }; - - // If it's not the last element of the name_arr, it's a testCase. - var is_testCase = function (name_arr, index) { - return index === name_arr.length - 1 ? false : true; - }; - - var testCase_line = function (txt) { - return txt + "\n"; - }; - - /** - * Prints (console.log) the nested test status line(s). - * - * @param {Array} name_arr - Array of name elements. - * @param {String} status - either 'pass' or 'fail'. - * @example - * > print_status(['TC1', 'TC1.1', 'mytest'], 'pass'); - * TC1 - * TC1.1 - * mytest (pass) - */ - var print_status = function (name_arr, status) { - var txt = ''; - var _name_slice, part, i; - for (i = 0; i < name_arr.length; i++) { - _name_slice = name_slice(name_arr, i); - part = name_arr[i]; - if (!tracker.already_printed[_name_slice]) { - txt = add_indent(txt, i); - if (is_testCase(name_arr, i)) { - txt += testCase_line(part); - } else { - txt += status_text(part, status); - } - tracker.already_printed[_name_slice] = true; - } - } - console.log(txt); - }; - - nodeunit.runFiles(paths, { - testspec: options.testspec, - testFullSpec: options.testFullSpec, - moduleStart: function (name) { - console.log('\n' + bold(name)); - }, - testDone: function (name, assertions) { - tracker.remove(name); - - if (!assertions.failures()) { - print_status(name, 'pass'); - } else { - print_status(name, 'fail'); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log( - 'Assertion Message: ' + - assertion_message(a.message) - ); - } - console.log(a.error.stack + '\n'); - } - }); - } - }, - done: function (assertions, end) { - end = end || new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '\n' + bold(error('FAILURES: ')) + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)' - ); - } else { - console.log( - '\n' + bold(ok('OK: ')) + assertions.length + - ' assertions (' + assertions.duration + 'ms)' - ); - } - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - }, - testStart: function (name) { - tracker.put(name); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/skip_passed.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/skip_passed.js deleted file mode 100644 index e63489b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/skip_passed.js +++ /dev/null @@ -1,108 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - path = require('path'), - AssertionError = require('assert').AssertionError; - -/** - * Reporter info string - */ - -exports.info = "Skip passed tests output"; - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - if (!options) { - // load default options - var content = fs.readFileSync( - __dirname + '/../../bin/nodeunit.json', 'utf8' - ); - options = JSON.parse(content); - } - - var error = function (str) { - return options.error_prefix + str + options.error_suffix; - }; - var ok = function (str) { - return options.ok_prefix + str + options.ok_suffix; - }; - var bold = function (str) { - return options.bold_prefix + str + options.bold_suffix; - }; - var assertion_message = function (str) { - return options.assertion_prefix + str + options.assertion_suffix; - }; - - var start = new Date().getTime(); - var paths = files.map(function (p) { - return path.resolve(p); - }); - - nodeunit.runFiles(paths, { - testspec: options.testspec, - testFullSpec: options.testFullSpec, - moduleStart: function (name) { - console.log('\n' + bold(name)); - }, - testDone: function (name, assertions) { - if (assertions.failures()) { - console.log(error('✖ ' + name) + '\n'); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log( - 'Assertion Message: ' + assertion_message(a.message) - ); - } - console.log(a.error.stack + '\n'); - } - }); - } - }, - moduleDone: function (name, assertions) { - if (!assertions.failures()) { - console.log('✔ all tests passed'); - } - else { - console.log(error('✖ some tests failed')); - } - }, - done: function (assertions) { - var end = new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '\n' + bold(error('FAILURES: ')) + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)' - ); - } - else { - console.log( - '\n' + bold(ok('OK: ')) + assertions.length + - ' assertions (' + assertions.duration + 'ms)' - ); - } - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/tap.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/tap.js deleted file mode 100644 index 8f7034c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/tap.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - path = require('path'), - assert = require('tap').assert, - TapProducer = require('tap').Producer, - fs = require('fs'); - -/** - * Reporter info string - */ - -exports.info = "TAP output"; - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - if (!options) { - // load default options - var content = fs.readFileSync( - __dirname + '/../../bin/nodeunit.json', 'utf8' - ); - options = JSON.parse(content); - } - - var paths = files.map(function (p) { - return path.resolve(p); - }); - var output = new TapProducer(); - output.pipe(process.stdout); - - nodeunit.runFiles(paths, { - testStart: function (name) { - output.write(name.toString()); - }, - testDone: function (name, assertions) { - assertions.forEach(function (e) { - var extra = {}; - if (e.error) { - extra.error = { - name: e.error.name, - message: e.error.message, - stack: e.error.stack.split(/\n/).filter(function (line) { - // exclude line of "types.js" - return ! RegExp(/types.js:83:39/).test(line); - }).join('\n') - }; - extra.wanted = e.error.expected; - extra.found = e.error.actual; - } - output.write(assert(e.passed(), e.message, extra)); - }); - }, - done: function (assertions) { - output.end(); - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/verbose.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/verbose.js deleted file mode 100644 index 6c6083a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/reporters/verbose.js +++ /dev/null @@ -1,125 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var nodeunit = require('../nodeunit'), - utils = require('../utils'), - fs = require('fs'), - track = require('../track'), - path = require('path'); - AssertionError = require('../assert').AssertionError; - -/** - * Reporter info string - */ - -exports.info = "Verbose tests reporter" - - -/** - * Run all tests within each module, reporting the results to the command-line. - * - * @param {Array} files - * @api public - */ - -exports.run = function (files, options, callback) { - - if (!options) { - // load default options - var content = fs.readFileSync( - __dirname + '/../../bin/nodeunit.json', 'utf8' - ); - options = JSON.parse(content); - } - - var error = function (str) { - return options.error_prefix + str + options.error_suffix; - }; - var ok = function (str) { - return options.ok_prefix + str + options.ok_suffix; - }; - var bold = function (str) { - return options.bold_prefix + str + options.bold_suffix; - }; - var assertion_message = function (str) { - return options.assertion_prefix + str + options.assertion_suffix; - }; - - var start = new Date().getTime(); - var paths = files.map(function (p) { - return path.resolve(p); - }); - var tracker = track.createTracker(function (tracker) { - if (tracker.unfinished()) { - console.log(''); - console.log(error(bold( - 'FAILURES: Undone tests (or their setups/teardowns): ' - ))); - var names = tracker.names(); - for (var i = 0; i < names.length; i += 1) { - console.log('- ' + names[i]); - } - console.log(''); - console.log('To fix this, make sure all tests call test.done()'); - process.reallyExit(tracker.unfinished()); - } - }); - - nodeunit.runFiles(paths, { - testspec: options.testspec, - testFullSpec: options.testFullSpec, - moduleStart: function (name) { - console.log('\n' + bold(name)); - }, - testDone: function (name, assertions) { - tracker.remove(name); - - if (!assertions.failures()) { - console.log('✔ ' + name); - } - else { - console.log(error('✖ ' + name)); - } - // verbose so print everything - assertions.forEach(function (a) { - if (a.failed()) { - console.log(error(' ✖ ' + a.message)); - a = utils.betterErrors(a); - console.log(' ' + a.error.stack); - } - else { - console.log(' ✔ ' + a.message); - } - }); - }, - done: function (assertions, end) { - var end = end || new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log( - '\n' + bold(error('FAILURES: ')) + assertions.failures() + - '/' + assertions.length + ' assertions failed (' + - assertions.duration + 'ms)' - ); - } - else { - console.log( - '\n' + bold(ok('OK: ')) + assertions.length + - ' assertions (' + assertions.duration + 'ms)' - ); - } - - if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); - }, - testStart: function(name) { - tracker.put(name); - } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/track.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/track.js deleted file mode 100644 index 5af98ad..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/track.js +++ /dev/null @@ -1,48 +0,0 @@ -/*! - * Simple util module to track tests. Adds a process.exit hook to print - * the undone tests. - */ - - -exports.createTracker = function (on_exit) { - var names = {}; - var tracker = { - names: function () { - var arr = []; - for (var k in names) { - if (names.hasOwnProperty(k)) { - arr.push(k); - } - } - return arr; - }, - unfinished: function () { - return tracker.names().length; - }, - put: function (testname) { - names[testname] = testname; - }, - remove: function (testname) { - delete names[testname]; - } - }; - - process.on('exit', function() { - on_exit = on_exit || exports.default_on_exit; - on_exit(tracker); - }); - - return tracker; -}; - -exports.default_on_exit = function (tracker) { - if (tracker.unfinished()) { - console.log(''); - console.log('Undone tests (or their setups/teardowns): '); - var names = tracker.names(); - for (var i = 0; i < names.length; i += 1) { - console.log(names[i]); - } - process.reallyExit(tracker.unfinished()); - } -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/types.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/types.js deleted file mode 100644 index 879edd8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/types.js +++ /dev/null @@ -1,190 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - * - * THIS FILE SHOULD BE BROWSER-COMPATIBLE JS! - * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build. - * Only code on that line will be removed, it's mostly to avoid requiring code - * that is node specific - */ - -/** - * Module dependencies - */ - -var assert = require('./assert'), //@REMOVE_LINE_FOR_BROWSER - async = require('../deps/async'); //@REMOVE_LINE_FOR_BROWSER - - -/** - * Creates assertion objects representing the result of an assert call. - * Accepts an object or AssertionError as its argument. - * - * @param {object} obj - * @api public - */ - -exports.assertion = function (obj) { - return { - method: obj.method || '', - message: obj.message || (obj.error && obj.error.message) || '', - error: obj.error, - passed: function () { - return !this.error; - }, - failed: function () { - return Boolean(this.error); - } - }; -}; - -/** - * Creates an assertion list object representing a group of assertions. - * Accepts an array of assertion objects. - * - * @param {Array} arr - * @param {Number} duration - * @api public - */ - -exports.assertionList = function (arr, duration) { - var that = arr || []; - that.failures = function () { - var failures = 0; - for (var i = 0; i < this.length; i += 1) { - if (this[i].failed()) { - failures += 1; - } - } - return failures; - }; - that.passes = function () { - return that.length - that.failures(); - }; - that.duration = duration || 0; - return that; -}; - -/** - * Create a wrapper function for assert module methods. Executes a callback - * after it's complete with an assertion object representing the result. - * - * @param {Function} callback - * @api private - */ - -var assertWrapper = function (callback) { - return function (new_method, assert_method, arity) { - return function () { - var message = arguments[arity - 1]; - var a = exports.assertion({method: new_method, message: message}); - try { - assert[assert_method].apply(null, arguments); - } - catch (e) { - a.error = e; - } - callback(a); - }; - }; -}; - -/** - * Creates the 'test' object that gets passed to every test function. - * Accepts the name of the test function as its first argument, followed by - * the start time in ms, the options object and a callback function. - * - * @param {String} name - * @param {Number} start - * @param {Object} options - * @param {Function} callback - * @api public - */ - -exports.test = function (name, start, options, callback) { - var expecting; - var a_list = []; - - var wrapAssert = assertWrapper(function (a) { - a_list.push(a); - if (options.log) { - async.nextTick(function () { - options.log(a); - }); - } - }); - - var test = { - done: function (err) { - if (expecting !== undefined && expecting !== a_list.length) { - var e = new Error( - 'Expected ' + expecting + ' assertions, ' + - a_list.length + ' ran' - ); - var a1 = exports.assertion({method: 'expect', error: e}); - a_list.push(a1); - if (options.log) { - async.nextTick(function () { - options.log(a1); - }); - } - } - if (err) { - var a2 = exports.assertion({error: err}); - a_list.push(a2); - if (options.log) { - async.nextTick(function () { - options.log(a2); - }); - } - } - var end = new Date().getTime(); - async.nextTick(function () { - var assertion_list = exports.assertionList(a_list, end - start); - options.testDone(name, assertion_list); - callback(null, a_list); - }); - }, - ok: wrapAssert('ok', 'ok', 2), - same: wrapAssert('same', 'deepEqual', 3), - equals: wrapAssert('equals', 'equal', 3), - expect: function (num) { - expecting = num; - }, - _assertion_list: a_list - }; - // add all functions from the assert module - for (var k in assert) { - if (assert.hasOwnProperty(k)) { - test[k] = wrapAssert(k, k, assert[k].length); - } - } - return test; -}; - -/** - * Ensures an options object has all callbacks, adding empty callback functions - * if any are missing. - * - * @param {Object} opt - * @return {Object} - * @api public - */ - -exports.options = function (opt) { - var optionalCallback = function (name) { - opt[name] = opt[name] || function () {}; - }; - - optionalCallback('moduleStart'); - optionalCallback('moduleDone'); - optionalCallback('testStart'); - optionalCallback('testReady'); - optionalCallback('testDone'); - //optionalCallback('log'); - - // 'done' callback is not optional. - - return opt; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/utils.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/utils.js deleted file mode 100644 index 5c72990..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/lib/utils.js +++ /dev/null @@ -1,216 +0,0 @@ -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ - -/** - * Module dependencies - */ - -var async = require('../deps/async'), - fs = require('fs'), - util = require('util'), - Script = require('vm').Script, - http = require('http'); - - -/** - * Detect if coffee-script, iced-coffeescript, or streamline are available and - * the respective file extensions to the search filter in modulePaths if it is. - */ - -var extensions = [ 'js' ]; // js is always supported: add it unconditionally -var extensionPattern; - -try { - require('coffee' + '-script/register'); - extensions.push('coffee'); -} catch (e) { } - -try { - require('iced-coffee' + '-script/register'); - extensions.push('iced'); -} catch (e) { } - -try { - require('stream' + 'line').register(); - extensions.push('_coffee'); - extensions.push('_js'); -} catch (e) { } - -extensionPattern = new RegExp('\\.(?:' + extensions.join('|') + ')$'); - - -/** - * Finds all modules at each path in an array, If a path is a directory, it - * returns all supported file types inside it. This only reads 1 level deep in - * the directory and does not recurse through sub-directories. - * - * The extension (.js, .coffee etc) is stripped from the filenames so they can - * simply be require()'ed. - * - * @param {Array} paths - * @param {Function} callback - * @api public - */ - -exports.modulePaths = function (paths, callback) { - async.concat(paths, function (p, cb) { - fs.stat(p, function (err, stats) { - if (err) { - return cb(err); - } - if (stats.isFile()) { - return cb(null, [p]); - } - if (stats.isDirectory()) { - fs.readdir(p, function (err, files) { - if (err) { - return cb(err); - } - - // filter out any filenames with unsupported extensions - var modules = files.filter(function (filename) { - return extensionPattern.exec(filename); - }); - - // remove extension from module name and prepend the - // directory path - var fullpaths = modules.map(function (filename) { - var mod_name = filename.replace(extensionPattern, ''); - return [p, mod_name].join('/'); - }); - - // sort filenames here, because Array.map changes order - fullpaths.sort(); - - cb(null, fullpaths); - }); - } - }); - }, callback); -}; - -/** - * Evaluates JavaScript files in a sandbox, returning the context. The first - * argument can either be a single filename or an array of filenames. If - * multiple filenames are given their contents are concatenated before - * evalution. The second argument is an optional context to use for the sandbox. - * - * @param files - * @param {Object} sandbox - * @return {Object} - * @api public - */ - -exports.sandbox = function (files, /*optional*/sandbox) { - var source, script, result; - if (!(files instanceof Array)) { - files = [files]; - } - source = files.map(function (file) { - return fs.readFileSync(file, 'utf8'); - }).join(''); - - if (!sandbox) { - sandbox = {}; - } - script = new Script(source); - result = script.runInNewContext(sandbox); - return sandbox; -}; - -/** - * Provides a http request, response testing environment. - * - * Example: - * - * var httputil = require('nodeunit').utils.httputil - * exports.testSomething = function(test) { - * httputil(function (req, resp) { - * resp.writeHead(200, {}); - * resp.end('test data'); - * }, - * function(server, client) { - * client.fetch('GET', '/', {}, function(resp) { - * test.equal('test data', resp.body); - * server.close(); - * test.done(); - * }) - * }); - * }; - * - * @param {Function} cgi - * @param {Function} envReady - * @api public - */ -exports.httputil = function (cgi, envReady) { - var hostname = process.env.HOSTNAME || 'localhost'; - var port = process.env.PORT || 3000; - - var server = http.createServer(cgi); - server.listen(port, hostname); - - var client = http.createClient(port, hostname); - client.fetch = function (method, path, headers, respReady) { - var request = this.request(method, path, headers); - request.end(); - request.on('response', function (response) { - response.setEncoding('utf8'); - response.on('data', function (chunk) { - if (response.body) { - response.body += chunk; - } else { - response.body = chunk; - } - }); - response.on('end', function () { - if (response.headers['content-type'] === 'application/json') { - response.bodyAsObject = JSON.parse(response.body); - } - respReady(response); - }); - }); - }; - - process.nextTick(function () { - if (envReady && typeof envReady === 'function') { - envReady(server, client); - } - }); -}; - - -/** - * Improves formatting of AssertionError messages to make deepEqual etc more - * readable. - * - * @param {Object} assertion - * @return {Object} - * @api public - */ - -exports.betterErrors = function (assertion) { - if (!assertion.error) { - return assertion; - } - var e = assertion.error; - if (e.actual && e.expected) { - var actual = util.inspect(e.actual, false, 10).replace(/\n$/, ''); - var expected = util.inspect(e.expected, false, 10).replace(/\n$/, ''); - var multiline = ( - actual.indexOf('\n') !== -1 || - expected.indexOf('\n') !== -1 - ); - var spacing = (multiline ? '\n' : ' '); - e._message = e.message; - e.stack = ( - e.name + ':' + spacing + - actual + spacing + e.operator + spacing + - expected + '\n' + - e.stack.split('\n').slice(1).join('\n') - ); - } - return assertion; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/man1/nodeunit.1 b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/man1/nodeunit.1 deleted file mode 100644 index 450772d..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/man1/nodeunit.1 +++ /dev/null @@ -1,95 +0,0 @@ -.\" Generated with Ronnjs/v0.1 -.\" http://github.com/kapouer/ronnjs/ -. -.TH "NODEUNIT" "1" "October 2010" "" "" -. -.SH "NAME" -\fBnodeunit\fR \-\- simple node\.js unit testing tool -. -.SH "SYNOPSIS" -. -.nf -nodeunit [options] [ \.\.\.] -. -.fi -. -.SH "DESCRIPTION" -Nodeunit is a simple unit testing tool based on the node\.js assert module\. -. -.IP "\(bu" 4 -Simple to use -. -.IP "\(bu" 4 -Just export the tests from a module -. -.IP "\(bu" 4 -Helps you avoid common pitfalls when testing asynchronous code -. -.IP "\(bu" 4 -Easy to add test cases with setUp and tearDown functions if you wish -. -.IP "\(bu" 4 -Allows the use of mocks and stubs -. -.IP "" 0 -. -.SH "OPTIONS" - \fB\-\-config FILE\fR: -. -.br - Load config options from a JSON file, allows the customisation - of color schemes for the default test reporter etc\. - See bin/nodeunit\.json for current available options\. -. -.P - \fB\-\-reporter FILE\fR: -. -.br - You can set the test reporter to a custom module or on of the modules - in nodeunit/lib/reporters, when omitted, the default test runner is used\. -. -.P - \fB\-\-list\-reporters\fR: -. -.br - List available build\-in reporters\. -. -.P - \fB\-h\fR, \fB\-\-help\fR: -. -.br - Display the help and exit\. -. -.P - \fB\-v\fR, \fB\-\-version\fR: -. -.br - Output version information and exit\. -. -.P - \fB\fR: - You can run nodeunit on specific files or on all \fI*\.js\fR files inside -. -.br - a directory\. -. -.SH "AUTHORS" -Written by Caolan McMahon and other nodeunit contributors\. -. -.br -Contributors list: \fIhttp://github\.com/caolan/nodeunit/contributors\fR\|\. -. -.SH "REPORTING BUGS" -Report nodeunit bugs to \fIhttp://github\.com/caolan/nodeunit/issues\fR\|\. -. -.SH "COPYRIGHT" -Copyright © 2010 Caolan McMahon\. -. -.br -Nodeunit has been released under the MIT license: -. -.br -\fIhttp://github\.com/caolan/nodeunit/raw/master/LICENSE\fR\|\. -. -.SH "SEE ALSO" -node(1) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/.bin/tap b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/.bin/tap deleted file mode 120000 index 999914b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/.bin/tap +++ /dev/null @@ -1 +0,0 @@ -../tap/bin/tap.js \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/.npmignore deleted file mode 100644 index e69de29..0000000 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/AUTHORS b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/AUTHORS deleted file mode 100644 index b7f6eb2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# contributors sorted by whether or not they're me -Isaac Z. Schlueter -baudehlo -James Halliday -Jason Smith (air) -Pedro P. Candel -Stein Martin Hustad -Trent Mick -Corey Richardson -Raynos -Siddharth Mahendraker diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/README.md deleted file mode 100644 index bed3955..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/README.md +++ /dev/null @@ -1,86 +0,0 @@ -This is a mix-and-match set of utilities that you can use to write test -harnesses and frameworks that communicate with one another using the -Test Anything Protocol. - -If you don't yet know what TAP is, [you better ask -somebody](http://testanything.org/). - -Default Usage: - -1. Make a directory. Maybe call it 'test'. That'd be nice and obvious. -2. Put a bunch of test scripts in there. If they're node programs, then - they should be ".js". Anything else is assumed to be some kind of shell - script, which should have a shebang line. -3. `npm install tap` -4. Update package.json scripts.test to include `tap ./test` [example - gist](https://gist.github.com/4469613) -5. `npm test` - -The output will be TAP-compliant. - -For extra special bonus points, you can do something like this: - - var test = require("tap").test - test("make sure the thingie is a thing", function (t) { - t.equal(thingie, "thing", "thingie should be thing") - t.deepEqual(array, ["foo", "bar"], "array has foo and bar elements") - t.strictDeepEqual(object, {foo: 42, bar: "thingie"}, "object has foo (Number) and bar (String) property") - t.type(thingie, "string", "type of thingie is string") - t.ok(true, "this is always true") - t.notOk(false, "this is never true") - t.test("a child test", function (t) { - t.equal(this, superEasy, "right!?") - t.similar(7, 2, "ever notice 7 is kinda like 2?", {todo: true}) - t.test("so skippable", {skip: true}, function (t) { - t.plan(1) // only one test in this block - t.ok(true, "but when the flag changes, it'll pass") - // no need to end, since we had a plan. - }) - t.end() - }) - t.ok(99, "can also skip individual assertions", {skip: true}) - // end lets it know it's over. - t.end() - }) - test("another one", function (t) { - t.plan(1) - t.ok(true, "It's ok to plan, and also end. Watch.") - t.end() // but it must match the plan! - }) - -Node-tap is actually a collection of several modules, any of which may be -mixed and matched however you please. - -If you don't like this test framework, and think you can do much much -better, *I strongly encourage you to do so!* If you use this library, -however, at least to output TAP-compliant results when `process.env.TAP` -is set, then the data coming out of your framework will be much more -consumable by machines. - -You can also use this to build programs that *consume* the TAP data, so -this is very useful for CI systems and such. - -* tap-assert: A collection of assert functions that return TAP result - objects. -* tap-consumer: A stream interface for consuming TAP data. -* tap-producer: A class that produces a TAP stream by taking in result - objects. -* tap-results: A class for keeping track of TAP result objects as they - pass by, counting up skips, passes, fails, and so on. -* tap-runner: A program that runs through a directory running all the - tests in it. (Tests which may or may not be TAP-outputting tests. But - it's better if they are.) -* tap-test: A class for actually running tests. -* tap-harness: A class that runs tests. (Tests are also Harnesses, - which is how sub-tests run.) -* tap-global-harness: A default harness that provides the top-level - support for running TAP tests. - -## Experimental Code Coverage with runforcover & bunker: - -``` -TAP_COV=1 tap ./test [--cover=./lib,foo.js] [--coverage-dir=./coverage] -``` - -This feature is experimental, and will most likely change somewhat -before being finalized. Feedback welcome. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-http.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-http.js deleted file mode 100644 index 296910f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-http.js +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env node - -// just an example, really -// Run with `node tap-http.js path/to/tests/` - -var argv = process.argv.slice(2) - , path = require("path") - , Runner = require("../lib/tap-runner") - - , http = require("http") - , server = http.createServer(function (req, res) { - // it'd be nice to return a non-200 if the tests fail, but we don't - // know the status until it's done, so that would mean not being able - // to pipe the output - res.writeHead(200, {'content-type': 'text/plain'}) - new Runner(argv, null).pipe(res) - }) - -server.listen(1337) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-reader.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-reader.js deleted file mode 100755 index b196cc2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap-reader.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -// read a tap stream from stdin. - -var TapConsumer = require("../lib/tap-consumer") - , TapProducer = require("../lib/tap-producer") - -var tc = new TapConsumer - , tp = new TapProducer - -//process.stdin.pipe(tc) -process.stdin.on("data", function (c) { - c = c + "" - // console.error(JSON.stringify(c).substr(0, 100)) - tc.write(c) -}) -process.stdin.on("end", function () { tc.end() }) -process.stdin.resume() -//tc.pipe(tp) -tc.on("data", function (c) { - tp.write(c) -}) -tc.on("end", function () { tp.end() }) - -tp.on("data", function (c) { - console.error(["output write", c]) - process.stdout.write(c) -}) - -tp.on("end", function (er, total, ok) { - if (er) throw er - process.exit(total - ok) -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap.js deleted file mode 100755 index c666040..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/bin/tap.js +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env node - -var argv = process.argv.slice(2) - , path = require("path") - , Runner = require("../lib/tap-runner") - - , nopt = require("nopt") - - , knownOpts = - { cover: [path, false] - , "cover-dir": path - , stderr: Boolean - , stdout: Boolean - , diag: Boolean - , version: Boolean - , tap: Boolean - , timeout: Number - , gc: Boolean - , debug: Boolean - , "debug-brk": Boolean - , strict: Boolean - , harmony: Boolean - } - - , shorthands = - // debugging 1: show stderr - { d: ["--stderr"] - // debugging 2: show stderr and tap - , dd: ["--stderr", "--tap"] - // debugging 3: show stderr, tap, AND always show diagnostics. - , ddd: ["--stderr", "--tap", "--diag"] - , "expose-gc": ["--gc"] - , g: ["--gc"] - , e: ["--stderr"] - , t: ["--timeout"] - , o: ["--tap"] - , c: ["--cover"] - , v: ["--version"] - , "?": ["--help"] - , h: ["--help"] - } - - , defaults = - { cover: "./lib" - , "cover-dir": "./coverage" - , stderr: process.env.TAP_STDERR !== '0' - , tap: process.env.TAP - , diag: process.env.TAP_DIAG - , timeout: +process.env.TAP_TIMEOUT || 30 - , gc: false - , debug: false - , "debug-brk": false - , strict: false - , harmony: false - , version: false - , help: false } - - , options = nopt(knownOpts, shorthands) - -if (options.version) { - console.log(require("../package.json").version) - process.exit(0) -} - -if (options.help) { - console.log(function(){/* - -Usage: - tap - - Run the files as tap tests, parse the output, and report the results - -Options: - - --stderr Print standard error output of tests to standard error. - --tap Print raw tap output. - --diag Print diagnostic output for passed tests, as well as failed. - (Implies --tap) - --gc Expose the garbage collector to tests. - --timeout Maximum time to wait for a subtest, in seconds. Default: 30 - --debug Pass the '--debug' flag to node for debugging - --debug-brk Pass the '--debug-brk' flag to node for debugging - --strict Enforce strict mode when running tests. - --harmony Enable harmony features for tests. - --version Print the version of node tap. - --help Print this help. - -Please report bugs! https://github.com/isaacs/node-tap/issues - -*/}.toString().split(/\n/).slice(1, -1).join("\n")) - process.exit(0) -} - - -Object.keys(defaults).forEach(function (k) { - if (!options.hasOwnProperty(k)) options[k] = defaults[k] -}) - -// other tests that might rely on these -if (options.diag) process.env.TAP_DIAG = true -if (options.tap) process.env.TAP = true -if (options.timeout) process.env.TAP_TIMEOUT = options.timeout - -var r = new Runner(options) - , TapProducer = require("../lib/tap-producer") - -if (options.tap || options.diag) { - r.pipe(process.stdout) -} else { - r.on("file", function (file, results, details) { - var s = (details.ok ? "" : "not ") + "ok "+results.name - , n = details.pass + "/" + details.testsTotal - , dots = new Array(Math.max(1, 60 - s.length - n.length)).join(".") - console.log("%s %s %s", s, dots, n) - if (details.ok) { - if (details.skip) { - console.log(" skipped: %s", details.skip) - } - if (details.todo) { - console.log(" todo: %s", details.todo) - } - } else { - // console.error(details) - console.log(" Command: %s", results.command) - console.log(" " + TapProducer.encode(details.list) - .split(/\n/).join("\n ")) - } - }) - r.on("end", function () { - //console.log(r) - var s = "total" - , n = r.results.pass + "/" + r.results.testsTotal - , dots = new Array(60 - s.length - n.length).join(".") - , ok = r.results.ok ? "ok" : "not ok" - console.log("%s %s %s\n\n%s", s, dots, n, ok) - if (r.doCoverage) { - console.error( "\nCoverage: %s\n" - , path.resolve(r.coverageOutDir, "index.html") ) - } - }) -} - - - -r.on("end", function () { - process.exit(r.results.ok ? 0 : 1) -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/bar.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/bar.js deleted file mode 100644 index e7cb7ad..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/bar.js +++ /dev/null @@ -1,15 +0,0 @@ -var Bar = module.exports = function(str) { - this.bar = str; - this.str = str; -}; - -Bar.prototype.foo = function() { - var self = this; - return self.bar; -}; - -Bar.prototype.baz = function() { - var self = this; - return self.str; -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/foo.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/foo.js deleted file mode 100644 index cb9ee8f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/lib/foo.js +++ /dev/null @@ -1,15 +0,0 @@ -var Foo = module.exports = function(str) { - this.foo = str; - this.str = str; -}; - -Foo.prototype.bar = function() { - var self = this; - return self.foo; -}; - -Foo.prototype.baz = function() { - var self = this; - return self.str; -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/bar.test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/bar.test.js deleted file mode 100644 index 91e4bc2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/bar.test.js +++ /dev/null @@ -1,20 +0,0 @@ -var test = require('tap').test, - Bar = require('../lib/bar'), - bar; - -test('setup', function(t) { - bar = new Bar('baz'); - t.ok(bar); - t.end(); -}); - -test('bar', function(t) { - t.equal('baz', bar.foo()); - t.end(); -}); - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/baz.test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/baz.test.js deleted file mode 100644 index fae22d8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/baz.test.js +++ /dev/null @@ -1,29 +0,0 @@ -var test = require('tap').test, - Foo = require('../lib/foo'), - Bar = require('../lib/bar'), - foo, bar; - -test('setup', function(t) { - foo = new Foo('baz'); - t.ok(foo); - bar = new Bar('baz'); - t.ok(bar); - t.end(); -}); - -test('baz from Foo', function(t) { - t.equal('baz', foo.baz()); - t.end(); -}); - -test('baz from Bar', function(t) { - t.equal('baz', bar.baz()); - t.end(); -}); - - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/foo.test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/foo.test.js deleted file mode 100644 index 2aed8fd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/coverage-example/test/foo.test.js +++ /dev/null @@ -1,20 +0,0 @@ -var test = require('tap').test, - Foo = require('../lib/foo'), - foo; - -test('setup', function(t) { - foo = new Foo('baz'); - t.ok(foo); - t.end(); -}); - -test('bar', function(t) { - t.equal('baz', foo.bar()); - t.end(); -}); - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/lib/math.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/lib/math.js deleted file mode 100644 index f798626..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/lib/math.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = Math diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/test/test-example.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/test/test-example.js deleted file mode 100644 index cd2549b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/example/test/test-example.js +++ /dev/null @@ -1,237 +0,0 @@ -var tap = require("tap") - , test = tap.test - , plan = tap.plan - , math - -test("load sut", function (t) { - math = require("../lib/math") - t.ok(math, "object loaded") - t.end() -}) - -test("validate constants", function (t) { - t.equal(math.LN10, 2.302585092994046, "ln 10") - t.equal(math.PI, 3.141592653589793, "pi") - t.equal(math.E, 2.718281828459045, "e") - t.equal(math.LOG10E, 0.4342944819032518, "log 10 e") - t.equal(math.SQRT2, 1.4142135623730951, "sqrt 2") - t.equal(math.SQRT1_2, 0.7071067811865476, "sqrt 1/2") - t.equal(math.LN2, 0.6931471805599453, "ln2") - t.end() -}) - -test("using this", function (t) { - // this also works. - this.equal(t, this, "call in scope of test obj") - this.end() -}) - -// test setTimeout, just a trivial example. -test("setTimeout", function (t) { - var start = Date.now() - setTimeout(function () { - t.ok(Date.now() >= start + 50, "timeout fired after delay") - t.end() - }, 50) -}) - -// another way to do the same, using a plan. -// this is more robust, but annoying when you have a long list -// of tests for something. For async stuff, it's generally better, -// since there's a higher risk of the control flowing off to lala land. -test("setTimeout planned", function (t) { - t.plan(1) - var start = Date.now() - setTimeout(function () { - t.ok(Date.now() >= start + 50, "timeout fired after delay") - }, 50) -}) - -// plans also are good for cases where things may fire in a non-deterministic -// order, since it won't be as obvious when everything is done. -test("setTimeout parallel", function (t) { - t.plan(2) - var start = Date.now() - setTimeout(function A () { - t.ok(Date.now() >= start + 50, "timeout A fired after delay") - }, 50) - setTimeout(function B () { - t.ok(Date.now() >= start + 50, "timeout B fired after delay") - }, 50) -}) - -// something slightly less hello worldy -test("async test", function (t) { - t.plan(4) - var fs = require("fs") - t.ok(fs, "fs library should load") - var rs = fs.createReadStream(__filename) - t.ok(rs, "read stream should start fine.") - rs.on("open", function (fd) { - t.type(fd, "number", "file descriptor should be a number") - t.equal(fd, rs.fd, "fd should match stream fd") - }) -}) - -// you can bail out of the entire everything if something is just -// Not Right (db not installed, etc.) -test("tarp", function (parent) { - if (7 === 5) { - parent.bailout("math is broken") - } - // bailout bubbles up a bit like "error" events - // if unhandled, then the parent will bail, as well. - parent.test("child bailouts", function (child) { - child.on("bailout", function (s) { - parent.fail("children shouldn't bail.") - }) - child.bailout("try to bail out, but instead just fail a test") - }) - - parent.test("child bailout 2", function (child) { - child.bailout("this one will bail out") - }) -}) - -// tests marked "todo" can fail without counting against the overall score -// never ever ever write tests to "verify" incorrect behavior! -test("unfinished test", function (t) { - t.equal(math.cos(math.PI), -1, "cos(PI)") - t.equal(math.sin(math.PI), 0, "sin(PI)") - t.equal(math.face, "your face", "math.face should be your face # TODO") - t.end() -}) - -// tests can have children. -test("http server", function (t) { - // one test plus 4 children. - t.plan(5) - - var http = require("http") - , PORT = 12346 - - t.ok(http, "http module should load") - var server - - t.test("set up server", function (t) { - t.plan(2) - server = http.createServer(function (req, res) { - t.comment("Request: "+req.url) - res.writeHead(200, {}) - res.end(req.method + " " + req.url) - }) - t.ok(server, "createServer should create a server") - server.listen(PORT, t.cb("listen should fire callback")) - }) - - // set the "parallel" flag on this one. - // That signals the harness to proceed immediately to the next test, - // and run them in parallel. - // Default behavior is to wait for each test to complete before proceeding - // to the next one. - // The first not-parallel test encountered will cause it to wait for that - // test, as well as all the parallel tests before it. - // A, B', C', D', E (where ' means "parallel") - // Runs A, and then B, C, and D in parallel, and then E. - t.test("testing POST", {parallel: true}, function (t) { - t.plan(1) - http.request("POST", { method: "POST" - , host: "localhost" - , path: "/foo" - , port: PORT }).on("response", function (res) { - t.bufferStream(res, function (s) { t.equal(s, "POST /foo") }) - }).end() - }) - - t.test("testing GET", {parallel: true}, function (t) { - t.plan(1) - http.request("POST", { method: "GET" - , host: "localhost" - , path: "/foo" - , port: PORT }).on("response", function (res) { - t.bufferStream(res, function (s) { t.equal(s, "GET /foo") }) - }).end() - }) - - // wrap in a test so that if this throws, it'll log as a failed test. - t.test("teardown", function (t) { - server.close() - t.end() - }) -}) - -// yo dawg! -test("meta-tests", function (t) { - t.plan(5) - - // t.fails() wraps a child test and succeeds if it fails. - t.fails(t.test("this should fail", function (t) { - t.ok(false, "assert false") - t.end() - })) - - // t.timesOut() wraps a child test and succeeds if it times out. - // if t.end() is called, or if a plan is completed, then it fails. - // set the timeout really low so that it will not take forever. - t.timesOut(t.test("this should timeout", { timeout: 1 }, function (t) { - t.ok(true, "assert true") - // t.end() never called. - })) - - // t.incomplete() wraps a child test and succeeds if it ends before - // the plan is finished. - t.incomplete(t.test("this should be incomplete", function (t) { - t.plan(100) - t.ok(true, "assert true") - // calling end prematurely. - t.end() - })) - - // t.bailsOut() wraps a child test and succeeds if it calls bailout() - t.bailsOut(t.test("this should bailout", function (t) { - t.bailout("oh noes, bailing out!") - })) - - // low-level analysis of subtests - t.test("verifying test success/failure expectations", function (t) { - t.once("end", function () { - var res = t.results - , is = t.equal - // hijack! - t.clear() - is(res.ok, false, "ok") - - is(res.bailedOut, false, "bailed out") - - is(res.skip, 2, "skips") - is(res.skipPass, 1, "skip that passed") - is(res.skipFail, 1, "skip that failed") - - is(res.todo, 2, "todos") - is(res.todoPass, 1, "todo that passed") - is(res.todoFail, 1, "todo that failed") - - is(res.failTotal, 3, "failures total") - is(res.fail, 1, "relevant failure") - - is(res.passTotal, 3, "passes total") - is(res.pass, 1, "relevant pass") - - is(res.testsTotal, 6, "total tests") - is(res.tests, 2, "should be 2 relevant tests") - - t.end() - }) - - // run the metatest. - // *this* is the actual SUT in this case. - t.ok(false, "failing todo #todo") - // can also set #todo or #skip explicitly - t.ok(true, "succeeding todo", {todo: true}) - t.ok(false, "failing skip #skip", {skip: true}) - t.ok(true, "suceeding skip #skip") - t.ok(false, "failing test") - t.ok(true, "succeeding test") - t.end() - }) -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/main.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/main.js deleted file mode 100644 index a9a520a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/main.js +++ /dev/null @@ -1,16 +0,0 @@ - -var GlobalHarness = require("./tap-global-harness") - -// this lets you do stuff like: -// var test = require("tap").test -// test(...) -// to run stuff in the global harness. -exports = module.exports = new GlobalHarness() - -exports.createProducer = exports.Producer = require("./tap-producer") -exports.createConsumer = exports.Consumer = require("./tap-consumer") -exports.yamlish = require("yamlish") -exports.createTest = exports.Test = require("./tap-test") -exports.createHarness = exports.Harness = require("./tap-harness") -exports.createRunner = exports.Runner = require("./tap-runner") -exports.assert = require("./tap-assert") diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-assert.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-assert.js deleted file mode 100644 index 9838961..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-assert.js +++ /dev/null @@ -1,466 +0,0 @@ -// an assert module that returns tappable data for each assertion. -var difflet = require('difflet') - , deepEqual = require('deep-equal') - , bufferEqual = require('buffer-equal') - , Buffer = require('buffer').Buffer - -module.exports = assert - -var syns = {} - , id = 1 - -function assert (ok, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - - //console.error("assert %j", [ok, message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - //console.error("assert", [ok, message, extra]) - ok = !!ok - var res = { id : id ++, ok: ok } - - var caller = getCaller(extra && extra.error) - if (extra && extra.error) { - res.type = extra.error.name - res.message = extra.error.message - res.code = extra.error.code - || extra.error.type - res.errno = extra.error.errno - delete extra.error - } - if (caller.file) { - res.file = caller.file - res.line = +caller.line - res.column = +caller.column - } - res.stack = caller.stack - - res.name = message || "(unnamed assert)" - - if (extra) Object.keys(extra).forEach(function (k) { - if (!res.hasOwnProperty(k)) res[k] = extra[k] - }) - - // strings and objects are hard to diff by eye - if (!ok && - res.hasOwnProperty("found") && - res.hasOwnProperty("wanted") && - res.found !== res.wanted) { - if (typeof res.wanted !== typeof res.found || - typeof res.wanted === "object" && (!res.found || !res.wanted)) { - res.type = { found: typeof found - , wanted: typeof wanted } - } else if (typeof res.wanted === "string") { - res.diff = diffString(res.found, res.wanted) - } else if (typeof res.wanted === "object") { - res.diff = diffObject(res.found, res.wanted) - } - } - - //console.error("assert return", res) - - return res -} -assert.ok = assert -syns.ok = [ "true", "assert" ] - - -function notOk (ok, message, extra) { - return assert(!ok, message, extra) -} -assert.notOk = notOk -syns.notOk = [ "false", "notok" ] - -function error (er, message, extra) { - if (!er) { - // just like notOk(er) - return assert(!er, message, extra) - } - message = message || er.message - extra = extra || {} - extra.error = er - return assert.fail(message, extra) -} -assert.error = error -syns.error = [ "ifError", "ifErr", "iferror" ] - - -function pass (message, extra) { - return assert(true, message, extra) -} -assert.pass = pass - -function fail (message, extra) { - //console.error("assert.fail", [message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - return assert(false, message, extra) -} -assert.fail = fail - -function skip (message, extra) { - //console.error("assert.skip", message, extra) - if (!extra) extra = {} - return { id: id ++, skip: true, name: message || "", - explanation: extra.explanation || "" } -} -assert.skip = skip - -function throws (fn, wanted, message, extra) { - if (typeof wanted === "string") { - extra = message - message = wanted - wanted = null - } - - if (extra && extra.skip) return assert.skip(message, extra) - - var found = null - try { - fn() - } catch (e) { - found = { name: e.name, message: e.message } - } - - extra = extra || {} - - extra.found = found - if (wanted) { - wanted = { name: wanted.name, message: wanted.message } - extra.wanted = wanted - } - - if (!message) { - message = "Expected to throw" - if (wanted) message += ": "+wanted.name + " " + wanted.message - } - - return (wanted) ? assert.similar(found, wanted, message, extra) - : assert.ok(found, message, extra) -} -assert.throws = throws - - -function doesNotThrow (fn, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var found = null - try { - fn() - } catch (e) { - found = {name: e.name, message: e.message} - } - message = message || "Should not throw" - - return assert.equal(found, null, message, extra) -} -assert.doesNotThrow = doesNotThrow - - -function equal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should be equal" - extra.found = a - extra.wanted = b - return assert(a === b, message, extra) -} -assert.equal = equal -syns.equal = ["equals" - ,"isEqual" - ,"is" - ,"strictEqual" - ,"strictEquals"] - - -function equivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var extra = extra || {} - message = message || "should be equivalent" - extra.found = a - extra.wanted = b - - if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { - return assert(bufferEqual(a, b), message, extra) - } else { - return assert(deepEqual(a, b), message, extra) - } -} -assert.equivalent = equivalent -syns.equivalent = ["isEquivalent" - ,"looseEqual" - ,"looseEquals" - ,"isDeeply" - ,"same" - ,"deepEqual" - ,"deepEquals"] - -function strictDeepEqual (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var extra = extra || {} - message = message || "should be strictly equal" - extra.found = a - extra.wanted = b - - if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { - return assert(bufferEqual(a, b), message, extra) - } else { - return assert(deepEqual(a, b, {strict: true}), message, extra) - } -} -assert.strictDeepEqual = strictDeepEqual -syns.strictDeepEqual = ["isStrictEquivalent" - ,"isStrictly" - ,"exactSame" - ,"strictDeepEqual" - ,"strictDeepEquals"] - - -function inequal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equal" - extra.found = a - extra.doNotWant = b - return assert(a !== b, message, extra) -} -assert.inequal = inequal -syns.inequal = ["notEqual" - ,"notEquals" - ,"notStrictEqual" - ,"notStrictEquals" - ,"isNotEqual" - ,"isNot" - ,"not" - ,"doesNotEqual" - ,"isInequal"] - - -function inequivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equivalent" - extra.found = a - extra.doNotWant = b - - if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { - return assert(!bufferEqual(a, b), message, extra) - } else { - return assert(!deepEqual(a, b), message, extra) - } -} -assert.inequivalent = inequivalent -syns.inequivalent = ["notEquivalent" - ,"notDeepEqual" - ,"notDeeply" - ,"notSame" - ,"isNotDeepEqual" - ,"isNotDeeply" - ,"isNotEquivalent" - ,"isInequivalent"] - -function similar (a, b, message, extra, flip) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be similar" - - if (typeof a === "string" && - (Object.prototype.toString.call(b) === "[object RegExp]")) { - extra = extra || {} - extra.pattern = b - extra.string = a - var ok = a.match(b) - extra.match = ok - if (flip) ok = !ok - return assert.ok(ok, message, extra) - } - - var isObj = assert(a && typeof a === "object", message, extra) - if (!isObj.ok) { - // not an object - if (a == b) isObj.ok = true - if (flip) isObj.ok = !isObj.ok - return isObj - } - - var eq = flip ? inequivalent : equivalent - return eq(selectFields(a, b), b, message, extra) -} -assert.similar = similar -syns.similar = ["isSimilar" - ,"has" - ,"hasFields" - ,"like" - ,"isLike"] - -function dissimilar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - message = message || "should be dissimilar" - return similar(a, b, message, extra, true) -} -assert.dissimilar = dissimilar -syns.dissimilar = ["unsimilar" - ,"notSimilar" - ,"unlike" - ,"isUnlike" - ,"notLike" - ,"isNotLike" - ,"doesNotHave" - ,"isNotSimilar" - ,"isDissimilar"] - -function type (thing, t, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var name = t - if (typeof name === "function") name = name.name || "(anonymous ctor)" - //console.error("name=%s", name) - message = message || "type is "+name - var type = typeof thing - //console.error("type=%s", type) - if (!thing && type === "object") type = "null" - if (type === "object" && t !== "object") { - if (typeof t === "function") { - //console.error("it is a function!") - extra = extra || {} - extra.found = Object.getPrototypeOf(thing).constructor.name - extra.wanted = name - //console.error(thing instanceof t, name) - return assert.ok(thing instanceof t, message, extra) - } - - //console.error("check prototype chain") - // check against classnames or objects in prototype chain, as well. - // type(new Error("asdf"), "Error") - // type(Object.create(foo), foo) - var p = thing - while (p = Object.getPrototypeOf(p)) { - if (p === t || p.constructor && p.constructor.name === t) { - type = name - break - } - } - } - //console.error(type, name, type === name) - return assert.equal(type, name, message, extra) -} -assert.type = type -syns.type = ["isa"] - -// synonyms are helpful. -Object.keys(syns).forEach(function (c) { - syns[c].forEach(function (s) { - Object.defineProperty(assert, s, { value: assert[c], enumerable: false }) - }) -}) - -// helpers below - -function selectFields (a, b) { - // get the values in A of the fields in B - var ret = Array.isArray(b) ? [] : {} - Object.keys(b).forEach(function (k) { - if (!a.hasOwnProperty(k)) return - var v = b[k] - , av = a[k] - if (v && av && typeof v === "object" && typeof av === "object" - && !(v instanceof Date) - && !(v instanceof RegExp) - && !(v instanceof String) - && !(v instanceof Boolean) - && !(v instanceof Number) - && !(Array.isArray(v))) { - ret[k] = selectFields(av, v) - } else ret[k] = av - }) - return ret -} - -function sortObject (obj) { - if (typeof obj !== 'object' || Array.isArray(obj) || obj === null) { - return obj - } - - return Object.keys(obj).sort().reduce(function (acc, key) { - acc[key] = sortObject(obj[key]) - return acc - }, {}) -} - -function stringify (a) { - return JSON.stringify(sortObject(a), (function () { - var seen = [] - , keys = [] - return function (key, val) { - var s = seen.indexOf(val) - if (s !== -1) { - return "[Circular: "+keys[s]+"]" - } - if (val && typeof val === "object" || typeof val === "function") { - seen.push(val) - keys.push(val["!"] || val.name || key || "") - if (typeof val === "function") { - return val.toString().split(/\n/)[0] - } else if (typeof val.toUTCString === "function") { - return val.toUTCString() - } - } - return val - }})()) -} - -function diffString (f, w) { - if (w === f) return null - var p = 0 - , l = w.length - while (p < l && w.charAt(p) === f.charAt(p)) p ++ - w = stringify(w).substr(1).replace(/"$/, "") - f = stringify(f).substr(1).replace(/"$/, "") - return diff(f, w, p) -} - -function diffObject (f, w) { - return difflet({ indent : 2, comment : true }).compare(w, f) -} - -function diff (f, w, p) { - if (w === f) return null - var i = p || 0 // it's going to be at least p. JSON can only be bigger. - , l = w.length - while (i < l && w.charAt(i) === f.charAt(i)) i ++ - var pos = Math.max(0, i - 20) - w = w.substr(pos, 40) - f = f.substr(pos, 40) - var pointer = i - pos - return "FOUND: "+f+"\n" - + "WANTED: "+w+"\n" - + (new Array(pointer + 9).join(" ")) - + "^ (at position = "+p+")" -} - -function getCaller (er) { - // get the first file/line that isn't this file. - if (!er) er = new Error - var stack = er.stack || "" - stack = stack.split(/\n/) - for (var i = 1, l = stack.length; i < l; i ++) { - var s = stack[i].match(/\(([^):]+):([0-9]+):([0-9]+)\)$/) - if (!s) continue - var file = s[1] - , line = +s[2] - , col = +s[3] - if (file.indexOf(__dirname) === 0) continue - if (file.match(/tap-test\/test.js$/)) continue - else break - } - var res = {} - if (file && file !== __filename && !file.match(/tap-test\/test.js$/)) { - res.file = file - res.line = line - res.column = col - } - - res.stack = stack.slice(1).map(function (s) { - return s.replace(/^\s*at\s*/, "") - }) - - return res -} - - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-browser-harness.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-browser-harness.js deleted file mode 100644 index 9eaa0e4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-browser-harness.js +++ /dev/null @@ -1,63 +0,0 @@ -// this is just a harness that pipes to stdout. -// It's the default one. -module.exports = BrowserHarness - -var BrowserHarness = global.TAP_Browser_Harness - , inherits = require("inherits") - , Results = require("./tap-results") - , Harness = require("./tap-harness") - , Test = require("./tap-test") - -inherits(BrowserHarness, Harness) -function BrowserHarness (outPipe) { - //console.error("calling BrowserHarness") - if (browserHarness) return browserHarness - if (!(this instanceof BrowserHarness)) { - return browserHarness = new BrowserHarness - } - browserHarness = global.TAP_Browser_Harness = this - Harness.call(this, Test) - - if (outPipe) this.output.pipe(outPipe) - - this.test = this.test.bind(this) - - this.plan = this.plan.bind(this) - - var output = this.output - this.on("childEnd", function (child) { - //console.error("childEnd in global harness") - //console.error(child.results) - // write out the stuff for this child. - //console.error("child.conf", child.conf) - - // maybe write some other stuff about the number of tests in this - // thing, etc. I dunno. - //console.error("child results", child.results) - this.results.list.forEach(function (res) { - //delete res.error - //console.error("child resuilt", res) - output.write(res) - }) - //console.error("wrote child results") - this.results.list.length = 0 - }) - - var streamEnded = false - this.on("end", function () { - //console.error("global ending the stream") - if (!streamEnded) { - this.results.list.forEach(function (res) { - output.write(res) - }) - this.results.list.length = 0 - output.end() - streamEnded = true - } - }) - - // TODO: handle global errors - // process.on("unhandledException", function (e) { - // this.bailout("unhandled exception: " + e.message) - // }) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-consumer.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-consumer.js deleted file mode 100644 index 0b991a5..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-consumer.js +++ /dev/null @@ -1,246 +0,0 @@ -module.exports = TapConsumer - -// pipe a stream into this that's emitting tap-formatted data, -// and it'll emit "data" events with test objects or comment strings -// and an "end" event with the final results. - -var yamlish = require("yamlish") - , Results = require("./tap-results") - , inherits = require("inherits") - -TapConsumer.decode = TapConsumer.parse = function (str) { - var tc = new TapConsumer - , list = [] - tc.on("data", function (res) { - list.push(res) - }) - tc.end(str) - tc.results.list = list - return tc.results -} - -var Stream = require("stream").Stream -inherits(TapConsumer, Stream) -function TapConsumer () { - if (!(this instanceof TapConsumer)) { - return new TapConsumer - } - - Stream.call(this) - this.results = new Results - this.readable = this.writable = true - - this.on("data", function (res) { - if (typeof res === "object") this.results.add(res) - }) - - this._plan = null - this._buffer = "" - this._indent = [] - this._current = null - this._actualCount = 0 - this._passed = [] - this._failed = [] - //console.error("TapConsumer ctor done") -} - -TapConsumer.prototype.bailedOut = false - -TapConsumer.prototype.write = function (chunk) { - if (!this.writable) this.emit("error", new Error("not writable")) - if (this.bailedOut) return true - - this._buffer = this._buffer + chunk - // split it up into lines. - var lines = this._buffer.split(/\r?\n/) - // ignore the last line, since it might be incomplete. - this._buffer = lines.pop() - - for (var i = 0, l = lines.length; i < l; i ++) { - //console.error([i, lines[i]]) - // see if it's indented. - var line = lines[i] - , spaces = (this._indent.length && !line.trim()) - || line.match(/^\s/) - // at this level, only interested in fully undented stuff. - if (spaces) { - var c = i - while (c < l && (!lines[c].trim() || lines[c].match(/^\s/))) { - this._indent.push(lines[c++]) - } - //console.error(c-i, "indented", this._indent, this._current) - i = c - 1 - continue - } - // some kind of line. summary, ok, notok, comment, or garbage. - // this also finishes parsing any of the indented lines from before - this._parseLine(line) - } - return true -} - -TapConsumer.prototype.end = function () { - // finish up any hanging indented sections or final buffer - if (this._buffer.match(/^\s/)) this._indent.push(this.buffer) - else this._parseLine(this._buffer) - - if (!this.bailedOut && - this._plan !== null && - this.results.testsTotal !== this._plan) { - while (this._actualCount < this._plan) { - this.emit("data", {ok: false, name:"MISSING TEST", - id:this._actualCount ++ }) - } - } - - this._parseLine("") - this._buffer = "" - this.writable = false - this.emit("end", null, this._actualCount, this._passed) -} - -TapConsumer.prototype._parseLine = function (line) { - if (this.bailedOut) return - //console.error("_parseLine", [line]) - // if there are any indented lines, and there is a - // current object already, then they belong to it. - // if there is not a current object, then they're garbage. - if (this._current && this._indent.length) { - this._parseIndented() - } - this._indent.length = 0 - if (this._current) { - if (this._current.ok) this._passed.push(this._current.id) - else this._failed.push(this._current.id) - this.emit("data", this._current) - } - this._current = null - line = line.trim() - if (!line) return - // try to see what kind of line this is. - - var bo - if (bo = line.match(/^bail out!\s*(.*)$/i)) { - this.bailedOut = true - // this.emit("error", new Error(line)) - this.emit("bailout", bo[1]) - return - } - - if (line.match(/^#/)) { // just a comment - line = line.replace(/^#+/, "").trim() - // console.error("outputting comment", [line]) - if (line) this.emit("data", line) - return - } - - var plan = line.match(/^([0-9]+)\.\.([0-9]+)(?:\s+#(.*))?$/) - if (plan) { - var start = +(plan[1]) - , end = +(plan[2]) - , comment = plan[3] - - // TODO: maybe do something else with this? - // it might be something like: "1..0 #Skip because of reasons" - this._plan = end - this.emit("plan", end, comment) - // plan must come before or after all tests. - if (this._actualCount !== 0) { - this._sawPlan = true - } - return - } - - if (line.match(/^(not )?ok(?:\s+([0-9]+))?/)) { - this._parseResultLine(line) - return - } - - // garbage. emit as a comment. - //console.error("emitting", [line.trim()]) - if (line.trim()) this.emit("data", line.trim()) -} - -TapConsumer.prototype._parseDirective = function (line) { - line = line.trim() - if (line.match(/^TODO\b/i)) { - return { todo:true, explanation: line.replace(/^TODO\s*/i, "") } - } else if (line.match(/^SKIP\b/i)) { - return { skip:true, explanation: line.replace(/^SKIP\s*/i, "") } - } -} - -TapConsumer.prototype._parseResultLine = function (line) { - this._actualCount ++ - if (this._sawPlan) { - this.emit("data", {ok: false, name:"plan in the middle of tests" - ,id:this._actualCount ++}) - } - var parsed = line.match(/^(not )?ok(?: ([0-9]+))?(?:(?: - )?(.*))?$/) - , ok = !parsed[1] - , id = +(parsed[2] || this._actualCount) - , rest = parsed[3] || "" - , name - , res = { id:id, ok:ok } - - // split on un-escaped # characters - - //console.log("# "+JSON.stringify([name, rest])) - rest = rest.replace(/([^\\])((?:\\\\)*)#/g, "$1\n$2").split("\n") - name = rest.shift() - rest = rest.filter(function (r) { return r.trim() }).join("#") - //console.log("# "+JSON.stringify([name, rest])) - - // now, let's see if there's a directive in there. - var dir = this._parseDirective(rest.trim()) - if (!dir) name += rest ? "#" + rest : "" - else { - res.ok = true - if (dir.skip) res.skip = true - else if (dir.todo) res.todo = true - if (dir.explanation) res.explanation = dir.explanation - } - res.name = name - - //console.error(line, [ok, id, name]) - this._current = res -} - -TapConsumer.prototype._parseIndented = function () { - // pull yamlish block out - var ind = this._indent - , ys - , ye - , yind - , diag - //console.error(ind, this._indent) - for (var i = 0, l = ind.length; i < l; i ++) { - var line = ind[i] - if (line === undefined) continue - var lt = line.trim() - - if (!ys) { - ys = line.match(/^(\s*)---(.*)$/) - if (ys) { - yind = ys[1] - diag = [ys[2]] - //console.error([line,ys, diag]) - continue - } else if (lt) this.emit("data", lt) - } else if (ys && !ye) { - if (line === yind + "...") ye = true - else { - diag.push(line.substr(yind.length)) - } - } else if (ys && ye && lt) this.emit("data", lt) - } - if (diag) { - //console.error('about to parse', diag) - diag = yamlish.decode(diag.join("\n")) - //console.error('parsed', diag) - Object.keys(diag).forEach(function (k) { - //console.error(this._current, k) - if (!this._current.hasOwnProperty(k)) this._current[k] = diag[k] - }, this) - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-cov-html.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-cov-html.js deleted file mode 100644 index 3c1c192..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-cov-html.js +++ /dev/null @@ -1,78 +0,0 @@ -var fs = require('fs'), - path = require('path'), - asyncMap = require("slide").asyncMap, - util = require('util'); - -var CovHtml = module.exports = function(cov_stats, cov_dir, cb) { - var index = []; - - asyncMap( - Object.keys(cov_stats), - function(f, cb) { - var st = cov_stats[f], - missing_lines = st.missing.map(function(l) { - return l.number; - }), - out = '\n\n\n ' + - '\n ' + - - f + ' (' + st.loc + ')\n' + - '\n' + - '\n\n' + - '

' + f + ' (' + st.loc + ')' + '

' + - '

Run: ' + (st.missing.length ? st.loc - st.missing.length : st.loc) + ', Missing: ' + - st.missing.length + ', Percentage: ' + st.percentage + '

' + - '

Source:

\n' + - '
    \n' + - st.lines.map(function(line) { - var number = line.number, - color = (missing_lines.indexOf(number) !== -1) ? '#fcc' : '#cfc'; - return '
  1. ' + line.source.replace(/'; - }).join('\n') + - '
\n' + - '

Data

\n'+ - '
' + util.inspect(st, true, Infinity, false).replace(/\n';
-
-      fs.writeFile(
-        cov_dir + '/' + 
-        f.replace(process.cwd() + '/', '').replace(/\//g, '+') + '.html',
-        out,
-        'utf8',
-        function(err) {
-          if (err) {
-            throw err;
-          }
-          index.push(f);
-          cb();
-        });
-    },
-    function(err) {
-      if (err) {
-        throw err;
-      }
-      var out = '\n\n\n  ' +
-          '\n  Coverage Index\n\n' +
-          '\n

Code Coverage Information

\n
    ' + - index.map(function(fname) { - return '
  • ' + fname + '
  • '; - }).join('\n') + '
\n\n'; - - fs.writeFile(cov_dir + '/index.html', out, 'utf8', function(err) { - if (err) { - throw err; - } - cb(); - }); - } - ); -}; - - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-global-harness.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-global-harness.js deleted file mode 100644 index 3b04131..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-global-harness.js +++ /dev/null @@ -1,80 +0,0 @@ -// this is just a harness that pipes to stdout. -// It's the default one. -module.exports = GlobalHarness - -var globalHarness = global.TAP_Global_Harness - , inherits = require("inherits") - , Results = require("./tap-results") - , Harness = require("./tap-harness") - , Test = require("./tap-test") - -inherits(GlobalHarness, Harness) -function GlobalHarness () { - //console.error("calling GlobalHarness") - if (globalHarness) return globalHarness - if (!(this instanceof GlobalHarness)) { - return globalHarness = new GlobalHarness - } - - globalHarness = global.TAP_Global_Harness = this - Harness.call(this, Test) - - this.output.pipe(process.stdout) - //this.output.on("data", function () { - // process.nextTick(process.stdout.flush.bind(process.stdout)) - //}) - - this.test = this.test.bind(this) - - this.plan = this.plan.bind(this) - - var output = this.output - this.on("childEnd", function (child) { - //console.error("childEnd in global harness") - //console.error(child.results) - // write out the stuff for this child. - //console.error("child.conf", child.conf) - - // maybe write some other stuff about the number of tests in this - // thing, etc. I dunno. - //console.error("child results", child.results) - this.results.list.forEach(function (res) { - //delete res.error - //console.error("child resuilt", res) - output.write(res) - }) - //console.error("wrote child results") - this.results.list.length = 0 - }) - - var streamEnded = false - this.on("end", function () { - //console.error("global ending the stream") - if (!streamEnded) { - this.results.list.forEach(function (res) { - output.write(res) - }) - this.results.list.length = 0 - output.end() - streamEnded = true - - // If we had fails, then make sure that the exit code - // reflects that failure. - var exitCode - if (!this.results.ok) - exitCode = process.exitCode = 1 - if (exitCode !== 0) { - process.on('exit', function (code) { - if (code === 0) - process.exit(exitCode) - }) - } - } - }) - - //this.on("end", this.output.end.bind(this.output)) - - process.on("unhandledException", function (e) { - this.bailout("unhandled exception: " + e.message) - }) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-harness.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-harness.js deleted file mode 100644 index 1de0ca6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-harness.js +++ /dev/null @@ -1,226 +0,0 @@ -// a thing that runs tests. -// Every "test" is also a harness. If they do not have a harness, -// then they are attached to the defaut "global harness", -// which writes its results to stdout. - - -// TODO: -// - Bailout should stop running any tests. -// - "skip" in the test config obj should skip it. - -module.exports = Harness -var EE = require("events").EventEmitter -require("inherits")(Harness, EE) - -var Results = require("./tap-results") - , TapProducer = require("./tap-producer") - , assert = require("./tap-assert") - -function Harness (Test) { - if (!(this instanceof Harness)) return new Harness(Test) - - //console.error("Test in "+this.constructor.name, Test) - - this._Test = Test - this._plan = null - this._children = [] - this._processing = false - - this._testCount = 0 - this._planSum = 0 - - this.results = new Results() - // emit result events on the harness. - //this.results.on("result", function (res) { - // console.error("proxying result ev from res to harness") - // this.emit("result", res) - //}.bind(this)) - var me = this - this.results.on("result", this.emit.bind(this, "result")) - - var p = this.process.bind(this) - this.process = function () { - this._processing = true - process.nextTick(p) - } - - this.output = new TapProducer() - EE.call(this) -} - -// this function actually only gets called bound to -// the Harness object, and on process.nextTick. Even if -// passed as an event handler, everything *else* will -// happen before it gets called. -Harness.prototype.process = function () { - //console.error("harness process") - // "end" can emit multiple times, so only actually move on - // to the next test if the current one is actually over. - // TODO: multiple in-process tests, if all are marked "async" - if (this._current) { - if (!this._current._ended) return - // handle the current one before moving onto the next. - this.childEnd(this._current) - } - var skip = true - while (skip) { - //console.error("checking for skips") - var current = this._current = this._children.shift() - if (current) { - skip = current.conf.skip - if (skip) { - //console.error("add a failure for the skipping") - this.results.add(assert.fail(current.conf.name - ,{skip:true, diag:false})) - } - } else skip = false - } - - // keep processing through skipped tests, instead of running them. - if (current && this._bailedOut) { - return this.process() - } - - //console.error("got current?", !!current) - if (current) { - current.on("end", this.process) - current.emit("ready") - //console.error("emitted ready") - //console.error("_plan", this._plan, this.constructor.name) - } else if (!this._plan || (this._plan && this._plan === this._testCount)) { - //console.error("Harness process: no more left. ending") - if (this._endNice) { - this._endNice() - } else { - this.end() - } - } else { - this._processing = false; - } -} - -Harness.prototype.end = function () { - if (this._children.length) { - return this.process() - } - //console.error("harness end", this.constructor.name) - if (this._bailedOut) return - - // can't call .end() more than once. - if (this._ended) { - //console.error("adding failure for end calling") - this.results.add(assert.fail("end called more than once")) - } - - // see if the plan is completed properly, if there was one. - if (this._plan !== null) { - var total = this._testCount - if (total !== this._plan) { - this.results.add(assert.equal(total, this._plan, "test count != plan")) - } - this._plan = total - } - - //console.error("setting ended true", this.constructor.name) - this._ended = true - this.emit("end") -} - -Harness.prototype.plan = function (p) { - //console.error("setting plan", new Error().stack) - if (this._plan !== null) { - //console.error("about to add failure for calling plan") - return this.results.add(assert.fail("plan set multiple times")) - } - this._plan = p - if (p === 0 || this.results.testsTotal) { - this.end() - } -} - -Harness.prototype.childEnd = function (child) { - //console.error("childEnd") - this._testCount ++ - this._planSum += child._plan - //console.error("adding set of child.results") - - this.results.add(child.conf.name || "(unnamed test)") - this.results.addSet(child.results) - this.emit("childEnd", child) - // was this planned? - if (this._plan === this._testCount) { - //console.error("plan", [this._plan, this._testCount]) - return this.end() - } -} - -function copyObj(o) { - var copied = {} - Object.keys(o).forEach(function (k) { copied[k] = o[k] }) - return copied -} - -Harness.prototype.test = function test (name, conf, cb) { - if (this._bailedOut) return - - if (typeof conf === "function") cb = conf, conf = null - if (typeof name === "object") conf = name, name = null - if (typeof name === "function") cb = name, name = null - - conf = (conf ? copyObj(conf) : {}) - name = name || "" - - //console.error("making test", [name, conf, cb]) - - // timeout: value in milliseconds. Defaults to 30s - // Set to Infinity to have no timeout. - if (isNaN(conf.timeout)) conf.timeout = 30000 - var t = new this._Test(this, name, conf) - var self = this - if (cb) { - //console.error("attaching cb to ready event") - t.on("ready", function () { - if (!isNaN(conf.timeout) && isFinite(conf.timeout)) { - var timer = setTimeout(this.timeout.bind(this), conf.timeout) - var clear = function () { - clearTimeout(timer) - } - t.on("end", clear) - t.on("bailout", function (message) { - self.bailout(message) - clear() - }) - } - }) - t.on("ready", cb.bind(t, t)) - // proxy the child results to this object. - //t.on("result", function (res) { - // console.error("in harness, proxying result up") - // t.results.add(res) - //}) - } - return t -} - -Harness.prototype.bailout = function (message) { - // console.error("Harness bailout", this.constructor.name) - message = message || "" - //console.error("adding bailout message result") - this.results.add({bailout: message}) - // console.error(">>> results after bailout" , this.results) - this._bailedOut = true - this.emit("bailout", message) - this.output.end({bailout: message}) -} - -Harness.prototype.add = function (child) { - //console.error("adding child") - this._children.push(child) - if (!this._processing) this.process() -} - -// the tearDown function is *always* guaranteed to happen. -// Even if there's a bailout. -Harness.prototype.tearDown = function (fn) { - this.on("end", fn) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-producer.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-producer.js deleted file mode 100644 index b70d0ce..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-producer.js +++ /dev/null @@ -1,131 +0,0 @@ -module.exports = TapProducer - -var Results = require("./tap-results") - , inherits = require("inherits") - , yamlish = require("yamlish") - -TapProducer.encode = function (result, diag) { - var tp = new TapProducer(diag) - , out = "" - tp.on("data", function (c) { out += c }) - if (Array.isArray(result)) { - result.forEach(tp.write, tp) - } else tp.write(result) - tp.end() - return out -} - -var Stream = require("stream").Stream -inherits(TapProducer, Stream) -function TapProducer (diag) { - Stream.call(this) - this.diag = diag - this.count = 0 - this.readable = this.writable = true - this.results = new Results -} - -TapProducer.prototype.trailer = true - -TapProducer.prototype.write = function (res) { - // console.error("TapProducer.write", res) - if (typeof res === "function") throw new Error("wtf?") - if (!this.writable) this.emit("error", new Error("not writable")) - - if (!this._didHead) { - this.emit("data", "TAP version 13\n") - this._didHead = true - } - - var diag = res.diag - if (diag === undefined) diag = this.diag - - this.emit("data", encodeResult(res, this.count + 1, diag)) - - if (typeof res === "string") return true - - if (res.bailout) { - var bo = "bail out!" - if (typeof res.bailout === "string") bo += " " + res.bailout - this.emit("data", bo) - return - } - this.results.add(res, false) - - this.count ++ -} - -TapProducer.prototype.end = function (res) { - if (res) this.write(res) - // console.error("TapProducer end", res, this.results) - this.emit("data", "\n1.."+this.results.testsTotal+"\n") - if (this.trailer && typeof this.trailer !== "string") { - // summary trailer. - var trailer = "tests "+this.results.testsTotal + "\n" - if (this.results.pass) { - trailer += "pass " + this.results.pass + "\n" - } - if (this.results.fail) { - trailer += "fail " + this.results.fail + "\n" - } - if (this.results.skip) { - trailer += "skip "+this.results.skip + "\n" - } - if (this.results.todo) { - trailer += "todo "+this.results.todo + "\n" - } - if (this.results.bailedOut) { - trailer += "bailed out" + "\n" - } - - if (this.results.testsTotal === this.results.pass) { - trailer += "\nok\n" - } - this.trailer = trailer - } - if (this.trailer) this.write(this.trailer) - this.writable = false - this.emit("end", null, this.count, this.ok) -} - -function encodeResult (res, count, diag) { - // console.error(res, count, diag) - if (typeof res === "string") { - res = res.split(/\r?\n/).map(function (l) { - if (!l.trim()) return l.trim() - return "# " + l - }).join("\n") - if (res.substr(-1) !== "\n") res += "\n" - return res - } - - if (res.bailout) return "" - - - if (!!process.env.TAP_NODIAG) diag = false - else if (!!process.env.TAP_DIAG) diag = true - else if (diag === undefined) diag = !res.ok - - var output = "" - res.name = res.name && ("" + res.name).trim() - output += ( !res.ok ? "not " : "") + "ok " + count - + ( !res.name ? "" - : " " + res.name.replace(/[\r\n]/g, " ") ) - + ( res.skip ? " # SKIP " + ( res.explanation || "" ) - : res.todo ? " # TODO " + ( res.explanation || "" ) - : "" ) - + "\n" - - if (!diag) return output - var d = {} - , dc = 0 - Object.keys(res).filter(function (k) { - return k !== "ok" && k !== "name" && k !== "id" - }).forEach(function (k) { - dc ++ - d[k] = res[k] - }) - //console.error(d, "about to encode") - if (dc > 0) output += " ---"+yamlish.encode(d)+"\n ...\n" - return output -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-results.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-results.js deleted file mode 100644 index 3243cd7..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-results.js +++ /dev/null @@ -1,72 +0,0 @@ -// A class for counting up results in a test harness. - -module.exports = Results - -var inherits = require("inherits") - , EventEmitter = require("events").EventEmitter - -inherits(Results, EventEmitter) - -function Results (r) { - //console.error("result constructor", r) - this.ok = true - this.addSet(r) -} - -Results.prototype.addSet = function (r) { - //console.error("add set of results", r) - r = r || {ok: true} - ; [ "todo" - , "todoPass" - , "todoFail" - , "skip" - , "skipPass" - , "skipFail" - , "pass" - , "passTotal" - , "fail" - , "failTotal" - , "tests" - , "testsTotal" ].forEach(function (k) { - this[k] = (this[k] || 0) + (r[k] || 0) - //console.error([k, this[k]]) - }, this) - - this.ok = this.ok && r.ok && true - this.bailedOut = this.bailedOut || r.bailedOut || false - this.list = (this.list || []).concat(r.list || []) - this.emit("set", this.list) - //console.error("after addSet", this) -} - -Results.prototype.add = function (r, addToList) { - if (typeof r === 'object') { - var pf = r.ok ? "pass" : "fail" - , PF = r.ok ? "Pass" : "Fail" - - this.testsTotal ++ - this[pf + "Total"] ++ - - if (r.skip) { - this["skip" + PF] ++ - this.skip ++ - } else if (r.todo) { - this["todo" + PF] ++ - this.todo ++ - } else { - this.tests ++ - this[pf] ++ - } - - if (r.bailout || typeof r.bailout === "string") { - // console.error("Bailing out in result") - this.bailedOut = true - } - this.ok = !!(this.ok && (r.ok || r.skip || r.todo)) - } - - if (addToList === false) return - this.list = this.list || [] - this.list.push(r) - this.emit("result", r) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-runner.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-runner.js deleted file mode 100644 index d3689f0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-runner.js +++ /dev/null @@ -1,502 +0,0 @@ -var fs = require("fs") - , child_process = require("child_process") - , path = require("path") - , chain = require("slide").chain - , asyncMap = require("slide").asyncMap - , TapProducer = require("./tap-producer.js") - , TapConsumer = require("./tap-consumer.js") - , assert = require("./tap-assert.js") - , inherits = require("inherits") - , util = require("util") - , CovHtml = require("./tap-cov-html.js") - , glob = require("glob") - - // XXX Clean up the coverage options - , doCoverage = process.env.TAP_COV - || process.env.npm_package_config_coverage - || process.env.npm_config_coverage - -module.exports = Runner - -inherits(Runner, TapProducer) - -function Runner (options, cb) { - this.options = options - - var diag = this.options.diag - var dir = this.options.argv.remain - TapProducer.call(this, diag) - - this.doCoverage = doCoverage - // An array of full paths to files to obtain coverage - this.coverageFiles = [] - // The source of these files - this.coverageFilesSource = {} - // Where to write coverage information - this.coverageOutDir = this.options["coverage-dir"] - // Temporary test files bunkerified we'll remove later - this.f2delete = [] - // Raw coverage stats, as read from JSON files - this.rawCovStats = [] - // Processed coverage information, per file to cover: - this.covStats = {} - - if (dir) { - var filesToCover = this.options.cover - - if (doCoverage) { - var mkdirp = require("mkdirp") - this.coverageOutDir = path.resolve(this.coverageOutDir) - this.getFilesToCover(filesToCover) - var self = this - return mkdirp(this.coverageOutDir, '0755', function (er) { - if (er) return self.emit("error", er) - self.run(dir, cb) - }) - } - - this.run(dir, cb) - } -} - - -Runner.prototype.run = function() { - var self = this - , args = Array.prototype.slice.call(arguments) - , cb = args.pop() || finish - - function finish (er) { - if (er) { - self.emit("error", er) - } - - if (!doCoverage) return self.end() - - // Cleanup temporary test files with coverage: - self.f2delete.forEach(function(f) { - fs.unlinkSync(f) - }) - self.getFilesToCoverSource(function(err, data) { - if (err) { - self.emit("error", err) - } - self.getPerFileCovInfo(function(err, data) { - if (err) { - self.emit("error", err) - } - self.mergeCovStats(function(err, data) { - if (err) { - self.emit("error", err) - } - CovHtml(self.covStats, self.coverageOutDir, function() { - self.end() - }) - }) - }) - }) - } - - if (Array.isArray(args[0])) { - args = args[0] - } - self.runFiles(args, "", cb) -} - -Runner.prototype.runDir = function (dir, cb) { - var self = this - fs.readdir(dir, function (er, files) { - if (er) { - self.write(assert.fail("failed to readdir " + dir, { error: er })) - self.end() - return - } - files = files.sort(function(a, b) { - return a > b ? 1 : -1 - }) - files = files.filter(function(f) { - return !f.match(/^\./) - }) - files = files.map(function(file) { - return path.resolve(dir, file) - }) - - self.runFiles(files, path.resolve(dir), cb) - }) -} - - -// glob the filenames so that test/*.js works on windows -Runner.prototype.runFiles = function (files, dir, cb) { - var self = this - var globRes = [] - chain(files.map(function (f) { - return function (cb) { - glob(f, function (er, files) { - if (er) - return cb(er) - globRes.push.apply(globRes, files) - cb() - }) - } - }), function (er) { - if (er) - return cb(er) - runFiles(self, globRes, dir, cb) - }) -} - -// set some default options for node debugging tests -function setOptionsForDebug(self) { - // Note: we automatically increase the default timeout here. Yes - // the user can specify --timeout to increase, but by default, - // 30 seconds is not a long time to debug your test. - self.options.timeout = 1000000; - - // Note: we automatically turn on stderr so user can see the 'debugger listening on port' message. - // Without this it looks like tap has hung.. - self.options.stderr = true; -} - -function runFiles(self, files, dir, cb) { - chain(files.map(function(f) { - return function (cb) { - if (self._bailedOut) return - var relDir = dir || path.dirname(f) - , fileName = relDir === "." ? f : f.substr(relDir.length + 1) - - self.write(fileName) - fs.lstat(f, function(er, st) { - if (er) { - self.write(assert.fail("failed to stat " + f, {error: er})) - return cb() - } - - var cmd = f, args = [], env = {} - - if (path.extname(f) === ".js") { - cmd = process.execPath - if (self.options.gc) { - args.push("--expose-gc") - } - if (self.options.debug) { - args.push("--debug") - setOptionsForDebug(self) - } - if (self.options["debug-brk"]) { - args.push("--debug-brk") - setOptionsForDebug(self) - } - if (self.options.strict) { - args.push("--use-strict") - } - if (self.options.harmony) { - args.push("--harmony") - } - args.push(fileName) - } else if (path.extname(f) === ".coffee") { - cmd = "coffee" - args.push(fileName) - } else { - // Check if file is executable - if ((st.mode & parseInt('0100', 8)) && process.getuid) { - if (process.getuid() != st.uid) { - return cb() - } - } else if ((st.mode & parseInt('0010', 8)) && process.getgid) { - if (process.getgid() != st.gid) { - return cb() - } - } else if ((st.mode & parseInt('0001', 8)) == 0) { - return cb() - } - cmd = path.resolve(cmd) - } - - if (st.isDirectory()) { - return self.runDir(f, cb) - } - - if (doCoverage && path.extname(f) === ".js") { - var foriginal = fs.readFileSync(f, "utf8") - , fcontents = self.coverHeader() + foriginal + self.coverFooter() - , tmpBaseName = path.basename(f, path.extname(f)) - + ".with-coverage." + process.pid + path.extname(f) - , tmpFname = path.resolve(path.dirname(f), tmpBaseName) - - fs.writeFileSync(tmpFname, fcontents, "utf8") - args.splice(-1, 1, tmpFname) - } - - for (var i in process.env) { - env[i] = process.env[i] - } - env.TAP = 1 - - var cp = child_process.spawn(cmd, args, { env: env, cwd: relDir }) - , out = "" - , err = "" - , tc = new TapConsumer() - , childTests = [f] - - var timeout = setTimeout(function () { - if (!cp._ended) { - cp._timedOut = true - cp.kill() - } - }, self.options.timeout * 1000) - - tc.on("data", function(c) { - self.emit("result", c) - self.write(c) - }) - - tc.on("bailout", function (message) { - clearTimeout(timeout) - console.log("# " + f.substr(process.cwd().length + 1)) - process.stderr.write(err) - process.stdout.write(out + "\n") - self._bailedOut = true - cp._ended = true - cp.kill() - }) - - cp.stdout.pipe(tc) - cp.stdout.on("data", function (c) { out += c }) - cp.stderr.on("data", function (c) { - if (self.options.stderr) process.stderr.write(c) - err += c - }) - - cp.on("close", function (code, signal) { - if (cp._ended) return - cp._ended = true - var ok = !cp._timedOut && code === 0 - clearTimeout(timeout) - //childTests.forEach(function (c) { self.write(c) }) - var res = { name: path.dirname(f).replace(process.cwd() + "/", "") - + "/" + fileName - , ok: ok - , exit: code } - - if (cp._timedOut) - res.timedOut = cp._timedOut - if (signal) - res.signal = signal - - if (err) { - res.stderr = err - if (tc.results.ok && - tc.results.tests === 0 && - !self.options.stderr) { - // perhaps a compilation error or something else failed. - // no need if stderr is set, since it will have been - // output already anyway. - console.error(err) - } - } - - // tc.results.ok = tc.results.ok && ok - tc.results.add(res) - res.command = '"'+[cmd].concat(args).join(" ")+'"' - self.emit("result", res) - self.emit("file", f, res, tc.results) - self.write(res) - self.write("\n") - if (doCoverage) { - self.f2delete.push(tmpFname) - } - cb() - }) - }) - } - }), cb) - - return self -} - - -// Get an array of full paths to files we are interested into obtain -// code coverage. -Runner.prototype.getFilesToCover = function(filesToCover) { - var self = this - filesToCover = filesToCover.split(",").map(function(f) { - return path.resolve(f) - }).filter(function(f) { - var existsSync = fs.existsSync || path.existsSync; - return existsSync(f) - }) - - function recursive(f) { - if (path.extname(f) === "") { - // Is a directory: - fs.readdirSync(f).forEach(function(p) { - recursive(f + "/" + p) - }) - } else { - self.coverageFiles.push(f) - } - } - filesToCover.forEach(function(f) { - recursive(f) - }) -} - -// Prepend to every test file to run. Note tap.test at the very top due it -// "plays" with include paths. -Runner.prototype.coverHeader = function() { - // semi here since we're injecting it before the first line, - // and don't want to mess up line numbers in the test files. - return "var ___TAP_COVERAGE = require(" - + JSON.stringify(require.resolve("runforcover")) - + ").cover(/.*/g);" -} - -// Append at the end of every test file to run. Actually, the stuff which gets -// the coverage information. -// Maybe it would be better to move into a separate file template so editing -// could be easier. -Runner.prototype.coverFooter = function() { - var self = this - // This needs to be a string with proper interpolations: - return [ "" - , "var ___TAP = require(" + JSON.stringify(require.resolve("./main.js")) + ")" - , "if (typeof ___TAP._plan === 'number') ___TAP._plan ++" - , "___TAP.test(" + JSON.stringify("___coverage") + ", function(t) {" - , " var covFiles = " + JSON.stringify(self.coverageFiles) - , " , covDir = " + JSON.stringify(self.coverageOutDir) - , " , path = require('path')" - , " , fs = require('fs')" - , " , testFnBase = path.basename(__filename, '.js') + '.json'" - , " , testFn = path.resolve(covDir, testFnBase)" - , "" - , " function asyncForEach(arr, fn, callback) {" - , " if (!arr.length) {" - , " return callback()" - , " }" - , " var completed = 0" - , " arr.forEach(function(i) {" - , " fn(i, function (err) {" - , " if (err) {" - , " callback(err)" - , " callback = function () {}" - , " } else {" - , " completed += 1" - , " if (completed === arr.length) {" - , " callback()" - , " }" - , " }" - , " })" - , " })" - , " }" - , "" - , " ___TAP_COVERAGE(function(coverageData) {" - , " var outObj = {}" - , " asyncForEach(covFiles, function(f, cb) {" - , " if (coverageData[f]) {" - , " var stats = coverageData[f].stats()" - , " , stObj = stats" - , " stObj.lines = stats.lines.map(function (l) {" - , " return { number: l.lineno, source: l.source() }" - , " })" - , " outObj[f] = stObj" - , " }" - , " cb()" - , " }, function(err) {" - , " ___TAP_COVERAGE.release()" - , " fs.writeFileSync(testFn, JSON.stringify(outObj))" - , " t.end()" - , " })" - , " })" - , "})" ].join("\n") -} - - -Runner.prototype.getFilesToCoverSource = function(cb) { - var self = this - asyncMap(self.coverageFiles, function(f, cb) { - fs.readFile(f, "utf8", function(err, data) { - var lc = 0 - if (err) { - cb(err) - } - self.coverageFilesSource[f] = data.split("\n").map(function(l) { - lc += 1 - return { number: lc, source: l } - }) - cb() - }) - }, cb) -} - -Runner.prototype.getPerFileCovInfo = function(cb) { - var self = this - , covPath = path.resolve(self.coverageOutDir) - - fs.readdir(covPath, function(err, files) { - if (err) { - self.emit("error", err) - } - var covFiles = files.filter(function(f) { - return path.extname(f) === ".json" - }) - asyncMap(covFiles, function(f, cb) { - fs.readFile(path.resolve(covPath, f), "utf8", function(err, data) { - if (err) { - cb(err) - } - self.rawCovStats.push(JSON.parse(data)) - cb() - }) - }, function(f, cb) { - fs.unlink(path.resolve(covPath, f), cb) - }, cb) - }) -} - -Runner.prototype.mergeCovStats = function(cb) { - var self = this - self.rawCovStats.forEach(function(st) { - Object.keys(st).forEach(function(i) { - // If this is the first time we reach this file, just add the info: - if (!self.covStats[i]) { - self.covStats[i] = { - missing: st[i].lines - } - } else { - // If we already added info for this file before, we need to remove - // from self.covStats any line not duplicated again (since it has - // run on such case) - self.covStats[i].missing = self.covStats[i].missing.filter( - function(l) { - return (st[i].lines.indexOf(l)) - }) - } - }) - }) - - // This is due to a bug into - // chrisdickinson/node-bunker/blob/feature/add-coverage-interface - // which is using array indexes for line numbers instead of the right number - Object.keys(self.covStats).forEach(function(f) { - self.covStats[f].missing = self.covStats[f].missing.map(function(line) { - return { number: line.number, source: line.source } - }) - }) - - Object.keys(self.coverageFilesSource).forEach(function(f) { - if (!self.covStats[f]) { - self.covStats[f] = { missing: self.coverageFilesSource[f] - , percentage: 0 - } - } - self.covStats[f].lines = self.coverageFilesSource[f] - self.covStats[f].loc = self.coverageFilesSource[f].length - - if (!self.covStats[f].percentage) { - self.covStats[f].percentage = - 1 - (self.covStats[f].missing.length / self.covStats[f].loc) - } - - }) - cb() -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-test.js deleted file mode 100644 index ec73321..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/lib/tap-test.js +++ /dev/null @@ -1,110 +0,0 @@ -// This is a very simple test framework that leverages the tap framework -// to run tests and output tap-parseable results. - -module.exports = Test - -var assert = require("./tap-assert") - , inherits = require("inherits") - , Results = require("./tap-results") - , Harness = require("./tap-harness") - -// tests are also test harnesses -inherits(Test, Harness) - -function Test (harness, name, conf) { - //console.error("test ctor") - if (!(this instanceof Test)) return new Test(harness, name, conf) - - Harness.call(this, Test) - - conf.name = name || conf.name || "(anonymous)" - this.conf = conf - - this.harness = harness - this.harness.add(this) -} - -// it's taking too long! -Test.prototype.timeout = function () { - // detect false alarms - if (this._ended) return - this.fail("Timeout!") - this.end() -} - -Test.prototype.clear = function () { - this._started = false - this._ended = false - this._plan = null - this._bailedOut = false - this._testCount = 0 - this.results = new Results() -} - -// this gets called if a test throws ever -Test.prototype.threw = function (ex) { - //console.error("threw!", ex.stack) - this.fail(ex.name + ": " + ex.message, { error: ex, thrown: true }) - // may emit further failing tests if the plan is not completed - //console.error("end, because it threw") - if (!this._ended) this.end() -} - -Test.prototype.comment = function (m) { - if (typeof m !== "string") { - return this.fail("Test.comment argument must be a string") - } - this.result("\n" + m.trim()) -} - -Test.prototype.result = function (res) { - this.results.add(res) - this._testCount ++ - this.emit("result", res) - if (this._plan === this._testCount) { - process.nextTick(this._endNice.bind(this)) - } -} - -Test.prototype._endNice = function () { - if (!this._ended) this.end() -} - -// parasitic -// Who says you can't do multiple inheritance in js? -Object.getOwnPropertyNames(assert).forEach(function (k) { - if (k === "prototype" || k === "name") return - var d = Object.getOwnPropertyDescriptor(assert, k) - , v = d.value - if (!v) return - d.value = assertParasite(v) - Object.defineProperty(Test.prototype, k, d) -}) - -function assertParasite (fn) { return function _testAssert () { - //console.error("_testAssert", fn.name, arguments) - if (this._bailedOut) return - var res = fn.apply(assert, arguments) - this.result(res) - return res -}} - -// a few tweaks on the EE emit function, because -// we want to catch all thrown errors and bubble up "bailout" -Test.prototype.emit = (function (em) { return function (t) { - // bailouts bubble until handled - if (t === "bailout" && - this.listeners(t).length === 0 && - this.harness) { - return this.harness.bailout(arguments[1]) - } - - if (t === "error") return em.apply(this, arguments) - try { - em.apply(this, arguments) - } catch (ex) { - // any exceptions in a test are a failure - //console.error("caught!", ex.stack) - this.threw(ex) - } -}})(Harness.prototype.emit) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/mkdirp b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/mkdirp deleted file mode 120000 index 017896c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/mkdirp +++ /dev/null @@ -1 +0,0 @@ -../mkdirp/bin/cmd.js \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/nopt b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/nopt deleted file mode 120000 index 6b6566e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/.bin/nopt +++ /dev/null @@ -1 +0,0 @@ -../nopt/bin/nopt.js \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/.travis.yml deleted file mode 100644 index dad2273..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.8 - - "0.10" diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/README.markdown deleted file mode 100644 index 8c062fd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/README.markdown +++ /dev/null @@ -1,62 +0,0 @@ -buffer-equal -============ - -Return whether two buffers are equal. - -[![build status](https://secure.travis-ci.org/substack/node-buffer-equal.png)](http://travis-ci.org/substack/node-buffer-equal) - -example -======= - -``` js -var bufferEqual = require('buffer-equal'); - -console.dir(bufferEqual( - new Buffer([253,254,255]), - new Buffer([253,254,255]) -)); -console.dir(bufferEqual( - new Buffer('abc'), - new Buffer('abcd') -)); -console.dir(bufferEqual( - new Buffer('abc'), - 'abc' -)); -``` - -output: - -``` -true -false -undefined -``` - -methods -======= - -``` js -var bufferEqual = require('buffer-equal') -``` - -bufferEqual(a, b) ------------------ - -Return whether the two buffers `a` and `b` are equal. - -If `a` or `b` is not a buffer, return `undefined`. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install buffer-equal -``` - -license -======= - -MIT diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/example/eq.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/example/eq.js deleted file mode 100644 index 1eb0509..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/example/eq.js +++ /dev/null @@ -1,14 +0,0 @@ -var bufferEqual = require('../'); - -console.dir(bufferEqual( - new Buffer([253,254,255]), - new Buffer([253,254,255]) -)); -console.dir(bufferEqual( - new Buffer('abc'), - new Buffer('abcd') -)); -console.dir(bufferEqual( - new Buffer('abc'), - 'abc' -)); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/index.js deleted file mode 100644 index e640d4e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/index.js +++ /dev/null @@ -1,14 +0,0 @@ -var Buffer = require('buffer').Buffer; // for use with browserify - -module.exports = function (a, b) { - if (!Buffer.isBuffer(a)) return undefined; - if (!Buffer.isBuffer(b)) return undefined; - if (typeof a.equals === 'function') return a.equals(b); - if (a.length !== b.length) return false; - - for (var i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - - return true; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/package.json deleted file mode 100644 index 18daebc..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "buffer-equal", - "description": "return whether two buffers are equal", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/substack/node-buffer-equal.git" - }, - "main": "index.js", - "keywords": [ - "buffer", - "equal" - ], - "directories": { - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tap test/*.js" - }, - "devDependencies": { - "tap": "0.2.4" - }, - "engines": { - "node": ">=0.4.0" - }, - "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "bugs": { - "url": "https://github.com/substack/node-buffer-equal/issues" - }, - "homepage": "https://github.com/substack/node-buffer-equal", - "_id": "buffer-equal@0.0.1", - "dist": { - "shasum": "91bc74b11ea405bc916bc6aa908faafa5b4aac4b", - "tarball": "http://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz" - }, - "_from": "buffer-equal@~0.0.0", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "91bc74b11ea405bc916bc6aa908faafa5b4aac4b", - "_resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/test/eq.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/test/eq.js deleted file mode 100644 index 3d34006..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/buffer-equal/test/eq.js +++ /dev/null @@ -1,35 +0,0 @@ -var bufferEqual = require('../'); -var test = require('tap').test; - -test('equal', function (t) { - var eq = bufferEqual( - new Buffer([253,254,255]), - new Buffer([253,254,255]) - ); - t.strictEqual(eq, true); - t.end(); -}); - -test('not equal', function (t) { - var eq = bufferEqual( - new Buffer('abc'), - new Buffer('abcd') - ); - t.strictEqual(eq, false); - t.end(); -}); - -test('not equal not buffer', function (t) { - var eq = bufferEqual( - new Buffer('abc'), - 'abc' - ); - t.strictEqual(eq, undefined); - t.end(); -}); - -test('equal not buffer', function (t) { - var eq = bufferEqual('abc', 'abc'); - t.strictEqual(eq, undefined); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/.travis.yml deleted file mode 100644 index f1d0f13..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/LICENSE deleted file mode 100644 index ee27ba4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/example/cmp.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/example/cmp.js deleted file mode 100644 index 67014b8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/example/cmp.js +++ /dev/null @@ -1,11 +0,0 @@ -var equal = require('../'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/index.js deleted file mode 100644 index dbc11f2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/index.js +++ /dev/null @@ -1,94 +0,0 @@ -var pSlice = Array.prototype.slice; -var objectKeys = require('./lib/keys.js'); -var isArguments = require('./lib/is_arguments.js'); - -var deepEqual = module.exports = function (actual, expected, opts) { - if (!opts) opts = {}; - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return opts.strict ? actual === expected : actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected, opts); - } -} - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isBuffer (x) { - if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false; - if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { - return false; - } - if (x.length > 0 && typeof x[0] !== 'number') return false; - return true; -} - -function objEquiv(a, b, opts) { - var i, key; - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b, opts); - } - if (isBuffer(a)) { - if (!isBuffer(b)) { - return false; - } - if (a.length !== b.length) return false; - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; - } - try { - var ka = objectKeys(a), - kb = objectKeys(b); - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key], opts)) return false; - } - return typeof a === typeof b; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/is_arguments.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/is_arguments.js deleted file mode 100644 index 1ff150f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/is_arguments.js +++ /dev/null @@ -1,20 +0,0 @@ -var supportsArgumentsClass = (function(){ - return Object.prototype.toString.call(arguments) -})() == '[object Arguments]'; - -exports = module.exports = supportsArgumentsClass ? supported : unsupported; - -exports.supported = supported; -function supported(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -}; - -exports.unsupported = unsupported; -function unsupported(object){ - return object && - typeof object == 'object' && - typeof object.length == 'number' && - Object.prototype.hasOwnProperty.call(object, 'callee') && - !Object.prototype.propertyIsEnumerable.call(object, 'callee') || - false; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/keys.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/keys.js deleted file mode 100644 index 13af263..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/lib/keys.js +++ /dev/null @@ -1,9 +0,0 @@ -exports = module.exports = typeof Object.keys === 'function' - ? Object.keys : shim; - -exports.shim = shim; -function shim (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/package.json deleted file mode 100644 index 41115ee..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/package.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "name": "deep-equal", - "version": "1.0.0", - "description": "node's assert.deepEqual algorithm", - "main": "index.js", - "directories": { - "lib": ".", - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tape test/*.js" - }, - "devDependencies": { - "tape": "^3.5.0" - }, - "repository": { - "type": "git", - "url": "http://github.com/substack/node-deep-equal.git" - }, - "keywords": [ - "equality", - "equal", - "compare" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": { - "ie": [ - 6, - 7, - 8, - 9 - ], - "ff": [ - 3.5, - 10, - 15 - ], - "chrome": [ - 10, - 22 - ], - "safari": [ - 5.1 - ], - "opera": [ - 12 - ] - } - }, - "gitHead": "39c740ebdafed9443912a4ef1493b18693934daf", - "bugs": { - "url": "https://github.com/substack/node-deep-equal/issues" - }, - "homepage": "https://github.com/substack/node-deep-equal", - "_id": "deep-equal@1.0.0", - "_shasum": "d4564f07d2f0ab3e46110bec16592abd7dc2e326", - "_from": "deep-equal@^1.0.0", - "_npmVersion": "2.3.0", - "_nodeVersion": "0.10.35", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "dist": { - "shasum": "d4564f07d2f0ab3e46110bec16592abd7dc2e326", - "tarball": "http://registry.npmjs.org/deep-equal/-/deep-equal-1.0.0.tgz" - }, - "_resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/readme.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/readme.markdown deleted file mode 100644 index f489c2a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/readme.markdown +++ /dev/null @@ -1,61 +0,0 @@ -# deep-equal - -Node's `assert.deepEqual() algorithm` as a standalone module. - -This module is around [5 times faster](https://gist.github.com/2790507) -than wrapping `assert.deepEqual()` in a `try/catch`. - -[![browser support](https://ci.testling.com/substack/node-deep-equal.png)](https://ci.testling.com/substack/node-deep-equal) - -[![build status](https://secure.travis-ci.org/substack/node-deep-equal.png)](https://travis-ci.org/substack/node-deep-equal) - -# example - -``` js -var equal = require('deep-equal'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); -``` - -# methods - -``` js -var deepEqual = require('deep-equal') -``` - -## deepEqual(a, b, opts) - -Compare objects `a` and `b`, returning whether they are equal according to a -recursive equality algorithm. - -If `opts.strict` is `true`, use strict equality (`===`) to compare leaf nodes. -The default is to use coercive equality (`==`) because that's how -`assert.deepEqual()` works by default. - -# install - -With [npm](http://npmjs.org) do: - -``` -npm install deep-equal -``` - -# test - -With [npm](http://npmjs.org) do: - -``` -npm test -``` - -# license - -MIT. Derived largely from node's assert module. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/test/cmp.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/test/cmp.js deleted file mode 100644 index d141256..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/deep-equal/test/cmp.js +++ /dev/null @@ -1,89 +0,0 @@ -var test = require('tape'); -var equal = require('../'); -var isArguments = require('../lib/is_arguments.js'); -var objectKeys = require('../lib/keys.js'); - -test('equal', function (t) { - t.ok(equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - )); - t.end(); -}); - -test('not equal', function (t) { - t.notOk(equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - )); - t.end(); -}); - -test('nested nulls', function (t) { - t.ok(equal([ null, null, null ], [ null, null, null ])); - t.end(); -}); - -test('strict equal', function (t) { - t.notOk(equal( - [ { a: 3 }, { b: 4 } ], - [ { a: '3' }, { b: '4' } ], - { strict: true } - )); - t.end(); -}); - -test('non-objects', function (t) { - t.ok(equal(3, 3)); - t.ok(equal('beep', 'beep')); - t.ok(equal('3', 3)); - t.notOk(equal('3', 3, { strict: true })); - t.notOk(equal('3', [3])); - t.end(); -}); - -test('arguments class', function (t) { - t.ok(equal( - (function(){return arguments})(1,2,3), - (function(){return arguments})(1,2,3), - "compares arguments" - )); - t.notOk(equal( - (function(){return arguments})(1,2,3), - [1,2,3], - "differenciates array and arguments" - )); - t.end(); -}); - -test('test the arguments shim', function (t) { - t.ok(isArguments.supported((function(){return arguments})())); - t.notOk(isArguments.supported([1,2,3])); - - t.ok(isArguments.unsupported((function(){return arguments})())); - t.notOk(isArguments.unsupported([1,2,3])); - - t.end(); -}); - -test('test the keys shim', function (t) { - t.deepEqual(objectKeys.shim({ a: 1, b : 2 }), [ 'a', 'b' ]); - t.end(); -}); - -test('dates', function (t) { - var d0 = new Date(1387585278000); - var d1 = new Date('Fri Dec 20 2013 16:21:18 GMT-0800 (PST)'); - t.ok(equal(d0, d1)); - t.end(); -}); - -test('buffers', function (t) { - t.ok(equal(Buffer('xyz'), Buffer('xyz'))); - t.end(); -}); - -test('booleans and arrays', function (t) { - t.notOk(equal(true, [])); - t.end(); -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/.travis.yml deleted file mode 100644 index 09d3ef3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.8 - - 0.10 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/README.markdown deleted file mode 100644 index 9ad4303..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/README.markdown +++ /dev/null @@ -1,116 +0,0 @@ -difflet -======= - -Create colorful diffs for javascript objects. - -example -======= - -string.js ---------- - -``` js -var difflet = require('difflet'); - -var s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 }); -process.stdout.write(s); -``` - -output: - -![colorful output](http://substack.net/images/screenshots/difflet_string.png) - -colors.js ---------- - -``` js -var diff = require('difflet')({ indent : 2 }); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : 'beep', - c : { x : 7, z : 3 } -}; - -var next = { - a : [ 1, 2, "z", /beep/, new Buffer(3) ], - fn : function qqq () {}, - b : [5,6,7], - c : { x : 8, y : 5 } -}; - -diff(prev, next).pipe(process.stdout); -``` - -output: - -![colorful output](http://substack.net/images/screenshots/difflet_colors.png) - -green for inserts, blue for updates, red for deletes - -methods -======= - -var difflet = require('difflet') - -var diff = difflet(opts={}) ---------------------------- - -Create a difflet from optional options `opts`. - -With `opts.start(type, stream)` and `opts.stop(type, stream)`, -you can write custom handlers for all the types of differences: -`'inserted'`, `'updated'`, and `'deleted'`. -By default green is used for insertions, blue for updates, and red for -deletions. - -If `opts.indent` is set, output will span multiple lines and `opts.indent` -spaces will be used for leading whitespace. - -If `opts.comma === 'first'` then commas will be placed at the start of lines. - -Setting `opts.comment` to `true` will turn on comments with the previous -contents like this: - -![object comments](http://substack.net/images/screenshots/difflet_object_comments.png) - -diff(prev, next) ----------------- - -Return a stream with the colorful changes between objects `prev` and `next`. - -diff.compare(prev, next) ------------------------- - -Return a string with the colorful changes between `prev` and `next`. - -difflet.compare(prev, next) ---------------------------- - -Return a string with the colorful changes between `prev` and `next` with the -default options. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install difflet -``` - -test -==== - -With [npm](http://npmjs.org) do: - -``` -npm test -``` - -license -======= - -MIT/X11 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_array.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_array.js deleted file mode 100644 index bc5733f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_array.js +++ /dev/null @@ -1,6 +0,0 @@ -var difflet = require('../'); -var s = difflet({ indent : 2, comment : true }).compare( - [ 1, [2,3,{a:4}], 3 ], - [ 1, [[5],6,7], 4 ] -); -process.stdout.write(s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_object.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_object.js deleted file mode 100644 index 5e00e2c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/cmp_object.js +++ /dev/null @@ -1,6 +0,0 @@ -var difflet = require('../'); -var s = difflet({ indent : 2, comment : true }).compare( - { z : [6,7], a : 'abcdefgh', b : [ 31, 'xxt' ] }, - { x : 5, a : 'abdcefg', b : [ 51, 'xxs' ] } -); -console.log(s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/colors.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/colors.js deleted file mode 100644 index 332bbae..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/colors.js +++ /dev/null @@ -1,18 +0,0 @@ -var diff = require('../')({ indent : 2 }); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : 'beep', - c : { x : 7, z : 3 } -}; - -var next = { - a : [ 1, 2, "z", /beep/, new Buffer(3) ], - fn : function qqq () {}, - b : [5,6,7], - c : { x : 8, y : 5 } -}; - -diff(prev, next).pipe(process.stdout); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/comma_first.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/comma_first.js deleted file mode 100644 index 67ece23..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/comma_first.js +++ /dev/null @@ -1,12 +0,0 @@ -var diff = require('../')({ - indent : 2, - comma : 'first', -}); - -var prev = { yy : 6, zz : 5, a : [1,2,3] }; -var next = { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer(3) ], - fn : 8, - b : [5,6,7] -}; -diff(prev, next).pipe(process.stdout); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/diff.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/diff.js deleted file mode 100644 index 08f6e7a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/diff.js +++ /dev/null @@ -1,15 +0,0 @@ -var difflet = require('../'); -var a = { - x : 4, - z : 8, - xs : [ 5, 2, 1, { 0 : 'c' } ], -}; - -var b = { - x : 4, - y : 5, - xs : [ 5, 2, 2, { c : 5 } ], -}; - -var s = difflet({ comment : true, indent : 2 }).compare(a, b); -console.log(s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/html.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/html.js deleted file mode 100644 index 9ff4a29..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/html.js +++ /dev/null @@ -1,34 +0,0 @@ -var difflet = require('../'); -var ent = require('ent'); - -var tags = { - inserted : '', - updated : '', - deleted : '', -}; -var diff = difflet({ - start : function (t, s) { - s.write(tags[t]); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf) { - stream.write(ent.encode(buf)) - }, -}); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : function qq () {} -}; -var next = { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : 'I <3 robots', - b : [5,6,7] -}; - -var stream = diff(prev, next); -stream.pipe(process.stdout, { end : false }); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/string.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/string.js deleted file mode 100644 index 6cff6cb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/example/string.js +++ /dev/null @@ -1,4 +0,0 @@ -var difflet = require('../'); - -var s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 }); -process.stdout.write(s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/index.js deleted file mode 100644 index 278e6b9..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/index.js +++ /dev/null @@ -1,377 +0,0 @@ -var traverse = require('traverse'); -var Stream = require('stream').Stream; -var charm = require('charm'); -var deepEqual = require('deep-is'); - -var exports = module.exports = function (opts_) { - var fn = difflet.bind(null, opts_); - fn.compare = function (prev, next) { - var opts = Object.keys(opts_ || {}).reduce(function (acc, key) { - acc[key] = opts_[key]; - return acc; - }, {}); - var s = opts.stream = new Stream; - var data = ''; - s.write = function (buf) { data += buf }; - s.end = function () {}; - s.readable = true; - s.writable = true; - - difflet(opts, prev, next); - return data; - }; - return fn; -}; - -exports.compare = function (prev, next) { - return exports({}).compare(prev, next); -}; - -function difflet (opts, prev, next) { - var stream = opts.stream || new Stream; - if (!opts.stream) { - stream.readable = true; - stream.writable = true; - stream.write = function (buf) { this.emit('data', buf) }; - stream.end = function () { this.emit('end') }; - } - - if (!opts) opts = {}; - if (opts.start === undefined && opts.stop === undefined) { - var c = charm(stream); - opts.start = function (type) { - c.foreground({ - inserted : 'green', - updated : 'blue', - deleted : 'red', - comment : 'cyan', - }[type]); - c.display('bright'); - }; - opts.stop = function (type) { - c.display('reset'); - }; - } - var write = function (buf) { - if (opts.write) opts.write(buf, stream) - else stream.write(buf) - }; - - var commaFirst = opts.comma === 'first'; - - var stringify = function (node, params) { - return stringifier.call(this, true, node, params || opts); - }; - var plainStringify = function (node, params) { - return stringifier.call(this, false, node, params || opts); - }; - - var levels = 0; - function set (type) { - if (levels === 0) opts.start(type, stream); - levels ++; - } - - function unset (type) { - if (--levels === 0) opts.stop(type, stream); - } - - function stringifier (insertable, node, opts) { - var indent = opts.indent; - - if (insertable) { - var prevNode = traverse.get(prev, this.path || []); - } - var inserted = insertable && prevNode === undefined; - - var indentx; - try { - indentx = indent ? Array( - ((this.path || []).length + 1) * indent + 1 - ).join(' ') : ''; - } catch (e) { - // at times we get an invalid Array size here and need to prevent crashing - indentx = ''; - } - if (commaFirst) indentx = indentx.slice(indent); - - if (Array.isArray(node)) { - var updated = (prevNode || traverse.has(prev, this.path)) - && !Array.isArray(prevNode); - if (updated) { - set('updated'); - } - - if (opts.comment && !Array.isArray(prevNode)) { - indent = 0; - } - - this.before(function () { - if (inserted) set('inserted'); - if (indent && commaFirst) { - if ((this.path || []).length === 0 - || Array.isArray(this.parent.node)) { - write('[ '); - } - else write('\n' + indentx + '[ '); - } - else if (indent) { - write('[\n' + indentx); - } - else { - write('['); - } - }); - - this.post(function (child) { - if (!child.isLast && !(indent && commaFirst)) { - write(','); - } - - var prev = prevNode && prevNode[child.key]; - if (indent && opts.comment && child.node !== prev - && (typeof child.node !== 'object' || typeof prev !== 'object') - ) { - set('comment'); - write(' // != '); - traverse(prev).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - unset('comment'); - } - - if (!child.isLast) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - else if (indent) { - write('\n' + indentx); - } - } - }); - - this.after(function () { - if (indent && commaFirst) write('\n' + indentx); - else if (indent) write('\n' + indentx.slice(indent)); - - write(']'); - if (updated) unset('updated'); - if (inserted) unset('inserted'); - }); - } - else if (isRegExp(node)) { - this.block(); - - if (inserted) { - set('inserted'); - write(node.toString()); - unset('inserted'); - } - else if (insertable && prevNode !== node) { - set('updated'); - write(node.toString()); - unset('updated'); - } - else write(node.toString()); - } - else if (typeof node === 'object' - && node && typeof node.inspect === 'function') { - this.block(); - if (inserted) { - set('inserted'); - write(node.inspect()); - unset('inserted'); - } - else if (!(prevNode && typeof prevNode.inspect === 'function' - && prevNode.inspect() === node.inspect())) { - set('updated'); - write(node.inspect()); - unset('updated'); - } - else write(node.inspect()); - } - else if (typeof node == 'object' && node !== null) { - var insertedKey = false; - var deleted = insertable && typeof prevNode === 'object' && prevNode - ? Object.keys(prevNode).filter(function (key) { - return !Object.hasOwnProperty.call(node, key); - }) - : [] - ; - - this.before(function () { - if (inserted) set('inserted'); - write(indent && commaFirst && !this.isRoot - ? '\n' + indentx + '{ ' - : '{' - ); - }); - - this.pre(function (x, key) { - if (insertable) { - var obj = traverse.get(prev, this.path.concat(key)); - if (obj === undefined) { - insertedKey = true; - set('inserted'); - } - } - - if (indent && !commaFirst) write('\n' + indentx); - - plainStringify(key); - write(indent ? ' : ' : ':'); - }); - - this.post(function (child) { - if (!child.isLast && !(indent && commaFirst)) { - write(','); - } - - if (child.isLast && deleted.length) { - if (insertedKey) unset('inserted'); - insertedKey = false; - } - else if (insertedKey) { - unset('inserted'); - insertedKey = false; - } - - var prev = prevNode && prevNode[child.key]; - if (indent && opts.comment && child.node !== prev - && (typeof child.node !== 'object' || typeof prev !== 'object') - ) { - set('comment'); - write(' // != '); - traverse(prev).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - unset('comment'); - } - - if (child.isLast && deleted.length) { - if (insertedKey) unset('inserted'); - insertedKey = false; - - if (indent && commaFirst) { - write('\n' + indentx + ', ') - } - else if (opts.comment && indent) { - write('\n' + indentx); - } - else if (indent) { - write(',\n' + indentx); - } - else write(','); - } - else { - if (!child.isLast) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - } - } - }); - - this.after(function () { - if (inserted) unset('inserted'); - - if (deleted.length) { - if (indent && !commaFirst - && Object.keys(node).length === 0) { - write('\n' + indentx); - } - - set('deleted'); - deleted.forEach(function (key, ix) { - if (indent && opts.comment) { - unset('deleted'); - set('comment'); - write('// '); - unset('comment'); - set('deleted'); - } - - plainStringify(key); - write(indent ? ' : ' : ':'); - traverse(prevNode[key]).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - - var last = ix === deleted.length - 1; - if (insertable && !last) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - else if (indent) { - write(',\n' + indentx); - } - else write(','); - } - }); - unset('deleted'); - } - - if (commaFirst && indent) { - write(indentx.slice(indent) + ' }'); - } - else if (indent) { - write('\n' + indentx.slice(indent) + '}'); - } - else write('}'); - }); - } - else { - var changed = false; - - if (inserted) set('inserted'); - else if (insertable && !deepEqual(prevNode, node)) { - changed = true; - set('updated'); - } - - if (typeof node === 'string') { - write('"' + node.toString().replace(/"/g, '\\"') + '"'); - } - else if (isRegExp(node)) { - write(node.toString()); - } - else if (typeof node === 'function') { - write(node.name - ? '[Function: ' + node.name + ']' - : '[Function]' - ); - } - else if (node === undefined) { - write('undefined'); - } - else if (node === null) { - write('null'); - } - else { - write(node.toString()); - } - - if (inserted) unset('inserted'); - else if (changed) unset('updated'); - } - } - - if (opts.stream) { - traverse(next).forEach(stringify); - } - else process.nextTick(function () { - traverse(next).forEach(stringify); - stream.emit('end'); - }); - - return stream; -} - -function isRegExp (node) { - return node instanceof RegExp || (node - && typeof node.test === 'function' - && typeof node.exec === 'function' - && typeof node.compile === 'function' - && node.constructor && node.constructor.name === 'RegExp' - ); -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown deleted file mode 100644 index a0648ff..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown +++ /dev/null @@ -1,216 +0,0 @@ -charm -===== - -Use -[ansi terminal characters](http://www.termsys.demon.co.uk/vtansi.htm) -to write colors and cursor positions. - -![me lucky charms](http://substack.net/images/charms.png) - -example -======= - -lucky ------ - -````javascript -var charm = require('charm')(); -charm.pipe(process.stdout); -charm.reset(); - -var colors = [ 'red', 'cyan', 'yellow', 'green', 'blue' ]; -var text = 'Always after me lucky charms.'; - -var offset = 0; -var iv = setInterval(function () { - var y = 0, dy = 1; - for (var i = 0; i < 40; i++) { - var color = colors[(i + offset) % colors.length]; - var c = text[(i + offset) % text.length]; - charm - .move(1, dy) - .foreground(color) - .write(c) - ; - y += dy; - if (y <= 0 || y >= 5) dy *= -1; - } - charm.position(0, 1); - offset ++; -}, 150); -```` - -events -====== - -Charm objects pass along the data events from their input stream except for -events generated from querying the terminal device. - -Because charm puts stdin into raw mode, charm emits two special events: "^C" and -"^D" when the user types those combos. It's super convenient with these events -to do: - -````javascript -charm.on('^C', process.exit) -```` - -The above is set on all `charm` streams. If you want to add your own handling for these -special events simply: - -````javascript -charm.removeAllListeners('^C') -charm.on('^C', function () { - // Don't exit. Do some mad science instead. -}) -```` - -methods -======= - -var charm = require('charm')(param or stream, ...) --------------------------------------------------- - -Create a new readable/writable `charm` stream. - -You can pass in readable or writable streams as parameters and they will be -piped to or from accordingly. You can also pass `process` in which case -`process.stdin` and `process.stdout` will be used. - -You can `pipe()` to and from the `charm` object you get back. - -charm.reset() -------------- - -Reset the entire screen, like the /usr/bin/reset command. - -charm.destroy(), charm.end() ----------------------------- - -Emit an `"end"` event downstream. - -charm.write(msg) ----------------- - -Pass along `msg` to the output stream. - -charm.position(x, y) --------------------- - -Set the cursor position to the absolute coordinates `x, y`. - -charm.position(cb) ------------------- - -Query the absolute cursor position from the input stream through the output -stream (the shell does this automatically) and get the response back as -`cb(x, y)`. - -charm.move(x, y) ----------------- - -Move the cursor position by the relative coordinates `x, y`. - -charm.up(y) ------------ - -Move the cursor up by `y` rows. - -charm.down(y) -------------- - -Move the cursor down by `y` rows. - -charm.left(x) -------------- - -Move the cursor left by `x` columns. - -charm.right(x) --------------- - -Move the cursor right by `x` columns. - -charm.push(withAttributes=false) --------------------------------- - -Push the cursor state and optionally the attribute state. - -charm.pop(withAttributes=false) -------------------------------- - -Pop the cursor state and optionally the attribute state. - -charm.erase(s) --------------- - -Erase a region defined by the string `s`. - -`s` can be: - -* end - erase from the cursor to the end of the line -* start - erase from the cursor to the start of the line -* line - erase the current line -* down - erase everything below the current line -* up - erase everything above the current line -* screen - erase the entire screen - -charm.display(attr) -------------------- - -Set the display mode with the string `attr`. - -`attr` can be: - -* reset -* bright -* dim -* underscore -* blink -* reverse -* hidden - -charm.foreground(color) ------------------------ - -Set the foreground color with the string `color`, which can be: - -* red -* yellow -* green -* blue -* cyan -* magenta -* black -* white - -or `color` can be an integer from 0 to 255, inclusive. - -charm.background(color) ------------------------ - -Set the background color with the string `color`, which can be: - -* red -* yellow -* green -* blue -* cyan -* magenta -* black -* white - -or `color` can be an integer from 0 to 255, inclusive. - -charm.cursor(visible) ---------------------- - -Set the cursor visibility with a boolean `visible`. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install charm -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/256.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/256.js deleted file mode 100644 index 6851386..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/256.js +++ /dev/null @@ -1,17 +0,0 @@ -var charm = require('../')(process); - -function exit () { - charm.display('reset'); - process.exit(); -} -charm.on('^C', exit); - -var ix = 0; -var iv = setInterval(function () { - charm.background(ix++).write(' '); - if (ix === 256) { - clearInterval(iv); - charm.write('\n'); - exit(); - } -}, 10); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js deleted file mode 100644 index 2647e71..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js +++ /dev/null @@ -1,11 +0,0 @@ -var charm = require('../')(); -charm.pipe(process.stdout); - -charm - .column(16) - .write('beep') - .down() - .column(32) - .write('boop\n') - .end() -; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js deleted file mode 100644 index 0c565b0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js +++ /dev/null @@ -1,22 +0,0 @@ -var charm = require('../')(process); - -charm.position(5, 10); - -charm.position(function (x, y) { - console.dir([ x, y ]); - - charm.move(7,2); - charm.push(); - process.stdout.write('lul'); - - charm.left(3).up(1).foreground('magenta'); - process.stdout.write('v'); - charm.left(1).up(1).display('reset'); - process.stdout.write('|'); - - charm.down(3); - charm.pop().background('blue'); - process.stdout.write('popped\npow'); - charm.display('reset').erase('line'); - charm.destroy(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js deleted file mode 100644 index 727e3e8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js +++ /dev/null @@ -1,36 +0,0 @@ -var http = require('http'); -var charmer = require('../'); - -http.createServer(function (req, res) { - res.setHeader('content-type', 'text/ansi'); - - var charm = charmer(); - charm.pipe(res); - charm.reset(); - - var radius = 10; - var theta = 0; - var points = []; - - var iv = setInterval(function () { - var x = 2 + (radius + Math.cos(theta) * radius) * 2; - var y = 2 + radius + Math.sin(theta) * radius; - - points.unshift([ x, y ]); - var colors = [ 'red', 'yellow', 'green', 'cyan', 'blue', 'magenta' ]; - - points.forEach(function (p, i) { - charm.position(p[0], p[1]); - var c = colors[Math.floor(i / 12)]; - charm.background(c).write(' ') - }); - points = points.slice(0, 12 * colors.length - 1); - - theta += Math.PI / 40; - }, 50); - - req.connection.on('end', function () { - clearInterval(iv); - charm.end(); - }); -}).listen(8081); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js deleted file mode 100644 index 01fe801..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js +++ /dev/null @@ -1,24 +0,0 @@ -var charm = require('../')(); -charm.pipe(process.stdout); -charm.reset(); - -var colors = [ 'red', 'cyan', 'yellow', 'green', 'blue' ]; -var text = 'Always after me lucky charms.'; - -var offset = 0; -var iv = setInterval(function () { - var y = 0, dy = 1; - for (var i = 0; i < 40; i++) { - var color = colors[(i + offset) % colors.length]; - var c = text[(i + offset) % text.length]; - charm - .move(1, dy) - .foreground(color) - .write(c) - ; - y += dy; - if (y <= 0 || y >= 5) dy *= -1; - } - charm.position(0, 1); - offset ++; -}, 150); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js deleted file mode 100644 index 2c5ae9b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js +++ /dev/null @@ -1,7 +0,0 @@ -var charm = require('charm')(process); - -charm.on('^C', process.exit); - -charm.position(function (x, y) { - console.log('(%d, %d)', x, y); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js deleted file mode 100644 index 9da3c13..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js +++ /dev/null @@ -1,18 +0,0 @@ -var charm = require('../')(); -charm.pipe(process.stdout); - -charm.write('Progress: 0 %'); -var i = 0; - -var iv = setInterval(function () { - charm.left(i.toString().length + 2); - i ++; - charm.write(i + ' %'); - if (i === 100) { - charm.end('\nDone!\n'); - clearInterval(iv); - } -}, 25); - -charm.on('^C',process.exit); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/resize.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/resize.js deleted file mode 100644 index bda80b6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/resize.js +++ /dev/null @@ -1,62 +0,0 @@ -var c = require('../')(); -c.pipe(process.stdout); -c.on('^C', process.exit); - -var queue = (function () { - var tasks = []; - var pending = false; - - return { - abort : function () { - tasks = []; - next(); - }, - push : function (t) { - tasks.push(t); - if (!pending) next(); - } - }; - - function next () { - pending = true; - process.nextTick(function () { - if (tasks.length === 0) return; - var t = tasks.shift(); - t(); - pending = false; - next(); - }); - } -})(); - -process.stdout.on('resize', draw); -draw(); -setInterval(function () {}, 1e8); - -function draw () { - var cols = process.stdout.columns; - var rows = process.stdout.rows; - queue.abort(); - - queue.push(function () { - c.reset(); - c.background('blue'); - c.position(1, 1); - c.write(Array(cols + 1).join(' ')); - }); - - for (var y = 1; y < rows; y++) { - queue.push(function () { - c.position(1, y); - c.write(' '); - c.position(cols, y); - c.write(' '); - }); - } - - queue.push(function () { - c.position(1, rows); - c.write(Array(cols + 1).join(' ')); - c.display('reset'); - }); -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js deleted file mode 100644 index fd3e23a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js +++ /dev/null @@ -1,23 +0,0 @@ -var charm = require('../')(process); -charm.reset(); - -var radius = 10; -var theta = 0; -var points = []; - -var iv = setInterval(function () { - var x = 2 + (radius + Math.cos(theta) * radius) * 2; - var y = 2 + radius + Math.sin(theta) * radius; - - points.unshift([ x, y ]); - var colors = [ 'red', 'yellow', 'green', 'cyan', 'blue', 'magenta' ]; - - points.forEach(function (p, i) { - charm.position(p[0], p[1]); - var c = colors[Math.floor(i / 12)]; - charm.background(c).write(' ') - }); - points = points.slice(0, 12 * colors.length - 1); - - theta += Math.PI / 40; -}, 50); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/index.js deleted file mode 100644 index e1e7bdc..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/index.js +++ /dev/null @@ -1,305 +0,0 @@ -var tty = require('tty'); -var encode = require('./lib/encode'); -var Stream = require('stream').Stream; - -var exports = module.exports = function () { - var input = null; - function setInput (s) { - if (input) throw new Error('multiple inputs specified') - else input = s - } - - var output = null; - function setOutput (s) { - if (output) throw new Error('multiple outputs specified') - else output = s - } - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; - if (arg.readable) setInput(arg) - else if (arg.stdin || arg.input) setInput(arg.stdin || arg.input) - - if (arg.writable) setOutput(arg) - else if (arg.stdout || arg.output) setOutput(arg.stdout || arg.output) - - } - - if (input && typeof input.fd === 'number' && tty.isatty(input.fd)) { - if (process.stdin.setRawMode) { - process.stdin.setRawMode(true); - } - else tty.setRawMode(true); - } - - var charm = new Charm; - if (input) { - input.pipe(charm); - } - - if (output) { - charm.pipe(output); - } - - charm.once('^C', process.exit); - charm.once('end', function () { - if (input) { - if (typeof input.fd === 'number' && tty.isatty(input.fd)) { - if (process.stdin.setRawMode) { - process.stdin.setRawMode(false); - } - else tty.setRawMode(false); - } - input.destroy(); - } - }); - - return charm; -}; - -var Charm = exports.Charm = function Charm () { - this.writable = true; - this.readable = true; - this.pending = []; -} - -Charm.prototype = new Stream; - -Charm.prototype.write = function (buf) { - var self = this; - - if (self.pending.length) { - var codes = extractCodes(buf); - var matched = false; - - for (var i = 0; i < codes.length; i++) { - for (var j = 0; j < self.pending.length; j++) { - var cb = self.pending[j]; - if (cb(codes[i])) { - matched = true; - self.pending.splice(j, 1); - break; - } - } - } - - if (matched) return; - } - - if (buf.length === 1) { - if (buf[0] === 3) self.emit('^C'); - if (buf[0] === 4) self.emit('^D'); - } - - self.emit('data', buf); - - return self; -}; - - -Charm.prototype.destroy = function () { - this.end(); -}; - -Charm.prototype.end = function (buf) { - if (buf) this.write(buf); - this.emit('end'); -}; - -Charm.prototype.reset = function (cb) { - this.write(encode('c')); - return this; -}; - -Charm.prototype.position = function (x, y) { - // get/set absolute coordinates - if (typeof x === 'function') { - var cb = x; - this.pending.push(function (buf) { - if (buf[0] === 27 && buf[1] === encode.ord('[') - && buf[buf.length-1] === encode.ord('R')) { - var pos = buf.toString() - .slice(2,-1) - .split(';') - .map(Number) - ; - cb(pos[1], pos[0]); - return true; - } - }); - this.write(encode('[6n')); - } - else { - this.write(encode( - '[' + Math.floor(y) + ';' + Math.floor(x) + 'f' - )); - } - return this; -}; - -Charm.prototype.move = function (x, y) { - // set relative coordinates - var bufs = []; - - if (y < 0) this.up(-y) - else if (y > 0) this.down(y) - - if (x > 0) this.right(x) - else if (x < 0) this.left(-x) - - return this; -}; - -Charm.prototype.up = function (y) { - if (y === undefined) y = 1; - this.write(encode('[' + Math.floor(y) + 'A')); - return this; -}; - -Charm.prototype.down = function (y) { - if (y === undefined) y = 1; - this.write(encode('[' + Math.floor(y) + 'B')); - return this; -}; - -Charm.prototype.right = function (x) { - if (x === undefined) x = 1; - this.write(encode('[' + Math.floor(x) + 'C')); - return this; -}; - -Charm.prototype.left = function (x) { - if (x === undefined) x = 1; - this.write(encode('[' + Math.floor(x) + 'D')); - return this; -}; - -Charm.prototype.column = function (x) { - this.write(encode('[' + Math.floor(x) + 'G')); - return this; -}; - -Charm.prototype.push = function (withAttributes) { - this.write(encode(withAttributes ? '7' : '[s')); - return this; -}; - -Charm.prototype.pop = function (withAttributes) { - this.write(encode(withAttributes ? '8' : '[u')); - return this; -}; - -Charm.prototype.erase = function (s) { - if (s === 'end' || s === '$') { - this.write(encode('[K')); - } - else if (s === 'start' || s === '^') { - this.write(encode('[1K')); - } - else if (s === 'line') { - this.write(encode('[2K')); - } - else if (s === 'down') { - this.write(encode('[J')); - } - else if (s === 'up') { - this.write(encode('[1J')); - } - else if (s === 'screen') { - this.write(encode('[1J')); - } - else { - this.emit('error', new Error('Unknown erase type: ' + s)); - } - return this; -}; - -Charm.prototype.display = function (attr) { - var c = { - reset : 0, - bright : 1, - dim : 2, - underscore : 4, - blink : 5, - reverse : 7, - hidden : 8 - }[attr]; - if (c === undefined) { - this.emit('error', new Error('Unknown attribute: ' + attr)); - } - this.write(encode('[' + c + 'm')); - return this; -}; - -Charm.prototype.foreground = function (color) { - if (typeof color === 'number') { - if (color < 0 || color >= 256) { - this.emit('error', new Error('Color out of range: ' + color)); - } - this.write(encode('[38;5;' + color + 'm')); - } - else { - var c = { - black : 30, - red : 31, - green : 32, - yellow : 33, - blue : 34, - magenta : 35, - cyan : 36, - white : 37 - }[color.toLowerCase()]; - - if (!c) this.emit('error', new Error('Unknown color: ' + color)); - this.write(encode('[' + c + 'm')); - } - return this; -}; - -Charm.prototype.background = function (color) { - if (typeof color === 'number') { - if (color < 0 || color >= 256) { - this.emit('error', new Error('Color out of range: ' + color)); - } - this.write(encode('[48;5;' + color + 'm')); - } - else { - var c = { - black : 40, - red : 41, - green : 42, - yellow : 43, - blue : 44, - magenta : 45, - cyan : 46, - white : 47 - }[color.toLowerCase()]; - - if (!c) this.emit('error', new Error('Unknown color: ' + color)); - this.write(encode('[' + c + 'm')); - } - return this; -}; - -Charm.prototype.cursor = function (visible) { - this.write(encode(visible ? '[?25h' : '[?25l')); - return this; -}; - -var extractCodes = exports.extractCodes = function (buf) { - var codes = []; - var start = -1; - - for (var i = 0; i < buf.length; i++) { - if (buf[i] === 27) { - if (start >= 0) codes.push(buf.slice(start, i)); - start = i; - } - else if (start >= 0 && i === buf.length - 1) { - codes.push(buf.slice(start)); - } - } - - return codes; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js deleted file mode 100644 index 3b6417a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js +++ /dev/null @@ -1,18 +0,0 @@ -var encode = module.exports = function (xs) { - function bytes (s) { - if (typeof s === 'string') { - return s.split('').map(ord); - } - else if (Array.isArray(s)) { - return s.reduce(function (acc, c) { - return acc.concat(bytes(c)); - }, []); - } - } - - return new Buffer([ 0x1b ].concat(bytes(xs))); -}; - -var ord = encode.ord = function ord (c) { - return c.charCodeAt(0) -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/package.json deleted file mode 100644 index 1116802..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/charm/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "charm", - "version": "0.1.2", - "description": "ansi control sequences for terminal cursor hopping and colors", - "main": "index.js", - "directories": { - "lib": ".", - "example": "example", - "test": "test" - }, - "repository": { - "type": "git", - "url": "http://github.com/substack/node-charm.git" - }, - "keywords": [ - "terminal", - "ansi", - "cursor", - "color", - "console", - "control", - "escape", - "sequence" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT/X11", - "engine": { - "node": ">=0.4" - }, - "_id": "charm@0.1.2", - "dist": { - "shasum": "06c21eed1a1b06aeb67553cdc53e23274bac2296", - "tarball": "http://registry.npmjs.org/charm/-/charm-0.1.2.tgz" - }, - "_from": "charm@0.1.x", - "_npmVersion": "1.2.2", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "06c21eed1a1b06aeb67553cdc53e23274bac2296", - "_resolved": "https://registry.npmjs.org/charm/-/charm-0.1.2.tgz", - "bugs": { - "url": "https://github.com/substack/node-charm/issues" - }, - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/substack/node-charm" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/.travis.yml deleted file mode 100644 index d523c5f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 - - 0.8 - - 0.10 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/LICENSE deleted file mode 100644 index c38f840..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012, 2013 Thorsten Lorenz -Copyright (c) 2012 James Halliday -Copyright (c) 2009 Thomas Robinson <280north.com> - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/README.markdown deleted file mode 100644 index eb69a83..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/README.markdown +++ /dev/null @@ -1,70 +0,0 @@ -deep-is -========== - -Node's `assert.deepEqual() algorithm` as a standalone module. Exactly like -[deep-equal](https://github.com/substack/node-deep-equal) except for the fact that `deepEqual(NaN, NaN) === true`. - -This module is around [5 times faster](https://gist.github.com/2790507) -than wrapping `assert.deepEqual()` in a `try/catch`. - -[![browser support](http://ci.testling.com/thlorenz/deep-is.png)](http://ci.testling.com/thlorenz/deep-is) - -[![build status](https://secure.travis-ci.org/thlorenz/deep-is.png)](http://travis-ci.org/thlorenz/deep-is) - -example -======= - -``` js -var equal = require('deep-is'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); -``` - -methods -======= - -var deepIs = require('deep-is') - -deepIs(a, b) ---------------- - -Compare objects `a` and `b`, returning whether they are equal according to a -recursive equality algorithm. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install deep-is -``` - -test -==== - -With [npm](http://npmjs.org) do: - -``` -npm test -``` - -license -======= - -Copyright (c) 2012, 2013 Thorsten Lorenz -Copyright (c) 2012 James Halliday - -Derived largely from node's assert module, which has the copyright statement: - -Copyright (c) 2009 Thomas Robinson <280north.com> - -Released under the MIT license, see LICENSE for details. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/example/cmp.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/example/cmp.js deleted file mode 100644 index 67014b8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/example/cmp.js +++ /dev/null @@ -1,11 +0,0 @@ -var equal = require('../'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/index.js deleted file mode 100644 index 506fe27..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/index.js +++ /dev/null @@ -1,102 +0,0 @@ -var pSlice = Array.prototype.slice; -var Object_keys = typeof Object.keys === 'function' - ? Object.keys - : function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } -; - -var deepEqual = module.exports = function (actual, expected) { - // enforce Object.is +0 !== -0 - if (actual === 0 && expected === 0) { - return areZerosEqual(actual, expected); - - // 7.1. All identical values are equivalent, as determined by ===. - } else if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - } else if (isNumberNaN(actual)) { - return isNumberNaN(expected); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -}; - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function isNumberNaN(value) { - // NaN === NaN -> false - return typeof value == 'number' && value !== value; -} - -function areZerosEqual(zeroA, zeroB) { - // (1 / +0|0) -> Infinity, but (1 / -0) -> -Infinity and (Infinity !== -Infinity) - return (1 / zeroA) === (1 / zeroB); -} - -function objEquiv(a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b); - } - try { - var ka = Object_keys(a), - kb = Object_keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key])) return false; - } - return true; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/package.json deleted file mode 100644 index 5c8307e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/package.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "name": "deep-is", - "version": "0.1.3", - "description": "node's assert.deepEqual algorithm except for NaN being equal to NaN", - "main": "index.js", - "directories": { - "lib": ".", - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tape test/*.js" - }, - "devDependencies": { - "tape": "~1.0.2" - }, - "repository": { - "type": "git", - "url": "http://github.com/thlorenz/deep-is.git" - }, - "keywords": [ - "equality", - "equal", - "compare" - ], - "author": { - "name": "Thorsten Lorenz", - "email": "thlorenz@gmx.de", - "url": "http://thlorenz.com" - }, - "license": { - "type": "MIT", - "url": "https://github.com/thlorenz/deep-is/blob/master/LICENSE" - }, - "testling": { - "files": "test/*.js", - "browsers": { - "ie": [ - 6, - 7, - 8, - 9 - ], - "ff": [ - 3.5, - 10, - 15 - ], - "chrome": [ - 10, - 22 - ], - "safari": [ - 5.1 - ], - "opera": [ - 12 - ] - } - }, - "gitHead": "f126057628423458636dec9df3d621843b9ac55e", - "bugs": { - "url": "https://github.com/thlorenz/deep-is/issues" - }, - "homepage": "https://github.com/thlorenz/deep-is", - "_id": "deep-is@0.1.3", - "_shasum": "b369d6fb5dbc13eecf524f91b070feedc357cf34", - "_from": "deep-is@0.1.x", - "_npmVersion": "1.4.14", - "_npmUser": { - "name": "thlorenz", - "email": "thlorenz@gmx.de" - }, - "maintainers": [ - { - "name": "thlorenz", - "email": "thlorenz@gmx.de" - } - ], - "dist": { - "shasum": "b369d6fb5dbc13eecf524f91b070feedc357cf34", - "tarball": "http://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz" - }, - "_resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/NaN.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/NaN.js deleted file mode 100644 index ddaa5a7..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/NaN.js +++ /dev/null @@ -1,16 +0,0 @@ -var test = require('tape'); -var equal = require('../'); - -test('NaN and 0 values', function (t) { - t.ok(equal(NaN, NaN)); - t.notOk(equal(0, NaN)); - t.ok(equal(0, 0)); - t.notOk(equal(0, 1)); - t.end(); -}); - - -test('nested NaN values', function (t) { - t.ok(equal([ NaN, 1, NaN ], [ NaN, 1, NaN ])); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/cmp.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/cmp.js deleted file mode 100644 index 3071013..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/cmp.js +++ /dev/null @@ -1,23 +0,0 @@ -var test = require('tape'); -var equal = require('../'); - -test('equal', function (t) { - t.ok(equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - )); - t.end(); -}); - -test('not equal', function (t) { - t.notOk(equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - )); - t.end(); -}); - -test('nested nulls', function (t) { - t.ok(equal([ null, null, null ], [ null, null, null ])); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/neg-vs-pos-0.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/neg-vs-pos-0.js deleted file mode 100644 index ac26130..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/deep-is/test/neg-vs-pos-0.js +++ /dev/null @@ -1,15 +0,0 @@ -var test = require('tape'); -var equal = require('../'); - -test('0 values', function (t) { - t.ok(equal( 0, 0), ' 0 === 0'); - t.ok(equal( 0, +0), ' 0 === +0'); - t.ok(equal(+0, +0), '+0 === +0'); - t.ok(equal(-0, -0), '-0 === -0'); - - t.notOk(equal(-0, 0), '-0 !== 0'); - t.notOk(equal(-0, +0), '-0 !== +0'); - - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.travis.yml deleted file mode 100644 index 2d26206..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.6 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE deleted file mode 100644 index 7b75500..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: -http://www.opensource.org/licenses/mit-license.php - -Copyright 2010 James Halliday (mail@substack.net) - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js deleted file mode 100755 index 50d612e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js +++ /dev/null @@ -1,16 +0,0 @@ -var traverse = require('traverse'); - -var id = 54; -var callbacks = {}; -var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - -var scrubbed = traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } -}); - -console.dir(scrubbed); -console.dir(callbacks); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js deleted file mode 100755 index c1b310b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js +++ /dev/null @@ -1,15 +0,0 @@ -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js deleted file mode 100755 index 78608a0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js +++ /dev/null @@ -1,8 +0,0 @@ -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js deleted file mode 100755 index 5d15b91..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js deleted file mode 100755 index 167b68b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node -var traverse = require('traverse'); - -var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -var s = ''; -traverse(obj).forEach(function to_s (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - to_s(key); - s += ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'string') { - s += '"' + node.toString().replace(/"/g, '\\"') + '"'; - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } -}); - -console.log('JSON.stringify: ' + JSON.stringify(obj)); -console.log('this stringify: ' + s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js deleted file mode 100644 index 2f2cf67..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js +++ /dev/null @@ -1,314 +0,0 @@ -var traverse = module.exports = function (obj) { - return new Traverse(obj); -}; - -function Traverse (obj) { - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!node || !hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.has = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!node || !hasOwnProperty.call(node, key)) { - return false; - } - node = node[key]; - } - return true; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(objectKeys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function (stopHere) { - delete state.parent.node[state.key]; - if (stopHere) keepGoing = false; - }, - remove : function (stopHere) { - if (isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - if (stopHere) keepGoing = false; - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - function updateState() { - if (typeof state.node === 'object' && state.node !== null) { - if (!state.keys || state.node_ !== state.node) { - state.keys = objectKeys(state.node) - } - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - state.keys = null; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - } - - updateState(); - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - updateState(); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (isArray(src)) { - dst = []; - } - else if (isDate(src)) { - dst = new Date(src.getTime ? src.getTime() : src); - } - else if (isRegExp(src)) { - dst = new RegExp(src); - } - else if (isError(src)) { - dst = { message: src.message }; - } - else if (isBoolean(src)) { - dst = new Boolean(src); - } - else if (isNumber(src)) { - dst = new Number(src); - } - else if (isString(src)) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.constructor === Object) { - dst = {}; - } - else { - var proto = - (src.constructor && src.constructor.prototype) - || src.__proto__ - || {} - ; - var T = function () {}; - T.prototype = proto; - dst = new T; - } - - forEach(objectKeys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var objectKeys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -function toS (obj) { return Object.prototype.toString.call(obj) } -function isDate (obj) { return toS(obj) === '[object Date]' } -function isRegExp (obj) { return toS(obj) === '[object RegExp]' } -function isError (obj) { return toS(obj) === '[object Error]' } -function isBoolean (obj) { return toS(obj) === '[object Boolean]' } -function isNumber (obj) { return toS(obj) === '[object Number]' } -function isString (obj) { return toS(obj) === '[object String]' } - -var isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(objectKeys(Traverse.prototype), function (key) { - traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = new Traverse(obj); - return t[key].apply(t, args); - }; -}); - -var hasOwnProperty = Object.hasOwnProperty || function (obj, key) { - return key in obj; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json deleted file mode 100644 index a71577b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "traverse", - "version": "0.6.6", - "description": "traverse and transform objects by visiting every node on a recursive walk", - "main": "index.js", - "directories": { - "example": "example", - "test": "test" - }, - "devDependencies": { - "tape": "~1.0.4" - }, - "scripts": { - "test": "tape test/*.js" - }, - "testling": { - "files": "test/*.js", - "browsers": { - "iexplore": [ - "6.0", - "7.0", - "8.0", - "9.0" - ], - "chrome": [ - "10.0", - "20.0" - ], - "firefox": [ - "10.0", - "15.0" - ], - "safari": [ - "5.1" - ], - "opera": [ - "12.0" - ] - } - }, - "repository": { - "type": "git", - "url": "git://github.com/substack/js-traverse.git" - }, - "homepage": "https://github.com/substack/js-traverse", - "keywords": [ - "traverse", - "walk", - "recursive", - "map", - "forEach", - "deep", - "clone" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/substack/js-traverse/issues" - }, - "_id": "traverse@0.6.6", - "dist": { - "shasum": "cbdf560fd7b9af632502fed40f918c157ea97137", - "tarball": "http://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz" - }, - "_from": "traverse@0.6.x", - "_npmVersion": "1.3.7", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "cbdf560fd7b9af632502fed40f918c157ea97137", - "_resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.6.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/readme.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/readme.markdown deleted file mode 100644 index fbfd06e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/readme.markdown +++ /dev/null @@ -1,209 +0,0 @@ -# traverse - -Traverse and transform objects by visiting every node on a recursive walk. - -[![browser support](http://ci.testling.com/substack/js-traverse.png)](http://ci.testling.com/substack/js-traverse) - -[![build status](https://secure.travis-ci.org/substack/js-traverse.png)](http://travis-ci.org/substack/js-traverse) - -# examples - -## transform negative numbers in-place - -negative.js - -````javascript -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); -```` - -Output: - - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ] - -## collect leaf nodes - -leaves.js - -````javascript -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); -```` - -Output: - - [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -## scrub circular references - -scrub.js: - -````javascript -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); -```` - -output: - - { a: 1, b: 2, c: [ 3, 4 ] } - -# methods - -Each method that takes an `fn` uses the context documented below in the context -section. - -## .map(fn) - -Execute `fn` for each node in the object and return a new object with the -results of the walk. To update nodes in the result use `this.update(value)`. - -## .forEach(fn) - -Execute `fn` for each node in the object but unlike `.map()`, when -`this.update()` is called it updates the object in-place. - -## .reduce(fn, acc) - -For each node in the object, perform a -[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) -with the return value of `fn(acc, node)`. - -If `acc` isn't specified, `acc` is set to the root object for the first step -and the root element is skipped. - -## .paths() - -Return an `Array` of every possible non-cyclic path in the object. -Paths are `Array`s of string keys. - -## .nodes() - -Return an `Array` of every node in the object. - -## .clone() - -Create a deep clone of the object. - -## .get(path) - -Get the element at the array `path`. - -## .set(path, value) - -Set the element at the array `path` to `value`. - -## .has(path) - -Return whether the element at the array `path` exists. - -# context - -Each method that takes a callback has a context (its `this` object) with these -attributes: - -## this.node - -The present node on the recursive walk - -## this.path - -An array of string keys from the root to the present node - -## this.parent - -The context of the node's parent. -This is `undefined` for the root node. - -## this.key - -The name of the key of the present node in its parent. -This is `undefined` for the root node. - -## this.isRoot, this.notRoot - -Whether the present node is the root node - -## this.isLeaf, this.notLeaf - -Whether or not the present node is a leaf node (has no children) - -## this.level - -Depth of the node within the traversal - -## this.circular - -If the node equals one of its parents, the `circular` attribute is set to the -context of that parent and the traversal progresses no deeper. - -## this.update(value, stopHere=false) - -Set a new value for the present node. - -All the elements in `value` will be recursively traversed unless `stopHere` is -true. - -## this.remove(stopHere=false) - -Remove the current element from the output. If the node is in an Array it will -be spliced off. Otherwise it will be deleted from its parent. - -## this.delete(stopHere=false) - -Delete the current element from its parent in the output. Calls `delete` even on -Arrays. - -## this.before(fn) - -Call this function before any of the children are traversed. - -You can assign into `this.keys` here to traverse in a custom order. - -## this.after(fn) - -Call this function after any of the children are traversed. - -## this.pre(fn) - -Call this function before each of the children are traversed. - -## this.post(fn) - -Call this function after each of the children are traversed. - - -# install - -Using [npm](http://npmjs.org) do: - - $ npm install traverse - -# license - -MIT diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js deleted file mode 100644 index f56506a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js +++ /dev/null @@ -1,117 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); -var util = require('util'); - -test('circular', function (t) { - t.plan(1); - - var obj = { x : 3 }; - obj.y = obj; - traverse(obj).forEach(function (x) { - if (this.path.join('') == 'y') { - t.equal( - util.inspect(this.circular.node), - util.inspect(obj) - ); - } - }); -}); - -test('deepCirc', function (t) { - t.plan(2); - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - - var times = 0; - traverse(obj).forEach(function (x) { - if (this.circular) { - t.same(this.circular.path, []); - t.same(this.path, [ 'y', 2 ]); - } - }); -}); - -test('doubleCirc', function (t) { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var circs = []; - traverse(obj).forEach(function (x) { - if (this.circular) { - circs.push({ circ : this.circular, self : this, node : x }); - } - }); - - t.same(circs[0].self.path, [ 'x', 3, 2 ]); - t.same(circs[0].circ.path, []); - - t.same(circs[1].self.path, [ 'y', 2 ]); - t.same(circs[1].circ.path, []); - - t.same(circs.length, 2); - t.end(); -}); - -test('circDubForEach', function (t) { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - traverse(obj).forEach(function (x) { - if (this.circular) this.update('...'); - }); - - t.same(obj, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); - t.end(); -}); - -test('circDubMap', function (t) { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var c = traverse(obj).map(function (x) { - if (this.circular) { - this.update('...'); - } - }); - - t.same(c, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); - t.end(); -}); - -test('circClone', function (t) { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var clone = traverse.clone(obj); - t.ok(obj !== clone); - - t.ok(clone.y[2] === clone); - t.ok(clone.y[2] !== obj); - t.ok(clone.x[3][2] === clone); - t.ok(clone.x[3][2] !== obj); - t.same(clone.x.slice(0,3), [1,2,3]); - t.same(clone.y.slice(0,2), [4,5]); - t.end(); -}); - -test('circMapScrub', function (t) { - var obj = { a : 1, b : 2 }; - obj.c = obj; - - var scrubbed = traverse(obj).map(function (node) { - if (this.circular) this.remove(); - }); - t.same( - Object.keys(scrubbed).sort(), - [ 'a', 'b' ] - ); - t.ok(deepEqual(scrubbed, { a : 1, b : 2 })); - - t.equal(obj.c, obj); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js deleted file mode 100644 index 54db4b0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js +++ /dev/null @@ -1,37 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('dateEach', function (t) { - var obj = { x : new Date, y : 10, z : 5 }; - - var counts = {}; - - traverse(obj).forEach(function (node) { - var t = (node instanceof Date && 'Date') || typeof node; - counts[t] = (counts[t] || 0) + 1; - }); - - t.same(counts, { - object : 1, - Date : 1, - number : 2, - }); - t.end(); -}); - -test('dateMap', function (t) { - var obj = { x : new Date, y : 10, z : 5 }; - - var res = traverse(obj).map(function (node) { - if (typeof node === 'number') this.update(node + 100); - }); - - t.ok(obj.x !== res.x); - t.same(res, { - x : obj.x, - y : 110, - z : 105, - }); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js deleted file mode 100644 index fd0463c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js +++ /dev/null @@ -1,240 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -test('deepDates', function (t) { - t.plan(2); - - t.ok( - deepEqual( - { d : new Date, x : [ 1, 2, 3 ] }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'dates should be equal' - ); - - var d0 = new Date; - setTimeout(function () { - t.ok( - !deepEqual( - { d : d0, x : [ 1, 2, 3 ], }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'microseconds should count in date equality' - ); - }, 5); -}); - -test('deepCircular', function (t) { - var a = [1]; - a.push(a); // a = [ 1, *a ] - - var b = [1]; - b.push(a); // b = [ 1, [ 1, *a ] ] - - t.ok( - !deepEqual(a, b), - 'circular ref mount points count towards equality' - ); - - var c = [1]; - c.push(c); // c = [ 1, *c ] - t.ok( - deepEqual(a, c), - 'circular refs are structurally the same here' - ); - - var d = [1]; - d.push(a); // c = [ 1, [ 1, *d ] ] - t.ok( - deepEqual(b, d), - 'non-root circular ref structural comparison' - ); - - t.end(); -}); - -test('deepInstances', function (t) { - t.ok( - !deepEqual([ new Boolean(false) ], [ false ]), - 'boolean instances are not real booleans' - ); - - t.ok( - !deepEqual([ new String('x') ], [ 'x' ]), - 'string instances are not real strings' - ); - - t.ok( - !deepEqual([ new Number(4) ], [ 4 ]), - 'number instances are not real numbers' - ); - - t.ok( - deepEqual([ new RegExp('x') ], [ /x/ ]), - 'regexp instances are real regexps' - ); - - t.ok( - !deepEqual([ new RegExp(/./) ], [ /../ ]), - 'these regexps aren\'t the same' - ); - - t.ok( - !deepEqual( - [ function (x) { return x * 2 } ], - [ function (x) { return x * 2 } ] - ), - 'functions with the same .toString() aren\'t necessarily the same' - ); - - var f = function (x) { return x * 2 }; - t.ok( - deepEqual([ f ], [ f ]), - 'these functions are actually equal' - ); - - t.end(); -}); - -test('deepEqual', function (t) { - t.ok( - !deepEqual([ 1, 2, 3 ], { 0 : 1, 1 : 2, 2 : 3 }), - 'arrays are not objects' - ); - t.end(); -}); - -test('falsy', function (t) { - t.ok( - !deepEqual([ undefined ], [ null ]), - 'null is not undefined!' - ); - - t.ok( - !deepEqual([ null ], [ undefined ]), - 'undefined is not null!' - ); - - t.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'undefined is not null, however deeply!' - ); - - t.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); - - t.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); - - t.end(); -}); - -test('deletedArrayEqual', function (t) { - var xs = [ 1, 2, 3, 4 ]; - delete xs[2]; - - var ys = Object.create(Array.prototype); - ys[0] = 1; - ys[1] = 2; - ys[3] = 4; - - t.ok( - deepEqual(xs, ys), - 'arrays with deleted elements are only equal to' - + ' arrays with similarly deleted elements' - ); - - t.ok( - !deepEqual(xs, [ 1, 2, undefined, 4 ]), - 'deleted array elements cannot be undefined' - ); - - t.ok( - !deepEqual(xs, [ 1, 2, null, 4 ]), - 'deleted array elements cannot be null' - ); - - t.end(); -}); - -test('deletedObjectEqual', function (t) { - var obj = { a : 1, b : 2, c : 3 }; - delete obj.c; - - t.ok( - deepEqual(obj, { a : 1, b : 2 }), - 'deleted object elements should not show up' - ); - - t.ok( - !deepEqual(obj, { a : 1, b : 2, c : undefined }), - 'deleted object elements are not undefined' - ); - - t.ok( - !deepEqual(obj, { a : 1, b : 2, c : null }), - 'deleted object elements are not null' - ); - - t.end(); -}); - -test('emptyKeyEqual', function (t) { - t.ok(!deepEqual( - { a : 1 }, { a : 1, '' : 55 } - )); - - t.end(); -}); - -test('deepArguments', function (t) { - t.ok( - !deepEqual( - [ 4, 5, 6 ], - (function () { return arguments })(4, 5, 6) - ), - 'arguments are not arrays' - ); - - t.ok( - deepEqual( - (function () { return arguments })(4, 5, 6), - (function () { return arguments })(4, 5, 6) - ), - 'arguments should equal' - ); - - t.end(); -}); - -test('deepUn', function (t) { - t.ok(!deepEqual({ a : 1, b : 2 }, undefined)); - t.ok(!deepEqual({ a : 1, b : 2 }, {})); - t.ok(!deepEqual(undefined, { a : 1, b : 2 })); - t.ok(!deepEqual({}, { a : 1, b : 2 })); - t.ok(deepEqual(undefined, undefined)); - t.ok(deepEqual(null, null)); - t.ok(!deepEqual(undefined, null)); - - t.end(); -}); - -test('deepLevels', function (t) { - var xs = [ 1, 2, [ 3, 4, [ 5, 6 ] ] ]; - t.ok(!deepEqual(xs, [])); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/error.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/error.js deleted file mode 100644 index 447c725..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/error.js +++ /dev/null @@ -1,11 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('traverse an Error', function (t) { - var obj = new Error("test"); - var results = traverse(obj).map(function (node) {}); - t.same(results, { message: 'test' }); - - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js deleted file mode 100644 index 94a50c6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js +++ /dev/null @@ -1,15 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('has', function (t) { - var obj = { a : 2, b : [ 4, 5, { c : 6 } ] }; - - t.equal(traverse(obj).has([ 'b', 2, 'c' ]), true) - t.equal(traverse(obj).has([ 'b', 2, 'c', 0 ]), false) - t.equal(traverse(obj).has([ 'b', 2, 'd' ]), false) - t.equal(traverse(obj).has([]), true) - t.equal(traverse(obj).has([ 'a' ]), true) - t.equal(traverse(obj).has([ 'a', 2 ]), false) - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js deleted file mode 100644 index 112f477..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js +++ /dev/null @@ -1,17 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); -var EventEmitter = require('events').EventEmitter; - -test('check instanceof on node elems', function (t) { - var counts = { emitter : 0 }; - - traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }]) - .forEach(function (node) { - if (node instanceof EventEmitter) counts.emitter ++; - }) - ; - - t.equal(counts.emitter, 2); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js deleted file mode 100644 index f454c27..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js +++ /dev/null @@ -1,43 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('interface map', function (t) { - var obj = { a : [ 5,6,7 ], b : { c : [8] } }; - - t.same( - traverse.paths(obj) - .sort() - .map(function (path) { return path.join('/') }) - .slice(1) - .join(' ') - , - 'a a/0 a/1 a/2 b b/c b/c/0' - ); - - t.same( - traverse.nodes(obj), - [ - { a: [ 5, 6, 7 ], b: { c: [ 8 ] } }, - [ 5, 6, 7 ], 5, 6, 7, - { c: [ 8 ] }, [ 8 ], 8 - ] - ); - - t.same( - traverse.map(obj, function (node) { - if (typeof node == 'number') { - return node + 1000; - } - else if (Array.isArray(node)) { - return node.join(' '); - } - }), - { a: '5 6 7', b: { c: '8' } } - ); - - var nodes = 0; - traverse.forEach(obj, function (node) { nodes ++ }); - t.same(nodes, 8); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js deleted file mode 100644 index 46d55e6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js +++ /dev/null @@ -1,49 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('json test', function (t) { - var id = 54; - var callbacks = {}; - var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - - var scrubbed = traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } - }); - - t.equal( - scrubbed.moo, '[Function]', - 'obj.moo replaced with "[Function]"' - ); - - t.equal( - scrubbed.foo[3], '[Function]', - 'obj.foo[3] replaced with "[Function]"' - ); - - t.same(scrubbed, { - moo : '[Function]', - foo : [ 2, 3, 4, "[Function]" ] - }, 'Full JSON string matches'); - - t.same( - typeof obj.moo, 'function', - 'Original obj.moo still a function' - ); - - t.same( - typeof obj.foo[3], 'function', - 'Original obj.foo[3] still a function' - ); - - t.same(callbacks, { - 54: { id: 54, f : obj.moo, path: [ 'moo' ] }, - 55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] }, - }, 'Check the generated callbacks list'); - - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js deleted file mode 100644 index 9661140..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js +++ /dev/null @@ -1,31 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('sort test', function (t) { - var acc = []; - traverse({ - a: 30, - b: 22, - id: 9 - }).forEach(function (node) { - if ((! Array.isArray(node)) && typeof node === 'object') { - this.before(function(node) { - this.keys = Object.keys(node); - this.keys.sort(function(a, b) { - a = [a === "id" ? 0 : 1, a]; - b = [b === "id" ? 0 : 1, b]; - return a < b ? -1 : a > b ? 1 : 0; - }); - }); - } - if (this.isLeaf) acc.push(node); - }); - - t.equal( - acc.join(' '), - '9 30 22', - 'Traversal in a custom order' - ); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js deleted file mode 100644 index c04ad5f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js +++ /dev/null @@ -1,22 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('leaves test', function (t) { - var acc = []; - traverse({ - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - t.equal( - acc.join(' '), - '1 2 3 4 5 6 7 8 9', - 'Traversal in the right(?) order' - ); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js deleted file mode 100644 index c75b04c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js +++ /dev/null @@ -1,96 +0,0 @@ -var traverse = require('../../'); - -module.exports = function (a, b) { - if (arguments.length !== 2) { - throw new Error( - 'deepEqual requires exactly two objects to compare against' - ); - } - - var equal = true; - var node = b; - - traverse(a).forEach(function (y) { - var notEqual = (function () { - equal = false; - //this.stop(); - return undefined; - }).bind(this); - - //if (node === undefined || node === null) return notEqual(); - - if (!this.isRoot) { - /* - if (!Object.hasOwnProperty.call(node, this.key)) { - return notEqual(); - } - */ - if (typeof node !== 'object') return notEqual(); - node = node[this.key]; - } - - var x = node; - - this.post(function () { - node = x; - }); - - var toS = function (o) { - return Object.prototype.toString.call(o); - }; - - if (this.circular) { - if (traverse(b).get(this.circular.path) !== x) notEqual(); - } - else if (typeof x !== typeof y) { - notEqual(); - } - else if (x === null || y === null || x === undefined || y === undefined) { - if (x !== y) notEqual(); - } - else if (x.__proto__ !== y.__proto__) { - notEqual(); - } - else if (x === y) { - // nop - } - else if (typeof x === 'function') { - if (x instanceof RegExp) { - // both regexps on account of the __proto__ check - if (x.toString() != y.toString()) notEqual(); - } - else if (x !== y) notEqual(); - } - else if (typeof x === 'object') { - if (toS(y) === '[object Arguments]' - || toS(x) === '[object Arguments]') { - if (toS(x) !== toS(y)) { - notEqual(); - } - } - else if (toS(y) === '[object RegExp]' - || toS(x) === '[object RegExp]') { - if (!x || !y || x.toString() !== y.toString()) notEqual(); - } - else if (x instanceof Date || y instanceof Date) { - if (!(x instanceof Date) || !(y instanceof Date) - || x.getTime() !== y.getTime()) { - notEqual(); - } - } - else { - var kx = Object.keys(x); - var ky = Object.keys(y); - if (kx.length !== ky.length) return notEqual(); - for (var i = 0; i < kx.length; i++) { - var k = kx[i]; - if (!Object.hasOwnProperty.call(y, k)) { - notEqual(); - } - } - } - } - }); - - return equal; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js deleted file mode 100644 index 3ab90da..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js +++ /dev/null @@ -1,300 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -test('mutate', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).forEach(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - t.same(obj, res); - t.same(obj, { a : 1, b : 20, c : [ 3, 40 ] }); - t.end(); -}); - -test('mutateT', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse.forEach(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - t.same(obj, res); - t.same(obj, { a : 1, b : 20, c : [ 3, 40 ] }); - t.end(); -}); - -test('map', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).map(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - t.same(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - t.same(res, { a : 1, b : 20, c : [ 3, 40 ] }); - t.end(); -}); - -test('mapT', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse.map(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - t.same(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - t.same(res, { a : 1, b : 20, c : [ 3, 40 ] }); - t.end(); -}); - -test('clone', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).clone(); - t.same(obj, res); - t.ok(obj !== res); - obj.a ++; - t.same(res.a, 1); - obj.c.push(5); - t.same(res.c, [ 3, 4 ]); - t.end(); -}); - -test('cloneT', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse.clone(obj); - t.same(obj, res); - t.ok(obj !== res); - obj.a ++; - t.same(res.a, 1); - obj.c.push(5); - t.same(res.c, [ 3, 4 ]); - t.end(); -}); - -test('reduce', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; - }, []); - t.same(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - t.same(res, [ 1, 2, 3, 4 ]); - t.end(); -}); - -test('reduceInit', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).reduce(function (acc, x) { - if (this.isRoot) assert.fail('got root'); - return acc; - }); - t.same(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - t.same(res, obj); - t.end(); -}); - -test('remove', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - t.same(obj, { a : 1, c : [ 3 ] }); - t.end(); -}); - -exports.removeNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(); - }); - - t.same(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f']) - t.end(); -} - -exports.removeStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(true); - }); - - t.same(keys, [undefined, 'a', 'b', 'c', 'f']) - t.end(); -} - -test('removeMap', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - t.same(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - t.same(res, { a : 1, c : [ 3 ] }); - t.end(); -}); - -test('delete', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - t.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined ] } - )); - - t.ok(deepEqual( - obj, { a : 1, c : [ 3 ] } - )); - - t.ok(!deepEqual( - obj, { a : 1, c : [ 3, null ] } - )); - t.end(); -}); - -test('deleteNoStop', function (t) { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(); - }); - - t.same(keys, [undefined, 'a', 'b', 'c', 'd', 'e']) - t.end(); -}); - -test('deleteStop', function (t) { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(true); - }); - - t.same(keys, [undefined, 'a', 'b', 'c']) - t.end(); -}); - -test('deleteRedux', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - t.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined, 5 ] } - )); - - t.ok(deepEqual( - obj, { a : 1, c : [ 3 ,, 5 ] } - )); - - t.ok(!deepEqual( - obj, { a : 1, c : [ 3, null, 5 ] } - )); - - t.ok(!deepEqual( - obj, { a : 1, c : [ 3, 5 ] } - )); - - t.end(); -}); - -test('deleteMap', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - t.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4 ] } - )); - - var xs = [ 3, 4 ]; - delete xs[1]; - - t.ok(deepEqual( - res, { a : 1, c : xs } - )); - - t.ok(deepEqual( - res, { a : 1, c : [ 3, ] } - )); - - t.ok(deepEqual( - res, { a : 1, c : [ 3 ] } - )); - - t.end(); -}); - -test('deleteMapRedux', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - var res = traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - t.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4, 5 ] } - )); - - var xs = [ 3, 4, 5 ]; - delete xs[1]; - - t.ok(deepEqual( - res, { a : 1, c : xs } - )); - - t.ok(!deepEqual( - res, { a : 1, c : [ 3, 5 ] } - )); - - t.ok(deepEqual( - res, { a : 1, c : [ 3 ,, 5 ] } - )); - - t.end(); -}); - -test('objectToString', function (t) { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = traverse(obj).forEach(function (x) { - if (typeof x === 'object' && !this.isRoot) { - this.update(JSON.stringify(x)); - } - }); - t.same(obj, res); - t.same(obj, { a : 1, b : 2, c : "[3,4]" }); - t.end(); -}); - -test('stringToObject', function (t) { - var obj = { a : 1, b : 2, c : "[3,4]" }; - var res = traverse(obj).forEach(function (x) { - if (typeof x === 'string') { - this.update(JSON.parse(x)); - } - else if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - t.deepEqual(obj, res); - t.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js deleted file mode 100644 index 91566c8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js +++ /dev/null @@ -1,21 +0,0 @@ -var traverse = require('../'); -var test = require('tape'); - -test('negative update test', function (t) { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - var fixed = traverse.map(obj, function (x) { - if (x < 0) this.update(x + 128); - }); - - t.same(fixed, - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ], - 'Negative values += 128' - ); - - t.same(obj, - [ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ], - 'Original references not modified' - ); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js deleted file mode 100644 index 8bcf58a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js +++ /dev/null @@ -1,11 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('traverse an object with nested functions', function (t) { - t.plan(1); - - function Cons (x) { - t.equal(x, 10) - }; - traverse(new Cons(10)); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js deleted file mode 100644 index c59e557..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js +++ /dev/null @@ -1,37 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('siblings', function (t) { - var obj = { a : 1, b : 2, c : [ 4, 5, 6 ] }; - - var res = traverse(obj).reduce(function (acc, x) { - var p = '/' + this.path.join('/'); - if (this.parent) { - acc[p] = { - siblings : this.parent.keys, - key : this.key, - index : this.parent.keys.indexOf(this.key) - }; - } - else { - acc[p] = { - siblings : [], - key : this.key, - index : -1 - } - } - return acc; - }, {}); - - t.same(res, { - '/' : { siblings : [], key : undefined, index : -1 }, - '/a' : { siblings : [ 'a', 'b', 'c' ], key : 'a', index : 0 }, - '/b' : { siblings : [ 'a', 'b', 'c' ], key : 'b', index : 1 }, - '/c' : { siblings : [ 'a', 'b', 'c' ], key : 'c', index : 2 }, - '/c/0' : { siblings : [ '0', '1', '2' ], key : '0', index : 0 }, - '/c/1' : { siblings : [ '0', '1', '2' ], key : '1', index : 1 }, - '/c/2' : { siblings : [ '0', '1', '2' ], key : '2', index : 2 } - }); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js deleted file mode 100644 index 9ce15b0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js +++ /dev/null @@ -1,44 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('stop', function (t) { - var visits = 0; - traverse('abcdefghij'.split('')).forEach(function (node) { - if (typeof node === 'string') { - visits ++; - if (node === 'e') this.stop() - } - }); - - t.equal(visits, 5); - t.end(); -}); - -test('stopMap', function (t) { - var s = traverse('abcdefghij'.split('')).map(function (node) { - if (typeof node === 'string') { - if (node === 'e') this.stop() - return node.toUpperCase(); - } - }).join(''); - - t.equal(s, 'ABCDEfghij'); - t.end(); -}); - -test('stopReduce', function (t) { - var obj = { - a : [ 4, 5 ], - b : [ 6, [ 7, 8, 9 ] ] - }; - var xs = traverse(obj).reduce(function (acc, node) { - if (this.isLeaf) { - if (node === 7) this.stop(); - else acc.push(node) - } - return acc; - }, []); - - t.same(xs, [ 4, 5, 6 ]); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js deleted file mode 100644 index f1680d8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js +++ /dev/null @@ -1,36 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); - -test('stringify', function (t) { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - - var s = ''; - traverse(obj).forEach(function (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - s += '"' + key + '"' + ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } - }); - - t.equal(s, JSON.stringify(obj)); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js deleted file mode 100644 index 7682608..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js +++ /dev/null @@ -1,36 +0,0 @@ -var traverse = require('../'); -var test = require('tape'); - -test('subexpr', function (t) { - var obj = [ 'a', 4, 'b', 5, 'c', 6 ]; - var r = traverse(obj).map(function (x) { - if (typeof x === 'number') { - this.update([ x - 0.1, x, x + 0.1 ], true); - } - }); - - t.same(obj, [ 'a', 4, 'b', 5, 'c', 6 ]); - t.same(r, [ - 'a', [ 3.9, 4, 4.1 ], - 'b', [ 4.9, 5, 5.1 ], - 'c', [ 5.9, 6, 6.1 ], - ]); - t.end(); -}); - -test('block', function (t) { - var obj = [ [ 1 ], [ 2 ], [ 3 ] ]; - var r = traverse(obj).map(function (x) { - if (Array.isArray(x) && !this.isRoot) { - if (x[0] === 5) this.block() - else this.update([ [ x[0] + 1 ] ]) - } - }); - - t.same(r, [ - [ [ [ [ [ 5 ] ] ] ] ], - [ [ [ [ 5 ] ] ] ], - [ [ [ 5 ] ] ], - ]); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js deleted file mode 100644 index 1eb9e26..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js +++ /dev/null @@ -1,56 +0,0 @@ -var test = require('tape'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -test('super_deep', function (t) { - var util = require('util'); - var a0 = make(); - var a1 = make(); - t.ok(deepEqual(a0, a1)); - - a0.c.d.moo = true; - t.ok(!deepEqual(a0, a1)); - - a1.c.d.moo = true; - t.ok(deepEqual(a0, a1)); - - // TODO: this one - //a0.c.a = a1; - //t.ok(!deepEqual(a0, a1)); - t.end(); -}); - -function make () { - var a = { self : 'a' }; - var b = { self : 'b' }; - var c = { self : 'c' }; - var d = { self : 'd' }; - var e = { self : 'e' }; - - a.a = a; - a.b = b; - a.c = c; - - b.a = a; - b.b = b; - b.c = c; - - c.a = a; - c.b = b; - c.c = c; - c.d = d; - - d.a = a; - d.b = b; - d.c = c; - d.d = d; - d.e = e; - - e.a = a; - e.b = b; - e.c = c; - e.d = d; - e.e = e; - - return a; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js deleted file mode 100644 index 29968dd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js +++ /dev/null @@ -1,22 +0,0 @@ -var traverse = require('./'); -var test = require('testling'); - -test('leaves', function (t) { - var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }; - - var acc = []; - traverse(obj).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - t.deepEqual( - acc, [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], - 'traversal in the proper order' - ); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/package.json deleted file mode 100644 index a7d9ab1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "difflet", - "description": "colorful diffs for javascript objects", - "version": "0.2.6", - "repository": { - "type": "git", - "url": "git://github.com/substack/difflet.git" - }, - "main": "index.js", - "keywords": [ - "diff", - "object", - "compare" - ], - "directories": { - "lib": ".", - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": { - "traverse": "0.6.x", - "charm": "0.1.x", - "deep-is": "0.1.x" - }, - "devDependencies": { - "tap": "0.1.x", - "ent": "0.0.x" - }, - "engines": { - "node": ">=0.4.0" - }, - "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "readme": "difflet\n=======\n\nCreate colorful diffs for javascript objects.\n\nexample\n=======\n\nstring.js\n---------\n\n``` js\nvar difflet = require('difflet');\n\nvar s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 });\nprocess.stdout.write(s);\n```\n\noutput:\n\n![colorful output](http://substack.net/images/screenshots/difflet_string.png)\n\ncolors.js\n---------\n\n``` js\nvar diff = require('difflet')({ indent : 2 });\n\nvar prev = {\n yy : 6,\n zz : 5,\n a : [1,2,3],\n fn : 'beep',\n c : { x : 7, z : 3 }\n};\n\nvar next = {\n a : [ 1, 2, \"z\", /beep/, new Buffer(3) ],\n fn : function qqq () {},\n b : [5,6,7],\n c : { x : 8, y : 5 }\n};\n\ndiff(prev, next).pipe(process.stdout);\n```\n\noutput:\n\n![colorful output](http://substack.net/images/screenshots/difflet_colors.png)\n\ngreen for inserts, blue for updates, red for deletes\n\nmethods\n=======\n\nvar difflet = require('difflet')\n\nvar diff = difflet(opts={})\n---------------------------\n\nCreate a difflet from optional options `opts`.\n\nWith `opts.start(type, stream)` and `opts.stop(type, stream)`,\nyou can write custom handlers for all the types of differences:\n`'inserted'`, `'updated'`, and `'deleted'`.\nBy default green is used for insertions, blue for updates, and red for\ndeletions.\n\nIf `opts.indent` is set, output will span multiple lines and `opts.indent`\nspaces will be used for leading whitespace.\n\nIf `opts.comma === 'first'` then commas will be placed at the start of lines.\n\nSetting `opts.comment` to `true` will turn on comments with the previous\ncontents like this:\n\n![object comments](http://substack.net/images/screenshots/difflet_object_comments.png)\n\ndiff(prev, next)\n----------------\n\nReturn a stream with the colorful changes between objects `prev` and `next`.\n\ndiff.compare(prev, next)\n------------------------\n\nReturn a string with the colorful changes between `prev` and `next`.\n\ndifflet.compare(prev, next)\n---------------------------\n\nReturn a string with the colorful changes between `prev` and `next` with the\ndefault options.\n\ninstall\n=======\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install difflet\n```\n\ntest\n====\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm test\n```\n\nlicense\n=======\n\nMIT/X11\n", - "readmeFilename": "README.markdown", - "bugs": { - "url": "https://github.com/substack/difflet/issues" - }, - "_id": "difflet@0.2.6", - "dist": { - "shasum": "ab23b31f5649b6faa8e3d2acbd334467365ca6fa", - "tarball": "http://registry.npmjs.org/difflet/-/difflet-0.2.6.tgz" - }, - "_from": "difflet@~0.2.0", - "_npmVersion": "1.3.0", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "ab23b31f5649b6faa8e3d2acbd334467365ca6fa", - "_resolved": "https://registry.npmjs.org/difflet/-/difflet-0.2.6.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/diffing-NaN.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/diffing-NaN.js deleted file mode 100644 index d29e6e1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/diffing-NaN.js +++ /dev/null @@ -1,17 +0,0 @@ -var difflet = require('../'); -var diff = difflet(); -var test = require('tap').test; - -test('diffing NaN against NaN', function (t) { - t.plan(1); - var d = diff.compare(NaN, NaN); - - t.equal(d, 'NaN'); -}); - -test('diffing { o: NaN } against { o: NaN }', function (t) { - t.plan(1); - var d = diff.compare({ o: NaN }, { o: NaN }); - - t.equal(d, '{"o":NaN}'); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/html.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/html.js deleted file mode 100644 index 26d2ed4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/difflet/test/html.js +++ /dev/null @@ -1,80 +0,0 @@ -var difflet = require('../'); -var test = require('tap').test; -var ent = require('ent'); - -var tags = { - inserted : 'g', - updated : 'b', - deleted : 'r', -}; - -test('html output', function (t) { - t.plan(1); - var diff = difflet({ - start : function (t, s) { - s.write('<' + tags[t] + '>'); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf, s) { - s.write(ent.encode(buf)); - } - }); - - var stream = diff( - { yy : 6, zz : 5, a : [1,2,3], fn : function qqq () {} }, - { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : function rrr () {}, - b : [5,6,7] - } - ); - - var data = '' - stream.on('data', function (buf) { data += buf }); - stream.on('end', function () { - t.equal(data, - '{"a":[1,2,3,[4],"z",' - + '/beep/,<Buffer 00 01 02>],' - + '"fn":[Function: rrr],' - + '"b":[5,6,7],"yy":6,' - + '"zz":5}' - ); - t.end(); - }); -}); - -test('compare html output', function (t) { - t.plan(1); - - var diff = difflet({ - start : function (t, s) { - s.write('<' + tags[t] + '>'); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf, s) { - s.write(ent.encode(buf)); - } - }); - - var data = diff.compare( - { yy : 6, zz : 5, a : [1,2,3], fn : function qqq () {} }, - { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : function rrr () {}, - b : [5,6,7] - } - ); - - t.equal(data, - '{"a":[1,2,3,[4],"z",' - + '/beep/,<Buffer 00 01 02>],' - + '"fn":[Function: rrr],' - + '"b":[5,6,7],"yy":6,' - + '"zz":5}' - ); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/LICENSE deleted file mode 100644 index 19129e3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/README.md deleted file mode 100644 index 258257e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/README.md +++ /dev/null @@ -1,369 +0,0 @@ -[![Build Status](https://travis-ci.org/isaacs/node-glob.svg?branch=master)](https://travis-ci.org/isaacs/node-glob/) [![Dependency Status](https://david-dm.org/isaacs/node-glob.svg)](https://david-dm.org/isaacs/node-glob) [![devDependency Status](https://david-dm.org/isaacs/node-glob/dev-status.svg)](https://david-dm.org/isaacs/node-glob#info=devDependencies) [![optionalDependency Status](https://david-dm.org/isaacs/node-glob/optional-status.svg)](https://david-dm.org/isaacs/node-glob#info=optionalDependencies) - -# Glob - -Match files using the patterns the shell uses, like stars and stuff. - -This is a glob implementation in JavaScript. It uses the `minimatch` -library to do its matching. - -![](oh-my-glob.gif) - -## Usage - -```javascript -var glob = require("glob") - -// options is optional -glob("**/*.js", options, function (er, files) { - // files is an array of filenames. - // If the `nonull` option is set, and nothing - // was found, then files is ["**/*.js"] - // er is an error object or null. -}) -``` - -## Glob Primer - -"Globs" are the patterns you type when you do stuff like `ls *.js` on -the command line, or put `build/*` in a `.gitignore` file. - -Before parsing the path part patterns, braced sections are expanded -into a set. Braced sections start with `{` and end with `}`, with any -number of comma-delimited sections within. Braced sections may contain -slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`. - -The following characters have special magic meaning when used in a -path portion: - -* `*` Matches 0 or more characters in a single path portion -* `?` Matches 1 character -* `[...]` Matches a range of characters, similar to a RegExp range. - If the first character of the range is `!` or `^` then it matches - any character not in the range. -* `!(pattern|pattern|pattern)` Matches anything that does not match - any of the patterns provided. -* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the - patterns provided. -* `+(pattern|pattern|pattern)` Matches one or more occurrences of the - patterns provided. -* `*(a|b|c)` Matches zero or more occurrences of the patterns provided -* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns - provided -* `**` If a "globstar" is alone in a path portion, then it matches - zero or more directories and subdirectories searching for matches. - It does not crawl symlinked directories. - -### Dots - -If a file or directory path portion has a `.` as the first character, -then it will not match any glob pattern unless that pattern's -corresponding path part also has a `.` as its first character. - -For example, the pattern `a/.*/c` would match the file at `a/.b/c`. -However the pattern `a/*/c` would not, because `*` does not start with -a dot character. - -You can make glob treat dots as normal characters by setting -`dot:true` in the options. - -### Basename Matching - -If you set `matchBase:true` in the options, and the pattern has no -slashes in it, then it will seek for any file anywhere in the tree -with a matching basename. For example, `*.js` would match -`test/simple/basic.js`. - -### Negation - -The intent for negation would be for a pattern starting with `!` to -match everything that *doesn't* match the supplied pattern. However, -the implementation is weird, and for the time being, this should be -avoided. The behavior will change or be deprecated in version 5. - -### Empty Sets - -If no matching files are found, then an empty array is returned. This -differs from the shell, where the pattern itself is returned. For -example: - - $ echo a*s*d*f - a*s*d*f - -To get the bash-style behavior, set the `nonull:true` in the options. - -### See Also: - -* `man sh` -* `man bash` (Search for "Pattern Matching") -* `man 3 fnmatch` -* `man 5 gitignore` -* [minimatch documentation](https://github.com/isaacs/minimatch) - -## glob.hasMagic(pattern, [options]) - -Returns `true` if there are any special characters in the pattern, and -`false` otherwise. - -Note that the options affect the results. If `noext:true` is set in -the options object, then `+(a|b)` will not be considered a magic -pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}` -then that is considered magical, unless `nobrace:true` is set in the -options. - -## glob(pattern, [options], cb) - -* `pattern` {String} Pattern to be matched -* `options` {Object} -* `cb` {Function} - * `err` {Error | null} - * `matches` {Array} filenames found matching the pattern - -Perform an asynchronous glob search. - -## glob.sync(pattern, [options]) - -* `pattern` {String} Pattern to be matched -* `options` {Object} -* return: {Array} filenames found matching the pattern - -Perform a synchronous glob search. - -## Class: glob.Glob - -Create a Glob object by instantiating the `glob.Glob` class. - -```javascript -var Glob = require("glob").Glob -var mg = new Glob(pattern, options, cb) -``` - -It's an EventEmitter, and starts walking the filesystem to find matches -immediately. - -### new glob.Glob(pattern, [options], [cb]) - -* `pattern` {String} pattern to search for -* `options` {Object} -* `cb` {Function} Called when an error occurs, or matches are found - * `err` {Error | null} - * `matches` {Array} filenames found matching the pattern - -Note that if the `sync` flag is set in the options, then matches will -be immediately available on the `g.found` member. - -### Properties - -* `minimatch` The minimatch object that the glob uses. -* `options` The options object passed in. -* `aborted` Boolean which is set to true when calling `abort()`. There - is no way at this time to continue a glob search after aborting, but - you can re-use the statCache to avoid having to duplicate syscalls. -* `statCache` Collection of all the stat results the glob search - performed. -* `cache` Convenience object. Each field has the following possible - values: - * `false` - Path does not exist - * `true` - Path exists - * `'DIR'` - Path exists, and is not a directory - * `'FILE'` - Path exists, and is a directory - * `[file, entries, ...]` - Path exists, is a directory, and the - array value is the results of `fs.readdir` -* `statCache` Cache of `fs.stat` results, to prevent statting the same - path multiple times. -* `symlinks` A record of which paths are symbolic links, which is - relevant in resolving `**` patterns. -* `realpathCache` An optional object which is passed to `fs.realpath` - to minimize unnecessary syscalls. It is stored on the instantiated - Glob object, and may be re-used. - -### Events - -* `end` When the matching is finished, this is emitted with all the - matches found. If the `nonull` option is set, and no match was found, - then the `matches` list contains the original pattern. The matches - are sorted, unless the `nosort` flag is set. -* `match` Every time a match is found, this is emitted with the matched. -* `error` Emitted when an unexpected error is encountered, or whenever - any fs error occurs if `options.strict` is set. -* `abort` When `abort()` is called, this event is raised. - -### Methods - -* `pause` Temporarily stop the search -* `resume` Resume the search -* `abort` Stop the search forever - -### Options - -All the options that can be passed to Minimatch can also be passed to -Glob to change pattern matching behavior. Also, some have been added, -or have glob-specific ramifications. - -All options are false by default, unless otherwise noted. - -All options are added to the Glob object, as well. - -If you are running many `glob` operations, you can pass a Glob object -as the `options` argument to a subsequent operation to shortcut some -`stat` and `readdir` calls. At the very least, you may pass in shared -`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that -parallel glob operations will be sped up by sharing information about -the filesystem. - -* `cwd` The current working directory in which to search. Defaults - to `process.cwd()`. -* `root` The place where patterns starting with `/` will be mounted - onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix - systems, and `C:\` or some such on Windows.) -* `dot` Include `.dot` files in normal matches and `globstar` matches. - Note that an explicit dot in a portion of the pattern will always - match dot files. -* `nomount` By default, a pattern starting with a forward-slash will be - "mounted" onto the root setting, so that a valid filesystem path is - returned. Set this flag to disable that behavior. -* `mark` Add a `/` character to directory matches. Note that this - requires additional stat calls. -* `nosort` Don't sort the results. -* `stat` Set to true to stat *all* results. This reduces performance - somewhat, and is completely unnecessary, unless `readdir` is presumed - to be an untrustworthy indicator of file existence. -* `silent` When an unusual error is encountered when attempting to - read a directory, a warning will be printed to stderr. Set the - `silent` option to true to suppress these warnings. -* `strict` When an unusual error is encountered when attempting to - read a directory, the process will just continue on in search of - other matches. Set the `strict` option to raise an error in these - cases. -* `cache` See `cache` property above. Pass in a previously generated - cache object to save some fs calls. -* `statCache` A cache of results of filesystem information, to prevent - unnecessary stat calls. While it should not normally be necessary - to set this, you may pass the statCache from one glob() call to the - options object of another, if you know that the filesystem will not - change between calls. (See "Race Conditions" below.) -* `symlinks` A cache of known symbolic links. You may pass in a - previously generated `symlinks` object to save `lstat` calls when - resolving `**` matches. -* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead. -* `nounique` In some cases, brace-expanded patterns can result in the - same file showing up multiple times in the result set. By default, - this implementation prevents duplicates in the result set. Set this - flag to disable that behavior. -* `nonull` Set to never return an empty set, instead returning a set - containing the pattern itself. This is the default in glob(3). -* `debug` Set to enable debug logging in minimatch and glob. -* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets. -* `noglobstar` Do not match `**` against multiple filenames. (Ie, - treat it as a normal `*` instead.) -* `noext` Do not match `+(a|b)` "extglob" patterns. -* `nocase` Perform a case-insensitive match. Note: on - case-insensitive filesystems, non-magic patterns will match by - default, since `stat` and `readdir` will not raise errors. -* `matchBase` Perform a basename-only match if the pattern does not - contain any slash characters. That is, `*.js` would be treated as - equivalent to `**/*.js`, matching all js files in all directories. -* `nonegate` Suppress `negate` behavior. (See below.) -* `nocomment` Suppress `comment` behavior. (See below.) -* `nonull` Return the pattern when no matches are found. -* `nodir` Do not match directories, only files. (Note: to match - *only* directories, simply put a `/` at the end of the pattern.) -* `ignore` Add a pattern or an array of patterns to exclude matches. -* `follow` Follow symlinked directories when expanding `**` patterns. - Note that this can result in a lot of duplicate references in the - presence of cyclic links. -* `realpath` Set to true to call `fs.realpath` on all of the results. - In the case of a symlink that cannot be resolved, the full absolute - path to the matched entry is returned (though it will usually be a - broken symlink) - -## Comparisons to other fnmatch/glob implementations - -While strict compliance with the existing standards is a worthwhile -goal, some discrepancies exist between node-glob and other -implementations, and are intentional. - -If the pattern starts with a `!` character, then it is negated. Set the -`nonegate` flag to suppress this behavior, and treat leading `!` -characters normally. This is perhaps relevant if you wish to start the -pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` -characters at the start of a pattern will negate the pattern multiple -times. - -If a pattern starts with `#`, then it is treated as a comment, and -will not match anything. Use `\#` to match a literal `#` at the -start of a line, or set the `nocomment` flag to suppress this behavior. - -The double-star character `**` is supported by default, unless the -`noglobstar` flag is set. This is supported in the manner of bsdglob -and bash 4.3, where `**` only has special significance if it is the only -thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but -`a/**b` will not. - -Note that symlinked directories are not crawled as part of a `**`, -though their contents may match against subsequent portions of the -pattern. This prevents infinite loops and duplicates and the like. - -If an escaped pattern has no matches, and the `nonull` flag is set, -then glob returns the pattern as-provided, rather than -interpreting the character escapes. For example, -`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than -`"*a?"`. This is akin to setting the `nullglob` option in bash, except -that it does not resolve escaped pattern characters. - -If brace expansion is not disabled, then it is performed before any -other interpretation of the glob pattern. Thus, a pattern like -`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded -**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are -checked for validity. Since those two are valid, matching proceeds. - -## Windows - -**Please only use forward-slashes in glob expressions.** - -Though windows uses either `/` or `\` as its path separator, only `/` -characters are used by this glob implementation. You must use -forward-slashes **only** in glob expressions. Back-slashes will always -be interpreted as escape characters, not path separators. - -Results from absolute patterns such as `/foo/*` are mounted onto the -root setting using `path.join`. On windows, this will by default result -in `/foo/*` matching `C:\foo\bar.txt`. - -## Race Conditions - -Glob searching, by its very nature, is susceptible to race conditions, -since it relies on directory walking and such. - -As a result, it is possible that a file that exists when glob looks for -it may have been deleted or modified by the time it returns the result. - -As part of its internal implementation, this program caches all stat -and readdir calls that it makes, in order to cut down on system -overhead. However, this also makes it even more susceptible to races, -especially if the cache or statCache objects are reused between glob -calls. - -Users are thus advised not to use a glob result as a guarantee of -filesystem state in the face of rapid changes. For the vast majority -of operations, this is never a problem. - -## Contributing - -Any change to behavior (including bugfixes) must come with a test. - -Patches that fail tests or reduce performance will be rejected. - -``` -# to run tests -npm test - -# to re-generate test fixtures -npm run test-regen - -# to benchmark against bash/zsh -npm run bench - -# to profile javascript -npm run prof -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/common.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/common.js deleted file mode 100644 index cd7c824..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/common.js +++ /dev/null @@ -1,237 +0,0 @@ -exports.alphasort = alphasort -exports.alphasorti = alphasorti -exports.isAbsolute = process.platform === "win32" ? absWin : absUnix -exports.setopts = setopts -exports.ownProp = ownProp -exports.makeAbs = makeAbs -exports.finish = finish -exports.mark = mark -exports.isIgnored = isIgnored -exports.childrenIgnored = childrenIgnored - -function ownProp (obj, field) { - return Object.prototype.hasOwnProperty.call(obj, field) -} - -var path = require("path") -var minimatch = require("minimatch") -var Minimatch = minimatch.Minimatch - -function absWin (p) { - if (absUnix(p)) return true - // pull off the device/UNC bit from a windows path. - // from node's lib/path.js - var splitDeviceRe = - /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/ - var result = splitDeviceRe.exec(p) - var device = result[1] || '' - var isUnc = device && device.charAt(1) !== ':' - var isAbsolute = !!result[2] || isUnc // UNC paths are always absolute - - return isAbsolute -} - -function absUnix (p) { - return p.charAt(0) === "/" || p === "" -} - -function alphasorti (a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()) -} - -function alphasort (a, b) { - return a.localeCompare(b) -} - -function setupIgnores (self, options) { - self.ignore = options.ignore || [] - - if (!Array.isArray(self.ignore)) - self.ignore = [self.ignore] - - if (self.ignore.length) { - self.ignore = self.ignore.map(ignoreMap) - } -} - -function ignoreMap (pattern) { - var gmatcher = null - if (pattern.slice(-3) === '/**') { - var gpattern = pattern.replace(/(\/\*\*)+$/, '') - gmatcher = new Minimatch(gpattern, { nonegate: true }) - } - - return { - matcher: new Minimatch(pattern, { nonegate: true }), - gmatcher: gmatcher - } -} - -function setopts (self, pattern, options) { - if (!options) - options = {} - - // base-matching: just use globstar for that. - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar") - } - pattern = "**/" + pattern - } - - self.pattern = pattern - self.strict = options.strict !== false - self.realpath = !!options.realpath - self.realpathCache = options.realpathCache || Object.create(null) - self.follow = !!options.follow - self.dot = !!options.dot - self.mark = !!options.mark - self.nodir = !!options.nodir - if (self.nodir) - self.mark = true - self.sync = !!options.sync - self.nounique = !!options.nounique - self.nonull = !!options.nonull - self.nosort = !!options.nosort - self.nocase = !!options.nocase - self.stat = !!options.stat - self.noprocess = !!options.noprocess - - self.maxLength = options.maxLength || Infinity - self.cache = options.cache || Object.create(null) - self.statCache = options.statCache || Object.create(null) - self.symlinks = options.symlinks || Object.create(null) - - setupIgnores(self, options) - - self.changedCwd = false - var cwd = process.cwd() - if (!ownProp(options, "cwd")) - self.cwd = cwd - else { - self.cwd = options.cwd - self.changedCwd = path.resolve(options.cwd) !== cwd - } - - self.root = options.root || path.resolve(self.cwd, "/") - self.root = path.resolve(self.root) - if (process.platform === "win32") - self.root = self.root.replace(/\\/g, "/") - - self.nomount = !!options.nomount - - self.minimatch = new Minimatch(pattern, options) - self.options = self.minimatch.options -} - -function finish (self) { - var nou = self.nounique - var all = nou ? [] : Object.create(null) - - for (var i = 0, l = self.matches.length; i < l; i ++) { - var matches = self.matches[i] - if (!matches || Object.keys(matches).length === 0) { - if (self.nonull) { - // do like the shell, and spit out the literal glob - var literal = self.minimatch.globSet[i] - if (nou) - all.push(literal) - else - all[literal] = true - } - } else { - // had matches - var m = Object.keys(matches) - if (nou) - all.push.apply(all, m) - else - m.forEach(function (m) { - all[m] = true - }) - } - } - - if (!nou) - all = Object.keys(all) - - if (!self.nosort) - all = all.sort(self.nocase ? alphasorti : alphasort) - - // at *some* point we statted all of these - if (self.mark) { - for (var i = 0; i < all.length; i++) { - all[i] = self._mark(all[i]) - } - if (self.nodir) { - all = all.filter(function (e) { - return !(/\/$/.test(e)) - }) - } - } - - if (self.ignore.length) - all = all.filter(function(m) { - return !isIgnored(self, m) - }) - - self.found = all -} - -function mark (self, p) { - var abs = makeAbs(self, p) - var c = self.cache[abs] - var m = p - if (c) { - var isDir = c === 'DIR' || Array.isArray(c) - var slash = p.slice(-1) === '/' - - if (isDir && !slash) - m += '/' - else if (!isDir && slash) - m = m.slice(0, -1) - - if (m !== p) { - var mabs = makeAbs(self, m) - self.statCache[mabs] = self.statCache[abs] - self.cache[mabs] = self.cache[abs] - } - } - - return m -} - -// lotta situps... -function makeAbs (self, f) { - var abs = f - if (f.charAt(0) === '/') { - abs = path.join(self.root, f) - } else if (exports.isAbsolute(f)) { - abs = f - } else if (self.changedCwd) { - abs = path.resolve(self.cwd, f) - } else if (self.realpath) { - abs = path.resolve(f) - } - return abs -} - - -// Return true, if pattern ends with globstar '**', for the accompanying parent directory. -// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents -function isIgnored (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) - }) -} - -function childrenIgnored (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return !!(item.gmatcher && item.gmatcher.match(path)) - }) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/glob.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/glob.js deleted file mode 100644 index eac0693..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/glob.js +++ /dev/null @@ -1,740 +0,0 @@ -// Approach: -// -// 1. Get the minimatch set -// 2. For each pattern in the set, PROCESS(pattern, false) -// 3. Store matches per-set, then uniq them -// -// PROCESS(pattern, inGlobStar) -// Get the first [n] items from pattern that are all strings -// Join these together. This is PREFIX. -// If there is no more remaining, then stat(PREFIX) and -// add to matches if it succeeds. END. -// -// If inGlobStar and PREFIX is symlink and points to dir -// set ENTRIES = [] -// else readdir(PREFIX) as ENTRIES -// If fail, END -// -// with ENTRIES -// If pattern[n] is GLOBSTAR -// // handle the case where the globstar match is empty -// // by pruning it out, and testing the resulting pattern -// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) -// // handle other cases. -// for ENTRY in ENTRIES (not dotfiles) -// // attach globstar + tail onto the entry -// // Mark that this entry is a globstar match -// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) -// -// else // not globstar -// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) -// Test ENTRY against pattern[n] -// If fails, continue -// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) -// -// Caveat: -// Cache all stats and readdirs results to minimize syscall. Since all -// we ever care about is existence and directory-ness, we can just keep -// `true` for files, and [children,...] for directories, or `false` for -// things that don't exist. - -module.exports = glob - -var fs = require('fs') -var minimatch = require('minimatch') -var Minimatch = minimatch.Minimatch -var inherits = require('inherits') -var EE = require('events').EventEmitter -var path = require('path') -var assert = require('assert') -var globSync = require('./sync.js') -var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti -var isAbsolute = common.isAbsolute -var setopts = common.setopts -var ownProp = common.ownProp -var inflight = require('inflight') -var util = require('util') -var childrenIgnored = common.childrenIgnored - -var once = require('once') - -function glob (pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {} - if (!options) options = {} - - if (options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return globSync(pattern, options) - } - - return new Glob(pattern, options, cb) -} - -glob.sync = globSync -var GlobSync = glob.GlobSync = globSync.GlobSync - -// old api surface -glob.glob = glob - -glob.hasMagic = function (pattern, options_) { - var options = util._extend({}, options_) - options.noprocess = true - - var g = new Glob(pattern, options) - var set = g.minimatch.set - if (set.length > 1) - return true - - for (var j = 0; j < set[0].length; j++) { - if (typeof set[0][j] !== 'string') - return true - } - - return false -} - -glob.Glob = Glob -inherits(Glob, EE) -function Glob (pattern, options, cb) { - if (typeof options === 'function') { - cb = options - options = null - } - - if (options && options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return new GlobSync(pattern, options) - } - - if (!(this instanceof Glob)) - return new Glob(pattern, options, cb) - - setopts(this, pattern, options) - this._didRealPath = false - - // process each pattern in the minimatch set - var n = this.minimatch.set.length - - // The matches are stored as {: true,...} so that - // duplicates are automagically pruned. - // Later, we do an Object.keys() on these. - // Keep them as a list so we can fill in when nonull is set. - this.matches = new Array(n) - - if (typeof cb === 'function') { - cb = once(cb) - this.on('error', cb) - this.on('end', function (matches) { - cb(null, matches) - }) - } - - var self = this - var n = this.minimatch.set.length - this._processing = 0 - this.matches = new Array(n) - - this._emitQueue = [] - this._processQueue = [] - this.paused = false - - if (this.noprocess) - return this - - if (n === 0) - return done() - - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false, done) - } - - function done () { - --self._processing - if (self._processing <= 0) - self._finish() - } -} - -Glob.prototype._finish = function () { - assert(this instanceof Glob) - if (this.aborted) - return - - if (this.realpath && !this._didRealpath) - return this._realpath() - - common.finish(this) - this.emit('end', this.found) -} - -Glob.prototype._realpath = function () { - if (this._didRealpath) - return - - this._didRealpath = true - - var n = this.matches.length - if (n === 0) - return this._finish() - - var self = this - for (var i = 0; i < this.matches.length; i++) - this._realpathSet(i, next) - - function next () { - if (--n === 0) - self._finish() - } -} - -Glob.prototype._realpathSet = function (index, cb) { - var matchset = this.matches[index] - if (!matchset) - return cb() - - var found = Object.keys(matchset) - var self = this - var n = found.length - - if (n === 0) - return cb() - - var set = this.matches[index] = Object.create(null) - found.forEach(function (p, i) { - // If there's a problem with the stat, then it means that - // one or more of the links in the realpath couldn't be - // resolved. just return the abs value in that case. - p = self._makeAbs(p) - fs.realpath(p, self.realpathCache, function (er, real) { - if (!er) - set[real] = true - else if (er.syscall === 'stat') - set[p] = true - else - self.emit('error', er) // srsly wtf right here - - if (--n === 0) { - self.matches[index] = set - cb() - } - }) - }) -} - -Glob.prototype._mark = function (p) { - return common.mark(this, p) -} - -Glob.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) -} - -Glob.prototype.abort = function () { - this.aborted = true - this.emit('abort') -} - -Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true - this.emit('pause') - } -} - -Glob.prototype.resume = function () { - if (this.paused) { - this.emit('resume') - this.paused = false - if (this._emitQueue.length) { - var eq = this._emitQueue.slice(0) - this._emitQueue.length = 0 - for (var i = 0; i < eq.length; i ++) { - var e = eq[i] - this._emitMatch(e[0], e[1]) - } - } - if (this._processQueue.length) { - var pq = this._processQueue.slice(0) - this._processQueue.length = 0 - for (var i = 0; i < pq.length; i ++) { - var p = pq[i] - this._processing-- - this._process(p[0], p[1], p[2], p[3]) - } - } - } -} - -Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob) - assert(typeof cb === 'function') - - if (this.aborted) - return - - this._processing++ - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]) - return - } - - //console.error('PROCESS %d', this._processing, pattern) - - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. - - // see if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index, cb) - return - - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break - - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break - } - - var remain = pattern.slice(n) - - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix - - var abs = this._makeAbs(read) - - //if ignored, skip _processing - if (childrenIgnored(this, read)) - return cb() - - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) -} - -Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) -} - -Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - - // if the abs isn't a dir, then nothing can match! - if (!entries) - return cb() - - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' - - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) - } else { - m = e.match(pn) - } - if (m) - matchedEntries.push(e) - } - } - - //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) - - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return cb() - - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. - - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) - } - this._emitMatch(index, e) - } - // This was the last one, and no stats were needed - return cb() - } - - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - this._process([e].concat(remain), index, inGlobStar, cb) - } - cb() -} - -Glob.prototype._emitMatch = function (index, e) { - if (this.aborted) - return - - if (this.matches[index][e]) - return - - if (this.paused) { - this._emitQueue.push([index, e]) - return - } - - var abs = this._makeAbs(e) - - if (this.nodir) { - var c = this.cache[abs] - if (c === 'DIR' || Array.isArray(c)) - return - } - - if (this.mark) - e = this._mark(e) - - this.matches[index][e] = true - - var st = this.statCache[abs] - if (st) - this.emit('stat', e, st) - - this.emit('match', e) -} - -Glob.prototype._readdirInGlobStar = function (abs, cb) { - if (this.aborted) - return - - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false, cb) - - var lstatkey = 'lstat\0' + abs - var self = this - var lstatcb = inflight(lstatkey, lstatcb_) - - if (lstatcb) - fs.lstat(abs, lstatcb) - - function lstatcb_ (er, lstat) { - if (er) - return cb() - - var isSym = lstat.isSymbolicLink() - self.symlinks[abs] = isSym - - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && !lstat.isDirectory()) { - self.cache[abs] = 'FILE' - cb() - } else - self._readdir(abs, false, cb) - } -} - -Glob.prototype._readdir = function (abs, inGlobStar, cb) { - if (this.aborted) - return - - cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) - if (!cb) - return - - //console.error('RD %j %j', +inGlobStar, abs) - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs, cb) - - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return cb() - - if (Array.isArray(c)) - return cb(null, c) - } - - var self = this - fs.readdir(abs, readdirCb(this, abs, cb)) -} - -function readdirCb (self, abs, cb) { - return function (er, entries) { - if (er) - self._readdirError(abs, er, cb) - else - self._readdirEntries(abs, entries, cb) - } -} - -Glob.prototype._readdirEntries = function (abs, entries, cb) { - if (this.aborted) - return - - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } - - this.cache[abs] = entries - return cb(null, entries) -} - -Glob.prototype._readdirError = function (f, er, cb) { - if (this.aborted) - return - - // handle errors, and cache the information - switch (er.code) { - case 'ENOTDIR': // totally normal. means it *does* exist. - this.cache[this._makeAbs(f)] = 'FILE' - break - - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break - - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) return this.emit('error', er) - if (!this.silent) console.error('glob error', er) - break - } - return cb() -} - -Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) -} - - -Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - //console.error('pgs2', prefix, remain[0], entries) - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return cb() - - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) - - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false, cb) - - var isSym = this.symlinks[abs] - var len = entries.length - - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return cb() - - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue - - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true, cb) - - var below = gspref.concat(entries[i], remain) - this._process(below, index, true, cb) - } - - cb() -} - -Glob.prototype._processSimple = function (prefix, index, cb) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var self = this - this._stat(prefix, function (er, exists) { - self._processSimple2(prefix, index, er, exists, cb) - }) -} -Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - - //console.error('ps2', prefix, exists) - - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - // If it doesn't exist, then just mark the lack of results - if (!exists) - return cb() - - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' - } - } - - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') - - // Mark this as a match - this._emitMatch(index, prefix) - cb() -} - -// Returns either 'DIR', 'FILE', or false -Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' - - if (f.length > this.maxLength) - return cb() - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] - - if (Array.isArray(c)) - c = 'DIR' - - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return cb(null, c) - - if (needDir && c === 'FILE') - return cb() - - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - - var exists - var stat = this.statCache[abs] - if (stat !== undefined) { - if (stat === false) - return cb(null, stat) - else { - var type = stat.isDirectory() ? 'DIR' : 'FILE' - if (needDir && type === 'FILE') - return cb() - else - return cb(null, type, stat) - } - } - - var self = this - var statcb = inflight('stat\0' + abs, lstatcb_) - if (statcb) - fs.lstat(abs, statcb) - - function lstatcb_ (er, lstat) { - if (lstat && lstat.isSymbolicLink()) { - // If it's a symlink, then treat it as the target, unless - // the target does not exist, then treat it as a file. - return fs.stat(abs, function (er, stat) { - if (er) - self._stat2(f, abs, null, lstat, cb) - else - self._stat2(f, abs, er, stat, cb) - }) - } else { - self._stat2(f, abs, er, lstat, cb) - } - } -} - -Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er) { - this.statCache[abs] = false - return cb() - } - - var needDir = f.slice(-1) === '/' - this.statCache[abs] = stat - - if (abs.slice(-1) === '/' && !stat.isDirectory()) - return cb(null, false, stat) - - var c = stat.isDirectory() ? 'DIR' : 'FILE' - this.cache[abs] = this.cache[abs] || c - - if (needDir && c !== 'DIR') - return cb() - - return cb(null, c, stat) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/.eslintrc b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/.eslintrc deleted file mode 100644 index b7a1550..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/.eslintrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "env" : { - "node" : true - }, - "rules" : { - "semi": [2, "never"], - "strict": 0, - "quotes": [1, "single", "avoid-escape"], - "no-use-before-define": 0, - "curly": 0, - "no-underscore-dangle": 0, - "no-lonely-if": 1, - "no-unused-vars": [2, {"vars" : "all", "args" : "after-used"}], - "no-mixed-requires": 0, - "space-infix-ops": 0 - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/LICENSE deleted file mode 100644 index 05eeeb8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/README.md deleted file mode 100644 index 6dc8929..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# inflight - -Add callbacks to requests in flight to avoid async duplication - -## USAGE - -```javascript -var inflight = require('inflight') - -// some request that does some stuff -function req(key, callback) { - // key is any random string. like a url or filename or whatever. - // - // will return either a falsey value, indicating that the - // request for this key is already in flight, or a new callback - // which when called will call all callbacks passed to inflightk - // with the same key - callback = inflight(key, callback) - - // If we got a falsey value back, then there's already a req going - if (!callback) return - - // this is where you'd fetch the url or whatever - // callback is also once()-ified, so it can safely be assigned - // to multiple events etc. First call wins. - setTimeout(function() { - callback(null, key) - }, 100) -} - -// only assigns a single setTimeout -// when it dings, all cbs get called -req('foo', cb1) -req('foo', cb2) -req('foo', cb3) -req('foo', cb4) -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/inflight.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/inflight.js deleted file mode 100644 index 8bc96cb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/inflight.js +++ /dev/null @@ -1,44 +0,0 @@ -var wrappy = require('wrappy') -var reqs = Object.create(null) -var once = require('once') - -module.exports = wrappy(inflight) - -function inflight (key, cb) { - if (reqs[key]) { - reqs[key].push(cb) - return null - } else { - reqs[key] = [cb] - return makeres(key) - } -} - -function makeres (key) { - return once(function RES () { - var cbs = reqs[key] - var len = cbs.length - var args = slice(arguments) - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args) - } - if (cbs.length > len) { - // added more in the interim. - // de-zalgo, just in case, but don't call again. - cbs.splice(0, len) - process.nextTick(function () { - RES.apply(null, args) - }) - } else { - delete reqs[key] - } - }) -} - -function slice (args) { - var length = args.length - var array = [] - - for (var i = 0; i < length; i++) array[i] = args[i] - return array -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE deleted file mode 100644 index 19129e3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md deleted file mode 100644 index 98eab25..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# wrappy - -Callback wrapping utility - -## USAGE - -```javascript -var wrappy = require("wrappy") - -// var wrapper = wrappy(wrapperFunction) - -// make sure a cb is called only once -// See also: http://npm.im/once for this specific use case -var once = wrappy(function (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } -}) - -function printBoo () { - console.log('boo') -} -// has some rando property -printBoo.iAmBooPrinter = true - -var onlyPrintOnce = once(printBoo) - -onlyPrintOnce() // prints 'boo' -onlyPrintOnce() // does nothing - -// random property is retained! -assert.equal(onlyPrintOnce.iAmBooPrinter, true) -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json deleted file mode 100644 index 9165c6e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "wrappy", - "version": "1.0.1", - "description": "Callback wrapping utility", - "main": "wrappy.js", - "directories": { - "test": "test" - }, - "dependencies": {}, - "devDependencies": { - "tap": "^0.4.12" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/wrappy" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/wrappy/issues" - }, - "homepage": "https://github.com/npm/wrappy", - "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", - "_id": "wrappy@1.0.1", - "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "_from": "wrappy@1", - "_npmVersion": "2.0.0", - "_nodeVersion": "0.10.31", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - }, - "_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js deleted file mode 100644 index 5ed0fcd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +++ /dev/null @@ -1,51 +0,0 @@ -var test = require('tap').test -var wrappy = require('../wrappy.js') - -test('basic', function (t) { - function onceifier (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } - } - onceifier.iAmOnce = {} - var once = wrappy(onceifier) - t.equal(once.iAmOnce, onceifier.iAmOnce) - - var called = 0 - function boo () { - t.equal(called, 0) - called++ - } - // has some rando property - boo.iAmBoo = true - - var onlyPrintOnce = once(boo) - - onlyPrintOnce() // prints 'boo' - onlyPrintOnce() // does nothing - t.equal(called, 1) - - // random property is retained! - t.equal(onlyPrintOnce.iAmBoo, true) - - var logs = [] - var logwrap = wrappy(function (msg, cb) { - logs.push(msg + ' wrapping cb') - return function () { - logs.push(msg + ' before cb') - var ret = cb.apply(this, arguments) - logs.push(msg + ' after cb') - } - }) - - var c = logwrap('foo', function () { - t.same(logs, [ 'foo wrapping cb', 'foo before cb' ]) - }) - c() - t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ]) - - t.end() -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js deleted file mode 100644 index bb7e7d6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +++ /dev/null @@ -1,33 +0,0 @@ -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -module.exports = wrappy -function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') - - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k] - }) - - return wrapper - - function wrapper() { - var args = new Array(arguments.length) - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - var ret = fn.apply(this, args) - var cb = args[args.length-1] - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k] - }) - } - return ret - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/package.json deleted file mode 100644 index 38417ea..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "inflight", - "version": "1.0.4", - "description": "Add callbacks to requests in flight to avoid async duplication", - "main": "inflight.js", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - }, - "devDependencies": { - "tap": "^0.4.10" - }, - "scripts": { - "test": "tap test.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/inflight" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "bugs": { - "url": "https://github.com/isaacs/inflight/issues" - }, - "homepage": "https://github.com/isaacs/inflight", - "license": "ISC", - "gitHead": "c7b5531d572a867064d4a1da9e013e8910b7d1ba", - "_id": "inflight@1.0.4", - "_shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", - "_from": "inflight@^1.0.4", - "_npmVersion": "2.1.3", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "dist": { - "shasum": "6cbb4521ebd51ce0ec0a936bfd7657ef7e9b172a", - "tarball": "http://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/test.js deleted file mode 100644 index 2bb75b3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/inflight/test.js +++ /dev/null @@ -1,97 +0,0 @@ -var test = require('tap').test -var inf = require('./inflight.js') - - -function req (key, cb) { - cb = inf(key, cb) - if (cb) setTimeout(function () { - cb(key) - cb(key) - }) - return cb -} - -test('basic', function (t) { - var calleda = false - var a = req('key', function (k) { - t.notOk(calleda) - calleda = true - t.equal(k, 'key') - if (calledb) t.end() - }) - t.ok(a, 'first returned cb function') - - var calledb = false - var b = req('key', function (k) { - t.notOk(calledb) - calledb = true - t.equal(k, 'key') - if (calleda) t.end() - }) - - t.notOk(b, 'second should get falsey inflight response') -}) - -test('timing', function (t) { - var expect = [ - 'method one', - 'start one', - 'end one', - 'two', - 'tick', - 'three' - ] - var i = 0 - - function log (m) { - t.equal(m, expect[i], m + ' === ' + expect[i]) - ++i - if (i === expect.length) - t.end() - } - - function method (name, cb) { - log('method ' + name) - process.nextTick(cb) - } - - var one = inf('foo', function () { - log('start one') - var three = inf('foo', function () { - log('three') - }) - if (three) method('three', three) - log('end one') - }) - - method('one', one) - - var two = inf('foo', function () { - log('two') - }) - if (two) method('one', two) - - process.nextTick(log.bind(null, 'tick')) -}) - -test('parameters', function (t) { - t.plan(8) - - var a = inf('key', function (first, second, third) { - t.equal(first, 1) - t.equal(second, 2) - t.equal(third, 3) - }) - t.ok(a, 'first returned cb function') - - var b = inf('key', function (first, second, third) { - t.equal(first, 1) - t.equal(second, 2) - t.equal(third, 3) - }) - t.notOk(b, 'second should get falsey inflight response') - - setTimeout(function () { - a(1, 2, 3) - }) -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/README.md deleted file mode 100644 index d458bc2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/README.md +++ /dev/null @@ -1,216 +0,0 @@ -# minimatch - -A minimal matching utility. - -[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) - - -This is the matching library used internally by npm. - -It works by converting glob expressions into JavaScript `RegExp` -objects. - -## Usage - -```javascript -var minimatch = require("minimatch") - -minimatch("bar.foo", "*.foo") // true! -minimatch("bar.foo", "*.bar") // false! -minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! -``` - -## Features - -Supports these glob features: - -* Brace Expansion -* Extended glob matching -* "Globstar" `**` matching - -See: - -* `man sh` -* `man bash` -* `man 3 fnmatch` -* `man 5 gitignore` - -## Minimatch Class - -Create a minimatch object by instanting the `minimatch.Minimatch` class. - -```javascript -var Minimatch = require("minimatch").Minimatch -var mm = new Minimatch(pattern, options) -``` - -### Properties - -* `pattern` The original pattern the minimatch object represents. -* `options` The options supplied to the constructor. -* `set` A 2-dimensional array of regexp or string expressions. - Each row in the - array corresponds to a brace-expanded pattern. Each item in the row - corresponds to a single path-part. For example, the pattern - `{a,b/c}/d` would expand to a set of patterns like: - - [ [ a, d ] - , [ b, c, d ] ] - - If a portion of the pattern doesn't have any "magic" in it - (that is, it's something like `"foo"` rather than `fo*o?`), then it - will be left as a string rather than converted to a regular - expression. - -* `regexp` Created by the `makeRe` method. A single regular expression - expressing the entire pattern. This is useful in cases where you wish - to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. -* `negate` True if the pattern is negated. -* `comment` True if the pattern is a comment. -* `empty` True if the pattern is `""`. - -### Methods - -* `makeRe` Generate the `regexp` member if necessary, and return it. - Will return `false` if the pattern is invalid. -* `match(fname)` Return true if the filename matches the pattern, or - false otherwise. -* `matchOne(fileArray, patternArray, partial)` Take a `/`-split - filename, and match it against a single row in the `regExpSet`. This - method is mainly for internal use, but is exposed so that it can be - used by a glob-walker that needs to avoid excessive filesystem calls. - -All other methods are internal, and will be called as necessary. - -## Functions - -The top-level exported function has a `cache` property, which is an LRU -cache set to store 100 items. So, calling these methods repeatedly -with the same pattern and options will use the same Minimatch object, -saving the cost of parsing it multiple times. - -### minimatch(path, pattern, options) - -Main export. Tests a path against the pattern using the options. - -```javascript -var isJS = minimatch(file, "*.js", { matchBase: true }) -``` - -### minimatch.filter(pattern, options) - -Returns a function that tests its -supplied argument, suitable for use with `Array.filter`. Example: - -```javascript -var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) -``` - -### minimatch.match(list, pattern, options) - -Match against the list of -files, in the style of fnmatch or glob. If nothing is matched, and -options.nonull is set, then return a list containing the pattern itself. - -```javascript -var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) -``` - -### minimatch.makeRe(pattern, options) - -Make a regular expression object from the pattern. - -## Options - -All options are `false` by default. - -### debug - -Dump a ton of stuff to stderr. - -### nobrace - -Do not expand `{a,b}` and `{1..3}` brace sets. - -### noglobstar - -Disable `**` matching against multiple folder names. - -### dot - -Allow patterns to match filenames starting with a period, even if -the pattern does not explicitly have a period in that spot. - -Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` -is set. - -### noext - -Disable "extglob" style patterns like `+(a|b)`. - -### nocase - -Perform a case-insensitive match. - -### nonull - -When a match is not found by `minimatch.match`, return a list containing -the pattern itself if this option is set. When not set, an empty list -is returned if there are no matches. - -### matchBase - -If set, then patterns without slashes will be matched -against the basename of the path if it contains slashes. For example, -`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. - -### nocomment - -Suppress the behavior of treating `#` at the start of a pattern as a -comment. - -### nonegate - -Suppress the behavior of treating a leading `!` character as negation. - -### flipNegate - -Returns from negate expressions the same as if they were not negated. -(Ie, true on a hit, false on a miss.) - - -## Comparisons to other fnmatch/glob implementations - -While strict compliance with the existing standards is a worthwhile -goal, some discrepancies exist between minimatch and other -implementations, and are intentional. - -If the pattern starts with a `!` character, then it is negated. Set the -`nonegate` flag to suppress this behavior, and treat leading `!` -characters normally. This is perhaps relevant if you wish to start the -pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` -characters at the start of a pattern will negate the pattern multiple -times. - -If a pattern starts with `#`, then it is treated as a comment, and -will not match anything. Use `\#` to match a literal `#` at the -start of a line, or set the `nocomment` flag to suppress this behavior. - -The double-star character `**` is supported by default, unless the -`noglobstar` flag is set. This is supported in the manner of bsdglob -and bash 4.1, where `**` only has special significance if it is the only -thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but -`a/**b` will not. - -If an escaped pattern has no matches, and the `nonull` flag is set, -then minimatch.match returns the pattern as-provided, rather than -interpreting the character escapes. For example, -`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than -`"*a?"`. This is akin to setting the `nullglob` option in bash, except -that it does not resolve escaped pattern characters. - -If brace expansion is not disabled, then it is performed before any -other interpretation of the glob pattern. Thus, a pattern like -`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded -**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are -checked for validity. Since those two are valid, matching proceeds. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/browser.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/browser.js deleted file mode 100644 index cf58a3f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/browser.js +++ /dev/null @@ -1,1114 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o any number of characters - , star = qmark + "*?" - - // ** when dots are allowed. Anything goes, except .. and . - // not (^ or / followed by one or two dots followed by $ or /), - // followed by anything, any number of times. - , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" - - // not a ^ or / followed by a dot, - // followed by anything, any number of times. - , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" - - // characters that need to be escaped in RegExp. - , reSpecials = charSet("().*{}+?[]^$\\!") - -// "abc" -> { a:true, b:true, c:true } -function charSet (s) { - return s.split("").reduce(function (set, c) { - set[c] = true - return set - }, {}) -} - -// normalizes slashes. -var slashSplit = /\/+/ - -minimatch.filter = filter -function filter (pattern, options) { - options = options || {} - return function (p, i, list) { - return minimatch(p, pattern, options) - } -} - -function ext (a, b) { - a = a || {} - b = b || {} - var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) - Object.keys(a).forEach(function (k) { - t[k] = a[k] - }) - return t -} - -minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch - - var orig = minimatch - - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - } - - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - } - - return m -} - -Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch - return minimatch.defaults(def).Minimatch -} - - -function minimatch (p, pattern, options) { - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") - } - - if (!options) options = {} - - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { - return false - } - - // "" only matches "" - if (pattern.trim() === "") return p === "" - - return new Minimatch(pattern, options).match(p) -} - -function Minimatch (pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) - } - - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") - } - - if (!options) options = {} - pattern = pattern.trim() - - // windows support: need to use /, not \ - if (isWindows) - pattern = pattern.split("\\").join("/") - - this.options = options - this.set = [] - this.pattern = pattern - this.regexp = null - this.negate = false - this.comment = false - this.empty = false - - // make the set of regexps etc. - this.make() -} - -Minimatch.prototype.debug = function() {} - -Minimatch.prototype.make = make -function make () { - // don't do it more than once. - if (this._made) return - - var pattern = this.pattern - var options = this.options - - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { - this.comment = true - return - } - if (!pattern) { - this.empty = true - return - } - - // step 1: figure out negation, etc. - this.parseNegate() - - // step 2: expand braces - var set = this.globSet = this.braceExpand() - - if (options.debug) this.debug = console.error - - this.debug(this.pattern, set) - - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }) - - this.debug(this.pattern, set) - - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) - - this.debug(this.pattern, set) - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return -1 === s.indexOf(false) - }) - - this.debug(this.pattern, set) - - this.set = set -} - -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - , negate = false - , options = this.options - , negateOffset = 0 - - if (options.nonegate) return - - for ( var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === "!" - ; i ++) { - negate = !negate - negateOffset ++ - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} - -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} - -Minimatch.prototype.braceExpand = braceExpand - -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) - options = this.options - else - options = {} - } - - pattern = typeof pattern === "undefined" - ? this.pattern : pattern - - if (typeof pattern === "undefined") { - throw new Error("undefined pattern") - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) -} - -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - var options = this.options - - // shortcuts - if (!options.noglobstar && pattern === "**") return GLOBSTAR - if (pattern === "") return "" - - var re = "" - , hasMagic = !!options.nocase - , escaping = false - // ? => one single character - , patternListStack = [] - , plType - , stateChar - , inClass = false - , reClassStart = -1 - , classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - , patternStart = pattern.charAt(0) === "." ? "" // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" - : "(?!\\.)" - , self = this - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case "*": - re += star - hasMagic = true - break - case "?": - re += qmark - hasMagic = true - break - default: - re += "\\"+stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } - } - - for ( var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i ++ ) { - - this.debug("%s\t%s %s %j", pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += "\\" + c - escaping = false - continue - } - - SWITCH: switch (c) { - case "/": - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case "\\": - clearStateChar() - escaping = true - continue - - // the various stateChar values - // for the "extglob" stuff. - case "?": - case "*": - case "+": - case "@": - case "!": - this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c) - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === "!" && i === classStart + 1) c = "^" - re += c - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue - - case "(": - if (inClass) { - re += "(" - continue - } - - if (!stateChar) { - re += "\\(" - continue - } - - plType = stateChar - patternListStack.push({ type: plType - , start: i - 1 - , reStart: re.length }) - // negation is (?:(?!js)[^/]*) - re += stateChar === "!" ? "(?:(?!" : "(?:" - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue - - case ")": - if (inClass || !patternListStack.length) { - re += "\\)" - continue - } - - clearStateChar() - hasMagic = true - re += ")" - plType = patternListStack.pop().type - // negation is (?:(?!js)[^/]*) - // The others are (?:) - switch (plType) { - case "!": - re += "[^/]*?)" - break - case "?": - case "+": - case "*": re += plType - case "@": break // the default anyway - } - continue - - case "|": - if (inClass || !patternListStack.length || escaping) { - re += "\\|" - escaping = false - continue - } - - clearStateChar() - re += "|" - continue - - // these are mostly the same in regexp and glob - case "[": - // swallow any state-tracking char before the [ - clearStateChar() - - if (inClass) { - re += "\\" + c - continue - } - - inClass = true - classStart = i - reClassStart = re.length - re += c - continue - - case "]": - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += "\\" + c - escaping = false - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - new RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + "\\[" + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - - // finish up the class. - hasMagic = true - inClass = false - re += c - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar() - - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === "^" && inClass)) { - re += "\\" - } - - re += c - - } // switch - } // for - - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - var cs = pattern.substr(classStart + 1) - , sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + "\\[" + sp[0] - hasMagic = hasMagic || sp[1] - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - var pl - while (pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + 3) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = "\\" - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + "|" - }) - - this.debug("tail=%j\n %s", tail, tail) - var t = pl.type === "*" ? star - : pl.type === "?" ? qmark - : "\\" + pl.type - - hasMagic = true - re = re.slice(0, pl.reStart) - + t + "\\(" - + tail - } - - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += "\\\\" - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case ".": - case "[": - case "(": addPatternStart = true - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== "" && hasMagic) re = "(?=.)" + re - - if (addPatternStart) re = patternStart + re - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [ re, hasMagic ] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? "i" : "" - , regExp = new RegExp("^" + re + "$", flags) - - regExp._glob = pattern - regExp._src = re - - return regExp -} - -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} - -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set - - if (!set.length) return this.regexp = false - var options = this.options - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - , flags = options.nocase ? "i" : "" - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === "string") ? regExpEscape(p) - : p._src - }).join("\\\/") - }).join("|") - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = "^(?:" + re + ")$" - - // can match anything, as long as it's not this. - if (this.negate) re = "^(?!" + re + ").*$" - - try { - return this.regexp = new RegExp(re, flags) - } catch (ex) { - return this.regexp = false - } -} - -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} - -Minimatch.prototype.match = match -function match (f, partial) { - this.debug("match", f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === "" - - if (f === "/" && partial) return true - - var options = this.options - - // windows: need to use /, not \ - if (isWindows) - f = f.split("\\").join("/") - - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, "split", f) - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set - this.debug(this.pattern, "set", set) - - // Find the basename of the path by looking for the last non-empty segment - var filename; - for (var i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } - - for (var i = 0, l = set.length; i < l; i ++) { - var pattern = set[i], file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate -} - -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options - - this.debug("matchOne", - { "this": this - , file: file - , pattern: pattern }) - - this.debug("matchOne", file.length, pattern.length) - - for ( var fi = 0 - , pi = 0 - , fl = file.length - , pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi ++, pi ++ ) { - - this.debug("matchOne loop") - var p = pattern[pi] - , f = file[fi] - - this.debug(pattern, p, f) - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - , pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for ( ; fi < fl; fi ++) { - if (file[fi] === "." || file[fi] === ".." || - (!options.dot && file[fi].charAt(0) === ".")) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - WHILE: while (fr < fl) { - var swallowee = file[fr] - - this.debug('\nglobstar while', - file, fr, pattern, pr, swallowee) - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === "." || swallowee === ".." || - (!options.dot && swallowee.charAt(0) === ".")) { - this.debug("dot detected!", file, fr, pattern, pr) - break WHILE - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr ++ - } - } - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug("\n>>> no match, partial?", file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === "string") { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug("string match", p, f, hit) - } else { - hit = f.match(p) - this.debug("pattern match", p, f, hit) - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === "") - return emptyFileEnd - } - - // should be unreachable. - throw new Error("wtf?") -} - - -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, "$1") -} - - -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") -} - -},{"brace-expansion":2}],2:[function(require,module,exports){ -var concatMap = require('concat-map'); -var balanced = require('balanced-match'); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - var expansions = expand(escapeBraces(str)); - return expansions.filter(identity).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0]).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - expansions.push([pre, N[j], post[k]].join('')) - } - } - - return expansions; -} - - -},{"balanced-match":3,"concat-map":4}],3:[function(require,module,exports){ -module.exports = balanced; -function balanced(a, b, str) { - var bal = 0; - var m = {}; - var ended = false; - - for (var i = 0; i < str.length; i++) { - if (a == str.substr(i, a.length)) { - if (!('start' in m)) m.start = i; - bal++; - } - else if (b == str.substr(i, b.length) && 'start' in m) { - ended = true; - bal--; - if (!bal) { - m.end = i; - m.pre = str.substr(0, m.start); - m.body = (m.end - m.start > 1) - ? str.substring(m.start + a.length, m.end) - : ''; - m.post = str.slice(m.end + b.length); - return m; - } - } - } - - // if we opened more than we closed, find the one we closed - if (bal && ended) { - var start = m.start + a.length; - m = balanced(a, b, str.substr(start)); - if (m) { - m.start += start; - m.end += start; - m.pre = str.slice(0, start) + m.pre; - } - return m; - } -} - -},{}],4:[function(require,module,exports){ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (Array.isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -},{}]},{},[1]); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/minimatch.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/minimatch.js deleted file mode 100644 index 2bfdf62..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/minimatch.js +++ /dev/null @@ -1,868 +0,0 @@ -module.exports = minimatch -minimatch.Minimatch = Minimatch - -var isWindows = false -if (typeof process !== 'undefined' && process.platform === 'win32') - isWindows = true - -var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} - , expand = require("brace-expansion") - - // any single thing other than / - // don't need to escape / when using new RegExp() - , qmark = "[^/]" - - // * => any number of characters - , star = qmark + "*?" - - // ** when dots are allowed. Anything goes, except .. and . - // not (^ or / followed by one or two dots followed by $ or /), - // followed by anything, any number of times. - , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" - - // not a ^ or / followed by a dot, - // followed by anything, any number of times. - , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" - - // characters that need to be escaped in RegExp. - , reSpecials = charSet("().*{}+?[]^$\\!") - -// "abc" -> { a:true, b:true, c:true } -function charSet (s) { - return s.split("").reduce(function (set, c) { - set[c] = true - return set - }, {}) -} - -// normalizes slashes. -var slashSplit = /\/+/ - -minimatch.filter = filter -function filter (pattern, options) { - options = options || {} - return function (p, i, list) { - return minimatch(p, pattern, options) - } -} - -function ext (a, b) { - a = a || {} - b = b || {} - var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) - Object.keys(a).forEach(function (k) { - t[k] = a[k] - }) - return t -} - -minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch - - var orig = minimatch - - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - } - - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - } - - return m -} - -Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch - return minimatch.defaults(def).Minimatch -} - - -function minimatch (p, pattern, options) { - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") - } - - if (!options) options = {} - - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { - return false - } - - // "" only matches "" - if (pattern.trim() === "") return p === "" - - return new Minimatch(pattern, options).match(p) -} - -function Minimatch (pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) - } - - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") - } - - if (!options) options = {} - pattern = pattern.trim() - - // windows support: need to use /, not \ - if (isWindows) - pattern = pattern.split("\\").join("/") - - this.options = options - this.set = [] - this.pattern = pattern - this.regexp = null - this.negate = false - this.comment = false - this.empty = false - - // make the set of regexps etc. - this.make() -} - -Minimatch.prototype.debug = function() {} - -Minimatch.prototype.make = make -function make () { - // don't do it more than once. - if (this._made) return - - var pattern = this.pattern - var options = this.options - - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { - this.comment = true - return - } - if (!pattern) { - this.empty = true - return - } - - // step 1: figure out negation, etc. - this.parseNegate() - - // step 2: expand braces - var set = this.globSet = this.braceExpand() - - if (options.debug) this.debug = console.error - - this.debug(this.pattern, set) - - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }) - - this.debug(this.pattern, set) - - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) - - this.debug(this.pattern, set) - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return -1 === s.indexOf(false) - }) - - this.debug(this.pattern, set) - - this.set = set -} - -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - , negate = false - , options = this.options - , negateOffset = 0 - - if (options.nonegate) return - - for ( var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === "!" - ; i ++) { - negate = !negate - negateOffset ++ - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} - -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} - -Minimatch.prototype.braceExpand = braceExpand - -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) - options = this.options - else - options = {} - } - - pattern = typeof pattern === "undefined" - ? this.pattern : pattern - - if (typeof pattern === "undefined") { - throw new Error("undefined pattern") - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) -} - -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - var options = this.options - - // shortcuts - if (!options.noglobstar && pattern === "**") return GLOBSTAR - if (pattern === "") return "" - - var re = "" - , hasMagic = !!options.nocase - , escaping = false - // ? => one single character - , patternListStack = [] - , plType - , stateChar - , inClass = false - , reClassStart = -1 - , classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - , patternStart = pattern.charAt(0) === "." ? "" // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" - : "(?!\\.)" - , self = this - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case "*": - re += star - hasMagic = true - break - case "?": - re += qmark - hasMagic = true - break - default: - re += "\\"+stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } - } - - for ( var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i ++ ) { - - this.debug("%s\t%s %s %j", pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += "\\" + c - escaping = false - continue - } - - SWITCH: switch (c) { - case "/": - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case "\\": - clearStateChar() - escaping = true - continue - - // the various stateChar values - // for the "extglob" stuff. - case "?": - case "*": - case "+": - case "@": - case "!": - this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c) - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === "!" && i === classStart + 1) c = "^" - re += c - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue - - case "(": - if (inClass) { - re += "(" - continue - } - - if (!stateChar) { - re += "\\(" - continue - } - - plType = stateChar - patternListStack.push({ type: plType - , start: i - 1 - , reStart: re.length }) - // negation is (?:(?!js)[^/]*) - re += stateChar === "!" ? "(?:(?!" : "(?:" - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue - - case ")": - if (inClass || !patternListStack.length) { - re += "\\)" - continue - } - - clearStateChar() - hasMagic = true - re += ")" - plType = patternListStack.pop().type - // negation is (?:(?!js)[^/]*) - // The others are (?:) - switch (plType) { - case "!": - re += "[^/]*?)" - break - case "?": - case "+": - case "*": re += plType - case "@": break // the default anyway - } - continue - - case "|": - if (inClass || !patternListStack.length || escaping) { - re += "\\|" - escaping = false - continue - } - - clearStateChar() - re += "|" - continue - - // these are mostly the same in regexp and glob - case "[": - // swallow any state-tracking char before the [ - clearStateChar() - - if (inClass) { - re += "\\" + c - continue - } - - inClass = true - classStart = i - reClassStart = re.length - re += c - continue - - case "]": - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += "\\" + c - escaping = false - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - new RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + "\\[" + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - - // finish up the class. - hasMagic = true - inClass = false - re += c - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar() - - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === "^" && inClass)) { - re += "\\" - } - - re += c - - } // switch - } // for - - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - var cs = pattern.substr(classStart + 1) - , sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + "\\[" + sp[0] - hasMagic = hasMagic || sp[1] - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - var pl - while (pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + 3) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = "\\" - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + "|" - }) - - this.debug("tail=%j\n %s", tail, tail) - var t = pl.type === "*" ? star - : pl.type === "?" ? qmark - : "\\" + pl.type - - hasMagic = true - re = re.slice(0, pl.reStart) - + t + "\\(" - + tail - } - - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += "\\\\" - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case ".": - case "[": - case "(": addPatternStart = true - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== "" && hasMagic) re = "(?=.)" + re - - if (addPatternStart) re = patternStart + re - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [ re, hasMagic ] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? "i" : "" - , regExp = new RegExp("^" + re + "$", flags) - - regExp._glob = pattern - regExp._src = re - - return regExp -} - -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} - -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set - - if (!set.length) return this.regexp = false - var options = this.options - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - , flags = options.nocase ? "i" : "" - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === "string") ? regExpEscape(p) - : p._src - }).join("\\\/") - }).join("|") - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = "^(?:" + re + ")$" - - // can match anything, as long as it's not this. - if (this.negate) re = "^(?!" + re + ").*$" - - try { - return this.regexp = new RegExp(re, flags) - } catch (ex) { - return this.regexp = false - } -} - -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} - -Minimatch.prototype.match = match -function match (f, partial) { - this.debug("match", f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === "" - - if (f === "/" && partial) return true - - var options = this.options - - // windows: need to use /, not \ - if (isWindows) - f = f.split("\\").join("/") - - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, "split", f) - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set - this.debug(this.pattern, "set", set) - - // Find the basename of the path by looking for the last non-empty segment - var filename; - for (var i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } - - for (var i = 0, l = set.length; i < l; i ++) { - var pattern = set[i], file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate -} - -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options - - this.debug("matchOne", - { "this": this - , file: file - , pattern: pattern }) - - this.debug("matchOne", file.length, pattern.length) - - for ( var fi = 0 - , pi = 0 - , fl = file.length - , pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi ++, pi ++ ) { - - this.debug("matchOne loop") - var p = pattern[pi] - , f = file[fi] - - this.debug(pattern, p, f) - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - , pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for ( ; fi < fl; fi ++) { - if (file[fi] === "." || file[fi] === ".." || - (!options.dot && file[fi].charAt(0) === ".")) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - WHILE: while (fr < fl) { - var swallowee = file[fr] - - this.debug('\nglobstar while', - file, fr, pattern, pr, swallowee) - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === "." || swallowee === ".." || - (!options.dot && swallowee.charAt(0) === ".")) { - this.debug("dot detected!", file, fr, pattern, pr) - break WHILE - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr ++ - } - } - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug("\n>>> no match, partial?", file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === "string") { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug("string match", p, f, hit) - } else { - hit = f.match(p) - this.debug("pattern match", p, f, hit) - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === "") - return emptyFileEnd - } - - // should be unreachable. - throw new Error("wtf?") -} - - -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, "$1") -} - - -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore deleted file mode 100644 index 249bc20..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -*.sw* diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml deleted file mode 100644 index 6e5919d..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - "0.10" diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md deleted file mode 100644 index 62bc7ba..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +++ /dev/null @@ -1,121 +0,0 @@ -# brace-expansion - -[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), -as known from sh/bash, in JavaScript. - -[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion) - -[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion) - -## Example - -```js -var expand = require('brace-expansion'); - -expand('file-{a,b,c}.jpg') -// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] - -expand('-v{,,}') -// => ['-v', '-v', '-v'] - -expand('file{0..2}.jpg') -// => ['file0.jpg', 'file1.jpg', 'file2.jpg'] - -expand('file-{a..c}.jpg') -// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] - -expand('file{2..0}.jpg') -// => ['file2.jpg', 'file1.jpg', 'file0.jpg'] - -expand('file{0..4..2}.jpg') -// => ['file0.jpg', 'file2.jpg', 'file4.jpg'] - -expand('file-{a..e..2}.jpg') -// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] - -expand('file{00..10..5}.jpg') -// => ['file00.jpg', 'file05.jpg', 'file10.jpg'] - -expand('{{A..C},{a..c}}') -// => ['A', 'B', 'C', 'a', 'b', 'c'] - -expand('ppp{,config,oe{,conf}}') -// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] -``` - -## API - -```js -var expand = require('brace-expansion'); -``` - -### var expanded = expand(str) - -Return an array of all possible and valid expansions of `str`. If none are -found, `[str]` is returned. - -Valid expansions are: - -```js -/^(.*,)+(.+)?$/ -// {a,b,...} -``` - -A comma seperated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. - -```js -/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ -// {x..y[..incr]} -``` - -A numeric sequence from `x` to `y` inclusive, with optional increment. -If `x` or `y` start with a leading `0`, all the numbers will be padded -to have equal length. Negative numbers and backwards iteration work too. - -```js -/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ -// {x..y[..incr]} -``` - -An alphabetic sequence from `x` to `y` inclusive, with optional increment. -`x` and `y` must be exactly one character, and if given, `incr` must be a -number. - -For compatibility reasons, the string `${` is not eligible for brace expansion. - -## Installation - -With [npm](https://npmjs.org) do: - -```bash -npm install brace-expansion -``` - -## Contributors - -- [Julian Gruber](https://github.com/juliangruber) -- [Isaac Z. Schlueter](https://github.com/isaacs) - -## License - -(MIT) - -Copyright (c) 2013 Julian Gruber <julian@juliangruber.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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js deleted file mode 100644 index 60ecfc7..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +++ /dev/null @@ -1,8 +0,0 @@ -var expand = require('./'); - -console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); -console.log(expand('http://www.numericals.com/file{1..100..10}.txt')); -console.log(expand('http://www.letters.com/file{a..z..2}.txt')); -console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); -console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js deleted file mode 100644 index a23104e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +++ /dev/null @@ -1,191 +0,0 @@ -var concatMap = require('concat-map'); -var balanced = require('balanced-match'); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - return expand(escapeBraces(str), true).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; -} - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore deleted file mode 100644 index fd4f2b0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -.DS_Store diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml deleted file mode 100644 index cc4dba2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - "0.8" - - "0.10" diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile deleted file mode 100644 index fa5da71..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +++ /dev/null @@ -1,6 +0,0 @@ - -test: - @node_modules/.bin/tape test/*.js - -.PHONY: test - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md deleted file mode 100644 index 2aff0eb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +++ /dev/null @@ -1,80 +0,0 @@ -# balanced-match - -Match balanced string pairs, like `{` and `}` or `` and ``. - -[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match) -[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match) - -[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match) - -## Example - -Get the first matching pair of braces: - -```js -var balanced = require('balanced-match'); - -console.log(balanced('{', '}', 'pre{in{nested}}post')); -console.log(balanced('{', '}', 'pre{first}between{second}post')); -``` - -The matches are: - -```bash -$ node example.js -{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } -{ start: 3, - end: 9, - pre: 'pre', - body: 'first', - post: 'between{second}post' } -``` - -## API - -### var m = balanced(a, b, str) - -For the first non-nested matching pair of `a` and `b` in `str`, return an -object with those keys: - -* **start** the index of the first match of `a` -* **end** the index of the matching `b` -* **pre** the preamble, `a` and `b` not included -* **body** the match, `a` and `b` not included -* **post** the postscript, `a` and `b` not included - -If there's no match, `undefined` will be returned. - -If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']`. - -## Installation - -With [npm](https://npmjs.org) do: - -```bash -npm install balanced-match -``` - -## License - -(MIT) - -Copyright (c) 2013 Julian Gruber <julian@juliangruber.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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js deleted file mode 100644 index c02ad34..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +++ /dev/null @@ -1,5 +0,0 @@ -var balanced = require('./'); - -console.log(balanced('{', '}', 'pre{in{nested}}post')); -console.log(balanced('{', '}', 'pre{first}between{second}post')); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js deleted file mode 100644 index d165ae8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = balanced; -function balanced(a, b, str) { - var bal = 0; - var m = {}; - var ended = false; - - for (var i = 0; i < str.length; i++) { - if (a == str.substr(i, a.length)) { - if (!('start' in m)) m.start = i; - bal++; - } - else if (b == str.substr(i, b.length) && 'start' in m) { - ended = true; - bal--; - if (!bal) { - m.end = i; - m.pre = str.substr(0, m.start); - m.body = (m.end - m.start > 1) - ? str.substring(m.start + a.length, m.end) - : ''; - m.post = str.slice(m.end + b.length); - return m; - } - } - } - - // if we opened more than we closed, find the one we closed - if (bal && ended) { - var start = m.start + a.length; - m = balanced(a, b, str.substr(start)); - if (m) { - m.start += start; - m.end += start; - m.pre = str.slice(0, start) + m.pre; - } - return m; - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json deleted file mode 100644 index 9ffdc67..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "balanced-match", - "description": "Match balanced character pairs, like \"{\" and \"}\"", - "version": "0.2.0", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/balanced-match.git" - }, - "homepage": "https://github.com/juliangruber/balanced-match", - "main": "index.js", - "scripts": { - "test": "make test" - }, - "dependencies": {}, - "devDependencies": { - "tape": "~1.1.1" - }, - "keywords": [ - "match", - "regexp", - "test", - "balanced", - "parse" - ], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/8..latest", - "firefox/20..latest", - "firefox/nightly", - "chrome/25..latest", - "chrome/canary", - "opera/12..latest", - "opera/next", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - }, - "gitHead": "ba40ed78e7114a4a67c51da768a100184dead39c", - "bugs": { - "url": "https://github.com/juliangruber/balanced-match/issues" - }, - "_id": "balanced-match@0.2.0", - "_shasum": "38f6730c03aab6d5edbb52bd934885e756d71674", - "_from": "balanced-match@^0.2.0", - "_npmVersion": "2.1.8", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], - "dist": { - "shasum": "38f6730c03aab6d5edbb52bd934885e756d71674", - "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js deleted file mode 100644 index 36bfd39..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +++ /dev/null @@ -1,56 +0,0 @@ -var test = require('tape'); -var balanced = require('..'); - -test('balanced', function(t) { - t.deepEqual(balanced('{', '}', 'pre{in{nest}}post'), { - start: 3, - end: 12, - pre: 'pre', - body: 'in{nest}', - post: 'post' - }); - t.deepEqual(balanced('{', '}', '{{{{{{{{{in}post'), { - start: 8, - end: 11, - pre: '{{{{{{{{', - body: 'in', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre{body{in}post'), { - start: 8, - end: 11, - pre: 'pre{body', - body: 'in', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre}{in{nest}}post'), { - start: 4, - end: 13, - pre: 'pre}', - body: 'in{nest}', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre{body}between{body2}post'), { - start: 3, - end: 8, - pre: 'pre', - body: 'body', - post: 'between{body2}post' - }); - t.notOk(balanced('{', '}', 'nope'), 'should be notOk'); - t.deepEqual(balanced('', '', 'preinnestpost'), { - start: 3, - end: 19, - pre: 'pre', - body: 'innest', - post: 'post' - }); - t.deepEqual(balanced('', '', 'preinnestpost'), { - start: 7, - end: 23, - pre: 'pre', - body: 'innest', - post: 'post' - }); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml deleted file mode 100644 index f1d0f13..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE deleted file mode 100644 index ee27ba4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown deleted file mode 100644 index 408f70a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +++ /dev/null @@ -1,62 +0,0 @@ -concat-map -========== - -Concatenative mapdashery. - -[![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map) - -[![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map) - -example -======= - -``` js -var concatMap = require('concat-map'); -var xs = [ 1, 2, 3, 4, 5, 6 ]; -var ys = concatMap(xs, function (x) { - return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; -}); -console.dir(ys); -``` - -*** - -``` -[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] -``` - -methods -======= - -``` js -var concatMap = require('concat-map') -``` - -concatMap(xs, fn) ------------------ - -Return an array of concatenated elements by calling `fn(x, i)` for each element -`x` and each index `i` in the array `xs`. - -When `fn(x, i)` returns an array, its result will be concatenated with the -result array. If `fn(x, i)` returns anything else, that value will be pushed -onto the end of the result array. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install concat-map -``` - -license -======= - -MIT - -notes -===== - -This module was written while sitting high above the ground in a tree. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js deleted file mode 100644 index 3365621..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +++ /dev/null @@ -1,6 +0,0 @@ -var concatMap = require('../'); -var xs = [ 1, 2, 3, 4, 5, 6 ]; -var ys = concatMap(xs, function (x) { - return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; -}); -console.dir(ys); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js deleted file mode 100644 index b29a781..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json deleted file mode 100644 index b516138..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "concat-map", - "description": "concatenative mapdashery", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/substack/node-concat-map.git" - }, - "main": "index.js", - "keywords": [ - "concat", - "concatMap", - "map", - "functional", - "higher-order" - ], - "directories": { - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tape test/*.js" - }, - "devDependencies": { - "tape": "~2.4.0" - }, - "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "testling": { - "files": "test/*.js", - "browsers": { - "ie": [ - 6, - 7, - 8, - 9 - ], - "ff": [ - 3.5, - 10, - 15 - ], - "chrome": [ - 10, - 22 - ], - "safari": [ - 5.1 - ], - "opera": [ - 12 - ] - } - }, - "bugs": { - "url": "https://github.com/substack/node-concat-map/issues" - }, - "homepage": "https://github.com/substack/node-concat-map", - "_id": "concat-map@0.0.1", - "dist": { - "shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", - "tarball": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - }, - "_from": "concat-map@0.0.1", - "_npmVersion": "1.3.21", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", - "_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js deleted file mode 100644 index fdbd702..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +++ /dev/null @@ -1,39 +0,0 @@ -var concatMap = require('../'); -var test = require('tape'); - -test('empty or not', function (t) { - var xs = [ 1, 2, 3, 4, 5, 6 ]; - var ixes = []; - var ys = concatMap(xs, function (x, ix) { - ixes.push(ix); - return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; - }); - t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]); - t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]); - t.end(); -}); - -test('always something', function (t) { - var xs = [ 'a', 'b', 'c', 'd' ]; - var ys = concatMap(xs, function (x) { - return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ]; - }); - t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); - t.end(); -}); - -test('scalars', function (t) { - var xs = [ 'a', 'b', 'c', 'd' ]; - var ys = concatMap(xs, function (x) { - return x === 'b' ? [ 'B', 'B', 'B' ] : x; - }); - t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); - t.end(); -}); - -test('undefs', function (t) { - var xs = [ 'a', 'b', 'c', 'd' ]; - var ys = concatMap(xs, function () {}); - t.same(ys, [ undefined, undefined, undefined, undefined ]); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json deleted file mode 100644 index becf26c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "brace-expansion", - "description": "Brace expansion as known from sh/bash", - "version": "1.1.0", - "repository": { - "type": "git", - "url": "git://github.com/juliangruber/brace-expansion.git" - }, - "homepage": "https://github.com/juliangruber/brace-expansion", - "main": "index.js", - "scripts": { - "test": "tape test/*.js", - "gentest": "bash test/generate.sh" - }, - "dependencies": { - "balanced-match": "^0.2.0", - "concat-map": "0.0.1" - }, - "devDependencies": { - "tape": "^3.0.3" - }, - "keywords": [], - "author": { - "name": "Julian Gruber", - "email": "mail@juliangruber.com", - "url": "http://juliangruber.com" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/8..latest", - "firefox/20..latest", - "firefox/nightly", - "chrome/25..latest", - "chrome/canary", - "opera/12..latest", - "opera/next", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - }, - "gitHead": "b5fa3b1c74e5e2dba2d0efa19b28335641bc1164", - "bugs": { - "url": "https://github.com/juliangruber/brace-expansion/issues" - }, - "_id": "brace-expansion@1.1.0", - "_shasum": "c9b7d03c03f37bc704be100e522b40db8f6cfcd9", - "_from": "brace-expansion@^1.0.0", - "_npmVersion": "2.1.10", - "_nodeVersion": "0.10.32", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - } - ], - "dist": { - "shasum": "c9b7d03c03f37bc704be100e522b40db8f6cfcd9", - "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js deleted file mode 100644 index 5fe2b8a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +++ /dev/null @@ -1,32 +0,0 @@ -var test = require('tape'); -var expand = require('..'); -var fs = require('fs'); -var resfile = __dirname + '/bash-results.txt'; -var cases = fs.readFileSync(resfile, 'utf8').split('><><><><'); - -// throw away the EOF marker -cases.pop() - -test('matches bash expansions', function(t) { - cases.forEach(function(testcase) { - var set = testcase.split('\n'); - var pattern = set.shift(); - var actual = expand(pattern); - - // If it expands to the empty string, then it's actually - // just nothing, but Bash is a singly typed language, so - // "nothing" is the same as "". - if (set.length === 1 && set[0] === '') { - set = [] - } else { - // otherwise, strip off the [] that were added so that - // "" expansions would be preserved properly. - set = set.map(function (s) { - return s.replace(/^\[|\]$/g, '') - }) - } - - t.same(actual, set, pattern); - }); - t.end(); -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt deleted file mode 100644 index 958148d..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +++ /dev/null @@ -1,1075 +0,0 @@ -A{b,{d,e},{f,g}}Z -[AbZ] -[AdZ] -[AeZ] -[AfZ] -[AgZ]><><><><><><><\{a,b}{{a,b},a,b} -[{a,b}a] -[{a,b}b] -[{a,b}a] -[{a,b}b]><><><><{{a,b} -[{a] -[{b]><><><><{a,b}} -[a}] -[b}]><><><><{,} -><><><><><><><{,}b -[b] -[b]><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><{-01..5} -[-01] -[000] -[001] -[002] -[003] -[004] -[005]><><><><{-05..100..5} -[-05] -[000] -[005] -[010] -[015] -[020] -[025] -[030] -[035] -[040] -[045] -[050] -[055] -[060] -[065] -[070] -[075] -[080] -[085] -[090] -[095] -[100]><><><><{-05..100} -[-05] -[-04] -[-03] -[-02] -[-01] -[000] -[001] -[002] -[003] -[004] -[005] -[006] -[007] -[008] -[009] -[010] -[011] -[012] -[013] -[014] -[015] -[016] -[017] -[018] -[019] -[020] -[021] -[022] -[023] -[024] -[025] -[026] -[027] -[028] -[029] -[030] -[031] -[032] -[033] -[034] -[035] -[036] -[037] -[038] -[039] -[040] -[041] -[042] -[043] -[044] -[045] -[046] -[047] -[048] -[049] -[050] -[051] -[052] -[053] -[054] -[055] -[056] -[057] -[058] -[059] -[060] -[061] -[062] -[063] -[064] -[065] -[066] -[067] -[068] -[069] -[070] -[071] -[072] -[073] -[074] -[075] -[076] -[077] -[078] -[079] -[080] -[081] -[082] -[083] -[084] -[085] -[086] -[087] -[088] -[089] -[090] -[091] -[092] -[093] -[094] -[095] -[096] -[097] -[098] -[099] -[100]><><><><{0..5..2} -[0] -[2] -[4]><><><><{0001..05..2} -[0001] -[0003] -[0005]><><><><{0001..-5..2} -[0001] -[-001] -[-003] -[-005]><><><><{0001..-5..-2} -[0001] -[-001] -[-003] -[-005]><><><><{0001..5..-2} -[0001] -[0003] -[0005]><><><><{01..5} -[01] -[02] -[03] -[04] -[05]><><><><{1..05} -[01] -[02] -[03] -[04] -[05]><><><><{1..05..3} -[01] -[04]><><><><{05..100} -[005] -[006] -[007] -[008] -[009] -[010] -[011] -[012] -[013] -[014] -[015] -[016] -[017] -[018] -[019] -[020] -[021] -[022] -[023] -[024] -[025] -[026] -[027] -[028] -[029] -[030] -[031] -[032] -[033] -[034] -[035] -[036] -[037] -[038] -[039] -[040] -[041] -[042] -[043] -[044] -[045] -[046] -[047] -[048] -[049] -[050] -[051] -[052] -[053] -[054] -[055] -[056] -[057] -[058] -[059] -[060] -[061] -[062] -[063] -[064] -[065] -[066] -[067] -[068] -[069] -[070] -[071] -[072] -[073] -[074] -[075] -[076] -[077] -[078] -[079] -[080] -[081] -[082] -[083] -[084] -[085] -[086] -[087] -[088] -[089] -[090] -[091] -[092] -[093] -[094] -[095] -[096] -[097] -[098] -[099] -[100]><><><><{0a..0z} -[{0a..0z}]><><><><{a,b\}c,d} -[a] -[b}c] -[d]><><><><{a,b{c,d} -[{a,bc] -[{a,bd]><><><><{a,b}c,d} -[ac,d}] -[bc,d}]><><><><{a..F} -[a] -[`] -[_] -[^] -[]] -[] -[[] -[Z] -[Y] -[X] -[W] -[V] -[U] -[T] -[S] -[R] -[Q] -[P] -[O] -[N] -[M] -[L] -[K] -[J] -[I] -[H] -[G] -[F]><><><><{A..f} -[A] -[B] -[C] -[D] -[E] -[F] -[G] -[H] -[I] -[J] -[K] -[L] -[M] -[N] -[O] -[P] -[Q] -[R] -[S] -[T] -[U] -[V] -[W] -[X] -[Y] -[Z] -[[] -[] -[]] -[^] -[_] -[`] -[a] -[b] -[c] -[d] -[e] -[f]><><><><{a..Z} -[a] -[`] -[_] -[^] -[]] -[] -[[] -[Z]><><><><{A..z} -[A] -[B] -[C] -[D] -[E] -[F] -[G] -[H] -[I] -[J] -[K] -[L] -[M] -[N] -[O] -[P] -[Q] -[R] -[S] -[T] -[U] -[V] -[W] -[X] -[Y] -[Z] -[[] -[] -[]] -[^] -[_] -[`] -[a] -[b] -[c] -[d] -[e] -[f] -[g] -[h] -[i] -[j] -[k] -[l] -[m] -[n] -[o] -[p] -[q] -[r] -[s] -[t] -[u] -[v] -[w] -[x] -[y] -[z]><><><><{z..A} -[z] -[y] -[x] -[w] -[v] -[u] -[t] -[s] -[r] -[q] -[p] -[o] -[n] -[m] -[l] -[k] -[j] -[i] -[h] -[g] -[f] -[e] -[d] -[c] -[b] -[a] -[`] -[_] -[^] -[]] -[] -[[] -[Z] -[Y] -[X] -[W] -[V] -[U] -[T] -[S] -[R] -[Q] -[P] -[O] -[N] -[M] -[L] -[K] -[J] -[I] -[H] -[G] -[F] -[E] -[D] -[C] -[B] -[A]><><><><{Z..a} -[Z] -[[] -[] -[]] -[^] -[_] -[`] -[a]><><><><{a..F..2} -[a] -[_] -[]] -[[] -[Y] -[W] -[U] -[S] -[Q] -[O] -[M] -[K] -[I] -[G]><><><><{A..f..02} -[A] -[C] -[E] -[G] -[I] -[K] -[M] -[O] -[Q] -[S] -[U] -[W] -[Y] -[[] -[]] -[_] -[a] -[c] -[e]><><><><{a..Z..5} -[a] -[]><><><><><><><{A..z..10} -[A] -[K] -[U] -[_] -[i] -[s]><><><><{z..A..-2} -[z] -[x] -[v] -[t] -[r] -[p] -[n] -[l] -[j] -[h] -[f] -[d] -[b] -[`] -[^] -[] -[Z] -[X] -[V] -[T] -[R] -[P] -[N] -[L] -[J] -[H] -[F] -[D] -[B]><><><><{Z..a..20} -[Z]><><><><{a{,b} -[{a] -[{ab]><><><><{a},b} -[a}] -[b]><><><><{x,y{,}g} -[x] -[yg] -[yg]><><><><{x,y{}g} -[x] -[y{}g]><><><><{{a,b} -[{a] -[{b]><><><><{{a,b},c} -[a] -[b] -[c]><><><><{{a,b}c} -[{ac}] -[{bc}]><><><><{{a,b},} -[a] -[b]><><><><><><><{{a,b},}c -[ac] -[bc] -[c]><><><><{{a,b}.} -[{a.}] -[{b.}]><><><><{{a,b}} -[{a}] -[{b}]><><><><><><>< -><><><><{-10..00} -[-10] -[-09] -[-08] -[-07] -[-06] -[-05] -[-04] -[-03] -[-02] -[-01] -[000]><><><><{a,\\{a,b}c} -[a] -[\ac] -[\bc]><><><><{a,\{a,b}c} -[ac}] -[{ac}] -[bc}]><><><><><><><{-10.\.00} -[{-10..00}]><><><><><><><><><><{l,n,m}xyz -[lxyz] -[nxyz] -[mxyz]><><><><{abc\,def} -[{abc,def}]><><><><{abc} -[{abc}]><><><><{x\,y,\{abc\},trie} -[x,y] -[{abc}] -[trie]><><><><{} -[{}]><><><><} -[}]><><><><{ -[{]><><><><><><><{1..10} -[1] -[2] -[3] -[4] -[5] -[6] -[7] -[8] -[9] -[10]><><><><{0..10,braces} -[0..10] -[braces]><><><><{{0..10},braces} -[0] -[1] -[2] -[3] -[4] -[5] -[6] -[7] -[8] -[9] -[10] -[braces]><><><><><><><{3..3} -[3]><><><><><><><{10..1} -[10] -[9] -[8] -[7] -[6] -[5] -[4] -[3] -[2] -[1]><><><><{10..1}y -[10y] -[9y] -[8y] -[7y] -[6y] -[5y] -[4y] -[3y] -[2y] -[1y]><><><><><><><{a..f} -[a] -[b] -[c] -[d] -[e] -[f]><><><><{f..a} -[f] -[e] -[d] -[c] -[b] -[a]><><><><{a..A} -[a] -[`] -[_] -[^] -[]] -[] -[[] -[Z] -[Y] -[X] -[W] -[V] -[U] -[T] -[S] -[R] -[Q] -[P] -[O] -[N] -[M] -[L] -[K] -[J] -[I] -[H] -[G] -[F] -[E] -[D] -[C] -[B] -[A]><><><><{A..a} -[A] -[B] -[C] -[D] -[E] -[F] -[G] -[H] -[I] -[J] -[K] -[L] -[M] -[N] -[O] -[P] -[Q] -[R] -[S] -[T] -[U] -[V] -[W] -[X] -[Y] -[Z] -[[] -[] -[]] -[^] -[_] -[`] -[a]><><><><{f..f} -[f]><><><><{1..f} -[{1..f}]><><><><{f..1} -[{f..1}]><><><><{-1..-10} -[-1] -[-2] -[-3] -[-4] -[-5] -[-6] -[-7] -[-8] -[-9] -[-10]><><><><{-20..0} -[-20] -[-19] -[-18] -[-17] -[-16] -[-15] -[-14] -[-13] -[-12] -[-11] -[-10] -[-9] -[-8] -[-7] -[-6] -[-5] -[-4] -[-3] -[-2] -[-1] -[0]><><><><><><><><><><{klklkl}{1,2,3} -[{klklkl}1] -[{klklkl}2] -[{klklkl}3]><><><><{1..10..2} -[1] -[3] -[5] -[7] -[9]><><><><{-1..-10..2} -[-1] -[-3] -[-5] -[-7] -[-9]><><><><{-1..-10..-2} -[-1] -[-3] -[-5] -[-7] -[-9]><><><><{10..1..-2} -[10] -[8] -[6] -[4] -[2]><><><><{10..1..2} -[10] -[8] -[6] -[4] -[2]><><><><{1..20..2} -[1] -[3] -[5] -[7] -[9] -[11] -[13] -[15] -[17] -[19]><><><><{1..20..20} -[1]><><><><{100..0..5} -[100] -[95] -[90] -[85] -[80] -[75] -[70] -[65] -[60] -[55] -[50] -[45] -[40] -[35] -[30] -[25] -[20] -[15] -[10] -[5] -[0]><><><><{100..0..-5} -[100] -[95] -[90] -[85] -[80] -[75] -[70] -[65] -[60] -[55] -[50] -[45] -[40] -[35] -[30] -[25] -[20] -[15] -[10] -[5] -[0]><><><><{a..z} -[a] -[b] -[c] -[d] -[e] -[f] -[g] -[h] -[i] -[j] -[k] -[l] -[m] -[n] -[o] -[p] -[q] -[r] -[s] -[t] -[u] -[v] -[w] -[x] -[y] -[z]><><><><{a..z..2} -[a] -[c] -[e] -[g] -[i] -[k] -[m] -[o] -[q] -[s] -[u] -[w] -[y]><><><><{z..a..-2} -[z] -[x] -[v] -[t] -[r] -[p] -[n] -[l] -[j] -[h] -[f] -[d] -[b]><><><><{2147483645..2147483649} -[2147483645] -[2147483646] -[2147483647] -[2147483648] -[2147483649]><><><><{10..0..2} -[10] -[8] -[6] -[4] -[2] -[0]><><><><{10..0..-2} -[10] -[8] -[6] -[4] -[2] -[0]><><><><{-50..-0..5} -[-50] -[-45] -[-40] -[-35] -[-30] -[-25] -[-20] -[-15] -[-10] -[-5] -[0]><><><><{1..10.f} -[{1..10.f}]><><><><{1..ff} -[{1..ff}]><><><><{1..10..ff} -[{1..10..ff}]><><><><{1.20..2} -[{1.20..2}]><><><><{1..20..f2} -[{1..20..f2}]><><><><{1..20..2f} -[{1..20..2f}]><><><><{1..2f..2} -[{1..2f..2}]><><><><{1..ff..2} -[{1..ff..2}]><><><><{1..ff} -[{1..ff}]><><><><{1..f} -[{1..f}]><><><><{1..0f} -[{1..0f}]><><><><{1..10f} -[{1..10f}]><><><><{1..10.f} -[{1..10.f}]><><><><{1..10.f} -[{1..10.f}]><><><>< \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt deleted file mode 100644 index e5161c3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +++ /dev/null @@ -1,182 +0,0 @@ -# skip quotes for now -# "{x,x}" -# {"x,x"} -# {x","x} -# '{a,b}{{a,b},a,b}' -A{b,{d,e},{f,g}}Z -PRE-{a,b}{{a,b},a,b}-POST -\\{a,b}{{a,b},a,b} -{{a,b} -{a,b}} -{,} -a{,} -{,}b -a{,}b -a{b}c -a{1..5}b -a{01..5}b -a{-01..5}b -a{-01..5..3}b -a{001..9}b -a{b,c{d,e},{f,g}h}x{y,z -a{b,c{d,e},{f,g}h}x{y,z\\} -a{b,c{d,e},{f,g}h}x{y,z} -a{b{c{d,e}f{x,y{{g}h -a{b{c{d,e}f{x,y{}g}h -a{b{c{d,e}f{x,y}}g}h -a{b{c{d,e}f}g}h -a{{x,y},z}b -f{x,y{g,z}}h -f{x,y{{g,z}}h -f{x,y{{g,z}}h} -f{x,y{{g}h -f{x,y{{g}}h -f{x,y{}g}h -z{a,b{,c}d -z{a,b},c}d -{-01..5} -{-05..100..5} -{-05..100} -{0..5..2} -{0001..05..2} -{0001..-5..2} -{0001..-5..-2} -{0001..5..-2} -{01..5} -{1..05} -{1..05..3} -{05..100} -{0a..0z} -{a,b\\}c,d} -{a,b{c,d} -{a,b}c,d} -{a..F} -{A..f} -{a..Z} -{A..z} -{z..A} -{Z..a} -{a..F..2} -{A..f..02} -{a..Z..5} -d{a..Z..5}b -{A..z..10} -{z..A..-2} -{Z..a..20} -{a{,b} -{a},b} -{x,y{,}g} -{x,y{}g} -{{a,b} -{{a,b},c} -{{a,b}c} -{{a,b},} -X{{a,b},}X -{{a,b},}c -{{a,b}.} -{{a,b}} -X{a..#}X -# this next one is an empty string - -{-10..00} -# Need to escape slashes in here for reasons i guess. -{a,\\\\{a,b}c} -{a,\\{a,b}c} -a,\\{b,c} -{-10.\\.00} -#### bash tests/braces.tests -# Note that some tests are edited out because some features of -# bash are intentionally not supported in this brace expander. -ff{c,b,a} -f{d,e,f}g -{l,n,m}xyz -{abc\\,def} -{abc} -{x\\,y,\\{abc\\},trie} -# not impementing back-ticks obviously -# XXXX\\{`echo a b c | tr ' ' ','`\\} -{} -# We only ever have to worry about parsing a single argument, -# not a command line, so spaces have a different meaning than bash. -# { } -} -{ -abcd{efgh -# spaces -# foo {1,2} bar -# not impementing back-ticks obviously -# `zecho foo {1,2} bar` -# $(zecho foo {1,2} bar) -# ${var} is not a variable here, like it is in bash. omit. -# foo{bar,${var}.} -# foo{bar,${var}} -# isaacs: skip quotes for now -# "${var}"{x,y} -# $var{x,y} -# ${var}{x,y} -# new sequence brace operators -{1..10} -# this doesn't work yet -{0..10,braces} -# but this does -{{0..10},braces} -x{{0..10},braces}y -{3..3} -x{3..3}y -{10..1} -{10..1}y -x{10..1}y -{a..f} -{f..a} -{a..A} -{A..a} -{f..f} -# mixes are incorrectly-formed brace expansions -{1..f} -{f..1} -# spaces -# 0{1..9} {10..20} -# do negative numbers work? -{-1..-10} -{-20..0} -# weirdly-formed brace expansions -- fixed in post-bash-3.1 -a-{b{d,e}}-c -a-{bdef-{g,i}-c -# isaacs: skip quotes for now -# {"klklkl"}{1,2,3} -# isaacs: this is a valid test, though -{klklkl}{1,2,3} -# {"x,x"} -{1..10..2} -{-1..-10..2} -{-1..-10..-2} -{10..1..-2} -{10..1..2} -{1..20..2} -{1..20..20} -{100..0..5} -{100..0..-5} -{a..z} -{a..z..2} -{z..a..-2} -# make sure brace expansion handles ints > 2**31 - 1 using intmax_t -{2147483645..2147483649} -# unwanted zero-padding -- fixed post-bash-4.0 -{10..0..2} -{10..0..-2} -{-50..-0..5} -# bad -{1..10.f} -{1..ff} -{1..10..ff} -{1.20..2} -{1..20..f2} -{1..20..2f} -{1..2f..2} -{1..ff..2} -{1..ff} -{1..f} -{1..0f} -{1..10f} -{1..10.f} -{1..10.f} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js deleted file mode 100644 index 3fcc185..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +++ /dev/null @@ -1,9 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('ignores ${', function(t) { - t.deepEqual(expand('${1..3}'), ['${1..3}']); - t.deepEqual(expand('${a,b}${c,d}'), ['${a,b}${c,d}']); - t.deepEqual(expand('x${a,b}x${c,d}x'), ['x${a,b}x${c,d}x']); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js deleted file mode 100644 index e429121..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +++ /dev/null @@ -1,10 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('empty option', function(t) { - t.deepEqual(expand('-v{,,,,}'), [ - '-v', '-v', '-v', '-v', '-v' - ]); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh deleted file mode 100644 index e040e66..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Bash 4.3 because of arbitrary need to pick a single standard. - -if [ "${BASH_VERSINFO[0]}" != "4" ] || [ "${BASH_VERSINFO[1]}" != "3" ]; then - echo "this script requires bash 4.3" >&2 - exit 1 -fi - -CDPATH= cd "$(dirname "$0")" - -js='require("./")(process.argv[1]).join(" ")' - -cat cases.txt | \ - while read case; do - if [ "${case:0:1}" = "#" ]; then - continue; - fi; - b="$($BASH -c 'for c in '"$case"'; do echo ["$c"]; done')" - echo "$case" - echo -n "$b><><><><"; - done > bash-results.txt diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js deleted file mode 100644 index 8d434c2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +++ /dev/null @@ -1,15 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('negative increment', function(t) { - t.deepEqual(expand('{3..1}'), ['3', '2', '1']); - t.deepEqual(expand('{10..8}'), ['10', '9', '8']); - t.deepEqual(expand('{10..08}'), ['10', '09', '08']); - t.deepEqual(expand('{c..a}'), ['c', 'b', 'a']); - - t.deepEqual(expand('{4..0..2}'), ['4', '2', '0']); - t.deepEqual(expand('{4..0..-2}'), ['4', '2', '0']); - t.deepEqual(expand('{e..a..2}'), ['e', 'c', 'a']); - - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js deleted file mode 100644 index 0862dc5..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +++ /dev/null @@ -1,16 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('nested', function(t) { - t.deepEqual(expand('{a,b{1..3},c}'), [ - 'a', 'b1', 'b2', 'b3', 'c' - ]); - t.deepEqual(expand('{{A..Z},{a..z}}'), - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('') - ); - t.deepEqual(expand('ppp{,config,oe{,conf}}'), [ - 'ppp', 'pppconfig', 'pppoe', 'pppoeconf' - ]); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js deleted file mode 100644 index c00ad15..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +++ /dev/null @@ -1,10 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('order', function(t) { - t.deepEqual(expand('a{d,c,b}e'), [ - 'ade', 'ace', 'abe' - ]); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js deleted file mode 100644 index e415877..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +++ /dev/null @@ -1,13 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('pad', function(t) { - t.deepEqual(expand('{9..11}'), [ - '9', '10', '11' - ]); - t.deepEqual(expand('{09..11}'), [ - '09', '10', '11' - ]); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js deleted file mode 100644 index 3038fba..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +++ /dev/null @@ -1,7 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('x and y of same type', function(t) { - t.deepEqual(expand('{a..9}'), ['{a..9}']); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js deleted file mode 100644 index f73a957..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +++ /dev/null @@ -1,50 +0,0 @@ -var test = require('tape'); -var expand = require('..'); - -test('numeric sequences', function(t) { - t.deepEqual(expand('a{1..2}b{2..3}c'), [ - 'a1b2c', 'a1b3c', 'a2b2c', 'a2b3c' - ]); - t.deepEqual(expand('{1..2}{2..3}'), [ - '12', '13', '22', '23' - ]); - t.end(); -}); - -test('numeric sequences with step count', function(t) { - t.deepEqual(expand('{0..8..2}'), [ - '0', '2', '4', '6', '8' - ]); - t.deepEqual(expand('{1..8..2}'), [ - '1', '3', '5', '7' - ]); - t.end(); -}); - -test('numeric sequence with negative x / y', function(t) { - t.deepEqual(expand('{3..-2}'), [ - '3', '2', '1', '0', '-1', '-2' - ]); - t.end(); -}); - -test('alphabetic sequences', function(t) { - t.deepEqual(expand('1{a..b}2{b..c}3'), [ - '1a2b3', '1a2c3', '1b2b3', '1b2c3' - ]); - t.deepEqual(expand('{a..b}{b..c}'), [ - 'ab', 'ac', 'bb', 'bc' - ]); - t.end(); -}); - -test('alphabetic sequences with step count', function(t) { - t.deepEqual(expand('{a..k..2}'), [ - 'a', 'c', 'e', 'g', 'i', 'k' - ]); - t.deepEqual(expand('{b..k..2}'), [ - 'b', 'd', 'f', 'h', 'j' - ]); - t.end(); -}); - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/package.json deleted file mode 100644 index 0ada269..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/minimatch/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me" - }, - "name": "minimatch", - "description": "a glob matcher in javascript", - "version": "2.0.4", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/minimatch.git" - }, - "main": "minimatch.js", - "scripts": { - "test": "tap test/*.js", - "prepublish": "browserify -o browser.js -e minimatch.js --bare" - }, - "engines": { - "node": "*" - }, - "dependencies": { - "brace-expansion": "^1.0.0" - }, - "devDependencies": { - "browserify": "^9.0.3", - "tap": "" - }, - "license": { - "type": "MIT", - "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" - }, - "files": [ - "minimatch.js", - "browser.js" - ], - "gitHead": "c75d17c23df3b6050338ee654a58490255b36ebc", - "bugs": { - "url": "https://github.com/isaacs/minimatch/issues" - }, - "homepage": "https://github.com/isaacs/minimatch", - "_id": "minimatch@2.0.4", - "_shasum": "83bea115803e7a097a78022427287edb762fafed", - "_from": "minimatch@^2.0.1", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.4.2", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "83bea115803e7a097a78022427287edb762fafed", - "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-2.0.4.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.4.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/LICENSE deleted file mode 100644 index 0c44ae7..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Isaac Z. Schlueter ("Author") -All rights reserved. - -The BSD License - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. 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. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/README.md deleted file mode 100644 index a2981ea..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# once - -Only call a function once. - -## usage - -```javascript -var once = require('once') - -function load (file, cb) { - cb = once(cb) - loader.load('file') - loader.once('load', cb) - loader.once('error', cb) -} -``` - -Or add to the Function.prototype in a responsible way: - -```javascript -// only has to be done once -require('once').proto() - -function load (file, cb) { - cb = cb.once() - loader.load('file') - loader.once('load', cb) - loader.once('error', cb) -} -``` - -Ironically, the prototype feature makes this module twice as -complicated as necessary. - -To check whether you function has been called, use `fn.called`. Once the -function is called for the first time the return value of the original -function is saved in `fn.value` and subsequent calls will continue to -return this value. - -```javascript -var once = require('once') - -function load (cb) { - cb = once(cb) - var stream = createStream() - stream.once('data', cb) - stream.once('end', function () { - if (!cb.called) cb(new Error('not found')) - }) -} -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE deleted file mode 100644 index 19129e3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/README.md deleted file mode 100644 index 98eab25..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# wrappy - -Callback wrapping utility - -## USAGE - -```javascript -var wrappy = require("wrappy") - -// var wrapper = wrappy(wrapperFunction) - -// make sure a cb is called only once -// See also: http://npm.im/once for this specific use case -var once = wrappy(function (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } -}) - -function printBoo () { - console.log('boo') -} -// has some rando property -printBoo.iAmBooPrinter = true - -var onlyPrintOnce = once(printBoo) - -onlyPrintOnce() // prints 'boo' -onlyPrintOnce() // does nothing - -// random property is retained! -assert.equal(onlyPrintOnce.iAmBooPrinter, true) -``` diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/package.json deleted file mode 100644 index 9165c6e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "wrappy", - "version": "1.0.1", - "description": "Callback wrapping utility", - "main": "wrappy.js", - "directories": { - "test": "test" - }, - "dependencies": {}, - "devDependencies": { - "tap": "^0.4.12" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/wrappy" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "bugs": { - "url": "https://github.com/npm/wrappy/issues" - }, - "homepage": "https://github.com/npm/wrappy", - "gitHead": "006a8cbac6b99988315834c207896eed71fd069a", - "_id": "wrappy@1.0.1", - "_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "_from": "wrappy@1", - "_npmVersion": "2.0.0", - "_nodeVersion": "0.10.31", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739", - "tarball": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - }, - "_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js deleted file mode 100644 index 5ed0fcd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +++ /dev/null @@ -1,51 +0,0 @@ -var test = require('tap').test -var wrappy = require('../wrappy.js') - -test('basic', function (t) { - function onceifier (cb) { - var called = false - return function () { - if (called) return - called = true - return cb.apply(this, arguments) - } - } - onceifier.iAmOnce = {} - var once = wrappy(onceifier) - t.equal(once.iAmOnce, onceifier.iAmOnce) - - var called = 0 - function boo () { - t.equal(called, 0) - called++ - } - // has some rando property - boo.iAmBoo = true - - var onlyPrintOnce = once(boo) - - onlyPrintOnce() // prints 'boo' - onlyPrintOnce() // does nothing - t.equal(called, 1) - - // random property is retained! - t.equal(onlyPrintOnce.iAmBoo, true) - - var logs = [] - var logwrap = wrappy(function (msg, cb) { - logs.push(msg + ' wrapping cb') - return function () { - logs.push(msg + ' before cb') - var ret = cb.apply(this, arguments) - logs.push(msg + ' after cb') - } - }) - - var c = logwrap('foo', function () { - t.same(logs, [ 'foo wrapping cb', 'foo before cb' ]) - }) - c() - t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ]) - - t.end() -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js deleted file mode 100644 index bb7e7d6..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +++ /dev/null @@ -1,33 +0,0 @@ -// Returns a wrapper function that returns a wrapped callback -// The wrapper function should do some stuff, and return a -// presumably different callback function. -// This makes sure that own properties are retained, so that -// decorations and such are not lost along the way. -module.exports = wrappy -function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') - - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k] - }) - - return wrapper - - function wrapper() { - var args = new Array(arguments.length) - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i] - } - var ret = fn.apply(this, args) - var cb = args[args.length-1] - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k] - }) - } - return ret - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/once.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/once.js deleted file mode 100644 index 2e1e721..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/once.js +++ /dev/null @@ -1,21 +0,0 @@ -var wrappy = require('wrappy') -module.exports = wrappy(once) - -once.proto = once(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once(this) - }, - configurable: true - }) -}) - -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) - } - f.called = false - return f -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/package.json deleted file mode 100644 index 74d80e0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "once", - "version": "1.3.1", - "description": "Run a function exactly one time", - "main": "once.js", - "directories": { - "test": "test" - }, - "dependencies": { - "wrappy": "1" - }, - "devDependencies": { - "tap": "~0.3.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/once" - }, - "keywords": [ - "once", - "function", - "one", - "single" - ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "BSD", - "gitHead": "c90ac02a74f433ce47f6938869e68dd6196ffc2c", - "bugs": { - "url": "https://github.com/isaacs/once/issues" - }, - "homepage": "https://github.com/isaacs/once", - "_id": "once@1.3.1", - "_shasum": "f3f3e4da5b7d27b5c732969ee3e67e729457b31f", - "_from": "once@^1.3.0", - "_npmVersion": "2.0.0", - "_nodeVersion": "0.10.31", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "f3f3e4da5b7d27b5c732969ee3e67e729457b31f", - "tarball": "http://registry.npmjs.org/once/-/once-1.3.1.tgz" - }, - "_resolved": "https://registry.npmjs.org/once/-/once-1.3.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/test/once.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/test/once.js deleted file mode 100644 index c618360..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/node_modules/once/test/once.js +++ /dev/null @@ -1,23 +0,0 @@ -var test = require('tap').test -var once = require('../once.js') - -test('once', function (t) { - var f = 0 - function fn (g) { - t.equal(f, 0) - f ++ - return f + g + this - } - fn.ownProperty = {} - var foo = once(fn) - t.equal(fn.ownProperty, foo.ownProperty) - t.notOk(foo.called) - for (var i = 0; i < 1E3; i++) { - t.same(f, i === 0 ? 0 : 1) - var g = foo.call(1, 1) - t.ok(foo.called) - t.same(g, 3) - t.same(f, 1) - } - t.end() -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/package.json deleted file mode 100644 index 104a748..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "name": "glob", - "description": "a little globber", - "version": "4.5.3", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-glob.git" - }, - "main": "glob.js", - "files": [ - "glob.js", - "sync.js", - "common.js" - ], - "engines": { - "node": "*" - }, - "dependencies": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - }, - "devDependencies": { - "mkdirp": "0", - "rimraf": "^2.2.8", - "tap": "^0.5.0", - "tick": "0.0.6" - }, - "scripts": { - "prepublish": "npm run benchclean", - "profclean": "rm -f v8.log profile.txt", - "test": "npm run profclean && tap test/*.js", - "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", - "bench": "bash benchmark.sh", - "prof": "bash prof.sh && cat profile.txt", - "benchclean": "bash benchclean.sh" - }, - "license": "ISC", - "gitHead": "a4e461ab59a837eee80a4d8dbdbf5ae1054a646f", - "bugs": { - "url": "https://github.com/isaacs/node-glob/issues" - }, - "homepage": "https://github.com/isaacs/node-glob", - "_id": "glob@4.5.3", - "_shasum": "c6cb73d3226c1efef04de3c56d012f03377ee15f", - "_from": "glob@^4.3.5", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.4.2", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "c6cb73d3226c1efef04de3c56d012f03377ee15f", - "tarball": "http://registry.npmjs.org/glob/-/glob-4.5.3.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/sync.js deleted file mode 100644 index f4f5e36..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/glob/sync.js +++ /dev/null @@ -1,457 +0,0 @@ -module.exports = globSync -globSync.GlobSync = GlobSync - -var fs = require('fs') -var minimatch = require('minimatch') -var Minimatch = minimatch.Minimatch -var Glob = require('./glob.js').Glob -var util = require('util') -var path = require('path') -var assert = require('assert') -var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti -var isAbsolute = common.isAbsolute -var setopts = common.setopts -var ownProp = common.ownProp -var childrenIgnored = common.childrenIgnored - -function globSync (pattern, options) { - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - return new GlobSync(pattern, options).found -} - -function GlobSync (pattern, options) { - if (!pattern) - throw new Error('must provide pattern') - - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - if (!(this instanceof GlobSync)) - return new GlobSync(pattern, options) - - setopts(this, pattern, options) - - if (this.noprocess) - return this - - var n = this.minimatch.set.length - this.matches = new Array(n) - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false) - } - this._finish() -} - -GlobSync.prototype._finish = function () { - assert(this instanceof GlobSync) - if (this.realpath) { - var self = this - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null) - for (var p in matchset) { - try { - p = self._makeAbs(p) - var real = fs.realpathSync(p, this.realpathCache) - set[real] = true - } catch (er) { - if (er.syscall === 'stat') - set[self._makeAbs(p)] = true - else - throw er - } - } - }) - } - common.finish(this) -} - - -GlobSync.prototype._process = function (pattern, index, inGlobStar) { - assert(this instanceof GlobSync) - - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. - - // See if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index) - return - - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break - - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break - } - - var remain = pattern.slice(n) - - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix - - var abs = this._makeAbs(read) - - //if ignored, skip processing - if (childrenIgnored(this, read)) - return - - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar) -} - - -GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar) - - // if the abs isn't a dir, then nothing can match! - if (!entries) - return - - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' - - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) - } else { - m = e.match(pn) - } - if (m) - matchedEntries.push(e) - } - } - - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return - - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. - - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix.slice(-1) !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) - } - this.matches[index][e] = true - } - // This was the last one, and no stats were needed - return - } - - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) - newPattern = [prefix, e] - else - newPattern = [e] - this._process(newPattern.concat(remain), index, inGlobStar) - } -} - - -GlobSync.prototype._emitMatch = function (index, e) { - var abs = this._makeAbs(e) - if (this.mark) - e = this._mark(e) - - if (this.matches[index][e]) - return - - if (this.nodir) { - var c = this.cache[this._makeAbs(e)] - if (c === 'DIR' || Array.isArray(c)) - return - } - - this.matches[index][e] = true - if (this.stat) - this._stat(e) -} - - -GlobSync.prototype._readdirInGlobStar = function (abs) { - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false) - - var entries - var lstat - var stat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - // lstat failed, doesn't exist - return null - } - - var isSym = lstat.isSymbolicLink() - this.symlinks[abs] = isSym - - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && !lstat.isDirectory()) - this.cache[abs] = 'FILE' - else - entries = this._readdir(abs, false) - - return entries -} - -GlobSync.prototype._readdir = function (abs, inGlobStar) { - var entries - - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs) - - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return null - - if (Array.isArray(c)) - return c - } - - try { - return this._readdirEntries(abs, fs.readdirSync(abs)) - } catch (er) { - this._readdirError(abs, er) - return null - } -} - -GlobSync.prototype._readdirEntries = function (abs, entries) { - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } - - this.cache[abs] = entries - - // mark and cache dir-ness - return entries -} - -GlobSync.prototype._readdirError = function (f, er) { - // handle errors, and cache the information - switch (er.code) { - case 'ENOTDIR': // totally normal. means it *does* exist. - this.cache[this._makeAbs(f)] = 'FILE' - break - - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break - - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) throw er - if (!this.silent) console.error('glob error', er) - break - } -} - -GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - - var entries = this._readdir(abs, inGlobStar) - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return - - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) - - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false) - - var len = entries.length - var isSym = this.symlinks[abs] - - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return - - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue - - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true) - - var below = gspref.concat(entries[i], remain) - this._process(below, index, true) - } -} - -GlobSync.prototype._processSimple = function (prefix, index) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var exists = this._stat(prefix) - - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - // If it doesn't exist, then just mark the lack of results - if (!exists) - return - - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' - } - } - - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') - - // Mark this as a match - this.matches[index][prefix] = true -} - -// Returns either 'DIR', 'FILE', or false -GlobSync.prototype._stat = function (f) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' - - if (f.length > this.maxLength) - return false - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] - - if (Array.isArray(c)) - c = 'DIR' - - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return c - - if (needDir && c === 'FILE') - return false - - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - - var exists - var stat = this.statCache[abs] - if (!stat) { - var lstat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - return false - } - - if (lstat.isSymbolicLink()) { - try { - stat = fs.statSync(abs) - } catch (er) { - stat = lstat - } - } else { - stat = lstat - } - } - - this.statCache[abs] = stat - - var c = stat.isDirectory() ? 'DIR' : 'FILE' - this.cache[abs] = this.cache[abs] || c - - if (needDir && c !== 'DIR') - return false - - return c -} - -GlobSync.prototype._mark = function (p) { - return common.mark(this, p) -} - -GlobSync.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/LICENSE deleted file mode 100644 index dea3013..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter - -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. - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/README.md deleted file mode 100644 index b1c5665..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/README.md +++ /dev/null @@ -1,42 +0,0 @@ -Browser-friendly inheritance fully compatible with standard node.js -[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). - -This package exports standard `inherits` from node.js `util` module in -node environment, but also provides alternative browser-friendly -implementation through [browser -field](https://gist.github.com/shtylman/4339901). Alternative -implementation is a literal copy of standard one located in standalone -module to avoid requiring of `util`. It also has a shim for old -browsers with no `Object.create` support. - -While keeping you sure you are using standard `inherits` -implementation in node.js environment, it allows bundlers such as -[browserify](https://github.com/substack/node-browserify) to not -include full `util` package to your client code if all you need is -just `inherits` function. It worth, because browser shim for `util` -package is large and `inherits` is often the single function you need -from it. - -It's recommended to use this package instead of -`require('util').inherits` for any code that has chances to be used -not only in node.js but in browser too. - -## usage - -```js -var inherits = require('inherits'); -// then use exactly as the standard one -``` - -## note on version ~1.0 - -Version ~1.0 had completely different motivation and is not compatible -neither with 2.0 nor with standard node.js `inherits`. - -If you are using version ~1.0 and planning to switch to ~2.0, be -careful: - -* new version uses `super_` instead of `super` for referencing - superclass -* new version overwrites current prototype while old one preserves any - existing fields on it diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits.js deleted file mode 100644 index 29f5e24..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('util').inherits diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits_browser.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits_browser.js deleted file mode 100644 index c1e78a7..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/inherits_browser.js +++ /dev/null @@ -1,23 +0,0 @@ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/package.json deleted file mode 100644 index 99269b1..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "inherits", - "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", - "version": "2.0.1", - "keywords": [ - "inheritance", - "class", - "klass", - "oop", - "object-oriented", - "inherits", - "browser", - "browserify" - ], - "main": "./inherits.js", - "browser": "./inherits_browser.js", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/inherits" - }, - "license": "ISC", - "scripts": { - "test": "node test" - }, - "readme": "Browser-friendly inheritance fully compatible with standard node.js\n[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).\n\nThis package exports standard `inherits` from node.js `util` module in\nnode environment, but also provides alternative browser-friendly\nimplementation through [browser\nfield](https://gist.github.com/shtylman/4339901). Alternative\nimplementation is a literal copy of standard one located in standalone\nmodule to avoid requiring of `util`. It also has a shim for old\nbrowsers with no `Object.create` support.\n\nWhile keeping you sure you are using standard `inherits`\nimplementation in node.js environment, it allows bundlers such as\n[browserify](https://github.com/substack/node-browserify) to not\ninclude full `util` package to your client code if all you need is\njust `inherits` function. It worth, because browser shim for `util`\npackage is large and `inherits` is often the single function you need\nfrom it.\n\nIt's recommended to use this package instead of\n`require('util').inherits` for any code that has chances to be used\nnot only in node.js but in browser too.\n\n## usage\n\n```js\nvar inherits = require('inherits');\n// then use exactly as the standard one\n```\n\n## note on version ~1.0\n\nVersion ~1.0 had completely different motivation and is not compatible\nneither with 2.0 nor with standard node.js `inherits`.\n\nIf you are using version ~1.0 and planning to switch to ~2.0, be\ncareful:\n\n* new version uses `super_` instead of `super` for referencing\n superclass\n* new version overwrites current prototype while old one preserves any\n existing fields on it\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/isaacs/inherits/issues" - }, - "_id": "inherits@2.0.1", - "dist": { - "shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "tarball": "http://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - }, - "_from": "inherits@*", - "_npmVersion": "1.3.8", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", - "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "homepage": "https://github.com/isaacs/inherits" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/test.js deleted file mode 100644 index fc53012..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/inherits/test.js +++ /dev/null @@ -1,25 +0,0 @@ -var inherits = require('./inherits.js') -var assert = require('assert') - -function test(c) { - assert(c.constructor === Child) - assert(c.constructor.super_ === Parent) - assert(Object.getPrototypeOf(c) === Child.prototype) - assert(Object.getPrototypeOf(Object.getPrototypeOf(c)) === Parent.prototype) - assert(c instanceof Child) - assert(c instanceof Parent) -} - -function Child() { - Parent.call(this) - test(this) -} - -function Parent() {} - -inherits(Child, Parent) - -var c = new Child -test(c) - -console.log('ok') diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.npmignore deleted file mode 100644 index 9303c34..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -npm-debug.log \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.travis.yml deleted file mode 100644 index c693a93..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - 0.6 - - 0.8 - - "0.10" diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/LICENSE deleted file mode 100644 index 432d1ae..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/cmd.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/cmd.js deleted file mode 100755 index d95de15..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/cmd.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -var mkdirp = require('../'); -var minimist = require('minimist'); -var fs = require('fs'); - -var argv = minimist(process.argv.slice(2), { - alias: { m: 'mode', h: 'help' }, - string: [ 'mode' ] -}); -if (argv.help) { - fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout); - return; -} - -var paths = argv._.slice(); -var mode = argv.mode ? parseInt(argv.mode, 8) : undefined; - -(function next () { - if (paths.length === 0) return; - var p = paths.shift(); - - if (mode === undefined) mkdirp(p, cb) - else mkdirp(p, mode, cb) - - function cb (err) { - if (err) { - console.error(err.message); - process.exit(1); - } - else next(); - } -})(); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/usage.txt b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/usage.txt deleted file mode 100644 index f952aa2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/bin/usage.txt +++ /dev/null @@ -1,12 +0,0 @@ -usage: mkdirp [DIR1,DIR2..] {OPTIONS} - - Create each supplied directory including any necessary parent directories that - don't yet exist. - - If the directory already exists, do nothing. - -OPTIONS are: - - -m, --mode If a directory needs to be created, set the mode as an octal - permission string. - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/examples/pow.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/examples/pow.js deleted file mode 100644 index e692421..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/examples/pow.js +++ /dev/null @@ -1,6 +0,0 @@ -var mkdirp = require('mkdirp'); - -mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) console.error(err) - else console.log('pow!') -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/index.js deleted file mode 100644 index a1742b2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/index.js +++ /dev/null @@ -1,97 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; - -function mkdirP (p, opts, f, made) { - if (typeof opts === 'function') { - f = opts; - opts = {}; - } - else if (!opts || typeof opts !== 'object') { - opts = { mode: opts }; - } - - var mode = opts.mode; - var xfs = opts.fs || fs; - - if (mode === undefined) { - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - var cb = f || function () {}; - p = path.resolve(p); - - xfs.mkdir(p, mode, function (er) { - if (!er) { - made = made || p; - return cb(null, made); - } - switch (er.code) { - case 'ENOENT': - mkdirP(path.dirname(p), opts, function (er, made) { - if (er) cb(er, made); - else mkdirP(p, opts, cb, made); - }); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - xfs.stat(p, function (er2, stat) { - // if the stat fails, then that's super weird. - // let the original error be the failure reason. - if (er2 || !stat.isDirectory()) cb(er, made) - else cb(null, made); - }); - break; - } - }); -} - -mkdirP.sync = function sync (p, opts, made) { - if (!opts || typeof opts !== 'object') { - opts = { mode: opts }; - } - - var mode = opts.mode; - var xfs = opts.fs || fs; - - if (mode === undefined) { - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - p = path.resolve(p); - - try { - xfs.mkdirSync(p, mode); - made = made || p; - } - catch (err0) { - switch (err0.code) { - case 'ENOENT' : - made = sync(path.dirname(p), opts, made); - sync(p, opts, made); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - var stat; - try { - stat = xfs.statSync(p); - } - catch (err1) { - throw err0; - } - if (!stat.isDirectory()) throw err0; - break; - } - } - - return made; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/.travis.yml deleted file mode 100644 index cc4dba2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - "0.8" - - "0.10" diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/LICENSE deleted file mode 100644 index ee27ba4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/example/parse.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/example/parse.js deleted file mode 100644 index abff3e8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/example/parse.js +++ /dev/null @@ -1,2 +0,0 @@ -var argv = require('../')(process.argv.slice(2)); -console.dir(argv); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/index.js deleted file mode 100644 index 584f551..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/index.js +++ /dev/null @@ -1,187 +0,0 @@ -module.exports = function (args, opts) { - if (!opts) opts = {}; - - var flags = { bools : {}, strings : {} }; - - [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { - flags.bools[key] = true; - }); - - [].concat(opts.string).filter(Boolean).forEach(function (key) { - flags.strings[key] = true; - }); - - var aliases = {}; - Object.keys(opts.alias || {}).forEach(function (key) { - aliases[key] = [].concat(opts.alias[key]); - aliases[key].forEach(function (x) { - aliases[x] = [key].concat(aliases[key].filter(function (y) { - return x !== y; - })); - }); - }); - - var defaults = opts['default'] || {}; - - var argv = { _ : [] }; - Object.keys(flags.bools).forEach(function (key) { - setArg(key, defaults[key] === undefined ? false : defaults[key]); - }); - - var notFlags = []; - - if (args.indexOf('--') !== -1) { - notFlags = args.slice(args.indexOf('--')+1); - args = args.slice(0, args.indexOf('--')); - } - - function setArg (key, val) { - var value = !flags.strings[key] && isNumber(val) - ? Number(val) : val - ; - setKey(argv, key.split('.'), value); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), value); - }); - } - - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - - if (/^--.+=/.test(arg)) { - // Using [\s\S] instead of . because js doesn't support the - // 'dotall' regex modifier. See: - // http://stackoverflow.com/a/1068308/13216 - var m = arg.match(/^--([^=]+)=([\s\S]*)$/); - setArg(m[1], m[2]); - } - else if (/^--no-.+/.test(arg)) { - var key = arg.match(/^--no-(.+)/)[1]; - setArg(key, false); - } - else if (/^--.+/.test(arg)) { - var key = arg.match(/^--(.+)/)[1]; - var next = args[i + 1]; - if (next !== undefined && !/^-/.test(next) - && !flags.bools[key] - && (aliases[key] ? !flags.bools[aliases[key]] : true)) { - setArg(key, next); - i++; - } - else if (/^(true|false)$/.test(next)) { - setArg(key, next === 'true'); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true); - } - } - else if (/^-[^-]+/.test(arg)) { - var letters = arg.slice(1,-1).split(''); - - var broken = false; - for (var j = 0; j < letters.length; j++) { - var next = arg.slice(j+2); - - if (next === '-') { - setArg(letters[j], next) - continue; - } - - if (/[A-Za-z]/.test(letters[j]) - && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { - setArg(letters[j], next); - broken = true; - break; - } - - if (letters[j+1] && letters[j+1].match(/\W/)) { - setArg(letters[j], arg.slice(j+2)); - broken = true; - break; - } - else { - setArg(letters[j], flags.strings[letters[j]] ? '' : true); - } - } - - var key = arg.slice(-1)[0]; - if (!broken && key !== '-') { - if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) - && !flags.bools[key] - && (aliases[key] ? !flags.bools[aliases[key]] : true)) { - setArg(key, args[i+1]); - i++; - } - else if (args[i+1] && /true|false/.test(args[i+1])) { - setArg(key, args[i+1] === 'true'); - i++; - } - else { - setArg(key, flags.strings[key] ? '' : true); - } - } - } - else { - argv._.push( - flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) - ); - } - } - - Object.keys(defaults).forEach(function (key) { - if (!hasKey(argv, key.split('.'))) { - setKey(argv, key.split('.'), defaults[key]); - - (aliases[key] || []).forEach(function (x) { - setKey(argv, x.split('.'), defaults[key]); - }); - } - }); - - notFlags.forEach(function(key) { - argv._.push(key); - }); - - return argv; -}; - -function hasKey (obj, keys) { - var o = obj; - keys.slice(0,-1).forEach(function (key) { - o = (o[key] || {}); - }); - - var key = keys[keys.length - 1]; - return key in o; -} - -function setKey (obj, keys, value) { - var o = obj; - keys.slice(0,-1).forEach(function (key) { - if (o[key] === undefined) o[key] = {}; - o = o[key]; - }); - - var key = keys[keys.length - 1]; - if (o[key] === undefined || typeof o[key] === 'boolean') { - o[key] = value; - } - else if (Array.isArray(o[key])) { - o[key].push(value); - } - else { - o[key] = [ o[key], value ]; - } -} - -function isNumber (x) { - if (typeof x === 'number') return true; - if (/^0x[0-9a-f]+$/i.test(x)) return true; - return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); -} - -function longest (xs) { - return Math.max.apply(null, xs.map(function (x) { return x.length })); -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/package.json deleted file mode 100644 index 7cd80f4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "minimist", - "version": "0.0.8", - "description": "parse argument options", - "main": "index.js", - "devDependencies": { - "tape": "~1.0.4", - "tap": "~0.4.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/6..latest", - "ff/5", - "firefox/latest", - "chrome/10", - "chrome/latest", - "safari/5.1", - "safari/latest", - "opera/12" - ] - }, - "repository": { - "type": "git", - "url": "git://github.com/substack/minimist.git" - }, - "homepage": "https://github.com/substack/minimist", - "keywords": [ - "argv", - "getopt", - "parser", - "optimist" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/substack/minimist/issues" - }, - "_id": "minimist@0.0.8", - "dist": { - "shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", - "tarball": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - }, - "_from": "minimist@0.0.8", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", - "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/readme.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/readme.markdown deleted file mode 100644 index c256353..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/readme.markdown +++ /dev/null @@ -1,73 +0,0 @@ -# minimist - -parse argument options - -This module is the guts of optimist's argument parser without all the -fanciful decoration. - -[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist) - -[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist) - -# example - -``` js -var argv = require('minimist')(process.argv.slice(2)); -console.dir(argv); -``` - -``` -$ node example/parse.js -a beep -b boop -{ _: [], a: 'beep', b: 'boop' } -``` - -``` -$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz -{ _: [ 'foo', 'bar', 'baz' ], - x: 3, - y: 4, - n: 5, - a: true, - b: true, - c: true, - beep: 'boop' } -``` - -# methods - -``` js -var parseArgs = require('minimist') -``` - -## var argv = parseArgs(args, opts={}) - -Return an argument object `argv` populated with the array arguments from `args`. - -`argv._` contains all the arguments that didn't have an option associated with -them. - -Numeric-looking arguments will be returned as numbers unless `opts.string` or -`opts.boolean` is set for that argument name. - -Any arguments after `'--'` will not be parsed and will end up in `argv._`. - -options can be: - -* `opts.string` - a string or array of strings argument names to always treat as -strings -* `opts.boolean` - a string or array of strings to always treat as booleans -* `opts.alias` - an object mapping string names to strings or arrays of string -argument names to use as aliases -* `opts.default` - an object mapping string argument names to default values - -# install - -With [npm](https://npmjs.org) do: - -``` -npm install minimist -``` - -# license - -MIT diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dash.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dash.js deleted file mode 100644 index 8b034b9..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dash.js +++ /dev/null @@ -1,24 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('-', function (t) { - t.plan(5); - t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] }); - t.deepEqual(parse([ '-' ]), { _: [ '-' ] }); - t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] }); - t.deepEqual( - parse([ '-b', '-' ], { boolean: 'b' }), - { b: true, _: [ '-' ] } - ); - t.deepEqual( - parse([ '-s', '-' ], { string: 's' }), - { s: '-', _: [] } - ); -}); - -test('-a -- b', function (t) { - t.plan(3); - t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] }); - t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); - t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/default_bool.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/default_bool.js deleted file mode 100644 index f0041ee..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/default_bool.js +++ /dev/null @@ -1,20 +0,0 @@ -var test = require('tape'); -var parse = require('../'); - -test('boolean default true', function (t) { - var argv = parse([], { - boolean: 'sometrue', - default: { sometrue: true } - }); - t.equal(argv.sometrue, true); - t.end(); -}); - -test('boolean default false', function (t) { - var argv = parse([], { - boolean: 'somefalse', - default: { somefalse: false } - }); - t.equal(argv.somefalse, false); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dotted.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dotted.js deleted file mode 100644 index ef0ae34..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/dotted.js +++ /dev/null @@ -1,16 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('dotted alias', function (t) { - var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); - t.equal(argv.a.b, 22); - t.equal(argv.aa.bb, 22); - t.end(); -}); - -test('dotted default', function (t) { - var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); - t.equal(argv.a.b, 11); - t.equal(argv.aa.bb, 11); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/long.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/long.js deleted file mode 100644 index 5d3a1e0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/long.js +++ /dev/null @@ -1,31 +0,0 @@ -var test = require('tape'); -var parse = require('../'); - -test('long opts', function (t) { - t.deepEqual( - parse([ '--bool' ]), - { bool : true, _ : [] }, - 'long boolean' - ); - t.deepEqual( - parse([ '--pow', 'xixxle' ]), - { pow : 'xixxle', _ : [] }, - 'long capture sp' - ); - t.deepEqual( - parse([ '--pow=xixxle' ]), - { pow : 'xixxle', _ : [] }, - 'long capture eq' - ); - t.deepEqual( - parse([ '--host', 'localhost', '--port', '555' ]), - { host : 'localhost', port : 555, _ : [] }, - 'long captures sp' - ); - t.deepEqual( - parse([ '--host=localhost', '--port=555' ]), - { host : 'localhost', port : 555, _ : [] }, - 'long captures eq' - ); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse.js deleted file mode 100644 index 8a90646..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse.js +++ /dev/null @@ -1,318 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('parse args', function (t) { - t.deepEqual( - parse([ '--no-moo' ]), - { moo : false, _ : [] }, - 'no' - ); - t.deepEqual( - parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]), - { v : ['a','b','c'], _ : [] }, - 'multi' - ); - t.end(); -}); - -test('comprehensive', function (t) { - t.deepEqual( - parse([ - '--name=meowmers', 'bare', '-cats', 'woo', - '-h', 'awesome', '--multi=quux', - '--key', 'value', - '-b', '--bool', '--no-meep', '--multi=baz', - '--', '--not-a-flag', 'eek' - ]), - { - c : true, - a : true, - t : true, - s : 'woo', - h : 'awesome', - b : true, - bool : true, - key : 'value', - multi : [ 'quux', 'baz' ], - meep : false, - name : 'meowmers', - _ : [ 'bare', '--not-a-flag', 'eek' ] - } - ); - t.end(); -}); - -test('nums', function (t) { - var argv = parse([ - '-x', '1234', - '-y', '5.67', - '-z', '1e7', - '-w', '10f', - '--hex', '0xdeadbeef', - '789' - ]); - t.deepEqual(argv, { - x : 1234, - y : 5.67, - z : 1e7, - w : '10f', - hex : 0xdeadbeef, - _ : [ 789 ] - }); - t.deepEqual(typeof argv.x, 'number'); - t.deepEqual(typeof argv.y, 'number'); - t.deepEqual(typeof argv.z, 'number'); - t.deepEqual(typeof argv.w, 'string'); - t.deepEqual(typeof argv.hex, 'number'); - t.deepEqual(typeof argv._[0], 'number'); - t.end(); -}); - -test('flag boolean', function (t) { - var argv = parse([ '-t', 'moo' ], { boolean: 't' }); - t.deepEqual(argv, { t : true, _ : [ 'moo' ] }); - t.deepEqual(typeof argv.t, 'boolean'); - t.end(); -}); - -test('flag boolean value', function (t) { - var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], { - boolean: [ 't', 'verbose' ], - default: { verbose: true } - }); - - t.deepEqual(argv, { - verbose: false, - t: true, - _: ['moo'] - }); - - t.deepEqual(typeof argv.verbose, 'boolean'); - t.deepEqual(typeof argv.t, 'boolean'); - t.end(); -}); - -test('flag boolean default false', function (t) { - var argv = parse(['moo'], { - boolean: ['t', 'verbose'], - default: { verbose: false, t: false } - }); - - t.deepEqual(argv, { - verbose: false, - t: false, - _: ['moo'] - }); - - t.deepEqual(typeof argv.verbose, 'boolean'); - t.deepEqual(typeof argv.t, 'boolean'); - t.end(); - -}); - -test('boolean groups', function (t) { - var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], { - boolean: ['x','y','z'] - }); - - t.deepEqual(argv, { - x : true, - y : false, - z : true, - _ : [ 'one', 'two', 'three' ] - }); - - t.deepEqual(typeof argv.x, 'boolean'); - t.deepEqual(typeof argv.y, 'boolean'); - t.deepEqual(typeof argv.z, 'boolean'); - t.end(); -}); - -test('newlines in params' , function (t) { - var args = parse([ '-s', "X\nX" ]) - t.deepEqual(args, { _ : [], s : "X\nX" }); - - // reproduce in bash: - // VALUE="new - // line" - // node program.js --s="$VALUE" - args = parse([ "--s=X\nX" ]) - t.deepEqual(args, { _ : [], s : "X\nX" }); - t.end(); -}); - -test('strings' , function (t) { - var s = parse([ '-s', '0001234' ], { string: 's' }).s; - t.equal(s, '0001234'); - t.equal(typeof s, 'string'); - - var x = parse([ '-x', '56' ], { string: 'x' }).x; - t.equal(x, '56'); - t.equal(typeof x, 'string'); - t.end(); -}); - -test('stringArgs', function (t) { - var s = parse([ ' ', ' ' ], { string: '_' })._; - t.same(s.length, 2); - t.same(typeof s[0], 'string'); - t.same(s[0], ' '); - t.same(typeof s[1], 'string'); - t.same(s[1], ' '); - t.end(); -}); - -test('empty strings', function(t) { - var s = parse([ '-s' ], { string: 's' }).s; - t.equal(s, ''); - t.equal(typeof s, 'string'); - - var str = parse([ '--str' ], { string: 'str' }).str; - t.equal(str, ''); - t.equal(typeof str, 'string'); - - var letters = parse([ '-art' ], { - string: [ 'a', 't' ] - }); - - t.equal(letters.a, ''); - t.equal(letters.r, true); - t.equal(letters.t, ''); - - t.end(); -}); - - -test('slashBreak', function (t) { - t.same( - parse([ '-I/foo/bar/baz' ]), - { I : '/foo/bar/baz', _ : [] } - ); - t.same( - parse([ '-xyz/foo/bar/baz' ]), - { x : true, y : true, z : '/foo/bar/baz', _ : [] } - ); - t.end(); -}); - -test('alias', function (t) { - var argv = parse([ '-f', '11', '--zoom', '55' ], { - alias: { z: 'zoom' } - }); - t.equal(argv.zoom, 55); - t.equal(argv.z, argv.zoom); - t.equal(argv.f, 11); - t.end(); -}); - -test('multiAlias', function (t) { - var argv = parse([ '-f', '11', '--zoom', '55' ], { - alias: { z: [ 'zm', 'zoom' ] } - }); - t.equal(argv.zoom, 55); - t.equal(argv.z, argv.zoom); - t.equal(argv.z, argv.zm); - t.equal(argv.f, 11); - t.end(); -}); - -test('nested dotted objects', function (t) { - var argv = parse([ - '--foo.bar', '3', '--foo.baz', '4', - '--foo.quux.quibble', '5', '--foo.quux.o_O', - '--beep.boop' - ]); - - t.same(argv.foo, { - bar : 3, - baz : 4, - quux : { - quibble : 5, - o_O : true - } - }); - t.same(argv.beep, { boop : true }); - t.end(); -}); - -test('boolean and alias with chainable api', function (t) { - var aliased = [ '-h', 'derp' ]; - var regular = [ '--herp', 'derp' ]; - var opts = { - herp: { alias: 'h', boolean: true } - }; - var aliasedArgv = parse(aliased, { - boolean: 'herp', - alias: { h: 'herp' } - }); - var propertyArgv = parse(regular, { - boolean: 'herp', - alias: { h: 'herp' } - }); - var expected = { - herp: true, - h: true, - '_': [ 'derp' ] - }; - - t.same(aliasedArgv, expected); - t.same(propertyArgv, expected); - t.end(); -}); - -test('boolean and alias with options hash', function (t) { - var aliased = [ '-h', 'derp' ]; - var regular = [ '--herp', 'derp' ]; - var opts = { - alias: { 'h': 'herp' }, - boolean: 'herp' - }; - var aliasedArgv = parse(aliased, opts); - var propertyArgv = parse(regular, opts); - var expected = { - herp: true, - h: true, - '_': [ 'derp' ] - }; - t.same(aliasedArgv, expected); - t.same(propertyArgv, expected); - t.end(); -}); - -test('boolean and alias using explicit true', function (t) { - var aliased = [ '-h', 'true' ]; - var regular = [ '--herp', 'true' ]; - var opts = { - alias: { h: 'herp' }, - boolean: 'h' - }; - var aliasedArgv = parse(aliased, opts); - var propertyArgv = parse(regular, opts); - var expected = { - herp: true, - h: true, - '_': [ ] - }; - - t.same(aliasedArgv, expected); - t.same(propertyArgv, expected); - t.end(); -}); - -// regression, see https://github.com/substack/node-optimist/issues/71 -test('boolean and --x=true', function(t) { - var parsed = parse(['--boool', '--other=true'], { - boolean: 'boool' - }); - - t.same(parsed.boool, true); - t.same(parsed.other, 'true'); - - parsed = parse(['--boool', '--other=false'], { - boolean: 'boool' - }); - - t.same(parsed.boool, true); - t.same(parsed.other, 'false'); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js deleted file mode 100644 index 21851b0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js +++ /dev/null @@ -1,9 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('parse with modifier functions' , function (t) { - t.plan(1); - - var argv = parse([ '-b', '123' ], { boolean: 'b' }); - t.deepEqual(argv, { b: true, _: ['123'] }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/short.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/short.js deleted file mode 100644 index d513a1c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/short.js +++ /dev/null @@ -1,67 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('numeric short args', function (t) { - t.plan(2); - t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] }); - t.deepEqual( - parse([ '-123', '456' ]), - { 1: true, 2: true, 3: 456, _: [] } - ); -}); - -test('short', function (t) { - t.deepEqual( - parse([ '-b' ]), - { b : true, _ : [] }, - 'short boolean' - ); - t.deepEqual( - parse([ 'foo', 'bar', 'baz' ]), - { _ : [ 'foo', 'bar', 'baz' ] }, - 'bare' - ); - t.deepEqual( - parse([ '-cats' ]), - { c : true, a : true, t : true, s : true, _ : [] }, - 'group' - ); - t.deepEqual( - parse([ '-cats', 'meow' ]), - { c : true, a : true, t : true, s : 'meow', _ : [] }, - 'short group next' - ); - t.deepEqual( - parse([ '-h', 'localhost' ]), - { h : 'localhost', _ : [] }, - 'short capture' - ); - t.deepEqual( - parse([ '-h', 'localhost', '-p', '555' ]), - { h : 'localhost', p : 555, _ : [] }, - 'short captures' - ); - t.end(); -}); - -test('mixed short bool and capture', function (t) { - t.same( - parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), - { - f : true, p : 555, h : 'localhost', - _ : [ 'script.js' ] - } - ); - t.end(); -}); - -test('short and long', function (t) { - t.deepEqual( - parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), - { - f : true, p : 555, h : 'localhost', - _ : [ 'script.js' ] - } - ); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/whitespace.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/whitespace.js deleted file mode 100644 index 8a52a58..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/node_modules/minimist/test/whitespace.js +++ /dev/null @@ -1,8 +0,0 @@ -var parse = require('../'); -var test = require('tape'); - -test('whitespace should be whitespace' , function (t) { - t.plan(1); - var x = parse([ '-x', '\t' ]).x; - t.equal(x, '\t'); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/package.json deleted file mode 100644 index becdf58..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "mkdirp", - "description": "Recursively mkdir, like `mkdir -p`", - "version": "0.5.0", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "main": "./index", - "keywords": [ - "mkdir", - "directory" - ], - "repository": { - "type": "git", - "url": "https://github.com/substack/node-mkdirp.git" - }, - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": { - "minimist": "0.0.8" - }, - "devDependencies": { - "tap": "~0.4.0", - "mock-fs": "~2.2.0" - }, - "bin": { - "mkdirp": "bin/cmd.js" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/substack/node-mkdirp/issues" - }, - "homepage": "https://github.com/substack/node-mkdirp", - "_id": "mkdirp@0.5.0", - "dist": { - "shasum": "1d73076a6df986cd9344e15e71fcc05a4c9abf12", - "tarball": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz" - }, - "_from": "mkdirp@^0.5.0", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "1d73076a6df986cd9344e15e71fcc05a4c9abf12", - "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/readme.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/readme.markdown deleted file mode 100644 index 3cc1315..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/readme.markdown +++ /dev/null @@ -1,100 +0,0 @@ -# mkdirp - -Like `mkdir -p`, but in node.js! - -[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) - -# example - -## pow.js - -```js -var mkdirp = require('mkdirp'); - -mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) console.error(err) - else console.log('pow!') -}); -``` - -Output - -``` -pow! -``` - -And now /tmp/foo/bar/baz exists, huzzah! - -# methods - -```js -var mkdirp = require('mkdirp'); -``` - -## mkdirp(dir, opts, cb) - -Create a new directory and any necessary subdirectories at `dir` with octal -permission string `opts.mode`. If `opts` is a non-object, it will be treated as -the `opts.mode`. - -If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -`cb(err, made)` fires with the error or the first directory `made` -that had to be created, if any. - -You can optionally pass in an alternate `fs` implementation by passing in -`opts.fs`. Your implementation should have `opts.fs.mkdir(path, mode, cb)` and -`opts.fs.stat(path, cb)`. - -## mkdirp.sync(dir, opts) - -Synchronously create a new directory and any necessary subdirectories at `dir` -with octal permission string `opts.mode`. If `opts` is a non-object, it will be -treated as the `opts.mode`. - -If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -Returns the first directory that had to be created, if any. - -You can optionally pass in an alternate `fs` implementation by passing in -`opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)` and -`opts.fs.statSync(path)`. - -# usage - -This package also ships with a `mkdirp` command. - -``` -usage: mkdirp [DIR1,DIR2..] {OPTIONS} - - Create each supplied directory including any necessary parent directories that - don't yet exist. - - If the directory already exists, do nothing. - -OPTIONS are: - - -m, --mode If a directory needs to be created, set the mode as an octal - permission string. - -``` - -# install - -With [npm](http://npmjs.org) do: - -``` -npm install mkdirp -``` - -to get the library, or - -``` -npm install -g mkdirp -``` - -to get the command. - -# license - -MIT diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/chmod.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/chmod.js deleted file mode 100644 index 520dcb8..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/chmod.js +++ /dev/null @@ -1,38 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -var ps = [ '', 'tmp' ]; - -for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); -} - -var file = ps.join('/'); - -test('chmod-pre', function (t) { - var mode = 0744 - mkdirp(file, mode, function (er) { - t.ifError(er, 'should not error'); - fs.stat(file, function (er, stat) { - t.ifError(er, 'should exist'); - t.ok(stat && stat.isDirectory(), 'should be directory'); - t.equal(stat && stat.mode & 0777, mode, 'should be 0744'); - t.end(); - }); - }); -}); - -test('chmod', function (t) { - var mode = 0755 - mkdirp(file, mode, function (er) { - t.ifError(er, 'should not error'); - fs.stat(file, function (er, stat) { - t.ifError(er, 'should exist'); - t.ok(stat && stat.isDirectory(), 'should be directory'); - t.end(); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/clobber.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/clobber.js deleted file mode 100644 index 0eb7099..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/clobber.js +++ /dev/null @@ -1,37 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -var ps = [ '', 'tmp' ]; - -for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); -} - -var file = ps.join('/'); - -// a file in the way -var itw = ps.slice(0, 3).join('/'); - - -test('clobber-pre', function (t) { - console.error("about to write to "+itw) - fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.'); - - fs.stat(itw, function (er, stat) { - t.ifError(er) - t.ok(stat && stat.isFile(), 'should be file') - t.end() - }) -}) - -test('clobber', function (t) { - t.plan(2); - mkdirp(file, 0755, function (err) { - t.ok(err); - t.equal(err.code, 'ENOTDIR'); - t.end(); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/mkdirp.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/mkdirp.js deleted file mode 100644 index 3b624dd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/mkdirp.js +++ /dev/null @@ -1,26 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('woo', function (t) { - t.plan(5); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - mkdirp(file, 0755, function (err) { - t.ifError(err); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }) - }) - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs.js deleted file mode 100644 index f1fbeca..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs.js +++ /dev/null @@ -1,27 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var test = require('tap').test; -var mockfs = require('mock-fs'); - -test('opts.fs', function (t) { - t.plan(5); - - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/beep/boop/' + [x,y,z].join('/'); - var xfs = mockfs.fs(); - - mkdirp(file, { fs: xfs, mode: 0755 }, function (err) { - t.ifError(err); - xfs.exists(file, function (ex) { - t.ok(ex, 'created file'); - xfs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs_sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs_sync.js deleted file mode 100644 index 224b506..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/opts_fs_sync.js +++ /dev/null @@ -1,25 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var test = require('tap').test; -var mockfs = require('mock-fs'); - -test('opts.fs sync', function (t) { - t.plan(4); - - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/beep/boop/' + [x,y,z].join('/'); - var xfs = mockfs.fs(); - - mkdirp.sync(file, { fs: xfs, mode: 0755 }); - xfs.exists(file, function (ex) { - t.ok(ex, 'created file'); - xfs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm.js deleted file mode 100644 index 2c97590..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm.js +++ /dev/null @@ -1,30 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('async perm', function (t) { - t.plan(5); - var file = '/tmp/' + (Math.random() * (1<<30)).toString(16); - - mkdirp(file, 0755, function (err) { - t.ifError(err); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }) - }) - }); -}); - -test('async root perm', function (t) { - mkdirp('/tmp', 0755, function (err) { - if (err) t.fail(err); - t.end(); - }); - t.end(); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm_sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm_sync.js deleted file mode 100644 index 327e54b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/perm_sync.js +++ /dev/null @@ -1,34 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('sync perm', function (t) { - t.plan(4); - var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json'; - - mkdirp.sync(file, 0755); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }); -}); - -test('sync root perm', function (t) { - t.plan(3); - - var file = '/tmp'; - mkdirp.sync(file, 0755); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.ok(stat.isDirectory(), 'target not a directory'); - }) - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/race.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/race.js deleted file mode 100644 index 7c295f4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/race.js +++ /dev/null @@ -1,40 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('race', function (t) { - t.plan(6); - var ps = [ '', 'tmp' ]; - - for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); - } - var file = ps.join('/'); - - var res = 2; - mk(file, function () { - if (--res === 0) t.end(); - }); - - mk(file, function () { - if (--res === 0) t.end(); - }); - - function mk (file, cb) { - mkdirp(file, 0755, function (err) { - t.ifError(err); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - if (cb) cb(); - }); - }) - }); - } -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/rel.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/rel.js deleted file mode 100644 index d1f175c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/rel.js +++ /dev/null @@ -1,30 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('rel', function (t) { - t.plan(5); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var cwd = process.cwd(); - process.chdir('/tmp'); - - var file = [x,y,z].join('/'); - - mkdirp(file, 0755, function (err) { - t.ifError(err); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - process.chdir(cwd); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }) - }) - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return.js deleted file mode 100644 index bce68e5..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return.js +++ /dev/null @@ -1,25 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('return value', function (t) { - t.plan(4); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - // should return the first dir created. - // By this point, it would be profoundly surprising if /tmp didn't - // already exist, since every other test makes things in there. - mkdirp(file, function (err, made) { - t.ifError(err); - t.equal(made, '/tmp/' + x); - mkdirp(file, function (err, made) { - t.ifError(err); - t.equal(made, null); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return_sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return_sync.js deleted file mode 100644 index 7c222d3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/return_sync.js +++ /dev/null @@ -1,24 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('return value', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - // should return the first dir created. - // By this point, it would be profoundly surprising if /tmp didn't - // already exist, since every other test makes things in there. - // Note that this will throw on failure, which will fail the test. - var made = mkdirp.sync(file); - t.equal(made, '/tmp/' + x); - - // making the same file again should have no effect. - made = mkdirp.sync(file); - t.equal(made, null); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/root.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/root.js deleted file mode 100644 index 97ad7a2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/root.js +++ /dev/null @@ -1,18 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('root', function (t) { - // '/' on unix, 'c:/' on windows. - var file = path.resolve('/'); - - mkdirp(file, 0755, function (err) { - if (err) throw err - fs.stat(file, function (er, stat) { - if (er) throw er - t.ok(stat.isDirectory(), 'target is a directory'); - t.end(); - }) - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/sync.js deleted file mode 100644 index 88fa432..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/sync.js +++ /dev/null @@ -1,30 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('sync', function (t) { - t.plan(4); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - try { - mkdirp.sync(file, 0755); - } catch (err) { - t.fail(err); - return t.end(); - } - - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask.js deleted file mode 100644 index 82c393a..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask.js +++ /dev/null @@ -1,26 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('implicit mode from umask', function (t) { - t.plan(5); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - mkdirp(file, function (err) { - t.ifError(err); - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, 0777 & (~process.umask())); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }) - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask_sync.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask_sync.js deleted file mode 100644 index e537fbe..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/mkdirp/test/umask_sync.js +++ /dev/null @@ -1,30 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var exists = fs.exists || path.exists; -var test = require('tap').test; - -test('umask sync modes', function (t) { - t.plan(4); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - try { - mkdirp.sync(file); - } catch (err) { - t.fail(err); - return t.end(); - } - - exists(file, function (ex) { - t.ok(ex, 'file created'); - fs.stat(file, function (err, stat) { - t.ifError(err); - t.equal(stat.mode & 0777, (0777 & (~process.umask()))); - t.ok(stat.isDirectory(), 'target not a directory'); - }); - }); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/README.md deleted file mode 100644 index 5aba088..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/README.md +++ /dev/null @@ -1,209 +0,0 @@ -If you want to write an option parser, and have it be good, there are -two ways to do it. The Right Way, and the Wrong Way. - -The Wrong Way is to sit down and write an option parser. We've all done -that. - -The Right Way is to write some complex configurable program with so many -options that you go half-insane just trying to manage them all, and put -it off with duct-tape solutions until you see exactly to the core of the -problem, and finally snap and write an awesome option parser. - -If you want to write an option parser, don't write an option parser. -Write a package manager, or a source control system, or a service -restarter, or an operating system. You probably won't end up with a -good one of those, but if you don't give up, and you are relentless and -diligent enough in your procrastination, you may just end up with a very -nice option parser. - -## USAGE - - // my-program.js - var nopt = require("nopt") - , Stream = require("stream").Stream - , path = require("path") - , knownOpts = { "foo" : [String, null] - , "bar" : [Stream, Number] - , "baz" : path - , "bloo" : [ "big", "medium", "small" ] - , "flag" : Boolean - , "pick" : Boolean - , "many" : [String, Array] - } - , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] - , "b7" : ["--bar", "7"] - , "m" : ["--bloo", "medium"] - , "p" : ["--pick"] - , "f" : ["--flag"] - } - // everything is optional. - // knownOpts and shorthands default to {} - // arg list defaults to process.argv - // slice defaults to 2 - , parsed = nopt(knownOpts, shortHands, process.argv, 2) - console.log(parsed) - -This would give you support for any of the following: - -```bash -$ node my-program.js --foo "blerp" --no-flag -{ "foo" : "blerp", "flag" : false } - -$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag -{ bar: 7, foo: "Mr. Hand", flag: true } - -$ node my-program.js --foo "blerp" -f -----p -{ foo: "blerp", flag: true, pick: true } - -$ node my-program.js -fp --foofoo -{ foo: "Mr. Foo", flag: true, pick: true } - -$ node my-program.js --foofoo -- -fp # -- stops the flag parsing. -{ foo: "Mr. Foo", argv: { remain: ["-fp"] } } - -$ node my-program.js --blatzk -fp # unknown opts are ok. -{ blatzk: true, flag: true, pick: true } - -$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value -{ blatzk: 1000, flag: true, pick: true } - -$ node my-program.js --no-blatzk -fp # unless they start with "no-" -{ blatzk: false, flag: true, pick: true } - -$ node my-program.js --baz b/a/z # known paths are resolved. -{ baz: "/Users/isaacs/b/a/z" } - -# if Array is one of the types, then it can take many -# values, and will always be an array. The other types provided -# specify what types are allowed in the list. - -$ node my-program.js --many 1 --many null --many foo -{ many: ["1", "null", "foo"] } - -$ node my-program.js --many foo -{ many: ["foo"] } -``` - -Read the tests at the bottom of `lib/nopt.js` for more examples of -what this puppy can do. - -## Types - -The following types are supported, and defined on `nopt.typeDefs` - -* String: A normal string. No parsing is done. -* path: A file system path. Gets resolved against cwd if not absolute. -* url: A url. If it doesn't parse, it isn't accepted. -* Number: Must be numeric. -* Date: Must parse as a date. If it does, and `Date` is one of the options, - then it will return a Date object, not a string. -* Boolean: Must be either `true` or `false`. If an option is a boolean, - then it does not need a value, and its presence will imply `true` as - the value. To negate boolean flags, do `--no-whatever` or `--whatever - false` -* NaN: Means that the option is strictly not allowed. Any value will - fail. -* Stream: An object matching the "Stream" class in node. Valuable - for use when validating programmatically. (npm uses this to let you - supply any WriteStream on the `outfd` and `logfd` config options.) -* Array: If `Array` is specified as one of the types, then the value - will be parsed as a list of options. This means that multiple values - can be specified, and that the value will always be an array. - -If a type is an array of values not on this list, then those are -considered valid values. For instance, in the example above, the -`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`, -and any other value will be rejected. - -When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be -interpreted as their JavaScript equivalents. - -You can also mix types and values, or multiple types, in a list. For -instance `{ blah: [Number, null] }` would allow a value to be set to -either a Number or null. When types are ordered, this implies a -preference, and the first type that can be used to properly interpret -the value will be used. - -To define a new type, add it to `nopt.typeDefs`. Each item in that -hash is an object with a `type` member and a `validate` method. The -`type` member is an object that matches what goes in the type list. The -`validate` method is a function that gets called with `validate(data, -key, val)`. Validate methods should assign `data[key]` to the valid -value of `val` if it can be handled properly, or return boolean -`false` if it cannot. - -You can also call `nopt.clean(data, types, typeDefs)` to clean up a -config object and remove its invalid properties. - -## Error Handling - -By default, nopt outputs a warning to standard error when invalid -options are found. You can change this behavior by assigning a method -to `nopt.invalidHandler`. This method will be called with -the offending `nopt.invalidHandler(key, val, types)`. - -If no `nopt.invalidHandler` is assigned, then it will console.error -its whining. If it is assigned to boolean `false` then the warning is -suppressed. - -## Abbreviations - -Yes, they are supported. If you define options like this: - -```javascript -{ "foolhardyelephants" : Boolean -, "pileofmonkeys" : Boolean } -``` - -Then this will work: - -```bash -node program.js --foolhar --pil -node program.js --no-f --pileofmon -# etc. -``` - -## Shorthands - -Shorthands are a hash of shorter option names to a snippet of args that -they expand to. - -If multiple one-character shorthands are all combined, and the -combination does not unambiguously match any other option or shorthand, -then they will be broken up into their constituent parts. For example: - -```json -{ "s" : ["--loglevel", "silent"] -, "g" : "--global" -, "f" : "--force" -, "p" : "--parseable" -, "l" : "--long" -} -``` - -```bash -npm ls -sgflp -# just like doing this: -npm ls --loglevel silent --global --force --long --parseable -``` - -## The Rest of the args - -The config object returned by nopt is given a special member called -`argv`, which is an object with the following fields: - -* `remain`: The remaining args after all the parsing has occurred. -* `original`: The args as they originally appeared. -* `cooked`: The args after flags and shorthands are expanded. - -## Slicing - -Node programs are called with more or less the exact argv as it appears -in C land, after the v8 and node-specific options have been plucked off. -As such, `argv[0]` is always `node` and `argv[1]` is always the -JavaScript program being run. - -That's usually not very useful to you. So they're sliced off by -default. If you want them, then you can pass in `0` as the last -argument, or any other number that you'd like to slice off the start of -the list. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/bin/nopt.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/bin/nopt.js deleted file mode 100755 index 3232d4c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/bin/nopt.js +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env node -var nopt = require("../lib/nopt") - , path = require("path") - , types = { num: Number - , bool: Boolean - , help: Boolean - , list: Array - , "num-list": [Number, Array] - , "str-list": [String, Array] - , "bool-list": [Boolean, Array] - , str: String - , clear: Boolean - , config: Boolean - , length: Number - , file: path - } - , shorthands = { s: [ "--str", "astring" ] - , b: [ "--bool" ] - , nb: [ "--no-bool" ] - , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ] - , "?": ["--help"] - , h: ["--help"] - , H: ["--help"] - , n: [ "--num", "125" ] - , c: ["--config"] - , l: ["--length"] - , f: ["--file"] - } - , parsed = nopt( types - , shorthands - , process.argv - , 2 ) - -console.log("parsed", parsed) - -if (parsed.help) { - console.log("") - console.log("nopt cli tester") - console.log("") - console.log("types") - console.log(Object.keys(types).map(function M (t) { - var type = types[t] - if (Array.isArray(type)) { - return [t, type.map(function (type) { return type.name })] - } - return [t, type && type.name] - }).reduce(function (s, i) { - s[i[0]] = i[1] - return s - }, {})) - console.log("") - console.log("shorthands") - console.log(shorthands) -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/examples/my-program.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/examples/my-program.js deleted file mode 100755 index 142447e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/examples/my-program.js +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node - -//process.env.DEBUG_NOPT = 1 - -// my-program.js -var nopt = require("../lib/nopt") - , Stream = require("stream").Stream - , path = require("path") - , knownOpts = { "foo" : [String, null] - , "bar" : [Stream, Number] - , "baz" : path - , "bloo" : [ "big", "medium", "small" ] - , "flag" : Boolean - , "pick" : Boolean - } - , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] - , "b7" : ["--bar", "7"] - , "m" : ["--bloo", "medium"] - , "p" : ["--pick"] - , "f" : ["--flag", "true"] - , "g" : ["--flag"] - , "s" : "--flag" - } - // everything is optional. - // knownOpts and shorthands default to {} - // arg list defaults to process.argv - // slice defaults to 2 - , parsed = nopt(knownOpts, shortHands, process.argv, 2) - -console.log("parsed =\n"+ require("util").inspect(parsed)) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/lib/nopt.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/lib/nopt.js deleted file mode 100644 index 5309a00..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/lib/nopt.js +++ /dev/null @@ -1,414 +0,0 @@ -// info about each config option. - -var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG - ? function () { console.error.apply(console, arguments) } - : function () {} - -var url = require("url") - , path = require("path") - , Stream = require("stream").Stream - , abbrev = require("abbrev") - -module.exports = exports = nopt -exports.clean = clean - -exports.typeDefs = - { String : { type: String, validate: validateString } - , Boolean : { type: Boolean, validate: validateBoolean } - , url : { type: url, validate: validateUrl } - , Number : { type: Number, validate: validateNumber } - , path : { type: path, validate: validatePath } - , Stream : { type: Stream, validate: validateStream } - , Date : { type: Date, validate: validateDate } - } - -function nopt (types, shorthands, args, slice) { - args = args || process.argv - types = types || {} - shorthands = shorthands || {} - if (typeof slice !== "number") slice = 2 - - debug(types, shorthands, args, slice) - - args = args.slice(slice) - var data = {} - , key - , remain = [] - , cooked = args - , original = args.slice(0) - - parse(args, data, remain, types, shorthands) - // now data is full - clean(data, types, exports.typeDefs) - data.argv = {remain:remain,cooked:cooked,original:original} - Object.defineProperty(data.argv, 'toString', { value: function () { - return this.original.map(JSON.stringify).join(" ") - }, enumerable: false }) - return data -} - -function clean (data, types, typeDefs) { - typeDefs = typeDefs || exports.typeDefs - var remove = {} - , typeDefault = [false, true, null, String, Array] - - Object.keys(data).forEach(function (k) { - if (k === "argv") return - var val = data[k] - , isArray = Array.isArray(val) - , type = types[k] - if (!isArray) val = [val] - if (!type) type = typeDefault - if (type === Array) type = typeDefault.concat(Array) - if (!Array.isArray(type)) type = [type] - - debug("val=%j", val) - debug("types=", type) - val = val.map(function (val) { - // if it's an unknown value, then parse false/true/null/numbers/dates - if (typeof val === "string") { - debug("string %j", val) - val = val.trim() - if ((val === "null" && ~type.indexOf(null)) - || (val === "true" && - (~type.indexOf(true) || ~type.indexOf(Boolean))) - || (val === "false" && - (~type.indexOf(false) || ~type.indexOf(Boolean)))) { - val = JSON.parse(val) - debug("jsonable %j", val) - } else if (~type.indexOf(Number) && !isNaN(val)) { - debug("convert to number", val) - val = +val - } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) { - debug("convert to date", val) - val = new Date(val) - } - } - - if (!types.hasOwnProperty(k)) { - return val - } - - // allow `--no-blah` to set 'blah' to null if null is allowed - if (val === false && ~type.indexOf(null) && - !(~type.indexOf(false) || ~type.indexOf(Boolean))) { - val = null - } - - var d = {} - d[k] = val - debug("prevalidated val", d, val, types[k]) - if (!validate(d, k, val, types[k], typeDefs)) { - if (exports.invalidHandler) { - exports.invalidHandler(k, val, types[k], data) - } else if (exports.invalidHandler !== false) { - debug("invalid: "+k+"="+val, types[k]) - } - return remove - } - debug("validated val", d, val, types[k]) - return d[k] - }).filter(function (val) { return val !== remove }) - - if (!val.length) delete data[k] - else if (isArray) { - debug(isArray, data[k], val) - data[k] = val - } else data[k] = val[0] - - debug("k=%s val=%j", k, val, data[k]) - }) -} - -function validateString (data, k, val) { - data[k] = String(val) -} - -function validatePath (data, k, val) { - if (val === true) return false - if (val === null) return true - - val = String(val) - var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\// - if (val.match(homePattern) && process.env.HOME) { - val = path.resolve(process.env.HOME, val.substr(2)) - } - data[k] = path.resolve(String(val)) - return true -} - -function validateNumber (data, k, val) { - debug("validate Number %j %j %j", k, val, isNaN(val)) - if (isNaN(val)) return false - data[k] = +val -} - -function validateDate (data, k, val) { - debug("validate Date %j %j %j", k, val, Date.parse(val)) - var s = Date.parse(val) - if (isNaN(s)) return false - data[k] = new Date(val) -} - -function validateBoolean (data, k, val) { - if (val instanceof Boolean) val = val.valueOf() - else if (typeof val === "string") { - if (!isNaN(val)) val = !!(+val) - else if (val === "null" || val === "false") val = false - else val = true - } else val = !!val - data[k] = val -} - -function validateUrl (data, k, val) { - val = url.parse(String(val)) - if (!val.host) return false - data[k] = val.href -} - -function validateStream (data, k, val) { - if (!(val instanceof Stream)) return false - data[k] = val -} - -function validate (data, k, val, type, typeDefs) { - // arrays are lists of types. - if (Array.isArray(type)) { - for (var i = 0, l = type.length; i < l; i ++) { - if (type[i] === Array) continue - if (validate(data, k, val, type[i], typeDefs)) return true - } - delete data[k] - return false - } - - // an array of anything? - if (type === Array) return true - - // NaN is poisonous. Means that something is not allowed. - if (type !== type) { - debug("Poison NaN", k, val, type) - delete data[k] - return false - } - - // explicit list of values - if (val === type) { - debug("Explicitly allowed %j", val) - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - return true - } - - // now go through the list of typeDefs, validate against each one. - var ok = false - , types = Object.keys(typeDefs) - for (var i = 0, l = types.length; i < l; i ++) { - debug("test type %j %j %j", k, val, types[i]) - var t = typeDefs[types[i]] - if (t && type === t.type) { - var d = {} - ok = false !== t.validate(d, k, val) - val = d[k] - if (ok) { - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - break - } - } - } - debug("OK? %j (%j %j %j)", ok, k, val, types[i]) - - if (!ok) delete data[k] - return ok -} - -function parse (args, data, remain, types, shorthands) { - debug("parse", args, data, remain) - - var key = null - , abbrevs = abbrev(Object.keys(types)) - , shortAbbr = abbrev(Object.keys(shorthands)) - - for (var i = 0; i < args.length; i ++) { - var arg = args[i] - debug("arg", arg) - - if (arg.match(/^-{2,}$/)) { - // done with keys. - // the rest are args. - remain.push.apply(remain, args.slice(i + 1)) - args[i] = "--" - break - } - var hadEq = false - if (arg.charAt(0) === "-" && arg.length > 1) { - if (arg.indexOf("=") !== -1) { - hadEq = true - var v = arg.split("=") - arg = v.shift() - v = v.join("=") - args.splice.apply(args, [i, 1].concat([arg, v])) - } - - // see if it's a shorthand - // if so, splice and back up to re-parse it. - var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs) - debug("arg=%j shRes=%j", arg, shRes) - if (shRes) { - debug(arg, shRes) - args.splice.apply(args, [i, 1].concat(shRes)) - if (arg !== shRes[0]) { - i -- - continue - } - } - arg = arg.replace(/^-+/, "") - var no = null - while (arg.toLowerCase().indexOf("no-") === 0) { - no = !no - arg = arg.substr(3) - } - - if (abbrevs[arg]) arg = abbrevs[arg] - - var isArray = types[arg] === Array || - Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1 - - // allow unknown things to be arrays if specified multiple times. - if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) { - if (!Array.isArray(data[arg])) - data[arg] = [data[arg]] - isArray = true - } - - var val - , la = args[i + 1] - - var isBool = typeof no === 'boolean' || - types[arg] === Boolean || - Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || - (typeof types[arg] === 'undefined' && !hadEq) || - (la === "false" && - (types[arg] === null || - Array.isArray(types[arg]) && ~types[arg].indexOf(null))) - - if (isBool) { - // just set and move along - val = !no - // however, also support --bool true or --bool false - if (la === "true" || la === "false") { - val = JSON.parse(la) - la = null - if (no) val = !val - i ++ - } - - // also support "foo":[Boolean, "bar"] and "--foo bar" - if (Array.isArray(types[arg]) && la) { - if (~types[arg].indexOf(la)) { - // an explicit type - val = la - i ++ - } else if ( la === "null" && ~types[arg].indexOf(null) ) { - // null allowed - val = null - i ++ - } else if ( !la.match(/^-{2,}[^-]/) && - !isNaN(la) && - ~types[arg].indexOf(Number) ) { - // number - val = +la - i ++ - } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) { - // string - val = la - i ++ - } - } - - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - continue - } - - if (types[arg] === String && la === undefined) - la = "" - - if (la && la.match(/^-{2,}$/)) { - la = undefined - i -- - } - - val = la === undefined ? true : la - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - i ++ - continue - } - remain.push(arg) - } -} - -function resolveShort (arg, shorthands, shortAbbr, abbrevs) { - // handle single-char shorthands glommed together, like - // npm ls -glp, but only if there is one dash, and only if - // all of the chars are single-char shorthands, and it's - // not a match to some other abbrev. - arg = arg.replace(/^-+/, '') - - // if it's an exact known option, then don't go any further - if (abbrevs[arg] === arg) - return null - - // if it's an exact known shortopt, same deal - if (shorthands[arg]) { - // make it an array, if it's a list of words - if (shorthands[arg] && !Array.isArray(shorthands[arg])) - shorthands[arg] = shorthands[arg].split(/\s+/) - - return shorthands[arg] - } - - // first check to see if this arg is a set of single-char shorthands - var singles = shorthands.___singles - if (!singles) { - singles = Object.keys(shorthands).filter(function (s) { - return s.length === 1 - }).reduce(function (l,r) { - l[r] = true - return l - }, {}) - shorthands.___singles = singles - debug('shorthand singles', singles) - } - - var chrs = arg.split("").filter(function (c) { - return singles[c] - }) - - if (chrs.join("") === arg) return chrs.map(function (c) { - return shorthands[c] - }).reduce(function (l, r) { - return l.concat(r) - }, []) - - - // if it's an arg abbrev, and not a literal shorthand, then prefer the arg - if (abbrevs[arg] && !shorthands[arg]) - return null - - // if it's an abbr for a shorthand, then use that - if (shortAbbr[arg]) - arg = shortAbbr[arg] - - // make it an array, if it's a list of words - if (shorthands[arg] && !Array.isArray(shorthands[arg])) - shorthands[arg] = shorthands[arg].split(/\s+/) - - return shorthands[arg] -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md deleted file mode 100644 index 2f30261..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md +++ /dev/null @@ -1,3 +0,0 @@ - To get started, sign the - Contributor License Agreement. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md deleted file mode 100644 index 99746fe..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# abbrev-js - -Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev). - -Usage: - - var abbrev = require("abbrev"); - abbrev("foo", "fool", "folding", "flop"); - - // returns: - { fl: 'flop' - , flo: 'flop' - , flop: 'flop' - , fol: 'folding' - , fold: 'folding' - , foldi: 'folding' - , foldin: 'folding' - , folding: 'folding' - , foo: 'foo' - , fool: 'fool' - } - -This is handy for command-line scripts, or other cases where you want to be able to accept shorthands. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/abbrev.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/abbrev.js deleted file mode 100644 index 69cfeac..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/abbrev.js +++ /dev/null @@ -1,62 +0,0 @@ - -module.exports = exports = abbrev.abbrev = abbrev - -abbrev.monkeyPatch = monkeyPatch - -function monkeyPatch () { - Object.defineProperty(Array.prototype, 'abbrev', { - value: function () { return abbrev(this) }, - enumerable: false, configurable: true, writable: true - }) - - Object.defineProperty(Object.prototype, 'abbrev', { - value: function () { return abbrev(Object.keys(this)) }, - enumerable: false, configurable: true, writable: true - }) -} - -function abbrev (list) { - if (arguments.length !== 1 || !Array.isArray(list)) { - list = Array.prototype.slice.call(arguments, 0) - } - for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { - args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) - } - - // sort them lexicographically, so that they're next to their nearest kin - args = args.sort(lexSort) - - // walk through each, seeing how much it has in common with the next and previous - var abbrevs = {} - , prev = "" - for (var i = 0, l = args.length ; i < l ; i ++) { - var current = args[i] - , next = args[i + 1] || "" - , nextMatches = true - , prevMatches = true - if (current === next) continue - for (var j = 0, cl = current.length ; j < cl ; j ++) { - var curChar = current.charAt(j) - nextMatches = nextMatches && curChar === next.charAt(j) - prevMatches = prevMatches && curChar === prev.charAt(j) - if (!nextMatches && !prevMatches) { - j ++ - break - } - } - prev = current - if (j === cl) { - abbrevs[current] = current - continue - } - for (var a = current.substr(0, j) ; j <= cl ; j ++) { - abbrevs[a] = current - a += current.charAt(j) - } - } - return abbrevs -} - -function lexSort (a, b) { - return a === b ? 0 : a > b ? 1 : -1 -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json deleted file mode 100644 index 1dad5f2..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "abbrev", - "version": "1.0.5", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "http://github.com/isaacs/abbrev-js" - }, - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" - }, - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js", - "_id": "abbrev@1.0.5", - "_shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03", - "_from": "abbrev@1", - "_npmVersion": "1.4.7", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03", - "tarball": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/test.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/test.js deleted file mode 100644 index d5a7303..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/node_modules/abbrev/test.js +++ /dev/null @@ -1,47 +0,0 @@ -var abbrev = require('./abbrev.js') -var assert = require("assert") -var util = require("util") - -console.log("TAP Version 13") -var count = 0 - -function test (list, expect) { - count++ - var actual = abbrev(list) - assert.deepEqual(actual, expect, - "abbrev("+util.inspect(list)+") === " + util.inspect(expect) + "\n"+ - "actual: "+util.inspect(actual)) - actual = abbrev.apply(exports, list) - assert.deepEqual(abbrev.apply(exports, list), expect, - "abbrev("+list.map(JSON.stringify).join(",")+") === " + util.inspect(expect) + "\n"+ - "actual: "+util.inspect(actual)) - console.log('ok - ' + list.join(' ')) -} - -test([ "ruby", "ruby", "rules", "rules", "rules" ], -{ rub: 'ruby' -, ruby: 'ruby' -, rul: 'rules' -, rule: 'rules' -, rules: 'rules' -}) -test(["fool", "foom", "pool", "pope"], -{ fool: 'fool' -, foom: 'foom' -, poo: 'pool' -, pool: 'pool' -, pop: 'pope' -, pope: 'pope' -}) -test(["a", "ab", "abc", "abcd", "abcde", "acde"], -{ a: 'a' -, ab: 'ab' -, abc: 'abc' -, abcd: 'abcd' -, abcde: 'abcde' -, ac: 'acde' -, acd: 'acde' -, acde: 'acde' -}) - -console.log("0..%d", count) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/package.json deleted file mode 100644 index e392be4..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "nopt", - "version": "3.0.1", - "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "main": "lib/nopt.js", - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "http://github.com/isaacs/nopt" - }, - "bin": { - "nopt": "./bin/nopt.js" - }, - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/nopt/raw/master/LICENSE" - }, - "dependencies": { - "abbrev": "1" - }, - "devDependencies": { - "tap": "~0.4.8" - }, - "gitHead": "4296f7aba7847c198fea2da594f9e1bec02817ec", - "bugs": { - "url": "https://github.com/isaacs/nopt/issues" - }, - "homepage": "https://github.com/isaacs/nopt", - "_id": "nopt@3.0.1", - "_shasum": "bce5c42446a3291f47622a370abbf158fbbacbfd", - "_from": "nopt@^3.0.1", - "_npmVersion": "1.4.18", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "bce5c42446a3291f47622a370abbf158fbbacbfd", - "tarball": "http://registry.npmjs.org/nopt/-/nopt-3.0.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/test/basic.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/test/basic.js deleted file mode 100644 index 2f9088c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/nopt/test/basic.js +++ /dev/null @@ -1,251 +0,0 @@ -var nopt = require("../") - , test = require('tap').test - - -test("passing a string results in a string", function (t) { - var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0) - t.same(parsed.key, "myvalue") - t.end() -}) - -// https://github.com/npm/nopt/issues/31 -test("Empty String results in empty string, not true", function (t) { - var parsed = nopt({ empty: String }, {}, ["--empty"], 0) - t.same(parsed.empty, "") - t.end() -}) - -test("~ path is resolved to $HOME", function (t) { - var path = require("path") - if (!process.env.HOME) process.env.HOME = "/tmp" - var parsed = nopt({key: path}, {}, ["--key=~/val"], 0) - t.same(parsed.key, path.resolve(process.env.HOME, "val")) - t.end() -}) - -// https://github.com/npm/nopt/issues/24 -test("Unknown options are not parsed as numbers", function (t) { - var parsed = nopt({"parse-me": Number}, null, ['--leave-as-is=1.20', '--parse-me=1.20'], 0) - t.equal(parsed['leave-as-is'], '1.20') - t.equal(parsed['parse-me'], 1.2) - t.end() -}); - -test("other tests", function (t) { - - var util = require("util") - , Stream = require("stream") - , path = require("path") - , url = require("url") - - , shorthands = - { s : ["--loglevel", "silent"] - , d : ["--loglevel", "info"] - , dd : ["--loglevel", "verbose"] - , ddd : ["--loglevel", "silly"] - , noreg : ["--no-registry"] - , reg : ["--registry"] - , "no-reg" : ["--no-registry"] - , silent : ["--loglevel", "silent"] - , verbose : ["--loglevel", "verbose"] - , h : ["--usage"] - , H : ["--usage"] - , "?" : ["--usage"] - , help : ["--usage"] - , v : ["--version"] - , f : ["--force"] - , desc : ["--description"] - , "no-desc" : ["--no-description"] - , "local" : ["--no-global"] - , l : ["--long"] - , p : ["--parseable"] - , porcelain : ["--parseable"] - , g : ["--global"] - } - - , types = - { aoa: Array - , nullstream: [null, Stream] - , date: Date - , str: String - , browser : String - , cache : path - , color : ["always", Boolean] - , depth : Number - , description : Boolean - , dev : Boolean - , editor : path - , force : Boolean - , global : Boolean - , globalconfig : path - , group : [String, Number] - , gzipbin : String - , logfd : [Number, Stream] - , loglevel : ["silent","win","error","warn","info","verbose","silly"] - , long : Boolean - , "node-version" : [false, String] - , npaturl : url - , npat : Boolean - , "onload-script" : [false, String] - , outfd : [Number, Stream] - , parseable : Boolean - , pre: Boolean - , prefix: path - , proxy : url - , "rebuild-bundle" : Boolean - , registry : url - , searchopts : String - , searchexclude: [null, String] - , shell : path - , t: [Array, String] - , tag : String - , tar : String - , tmp : path - , "unsafe-perm" : Boolean - , usage : Boolean - , user : String - , username : String - , userconfig : path - , version : Boolean - , viewer: path - , _exit : Boolean - , path: path - } - - ; [["-v", {version:true}, []] - ,["---v", {version:true}, []] - ,["ls -s --no-reg connect -d", - {loglevel:"info",registry:null},["ls","connect"]] - ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]] - ,["ls --registry blargle", {}, ["ls"]] - ,["--no-registry", {registry:null}, []] - ,["--no-color true", {color:false}, []] - ,["--no-color false", {color:true}, []] - ,["--no-color", {color:false}, []] - ,["--color false", {color:false}, []] - ,["--color --logfd 7", {logfd:7,color:true}, []] - ,["--color=true", {color:true}, []] - ,["--logfd=10", {logfd:10}, []] - ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]] - ,["--tmp=tmp -tar=gtar", - {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]] - ,["--logfd x", {}, []] - ,["a -true -- -no-false", {true:true},["a","-no-false"]] - ,["a -no-false", {false:false},["a"]] - ,["a -no-no-true", {true:true}, ["a"]] - ,["a -no-no-no-false", {false:false}, ["a"]] - ,["---NO-no-No-no-no-no-nO-no-no"+ - "-No-no-no-no-no-no-no-no-no"+ - "-no-no-no-no-NO-NO-no-no-no-no-no-no"+ - "-no-body-can-do-the-boogaloo-like-I-do" - ,{"body-can-do-the-boogaloo-like-I-do":false}, []] - ,["we are -no-strangers-to-love "+ - "--you-know=the-rules --and=so-do-i "+ - "---im-thinking-of=a-full-commitment "+ - "--no-you-would-get-this-from-any-other-guy "+ - "--no-gonna-give-you-up "+ - "-no-gonna-let-you-down=true "+ - "--no-no-gonna-run-around false "+ - "--desert-you=false "+ - "--make-you-cry false "+ - "--no-tell-a-lie "+ - "--no-no-and-hurt-you false" - ,{"strangers-to-love":false - ,"you-know":"the-rules" - ,"and":"so-do-i" - ,"you-would-get-this-from-any-other-guy":false - ,"gonna-give-you-up":false - ,"gonna-let-you-down":false - ,"gonna-run-around":false - ,"desert-you":false - ,"make-you-cry":false - ,"tell-a-lie":false - ,"and-hurt-you":false - },["we", "are"]] - ,["-t one -t two -t three" - ,{t: ["one", "two", "three"]} - ,[]] - ,["-t one -t null -t three four five null" - ,{t: ["one", "null", "three"]} - ,["four", "five", "null"]] - ,["-t foo" - ,{t:["foo"]} - ,[]] - ,["--no-t" - ,{t:["false"]} - ,[]] - ,["-no-no-t" - ,{t:["true"]} - ,[]] - ,["-aoa one -aoa null -aoa 100" - ,{aoa:["one", null, '100']} - ,[]] - ,["-str 100" - ,{str:"100"} - ,[]] - ,["--color always" - ,{color:"always"} - ,[]] - ,["--no-nullstream" - ,{nullstream:null} - ,[]] - ,["--nullstream false" - ,{nullstream:null} - ,[]] - ,["--notadate=2011-01-25" - ,{notadate: "2011-01-25"} - ,[]] - ,["--date 2011-01-25" - ,{date: new Date("2011-01-25")} - ,[]] - ,["-cl 1" - ,{config: true, length: 1} - ,[] - ,{config: Boolean, length: Number, clear: Boolean} - ,{c: "--config", l: "--length"}] - ,["--acount bla" - ,{"acount":true} - ,["bla"] - ,{account: Boolean, credentials: Boolean, options: String} - ,{a:"--account", c:"--credentials",o:"--options"}] - ,["--clear" - ,{clear:true} - ,[] - ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean} - ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}] - ,["--file -" - ,{"file":"-"} - ,[] - ,{file:String} - ,{}] - ,["--file -" - ,{"file":true} - ,["-"] - ,{file:Boolean} - ,{}] - ,["--path" - ,{"path":null} - ,[]] - ,["--path ." - ,{"path":process.cwd()} - ,[]] - ].forEach(function (test) { - var argv = test[0].split(/\s+/) - , opts = test[1] - , rem = test[2] - , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0) - , parsed = actual.argv - delete actual.argv - for (var i in opts) { - var e = JSON.stringify(opts[i]) - , a = JSON.stringify(actual[i] === undefined ? null : actual[i]) - if (e && typeof e === "object") { - t.deepEqual(e, a) - } else { - t.equal(e, a) - } - } - t.deepEqual(rem, parsed.remain) - }) - t.end() -}) diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/README.markdown deleted file mode 100644 index 1e56ebd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/README.markdown +++ /dev/null @@ -1,56 +0,0 @@ -runforcover -====== - -Runforcover is a require-hook library that uses node-bunker to provide code coverage data -for your unit test library, whatever it might be. - -methods -======= -var runforcover = require('runforcover'); - -var coverage = runforcover.cover([RegExp | path]); -------- - -Attach runforcover to the global `require` object and patch `require.extensions['.js']` to -provide coverage metadata for all files required after this point. Returns a function -object that can be called to obtain a object keying files to `CoverageData` objects, with -a method for releasing control back to vanilla `require`. Usage: - -````javascript - -var coverage = runforcover.cover(/.*/g); - -require('some/library'); - -coverage(function(coverageData) { - // coverageData is an object keyed by filename. - var stats = coverageData['/full/path/to/file.js'].stats() - - // the percentage of lines run versus total lines in file - console.log(stats.percentage); - - // the number of missing lines - console.log(stats.missing); - - // the number of lines run (seen) - console.log(stats.seen); - - // an array of line objects representing 'missed' lines - stats.lines; - - stats.lines.forEach(function(line) { - // the line number of the line: - console.log(line.number); - - // returns a string containing the source data for the line: - console.log(line.source()); - }); - - // return control back to the original require function - coverage.release(); -}); -```` - -license -======= -new BSD. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/index.js deleted file mode 100644 index b5318ac..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/index.js +++ /dev/null @@ -1,127 +0,0 @@ -var bunker = require('bunker'), - Module = require('module').Module, - path = require('path'), - fs = require('fs'), - vm = require('vm'); - -function CoverageData (filename, bunker) { - this.bunker = bunker; - this.filename = filename; - this.nodes = {}; -}; - -CoverageData.prototype.visit = function(node) { - ++(this.nodes[node.id] = this.nodes[node.id] || {node:node, count:0}).count; -}; - -CoverageData.prototype.missing = function() { - var nodes = this.nodes, - missing = this.bunker.nodes.filter(function(node) { - return !nodes[node.id]; - }); - - return missing; -}; - -CoverageData.prototype.stats = function() { - var missing = this.missing(), - filedata = fs.readFileSync(this.filename, 'utf8').split('\n'); - - var seenLines = [], - lines = - missing.sort(function(lhs, rhs) { - return lhs.node[0].start.line < rhs.node[0].start.line ? -1 : - lhs.node[0].start.line > rhs.node[0].start.line ? 1 : - 0; - }).filter(function(node) { - - var okay = (seenLines.indexOf(node.node[0].start.line) < 0); - if(okay) - seenLines.push(node.node[0].start.line); - return okay; - - }).map(function(node, idx, all) { - return { - lineno:node.node[0].start.line + 1, - source:function() { return filedata[node.node[0].start.line]; } - }; - }); - - return { - percentage:(filedata.length-seenLines.length)/filedata.length, - lines:lines, - missing:seenLines.length, - seen:(filedata.length-seenLines.length) - }; -}; - -module.exports.createEnvironment = function(module, filename) { - var req = function(path) { - return Module._load(path, module); - }; - req.resolve = function(request) { - return Module._resolveFilename(request, module)[1]; - } - req.paths = Module._paths; - req.main = process.mainModule; - req.extensions = Module._extensions; - req.registerExtension = function() { - throw new Error('require.registerExtension() removed. Use ' + - 'require.extensions instead.'); - } - require.cache = Module._cache; - - var ctxt = {}; - for(var k in global) - ctxt[k] = global[k]; - - ctxt.require = req; - ctxt.exports = module.exports; - ctxt.__filename = filename; - ctxt.__dirname = path.dirname(filename); - ctxt.process = process; - ctxt.console = console; - ctxt.module = module; - ctxt.global = ctxt; - - return ctxt; -}; - -module.exports.cover = function(fileRegex) { - var originalRequire = require.extensions['.js'], - coverageData = {}, - match = fileRegex instanceof RegExp ? - fileRegex : new RegExp( - fileRegex ? fileRegex.replace(/\//g, '\\/').replace(/\./g, '\\.') : '.*' - , 'g'), - target = this; - - require.extensions['.js'] = function(module, filename) { - if(!match.test(filename)) return originalRequire(module, filename); - - var context = target.createEnvironment(module, filename), - data = fs.readFileSync(filename, 'utf8'), - bunkerized = bunker(data), - coverage = coverageData[filename] = new CoverageData(filename, bunkerized); - - bunkerized.on('node', coverage.visit.bind(coverage)); - bunkerized.assign(context); - - var wrapper = '(function(ctxt) { with(ctxt) { return '+Module.wrap(bunkerized.compile())+'; } })', - compiledWrapper = vm.runInThisContext(wrapper, filename, true)(context); - - var args = [context.exports, context.require, module, filename, context.__dirname]; - return compiledWrapper.apply(module.exports, args); - }; - - var retval = function(ready) { - ready(coverageData); - }; - - retval.release = function() { - require.extensions['.js'] = originalRequire; - }; - - return retval; -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.travis.yml deleted file mode 100644 index f1d0f13..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown deleted file mode 100644 index 0d0c387..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown +++ /dev/null @@ -1,82 +0,0 @@ -bunker -====== - -Bunker is a module to calculate code coverage using native javascript -[burrito](https://github.com/substack/node-burrito) AST trickery. - -[![build status](https://secure.travis-ci.org/substack/node-bunker.png)](http://travis-ci.org/substack/node-bunker) - -![code coverage](http://substack.net/images/code_coverage.png) - -examples -======== - -tiny ----- - -````javascript -var bunker = require('bunker'); -var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log(count.times + ' : ' + count.node.source()); -}); -```` - -output: - - $ node example/tiny.js - 1 : var x=0; - 31 : i<30 - 30 : i++ - 30 : x++; - 30 : x++ - -methods -======= - -var bunker = require('bunker'); - -var b = bunker(src) -------------------- - -Create a new bunker code coverageifier with some source `src`. - -The bunker object `b` is an `EventEmitter` that emits `'node'` events with two -parameters: - -* `node` - the [burrito](https://github.com/substack/node-burrito) node object -* `stack` - the stack, [stackedy](https://github.com/substack/node-stackedy) style - -b.include(src) --------------- - -Include some source into the bunker. - -b.compile() ------------ - -Return the source wrapped with burrito. - -b.assign(context={}) --------------------- - -Assign the statement-tracking functions into `context`. - -b.run(context={}) ------------------ - -Run the source using `vm.runInNewContext()` with some `context`. -The statement-tracking functions will be added to `context` by `assign()`. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js deleted file mode 100644 index 5cac4cc..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js +++ /dev/null @@ -1,51 +0,0 @@ -var bunker = require('bunker'); -var b = bunker('(' + function () { - function beep () { - var x = 0; - for (var i = 0; i < 1000; i++) { - for (var j = 0; j < 100; j++) { - x += j; - } - } - return x; - } - - beep(); - -} + ')()'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node, elapsed : 0 }; - } - counts[node.id].times ++; - - var now = Date.now(); - - if (last.id !== undefined) { - counts[last.id].elapsed += last. - } - - if (node.name === 'call') { - var start = now; - - last.id = node.id; - counts[node.id].elapsed += Date.now() - start; - } - else { - counts[node.id].elapsed += now - last; - last = now; - } -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log( - [ count.times, count.node.source(), count.elapsed ] - .join(' : ') - ); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js deleted file mode 100644 index aa5b034..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js +++ /dev/null @@ -1,18 +0,0 @@ -var bunker = require('bunker'); -var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log(count.times + ' : ' + count.node.source()); -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js deleted file mode 100644 index d9eaa10..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js +++ /dev/null @@ -1,31 +0,0 @@ -var bunker = require('bunker'); -var fs = require('fs'); -var src = fs.readFileSync(__dirname + '/src.js', 'utf8'); - -var counts = {}; - -var b = bunker(src); -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run({ - setInterval : setInterval, - clearInterval : clearInterval, - end : function () { - Object.keys(counts) - .sort(function (a, b) { - return counts[b].times - counts[a].times - }) - .forEach(function (key) { - var count = counts[key]; - console.log( - count.times + ' : ' + count.node.source() - ); - }) - ; - } -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js deleted file mode 100644 index 0c92e48..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js +++ /dev/null @@ -1,18 +0,0 @@ -function boop () { - for (var i = 0; i < 30; i++) { - nop(); - } -} - -function nop () { - return undefined; -} - -var times = 0; -var iv = setInterval(function () { - if (++times === 10) { - clearInterval(iv); - end(); - } - else boop() -}, 100); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js deleted file mode 100644 index ed5d437..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js +++ /dev/null @@ -1,116 +0,0 @@ -var burrito = require('burrito'); -var vm = require('vm'); -var EventEmitter = require('events').EventEmitter; - -module.exports = function (src) { - var b = new Bunker(); - if (src) b.include(src); - return b; -}; - -function Bunker () { - this.sources = []; - this.nodes = []; - - this.names = { - call : burrito.generateName(6), - expr : burrito.generateName(6), - stat : burrito.generateName(6), - return : burrito.generateName(6) - }; -} - -Bunker.prototype = new EventEmitter; - -Bunker.prototype.include = function (src) { - this.sources.push(src); - this.source = null; - return this; -}; - -Bunker.prototype.compile = function () { - var src = this.sources.join('\n'); - var nodes = this.nodes; - var names = this.names; - - return burrito(src, function (node) { - var i = nodes.length; - - if (node.name === 'call') { - nodes.push(node); - node.wrap(names.call + '(' + i + ')(%s)'); - } - else if (node.name === 'stat' || node.name === 'throw' - || node.name === 'var') { - nodes.push(node); - node.wrap('{' + names.stat + '(' + i + ');%s}'); - } - else if (node.name === 'return') { - nodes.push(node); - // We need to wrap the new source in a function definition - // so that UglifyJS will allow the presence of return - var stat = names.stat + '(' + i + ');'; - var wrapped = 'function ' + names.return + '() {' - + stat + node.source() - +'}' - ; - var parsed = burrito.parse(wrapped); - // Remove the function definition from the AST - parsed[1] = parsed[1][0][3]; - node.state.update(parsed, true); - } - else if (node.name === 'binary') { - nodes.push(node); - node.wrap(names.expr + '(' + i + ')(%s)'); - } - else if (node.name === 'unary-postfix' || node.name === 'unary-prefix') { - nodes.push(node); - node.wrap(names.expr + '(' + i + ')(%s)'); - } - - if (i !== nodes.length) { - node.id = i; - } - }); -}; - -Bunker.prototype.assign = function (context) { - if (!context) context = {}; - - var self = this; - var stack = []; - - context[self.names.call] = function (i) { - var node = self.nodes[i]; - stack.unshift(node); - self.emit('node', node, stack); - - return function (expr) { - stack.shift(); - return expr; - }; - }; - - context[self.names.expr] = function (i) { - var node = self.nodes[i]; - self.emit('node', node, stack); - - return function (expr) { - return expr; - }; - }; - - context[self.names.stat] = function (i) { - var node = self.nodes[i]; - self.emit('node', node, stack); - }; - - return context; -}; - -Bunker.prototype.run = function (context) { - var src = this.compile(); - vm.runInNewContext(src, this.assign(context)); - - return this; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.travis.yml b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.travis.yml deleted file mode 100644 index f1d0f13..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown deleted file mode 100644 index 7c9097c..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown +++ /dev/null @@ -1,187 +0,0 @@ -burrito -======= - -Burrito makes it easy to do crazy stuff with the javascript AST. - -This is super useful if you want to roll your own stack traces or build a code -coverage tool. - -[![build status](https://secure.travis-ci.org/substack/node-burrito.png)](http://travis-ci.org/substack/node-burrito) - -![node.wrap("burrito")](http://substack.net/images/burrito.png) - -examples -======== - -microwave ---------- - -examples/microwave.js - -````javascript -var burrito = require('burrito'); - -var res = burrito.microwave('Math.sin(2)', function (node) { - if (node.name === 'num') node.wrap('Math.PI / %s'); -}); - -console.log(res); // sin(pi / 2) == 1 -```` - -output: - - 1 - -wrap ----- - -examples/wrap.js - -````javascript -var burrito = require('burrito'); - -var src = burrito('f() && g(h())\nfoo()', function (node) { - if (node.name === 'call') node.wrap('qqq(%s)'); -}); - -console.log(src); -```` - -output: - - qqq(f()) && qqq(g(qqq(h()))); - - qqq(foo()); - -methods -======= - - var burrito = require('burrito'); - -burrito(code, cb) ------------------ - -Given some source `code` and a function `trace`, walk the ast by expression. - -The `cb` gets called with a node object described below. - -If `code` is an Array then it is assumbed to be an AST which you can generate -yourself with `burrito.parse()`. The AST must be annotated, so make sure to -`burrito.parse(src, false, true)`. - -burrito.microwave(code, context={}, cb) ---------------------------------------- - -Like `burrito()` except the result is run using -`vm.runInNewContext(res, context)`. - -node object -=========== - -node.name ---------- - -Name is a string that contains the type of the expression as named by uglify. - -node.wrap(s) ------------- - -Wrap the current expression in `s`. - -If `s` is a string, `"%s"` will be replaced with the stringified current -expression. - -If `s` is a function, it is called with the stringified current expression and -should return a new stringified expression. - -If the `node.name === "binary"`, you get the subterms "%a" and "%b" to play with -too. These subterms are applied if `s` is a function too: `s(expr, a, b)`. - -Protip: to insert multiple statements you can use javascript's lesser-known block -syntax that it gets from C: - -````javascript -if (node.name === 'stat') node.wrap('{ foo(); %s }') -```` - -node.node ---------- - -raw ast data generated by uglify - -node.value ----------- - -`node.node.slice(1)` to skip the annotations - -node.start ----------- - -The start location of the expression, like this: - -````javascript -{ type: 'name', - value: 'b', - line: 0, - col: 3, - pos: 3, - nlb: false, - comments_before: [] } -```` - -node.end --------- - -The end location of the expression, formatted the same as `node.start`. - -node.state ----------- - -The state of the traversal using traverse. - -node.source() -------------- - -Returns a stringified version of the expression. - -node.parent() -------------- - -Returns the parent `node` or `null` if the node is the root element. - -node.label() ------------- - -Return the label of the present node or `null` if there is no label. - -Labels are returned for "call", "var", "defun", and "function" nodes. - -Returns an array for "var" nodes since `var` statements can -contain multiple labels in assignment. - -install -======= - -With [npm](http://npmjs.org) you can just: - - npm install burrito - -in the browser -============== - -Burrito works in browser with -[browserify](https://github.com/substack/node-browserify). - -It has been tested against: - -* Internet Explorer 5.5, 6.0, 7.0, 8.0, 9.0 -* Firefox 3.5 -* Chrome 6.0 -* Opera 10.6 -* Safari 5.0 - -kudos -===== - -Heavily inspired by (and previously mostly lifted outright from) isaacs's nifty -tmp/instrument.js thingy from uglify-js. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js deleted file mode 100644 index c6fcf45..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js +++ /dev/null @@ -1,8 +0,0 @@ -var burrito = require('burrito'); - -var res = burrito.microwave('Math.sin(2)', function (node) { - console.dir(node); - if (node.name === 'num') node.wrap('Math.PI / %s'); -}); - -console.log(res); // sin(pi / 2) == 1 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js deleted file mode 100644 index 3583c7f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js +++ /dev/null @@ -1,4832 +0,0 @@ -var require = function (file, cwd) { - var resolved = require.resolve(file, cwd || '/'); - var mod = require.modules[resolved]; - if (!mod) throw new Error( - 'Failed to resolve module ' + file + ', tried ' + resolved - ); - var res = mod._cached ? mod._cached : mod(); - return res; -} -var __require = require; - -require.paths = []; -require.modules = {}; -require.extensions = [".js",".coffee"]; - -require.resolve = (function () { - var core = { - 'assert': true, - 'events': true, - 'fs': true, - 'path': true, - 'vm': true - }; - - return function (x, cwd) { - if (!cwd) cwd = '/'; - - if (core[x]) return x; - var path = require.modules.path(); - var y = cwd || '.'; - - if (x.match(/^(?:\.\.?\/|\/)/)) { - var m = loadAsFileSync(path.resolve(y, x)) - || loadAsDirectorySync(path.resolve(y, x)); - if (m) return m; - } - - var n = loadNodeModulesSync(x, y); - if (n) return n; - - throw new Error("Cannot find module '" + x + "'"); - - function loadAsFileSync (x) { - if (require.modules[x]) { - return x; - } - - for (var i = 0; i < require.extensions.length; i++) { - var ext = require.extensions[i]; - if (require.modules[x + ext]) return x + ext; - } - } - - function loadAsDirectorySync (x) { - x = x.replace(/\/+$/, ''); - var pkgfile = x + '/package.json'; - if (require.modules[pkgfile]) { - var pkg = require.modules[pkgfile](); - var b = pkg.browserify; - if (typeof b === 'object' && b.main) { - var m = loadAsFileSync(path.resolve(x, b.main)); - if (m) return m; - } - else if (typeof b === 'string') { - var m = loadAsFileSync(path.resolve(x, b)); - if (m) return m; - } - else if (pkg.main) { - var m = loadAsFileSync(path.resolve(x, pkg.main)); - if (m) return m; - } - } - - return loadAsFileSync(x + '/index'); - } - - function loadNodeModulesSync (x, start) { - var dirs = nodeModulesPathsSync(start); - for (var i = 0; i < dirs.length; i++) { - var dir = dirs[i]; - var m = loadAsFileSync(dir + '/' + x); - if (m) return m; - var n = loadAsDirectorySync(dir + '/' + x); - if (n) return n; - } - - var m = loadAsFileSync(x); - if (m) return m; - } - - function nodeModulesPathsSync (start) { - var parts; - if (start === '/') parts = [ '' ]; - else parts = path.normalize(start).split('/'); - - var dirs = []; - for (var i = parts.length - 1; i >= 0; i--) { - if (parts[i] === 'node_modules') continue; - var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; - dirs.push(dir); - } - - return dirs; - } - }; -})(); - -require.alias = function (from, to) { - var path = require.modules.path(); - var res = null; - try { - res = require.resolve(from + '/package.json', '/'); - } - catch (err) { - res = require.resolve(from, '/'); - } - var basedir = path.dirname(res); - - var keys = Object_keys(require.modules); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key.slice(0, basedir.length + 1) === basedir + '/') { - var f = key.slice(basedir.length); - require.modules[to + f] = require.modules[basedir + f]; - } - else if (key === basedir) { - require.modules[to] = require.modules[basedir]; - } - } -}; - -var Object_keys = Object.keys || function (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -if (typeof process === 'undefined') process = {}; - -if (!process.nextTick) process.nextTick = function (fn) { - setTimeout(fn, 0); -}; - -if (!process.title) process.title = 'browser'; - -if (!process.binding) process.binding = function (name) { - if (name === 'evals') return require('vm') - else throw new Error('No such module') -}; - -if (!process.cwd) process.cwd = function () { return '.' }; - -require.modules["path"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "path"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["path"]._cached = module.exports; - - (function () { - function filter (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - if (fn(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length; i >= 0; i--) { - var last = parts[i]; - if (last == '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Regex to split a filename into [*, dir, basename, ext] -// posix version -var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { -var resolvedPath = '', - resolvedAbsolute = false; - -for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) - ? arguments[i] - : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string' || !path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; -} - -// At this point the path should be resolved to a full absolute path, but -// handle relative paths to be safe (might happen when process.cwd() fails) - -// Normalize the path -resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { -var isAbsolute = path.charAt(0) === '/', - trailingSlash = path.slice(-1) === '/'; - -// Normalize the path -path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - return p && typeof p === 'string'; - }).join('/')); -}; - - -exports.dirname = function(path) { - var dir = splitPathRe.exec(path)[1] || ''; - var isWindows = false; - if (!dir) { - // No dirname - return '.'; - } else if (dir.length === 1 || - (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) { - // It is just a slash or a drive letter with a slash - return dir; - } else { - // It is a full dirname, strip trailing slash - return dir.substring(0, dir.length - 1); - } -}; - - -exports.basename = function(path, ext) { - var f = splitPathRe.exec(path)[2] || ''; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPathRe.exec(path)[3] || ''; -}; -; - }).call(module.exports); - - __require.modules["path"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito"; - var __filename = "/node_modules/burrito/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"burrito","description":"Wrap up expressions with a trace function while walking the AST with rice and beans on the side","version":"0.2.8","repository":{"type":"git","url":"git://github.com/substack/node-burrito.git"},"main":"./index.js","keywords":["trace","ast","walk","syntax","source","tree","uglify"],"directories":{"lib":".","example":"example","test":"test"},"scripts":{"test":"expresso"},"dependencies":{"traverse":">=0.5.1 <0.6","uglify-js":"1.0.4"},"devDependencies":{"expresso":"=0.7.x"},"engines":{"node":">=0.4.0"},"license":"BSD","author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"uglify-js","author":{"name":"Mihai Bazon","email":"mihai.bazon@gmail.com","url":"http://mihai.bazon.net/blog"},"version":"1.0.4","main":"./uglify-js.js","bin":{"uglifyjs":"./bin/uglifyjs"},"repository":{"type":"git","url":"git@github.com:mishoo/UglifyJS.git"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/uglify-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - - (function () { - //convienence function(src, [options]); -function uglify(orig_code, options){ - options || (options = {}); - var jsp = uglify.parser; - var pro = uglify.uglify; - - var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST - ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names - ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations - var final_code = pro.gen_code(ast, options.gen_options); // compressed code here - return final_code; -}; - -uglify.parser = require("./lib/parse-js"); -uglify.uglify = require("./lib/process"); - -module.exports = uglify; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file contains the tokenizer/parser. It is a port to JavaScript - of parse-js [1], a JavaScript parser library written in Common Lisp - by Marijn Haverbeke. Thank you Marijn! - - [1] http://marijn.haverbeke.nl/parse-js/ - - Exported functions: - - - tokenizer(code) -- returns a function. Call the returned - function to fetch the next token. - - - parse(code) -- returns an AST of the given JavaScript code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - Based on parse-js (http://marijn.haverbeke.nl/parse-js/). - - 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. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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. - - ***********************************************************************/ - -/* -----[ Tokenizer (constants) ]----- */ - -var KEYWORDS = array_to_hash([ - "break", - "case", - "catch", - "const", - "continue", - "default", - "delete", - "do", - "else", - "finally", - "for", - "function", - "if", - "in", - "instanceof", - "new", - "return", - "switch", - "throw", - "try", - "typeof", - "var", - "void", - "while", - "with" -]); - -var RESERVED_WORDS = array_to_hash([ - "abstract", - "boolean", - "byte", - "char", - "class", - "debugger", - "double", - "enum", - "export", - "extends", - "final", - "float", - "goto", - "implements", - "import", - "int", - "interface", - "long", - "native", - "package", - "private", - "protected", - "public", - "short", - "static", - "super", - "synchronized", - "throws", - "transient", - "volatile" -]); - -var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([ - "return", - "new", - "delete", - "throw", - "else", - "case" -]); - -var KEYWORDS_ATOM = array_to_hash([ - "false", - "null", - "true", - "undefined" -]); - -var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^")); - -var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i; -var RE_OCT_NUMBER = /^0[0-7]+$/; -var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i; - -var OPERATORS = array_to_hash([ - "in", - "instanceof", - "typeof", - "new", - "void", - "delete", - "++", - "--", - "+", - "-", - "!", - "~", - "&", - "|", - "^", - "*", - "/", - "%", - ">>", - "<<", - ">>>", - "<", - ">", - "<=", - ">=", - "==", - "===", - "!=", - "!==", - "?", - "=", - "+=", - "-=", - "/=", - "*=", - "%=", - ">>=", - "<<=", - ">>>=", - "|=", - "^=", - "&=", - "&&", - "||" -]); - -var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\v\u200b")); - -var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:")); - -var PUNC_CHARS = array_to_hash(characters("[]{}(),;:")); - -var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy")); - -/* -----[ Tokenizer ]----- */ - -// regexps adapted from http://xregexp.com/plugins/#unicode -var UNICODE = { - letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), - non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"), - space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"), - connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]") -}; - -function is_letter(ch) { - return UNICODE.letter.test(ch); -}; - -function is_digit(ch) { - ch = ch.charCodeAt(0); - return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9 -}; - -function is_alphanumeric_char(ch) { - return is_digit(ch) || is_letter(ch); -}; - -function is_unicode_combining_mark(ch) { - return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch); -}; - -function is_unicode_connector_punctuation(ch) { - return UNICODE.connector_punctuation.test(ch); -}; - -function is_identifier_start(ch) { - return ch == "$" || ch == "_" || is_letter(ch); -}; - -function is_identifier_char(ch) { - return is_identifier_start(ch) - || is_unicode_combining_mark(ch) - || is_digit(ch) - || is_unicode_connector_punctuation(ch) - || ch == "\u200c" // zero-width non-joiner - || ch == "\u200d" // zero-width joiner (in my ECMA-262 PDF, this is also 200c) - ; -}; - -function parse_js_number(num) { - if (RE_HEX_NUMBER.test(num)) { - return parseInt(num.substr(2), 16); - } else if (RE_OCT_NUMBER.test(num)) { - return parseInt(num.substr(1), 8); - } else if (RE_DEC_NUMBER.test(num)) { - return parseFloat(num); - } -}; - -function JS_Parse_Error(message, line, col, pos) { - this.message = message; - this.line = line; - this.col = col; - this.pos = pos; - try { - ({})(); - } catch(ex) { - this.stack = ex.stack; - }; -}; - -JS_Parse_Error.prototype.toString = function() { - return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; -}; - -function js_error(message, line, col, pos) { - throw new JS_Parse_Error(message, line, col, pos); -}; - -function is_token(token, type, val) { - return token.type == type && (val == null || token.value == val); -}; - -var EX_EOF = {}; - -function tokenizer($TEXT) { - - var S = { - text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''), - pos : 0, - tokpos : 0, - line : 0, - tokline : 0, - col : 0, - tokcol : 0, - newline_before : false, - regex_allowed : false, - comments_before : [] - }; - - function peek() { return S.text.charAt(S.pos); }; - - function next(signal_eof) { - var ch = S.text.charAt(S.pos++); - if (signal_eof && !ch) - throw EX_EOF; - if (ch == "\n") { - S.newline_before = true; - ++S.line; - S.col = 0; - } else { - ++S.col; - } - return ch; - }; - - function eof() { - return !S.peek(); - }; - - function find(what, signal_eof) { - var pos = S.text.indexOf(what, S.pos); - if (signal_eof && pos == -1) throw EX_EOF; - return pos; - }; - - function start_token() { - S.tokline = S.line; - S.tokcol = S.col; - S.tokpos = S.pos; - }; - - function token(type, value, is_comment) { - S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) || - (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) || - (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value))); - var ret = { - type : type, - value : value, - line : S.tokline, - col : S.tokcol, - pos : S.tokpos, - nlb : S.newline_before - }; - if (!is_comment) { - ret.comments_before = S.comments_before; - S.comments_before = []; - } - S.newline_before = false; - return ret; - }; - - function skip_whitespace() { - while (HOP(WHITESPACE_CHARS, peek())) - next(); - }; - - function read_while(pred) { - var ret = "", ch = peek(), i = 0; - while (ch && pred(ch, i++)) { - ret += next(); - ch = peek(); - } - return ret; - }; - - function parse_error(err) { - js_error(err, S.tokline, S.tokcol, S.tokpos); - }; - - function read_num(prefix) { - var has_e = false, after_e = false, has_x = false, has_dot = prefix == "."; - var num = read_while(function(ch, i){ - if (ch == "x" || ch == "X") { - if (has_x) return false; - return has_x = true; - } - if (!has_x && (ch == "E" || ch == "e")) { - if (has_e) return false; - return has_e = after_e = true; - } - if (ch == "-") { - if (after_e || (i == 0 && !prefix)) return true; - return false; - } - if (ch == "+") return after_e; - after_e = false; - if (ch == ".") { - if (!has_dot && !has_x) - return has_dot = true; - return false; - } - return is_alphanumeric_char(ch); - }); - if (prefix) - num = prefix + num; - var valid = parse_js_number(num); - if (!isNaN(valid)) { - return token("num", valid); - } else { - parse_error("Invalid syntax: " + num); - } - }; - - function read_escaped_char() { - var ch = next(true); - switch (ch) { - case "n" : return "\n"; - case "r" : return "\r"; - case "t" : return "\t"; - case "b" : return "\b"; - case "v" : return "\v"; - case "f" : return "\f"; - case "0" : return "\0"; - case "x" : return String.fromCharCode(hex_bytes(2)); - case "u" : return String.fromCharCode(hex_bytes(4)); - default : return ch; - } - }; - - function hex_bytes(n) { - var num = 0; - for (; n > 0; --n) { - var digit = parseInt(next(true), 16); - if (isNaN(digit)) - parse_error("Invalid hex-character pattern in string"); - num = (num << 4) | digit; - } - return num; - }; - - function read_string() { - return with_eof_error("Unterminated string constant", function(){ - var quote = next(), ret = ""; - for (;;) { - var ch = next(true); - if (ch == "\\") ch = read_escaped_char(); - else if (ch == quote) break; - ret += ch; - } - return token("string", ret); - }); - }; - - function read_line_comment() { - next(); - var i = find("\n"), ret; - if (i == -1) { - ret = S.text.substr(S.pos); - S.pos = S.text.length; - } else { - ret = S.text.substring(S.pos, i); - S.pos = i; - } - return token("comment1", ret, true); - }; - - function read_multiline_comment() { - next(); - return with_eof_error("Unterminated multiline comment", function(){ - var i = find("*/", true), - text = S.text.substring(S.pos, i), - tok = token("comment2", text, true); - S.pos = i + 2; - S.line += text.split("\n").length - 1; - S.newline_before = text.indexOf("\n") >= 0; - - // https://github.com/mishoo/UglifyJS/issues/#issue/100 - if (/^@cc_on/i.test(text)) { - warn("WARNING: at line " + S.line); - warn("*** Found \"conditional comment\": " + text); - warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer."); - } - - return tok; - }); - }; - - function read_name() { - var backslash = false, name = "", ch; - while ((ch = peek()) != null) { - if (!backslash) { - if (ch == "\\") backslash = true, next(); - else if (is_identifier_char(ch)) name += next(); - else break; - } - else { - if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX"); - ch = read_escaped_char(); - if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier"); - name += ch; - backslash = false; - } - } - return name; - }; - - function read_regexp() { - return with_eof_error("Unterminated regular expression", function(){ - var prev_backslash = false, regexp = "", ch, in_class = false; - while ((ch = next(true))) if (prev_backslash) { - regexp += "\\" + ch; - prev_backslash = false; - } else if (ch == "[") { - in_class = true; - regexp += ch; - } else if (ch == "]" && in_class) { - in_class = false; - regexp += ch; - } else if (ch == "/" && !in_class) { - break; - } else if (ch == "\\") { - prev_backslash = true; - } else { - regexp += ch; - } - var mods = read_name(); - return token("regexp", [ regexp, mods ]); - }); - }; - - function read_operator(prefix) { - function grow(op) { - if (!peek()) return op; - var bigger = op + peek(); - if (HOP(OPERATORS, bigger)) { - next(); - return grow(bigger); - } else { - return op; - } - }; - return token("operator", grow(prefix || next())); - }; - - function handle_slash() { - next(); - var regex_allowed = S.regex_allowed; - switch (peek()) { - case "/": - S.comments_before.push(read_line_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - case "*": - S.comments_before.push(read_multiline_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - } - return S.regex_allowed ? read_regexp() : read_operator("/"); - }; - - function handle_dot() { - next(); - return is_digit(peek()) - ? read_num(".") - : token("punc", "."); - }; - - function read_word() { - var word = read_name(); - return !HOP(KEYWORDS, word) - ? token("name", word) - : HOP(OPERATORS, word) - ? token("operator", word) - : HOP(KEYWORDS_ATOM, word) - ? token("atom", word) - : token("keyword", word); - }; - - function with_eof_error(eof_error, cont) { - try { - return cont(); - } catch(ex) { - if (ex === EX_EOF) parse_error(eof_error); - else throw ex; - } - }; - - function next_token(force_regexp) { - if (force_regexp) - return read_regexp(); - skip_whitespace(); - start_token(); - var ch = peek(); - if (!ch) return token("eof"); - if (is_digit(ch)) return read_num(); - if (ch == '"' || ch == "'") return read_string(); - if (HOP(PUNC_CHARS, ch)) return token("punc", next()); - if (ch == ".") return handle_dot(); - if (ch == "/") return handle_slash(); - if (HOP(OPERATOR_CHARS, ch)) return read_operator(); - if (ch == "\\" || is_identifier_start(ch)) return read_word(); - parse_error("Unexpected character '" + ch + "'"); - }; - - next_token.context = function(nc) { - if (nc) S = nc; - return S; - }; - - return next_token; - -}; - -/* -----[ Parser (constants) ]----- */ - -var UNARY_PREFIX = array_to_hash([ - "typeof", - "void", - "delete", - "--", - "++", - "!", - "~", - "-", - "+" -]); - -var UNARY_POSTFIX = array_to_hash([ "--", "++" ]); - -var ASSIGNMENT = (function(a, ret, i){ - while (i < a.length) { - ret[a[i]] = a[i].substr(0, a[i].length - 1); - i++; - } - return ret; -})( - ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="], - { "=": true }, - 0 -); - -var PRECEDENCE = (function(a, ret){ - for (var i = 0, n = 1; i < a.length; ++i, ++n) { - var b = a[i]; - for (var j = 0; j < b.length; ++j) { - ret[b[j]] = n; - } - } - return ret; -})( - [ - ["||"], - ["&&"], - ["|"], - ["^"], - ["&"], - ["==", "===", "!=", "!=="], - ["<", ">", "<=", ">=", "in", "instanceof"], - [">>", "<<", ">>>"], - ["+", "-"], - ["*", "/", "%"] - ], - {} -); - -var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]); - -var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]); - -/* -----[ Parser ]----- */ - -function NodeWithToken(str, start, end) { - this.name = str; - this.start = start; - this.end = end; -}; - -NodeWithToken.prototype.toString = function() { return this.name; }; - -function parse($TEXT, exigent_mode, embed_tokens) { - - var S = { - input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT, - token : null, - prev : null, - peeked : null, - in_function : 0, - in_loop : 0, - labels : [] - }; - - S.token = next(); - - function is(type, value) { - return is_token(S.token, type, value); - }; - - function peek() { return S.peeked || (S.peeked = S.input()); }; - - function next() { - S.prev = S.token; - if (S.peeked) { - S.token = S.peeked; - S.peeked = null; - } else { - S.token = S.input(); - } - return S.token; - }; - - function prev() { - return S.prev; - }; - - function croak(msg, line, col, pos) { - var ctx = S.input.context(); - js_error(msg, - line != null ? line : ctx.tokline, - col != null ? col : ctx.tokcol, - pos != null ? pos : ctx.tokpos); - }; - - function token_error(token, msg) { - croak(msg, token.line, token.col); - }; - - function unexpected(token) { - if (token == null) - token = S.token; - token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); - }; - - function expect_token(type, val) { - if (is(type, val)) { - return next(); - } - token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); - }; - - function expect(punc) { return expect_token("punc", punc); }; - - function can_insert_semicolon() { - return !exigent_mode && ( - S.token.nlb || is("eof") || is("punc", "}") - ); - }; - - function semicolon() { - if (is("punc", ";")) next(); - else if (!can_insert_semicolon()) unexpected(); - }; - - function as() { - return slice(arguments); - }; - - function parenthesised() { - expect("("); - var ex = expression(); - expect(")"); - return ex; - }; - - function add_tokens(str, start, end) { - return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end); - }; - - function maybe_embed_tokens(parser) { - if (embed_tokens) return function() { - var start = S.token; - var ast = parser.apply(this, arguments); - ast[0] = add_tokens(ast[0], start, prev()); - return ast; - }; - else return parser; - }; - - var statement = maybe_embed_tokens(function() { - if (is("operator", "/")) { - S.peeked = null; - S.token = S.input(true); // force regexp - } - switch (S.token.type) { - case "num": - case "string": - case "regexp": - case "operator": - case "atom": - return simple_statement(); - - case "name": - return is_token(peek(), "punc", ":") - ? labeled_statement(prog1(S.token.value, next, next)) - : simple_statement(); - - case "punc": - switch (S.token.value) { - case "{": - return as("block", block_()); - case "[": - case "(": - return simple_statement(); - case ";": - next(); - return as("block"); - default: - unexpected(); - } - - case "keyword": - switch (prog1(S.token.value, next)) { - case "break": - return break_cont("break"); - - case "continue": - return break_cont("continue"); - - case "debugger": - semicolon(); - return as("debugger"); - - case "do": - return (function(body){ - expect_token("keyword", "while"); - return as("do", prog1(parenthesised, semicolon), body); - })(in_loop(statement)); - - case "for": - return for_(); - - case "function": - return function_(true); - - case "if": - return if_(); - - case "return": - if (S.in_function == 0) - croak("'return' outside of function"); - return as("return", - is("punc", ";") - ? (next(), null) - : can_insert_semicolon() - ? null - : prog1(expression, semicolon)); - - case "switch": - return as("switch", parenthesised(), switch_block_()); - - case "throw": - return as("throw", prog1(expression, semicolon)); - - case "try": - return try_(); - - case "var": - return prog1(var_, semicolon); - - case "const": - return prog1(const_, semicolon); - - case "while": - return as("while", parenthesised(), in_loop(statement)); - - case "with": - return as("with", parenthesised(), statement()); - - default: - unexpected(); - } - } - }); - - function labeled_statement(label) { - S.labels.push(label); - var start = S.token, stat = statement(); - if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0])) - unexpected(start); - S.labels.pop(); - return as("label", label, stat); - }; - - function simple_statement() { - return as("stat", prog1(expression, semicolon)); - }; - - function break_cont(type) { - var name; - if (!can_insert_semicolon()) { - name = is("name") ? S.token.value : null; - } - if (name != null) { - next(); - if (!member(name, S.labels)) - croak("Label " + name + " without matching loop or statement"); - } - else if (S.in_loop == 0) - croak(type + " not inside a loop or switch"); - semicolon(); - return as(type, name); - }; - - function for_() { - expect("("); - var init = null; - if (!is("punc", ";")) { - init = is("keyword", "var") - ? (next(), var_(true)) - : expression(true, true); - if (is("operator", "in")) - return for_in(init); - } - return regular_for(init); - }; - - function regular_for(init) { - expect(";"); - var test = is("punc", ";") ? null : expression(); - expect(";"); - var step = is("punc", ")") ? null : expression(); - expect(")"); - return as("for", init, test, step, in_loop(statement)); - }; - - function for_in(init) { - var lhs = init[0] == "var" ? as("name", init[1][0]) : init; - next(); - var obj = expression(); - expect(")"); - return as("for-in", init, lhs, obj, in_loop(statement)); - }; - - var function_ = maybe_embed_tokens(function(in_statement) { - var name = is("name") ? prog1(S.token.value, next) : null; - if (in_statement && !name) - unexpected(); - expect("("); - return as(in_statement ? "defun" : "function", - name, - // arguments - (function(first, a){ - while (!is("punc", ")")) { - if (first) first = false; else expect(","); - if (!is("name")) unexpected(); - a.push(S.token.value); - next(); - } - next(); - return a; - })(true, []), - // body - (function(){ - ++S.in_function; - var loop = S.in_loop; - S.in_loop = 0; - var a = block_(); - --S.in_function; - S.in_loop = loop; - return a; - })()); - }); - - function if_() { - var cond = parenthesised(), body = statement(), belse; - if (is("keyword", "else")) { - next(); - belse = statement(); - } - return as("if", cond, body, belse); - }; - - function block_() { - expect("{"); - var a = []; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - a.push(statement()); - } - next(); - return a; - }; - - var switch_block_ = curry(in_loop, function(){ - expect("{"); - var a = [], cur = null; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - if (is("keyword", "case")) { - next(); - cur = []; - a.push([ expression(), cur ]); - expect(":"); - } - else if (is("keyword", "default")) { - next(); - expect(":"); - cur = []; - a.push([ null, cur ]); - } - else { - if (!cur) unexpected(); - cur.push(statement()); - } - } - next(); - return a; - }); - - function try_() { - var body = block_(), bcatch, bfinally; - if (is("keyword", "catch")) { - next(); - expect("("); - if (!is("name")) - croak("Name expected"); - var name = S.token.value; - next(); - expect(")"); - bcatch = [ name, block_() ]; - } - if (is("keyword", "finally")) { - next(); - bfinally = block_(); - } - if (!bcatch && !bfinally) - croak("Missing catch/finally blocks"); - return as("try", body, bcatch, bfinally); - }; - - function vardefs(no_in) { - var a = []; - for (;;) { - if (!is("name")) - unexpected(); - var name = S.token.value; - next(); - if (is("operator", "=")) { - next(); - a.push([ name, expression(false, no_in) ]); - } else { - a.push([ name ]); - } - if (!is("punc", ",")) - break; - next(); - } - return a; - }; - - function var_(no_in) { - return as("var", vardefs(no_in)); - }; - - function const_() { - return as("const", vardefs()); - }; - - function new_() { - var newexp = expr_atom(false), args; - if (is("punc", "(")) { - next(); - args = expr_list(")"); - } else { - args = []; - } - return subscripts(as("new", newexp, args), true); - }; - - var expr_atom = maybe_embed_tokens(function(allow_calls) { - if (is("operator", "new")) { - next(); - return new_(); - } - if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) { - return make_unary("unary-prefix", - prog1(S.token.value, next), - expr_atom(allow_calls)); - } - if (is("punc")) { - switch (S.token.value) { - case "(": - next(); - return subscripts(prog1(expression, curry(expect, ")")), allow_calls); - case "[": - next(); - return subscripts(array_(), allow_calls); - case "{": - next(); - return subscripts(object_(), allow_calls); - } - unexpected(); - } - if (is("keyword", "function")) { - next(); - return subscripts(function_(false), allow_calls); - } - if (HOP(ATOMIC_START_TOKEN, S.token.type)) { - var atom = S.token.type == "regexp" - ? as("regexp", S.token.value[0], S.token.value[1]) - : as(S.token.type, S.token.value); - return subscripts(prog1(atom, next), allow_calls); - } - unexpected(); - }); - - function expr_list(closing, allow_trailing_comma, allow_empty) { - var first = true, a = []; - while (!is("punc", closing)) { - if (first) first = false; else expect(","); - if (allow_trailing_comma && is("punc", closing)) break; - if (is("punc", ",") && allow_empty) { - a.push([ "atom", "undefined" ]); - } else { - a.push(expression(false)); - } - } - next(); - return a; - }; - - function array_() { - return as("array", expr_list("]", !exigent_mode, true)); - }; - - function object_() { - var first = true, a = []; - while (!is("punc", "}")) { - if (first) first = false; else expect(","); - if (!exigent_mode && is("punc", "}")) - // allow trailing comma - break; - var type = S.token.type; - var name = as_property_name(); - if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) { - a.push([ as_name(), function_(false), name ]); - } else { - expect(":"); - a.push([ name, expression(false) ]); - } - } - next(); - return as("object", a); - }; - - function as_property_name() { - switch (S.token.type) { - case "num": - case "string": - return prog1(S.token.value, next); - } - return as_name(); - }; - - function as_name() { - switch (S.token.type) { - case "name": - case "operator": - case "keyword": - case "atom": - return prog1(S.token.value, next); - default: - unexpected(); - } - }; - - function subscripts(expr, allow_calls) { - if (is("punc", ".")) { - next(); - return subscripts(as("dot", expr, as_name()), allow_calls); - } - if (is("punc", "[")) { - next(); - return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls); - } - if (allow_calls && is("punc", "(")) { - next(); - return subscripts(as("call", expr, expr_list(")")), true); - } - if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) { - return prog1(curry(make_unary, "unary-postfix", S.token.value, expr), - next); - } - return expr; - }; - - function make_unary(tag, op, expr) { - if ((op == "++" || op == "--") && !is_assignable(expr)) - croak("Invalid use of " + op + " operator"); - return as(tag, op, expr); - }; - - function expr_op(left, min_prec, no_in) { - var op = is("operator") ? S.token.value : null; - if (op && op == "in" && no_in) op = null; - var prec = op != null ? PRECEDENCE[op] : null; - if (prec != null && prec > min_prec) { - next(); - var right = expr_op(expr_atom(true), prec, no_in); - return expr_op(as("binary", op, left, right), min_prec, no_in); - } - return left; - }; - - function expr_ops(no_in) { - return expr_op(expr_atom(true), 0, no_in); - }; - - function maybe_conditional(no_in) { - var expr = expr_ops(no_in); - if (is("operator", "?")) { - next(); - var yes = expression(false); - expect(":"); - return as("conditional", expr, yes, expression(false, no_in)); - } - return expr; - }; - - function is_assignable(expr) { - if (!exigent_mode) return true; - switch (expr[0]) { - case "dot": - case "sub": - case "new": - case "call": - return true; - case "name": - return expr[1] != "this"; - } - }; - - function maybe_assign(no_in) { - var left = maybe_conditional(no_in), val = S.token.value; - if (is("operator") && HOP(ASSIGNMENT, val)) { - if (is_assignable(left)) { - next(); - return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in)); - } - croak("Invalid assignment"); - } - return left; - }; - - var expression = maybe_embed_tokens(function(commas, no_in) { - if (arguments.length == 0) - commas = true; - var expr = maybe_assign(no_in); - if (commas && is("punc", ",")) { - next(); - return as("seq", expr, expression(true, no_in)); - } - return expr; - }); - - function in_loop(cont) { - try { - ++S.in_loop; - return cont(); - } finally { - --S.in_loop; - } - }; - - return as("toplevel", (function(a){ - while (!is("eof")) - a.push(statement()); - return a; - })([])); - -}; - -/* -----[ Utilities ]----- */ - -function curry(f) { - var args = slice(arguments, 1); - return function() { return f.apply(this, args.concat(slice(arguments))); }; -}; - -function prog1(ret) { - if (ret instanceof Function) - ret = ret(); - for (var i = 1, n = arguments.length; --n > 0; ++i) - arguments[i](); - return ret; -}; - -function array_to_hash(a) { - var ret = {}; - for (var i = 0; i < a.length; ++i) - ret[a[i]] = true; - return ret; -}; - -function slice(a, start) { - return Array.prototype.slice.call(a, start == null ? 0 : start); -}; - -function characters(str) { - return str.split(""); -}; - -function member(name, array) { - for (var i = array.length; --i >= 0;) - if (array[i] === name) - return true; - return false; -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -var warn = function() {}; - -/* -----[ Exports ]----- */ - -exports.tokenizer = tokenizer; -exports.parse = parse; -exports.slice = slice; -exports.curry = curry; -exports.member = member; -exports.array_to_hash = array_to_hash; -exports.PRECEDENCE = PRECEDENCE; -exports.KEYWORDS_ATOM = KEYWORDS_ATOM; -exports.RESERVED_WORDS = RESERVED_WORDS; -exports.KEYWORDS = KEYWORDS; -exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; -exports.OPERATORS = OPERATORS; -exports.is_alphanumeric_char = is_alphanumeric_char; -exports.set_logger = function(logger) { - warn = logger; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/process.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file implements some AST processors. They work on data built - by parse-js. - - Exported functions: - - - ast_mangle(ast, options) -- mangles the variable/function names - in the AST. Returns an AST. - - - ast_squeeze(ast) -- employs various optimizations to make the - final generated code even smaller. Returns an AST. - - - gen_code(ast, options) -- generates JS code from the AST. Pass - true (or an object, see the code for some options) as second - argument to get "pretty" (indented) code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - - 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. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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. - - ***********************************************************************/ - -var jsp = require("./parse-js"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -/* -----[ helper for AST traversal ]----- */ - -function ast_walker(ast) { - function _vardefs(defs) { - return [ this[0], MAP(defs, function(def){ - var a = [ def[0] ]; - if (def.length > 1) - a[1] = walk(def[1]); - return a; - }) ]; - }; - function _block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(MAP(statements, walk)); - return out; - }; - var walkers = { - "string": function(str) { - return [ this[0], str ]; - }, - "num": function(num) { - return [ this[0], num ]; - }, - "name": function(name) { - return [ this[0], name ]; - }, - "toplevel": function(statements) { - return [ this[0], MAP(statements, walk) ]; - }, - "block": _block, - "splice": _block, - "var": _vardefs, - "const": _vardefs, - "try": function(t, c, f) { - return [ - this[0], - MAP(t, walk), - c != null ? [ c[0], MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null - ]; - }, - "throw": function(expr) { - return [ this[0], walk(expr) ]; - }, - "new": function(ctor, args) { - return [ this[0], walk(ctor), MAP(args, walk) ]; - }, - "switch": function(expr, body) { - return [ this[0], walk(expr), MAP(body, function(branch){ - return [ branch[0] ? walk(branch[0]) : null, - MAP(branch[1], walk) ]; - }) ]; - }, - "break": function(label) { - return [ this[0], label ]; - }, - "continue": function(label) { - return [ this[0], label ]; - }, - "conditional": function(cond, t, e) { - return [ this[0], walk(cond), walk(t), walk(e) ]; - }, - "assign": function(op, lvalue, rvalue) { - return [ this[0], op, walk(lvalue), walk(rvalue) ]; - }, - "dot": function(expr) { - return [ this[0], walk(expr) ].concat(slice(arguments, 1)); - }, - "call": function(expr, args) { - return [ this[0], walk(expr), MAP(args, walk) ]; - }, - "function": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "defun": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "if": function(conditional, t, e) { - return [ this[0], walk(conditional), walk(t), walk(e) ]; - }, - "for": function(init, cond, step, block) { - return [ this[0], walk(init), walk(cond), walk(step), walk(block) ]; - }, - "for-in": function(vvar, key, hash, block) { - return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ]; - }, - "while": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "do": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "return": function(expr) { - return [ this[0], walk(expr) ]; - }, - "binary": function(op, left, right) { - return [ this[0], op, walk(left), walk(right) ]; - }, - "unary-prefix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "unary-postfix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "sub": function(expr, subscript) { - return [ this[0], walk(expr), walk(subscript) ]; - }, - "object": function(props) { - return [ this[0], MAP(props, function(p){ - return p.length == 2 - ? [ p[0], walk(p[1]) ] - : [ p[0], walk(p[1]), p[2] ]; // get/set-ter - }) ]; - }, - "regexp": function(rx, mods) { - return [ this[0], rx, mods ]; - }, - "array": function(elements) { - return [ this[0], MAP(elements, walk) ]; - }, - "stat": function(stat) { - return [ this[0], walk(stat) ]; - }, - "seq": function() { - return [ this[0] ].concat(MAP(slice(arguments), walk)); - }, - "label": function(name, block) { - return [ this[0], name, walk(block) ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), walk(block) ]; - }, - "atom": function(name) { - return [ this[0], name ]; - } - }; - - var user = {}; - var stack = []; - function walk(ast) { - if (ast == null) - return null; - try { - stack.push(ast); - var type = ast[0]; - var gen = user[type]; - if (gen) { - var ret = gen.apply(ast, ast.slice(1)); - if (ret != null) - return ret; - } - gen = walkers[type]; - return gen.apply(ast, ast.slice(1)); - } finally { - stack.pop(); - } - }; - - function with_walkers(walkers, cont){ - var save = {}, i; - for (i in walkers) if (HOP(walkers, i)) { - save[i] = user[i]; - user[i] = walkers[i]; - } - var ret = cont(); - for (i in save) if (HOP(save, i)) { - if (!save[i]) delete user[i]; - else user[i] = save[i]; - } - return ret; - }; - - return { - walk: walk, - with_walkers: with_walkers, - parent: function() { - return stack[stack.length - 2]; // last one is current node - }, - stack: function() { - return stack; - } - }; -}; - -/* -----[ Scope and mangling ]----- */ - -function Scope(parent) { - this.names = {}; // names defined in this scope - this.mangled = {}; // mangled names (orig.name => mangled) - this.rev_mangled = {}; // reverse lookup (mangled => orig.name) - this.cname = -1; // current mangled name - this.refs = {}; // names referenced from this scope - this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes - this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes - this.parent = parent; // parent scope - this.children = []; // sub-scopes - if (parent) { - this.level = parent.level + 1; - parent.children.push(this); - } else { - this.level = 0; - } -}; - -var base54 = (function(){ - var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; - return function(num) { - var ret = ""; - do { - ret = DIGITS.charAt(num % 54) + ret; - num = Math.floor(num / 54); - } while (num > 0); - return ret; - }; -})(); - -Scope.prototype = { - has: function(name) { - for (var s = this; s; s = s.parent) - if (HOP(s.names, name)) - return s; - }, - has_mangled: function(mname) { - for (var s = this; s; s = s.parent) - if (HOP(s.rev_mangled, mname)) - return s; - }, - toJSON: function() { - return { - names: this.names, - uses_eval: this.uses_eval, - uses_with: this.uses_with - }; - }, - - next_mangled: function() { - // we must be careful that the new mangled name: - // - // 1. doesn't shadow a mangled name from a parent - // scope, unless we don't reference the original - // name from this scope OR from any sub-scopes! - // This will get slow. - // - // 2. doesn't shadow an original name from a parent - // scope, in the event that the name is not mangled - // in the parent scope and we reference that name - // here OR IN ANY SUBSCOPES! - // - // 3. doesn't shadow a name that is referenced but not - // defined (possibly global defined elsewhere). - for (;;) { - var m = base54(++this.cname), prior; - - // case 1. - prior = this.has_mangled(m); - if (prior && this.refs[prior.rev_mangled[m]] === prior) - continue; - - // case 2. - prior = this.has(m); - if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m)) - continue; - - // case 3. - if (HOP(this.refs, m) && this.refs[m] == null) - continue; - - // I got "do" once. :-/ - if (!is_identifier(m)) - continue; - - return m; - } - }, - set_mangle: function(name, m) { - this.rev_mangled[m] = name; - return this.mangled[name] = m; - }, - get_mangled: function(name, newMangle) { - if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use - var s = this.has(name); - if (!s) return name; // not in visible scope, no mangle - if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope - if (!newMangle) return name; // not found and no mangling requested - return s.set_mangle(name, s.next_mangled()); - }, - define: function(name) { - if (name != null) - return this.names[name] = name; - } -}; - -function ast_add_scope(ast) { - - var current_scope = null; - var w = ast_walker(), walk = w.walk; - var having_eval = []; - - function with_new_scope(cont) { - current_scope = new Scope(current_scope); - var ret = current_scope.body = cont(); - ret.scope = current_scope; - current_scope = current_scope.parent; - return ret; - }; - - function define(name) { - return current_scope.define(name); - }; - - function reference(name) { - current_scope.refs[name] = true; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - return [ this[0], is_defun ? define(name) : name, args, with_new_scope(function(){ - if (!is_defun) define(name); - MAP(args, define); - return MAP(body, walk); - })]; - }; - - return with_new_scope(function(){ - // process AST - var ret = w.with_walkers({ - "function": _lambda, - "defun": _lambda, - "with": function(expr, block) { - for (var s = current_scope; s; s = s.parent) - s.uses_with = true; - }, - "var": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "const": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "try": function(t, c, f) { - if (c != null) return [ - this[0], - MAP(t, walk), - [ define(c[0]), MAP(c[1], walk) ], - f != null ? MAP(f, walk) : null - ]; - }, - "name": function(name) { - if (name == "eval") - having_eval.push(current_scope); - reference(name); - } - }, function(){ - return walk(ast); - }); - - // the reason why we need an additional pass here is - // that names can be used prior to their definition. - - // scopes where eval was detected and their parents - // are marked with uses_eval, unless they define the - // "eval" name. - MAP(having_eval, function(scope){ - if (!scope.has("eval")) while (scope) { - scope.uses_eval = true; - scope = scope.parent; - } - }); - - // for referenced names it might be useful to know - // their origin scope. current_scope here is the - // toplevel one. - function fixrefs(scope, i) { - // do children first; order shouldn't matter - for (i = scope.children.length; --i >= 0;) - fixrefs(scope.children[i]); - for (i in scope.refs) if (HOP(scope.refs, i)) { - // find origin scope and propagate the reference to origin - for (var origin = scope.has(i), s = scope; s; s = s.parent) { - s.refs[i] = origin; - if (s === origin) break; - } - } - }; - fixrefs(current_scope); - - return ret; - }); - -}; - -/* -----[ mangle names ]----- */ - -function ast_mangle(ast, options) { - var w = ast_walker(), walk = w.walk, scope; - options = options || {}; - - function get_mangled(name, newMangle) { - if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel - if (options.except && member(name, options.except)) - return name; - return scope.get_mangled(name, newMangle); - }; - - function get_define(name) { - if (options.defines) { - // we always lookup a defined symbol for the current scope FIRST, so declared - // vars trump a DEFINE symbol, but if no such var is found, then match a DEFINE value - if (!scope.has(name)) { - if (HOP(options.defines, name)) { - return options.defines[name]; - } - } - return null; - } - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun", extra; - if (name) { - if (is_defun) name = get_mangled(name); - else { - extra = {}; - name = extra[name] = scope.next_mangled(); - } - } - body = with_scope(body.scope, function(){ - args = MAP(args, function(name){ return get_mangled(name) }); - return MAP(body, walk); - }, extra); - return [ this[0], name, args, body ]; - }; - - function with_scope(s, cont, extra) { - var _scope = scope; - scope = s; - if (extra) for (var i in extra) if (HOP(extra, i)) { - s.set_mangle(i, extra[i]); - } - for (var i in s.names) if (HOP(s.names, i)) { - get_mangled(i, true); - } - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function _vardefs(defs) { - return [ this[0], MAP(defs, function(d){ - return [ get_mangled(d[0]), walk(d[1]) ]; - }) ]; - }; - - return w.with_walkers({ - "function": _lambda, - "defun": function() { - // move function declarations to the top when - // they are not in some block. - var ast = _lambda.apply(this, arguments); - switch (w.parent()[0]) { - case "toplevel": - case "function": - case "defun": - return MAP.at_top(ast); - } - return ast; - }, - "var": _vardefs, - "const": _vardefs, - "name": function(name) { - return get_define(name) || [ this[0], get_mangled(name) ]; - }, - "try": function(t, c, f) { - return [ this[0], - MAP(t, walk), - c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null ]; - }, - "toplevel": function(body) { - var self = this; - return with_scope(self.scope, function(){ - return [ self[0], MAP(body, walk) ]; - }); - } - }, function() { - return walk(ast_add_scope(ast)); - }); -}; - -/* -----[ - - compress foo["bar"] into foo.bar, - - remove block brackets {} where possible - - join consecutive var declarations - - various optimizations for IFs: - - if (cond) foo(); else bar(); ==> cond?foo():bar(); - - if (cond) foo(); ==> cond&&foo(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - ]----- */ - -var warn = function(){}; - -function best_of(ast1, ast2) { - return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1; -}; - -function last_stat(b) { - if (b[0] == "block" && b[1] && b[1].length > 0) - return b[1][b[1].length - 1]; - return b; -} - -function aborts(t) { - if (t) { - t = last_stat(t); - if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw") - return true; - } -}; - -function boolean_expr(expr) { - return ( (expr[0] == "unary-prefix" - && member(expr[1], [ "!", "delete" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "&&", "||" ]) - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "conditional" - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "assign" - && expr[1] === true - && boolean_expr(expr[3])) || - - (expr[0] == "seq" - && boolean_expr(expr[expr.length - 1])) - ); -}; - -function make_conditional(c, t, e) { - var make_real_conditional = function() { - if (c[0] == "unary-prefix" && c[1] == "!") { - return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ]; - } else { - return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ]; - } - }; - // shortcut the conditional if the expression has a constant value - return when_constant(c, function(ast, val){ - warn_unreachable(val ? e : t); - return (val ? t : e); - }, make_real_conditional); -}; - -function empty(b) { - return !b || (b[0] == "block" && (!b[1] || b[1].length == 0)); -}; - -function is_string(node) { - return (node[0] == "string" || - node[0] == "unary-prefix" && node[1] == "typeof" || - node[0] == "binary" && node[1] == "+" && - (is_string(node[2]) || is_string(node[3]))); -}; - -var when_constant = (function(){ - - var $NOT_CONSTANT = {}; - - // this can only evaluate constant expressions. If it finds anything - // not constant, it throws $NOT_CONSTANT. - function evaluate(expr) { - switch (expr[0]) { - case "string": - case "num": - return expr[1]; - case "name": - case "atom": - switch (expr[1]) { - case "true": return true; - case "false": return false; - } - break; - case "unary-prefix": - switch (expr[1]) { - case "!": return !evaluate(expr[2]); - case "typeof": return typeof evaluate(expr[2]); - case "~": return ~evaluate(expr[2]); - case "-": return -evaluate(expr[2]); - case "+": return +evaluate(expr[2]); - } - break; - case "binary": - var left = expr[2], right = expr[3]; - switch (expr[1]) { - case "&&" : return evaluate(left) && evaluate(right); - case "||" : return evaluate(left) || evaluate(right); - case "|" : return evaluate(left) | evaluate(right); - case "&" : return evaluate(left) & evaluate(right); - case "^" : return evaluate(left) ^ evaluate(right); - case "+" : return evaluate(left) + evaluate(right); - case "*" : return evaluate(left) * evaluate(right); - case "/" : return evaluate(left) / evaluate(right); - case "-" : return evaluate(left) - evaluate(right); - case "<<" : return evaluate(left) << evaluate(right); - case ">>" : return evaluate(left) >> evaluate(right); - case ">>>" : return evaluate(left) >>> evaluate(right); - case "==" : return evaluate(left) == evaluate(right); - case "===" : return evaluate(left) === evaluate(right); - case "!=" : return evaluate(left) != evaluate(right); - case "!==" : return evaluate(left) !== evaluate(right); - case "<" : return evaluate(left) < evaluate(right); - case "<=" : return evaluate(left) <= evaluate(right); - case ">" : return evaluate(left) > evaluate(right); - case ">=" : return evaluate(left) >= evaluate(right); - case "in" : return evaluate(left) in evaluate(right); - case "instanceof" : return evaluate(left) instanceof evaluate(right); - } - } - throw $NOT_CONSTANT; - }; - - return function(expr, yes, no) { - try { - var val = evaluate(expr), ast; - switch (typeof val) { - case "string": ast = [ "string", val ]; break; - case "number": ast = [ "num", val ]; break; - case "boolean": ast = [ "name", String(val) ]; break; - default: throw new Error("Can't handle constant of type: " + (typeof val)); - } - return yes.call(expr, ast, val); - } catch(ex) { - if (ex === $NOT_CONSTANT) { - if (expr[0] == "binary" - && (expr[1] == "===" || expr[1] == "!==") - && ((is_string(expr[2]) && is_string(expr[3])) - || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) { - expr[1] = expr[1].substr(0, 2); - } - else if (no && expr[0] == "binary" - && (expr[1] == "||" || expr[1] == "&&")) { - // the whole expression is not constant but the lval may be... - try { - var lval = evaluate(expr[2]); - expr = ((expr[1] == "&&" && (lval ? expr[3] : lval)) || - (expr[1] == "||" && (lval ? lval : expr[3])) || - expr); - } catch(ex2) { - // IGNORE... lval is not constant - } - } - return no ? no.call(expr, expr) : null; - } - else throw ex; - } - }; - -})(); - -function warn_unreachable(ast) { - if (!empty(ast)) - warn("Dropping unreachable code: " + gen_code(ast, true)); -}; - -function prepare_ifs(ast) { - var w = ast_walker(), walk = w.walk; - // In this first pass, we rewrite ifs which abort with no else with an - // if-else. For example: - // - // if (x) { - // blah(); - // return y; - // } - // foobar(); - // - // is rewritten into: - // - // if (x) { - // blah(); - // return y; - // } else { - // foobar(); - // } - function redo_if(statements) { - statements = MAP(statements, walk); - - for (var i = 0; i < statements.length; ++i) { - var fi = statements[i]; - if (fi[0] != "if") continue; - - if (fi[3] && walk(fi[3])) continue; - - var t = walk(fi[2]); - if (!aborts(t)) continue; - - var conditional = walk(fi[1]); - - var e_body = statements.slice(i + 1); - var e; - if (e_body.length == 1) e = e_body[0]; - else e = [ "block", e_body ]; - - var ret = statements.slice(0, i).concat([ [ - fi[0], // "if" - conditional, // conditional - t, // then - e // else - ] ]); - - return redo_if(ret); - } - - return statements; - }; - - function redo_if_lambda(name, args, body) { - body = redo_if(body); - return [ this[0], name, args.slice(), body ]; - }; - - function redo_if_block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(redo_if(statements)); - return out; - }; - - return w.with_walkers({ - "defun": redo_if_lambda, - "function": redo_if_lambda, - "block": redo_if_block, - "splice": redo_if_block, - "toplevel": function(statements) { - return [ this[0], redo_if(statements) ]; - }, - "try": function(t, c, f) { - return [ - this[0], - redo_if(t), - c != null ? [ c[0], redo_if(c[1]) ] : null, - f != null ? redo_if(f) : null - ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), redo_if(block) ]; - } - }, function() { - return walk(ast); - }); -}; - -function ast_squeeze(ast, options) { - options = defaults(options, { - make_seqs : true, - dead_code : true, - keep_comps : true, - no_warnings : false - }); - - var w = ast_walker(), walk = w.walk, scope; - - function negate(c) { - var not_c = [ "unary-prefix", "!", c ]; - switch (c[0]) { - case "unary-prefix": - return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c; - case "seq": - c = slice(c); - c[c.length - 1] = negate(c[c.length - 1]); - return c; - case "conditional": - return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]); - case "binary": - var op = c[1], left = c[2], right = c[3]; - if (!options.keep_comps) switch (op) { - case "<=" : return [ "binary", ">", left, right ]; - case "<" : return [ "binary", ">=", left, right ]; - case ">=" : return [ "binary", "<", left, right ]; - case ">" : return [ "binary", "<=", left, right ]; - } - switch (op) { - case "==" : return [ "binary", "!=", left, right ]; - case "!=" : return [ "binary", "==", left, right ]; - case "===" : return [ "binary", "!==", left, right ]; - case "!==" : return [ "binary", "===", left, right ]; - case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]); - case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]); - } - break; - } - return not_c; - }; - - function with_scope(s, cont) { - var _scope = scope; - scope = s; - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function rmblock(block) { - if (block != null && block[0] == "block" && block[1]) { - if (block[1].length == 1) - block = block[1][0]; - else if (block[1].length == 0) - block = [ "block" ]; - } - return block; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - body = with_scope(body.scope, function(){ - var ret = tighten(MAP(body, walk), "lambda"); - if (!is_defun && name && !HOP(scope.refs, name)) - name = null; - return ret; - }); - return [ this[0], name, args, body ]; - }; - - // we get here for blocks that have been already transformed. - // this function does a few things: - // 1. discard useless blocks - // 2. join consecutive var declarations - // 3. remove obviously dead code - // 4. transform consecutive statements using the comma operator - // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... } - function tighten(statements, block_type) { - statements = statements.reduce(function(a, stat){ - if (stat[0] == "block") { - if (stat[1]) { - a.push.apply(a, stat[1]); - } - } else { - a.push(stat); - } - return a; - }, []); - - statements = (function(a, prev){ - statements.forEach(function(cur){ - if (prev && ((cur[0] == "var" && prev[0] == "var") || - (cur[0] == "const" && prev[0] == "const"))) { - prev[1] = prev[1].concat(cur[1]); - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (options.dead_code) statements = (function(a, has_quit){ - statements.forEach(function(st){ - if (has_quit) { - if (member(st[0], [ "function", "defun" , "var", "const" ])) { - a.push(st); - } - else if (!options.no_warnings) - warn_unreachable(st); - } - else { - a.push(st); - if (member(st[0], [ "return", "throw", "break", "continue" ])) - has_quit = true; - } - }); - return a; - })([]); - - if (options.make_seqs) statements = (function(a, prev) { - statements.forEach(function(cur){ - if (prev && prev[0] == "stat" && cur[0] == "stat") { - prev[1] = [ "seq", prev[1], cur[1] ]; - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (block_type == "lambda") statements = (function(i, a, stat){ - while (i < statements.length) { - stat = statements[i++]; - if (stat[0] == "if" && !stat[3]) { - if (stat[2][0] == "return" && stat[2][1] == null) { - a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ])); - break; - } - var last = last_stat(stat[2]); - if (last[0] == "return" && last[1] == null) { - a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ])); - break; - } - } - a.push(stat); - } - return a; - })(0, []); - - return statements; - }; - - function make_if(c, t, e) { - return when_constant(c, function(ast, val){ - if (val) { - warn_unreachable(e); - return t; - } else { - warn_unreachable(t); - return e; - } - }, function() { - return make_real_if(c, t, e); - }); - }; - - function make_real_if(c, t, e) { - c = walk(c); - t = walk(t); - e = walk(e); - - if (empty(t)) { - c = negate(c); - t = e; - e = null; - } else if (empty(e)) { - e = null; - } else { - // if we have both else and then, maybe it makes sense to switch them? - (function(){ - var a = gen_code(c); - var n = negate(c); - var b = gen_code(n); - if (b.length < a.length) { - var tmp = t; - t = e; - e = tmp; - c = n; - } - })(); - } - if (empty(e) && empty(t)) - return [ "stat", c ]; - var ret = [ "if", c, t, e ]; - if (t[0] == "if" && empty(t[3]) && empty(e)) { - ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ])); - } - else if (t[0] == "stat") { - if (e) { - if (e[0] == "stat") { - ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]); - } - } - else { - ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]); - } - } - else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) { - ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]); - } - else if (e && aborts(t)) { - ret = [ [ "if", c, t ] ]; - if (e[0] == "block") { - if (e[1]) ret = ret.concat(e[1]); - } - else { - ret.push(e); - } - ret = walk([ "block", ret ]); - } - else if (t && aborts(e)) { - ret = [ [ "if", negate(c), e ] ]; - if (t[0] == "block") { - if (t[1]) ret = ret.concat(t[1]); - } else { - ret.push(t); - } - ret = walk([ "block", ret ]); - } - return ret; - }; - - function _do_while(cond, body) { - return when_constant(cond, function(cond, val){ - if (!val) { - warn_unreachable(body); - return [ "block" ]; - } else { - return [ "for", null, null, null, walk(body) ]; - } - }); - }; - - ast = prepare_ifs(ast); - ast = ast_add_scope(ast); - - return w.with_walkers({ - "sub": function(expr, subscript) { - if (subscript[0] == "string") { - var name = subscript[1]; - if (is_identifier(name)) - return [ "dot", walk(expr), name ]; - else if (/^[1-9][0-9]*$/.test(name) || name === "0") - return [ "sub", walk(expr), [ "num", parseInt(name, 10) ] ]; - } - }, - "if": make_if, - "toplevel": function(body) { - return [ "toplevel", with_scope(this.scope, function(){ - return tighten(MAP(body, walk)); - }) ]; - }, - "switch": function(expr, body) { - var last = body.length - 1; - return [ "switch", walk(expr), MAP(body, function(branch, i){ - var block = tighten(MAP(branch[1], walk)); - if (i == last && block.length > 0) { - var node = block[block.length - 1]; - if (node[0] == "break" && !node[1]) - block.pop(); - } - return [ branch[0] ? walk(branch[0]) : null, block ]; - }) ]; - }, - "function": _lambda, - "defun": _lambda, - "block": function(body) { - if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]); - }, - "binary": function(op, left, right) { - return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){ - return best_of(walk(c), this); - }, function no() { - return this; - }); - }, - "conditional": function(c, t, e) { - return make_conditional(walk(c), walk(t), walk(e)); - }, - "try": function(t, c, f) { - return [ - "try", - tighten(MAP(t, walk)), - c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null, - f != null ? tighten(MAP(f, walk)) : null - ]; - }, - "unary-prefix": function(op, expr) { - expr = walk(expr); - var ret = [ "unary-prefix", op, expr ]; - if (op == "!") - ret = best_of(ret, negate(expr)); - return when_constant(ret, function(ast, val){ - return walk(ast); // it's either true or false, so minifies to !0 or !1 - }, function() { return ret }); - }, - "name": function(name) { - switch (name) { - case "true": return [ "unary-prefix", "!", [ "num", 0 ]]; - case "false": return [ "unary-prefix", "!", [ "num", 1 ]]; - } - }, - "new": function(ctor, args) { - if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) { - if (args.length != 1) { - return [ "array", args ]; - } else { - return [ "call", [ "name", "Array" ], args ]; - } - } - }, - "call": function(expr, args) { - if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) { - return [ "array", args ]; - } - }, - "while": _do_while - }, function() { - return walk(ast); - }); -}; - -/* -----[ re-generate code from the AST ]----- */ - -var DOT_CALL_NO_PARENS = jsp.array_to_hash([ - "name", - "array", - "object", - "string", - "dot", - "sub", - "call", - "regexp" -]); - -function make_string(str, ascii_only) { - var dq = 0, sq = 0; - str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){ - switch (s) { - case "\\": return "\\\\"; - case "\b": return "\\b"; - case "\f": return "\\f"; - case "\n": return "\\n"; - case "\r": return "\\r"; - case "\t": return "\\t"; - case "\u2028": return "\\u2028"; - case "\u2029": return "\\u2029"; - case '"': ++dq; return '"'; - case "'": ++sq; return "'"; - } - return s; - }); - if (ascii_only) str = to_ascii(str); - if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'"; - else return '"' + str.replace(/\x22/g, '\\"') + '"'; -}; - -function to_ascii(str) { - return str.replace(/[\u0080-\uffff]/g, function(ch) { - var code = ch.charCodeAt(0).toString(16); - while (code.length < 4) code = "0" + code; - return "\\u" + code; - }); -}; - -var SPLICE_NEEDS_BRACKETS = jsp.array_to_hash([ "if", "while", "do", "for", "for-in", "with" ]); - -function gen_code(ast, options) { - options = defaults(options, { - indent_start : 0, - indent_level : 4, - quote_keys : false, - space_colon : false, - beautify : false, - ascii_only : false - }); - var beautify = !!options.beautify; - var indentation = 0, - newline = beautify ? "\n" : "", - space = beautify ? " " : ""; - - function encode_string(str) { - return make_string(str, options.ascii_only); - }; - - function make_name(name) { - name = name.toString(); - if (options.ascii_only) - name = to_ascii(name); - return name; - }; - - function indent(line) { - if (line == null) - line = ""; - if (beautify) - line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line; - return line; - }; - - function with_indent(cont, incr) { - if (incr == null) incr = 1; - indentation += incr; - try { return cont.apply(null, slice(arguments, 1)); } - finally { indentation -= incr; } - }; - - function add_spaces(a) { - if (beautify) - return a.join(" "); - var b = []; - for (var i = 0; i < a.length; ++i) { - var next = a[i + 1]; - b.push(a[i]); - if (next && - ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) || - (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) { - b.push(" "); - } - } - return b.join(""); - }; - - function add_commas(a) { - return a.join("," + space); - }; - - function parenthesize(expr) { - var gen = make(expr); - for (var i = 1; i < arguments.length; ++i) { - var el = arguments[i]; - if ((el instanceof Function && el(expr)) || expr[0] == el) - return "(" + gen + ")"; - } - return gen; - }; - - function best_of(a) { - if (a.length == 1) { - return a[0]; - } - if (a.length == 2) { - var b = a[1]; - a = a[0]; - return a.length <= b.length ? a : b; - } - return best_of([ a[0], best_of(a.slice(1)) ]); - }; - - function needs_parens(expr) { - if (expr[0] == "function" || expr[0] == "object") { - // dot/call on a literal function requires the - // function literal itself to be parenthesized - // only if it's the first "thing" in a - // statement. This means that the parent is - // "stat", but it could also be a "seq" and - // we're the first in this "seq" and the - // parent is "stat", and so on. Messy stuff, - // but it worths the trouble. - var a = slice($stack), self = a.pop(), p = a.pop(); - while (p) { - if (p[0] == "stat") return true; - if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) || - ((p[0] == "binary" || p[0] == "assign" || p[0] == "unary-postfix") && p[2] === self)) { - self = p; - p = a.pop(); - } else { - return false; - } - } - } - return !HOP(DOT_CALL_NO_PARENS, expr[0]); - }; - - function make_num(num) { - var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m; - if (Math.floor(num) === num) { - a.push("0x" + num.toString(16).toLowerCase(), // probably pointless - "0" + num.toString(8)); // same. - if ((m = /^(.*?)(0+)$/.exec(num))) { - a.push(m[1] + "e" + m[2].length); - } - } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) { - a.push(m[2] + "e-" + (m[1].length + m[2].length), - str.substr(str.indexOf("."))); - } - return best_of(a); - }; - - var generators = { - "string": encode_string, - "num": make_num, - "name": make_name, - "toplevel": function(statements) { - return make_block_statements(statements) - .join(newline + newline); - }, - "splice": function(statements) { - var parent = $stack[$stack.length - 2][0]; - if (HOP(SPLICE_NEEDS_BRACKETS, parent)) { - // we need block brackets in this case - return make_block.apply(this, arguments); - } else { - return MAP(make_block_statements(statements, true), - function(line, i) { - // the first line is already indented - return i > 0 ? indent(line) : line; - }).join(newline); - } - }, - "block": make_block, - "var": function(defs) { - return "var " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "const": function(defs) { - return "const " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "try": function(tr, ca, fi) { - var out = [ "try", make_block(tr) ]; - if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1])); - if (fi) out.push("finally", make_block(fi)); - return add_spaces(out); - }, - "throw": function(expr) { - return add_spaces([ "throw", make(expr) ]) + ";"; - }, - "new": function(ctor, args) { - args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : ""; - return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){ - var w = ast_walker(), has_call = {}; - try { - w.with_walkers({ - "call": function() { throw has_call }, - "function": function() { return this } - }, function(){ - w.walk(expr); - }); - } catch(ex) { - if (ex === has_call) - return true; - throw ex; - } - }) + args ]); - }, - "switch": function(expr, body) { - return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]); - }, - "break": function(label) { - var out = "break"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "continue": function(label) { - var out = "continue"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "conditional": function(co, th, el) { - return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?", - parenthesize(th, "seq"), ":", - parenthesize(el, "seq") ]); - }, - "assign": function(op, lvalue, rvalue) { - if (op && op !== true) op += "="; - else op = "="; - return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]); - }, - "dot": function(expr) { - var out = make(expr), i = 1; - if (expr[0] == "num") { - if (!/\./.test(expr[1])) - out += "."; - } else if (needs_parens(expr)) - out = "(" + out + ")"; - while (i < arguments.length) - out += "." + make_name(arguments[i++]); - return out; - }, - "call": function(func, args) { - var f = make(func); - if (needs_parens(func)) - f = "(" + f + ")"; - return f + "(" + add_commas(MAP(args, function(expr){ - return parenthesize(expr, "seq"); - })) + ")"; - }, - "function": make_function, - "defun": make_function, - "if": function(co, th, el) { - var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ]; - if (el) { - out.push("else", make(el)); - } - return add_spaces(out); - }, - "for": function(init, cond, step, block) { - var out = [ "for" ]; - init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space); - cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space); - step = (step != null ? make(step) : "").replace(/;*\s*$/, ""); - var args = init + cond + step; - if (args == "; ; ") args = ";;"; - out.push("(" + args + ")", make(block)); - return add_spaces(out); - }, - "for-in": function(vvar, key, hash, block) { - return add_spaces([ "for", "(" + - (vvar ? make(vvar).replace(/;+$/, "") : make(key)), - "in", - make(hash) + ")", make(block) ]); - }, - "while": function(condition, block) { - return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]); - }, - "do": function(condition, block) { - return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";"; - }, - "return": function(expr) { - var out = [ "return" ]; - if (expr != null) out.push(make(expr)); - return add_spaces(out) + ";"; - }, - "binary": function(operator, lvalue, rvalue) { - var left = make(lvalue), right = make(rvalue); - // XXX: I'm pretty sure other cases will bite here. - // we need to be smarter. - // adding parens all the time is the safest bet. - if (member(lvalue[0], [ "assign", "conditional", "seq" ]) || - lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) { - left = "(" + left + ")"; - } - if (member(rvalue[0], [ "assign", "conditional", "seq" ]) || - rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] && - !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) { - right = "(" + right + ")"; - } - return add_spaces([ left, operator, right ]); - }, - "unary-prefix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val; - }, - "unary-postfix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return val + operator; - }, - "sub": function(expr, subscript) { - var hash = make(expr); - if (needs_parens(expr)) - hash = "(" + hash + ")"; - return hash + "[" + make(subscript) + "]"; - }, - "object": function(props) { - if (props.length == 0) - return "{}"; - return "{" + newline + with_indent(function(){ - return MAP(props, function(p){ - if (p.length == 3) { - // getter/setter. The name is in p[0], the arg.list in p[1][2], the - // body in p[1][3] and type ("get" / "set") in p[2]. - return indent(make_function(p[0], p[1][2], p[1][3], p[2])); - } - var key = p[0], val = make(p[1]); - if (options.quote_keys) { - key = encode_string(key); - } else if ((typeof key == "number" || !beautify && +key + "" == key) - && parseFloat(key) >= 0) { - key = make_num(+key); - } else if (!is_identifier(key)) { - key = encode_string(key); - } - return indent(add_spaces(beautify && options.space_colon - ? [ key, ":", val ] - : [ key + ":", val ])); - }).join("," + newline); - }) + newline + indent("}"); - }, - "regexp": function(rx, mods) { - return "/" + rx + "/" + mods; - }, - "array": function(elements) { - if (elements.length == 0) return "[]"; - return add_spaces([ "[", add_commas(MAP(elements, function(el){ - if (!beautify && el[0] == "atom" && el[1] == "undefined") return ""; - return parenthesize(el, "seq"); - })), "]" ]); - }, - "stat": function(stmt) { - return make(stmt).replace(/;*\s*$/, ";"); - }, - "seq": function() { - return add_commas(MAP(slice(arguments), make)); - }, - "label": function(name, block) { - return add_spaces([ make_name(name), ":", make(block) ]); - }, - "with": function(expr, block) { - return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]); - }, - "atom": function(name) { - return make_name(name); - } - }; - - // The squeezer replaces "block"-s that contain only a single - // statement with the statement itself; technically, the AST - // is correct, but this can create problems when we output an - // IF having an ELSE clause where the THEN clause ends in an - // IF *without* an ELSE block (then the outer ELSE would refer - // to the inner IF). This function checks for this case and - // adds the block brackets if needed. - function make_then(th) { - if (th[0] == "do") { - // https://github.com/mishoo/UglifyJS/issues/#issue/57 - // IE croaks with "syntax error" on code like this: - // if (foo) do ... while(cond); else ... - // we need block brackets around do/while - return make([ "block", [ th ]]); - } - var b = th; - while (true) { - var type = b[0]; - if (type == "if") { - if (!b[3]) - // no else, we must add the block - return make([ "block", [ th ]]); - b = b[3]; - } - else if (type == "while" || type == "do") b = b[2]; - else if (type == "for" || type == "for-in") b = b[4]; - else break; - } - return make(th); - }; - - function make_function(name, args, body, keyword) { - var out = keyword || "function"; - if (name) { - out += " " + make_name(name); - } - out += "(" + add_commas(MAP(args, make_name)) + ")"; - return add_spaces([ out, make_block(body) ]); - }; - - function make_block_statements(statements, noindent) { - for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) { - var stat = statements[i]; - var code = make(stat); - if (code != ";") { - if (!beautify && i == last) { - if ((stat[0] == "while" && empty(stat[2])) || - (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) || - (stat[0] == "if" && empty(stat[2]) && !stat[3]) || - (stat[0] == "if" && stat[3] && empty(stat[3]))) { - code = code.replace(/;*\s*$/, ";"); - } else { - code = code.replace(/;+\s*$/, ""); - } - } - a.push(code); - } - } - return noindent ? a : MAP(a, indent); - }; - - function make_switch_block(body) { - var n = body.length; - if (n == 0) return "{}"; - return "{" + newline + MAP(body, function(branch, i){ - var has_body = branch[1].length > 0, code = with_indent(function(){ - return indent(branch[0] - ? add_spaces([ "case", make(branch[0]) + ":" ]) - : "default:"); - }, 0.5) + (has_body ? newline + with_indent(function(){ - return make_block_statements(branch[1]).join(newline); - }) : ""); - if (!beautify && has_body && i < n - 1) - code += ";"; - return code; - }).join(newline) + newline + indent("}"); - }; - - function make_block(statements) { - if (!statements) return ";"; - if (statements.length == 0) return "{}"; - return "{" + newline + with_indent(function(){ - return make_block_statements(statements).join(newline); - }) + newline + indent("}"); - }; - - function make_1vardef(def) { - var name = def[0], val = def[1]; - if (val != null) - name = add_spaces([ make_name(name), "=", parenthesize(val, "seq") ]); - return name; - }; - - var $stack = []; - - function make(node) { - var type = node[0]; - var gen = generators[type]; - if (!gen) - throw new Error("Can't find generator for \"" + type + "\""); - $stack.push(node); - var ret = gen.apply(type, node.slice(1)); - $stack.pop(); - return ret; - }; - - return make(ast); -}; - -function split_lines(code, max_line_length) { - var splits = [ 0 ]; - jsp.parse(function(){ - var next_token = jsp.tokenizer(code); - var last_split = 0; - var prev_token; - function current_length(tok) { - return tok.pos - last_split; - }; - function split_here(tok) { - last_split = tok.pos; - splits.push(last_split); - }; - function custom(){ - var tok = next_token.apply(this, arguments); - out: { - if (prev_token) { - if (prev_token.type == "keyword") break out; - } - if (current_length(tok) > max_line_length) { - switch (tok.type) { - case "keyword": - case "atom": - case "name": - case "punc": - split_here(tok); - break out; - } - } - } - prev_token = tok; - return tok; - }; - custom.context = function() { - return next_token.context.apply(this, arguments); - }; - return custom; - }()); - return splits.map(function(pos, i){ - return code.substring(pos, splits[i + 1] || code.length); - }).join("\n"); -}; - -/* -----[ Utilities ]----- */ - -function repeat_string(str, i) { - if (i <= 0) return ""; - if (i == 1) return str; - var d = repeat_string(str, i >> 1); - d += d; - if (i & 1) d += str; - return d; -}; - -function defaults(args, defs) { - var ret = {}; - if (args === true) - args = {}; - for (var i in defs) if (HOP(defs, i)) { - ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; - } - return ret; -}; - -function is_identifier(name) { - return /^[a-z_$][a-z0-9_$]*$/i.test(name) - && name != "this" - && !HOP(jsp.KEYWORDS_ATOM, name) - && !HOP(jsp.RESERVED_WORDS, name) - && !HOP(jsp.KEYWORDS, name); -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -// some utilities - -var MAP; - -(function(){ - MAP = function(a, f, o) { - var ret = []; - for (var i = 0; i < a.length; ++i) { - var val = f.call(o, a[i], i); - if (val instanceof AtTop) ret.unshift(val.v); - else ret.push(val); - } - return ret; - }; - MAP.at_top = function(val) { return new AtTop(val) }; - function AtTop(val) { this.v = val }; -})(); - -/* -----[ Exports ]----- */ - -exports.ast_walker = ast_walker; -exports.ast_mangle = ast_mangle; -exports.ast_squeeze = ast_squeeze; -exports.gen_code = gen_code; -exports.ast_add_scope = ast_add_scope; -exports.set_logger = function(logger) { warn = logger }; -exports.make_string = make_string; -exports.split_lines = split_lines; -exports.MAP = MAP; - -// keep this last! -exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - - (function () { - var jsp = require("./parse-js"), - pro = require("./process"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -function ast_squeeze_more(ast) { - var w = pro.ast_walker(), walk = w.walk; - return w.with_walkers({ - "call": function(expr, args) { - if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) { - // foo.toString() ==> foo+"" - return [ "binary", "+", expr[1], [ "string", "" ]]; - } - } - }, function() { - return walk(ast); - }); -}; - -exports.ast_squeeze_more = ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/traverse/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/traverse"; - var __filename = "/node_modules/burrito/node_modules/traverse/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/traverse/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"traverse","version":"0.5.0","description":"Traverse and transform objects by visiting every node on a recursive walk","author":"James Halliday","license":"MIT/X11","main":"./index","repository":{"type":"git","url":"http://github.com/substack/js-traverse.git"},"devDependencies":{"expresso":"0.7.x"},"scripts":{"test":"expresso"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/traverse/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/traverse/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/traverse"; - var __filename = "/node_modules/burrito/node_modules/traverse/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/traverse/index.js"]._cached = module.exports; - - (function () { - module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function () { - delete state.parent.node[state.key]; - }, - remove : function () { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/traverse/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["vm"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "vm"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["vm"]._cached = module.exports; - - (function () { - var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -var iframe = document.createElement('iframe'); -if (!iframe.style) iframe.style = {}; -iframe.style.display = 'none'; - -var iframeCapable = true; // until proven otherwise -if (navigator.appName === 'Microsoft Internet Explorer') { - var m = navigator.appVersion.match(/\bMSIE (\d+\.\d+);/); - if (m && parseFloat(m[1]) <= 9.0) { - iframeCapable = false; - } -} - -Script.prototype.runInNewContext = function (context) { - if (!context) context = {}; - - if (!iframeCapable) { - var keys = Object_keys(context); - var args = []; - for (var i = 0; i < keys.length; i++) { - args.push(context[keys[i]]); - } - - var fn = Function(keys, this.code); - return fn.apply(null, args); - } - - document.body.appendChild(iframe); - - var win = iframe.contentWindow - || (window.frames && window.frames[window.frames.length - 1]) - || window[window.length - 1] - ; - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - iframe[key] = context[key]; - }); - - if (win.eval) { - // chrome and ff can just .eval() - var res = win.eval(this.code); - } - else { - // this works in IE9 but not anything newer - iframe.setAttribute('src', - 'javascript:__browserifyVmResult=(' + this.code + ')' - ); - if ('__browserifyVmResult' in win) { - var res = win.__browserifyVmResult; - } - else { - iframeCapable = false; - res = this.runInThisContext(context); - } - } - - forEach(Object_keys(win), function (key) { - context[key] = win[key]; - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInContext = function (context) { - // seems to be just runInNewContext on magical context objects which are - // otherwise indistinguishable from objects except plain old objects - // for the parameter segfaults node - return this.runInNewContext(context); -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - // not really sure what this one does - // seems to just make a shallow copy - var copy = {}; - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - return copy; -}; -; - }).call(module.exports); - - __require.modules["vm"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify"; - var __filename = "/node_modules/jsonify/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"jsonify","version":"0.0.0","description":"JSON without touching any globals","main":"index.js","directories":{"lib":".","test":"test"},"devDependencies":{"tap":"0.0.x","garbage":"0.0.x"},"scripts":{"test":"tap test"},"repository":{"type":"git","url":"http://github.com/substack/jsonify.git"},"keywords":["json","browser"],"author":{"name":"Douglas Crockford","url":"http://crockford.com/"},"license":"Public Domain"}; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify"; - var __filename = "/node_modules/jsonify/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/index.js"]._cached = module.exports; - - (function () { - exports.parse = require('./lib/parse'); -exports.stringify = require('./lib/stringify'); -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/lib/parse.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify/lib"; - var __filename = "/node_modules/jsonify/lib/parse.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/lib/parse.js"]._cached = module.exports; - - (function () { - var at, // The index of the current character - ch, // The current character - escapee = { - '"': '"', - '\\': '\\', - '/': '/', - b: '\b', - f: '\f', - n: '\n', - r: '\r', - t: '\t' - }, - text, - - error = function (m) { - // Call error when something is wrong. - throw { - name: 'SyntaxError', - message: m, - at: at, - text: text - }; - }, - - next = function (c) { - // If a c parameter is provided, verify that it matches the current character. - if (c && c !== ch) { - error("Expected '" + c + "' instead of '" + ch + "'"); - } - - // Get the next character. When there are no more characters, - // return the empty string. - - ch = text.charAt(at); - at += 1; - return ch; - }, - - number = function () { - // Parse a number value. - var number, - string = ''; - - if (ch === '-') { - string = '-'; - next('-'); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - if (ch === '.') { - string += '.'; - while (next() && ch >= '0' && ch <= '9') { - string += ch; - } - } - if (ch === 'e' || ch === 'E') { - string += ch; - next(); - if (ch === '-' || ch === '+') { - string += ch; - next(); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - } - number = +string; - if (!isFinite(number)) { - error("Bad number"); - } else { - return number; - } - }, - - string = function () { - // Parse a string value. - var hex, - i, - string = '', - uffff; - - // When parsing for string values, we must look for " and \ characters. - if (ch === '"') { - while (next()) { - if (ch === '"') { - next(); - return string; - } else if (ch === '\\') { - next(); - if (ch === 'u') { - uffff = 0; - for (i = 0; i < 4; i += 1) { - hex = parseInt(next(), 16); - if (!isFinite(hex)) { - break; - } - uffff = uffff * 16 + hex; - } - string += String.fromCharCode(uffff); - } else if (typeof escapee[ch] === 'string') { - string += escapee[ch]; - } else { - break; - } - } else { - string += ch; - } - } - } - error("Bad string"); - }, - - white = function () { - -// Skip whitespace. - - while (ch && ch <= ' ') { - next(); - } - }, - - word = function () { - -// true, false, or null. - - switch (ch) { - case 't': - next('t'); - next('r'); - next('u'); - next('e'); - return true; - case 'f': - next('f'); - next('a'); - next('l'); - next('s'); - next('e'); - return false; - case 'n': - next('n'); - next('u'); - next('l'); - next('l'); - return null; - } - error("Unexpected '" + ch + "'"); - }, - - value, // Place holder for the value function. - - array = function () { - -// Parse an array value. - - var array = []; - - if (ch === '[') { - next('['); - white(); - if (ch === ']') { - next(']'); - return array; // empty array - } - while (ch) { - array.push(value()); - white(); - if (ch === ']') { - next(']'); - return array; - } - next(','); - white(); - } - } - error("Bad array"); - }, - - object = function () { - -// Parse an object value. - - var key, - object = {}; - - if (ch === '{') { - next('{'); - white(); - if (ch === '}') { - next('}'); - return object; // empty object - } - while (ch) { - key = string(); - white(); - next(':'); - if (Object.hasOwnProperty.call(object, key)) { - error('Duplicate key "' + key + '"'); - } - object[key] = value(); - white(); - if (ch === '}') { - next('}'); - return object; - } - next(','); - white(); - } - } - error("Bad object"); - }; - -value = function () { - -// Parse a JSON value. It could be an object, an array, a string, a number, -// or a word. - - white(); - switch (ch) { - case '{': - return object(); - case '[': - return array(); - case '"': - return string(); - case '-': - return number(); - default: - return ch >= '0' && ch <= '9' ? number() : word(); - } -}; - -// Return the json_parse function. It will have access to all of the above -// functions and variables. - -module.exports = function (source, reviver) { - var result; - - text = source; - at = 0; - ch = ' '; - result = value(); - white(); - if (ch) { - error("Syntax error"); - } - - // If there is a reviver function, we recursively walk the new structure, - // passing each name/value pair to the reviver function for possible - // transformation, starting with a temporary root object that holds the result - // in an empty key. If there is not a reviver function, we simply return the - // result. - - return typeof reviver === 'function' ? (function walk(holder, key) { - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - }({'': result}, '')) : result; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/lib/parse.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/lib/stringify.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify/lib"; - var __filename = "/node_modules/jsonify/lib/stringify.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/lib/stringify.js"]._cached = module.exports; - - (function () { - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }, - rep; - -function quote(string) { - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable.lastIndex = 0; - return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; -} - -function str(key, holder) { - // Produce a string from holder[key]. - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - // If the value has a toJSON method, call it to obtain a replacement value. - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - // JSON numbers must be finite. Encode non-finite numbers as null. - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - return String(value); - - case 'object': - if (!value) return 'null'; - gap += indent; - partial = []; - - // Array.isArray - if (Object.prototype.toString.apply(value) === '[object Array]') { - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and - // wrap them in brackets. - v = partial.length === 0 ? '[]' : gap ? - '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be - // stringified. - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - else { - // Otherwise, iterate through all of the keys in the object. - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 ? '{}' : gap ? - '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : - '{' + partial.join(',') + '}'; - gap = mind; - return v; - } -} - -module.exports = function (value, replacer, space) { - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - } - // If the space parameter is a string, it will be used as the indent string. - else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - rep = replacer; - if (replacer && typeof replacer !== 'function' - && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - return str('', {'': value}); -}; -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/lib/stringify.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito"; - var __filename = "/node_modules/burrito/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/index.js"]._cached = module.exports; - - (function () { - var uglify = require('uglify-js'); -var parser = uglify.parser; -var parse = function (expr) { - if (typeof expr !== 'string') throw 'expression should be a string'; - - //try { - var args = [].slice.call(arguments); - var ast = parser.parse.apply(null, args); - /* } - catch (err) { - if (err.message === undefined - || err.line === undefined - || err.col === undefined - || err.pos === undefined - ) { throw err } - - var e = new SyntaxError( - err.message - + '\n at line ' + err.line + ':' + err.col + ' in expression:\n\n' - + ' ' + expr.split(/\r?\n/)[err.line] - ); - - e.original = err; - e.line = err.line; - e.col = err.col; - e.pos = err.pos; - throw e; - } - */ - return ast; -}; - -var deparse = function (ast, b) { - return uglify.uglify.gen_code(ast, { beautify : b }); -}; - -var traverse = require('traverse'); -var vm = require('vm'); - -var burrito = module.exports = function (code, cb) { - var ast = Array_isArray(code) - ? code // already an ast - : parse(code.toString(), false, true) - ; - - var ast_ = traverse(ast).map(function mapper () { - wrapNode(this, cb); - }); - - return deparse(parse(deparse(ast_)), true); -}; - -var wrapNode = burrito.wrapNode = function (state, cb) { - var node = state.node; - - var ann = Array_isArray(node) && node[0] - && typeof node[0] === 'object' && node[0].name - ? node[0] - : null - ; - - if (!ann) return undefined; - - var self = { - name : ann.name, - node : node, - start : node[0].start, - end : node[0].end, - value : node.slice(1), - state : state - }; - - self.wrap = function (s) { - var subsrc = deparse( - traverse(node).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - }) - ); - - if (self.name === 'binary') { - var a = deparse(traverse(node[2]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - var b = deparse(traverse(node[3]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - } - - var src = ''; - - if (typeof s === 'function') { - if (self.name === 'binary') { - src = s(subsrc, a, b); - } - else { - src = s(subsrc); - } - } - else { - src = s.toString() - .replace(/%s/g, function () { - return subsrc - }) - ; - - if (self.name === 'binary') { - src = src - .replace(/%a/g, function () { return a }) - .replace(/%b/g, function () { return b }) - ; - } - } - - var expr = parse(src); - state.update(expr, true); - }; - - var cache = {}; - - self.parent = state.isRoot ? null : function () { - if (!cache.parent) { - var s = state; - var x; - do { - s = s.parent; - if (s) x = wrapNode(s); - } while (s && !x); - - cache.parent = x; - } - - return cache.parent; - }; - - self.source = function () { - if (!cache.source) cache.source = deparse(node); - return cache.source; - }; - - self.label = function () { - return burrito.label(self); - }; - - if (cb) cb.call(state, self); - - if (self.node[0].name === 'conditional') { - self.wrap('[%s][0]'); - } - - return self; -} - -burrito.microwave = function (code, context, cb) { - if (!cb) { cb = context; context = {} }; - if (!context) context = {}; - - var src = burrito(code, cb); - return vm.runInNewContext(src, context); -}; - -burrito.generateName = function (len) { - var name = ''; - var lower = '$'.charCodeAt(0); - var upper = 'z'.charCodeAt(0); - - while (name.length < len) { - var c = String.fromCharCode(Math.floor( - Math.random() * (upper - lower + 1) + lower - )); - if ((name + c).match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) name += c; - } - - return name; -}; - -burrito.parse = parse; -burrito.deparse = deparse; - -burrito.label = function (node) { - if (node.name === 'call') { - if (typeof node.value[0] === 'string') { - return node.value[0]; - } - else if (node.value[0] && typeof node.value[0][1] === 'string') { - return node.value[0][1]; - } - else { - return null; - } - } - else if (node.name === 'var') { - return node.value[0].map(function (x) { return x[0] }); - } - else if (node.name === 'defun') { - return node.value[0]; - } - else if (node.name === 'function') { - return node.value[0]; - } - else { - return null; - } -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/index.js"]._cached = module.exports; - return module.exports; -}; - -process.nextTick(function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/"; - var __filename = "//home/substack/projects/node-burrito/example/web"; - - var require = function (file) { - return __require(file, "/"); - }; - require.modules = __require.modules; - - var burrito = require('burrito'); -var json = require('jsonify'); - -var src = [ - 'function f () { g() }', - 'function g () { h() }', - 'function h () { throw "moo" + Array(x).join("!") }', - 'var x = 4', - 'f()' -].join('\r\n'); - -window.onload = function () { - burrito(src, function (node) { - document.body.innerHTML += node.name + '
\n'; - }); -}; -if (document.readyState === 'complete') window.onload(); -; -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html deleted file mode 100644 index 66804fb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - -

-
-
diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js
deleted file mode 100644
index cc81a8b..0000000
--- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var burrito = require('burrito');
-var json = require('jsonify');
-
-var src = [
-    'function f () { g() }',
-    'function g () { h() }',
-    'function h () { throw "moo" + Array(x).join("!") }',
-    'var x = 4',
-    'f()'
-].join('\r\n');
-
-window.onload = function () {
-    burrito(src, function (node) {
-        document.body.innerHTML += node.name + '
\n'; - }); -}; -if (document.readyState === 'complete') window.onload(); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js deleted file mode 100644 index 6bce020..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js +++ /dev/null @@ -1,12 +0,0 @@ -var express = require('express'); -var browserify = require('browserify'); - -var app = express.createServer(); -app.use(express.static(__dirname)); -app.use(browserify({ - entry : __dirname + '/main.js', - watch : true, -})); - -app.listen(8081); -console.log('Listening on :8081'); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js deleted file mode 100644 index 1642401..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js +++ /dev/null @@ -1,7 +0,0 @@ -var burrito = require('burrito'); - -var src = burrito('f() && g(h())\nfoo()', function (node) { - if (node.name === 'call') node.wrap('qqq(%s)'); -}); - -console.log(src); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js deleted file mode 100644 index 60ef569..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js +++ /dev/null @@ -1,208 +0,0 @@ -var uglify = require('uglify-js'); -var parser = uglify.parser; -var parse = function (expr) { - if (typeof expr !== 'string') throw 'expression should be a string'; - - try { - var ast = parser.parse.apply(null, arguments); - } - catch (err) { - if (err.message === undefined - || err.line === undefined - || err.col === undefined - || err.pos === undefined - ) { throw err } - - var e = new SyntaxError( - err.message - + '\n at line ' + err.line + ':' + err.col + ' in expression:\n\n' - + ' ' + expr.split(/\r?\n/)[err.line] - ); - - e.original = err; - e.line = err.line; - e.col = err.col; - e.pos = err.pos; - throw e; - } - return ast; -}; - -var deparse = function (ast, b) { - return uglify.uglify.gen_code(ast, { beautify : b }); -}; - -var traverse = require('traverse'); -var vm = require('vm'); - -var burrito = module.exports = function (code, cb) { - var ast = Array_isArray(code) - ? code // already an ast - : parse(code.toString(), false, true) - ; - - var ast_ = traverse(ast).map(function mapper () { - wrapNode(this, cb); - }); - - return deparse(parse(deparse(ast_)), true); -}; - -var wrapNode = burrito.wrapNode = function (state, cb) { - var node = state.node; - - var ann = Array_isArray(node) && node[0] - && typeof node[0] === 'object' && node[0].name - ? node[0] - : null - ; - - if (!ann) return undefined; - - var self = { - name : ann.name, - node : node, - start : node[0].start, - end : node[0].end, - value : node.slice(1), - state : state - }; - - self.wrap = function (s) { - var subsrc = deparse( - traverse(node).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - }) - ); - - if (self.name === 'binary') { - var a = deparse(traverse(node[2]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - var b = deparse(traverse(node[3]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - } - - var src = ''; - - if (typeof s === 'function') { - if (self.name === 'binary') { - src = s(subsrc, a, b); - } - else { - src = s(subsrc); - } - } - else { - src = s.toString() - .replace(/%s/g, function () { - return subsrc - }) - ; - - if (self.name === 'binary') { - src = src - .replace(/%a/g, function () { return a }) - .replace(/%b/g, function () { return b }) - ; - } - } - - var expr = parse(src); - state.update(expr, true); - }; - - var cache = {}; - - self.parent = state.isRoot ? null : function () { - if (!cache.parent) { - var s = state; - var x; - do { - s = s.parent; - if (s) x = wrapNode(s); - } while (s && !x); - - cache.parent = x; - } - - return cache.parent; - }; - - self.source = function () { - if (!cache.source) cache.source = deparse(node); - return cache.source; - }; - - self.label = function () { - return burrito.label(self); - }; - - if (cb) cb.call(state, self); - - if (self.node[0].name === 'conditional') { - self.wrap('[%s][0]'); - } - - return self; -} - -burrito.microwave = function (code, context, cb) { - if (!cb) { cb = context; context = {} }; - if (!context) context = {}; - - var src = burrito(code, cb); - return vm.runInNewContext(src, context); -}; - -burrito.generateName = function (len) { - var name = ''; - var lower = '$'.charCodeAt(0); - var upper = 'z'.charCodeAt(0); - - while (name.length < len) { - var c = String.fromCharCode(Math.floor( - Math.random() * (upper - lower + 1) + lower - )); - if ((name + c).match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) name += c; - } - - return name; -}; - -burrito.parse = parse; -burrito.deparse = deparse; - -burrito.label = function (node) { - if (node.name === 'call') { - if (typeof node.value[0] === 'string') { - return node.value[0]; - } - else if (node.value[0] && typeof node.value[0][1] === 'string') { - return node.value[0][1]; - } - else if (node.value[0][0] === 'dot') { - return node.value[0][node.value[0].length - 1]; - } - else { - return null; - } - } - else if (node.name === 'var') { - return node.value[0].map(function (x) { return x[0] }); - } - else if (node.name === 'defun') { - return node.value[0]; - } - else if (node.name === 'function') { - return node.value[0]; - } - else { - return null; - } -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs deleted file mode 120000 index fef3468..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs +++ /dev/null @@ -1 +0,0 @@ -../uglify-js/bin/uglifyjs \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore deleted file mode 100644 index 3c3629e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE deleted file mode 100644 index 7b75500..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: -http://www.opensource.org/licenses/mit-license.php - -Copyright 2010 James Halliday (mail@substack.net) - -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. diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown deleted file mode 100644 index f86ef76..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown +++ /dev/null @@ -1,237 +0,0 @@ -traverse -======== - -Traverse and transform objects by visiting every node on a recursive walk. - -examples -======== - -transform negative numbers in-place ------------------------------------ - -negative.js - -````javascript -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); -```` - -Output: - - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ] - -collect leaf nodes ------------------- - -leaves.js - -````javascript -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); -```` - -Output: - - [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -scrub circular references -------------------------- - -scrub.js: - -````javascript -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); -```` - -output: - - { a: 1, b: 2, c: [ 3, 4 ] } - -context -======= - -Each method that takes a callback has a context (its `this` object) with these -attributes: - -this.node ---------- - -The present node on the recursive walk - -this.path ---------- - -An array of string keys from the root to the present node - -this.parent ------------ - -The context of the node's parent. -This is `undefined` for the root node. - -this.key --------- - -The name of the key of the present node in its parent. -This is `undefined` for the root node. - -this.isRoot, this.notRoot -------------------------- - -Whether the present node is the root node - -this.isLeaf, this.notLeaf -------------------------- - -Whether or not the present node is a leaf node (has no children) - -this.level ----------- - -Depth of the node within the traversal - -this.circular -------------- - -If the node equals one of its parents, the `circular` attribute is set to the -context of that parent and the traversal progresses no deeper. - -this.update(value, stopHere=false) ----------------------------------- - -Set a new value for the present node. - -All the elements in `value` will be recursively traversed unless `stopHere` is -true. - -this.remove(stopHere=false) -------------- - -Remove the current element from the output. If the node is in an Array it will -be spliced off. Otherwise it will be deleted from its parent. - -this.delete(stopHere=false) -------------- - -Delete the current element from its parent in the output. Calls `delete` even on -Arrays. - -this.before(fn) ---------------- - -Call this function before any of the children are traversed. - -You can assign into `this.keys` here to traverse in a custom order. - -this.after(fn) --------------- - -Call this function after any of the children are traversed. - -this.pre(fn) ------------- - -Call this function before each of the children are traversed. - -this.post(fn) -------------- - -Call this function after each of the children are traversed. - -methods -======= - -.map(fn) --------- - -Execute `fn` for each node in the object and return a new object with the -results of the walk. To update nodes in the result use `this.update(value)`. - -.forEach(fn) ------------- - -Execute `fn` for each node in the object but unlike `.map()`, when -`this.update()` is called it updates the object in-place. - -.reduce(fn, acc) ----------------- - -For each node in the object, perform a -[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) -with the return value of `fn(acc, node)`. - -If `acc` isn't specified, `acc` is set to the root object for the first step -and the root element is skipped. - -.paths() --------- - -Return an `Array` of every possible non-cyclic path in the object. -Paths are `Array`s of string keys. - -.nodes() --------- - -Return an `Array` of every node in the object. - -.clone() --------- - -Create a deep clone of the object. - -install -======= - -Using [npm](http://npmjs.org) do: - - $ npm install traverse - -test -==== - -Using [expresso](http://github.com/visionmedia/expresso) do: - - $ expresso - - 100% wahoo, your stuff is not broken! - -in the browser -============== - -Use [browserify](https://github.com/substack/node-browserify) to run traverse in -the browser. - -traverse has been tested and works with: - -* Internet Explorer 5.5, 6.0, 7.0, 8.0, 9.0 -* Firefox 3.5 -* Chrome 6.0 -* Opera 10.6 -* Safari 5.0 diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js deleted file mode 100755 index 50d612e..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js +++ /dev/null @@ -1,16 +0,0 @@ -var traverse = require('traverse'); - -var id = 54; -var callbacks = {}; -var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - -var scrubbed = traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } -}); - -console.dir(scrubbed); -console.dir(callbacks); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js deleted file mode 100755 index c1b310b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js +++ /dev/null @@ -1,15 +0,0 @@ -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js deleted file mode 100755 index 78608a0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js +++ /dev/null @@ -1,8 +0,0 @@ -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js deleted file mode 100755 index 5d15b91..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js deleted file mode 100755 index 167b68b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node -var traverse = require('traverse'); - -var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -var s = ''; -traverse(obj).forEach(function to_s (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - to_s(key); - s += ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'string') { - s += '"' + node.toString().replace(/"/g, '\\"') + '"'; - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } -}); - -console.log('JSON.stringify: ' + JSON.stringify(obj)); -console.log('this stringify: ' + s); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js deleted file mode 100644 index 038a1ad..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js +++ /dev/null @@ -1,267 +0,0 @@ -module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function (stopHere) { - delete state.parent.node[state.key]; - if (stopHere) keepGoing = false; - }, - remove : function (stopHere) { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - if (stopHere) keepGoing = false; - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js deleted file mode 100755 index d562d37..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('./index.js'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json deleted file mode 100644 index fd08146..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "traverse", - "version": "0.5.2", - "description": "Traverse and transform objects by visiting every node on a recursive walk", - "author": { - "name": "James Halliday" - }, - "license": "MIT/X11", - "main": "./index", - "repository": { - "type": "git", - "url": "git://github.com/substack/js-traverse.git" - }, - "devDependencies": { - "expresso": "0.7.x" - }, - "scripts": { - "test": "expresso" - }, - "_npmJsonOpts": { - "file": "/home/substack/.npm/traverse/0.5.2/package/package.json", - "wscript": false, - "contributors": false, - "serverjs": false - }, - "_id": "traverse@0.5.2", - "dependencies": {}, - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.0.30", - "_nodeVersion": "v0.4.12", - "_defaultsLoaded": true, - "dist": { - "shasum": "e203c58d5f7f0e37db6e74c0acb929bb09b61d85", - "tarball": "http://registry.npmjs.org/traverse/-/traverse-0.5.2.tgz" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "e203c58d5f7f0e37db6e74c0acb929bb09b61d85", - "_from": "traverse@~0.5.1", - "_resolved": "https://registry.npmjs.org/traverse/-/traverse-0.5.2.tgz" -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js deleted file mode 100644 index 9162601..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js +++ /dev/null @@ -1,115 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); -var util = require('util'); - -exports.circular = function () { - var obj = { x : 3 }; - obj.y = obj; - var foundY = false; - Traverse(obj).forEach(function (x) { - if (this.path.join('') == 'y') { - assert.equal( - util.inspect(this.circular.node), - util.inspect(obj) - ); - foundY = true; - } - }); - assert.ok(foundY); -}; - -exports.deepCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - - var times = 0; - Traverse(obj).forEach(function (x) { - if (this.circular) { - assert.deepEqual(this.circular.path, []); - assert.deepEqual(this.path, [ 'y', 2 ]); - times ++; - } - }); - - assert.deepEqual(times, 1); -}; - -exports.doubleCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var circs = []; - Traverse(obj).forEach(function (x) { - if (this.circular) { - circs.push({ circ : this.circular, self : this, node : x }); - } - }); - - assert.deepEqual(circs[0].self.path, [ 'x', 3, 2 ]); - assert.deepEqual(circs[0].circ.path, []); - - assert.deepEqual(circs[1].self.path, [ 'y', 2 ]); - assert.deepEqual(circs[1].circ.path, []); - - assert.deepEqual(circs.length, 2); -}; - -exports.circDubForEach = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - Traverse(obj).forEach(function (x) { - if (this.circular) this.update('...'); - }); - - assert.deepEqual(obj, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circDubMap = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var c = Traverse(obj).map(function (x) { - if (this.circular) { - this.update('...'); - } - }); - - assert.deepEqual(c, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circClone = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var clone = Traverse.clone(obj); - assert.ok(obj !== clone); - - assert.ok(clone.y[2] === clone); - assert.ok(clone.y[2] !== obj); - assert.ok(clone.x[3][2] === clone); - assert.ok(clone.x[3][2] !== obj); - assert.deepEqual(clone.x.slice(0,3), [1,2,3]); - assert.deepEqual(clone.y.slice(0,2), [4,5]); -}; - -exports.circMapScrub = function () { - var obj = { a : 1, b : 2 }; - obj.c = obj; - - var scrubbed = Traverse(obj).map(function (node) { - if (this.circular) this.remove(); - }); - assert.deepEqual( - Object.keys(scrubbed).sort(), - [ 'a', 'b' ] - ); - assert.ok(deepEqual(scrubbed, { a : 1, b : 2 })); - - assert.equal(obj.c, obj); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js deleted file mode 100644 index 4ca06dc..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.dateEach = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var counts = {}; - - Traverse(obj).forEach(function (node) { - var t = (node instanceof Date && 'Date') || typeof node; - counts[t] = (counts[t] || 0) + 1; - }); - - assert.deepEqual(counts, { - object : 1, - Date : 1, - number : 2, - }); -}; - -exports.dateMap = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var res = Traverse(obj).map(function (node) { - if (typeof node === 'number') this.update(node + 100); - }); - - assert.ok(obj.x !== res.x); - assert.deepEqual(res, { - x : obj.x, - y : 110, - z : 105, - }); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js deleted file mode 100644 index decc755..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js +++ /dev/null @@ -1,220 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.deepDates = function () { - assert.ok( - deepEqual( - { d : new Date, x : [ 1, 2, 3 ] }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'dates should be equal' - ); - - var d0 = new Date; - setTimeout(function () { - assert.ok( - !deepEqual( - { d : d0, x : [ 1, 2, 3 ], }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'microseconds should count in date equality' - ); - }, 5); -}; - -exports.deepCircular = function () { - var a = [1]; - a.push(a); // a = [ 1, *a ] - - var b = [1]; - b.push(a); // b = [ 1, [ 1, *a ] ] - - assert.ok( - !deepEqual(a, b), - 'circular ref mount points count towards equality' - ); - - var c = [1]; - c.push(c); // c = [ 1, *c ] - assert.ok( - deepEqual(a, c), - 'circular refs are structurally the same here' - ); - - var d = [1]; - d.push(a); // c = [ 1, [ 1, *d ] ] - assert.ok( - deepEqual(b, d), - 'non-root circular ref structural comparison' - ); -}; - -exports.deepInstances = function () { - assert.ok( - !deepEqual([ new Boolean(false) ], [ false ]), - 'boolean instances are not real booleans' - ); - - assert.ok( - !deepEqual([ new String('x') ], [ 'x' ]), - 'string instances are not real strings' - ); - - assert.ok( - !deepEqual([ new Number(4) ], [ 4 ]), - 'number instances are not real numbers' - ); - - assert.ok( - deepEqual([ new RegExp('x') ], [ /x/ ]), - 'regexp instances are real regexps' - ); - - assert.ok( - !deepEqual([ new RegExp(/./) ], [ /../ ]), - 'these regexps aren\'t the same' - ); - - assert.ok( - !deepEqual( - [ function (x) { return x * 2 } ], - [ function (x) { return x * 2 } ] - ), - 'functions with the same .toString() aren\'t necessarily the same' - ); - - var f = function (x) { return x * 2 }; - assert.ok( - deepEqual([ f ], [ f ]), - 'these functions are actually equal' - ); -}; - -exports.deepEqual = function () { - assert.ok( - !deepEqual([ 1, 2, 3 ], { 0 : 1, 1 : 2, 2 : 3 }), - 'arrays are not objects' - ); -}; - -exports.falsy = function () { - assert.ok( - !deepEqual([ undefined ], [ null ]), - 'null is not undefined!' - ); - - assert.ok( - !deepEqual([ null ], [ undefined ]), - 'undefined is not null!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'undefined is not null, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); -}; - -exports.deletedArrayEqual = function () { - var xs = [ 1, 2, 3, 4 ]; - delete xs[2]; - - var ys = Object.create(Array.prototype); - ys[0] = 1; - ys[1] = 2; - ys[3] = 4; - - assert.ok( - deepEqual(xs, ys), - 'arrays with deleted elements are only equal to' - + ' arrays with similarly deleted elements' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, undefined, 4 ]), - 'deleted array elements cannot be undefined' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, null, 4 ]), - 'deleted array elements cannot be null' - ); -}; - -exports.deletedObjectEqual = function () { - var obj = { a : 1, b : 2, c : 3 }; - delete obj.c; - - assert.ok( - deepEqual(obj, { a : 1, b : 2 }), - 'deleted object elements should not show up' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : undefined }), - 'deleted object elements are not undefined' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : null }), - 'deleted object elements are not null' - ); -}; - -exports.emptyKeyEqual = function () { - assert.ok(!deepEqual( - { a : 1 }, { a : 1, '' : 55 } - )); -}; - -exports.deepArguments = function () { - assert.ok( - !deepEqual( - [ 4, 5, 6 ], - (function () { return arguments })(4, 5, 6) - ), - 'arguments are not arrays' - ); - - assert.ok( - deepEqual( - (function () { return arguments })(4, 5, 6), - (function () { return arguments })(4, 5, 6) - ), - 'arguments should equal' - ); -}; - -exports.deepUn = function () { - assert.ok(!deepEqual({ a : 1, b : 2 }, undefined)); - assert.ok(!deepEqual({ a : 1, b : 2 }, {})); - assert.ok(!deepEqual(undefined, { a : 1, b : 2 })); - assert.ok(!deepEqual({}, { a : 1, b : 2 })); - assert.ok(deepEqual(undefined, undefined)); - assert.ok(deepEqual(null, null)); - assert.ok(!deepEqual(undefined, null)); -}; - -exports.deepLevels = function () { - var xs = [ 1, 2, [ 3, 4, [ 5, 6 ] ] ]; - assert.ok(!deepEqual(xs, [])); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js deleted file mode 100644 index 8d73525..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js +++ /dev/null @@ -1,17 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var EventEmitter = require('events').EventEmitter; - -exports['check instanceof on node elems'] = function () { - - var counts = { emitter : 0 }; - - Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }]) - .forEach(function (node) { - if (node instanceof EventEmitter) counts.emitter ++; - }) - ; - - assert.equal(counts.emitter, 2); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js deleted file mode 100644 index fce5bf9..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js +++ /dev/null @@ -1,42 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['interface map'] = function () { - var obj = { a : [ 5,6,7 ], b : { c : [8] } }; - - assert.deepEqual( - Traverse.paths(obj) - .sort() - .map(function (path) { return path.join('/') }) - .slice(1) - .join(' ') - , - 'a a/0 a/1 a/2 b b/c b/c/0' - ); - - assert.deepEqual( - Traverse.nodes(obj), - [ - { a: [ 5, 6, 7 ], b: { c: [ 8 ] } }, - [ 5, 6, 7 ], 5, 6, 7, - { c: [ 8 ] }, [ 8 ], 8 - ] - ); - - assert.deepEqual( - Traverse.map(obj, function (node) { - if (typeof node == 'number') { - return node + 1000; - } - else if (Array.isArray(node)) { - return node.join(' '); - } - }), - { a: '5 6 7', b: { c: '8' } } - ); - - var nodes = 0; - Traverse.forEach(obj, function (node) { nodes ++ }); - assert.deepEqual(nodes, 8); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js deleted file mode 100644 index 0a04529..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js +++ /dev/null @@ -1,47 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['json test'] = function () { - var id = 54; - var callbacks = {}; - var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - - var scrubbed = Traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } - }); - - assert.equal( - scrubbed.moo, '[Function]', - 'obj.moo replaced with "[Function]"' - ); - - assert.equal( - scrubbed.foo[3], '[Function]', - 'obj.foo[3] replaced with "[Function]"' - ); - - assert.deepEqual(scrubbed, { - moo : '[Function]', - foo : [ 2, 3, 4, "[Function]" ] - }, 'Full JSON string matches'); - - assert.deepEqual( - typeof obj.moo, 'function', - 'Original obj.moo still a function' - ); - - assert.deepEqual( - typeof obj.foo[3], 'function', - 'Original obj.foo[3] still a function' - ); - - assert.deepEqual(callbacks, { - 54: { id: 54, f : obj.moo, path: [ 'moo' ] }, - 55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] }, - }, 'Check the generated callbacks list'); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js deleted file mode 100644 index 7ecd545..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['sort test'] = function () { - var acc = []; - Traverse({ - a: 30, - b: 22, - id: 9 - }).forEach(function (node) { - if ((! Array.isArray(node)) && typeof node === 'object') { - this.before(function(node) { - this.keys = Object.keys(node); - this.keys.sort(function(a, b) { - a = [a === "id" ? 0 : 1, a]; - b = [b === "id" ? 0 : 1, b]; - return a < b ? -1 : a > b ? 1 : 0; - }); - }); - } - if (this.isLeaf) acc.push(node); - }); - - assert.equal( - acc.join(' '), - '9 30 22', - 'Traversal in a custom order' - ); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js deleted file mode 100644 index e520b72..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js +++ /dev/null @@ -1,21 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['leaves test'] = function () { - var acc = []; - Traverse({ - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - assert.equal( - acc.join(' '), - '1 2 3 4 5 6 7 8 9', - 'Traversal in the right(?) order' - ); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js deleted file mode 100644 index 4fa07bb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js +++ /dev/null @@ -1,92 +0,0 @@ -var traverse = require('../../'); - -module.exports = function (a, b) { - if (arguments.length !== 2) { - throw new Error( - 'deepEqual requires exactly two objects to compare against' - ); - } - - var equal = true; - var node = b; - - traverse(a).forEach(function (y) { - var notEqual = (function () { - equal = false; - //this.stop(); - return undefined; - }).bind(this); - - //if (node === undefined || node === null) return notEqual(); - - if (!this.isRoot) { - /* - if (!Object.hasOwnProperty.call(node, this.key)) { - return notEqual(); - } - */ - if (typeof node !== 'object') return notEqual(); - node = node[this.key]; - } - - var x = node; - - this.post(function () { - node = x; - }); - - var toS = function (o) { - return Object.prototype.toString.call(o); - }; - - if (this.circular) { - if (traverse(b).get(this.circular.path) !== x) notEqual(); - } - else if (typeof x !== typeof y) { - notEqual(); - } - else if (x === null || y === null || x === undefined || y === undefined) { - if (x !== y) notEqual(); - } - else if (x.__proto__ !== y.__proto__) { - notEqual(); - } - else if (x === y) { - // nop - } - else if (typeof x === 'function') { - if (x instanceof RegExp) { - // both regexps on account of the __proto__ check - if (x.toString() != y.toString()) notEqual(); - } - else if (x !== y) notEqual(); - } - else if (typeof x === 'object') { - if (toS(y) === '[object Arguments]' - || toS(x) === '[object Arguments]') { - if (toS(x) !== toS(y)) { - notEqual(); - } - } - else if (x instanceof Date || y instanceof Date) { - if (!(x instanceof Date) || !(y instanceof Date) - || x.getTime() !== y.getTime()) { - notEqual(); - } - } - else { - var kx = Object.keys(x); - var ky = Object.keys(y); - if (kx.length !== ky.length) return notEqual(); - for (var i = 0; i < kx.length; i++) { - var k = kx[i]; - if (!Object.hasOwnProperty.call(y, k)) { - notEqual(); - } - } - } - } - }); - - return equal; -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js deleted file mode 100644 index 2236f56..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js +++ /dev/null @@ -1,252 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.mutate = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).forEach(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mutateT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.forEach(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.map = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mapT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.map(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.clone = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).clone(); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.cloneT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.clone(obj); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.reduce = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; - }, []); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, [ 1, 2, 3, 4 ]); -}; - -exports.reduceInit = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isRoot) assert.fail('got root'); - return acc; - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, obj); -}; - -exports.remove = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, c : [ 3 ] }); -}; - -exports.removeNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f']) -} - -exports.removeStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'f']) -} - -exports.removeMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, c : [ 3 ] }); -}; - -exports.delete = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null ] } - )); -}; - -exports.deleteNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e']) -} - -exports.deleteStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c']) -} - -exports.deleteRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined, 5 ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ,, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, 5 ] } - )); -}; - -exports.deleteMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4 ] } - )); - - var xs = [ 3, 4 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3, ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ] } - )); -}; - -exports.deleteMapRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4, 5 ] } - )); - - var xs = [ 3, 4, 5 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(!deepEqual( - res, { a : 1, c : [ 3, 5 ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ,, 5 ] } - )); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js deleted file mode 100644 index f92dfb0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js +++ /dev/null @@ -1,20 +0,0 @@ -var Traverse = require('../'); -var assert = require('assert'); - -exports['negative update test'] = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - var fixed = Traverse.map(obj, function (x) { - if (x < 0) this.update(x + 128); - }); - - assert.deepEqual(fixed, - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ], - 'Negative values += 128' - ); - - assert.deepEqual(obj, - [ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ], - 'Original references not modified' - ); -} - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js deleted file mode 100644 index d46fd38..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js +++ /dev/null @@ -1,15 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['traverse an object with nested functions'] = function () { - var to = setTimeout(function () { - assert.fail('never ran'); - }, 1000); - - function Cons (x) { - clearTimeout(to); - assert.equal(x, 10); - }; - Traverse(new Cons(10)); -}; - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js deleted file mode 100644 index 99c0f1b..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.siblings = function () { - var obj = { a : 1, b : 2, c : [ 4, 5, 6 ] }; - - var res = traverse(obj).reduce(function (acc, x) { - var p = '/' + this.path.join('/'); - if (this.parent) { - acc[p] = { - siblings : this.parent.keys, - key : this.key, - index : this.parent.keys.indexOf(this.key) - }; - } - else { - acc[p] = { - siblings : [], - key : this.key, - index : -1 - } - } - return acc; - }, {}); - - assert.deepEqual(res, { - '/' : { siblings : [], key : undefined, index : -1 }, - '/a' : { siblings : [ 'a', 'b', 'c' ], key : 'a', index : 0 }, - '/b' : { siblings : [ 'a', 'b', 'c' ], key : 'b', index : 1 }, - '/c' : { siblings : [ 'a', 'b', 'c' ], key : 'c', index : 2 }, - '/c/0' : { siblings : [ '0', '1', '2' ], key : '0', index : 0 }, - '/c/1' : { siblings : [ '0', '1', '2' ], key : '1', index : 1 }, - '/c/2' : { siblings : [ '0', '1', '2' ], key : '2', index : 2 } - }); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js deleted file mode 100644 index 3529847..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js +++ /dev/null @@ -1,41 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.stop = function () { - var visits = 0; - traverse('abcdefghij'.split('')).forEach(function (node) { - if (typeof node === 'string') { - visits ++; - if (node === 'e') this.stop() - } - }); - - assert.equal(visits, 5); -}; - -exports.stopMap = function () { - var s = traverse('abcdefghij'.split('')).map(function (node) { - if (typeof node === 'string') { - if (node === 'e') this.stop() - return node.toUpperCase(); - } - }).join(''); - - assert.equal(s, 'ABCDEfghij'); -}; - -exports.stopReduce = function () { - var obj = { - a : [ 4, 5 ], - b : [ 6, [ 7, 8, 9 ] ] - }; - var xs = traverse(obj).reduce(function (acc, node) { - if (this.isLeaf) { - if (node === 7) this.stop(); - else acc.push(node) - } - return acc; - }, []); - - assert.deepEqual(xs, [ 4, 5, 6 ]); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js deleted file mode 100644 index 932f5d3..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js +++ /dev/null @@ -1,36 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.stringify = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - - var s = ''; - Traverse(obj).forEach(function (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - s += '"' + key + '"' + ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } - }); - - assert.equal(s, JSON.stringify(obj)); -} - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js deleted file mode 100644 index a217beb..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js +++ /dev/null @@ -1,34 +0,0 @@ -var traverse = require('../'); -var assert = require('assert'); - -exports.subexpr = function () { - var obj = [ 'a', 4, 'b', 5, 'c', 6 ]; - var r = traverse(obj).map(function (x) { - if (typeof x === 'number') { - this.update([ x - 0.1, x, x + 0.1 ], true); - } - }); - - assert.deepEqual(obj, [ 'a', 4, 'b', 5, 'c', 6 ]); - assert.deepEqual(r, [ - 'a', [ 3.9, 4, 4.1 ], - 'b', [ 4.9, 5, 5.1 ], - 'c', [ 5.9, 6, 6.1 ], - ]); -}; - -exports.block = function () { - var obj = [ [ 1 ], [ 2 ], [ 3 ] ]; - var r = traverse(obj).map(function (x) { - if (Array.isArray(x) && !this.isRoot) { - if (x[0] === 5) this.block() - else this.update([ [ x[0] + 1 ] ]) - } - }); - - assert.deepEqual(r, [ - [ [ [ [ [ 5 ] ] ] ] ], - [ [ [ [ 5 ] ] ] ], - [ [ [ 5 ] ] ], - ]); -}; diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js deleted file mode 100644 index acac2fd..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js +++ /dev/null @@ -1,55 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.super_deep = function () { - var util = require('util'); - var a0 = make(); - var a1 = make(); - assert.ok(deepEqual(a0, a1)); - - a0.c.d.moo = true; - assert.ok(!deepEqual(a0, a1)); - - a1.c.d.moo = true; - assert.ok(deepEqual(a0, a1)); - - // TODO: this one - //a0.c.a = a1; - //assert.ok(!deepEqual(a0, a1)); -}; - -function make () { - var a = { self : 'a' }; - var b = { self : 'b' }; - var c = { self : 'c' }; - var d = { self : 'd' }; - var e = { self : 'e' }; - - a.a = a; - a.b = b; - a.c = c; - - b.a = a; - b.b = b; - b.c = c; - - c.a = a; - c.b = b; - c.c = c; - c.d = d; - - d.a = a; - d.b = b; - d.c = c; - d.d = d; - d.e = e; - - e.a = a; - e.b = b; - e.c = c; - e.d = d; - e.e = e; - - return a; -} diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore deleted file mode 100644 index d97eaa0..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -.tmp*~ -*.local.* -.pinf-* \ No newline at end of file diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html deleted file mode 100644 index 8f5223f..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html +++ /dev/null @@ -1,1026 +0,0 @@ - - - - -UglifyJS -- a JavaScript parser/compressor/beautifier - - - - - - - - - - - - -
- -

UglifyJS – a JavaScript parser/compressor/beautifier

- - - - -
-

1 UglifyJS — a JavaScript parser/compressor/beautifier

-
- - -

-This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on NodeJS, but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the exports.* lines from UglifyJS sources). -

-

-The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in parse-js.js and it's a -port to JavaScript of the excellent parse-js Common Lisp library from Marijn Haverbeke. -

-

-( See cl-uglify-js if you're looking for the Common Lisp version of -UglifyJS. ) -

-

-The second part of this package, implemented in process.js, inspects and -manipulates the AST generated by the parser to provide the following: -

-
    -
  • -ability to re-generate JavaScript code from the AST. Optionally -indented—you can use this if you want to “beautify” a program that has -been compressed, so that you can inspect the source. But you can also run -our code generator to print out an AST without any whitespace, so you -achieve compression as well. - -
  • -
  • -shorten variable names (usually to single characters). Our mangler will -analyze the code and generate proper variable names, depending on scope -and usage, and is smart enough to deal with globals defined elsewhere, or -with eval() calls or with{} statements. In short, if eval() or -with{} are used in some scope, then all variables in that scope and any -variables in the parent scopes will remain unmangled, and any references -to such variables remain unmangled as well. - -
  • -
  • -various small optimizations that may lead to faster code but certainly -lead to smaller code. Where possible, we do the following: - -
      -
    • -foo["bar"] ==> foo.bar - -
    • -
    • -remove block brackets {} - -
    • -
    • -join consecutive var declarations: -var a = 10; var b = 20; ==> var a=10,b=20; - -
    • -
    • -resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the -replacement if the result occupies less bytes; for example 1/3 would -translate to 0.333333333333, so in this case we don't replace it. - -
    • -
    • -consecutive statements in blocks are merged into a sequence; in many -cases, this leaves blocks with a single statement, so then we can remove -the block brackets. - -
    • -
    • -various optimizations for IF statements: - -
        -
      • -if (foo) bar(); else baz(); ==> foo?bar():baz(); -
      • -
      • -if (!foo) bar(); else baz(); ==> foo?baz():bar(); -
      • -
      • -if (foo) bar(); ==> foo&&bar(); -
      • -
      • -if (!foo) bar(); ==> foo||bar(); -
      • -
      • -if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); -
      • -
      • -if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - -
      • -
      -
    • -
    • -remove some unreachable code and warn about it (code that follows a -return, throw, break or continue statement, except -function/variable declarations). - -
    • -
    • -act a limited version of a pre-processor (c.f. the pre-processor of -C/C++) to allow you to safely replace selected global symbols with -specified values. When combined with the optimisations above this can -make UglifyJS operate slightly more like a compilation process, in -that when certain symbols are replaced by constant values, entire code -blocks may be optimised away as unreachable. -
    • -
    -
  • -
- - - -
- -
-

1.1 Unsafe transformations

-
- - -

-The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the ---unsafe flag. -

- -
- -
-

1.1.1 Calls involving the global Array constructor

-
- - -

-The following transformations occur: -

- - - -
new Array(1, 2, 3, 4)  => [1,2,3,4]
-Array(a, b, c)         => [a,b,c]
-new Array(5)           => Array(5)
-new Array(a)           => Array(a)
-
- - - -

-These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. -

-

-UglifyJS does handle the case where Array is redefined locally, or even -globally but with a function or var declaration. Therefore, in the -following cases UglifyJS doesn't touch calls or instantiations of Array: -

- - - -
// case 1.  globally declared variable
-  var Array;
-  new Array(1, 2, 3);
-  Array(a, b);
-
-  // or (can be declared later)
-  new Array(1, 2, 3);
-  var Array;
-
-  // or (can be a function)
-  new Array(1, 2, 3);
-  function Array() { ... }
-
-// case 2.  declared in a function
-  (function(){
-    a = new Array(1, 2, 3);
-    b = Array(5, 6);
-    var Array;
-  })();
-
-  // or
-  (function(Array){
-    return Array(5, 6, 7);
-  })();
-
-  // or
-  (function(){
-    return new Array(1, 2, 3, 4);
-    function Array() { ... }
-  })();
-
-  // etc.
-
- - - -
- -
- -
-

1.1.2 obj.toString() ==> obj+“”

-
- - -
-
- -
- -
-

1.2 Install (NPM)

-
- - -

-UglifyJS is now available through NPM — npm install uglify-js should do -the job. -

-
- -
- -
-

1.3 Install latest code from GitHub

-
- - - - - -
## clone the repository
-mkdir -p /where/you/wanna/put/it
-cd /where/you/wanna/put/it
-git clone git://github.com/mishoo/UglifyJS.git
-
-## make the module available to Node
-mkdir -p ~/.node_libraries/
-cd ~/.node_libraries/
-ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
-
-## and if you want the CLI script too:
-mkdir -p ~/bin
-cd ~/bin
-ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
-  # (then add ~/bin to your $PATH if it's not there already)
-
- - - -
- -
- -
-

1.4 Usage

-
- - -

-There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: -

- - - -
uglifyjs [ options... ] [ filename ]
-
- - - -

-filename should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. -

-

-Supported options: -

-
    -
  • --b or --beautify — output indented code; when passed, additional -options control the beautifier: - -
      -
    • --i N or --indent N — indentation level (number of spaces) - -
    • -
    • --q or --quote-keys — quote keys in literal objects (by default, -only keys that cannot be identifier names will be quotes). - -
    • -
    -
  • -
  • ---ascii — pass this argument to encode non-ASCII characters as -\uXXXX sequences. By default UglifyJS won't bother to do it and will -output Unicode characters instead. (the output is always encoded in UTF8, -but if you pass this option you'll only get ASCII). - -
  • -
  • --nm or --no-mangle — don't mangle variable names - -
  • -
  • --ns or --no-squeeze — don't call ast_squeeze() (which does various -optimizations that result in smaller, less readable code). - -
  • -
  • --mt or --mangle-toplevel — mangle names in the toplevel scope too -(by default we don't do this). - -
  • -
  • ---no-seqs — when ast_squeeze() is called (thus, unless you pass ---no-squeeze) it will reduce consecutive statements in blocks into a -sequence. For example, "a = 10; b = 20; foo();" will be written as -"a=10,b=20,foo();". In various occasions, this allows us to discard the -block brackets (since the block becomes a single statement). This is ON -by default because it seems safe and saves a few hundred bytes on some -libs that I tested it on, but pass --no-seqs to disable it. - -
  • -
  • ---no-dead-code — by default, UglifyJS will remove code that is -obviously unreachable (code that follows a return, throw, break or -continue statement and is not a function/variable declaration). Pass -this option to disable this optimization. - -
  • -
  • --nc or --no-copyright — by default, uglifyjs will keep the initial -comment tokens in the generated code (assumed to be copyright information -etc.). If you pass this it will discard it. - -
  • -
  • --o filename or --output filename — put the result in filename. If -this isn't given, the result goes to standard output (or see next one). - -
  • -
  • ---overwrite — if the code is read from a file (not from STDIN) and you -pass --overwrite then the output will be written in the same file. - -
  • -
  • ---ast — pass this if you want to get the Abstract Syntax Tree instead -of JavaScript as output. Useful for debugging or learning more about the -internals. - -
  • -
  • --v or --verbose — output some notes on STDERR (for now just how long -each operation takes). - -
  • -
  • --d SYMBOL[=VALUE] or --define SYMBOL[=VALUE] — will replace -all instances of the specified symbol where used as an identifier -(except where symbol has properly declared by a var declaration or -use as function parameter or similar) with the specified value. This -argument may be specified multiple times to define multiple -symbols - if no value is specified the symbol will be replaced with -the value true, or you can specify a numeric value (such as -1024), a quoted string value (such as ="object"= or -='https://github.com'), or the name of another symbol or keyword (such as =null or document). -This allows you, for example, to assign meaningful names to key -constant values but discard the symbolic names in the uglified -version for brevity/efficiency, or when used wth care, allows -UglifyJS to operate as a form of conditional compilation -whereby defining appropriate values may, by dint of the constant -folding and dead code removal features above, remove entire -superfluous code blocks (e.g. completely remove instrumentation or -trace code for production use). -Where string values are being defined, the handling of quotes are -likely to be subject to the specifics of your command shell -environment, so you may need to experiment with quoting styles -depending on your platform, or you may find the option ---define-from-module more suitable for use. - -
  • -
  • --define-from-module SOMEMODULE — will load the named module (as -per the NodeJS require() function) and iterate all the exported -properties of the module defining them as symbol names to be defined -(as if by the --define option) per the name of each property -(i.e. without the module name prefix) and given the value of the -property. This is a much easier way to handle and document groups of -symbols to be defined rather than a large number of --define -options. - -
  • -
  • ---unsafe — enable other additional optimizations that are known to be -unsafe in some contrived situations, but could still be generally useful. -For now only these: - -
      -
    • -foo.toString() ==> foo+"" -
    • -
    • -new Array(x,…) ==> [x,…] -
    • -
    • -new Array(x) ==> Array(x) - -
    • -
    -
  • -
  • ---max-line-len (default 32K characters) — add a newline after around -32K characters. I've seen both FF and Chrome croak when all the code was -on a single line of around 670K. Pass –max-line-len 0 to disable this -safety feature. - -
  • -
  • ---reserved-names — some libraries rely on certain names to be used, as -pointed out in issue #92 and #81, so this option allow you to exclude such -names from the mangler. For example, to keep names require and $super -intact you'd specify –reserved-names "require,$super". - -
  • -
  • ---inline-script – when you want to include the output literally in an -HTML <script> tag you can use this option to prevent </script from -showing up in the output. - -
  • -
  • ---lift-vars – when you pass this, UglifyJS will apply the following -transformations (see the notes in API, ast_lift_variables): - -
      -
    • -put all var declarations at the start of the scope -
    • -
    • -make sure a variable is declared only once -
    • -
    • -discard unused function arguments -
    • -
    • -discard unused inner (named) functions -
    • -
    • -finally, try to merge assignments into that one var declaration, if -possible. -
    • -
    -
  • -
- - - -
- -
-

1.4.1 API

-
- - -

-To use the library from JavaScript, you'd do the following (example for -NodeJS): -

- - - -
var jsp = require("uglify-js").parser;
-var pro = require("uglify-js").uglify;
-
-var orig_code = "... JS code here";
-var ast = jsp.parse(orig_code); // parse code and get the initial AST
-ast = pro.ast_mangle(ast); // get a new AST with mangled names
-ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
-var final_code = pro.gen_code(ast); // compressed code here
-
- - - -

-The above performs the full compression that is possible right now. As you -can see, there are a sequence of steps which you can apply. For example if -you want compressed output but for some reason you don't want to mangle -variable names, you would simply skip the line that calls -pro.ast_mangle(ast). -

-

-Some of these functions take optional arguments. Here's a description: -

-
    -
  • -jsp.parse(code, strict_semicolons) – parses JS code and returns an AST. -strict_semicolons is optional and defaults to false. If you pass -true then the parser will throw an error when it expects a semicolon and -it doesn't find it. For most JS code you don't want that, but it's useful -if you want to strictly sanitize your code. - -
  • -
  • -pro.ast_lift_variables(ast) – merge and move var declarations to the -scop of the scope; discard unused function arguments or variables; discard -unused (named) inner functions. It also tries to merge assignments -following the var declaration into it. - -

    -If your code is very hand-optimized concerning var declarations, this -lifting variable declarations might actually increase size. For me it -helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also -note that (since it's not enabled by default) this operation isn't yet -heavily tested (please report if you find issues!). -

    -

    -Note that although it might increase the image size (on jQuery it gains -865 bytes, 243 after gzip) it's technically more correct: in certain -situations, dead code removal might drop variable declarations, which -would not happen if the variables are lifted in advance. -

    -

    -Here's an example of what it does: -

    -
  • -
- - - - -
function f(a, b, c, d, e) {
-    var q;
-    var w;
-    w = 10;
-    q = 20;
-    for (var i = 1; i < 10; ++i) {
-        var boo = foo(a);
-    }
-    for (var i = 0; i < 1; ++i) {
-        var boo = bar(c);
-    }
-    function foo(){ ... }
-    function bar(){ ... }
-    function baz(){ ... }
-}
-
-// transforms into ==>
-
-function f(a, b, c) {
-    var i, boo, w = 10, q = 20;
-    for (i = 1; i < 10; ++i) {
-        boo = foo(a);
-    }
-    for (i = 0; i < 1; ++i) {
-        boo = bar(c);
-    }
-    function foo() { ... }
-    function bar() { ... }
-}
-
- - - -
    -
  • -pro.ast_mangle(ast, options) – generates a new AST containing mangled -(compressed) variable and function names. It supports the following -options: - -
      -
    • -toplevel – mangle toplevel names (by default we don't touch them). -
    • -
    • -except – an array of names to exclude from compression. -
    • -
    • -defines – an object with properties named after symbols to -replace (see the --define option for the script) and the values -representing the AST replacement value. - -
    • -
    -
  • -
  • -pro.ast_squeeze(ast, options) – employs further optimizations designed -to reduce the size of the code that gen_code would generate from the -AST. Returns a new AST. options can be a hash; the supported options -are: - -
      -
    • -make_seqs (default true) which will cause consecutive statements in a -block to be merged using the "sequence" (comma) operator - -
    • -
    • -dead_code (default true) which will remove unreachable code. - -
    • -
    -
  • -
  • -pro.gen_code(ast, options) – generates JS code from the AST. By -default it's minified, but using the options argument you can get nicely -formatted output. options is, well, optional :-) and if you pass it it -must be an object and supports the following properties (below you can see -the default values): - -
      -
    • -beautify: false – pass true if you want indented output -
    • -
    • -indent_start: 0 (only applies when beautify is true) – initial -indentation in spaces -
    • -
    • -indent_level: 4 (only applies when beautify is true) -- -indentation level, in spaces (pass an even number) -
    • -
    • -quote_keys: false – if you pass true it will quote all keys in -literal objects -
    • -
    • -space_colon: false (only applies when beautify is true) – wether -to put a space before the colon in object literals -
    • -
    • -ascii_only: false – pass true if you want to encode non-ASCII -characters as \uXXXX. -
    • -
    • -inline_script: false – pass true to escape occurrences of -</script in strings -
    • -
    -
  • -
- - -
- -
- -
-

1.4.2 Beautifier shortcoming – no more comments

-
- - -

-The beautifier can be used as a general purpose indentation tool. It's -useful when you want to make a minified file readable. One limitation, -though, is that it discards all comments, so you don't really want to use it -to reformat your code, unless you don't have, or don't care about, comments. -

-

-In fact it's not the beautifier who discards comments — they are dumped at -the parsing stage, when we build the initial AST. Comments don't really -make sense in the AST, and while we could add nodes for them, it would be -inconvenient because we'd have to add special rules to ignore them at all -the processing stages. -

-
- -
- -
-

1.4.3 Use as a code pre-processor

-
- - -

-The --define option can be used, particularly when combined with the -constant folding logic, as a form of pre-processor to enable or remove -particular constructions, such as might be used for instrumenting -development code, or to produce variations aimed at a specific -platform. -

-

-The code below illustrates the way this can be done, and how the -symbol replacement is performed. -

- - - -
CLAUSE1: if (typeof DEVMODE === 'undefined') {
-    DEVMODE = true;
-}
-
-CLAUSE2: function init() {
-    if (DEVMODE) {
-        console.log("init() called");
-    }
-    ....
-    DEVMODE &amp;&amp; console.log("init() complete");
-}
-
-CLAUSE3: function reportDeviceStatus(device) {
-    var DEVMODE = device.mode, DEVNAME = device.name;
-    if (DEVMODE === 'open') {
-        ....
-    }
-}
-
- - - -

-When the above code is normally executed, the undeclared global -variable DEVMODE will be assigned the value true (see CLAUSE1) -and so the init() function (CLAUSE2) will write messages to the -console log when executed, but in CLAUSE3 a locally declared -variable will mask access to the DEVMODE global symbol. -

-

-If the above code is processed by UglifyJS with an argument of ---define DEVMODE=false then UglifyJS will replace DEVMODE with the -boolean constant value false within CLAUSE1 and CLAUSE2, but it -will leave CLAUSE3 as it stands because there DEVMODE resolves to -a validly declared variable. -

-

-And more so, the constant-folding features of UglifyJS will recognise -that the if condition of CLAUSE1 is thus always false, and so will -remove the test and body of CLAUSE1 altogether (including the -otherwise slightly problematical statement false = true; which it -will have formed by replacing DEVMODE in the body). Similarly, -within CLAUSE2 both calls to console.log() will be removed -altogether. -

-

-In this way you can mimic, to a limited degree, the functionality of -the C/C++ pre-processor to enable or completely remove blocks -depending on how certain symbols are defined - perhaps using UglifyJS -to generate different versions of source aimed at different -environments -

-

-It is recommmended (but not made mandatory) that symbols designed for -this purpose are given names consisting of UPPER_CASE_LETTERS to -distinguish them from other (normal) symbols and avoid the sort of -clash that CLAUSE3 above illustrates. -

-
-
- -
- -
-

1.5 Compression – how good is it?

-
- - -

-Here are updated statistics. (I also updated my Google Closure and YUI -installations). -

-

-We're still a lot better than YUI in terms of compression, though slightly -slower. We're still a lot faster than Closure, and compression after gzip -is comparable. -

- - -- - - - - - - - - - -
FileUglifyJSUglifyJS+gzipClosureClosure+gzipYUIYUI+gzip
jquery-1.6.2.js91001 (0:01.59)3189690678 (0:07.40)31979101527 (0:01.82)34646
paper.js142023 (0:01.65)43334134301 (0:07.42)42495173383 (0:01.58)48785
prototype.js88544 (0:01.09)2668086955 (0:06.97)2632692130 (0:00.79)28624
thelib-full.js (DynarchLIB)251939 (0:02.55)72535249911 (0:09.05)72696258869 (0:01.94)76584
- - -
- -
- -
-

1.6 Bugs?

-
- - -

-Unfortunately, for the time being there is no automated test suite. But I -ran the compressor manually on non-trivial code, and then I tested that the -generated code works as expected. A few hundred times. -

-

-DynarchLIB was started in times when there was no good JS minifier. -Therefore I was quite religious about trying to write short code manually, -and as such DL contains a lot of syntactic hacks1 such as “foo == bar ? a -= 10 : b = 20”, though the more readable version would clearly be to use -“if/else”. -

-

-Since the parser/compressor runs fine on DL and jQuery, I'm quite confident -that it's solid enough for production use. If you can identify any bugs, -I'd love to hear about them (use the Google Group or email me directly). -

-
- -
- -
-

1.7 Links

-
- - - - - -
- -
- -
-

1.8 License

-
- - -

-UglifyJS is released under the BSD license: -

- - - -
Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
-Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
-
-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.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “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 HOLDER 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.
-
- - - - -
-
-
-
-

Footnotes:

-
-

1 I even reported a few bugs and suggested some fixes in the original -parse-js library, and Marijn pushed fixes literally in minutes. -

-
-
-
-

Author: Mihai Bazon -

-

Date: 2011-08-29 19:17:55 EEST

-

HTML generated by org-mode 7.01trans in emacs 23

-
-
- - diff --git a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org b/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org deleted file mode 100644 index 50c9c27..0000000 --- a/javascript/base/exercices/tests-unitaires/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org +++ /dev/null @@ -1,571 +0,0 @@ -#+TITLE: UglifyJS -- a JavaScript parser/compressor/beautifier -#+KEYWORDS: javascript, js, parser, compiler, compressor, mangle, minify, minifier -#+DESCRIPTION: a JavaScript parser/compressor/beautifier in JavaScript -#+STYLE: -#+AUTHOR: Mihai Bazon -#+EMAIL: mihai.bazon@gmail.com - -* UglifyJS --- a JavaScript parser/compressor/beautifier - -This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on [[http://nodejs.org/][NodeJS]], but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the =exports.*= lines from UglifyJS sources). - -The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in [[../lib/parse-js.js][parse-js.js]] and it's a -port to JavaScript of the excellent [[http://marijn.haverbeke.nl/parse-js/][parse-js]] Common Lisp library from [[http://marijn.haverbeke.nl/][Marijn -Haverbeke]]. - -( See [[http://github.com/mishoo/cl-uglify-js][cl-uglify-js]] if you're looking for the Common Lisp version of -UglifyJS. ) - -The second part of this package, implemented in [[../lib/process.js][process.js]], inspects and -manipulates the AST generated by the parser to provide the following: - -- ability to re-generate JavaScript code from the AST. Optionally - indented---you can use this if you want to “beautify” a program that has - been compressed, so that you can inspect the source. But you can also run - our code generator to print out an AST without any whitespace, so you - achieve compression as well. - -- shorten variable names (usually to single characters). Our mangler will - analyze the code and generate proper variable names, depending on scope - and usage, and is smart enough to deal with globals defined elsewhere, or - with =eval()= calls or =with{}= statements. In short, if =eval()= or - =with{}= are used in some scope, then all variables in that scope and any - variables in the parent scopes will remain unmangled, and any references - to such variables remain unmangled as well. - -- various small optimizations that may lead to faster code but certainly - lead to smaller code. Where possible, we do the following: - - - foo["bar"] ==> foo.bar - - - remove block brackets ={}= - - - join consecutive var declarations: - var a = 10; var b = 20; ==> var a=10,b=20; - - - resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the - replacement if the result occupies less bytes; for example 1/3 would - translate to 0.333333333333, so in this case we don't replace it. - - - consecutive statements in blocks are merged into a sequence; in many - cases, this leaves blocks with a single statement, so then we can remove - the block brackets. - - - various optimizations for IF statements: - - - if (foo) bar(); else baz(); ==> foo?bar():baz(); - - if (!foo) bar(); else baz(); ==> foo?baz():bar(); - - if (foo) bar(); ==> foo&&bar(); - - if (!foo) bar(); ==> foo||bar(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - - - remove some unreachable code and warn about it (code that follows a - =return=, =throw=, =break= or =continue= statement, except - function/variable declarations). - - - act a limited version of a pre-processor (c.f. the pre-processor of - C/C++) to allow you to safely replace selected global symbols with - specified values. When combined with the optimisations above this can - make UglifyJS operate slightly more like a compilation process, in - that when certain symbols are replaced by constant values, entire code - blocks may be optimised away as unreachable. - -** <> - -The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the -=--unsafe= flag. - -*** Calls involving the global Array constructor - -The following transformations occur: - -#+BEGIN_SRC js -new Array(1, 2, 3, 4) => [1,2,3,4] -Array(a, b, c) => [a,b,c] -new Array(5) => Array(5) -new Array(a) => Array(a) -#+END_SRC - -These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. - -UglifyJS does handle the case where Array is redefined locally, or even -globally but with a =function= or =var= declaration. Therefore, in the -following cases UglifyJS *doesn't touch* calls or instantiations of Array: - -#+BEGIN_SRC js -// case 1. globally declared variable - var Array; - new Array(1, 2, 3); - Array(a, b); - - // or (can be declared later) - new Array(1, 2, 3); - var Array; - - // or (can be a function) - new Array(1, 2, 3); - function Array() { ... } - -// case 2. declared in a function - (function(){ - a = new Array(1, 2, 3); - b = Array(5, 6); - var Array; - })(); - - // or - (function(Array){ - return Array(5, 6, 7); - })(); - - // or - (function(){ - return new Array(1, 2, 3, 4); - function Array() { ... } - })(); - - // etc. -#+END_SRC - -*** =obj.toString()= ==> =obj+“”= - -** Install (NPM) - -UglifyJS is now available through NPM --- =npm install uglify-js= should do -the job. - -** Install latest code from GitHub - -#+BEGIN_SRC sh -## clone the repository -mkdir -p /where/you/wanna/put/it -cd /where/you/wanna/put/it -git clone git://github.com/mishoo/UglifyJS.git - -## make the module available to Node -mkdir -p ~/.node_libraries/ -cd ~/.node_libraries/ -ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js - -## and if you want the CLI script too: -mkdir -p ~/bin -cd ~/bin -ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs - # (then add ~/bin to your $PATH if it's not there already) -#+END_SRC - -** Usage - -There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: - -#+BEGIN_SRC sh -uglifyjs [ options... ] [ filename ] -#+END_SRC - -=filename= should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. - -Supported options: - -- =-b= or =--beautify= --- output indented code; when passed, additional - options control the beautifier: - - - =-i N= or =--indent N= --- indentation level (number of spaces) - - - =-q= or =--quote-keys= --- quote keys in literal objects (by default, - only keys that cannot be identifier names will be quotes). - -- =--ascii= --- pass this argument to encode non-ASCII characters as - =\uXXXX= sequences. By default UglifyJS won't bother to do it and will - output Unicode characters instead. (the output is always encoded in UTF8, - but if you pass this option you'll only get ASCII). - -- =-nm= or =--no-mangle= --- don't mangle variable names - -- =-ns= or =--no-squeeze= --- don't call =ast_squeeze()= (which does various - optimizations that result in smaller, less readable code). - -- =-mt= or =--mangle-toplevel= --- mangle names in the toplevel scope too - (by default we don't do this). - -- =--no-seqs= --- when =ast_squeeze()= is called (thus, unless you pass - =--no-squeeze=) it will reduce consecutive statements in blocks into a - sequence. For example, "a = 10; b = 20; foo();" will be written as - "a=10,b=20,foo();". In various occasions, this allows us to discard the - block brackets (since the block becomes a single statement). This is ON - by default because it seems safe and saves a few hundred bytes on some - libs that I tested it on, but pass =--no-seqs= to disable it. - -- =--no-dead-code= --- by default, UglifyJS will remove code that is - obviously unreachable (code that follows a =return=, =throw=, =break= or - =continue= statement and is not a function/variable declaration). Pass - this option to disable this optimization. - -- =-nc= or =--no-copyright= --- by default, =uglifyjs= will keep the initial - comment tokens in the generated code (assumed to be copyright information - etc.). If you pass this it will discard it. - -- =-o filename= or =--output filename= --- put the result in =filename=. If - this isn't given, the result goes to standard output (or see next one). - -- =--overwrite= --- if the code is read from a file (not from STDIN) and you - pass =--overwrite= then the output will be written in the same file. - -- =--ast= --- pass this if you want to get the Abstract Syntax Tree instead - of JavaScript as output. Useful for debugging or learning more about the - internals. - -- =-v= or =--verbose= --- output some notes on STDERR (for now just how long - each operation takes). - -- =-d SYMBOL[=VALUE]= or =--define SYMBOL[=VALUE]= --- will replace - all instances of the specified symbol where used as an identifier - (except where symbol has properly declared by a var declaration or - use as function parameter or similar) with the specified value. This - argument may be specified multiple times to define multiple - symbols - if no value is specified the symbol will be replaced with - the value =true=, or you can specify a numeric value (such as - =1024=), a quoted string value (such as ="object"= or - ='https://github.com'=), or the name of another symbol or keyword - (such as =null= or =document=). - This allows you, for example, to assign meaningful names to key - constant values but discard the symbolic names in the uglified - version for brevity/efficiency, or when used wth care, allows - UglifyJS to operate as a form of *conditional compilation* - whereby defining appropriate values may, by dint of the constant - folding and dead code removal features above, remove entire - superfluous code blocks (e.g. completely remove instrumentation or - trace code for production use). - Where string values are being defined, the handling of quotes are - likely to be subject to the specifics of your command shell - environment, so you may need to experiment with quoting styles - depending on your platform, or you may find the option - =--define-from-module= more suitable for use. - -- =-define-from-module SOMEMODULE= --- will load the named module (as - per the NodeJS =require()= function) and iterate all the exported - properties of the module defining them as symbol names to be defined - (as if by the =--define= option) per the name of each property - (i.e. without the module name prefix) and given the value of the - property. This is a much easier way to handle and document groups of - symbols to be defined rather than a large number of =--define= - options. - -- =--unsafe= --- enable other additional optimizations that are known to be - unsafe in some contrived situations, but could still be generally useful. - For now only these: - - - foo.toString() ==> foo+"" - - new Array(x,...) ==> [x,...] - - new Array(x) ==> Array(x) - -- =--max-line-len= (default 32K characters) --- add a newline after around - 32K characters. I've seen both FF and Chrome croak when all the code was - on a single line of around 670K. Pass --max-line-len 0 to disable this - safety feature. - -- =--reserved-names= --- some libraries rely on certain names to be used, as - pointed out in issue #92 and #81, so this option allow you to exclude such - names from the mangler. For example, to keep names =require= and =$super= - intact you'd specify --reserved-names "require,$super". - -- =--inline-script= -- when you want to include the output literally in an - HTML = - - - - - - - -

Nodeunit Test Suite

- - - diff --git a/javascript/base/exercices/tests-unitaires/package.json b/javascript/base/exercices/tests-unitaires/package.json new file mode 100644 index 0000000..6028aa7 --- /dev/null +++ b/javascript/base/exercices/tests-unitaires/package.json @@ -0,0 +1,15 @@ +{ + "name": "tests-unitaires", + "version": "1.0.0", + "description": "``` npm install ./node_modules/.bin/nodeunit math-suite.js ```", + "main": "math-suite.js", + "dependencies": { + "nodeunit": "^0.9.1" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "GPL" +}