diff --git a/JavaScript/README.md b/JavaScript/README.md new file mode 100644 index 0000000..9a82c9c --- /dev/null +++ b/JavaScript/README.md @@ -0,0 +1,7 @@ +Instructions +------------ + +1. Connect the Pulse Sensor to the "A0" pin of the Arduino +2. Burn Standard Firmata to Arduino memory +3. Navigate to the current directory on the console +4. Run 'node app.js' diff --git a/JavaScript/app.js b/JavaScript/app.js new file mode 100644 index 0000000..b35b1fa --- /dev/null +++ b/JavaScript/app.js @@ -0,0 +1,105 @@ +var rate = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + sampleCounter = 0, + lastBeatTime = 0, + P = 512, + T = 512, + thresh = 525, + amp = 100, + firstBeat = true, + secondBeat = false, + IBI = 600, + Pulse = false, + BPM, + Signal, + QS = false; + +var five = require('johnny-five'), + board, sensor; +board = new five.Board(); + +board.on('ready', function() { + sensor = new five.Sensor({ + pin: "A0", + freq: 2 + }); + + sensor.scale([0,1024]).on('read', function() { + Signal = this.scaled; + calculate_bpm(); + + if(QS === true) { + console.log('BPM : ', BPM); + QS = false; + } + }); +}); + +function calculate_bpm() { + + sampleCounter += 2; + N = sampleCounter - lastBeatTime; + + if(Signal < thresh && N > (IBI/5)*3) { + if (Signal < T) { + T = Signal; + } + } + + if(Signal > thresh && Signal > P) { + P = Signal; + } + + + if (N > 250) { + + if ((Signal > thresh) && (Pulse === false) && (N > (IBI/5)*3)) { + Pulse = true; + IBI = sampleCounter - lastBeatTime; + lastBeatTime = sampleCounter; + + if(secondBeat) { + secondBeat = false; + for(var i=0; i<=9; i++){ + rate[i] = IBI; + } + } + + if(firstBeat) { + firstBeat = false; + secondBeat = true; + return; + } + + + var runningTotal = 0; + + for(var i=0; i<=8; i++) { + rate[i] = rate[i+1]; + runningTotal += rate[i]; + } + + rate[9] = IBI; + runningTotal += rate[9]; + runningTotal /= 10; + BPM = 60000/runningTotal; + QS = true; + } + } + + if (Signal < thresh && Pulse === true){ + Pulse = false; + amp = P - T; + thresh = amp/2 + T; + P = thresh; + T = thresh; + } + + if (N > 2500) { + thresh = 512; + P = 512; + T = 512; + lastBeatTime = sampleCounter; + firstBeat = true; + secondBeat = false; + } +} diff --git a/JavaScript/node_modules/johnny-five/.jscsrc b/JavaScript/node_modules/johnny-five/.jscsrc new file mode 100644 index 0000000..f14917e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/.jscsrc @@ -0,0 +1,29 @@ +{ + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch" + ], + "disallowNewlineBeforeBlockStatements": true, + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": true, + "requireSpaceAfterKeywords": [ + "if", "else", + "switch", "case", + "try", "catch", + "do", "while", "for", + "return", "typeof", "void" + ], + "validateQuoteMarks": { + "mark": "\"", + "escape": true + }, + "excludeFiles": [ + "node_modules/**/*.js" + ] +} diff --git a/JavaScript/node_modules/johnny-five/.jshintrc b/JavaScript/node_modules/johnny-five/.jshintrc new file mode 100644 index 0000000..84f5eda --- /dev/null +++ b/JavaScript/node_modules/johnny-five/.jshintrc @@ -0,0 +1,26 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": false, + "newcap": false, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "node": true, + "strict": false, + "esnext": true, + "quotmark": "double", + "unused": true, + "globals": { + "exports": true, + "document": true, + "$": true, + "Radar": true, + "WeakMap": true, + "window": true, + "copy": true + } +} diff --git a/JavaScript/node_modules/johnny-five/.npmignore b/JavaScript/node_modules/johnny-five/.npmignore new file mode 100644 index 0000000..8366041 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/.npmignore @@ -0,0 +1,14 @@ +node_modules/ +assets/ +docs/ +tpl/ +util/ +wip/ +articles.yaml +articles.js +*.c +*.ino +*.py +*.cpp +*.h +release diff --git a/JavaScript/node_modules/johnny-five/.travis.yml b/JavaScript/node_modules/johnny-five/.travis.yml new file mode 100644 index 0000000..1e80c9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/.travis.yml @@ -0,0 +1,13 @@ +language: node_js +node_js: + - "0.10" +compiler: clang +before_script: + - grunt test-examples +notifications: + webhooks: + urls: + - "https://webhooks.gitter.im/e/2f6f94ff359a6445b59d" + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: false # default: false diff --git a/JavaScript/node_modules/johnny-five/CONTRIBUTING.md b/JavaScript/node_modules/johnny-five/CONTRIBUTING.md new file mode 100644 index 0000000..c4a1c60 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/CONTRIBUTING.md @@ -0,0 +1,94 @@ +Contribute to Johnny-Five! +===================== +Do you want to help out but don't know where to start? + +### Guideline Contents + +There are a lot of ways to get involved and help out: +- [Reporting an issue](#reporting-issues) +- [Requesting features](#requesting-features) +- [Requesting Support for new hardware](#hardware-support) +- [Submitting Pullrequests](#pullrequests) +- [Writing tests](#writing-tests) +- [Writing Documentation](#writing-docs) +- [Sample Projects](#sample-projects) + + +## Reporting An Issue + +Johnny-Five does it's [issue tracking](https://github.com/rwaldron/johnny-five/issues) through github. To report an issue first search the repo to make sure that it has not been reported before. If no one has reported the bug before, create a new issue and be sure to include the following information: + +**Board:** (e.g Arduino Uno, Intel Edison, etc) +**Shield:** (if you're using one, what kind) +**Hardware you are having an issue with:** (e.g. servos, leds, sensors, and what brand/type you are using) +**Version of Johnny-Five:** +**What your expectations are:** +**What the actual outcome is:** +**Steps to reproduce (including code samples):** + +Lastly, if you are able, including a video is incredibly helpful in a lot of cases of debugging issues. You can upload videos to [youtube](https://www.youtube.com/), [vine](https://vine.co/), or any site that lets you host videos. + +If the issue has been reported before but you have new information to help troubleshoot the issue, add a comment to the thread with the same information as requested above. + + + +## Requesting Features + +To request a new feature be added to one of the existing classes, create a [github issue](https://github.com/rwaldron/johnny-five/issues) and include: + +**What feature you'd like to see:** +**Why this is important to you:** (this is here because it's interesting knowing what cool things people are working on and also could help community members make suggestions for work-arounds until the feature is built) + + + + +## Hardware Support + +Often, people get a new cool toy and wonder "does Johnny-Five support this yet?" When requesting support for new hardware remember that the team working on johnny-five might not own that hardware. + +To submit a request to support new hardware, first create a [github issue](https://github.com/rwaldron/johnny-five/issues) and include a link to the specs of the hardware and where one can purchase it. Often, it might be suggested that you be the one to help implement the support yourself if you're already in possession of the product. + + +## Submitting Pull Requests + +To contribute code to Johnny-Five, fork the project onto your github account and do your work in a branch. Before you submit the PR, make sure to rebase master into your branch so that you have the most recent changes and nothing breaks or conflicts. Lint and test your code using [grunt](https://github.com/gruntjs/grunt). Also squash your commits to a reasonable size before submitting. + +All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwaldron/idiomatic.js), +by maintaining the existing coding style. + +If you are contributing code, it must include unit tests that fail if the working code isn't present and succeed when it is. Also make sure you run `grunt jsbeautifier` to fix any syntax issues. + +When contributing new features that support new hardware, you must include documentation. The docs need to have: + +- [ ] fritzing diagram +- [ ] anotated example script in the eg/ folder +- [ ] api documentation in the wiki + +It's very important that your pull requests include all of the above in order for users to be able to use your code. Pull requests with undocumented code will not be accepted. + + + +## Writing Tests + +Tests are written using [nodeunit](https://github.com/caolan/nodeunit) and [sinon](http://sinonjs.org/). If you are having issues making a test pass, ask for help in the Johnny-Five [gitter](https://gitter.im/) room. Tests can be the hardest part to write when contributing code, so don't be discouraged. + +If you're interested in just writing tests to learn more about the project, check out the [tests](https://github.com/rwaldron/johnny-five/labels/Tests) label in the issues. + +Tests that involve temporal elements (e.g. animations, tones/songs) can be troublesome on certain hardware and can cause failures for Travis CI builds. These tests can be put in `test/extended` to prevent them from breaking builds. + + +## Writing Documentation + +We are always looking to improve our docs. If you find that any are lacking information or have wrong information, fix and submit a PR. If you're looking for areas to start writing docs for, see the [docs](https://github.com/rwaldron/johnny-five/labels/DOCS) label in issues. + +Docs should have tested and working sample code, [fritzing diagrams](http://fritzing.org/), photos, and videos where applicable. Many people using Johnny-Five are learning how to work with hardware for the first time, so write for a beginner audience. + +The [wiki](https://github.com/rwaldron/johnny-five/wiki) contains documentation about the api, and contains code examples and fritzing diagrams. + +The [eg folder](https://github.com/rwaldron/johnny-five/tree/master/eg) contains working code examples that users can run out of the box. Each of these example files has an associated .md file in the [docs folder](https://github.com/rwaldron/johnny-five/tree/master/docs) that is generated from the eg files. When contributing documentation updates for those code examples, modify the one in the [eg folder](https://github.com/rwaldron/johnny-five/tree/master/eg) and run `grunt examples` to regenerate its [docs folder](https://github.com/rwaldron/johnny-five/tree/master/docs) counterpart, then submit both of them as part of your contribution/PR. If you add a new documentation file, remember you will need to add it to `tpl/program.json` as well. + + + +## Sample Projects + +Have you made something cool with Johnny-Five? Let us know! There are a lot of people out there hacking on similar projects and looking for ideas, help or code. We'd like to create a directory of cool projects. diff --git a/JavaScript/node_modules/johnny-five/Gruntfile.js b/JavaScript/node_modules/johnny-five/Gruntfile.js new file mode 100644 index 0000000..0151e00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/Gruntfile.js @@ -0,0 +1,439 @@ +require("es6-shim"); +require("copy-paste"); + +var fs = require("fs"); +var exec = require("child_process").exec; +var shell = require("shelljs"); + +process.env.IS_TEST_MODE = true; + +module.exports = function(grunt) { + + var task = grunt.task; + var file = grunt.file; + var log = grunt.log; + var fail = grunt.fail; + var verbose = grunt.verbose; + var _ = grunt.util._; + + var templates = { + changelog: _.template(file.read("tpl/.changelog.md")), + eg: _.template(file.read("tpl/.eg.md")), + img: _.template(file.read("tpl/.img.md")), + breadboard: _.template(file.read("tpl/.breadboard.md")), + eglink: _.template(file.read("tpl/.readme.eglink.md")), + readme: _.template(file.read("tpl/.readme.md")), + embeds: { + youtube: _.template(file.read("tpl/.embed-youtube.html")), + }, + program: _.template(file.read("tpl/.eg-program-template.js")), + }; + + var noedit = file.read("tpl/.noedit.md"); + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + examples: { + files: ["tpl/programs.json"] + }, + nodeunit: { + tests: [ + "test/bootstrap/*.js", + "test/*.js" + ] + }, + jshint: { + options: { + jshintrc: true + }, + files: { + src: [ + "Gruntfile.js", + "lib/**/!(johnny-five)*.js", + "test/**/*.js", + "eg/**/*.js", + "wip/autobot-2.js" + ] + } + }, + jscs: { + src: [ + "Gruntfile.js", + "lib/**/!(johnny-five)*.js", + "test/**/*.js", + "eg/**/*.js", + "util/**/*.js" + ], + options: { + config: ".jscsrc" + } + }, + jsbeautifier: { + files: ["lib/**/*.js", "eg/**/*.js", "test/**/*.js"], + options: { + js: { + braceStyle: "collapse", + breakChainedMethods: false, + e4x: false, + evalCode: false, + indentChar: " ", + indentLevel: 0, + indentSize: 2, + indentWithTabs: false, + jslintHappy: false, + keepArrayIndentation: false, + keepFunctionIndentation: false, + maxPreserveNewlines: 10, + preserveNewlines: true, + spaceBeforeConditional: true, + spaceInParen: false, + unescapeStrings: false, + wrapLineLength: 0 + } + } + }, + watch: { + src: { + files: [ + "Gruntfile.js", + "lib/**/!(johnny-five)*.js", + "test/**/*.js", + "eg/**/*.js" + ], + tasks: ["default"], + options: { + interrupt: true, + }, + } + } + }); + + grunt.registerTask("example", "Create an example program, usage: \"grunt expample:[.js]\"", function(fileName) { + + if (!fileName.endsWith(".js")) { + fileName += ".js"; + } + + var pathAndFile = "eg/" + fileName; + + if (file.exists(pathAndFile)) { + fail.warn(pathAndFile + " exists!"); + } else { + file.write(pathAndFile, templates.program()); + log.writeln("Example created: %s", pathAndFile); + } + }); + + // Support running a single test suite: + // grunt nodeunit:just:motor for example + grunt.registerTask("nodeunit:just", "Run a single test specified by a target; usage: \"grunt nodeunit:just:[.js]\"", function(file) { + if (file) { + grunt.config("nodeunit.tests", [ + "test/bootstrap/*.js", + "test/" + file + ".js", + ]); + } + + grunt.task.run("nodeunit"); + }); + + // Support running a complete set of tests with + // extended (possibly-slow) tests included. + grunt.registerTask("nodeunit:complete", function() { + var testConfig = grunt.config("nodeunit.tests"); + testConfig.push("test/extended/*.js"); + grunt.config("nodeunit.tests", testConfig); + grunt.task.run("nodeunit"); + }); + + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-contrib-nodeunit"); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-jsbeautifier"); + grunt.loadNpmTasks("grunt-jscs"); + + grunt.registerTask("default", ["jshint", "jscs", "nodeunit"]); + // Explicit test task runs complete set of tests + grunt.registerTask("test", ["jshint", "jscs", "nodeunit:complete"]); + + grunt.registerMultiTask("examples", "Generate examples", function() { + // Concat specified files. + var entries = JSON.parse(file.read(file.expand(this.data))); + var readme = []; + + + entries.forEach(function(entry) { + var topic = entry.topic; + + log.writeln("Processing examples for: " + entry.topic); + + readme.push("\n### " + topic + "\n"); + + entry.examples.forEach(function(example) { + var markdown, filepath, eg, md, inMarkdown, + images, breadboards, embeds, name, imgMarkdown, values, primary; + + markdown = []; + filepath = "eg/" + example.file; + + if ( !example.file || !fs.existsSync(filepath) ) { + grunt.fail.fatal("Specified example file doesn't exist: " + filepath); + } + + eg = file.read(filepath); + name = (example.name || example.file).replace(".js", ""); + + md = "docs/" + name + ".md"; + inMarkdown = false; + + if (!example.title) { + grunt.fail.fatal("Invalid example (" + name + "): title required"); + } + + // Modify code in example to appear as it would if installed via npm + eg = eg.replace(/\.\.\/lib\/|\.js/g, "").split("\n").filter(function(line) { + if (/@markdown/.test(line)) { + inMarkdown = !inMarkdown; + return false; + } + + if (inMarkdown) { + line = line.trim(); + if (line) { + markdown.push( + line.replace(/^\/\//, "").trim() + ); + } + // Filter out the markdown lines + // from the main content. + return false; + } + + return true; + }).join("\n"); + + markdown = markdown.join("\n"); + + // If there are photo images to include + images = example.images || []; + + // Get list of breadboards diagrams to include (Default: same as file name) + breadboards = example.breadboards || [{ + "name": name, + "title": "Breadboard for \"" + example.title + "\"", + "auto": true + }]; + + embeds = (example.embeds || []).map(function(embed) { + return templates.embeds[embed.type]({ src: embed.src }); + }); + + // We'll combine markdown for images and breadboards + imgMarkdown = ""; + + primary = breadboards.shift(); + + images.forEach(function(img) { + if (!img.title || !img.file) { + grunt.fail.fatal("Invalid image: title and file required"); + } + + img.filepath = "docs/images/" + img.file; + var hasImg = fs.existsSync(img.filepath); + if (hasImg) { + imgMarkdown += templates.img({ img: img }); + } else { + // If it's specified but doesn't exist, we'll consider it an error + grunt.fail.fatal("Invalid image: " + img.file); + } + }); + + breadboards.forEach(function(breadboard) { + imgMarkdown += breadboardMarkdown(breadboard); + }); + + values = { + command: "node " + filepath, + description: example.description, + embeds: embeds, + example: eg, + externals: example.externals || [], + file: md, + images: imgMarkdown, + markdown: markdown, + primary: primary ? breadboardMarkdown(primary) : "", + title: example.title, + }; + + // Write the file to /docs/* + file.write(md, templates.eg(values)); + + // Push a rendered markdown link into the readme "index" + readme.push(templates.eglink(values)); + }); + }); + + // Write the readme with doc link index + file.write("README.md", + templates.readme({ + noedit: noedit, + eglinks: readme.join("") + }) + ); + + log.writeln("Examples created."); + }); + + + function breadboardMarkdown(breadboard) { + if (!breadboard.name) { + grunt.fail.fatal("Invalid breadboard: name required"); + } + + if (!breadboard.title) { + grunt.fail.fatal("Invalid breadboard (" + breadboard.name + "): title required"); + } + + breadboard.png = "docs/breadboard/" + breadboard.name + ".png"; + breadboard.fzz = "docs/breadboard/" + breadboard.name + ".fzz"; + + breadboard.hasPng = fs.existsSync(breadboard.png); + breadboard.hasFzz = fs.existsSync(breadboard.fzz); + + if (!breadboard.hasPng) { + if (breadboard.auto) { + // i.e. we tried to guess at a name but still doesn't exist + // We can just ignore and no breadboard shown + return; + } else { + // A breadboard was specified but doesn't exist - error + grunt.fail.fatal("Specified breadboard doesn't exist: " + breadboard.png); + } + } + + // FZZ is optional, but we'll warn at verbose + if (!breadboard.hasFzz) { + verbose.writeln("Missing FZZ: " + breadboard.fzz); + } + + return templates.breadboard({ breadboard: breadboard }); + } + + // run the examples task and fail if there are uncommitted changes to the docs directory + task.registerTask("test-examples", "Guard against out of date examples", ["examples", "fail-if-uncommitted-examples"]); + + task.registerTask("fail-if-uncommitted-examples", function() { + task.requires("examples"); + if (shell.exec("git diff --exit-code --name-status ./docs").code !== 0) { + grunt.fail.fatal("The generated examples don't match the committed examples. Please ensure you've run `grunt examples` before committing."); + } + }); + + grunt.registerTask("bump", "Bump the version", function(version) { + + // THIS IS SLIGHTLY INSANE. + // + // + // + // I don't want the whole package.json file reformatted, + // (because it makes the contributors section look insane) + // so we're going to look at lines and update the version + // line with either the next version of the specified version. + // + // It's either this or the whole contributors section + // changes from 1 line per contributor to 3 lines per. + // + + var pkg = grunt.file.read("package.json").split(/\n/).map(function(line) { + var replacement, minor, data; + + if (/version/.test(line)) { + data = line.replace(/"|,/g, "").split(":")[1].split("."); + + if (version) { + replacement = version; + } else { + minor = +data[2]; + data[2] = ++minor; + replacement = data.join(".").trim(); + } + + copy(replacement); + + return " \"version\": \"" + replacement + "\","; + } + + return line; + }); + + grunt.file.write("package.json", pkg.join("\n")); + + // TODO: + // + // - git commit with "vX.X.X" for commit message + // - npm publish + // + // + }); + + grunt.registerTask("changelog", "Generate a changelog. Range: changelog:v0.0.0--v0.0.2; Current: changelog:v0.0.2", function(version) { + var done = this.async(); + var temp = ""; + var previous = ""; + var thisPatch; + var lastPatch; + + if (!version) { + version = grunt.config("pkg.version"); + } + + if (version.includes("--")) { + /* + Example: + + grunt changelog:v0.8.71--v0.8.73 + + */ + temp = version.split("--"); + previous = temp[0]; + version = temp[1]; + } else { + /* + Example: + + grunt changelog + grunt changelog:v0.8.73 + + */ + thisPatch = version.replace(/^v/, "").split(".").pop(); + lastPatch = Number(thisPatch) - 1; + previous = version.replace(thisPatch, lastPatch); + version = "HEAD"; + } + + exec("git log --format='%H|%h|%an|%s' " + previous + ".." + version, function(error, result) { + if (error) { + console.log(error.message); + return; + } + + var commits = result.split("\n") + .filter(function(cmt) { return cmt.trim() !== ""; }) + .map(function(cmt) { return cmt.split("|"); }); + + var rows = commits.reduce(function(accum, commit) { + if (commit[3].indexOf("Merge") === 0) { + return accum; + } + accum += "| https://github.com/rwaldron/johnny-five/commit/" + commit[0] + " | " + commit[3] + " |\n"; + + return accum; + }, ""); + + log.writeln(templates.changelog({ rows: rows })); + + done(); + }); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/LICENSE-MIT b/JavaScript/node_modules/johnny-five/LICENSE-MIT new file mode 100644 index 0000000..510d124 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/LICENSE-MIT @@ -0,0 +1,30 @@ +Copyright (c) 2012, 2013, 2014 Rick Waldron +Copyright (c) 2014, 2015 The Johnny-Five Authors + +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. + +==== + +All files located in the node_modules directory are +externally maintained libraries used by this software which have their +own licenses; we recommend you read them, as their terms may differ from +the terms above. diff --git a/JavaScript/node_modules/johnny-five/README.md b/JavaScript/node_modules/johnny-five/README.md new file mode 100644 index 0000000..a285dc5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/README.md @@ -0,0 +1,439 @@ + + +# Johnny-Five +### The JavaScript Robotics Programming Framework + + + + +_Artwork by [Mike Sgier](http://msgierillustration.com)_ + +[](https://travis-ci.org/rwaldron/johnny-five) +[](https://gitter.im/rwaldron/johnny-five?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + +**Johnny-Five is an Open Source, Firmata Protocol based, IoT and Robotics programming framework, developed at [Bocoup](http://bocoup.com). Johnny-Five programs can be written for Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Spark/Particle Core, TI Launchpad and more!** + +Johnny-Five has grown from a passion project into a tool for inspiring learning and creativity for people of all ages, backgrounds, and from all across the world. + +Just interested in learning and building awesome things? You might want to start with the official [Johnny-Five website](http://johnny-five.io). The website combines content from this repo, the wiki, tutorials from the Bocoup blog and several third-party websites into a single, easily-discoverable source: + +* If you want to find the API documentation, [that’s right here](http://johnny-five.io/api/). +* Need to figure out what platform to use for a project? We put that stuff [here](http://johnny-five.io/platform-support/). +* Need inspiration for your next NodeBot? Check out the [examples](http://johnny-five.io/examples/). +* Want to stay up-to-date with projects in the community? [Check this out](http://johnny-five.io/articles/). +* Need NodeBots community or Johnny-Five project updates and announcements? [This](http://johnny-five.io/news/) is what you’re looking for. + + +Johnny-Five does not attempt to provide "all the things", but instead focuses on delivering robust, reality tested, highly composable APIs that behave consistently across all supported hardware platforms. Johnny-Five wants to be a baseline control kit for hardware projects, allowing you the freedom to build, grow and experiment with diverse JavaScript libraries of your own choice. Johnny-Five couples comfortably with: + +- Popular application libraries such as [Express.js](http://expressjs.com/) and [Socket.io](http://socket.io/). +- Fellow hardware projects like [ar-drone](https://github.com/felixge/node-ar-drone), [Aerogel](https://github.com/ceejbot/aerogel) and [Spheron](https://github.com/alchemycs/spheron) +- Bluetooth game controllers like [XBox Controller](https://github.com/andrew/node-xbox-controller) and [DualShock](https://github.com/rdepena/node-dualshock-controller) +- IoT frameworks, such as [Octoblu](http://www.octoblu.com/) + +...And that's only a few of the many explorable possibilities. Check out these exciting projects: [node-pulsesensor](https://www.npmjs.org/package/node-pulsesensor), [footballbot-workshop-ui](https://www.npmjs.org/package/footballbot-workshop-ui), [nodebotui](https://www.npmjs.org/package/nodebotui), [dublin-disco](https://www.npmjs.org/package/dublin-disco), [node-slot-car-bot](https://www.npmjs.org/package/node-slot-car-bot), [servo-calibrator](https://www.npmjs.org/package/servo-calibrator), [node-ardx](https://www.npmjs.org/package/node-ardx), [nodebot-workshop](https://www.npmjs.org/package/nodebot-workshop), [phone-home](https://www.npmjs.org/package/phone-home), [purple-unicorn](https://www.npmjs.org/package/purple-unicorn), [webduino](https://www.npmjs.org/package/webduino), [leapduino](https://www.npmjs.org/package/leapduino), [lasercat-workshop](https://www.npmjs.org/package/lasercat-workshop), [simplesense](https://www.npmjs.org/package/simplesense), [five-redbot](https://www.npmjs.org/package/five-redbot), [robotnik](https://www.npmjs.org/package/robotnik), [the-blender](https://www.npmjs.org/package/the-blender) + + +**Why JavaScript?** +[NodeBots: The Rise of JavaScript Robotics](http://www.voodootikigod.com/nodebots-the-rise-of-js-robotics) + +## Hello Johnny + +The ubiquitous "Hello World" program of the microcontroller and SoC world is "blink an LED". The following code demonstrates how this is done using the Johnny-Five framework. + +```javascript +var five = require("johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + // Create an Led on pin 13 + var led = new five.Led(13); + // Blink every half second + led.blink(500); +}); +``` + + + +> Note: Node will crash if you try to run johnny-five in the node REPL, but board instances will create their own contextual REPL. Put your script in a file. + + +## Supported Hardware + +Johnny-Five has been tested on a variety of Arduino-compatible [Boards](https://github.com/rwaldron/johnny-five/wiki/Board). + +For non-Arduino based projects, a number of platform-specific [IO Plugins](https://github.com/rwaldron/johnny-five/wiki/IO-Plugins) are available. IO Plugins allow Johnny-Five code to communicate with any non-Arduino based hardware in whatever language that platforms speaks! + +## Documentation + +Documentation for the Johnny-Five API can be found [here](http://johnny-five.io/api/) and [example programs here](http://johnny-five.io/examples/). + +## Guidance + +Need help? Ask a question on the [NodeBots Community Forum](http://forums.nodebots.io). If you just have a quick question or are interested in ongoing design discussions, join us in the [Johnny-Five Gitter Chat](https://gitter.im/rwaldron/johnny-five). + +For step-by-step examples, including an electronics primer, check out [Arduino Experimenter's Guide for NodeJS](http://node-ardx.org/) by [@AnnaGerber](https://twitter.com/AnnaGerber) + +Here is a list of [prerequisites](https://github.com/rwaldron/johnny-five/wiki/Prerequites) for Linux, OSX or Windows. + +Check out the [bluetooth guide](https://github.com/rwaldron/johnny-five/wiki/JY-MCU-Bluetooth-Serial-Port-Module-Notes) if you want to remotely control your robot. + +## Setup and Assemble Arduino + +- Recommended Starting Kit: [Sparkfun Inventor's Kit](https://www.sparkfun.com/products/12001) +- Download [Arduino IDE](http://arduino.cc/en/main/software) +- Plug in your Arduino or Arduino compatible microcontroller via USB +- Open the Arduino IDE, select: File > Examples > Firmata > StandardFirmata +- Click the "Upload" button. + +If the upload was successful, the board is now prepared and you can close the Arduino IDE. + +For non-Arduino projects, each IO Plugin's repo will provide its own platform specific setup instructions. + + +## Hey you, here's Johnny! + +#### Source Code: + +``` bash +git clone git://github.com/rwaldron/johnny-five.git && cd johnny-five + +npm install +``` + +#### npm package: + +Install the module with: + +```bash +npm install johnny-five +``` + + +## Example Programs + +To get you up and running quickly, we provide a variety of examples for using each Johnny-Five component. One thing we’re especially excited about is the extensive collection of [Fritzing](http://fritzing.org/home/) diagrams you’ll find throughout the site. A huge part of doing any Johnny-Five project is handling the actual hardware, and we’ve included these as part of the documentation because we realised that instructions on how to write code to control a servo are insufficient without instructions on how to connect a servo! + +To interactively navigate the examples, visit the [Johnny-Five examples](http://johnny-five.io/examples/) page on the official website. If you want to link directly to the examples in this repo, you can use one of the following links. + + + +### Board +- [Basic Board initialization](https://github.com/rwaldron/johnny-five/blob/master/docs/board.md) +- [Board - Specify port](https://github.com/rwaldron/johnny-five/blob/master/docs/board-with-port.md) +- [Board - Multiple in one program](https://github.com/rwaldron/johnny-five/blob/master/docs/board-multi.md) +- [REPL](https://github.com/rwaldron/johnny-five/blob/master/docs/repl.md) +- [Pin](https://github.com/rwaldron/johnny-five/blob/master/docs/pin.md) + +### Expander +- [Expander - MCP23017](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-MCP23017.md) +- [Expander - MCP23008](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-MCP23008.md) +- [Expander - PCF8574](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-PCF8574.md) +- [Expander - PCF8575](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-PCF8575.md) +- [Expander - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-PCA9685.md) +- [Expander - PCF8591](https://github.com/rwaldron/johnny-five/blob/master/docs/expander-PCF8591.md) + +### LED +- [LED](https://github.com/rwaldron/johnny-five/blob/master/docs/led.md) +- [LED - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/led-PCA9685.md) +- [LED - Blink](https://github.com/rwaldron/johnny-five/blob/master/docs/led-blink.md) +- [LED - Pulse](https://github.com/rwaldron/johnny-five/blob/master/docs/led-pulse.md) +- [LED - Pulse with animation](https://github.com/rwaldron/johnny-five/blob/master/docs/led-pulse-animation.md) +- [LED - Fade](https://github.com/rwaldron/johnny-five/blob/master/docs/led-fade.md) +- [LED - Fade callback](https://github.com/rwaldron/johnny-five/blob/master/docs/led-fade-callback.md) +- [LED - Fade with animation](https://github.com/rwaldron/johnny-five/blob/master/docs/led-fade-animation.md) +- [LED - Demo sequence](https://github.com/rwaldron/johnny-five/blob/master/docs/led-demo-sequence.md) +- [LED - Slider](https://github.com/rwaldron/johnny-five/blob/master/docs/led-slider.md) +- [LED - Array](https://github.com/rwaldron/johnny-five/blob/master/docs/led-array.md) +- [LED - RGB](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb.md) +- [LED - RGB (Common Anode)](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-anode.md) +- [LED - RGB (Common Anode) PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-anode-PCA9685.md) +- [LED - RGB Intensity](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-intensity.md) +- [LED - Rainbow](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rainbow.md) +- [LED - Digital Clock](https://github.com/rwaldron/johnny-five/blob/master/docs/led-digits-clock.md) +- [LED - Matrix](https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix.md) +- [LED - Matrix Demo](https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix-tutorial.md) +- [LED - Matrix HT16K33](https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix-HT16K33.md) +- [LED - Matrix HT16K33 16x8](https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix-HT16K33-16x8.md) + +### Servo +- [Servo](https://github.com/rwaldron/johnny-five/blob/master/docs/servo.md) +- [Servo - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-PCA9685.md) +- [Servo - Continuous](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-continuous.md) +- [Servo - Slider control](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-slider.md) +- [Servo - Prompt](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-prompt.md) +- [Servo - Drive](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-drive.md) +- [Servo - Sweep](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-sweep.md) +- [Servo - Array of servos](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-array.md) + +### Servo Animation +- [Servo - Animation](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-animation.md) +- [Servo - Leg Animation](https://github.com/rwaldron/johnny-five/blob/master/docs/servo-animation-leg.md) + +### Motor +- [Motor](https://github.com/rwaldron/johnny-five/blob/master/docs/motor.md) +- [Motor - Directional](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-directional.md) +- [Motor - Brake](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-brake.md) +- [Motor - Current](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-current.md) +- [Motor - H-Bridge](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-hbridge.md) +- [Motor - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-PCA9685.md) +- [Motor - 3 pin](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-3-pin.md) + +### Stepper Motor +- [Stepper - Driver](https://github.com/rwaldron/johnny-five/blob/master/docs/stepper-driver.md) +- [Stepper - Sweep](https://github.com/rwaldron/johnny-five/blob/master/docs/stepper-sweep.md) + +### ESC & Brushless Motor +- [ESC - Keypress](https://github.com/rwaldron/johnny-five/blob/master/docs/esc-keypress.md) +- [ESC - Dualshock](https://github.com/rwaldron/johnny-five/blob/master/docs/esc-dualshock.md) +- [ESC - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/esc-PCA9685.md) +- [ESC - Bidirectional](https://github.com/rwaldron/johnny-five/blob/master/docs/esc-bidirectional.md) +- [ESC - Bidirectional Forward-Reverse](https://github.com/rwaldron/johnny-five/blob/master/docs/esc-bidirectional-forward-reverse.md) + +### Sonar/Ultrasonic +- [Ping](https://github.com/rwaldron/johnny-five/blob/master/docs/ping.md) +- [Sonar](https://github.com/rwaldron/johnny-five/blob/master/docs/sonar.md) +- [Sonar - Scanner](https://github.com/rwaldron/johnny-five/blob/master/docs/sonar-scan.md) +- [Sonar - I2C SRF10](https://github.com/rwaldron/johnny-five/blob/master/docs/sonar-srf10.md) + +### Button / Switch +- [Button](https://github.com/rwaldron/johnny-five/blob/master/docs/button.md) +- [Button - Bumper](https://github.com/rwaldron/johnny-five/blob/master/docs/button-bumper.md) +- [Button - Options](https://github.com/rwaldron/johnny-five/blob/master/docs/button-options.md) +- [Button - Pullup](https://github.com/rwaldron/johnny-five/blob/master/docs/button-pullup.md) +- [Toggle Switch](https://github.com/rwaldron/johnny-five/blob/master/docs/toggle-switch.md) + +### Keypad +- [Keypad - VKEY](https://github.com/rwaldron/johnny-five/blob/master/docs/keypad-analog-vkey.md) +- [Keypad - Waveshare AD](https://github.com/rwaldron/johnny-five/blob/master/docs/keypad-analog-ad.md) +- [Keypad - MPR121](https://github.com/rwaldron/johnny-five/blob/master/docs/keypad-MPR121.md) +- [Keypad - MPR121QR2](https://github.com/rwaldron/johnny-five/blob/master/docs/keypad-MPR121QR2.md) + +### Relay +- [Relay](https://github.com/rwaldron/johnny-five/blob/master/docs/relay.md) + +### Shift Register +- [Shift Register](https://github.com/rwaldron/johnny-five/blob/master/docs/shift-register.md) +- [Shift Register - Seven segment controller](https://github.com/rwaldron/johnny-five/blob/master/docs/shift-register-seven-segment.md) +- [Shift Register - Seven segments, daisy chained](https://github.com/rwaldron/johnny-five/blob/master/docs/shift-register-daisy-chain.md) + +### Infrared (Proximity, Motion, Reflectance) +- [IR Motion](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-motion.md) +- [IR Proximity](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-proximity.md) +- [IR Reflectance](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-reflect.md) +- [IR Reflectance Array](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-reflect-array.md) + +### Proximity +- [Proximity](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity.md) +- [Proximity - GP2Y0A710K0F](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-GP2Y0A710K0F.md) +- [Proximity - SRF10](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-srf10.md) +- [Proximity - MB1000](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-mb1000.md) +- [Proximity - MB1010](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-mb1010.md) +- [Proximity - MB1003](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-mb1003.md) +- [Proximity - MB1230](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-mb1230.md) +- [Proximity - HC-SR04](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-hcsr04.md) +- [Proximity - LIDAR-Lite](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-lidarlite.md) + +### Motion +- [Motion](https://github.com/rwaldron/johnny-five/blob/master/docs/motion.md) +- [Motion - GP2Y0D805Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d805z0f.md) +- [Motion - GP2Y0D810Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d810z0f.md) +- [Motion - GP2Y0D810Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d815z0f.md) +- [Motion - GP2Y0A60SZLF](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-GP2Y0A60SZLF.md) + +### Joystick +- [Joystick](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick.md) +- [Joystick - Esplora](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick-esplora.md) +- [Joystick - Sparkfun Shield](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick-shield.md) +- [Joystick - Pan + Tilt control](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick-pantilt.md) + +### LCD +- [LCD](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd.md) +- [LCD - Enumerate characters](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-enumeratechars.md) +- [LCD - Runner 20x4](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-runner-20x4.md) +- [LCD - Runner 16x2](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-runner.md) +- [LCD - I2C](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-i2c.md) +- [LCD - I2C PCF8574](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-i2c-PCF8574.md) +- [LCD - I2C Runner](https://github.com/rwaldron/johnny-five/blob/master/docs/lcd-i2c-runner.md) + +### Compass/Magnetometer +- [Compass / Magnetometer](https://github.com/rwaldron/johnny-five/blob/master/docs/magnetometer.md) +- [Compass - HMC6352](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-hmc6352.md) +- [Compass - HMC5883L](https://github.com/rwaldron/johnny-five/blob/master/docs/compass-hmc5883l.md) +- [Compass - Logger](https://github.com/rwaldron/johnny-five/blob/master/docs/magnetometer-log.md) +- [Compass - Find north](https://github.com/rwaldron/johnny-five/blob/master/docs/magnetometer-north.md) + +### Piezo +- [Piezo](https://github.com/rwaldron/johnny-five/blob/master/docs/piezo.md) + +### IMU/Multi +- [IMU - MPU6050](https://github.com/rwaldron/johnny-five/blob/master/docs/imu-mpu6050.md) +- [Multi - MPL115A2](https://github.com/rwaldron/johnny-five/blob/master/docs/multi-mpl115a2.md) +- [Multi - BMP180](https://github.com/rwaldron/johnny-five/blob/master/docs/multi-bmp180.md) + +### Sensors +- [Sensor](https://github.com/rwaldron/johnny-five/blob/master/docs/sensor.md) +- [Sensor - Slide potentiometer](https://github.com/rwaldron/johnny-five/blob/master/docs/sensor-slider.md) +- [Sensor - Force sensitive resistor](https://github.com/rwaldron/johnny-five/blob/master/docs/sensor-fsr.md) +- [Sensor - Photoresistor](https://github.com/rwaldron/johnny-five/blob/master/docs/photoresistor.md) +- [Sensor - Potentiometer](https://github.com/rwaldron/johnny-five/blob/master/docs/potentiometer.md) +- [Sensor - Microphone](https://github.com/rwaldron/johnny-five/blob/master/docs/microphone.md) +- [Accelerometer](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer.md) +- [Accelerometer - ADXL345](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer-adxl345.md) +- [Accelerometer - ADXL335](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer-adxl335.md) +- [Accelerometer - MMA7361](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer-mma7361.md) +- [Accelerometer - MPU6050](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer-mpu6050.md) +- [Accelerometer - Pan + Tilt](https://github.com/rwaldron/johnny-five/blob/master/docs/accelerometer-pan-tilt.md) +- [Gyro](https://github.com/rwaldron/johnny-five/blob/master/docs/gyro.md) +- [Gyro - Analog LPR5150AL](https://github.com/rwaldron/johnny-five/blob/master/docs/gyro-lpr5150l.md) +- [Gyro - I2C MPU6050](https://github.com/rwaldron/johnny-five/blob/master/docs/gyro-mpu6050.md) +- [Temperature - TMP36](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-tmp36.md) +- [Temperature - LM35](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-lm35.md) +- [Temperature - DS18B20](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-ds18b20.md) +- [Temperature - MPU6050](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-mpu6050.md) +- [Barometer - MPL115A2](https://github.com/rwaldron/johnny-five/blob/master/docs/barometer-mpl115a2.md) +- [Temperature - MPL115A2](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-mpl115a2.md) +- [Barometer - BMP180](https://github.com/rwaldron/johnny-five/blob/master/docs/barometer-BMP180.md) +- [Temperature - BMP180](https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-BMP180.md) + +### Grove IoT Kit (Seeed Studio) +- [Grove - LED](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-led.md) +- [Grove - Button](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-button.md) +- [Grove - Touch](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-touch.md) +- [Grove - Sensor](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-sensor.md) +- [Grove - LCD RGB](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-lcd-rgb.md) +- [Grove - LCD RGB temperature display](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-lcd-rgb-temperature-display.md) +- [Grove - Servo](https://github.com/rwaldron/johnny-five/blob/master/docs/grove-servo.md) + +### TinkerKit +- [TinkerKit - Accelerometer](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-accelerometer.md) +- [TinkerKit - Blink](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-blink.md) +- [TinkerKit - Button](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-button.md) +- [TinkerKit - Combo](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-combo.md) +- [TinkerKit - Continuous servo](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-continuous-servo.md) +- [TinkerKit - Gyro](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-gyroscope.md) +- [TinkerKit - Joystick](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-joystick.md) +- [TinkerKit - Linear potentiometer](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-linear-pot.md) +- [TinkerKit - Rotary potentiometer](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-rotary.md) +- [TinkerKit - Temperature](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-thermistor.md) +- [TinkerKit - Tilt](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-tilt.md) +- [TinkerKit - Touch](https://github.com/rwaldron/johnny-five/blob/master/docs/tinkerkit-touch.md) + +### Wii +- [Wii Nunchuck](https://github.com/rwaldron/johnny-five/blob/master/docs/nunchuk.md) +- [Wii Classic Controller](https://github.com/rwaldron/johnny-five/blob/master/docs/classic-controller.md) + +### Complete Bots / Projects +- [Line Follower](https://github.com/rwaldron/johnny-five/blob/master/docs/line-follower.md) +- [Motobot](https://github.com/rwaldron/johnny-five/blob/master/docs/motobot.md) +- [Navigator](https://github.com/rwaldron/johnny-five/blob/master/docs/navigator.md) +- [Nodebot](https://github.com/rwaldron/johnny-five/blob/master/docs/nodebot.md) +- [Whisker](https://github.com/rwaldron/johnny-five/blob/master/docs/whisker.md) +- [Phoenix Hexapod](https://github.com/rwaldron/johnny-five/blob/master/docs/phoenix.md) +- [BOE Bot](https://github.com/rwaldron/johnny-five/blob/master/docs/boe-test-servos.md) +- [Bug](https://github.com/rwaldron/johnny-five/blob/master/docs/bug.md) +- [Lynxmotion Biped BRAT](https://github.com/rwaldron/johnny-five/blob/master/docs/brat.md) +- [Robotic Claw](https://github.com/rwaldron/johnny-five/blob/master/docs/claw.md) +- [Kinect Robotic Arm Controller](https://github.com/rwaldron/johnny-five/blob/master/docs/kinect-arm-controller.md) +- [Laser Trip Wire](https://github.com/rwaldron/johnny-five/blob/master/docs/laser-trip-wire.md) +- [Radar](https://github.com/rwaldron/johnny-five/blob/master/docs/radar.md) + +### Component Plugin Template +- [Example plugin](https://github.com/rwaldron/johnny-five/blob/master/docs/plugin.md) + +### IO Plugins +- [Led Blink on Electric Imp](https://github.com/rwaldron/johnny-five/blob/master/docs/imp-io.md) +- [Led Blink on Spark Core](https://github.com/rwaldron/johnny-five/blob/master/docs/spark-io.md) +- [Led Blink on pcDuino3](https://github.com/rwaldron/johnny-five/blob/master/docs/pcduino-io.md) +- [Led Blink on Intel Galileo Gen 2](https://github.com/rwaldron/johnny-five/blob/master/docs/galileo-io.md) +- [Led Blink on Raspberry Pi](https://github.com/rwaldron/johnny-five/blob/master/docs/raspi-io.md) +- [Led Blink on Intel Edison Arduino Board](https://github.com/rwaldron/johnny-five/blob/master/docs/edison-io-arduino.md) +- [Led Blink on Intel Edison Mini Board](https://github.com/rwaldron/johnny-five/blob/master/docs/edison-io-miniboard.md) + + + +## Many fragments. Some large, some small. + +#### [Wireless Nodebot](http://jsfiddle.net/rwaldron/88M6b/show/light) +#### [Kinect Controlled Robot Arm](http://jsfiddle.net/rwaldron/XMsGQ/show/light/) +#### [Biped Nodebot](http://jsfiddle.net/rwaldron/WZkn5/show/light/) +#### [LCD Running Man](http://jsfiddle.net/rwaldron/xKwaU/show/light/) +#### [Slider Controlled Panning Servo](http://jsfiddle.net/rwaldron/kZakv/show/light/) +#### [Joystick Controlled Laser (pan/tilt) 1](http://jsfiddle.net/rwaldron/HPqms/show/light/) +#### [Joystick Controlled Laser (pan/tilt) 2](http://jsfiddle.net/rwaldron/YHb7A/show/light/) +#### [Joystick Controlled Claw](http://jsfiddle.net/rwaldron/6ZXFe/show/light/) +#### [Robot Claw](http://jsfiddle.net/rwaldron/CFSZJ/show/light/) +#### [Joystick, Motor & Led](http://jsfiddle.net/rwaldron/gADSz/show/light/) + + + +## Make: JavaScript Robotics + +[](http://shop.oreilly.com/product/0636920031390.do) + + + + +## Contributing +All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwaldron/idiomatic.js), +by maintaining the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/gruntjs/grunt). + + +## License +Copyright (c) 2012, 2013, 2014 Rick Waldron +Licensed under the MIT license. +Copyright (c) 2014, 2015 The Johnny-Five Contributors +Licensed under the MIT license. diff --git a/JavaScript/node_modules/johnny-five/awesome.md b/JavaScript/node_modules/johnny-five/awesome.md new file mode 100644 index 0000000..098c53a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/awesome.md @@ -0,0 +1,142 @@ +# Awesome Nodebots Built with Johnny-Five +---------------- +(Entries listed newest to oldest) + + +## Ricardo de Pena [@ricardodepena](https://twitter.com/ricardodepena) + +- Clawbot: bluetooth bot with a claw, controlled via a ps3 controller + [video](http://vimeo.com/86788094) + [code](https://github.com/rdepena/clawbot) + + +## Richard Key [@busyrich](http://twitter.com/busyrich) + +- Arduino Attack! + [video](http://www.youtube.com/watch?v=1NalU4d7a20) + [code](https://github.com/BusyRich/arduino-attack) + + +## Andrew Homeyer [@andrewhomeyer](https://twitter.com/andrewhomeyer), Matt Parrish [@mattparrish](https://twitter.com/mattparrish), Nicholas Boll [@nicholasboll](https://twitter.com/nicholasboll) + +- Missile Command: A rubber band launcher that took down a nodecopter + [video](http://youtu.be/0FAfu-Zowuo) + [code](https://github.com/homeyer/missile-command/) + + +## Sara Gorecki [@opheliasdaisies] (https://twitter.com/opheliasdaisies) + +- A tri-color LED that cycles according to pressure sensor input. + [video](http://youtu.be/ePiiaja1CuI) + [code](https://github.com/opheliasdaisies/tri-color-led) + + +## Rahul Ravikumar [@tikurahul](https://twitter.com/tikurahul), Bryan Hughes[@nebrius](https://twitter.com/nebrius) + +- Typing Bot (nodebots, jsconf) + [video](http://www.youtube.com/watch?v=kjTO2OkGnD8) + + +## Raquel Vélez [@rockbot](https://twitter.com/rockbot) + +- Manny the Manipulator: A 2-dimensional serial manipulator using forward/inverse kinematics (via [vektor](https://github.com/rockbot/vektor)) + [video](http://www.youtube.com/watch?v=JKumEFyOvuI) + [code](https://github.com/rockbot/vektor/tree/master/manipulator) + + +## Travis Thieman [@thieman](https://twitter.com/thieman) + +- Power Glove (OS X Volume Control): + [video](http://www.youtube.com/watch?v=j1BimT0hPSQ) + [code](https://github.com/tthieman/arduino-projects/blob/master/hackathon_20130217/power_glove.js) + + +## Francis Gulotta [@reconbot](https://twitter.com/reconbot) + +- Dorby the DoorBot + [video howto](http://www.youtube.com/watch?v=6VnSIbRAlFw) + [video servo operation](http://www.youtube.com/watch?v=gh7LtDA6EL0) + [code](https://github.com/reconbot/dorby) + + +## Tim Walker [@timwalker2k](https://twitter.com/timwalker2k) + +- An experimental Theremin using a proximity sensor and JavaScript. + [code](https://github.com/twalker/sine5) + +- A build status light for use within a continuous integration workflow + [code](https://github.com/twalker/cilite) + + +## Kelly Korevec [@korevec](http://twitter.com/korevec) + +- Medibot + [Picture](https://twitter.com/korevec/status/267848987711766528/photo/1) + [code](https://github.com/korevec/medibot) + +## Irene Ros [@ireneros](http://twitter.com/ireneros) + +- Wii Nunchuk Controller for AR Drone (nodecopter event) + [video](http://twitter.yfrog.com/n4u1nrxrakmkyopxxpjmxzmzz) + [code](https://github.com/iros/nodecoptering) + + +## Chris Williams [@voodootikigod](http://twitter.com/voodootikigod) + +- Wii Nunchuk Controller for AR Drone (nodecopter event) + [code](https://github.com/voodootikigod/wii-drone/) + + +## Andreas Haugstrup Pedersen [@hgstrp](http://twitter.com/hgstrp) + +- LCD Controller (First successful implementation!!) + [video](http://vimeo.com/46577266) + [code](https://gist.github.com/3200331) + (Became the basis for the LCD constructor!) + + +## Rebecca Murphey [@rmurphey](http://twitter.com/rmurphey) + +- Johnny-Five Projects + [On Github](https://github.com/rmurphey/johnny-five-projects) + +- Shift Register Implementation w/ Led Counter Display + [video](http://vimeo.com/46463390) + [code](http://gist.github.com/3185390) + +## Jonathan Blanchet [@jblanchefr](http://twitter.com/jblanchefr) + +- Arduino + Websockets + particles: + [video](http://www.youtube.com/watch?v=MXEGLGmpCfo) + [code](https://gist.github.com/3145395) + +- Arduino + Websockets + css change: + [video](http://www.youtube.com/watch?v=aYFOOr1amSg&feature=plcp) + [code](https://gist.github.com/3145461) + +- Arduino + potentiometer + particles: + [video](http://www.youtube.com/watch?v=d5r5r7pHUZI) + [code](https://gist.github.com/3147263) + + +## Cole Gillespie [@theCole](https://twitter.com/theCole) + +- Joystick Controlled Google Maps Streetview: + [video](https://air.mozilla.org/hack-jam-dundee/) + + +## Kelly Korevec [@korevec](https://twitter.com/korevec) + +- 6WD Rover + [image](http://twitpic.com/a9t3rg) + +## Sara Chipps [@sarajchipps](https://twitter.com/sarajchipps) + +- LEDs that change color based on Twitter sentiment + [video](http://www.youtube.com/watch?v=ws7svZuq29c) + [code](https://github.com/SaraJo/twitter-ring) + +## Yusuf Çakmak [@yukocan](https://twitter.com/yukocan) + Control Led's Color with Leap Motion + Arduino + [Code](https://github.com/yusufcakmak/leapmotion-arduino/blob/master/examples/ledcontrolhands.js) + [Vine](https://vine.co/v/MmhnAKO7aLx) diff --git a/JavaScript/node_modules/johnny-five/eg/.jshintrc b/JavaScript/node_modules/johnny-five/eg/.jshintrc new file mode 100644 index 0000000..d519a3c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/.jshintrc @@ -0,0 +1,25 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": false, + "newcap": false, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "node": true, + "strict": false, + "esnext": true, + "quotmark": "double", + "globals": { + "exports": true, + "document": true, + "$": true, + "Radar": true, + "WeakMap": true, + "window": true, + "copy": true + } +} diff --git a/JavaScript/node_modules/johnny-five/eg/=proximity-SRF10.js b/JavaScript/node_modules/johnny-five/eg/=proximity-SRF10.js new file mode 100644 index 0000000..724bc79 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/=proximity-SRF10.js @@ -0,0 +1,14 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var proximity = new five.Proximity({ + controller: "SRF10" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm"); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl335.js b/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl335.js new file mode 100644 index 0000000..68aa510 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl335.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var accelerometer = new five.Accelerometer({ + controller: "ADXL335", + pins: ["A0", "A1", "A2"] + }); + + accelerometer.on("change", function() { + console.log("accelerometer"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" z : ", this.z); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" acceleration : ", this.acceleration); + console.log(" inclination : ", this.inclination); + console.log(" orientation : ", this.orientation); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl345.js b/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl345.js new file mode 100644 index 0000000..0077625 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer-adxl345.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var accelerometer = new five.Accelerometer({ + controller: "ADXL345" + }); + + accelerometer.on("change", function() { + console.log("accelerometer"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" z : ", this.z); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" acceleration : ", this.acceleration); + console.log(" inclination : ", this.inclination); + console.log(" orientation : ", this.orientation); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer-mma7361.js b/JavaScript/node_modules/johnny-five/eg/accelerometer-mma7361.js new file mode 100644 index 0000000..de9bc93 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer-mma7361.js @@ -0,0 +1,36 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + // --- Sleep Pin + // The sleepPin is used to enable/disable the device and put it into sleep mode + // You can also tie the sleep pin to high with a 10k resistor and omit + // this option + + // --- Calibration of zero-G readings (zeroV) + // This device also benefits from a calibration step. You can autoCalibrate + // by placing the device level on startup. You can also read the calibrated + // centers by reading the accelerometer.zeroV array after calibration. Subsequent + // initializations, you can omit the autoCalibrate and set the zeroV array + // in the options instead + + var accelerometer = new five.Accelerometer({ + controller: "MMA7361", + pins: ["A0", "A1", "A2"], + sleepPin: 13, + autoCalibrate: true + }); + + accelerometer.on("change", function() { + console.log("accelerometer"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" z : ", this.z); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" acceleration : ", this.acceleration); + console.log(" inclination : ", this.inclination); + console.log(" orientation : ", this.orientation); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer-mpu6050.js b/JavaScript/node_modules/johnny-five/eg/accelerometer-mpu6050.js new file mode 100644 index 0000000..48fd3dc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer-mpu6050.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var accelerometer = new five.Accelerometer({ + controller: "MPU6050" + }); + + accelerometer.on("change", function() { + console.log("accelerometer"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" z : ", this.z); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" acceleration : ", this.acceleration); + console.log(" inclination : ", this.inclination); + console.log(" orientation : ", this.orientation); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer-pan-tilt.js b/JavaScript/node_modules/johnny-five/eg/accelerometer-pan-tilt.js new file mode 100644 index 0000000..40f0662 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer-pan-tilt.js @@ -0,0 +1,41 @@ +var five = require("../lib/johnny-five.js"), + board; + +board = new five.Board(); + +board.on("ready", function() { + + var range, pan, tilt, accel; + + range = [0, 170]; + + // Servo to control panning + pan = new five.Servo({ + pin: 9, + range: range + }); + + // Servo to control tilt + tilt = new five.Servo({ + pin: 10, + range: range + }); + + // Accelerometer to control pan/tilt + accel = new five.Accelerometer({ + pins: ["A3", "A4", "A5"], + freq: 250 + }); + + // Center all servos + (five.Servos()).center(); + + accel.on("acceleration", function(err, timestamp) { + // console.log( "acceleration", this.axis ); + + tilt.to(Math.abs(Math.ceil(170 * this.pitch.toFixed(2)) - 180)); + pan.to(Math.ceil(170 * this.roll.toFixed(2))); + + // TODO: Math.abs(v - 180) as inversion function ? + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/accelerometer.js b/JavaScript/node_modules/johnny-five/eg/accelerometer.js new file mode 100644 index 0000000..f1cc3c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/accelerometer.js @@ -0,0 +1,88 @@ +var five = require("../lib/johnny-five.js"), + board, accel; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new analog `Accelerometer` hardware instance. + // + // five.Accelerometer([ x, y[, z] ]); + // + // five.Accelerometer({ + // pins: [ x, y[, z] ] + // freq: ms + // }); + // + + accel = new five.Accelerometer({ + pins: ["A3", "A4", "A5"], + + // Adjust the following for your device. + // These are the default values (LIS344AL) + // + sensitivity: 96, // mV/degree/seconds + zeroV: 478 // volts in ADC + }); + + // Accelerometer Event API + + + // "data" + // + // Fires when X, Y or Z has changed. + // + // The first argument is an object containing raw x, y, z + // values as read from the analog input. + // + accel.on("data", function(data) { + + console.log("raw: ", data); + }); + + // "acceleration" + // + // Fires once every N ms, equal to value of freg + // Defaults to 500ms + // + accel.on("acceleration", function(data) { + + console.log("acceleration", data); + }); + + // "orientation" + // + // Fires when orientation changes + // + accel.on("orientation", function(data) { + + console.log("orientation", data); + }); + + // "inclination" + // + // Fires when inclination changes + // + accel.on("inclination", function(data) { + + console.log("inclination", data); + }); + + // "change" + // + // Fires when X, Y or Z has changed + // + accel.on("change", function(data) { + + console.log("change", data); + }); +}); + +// @markdown +// +// - [Triple Axis Accelerometer, MMA7361](https://www.sparkfun.com/products/9652) +// - [Triple-Axis Accelerometer, ADXL326](http://www.adafruit.com/products/1018) +// +// - [Two or Three Axis Accelerometer, LIS344AL](http://www.st.ewi.tudelft.nl/~gemund/Courses/In4073/Resources/LIS344AL.pdf) +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/barometer-BMP180.js b/JavaScript/node_modules/johnny-five/eg/barometer-BMP180.js new file mode 100644 index 0000000..b805623 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/barometer-BMP180.js @@ -0,0 +1,14 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var barometer = new five.Barometer({ + controller: "BMP180" + }); + + barometer.on("change", function() { + console.log("barometer"); + console.log(" pressure : ", this.pressure); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/barometer-mpl115a2.js b/JavaScript/node_modules/johnny-five/eg/barometer-mpl115a2.js new file mode 100644 index 0000000..cbf7120 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/barometer-mpl115a2.js @@ -0,0 +1,14 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var barometer = new five.Barometer({ + controller: "MPL115A2" + }); + + barometer.on("data", function() { + console.log("barometer"); + console.log(" pressure : ", this.pressure); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/barometer-mpl3115a2.js b/JavaScript/node_modules/johnny-five/eg/barometer-mpl3115a2.js new file mode 100644 index 0000000..b70b63e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/barometer-mpl3115a2.js @@ -0,0 +1,18 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var barometer = new five.Barometer({ + controller: "MPL3115A2" + }); + + barometer.on("data", function() { + console.log("barometer"); + console.log(" pressure : ", this.pressure); + console.log("--------------------------------------"); + }); +}); + +// @markdown +// - [MPL115A2 - I2C Barometric Pressure/Temperature Sensor](https://www.adafruit.com/product/992) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/board-multi.js b/JavaScript/node_modules/johnny-five/eg/board-multi.js new file mode 100644 index 0000000..9777ab6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/board-multi.js @@ -0,0 +1,48 @@ +var five = require("../lib/johnny-five.js"); +var boards = new five.Boards(["A", "B"]); + +// Create 2 board instances with IDs "A" & "B" +boards.on("ready", function() { + + // Both "A" and "B" are initialized + // (connected and available for communication) + + // |this| is an array-like object containing references + // to each initialized board. + this.each(function(board) { + + // Initialize an Led instance on pin 13 of + // each initialized board and strobe it. + var led = new five.Led({ + pin: 13, + board: board + }); + + led.blink(); + }); +}); + +/** + * When initializing multiple boards with only an ID string, + * the order of initialization and connection is the order + * that your OS enumerates ports. + * + * Given the above program, "A" and "B" would be assigned as: + * + * A => /dev/cu.usbmodem411 + * B => /dev/cu.usbmodem621 + * + * + * You may override this by providing explicit port paths: + * + * var ports = [ + * { id: "A", port: "/dev/cu.usbmodem621" }, + * { id: "B", port: "/dev/cu.usbmodem411" } + * ]; + * + * new five.Boards(ports).on("ready", function() { + * + * // Boards are initialized! + * + * }); + */ diff --git a/JavaScript/node_modules/johnny-five/eg/board-with-port.js b/JavaScript/node_modules/johnny-five/eg/board-with-port.js new file mode 100644 index 0000000..795d44e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/board-with-port.js @@ -0,0 +1,19 @@ +var five = require("../lib/johnny-five.js"); + +// Johnny-Five will try its hardest to detect the port for you, +// however you may also explicitly specify the port by passing +// it as an optional property to the Board constructor: +var board = new five.Board({ + port: "/dev/cu.usbmodem1411" +}); + +// The board's pins will not be accessible until +// the board has reported that it is ready +board.on("ready", function() { + this.pinMode(13, this.MODES.OUTPUT); + + this.loop(500, function() { + // Whatever the last value was, write the opposite + this.digitalWrite(13, this.pins[13].value ? 0 : 1); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/board.js b/JavaScript/node_modules/johnny-five/eg/board.js new file mode 100644 index 0000000..dcdcd61 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/board.js @@ -0,0 +1,11 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +// The board's pins will not be accessible until +// the board has reported that it is ready +board.on("ready", function() { + console.log("Ready!"); + + var led = new five.Led(13); + led.blink(500); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/boe-test-servos.js b/JavaScript/node_modules/johnny-five/eg/boe-test-servos.js new file mode 100644 index 0000000..cca7094 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/boe-test-servos.js @@ -0,0 +1,251 @@ +var five = require("../lib/johnny-five.js"), + board, Navigator, bot, left, right, sonar, scanner, servos, + expandWhich, reverseDirMap, scale; + +reverseDirMap = { + right: "left", + left: "right" +}; + +scale = function(speed, low, high) { + return Math.floor(five.Fn.map(speed, 0, 5, low, high)); +}; + + +/** + * Navigator + * @param {Object} opts Optional properties object + */ + +function Navigator(opts) { + + // Boe Navigator continuous are calibrated to stop at 90° + this.center = opts.center || 90; + + this.servos = { + right: new five.Servo({ + pin: opts.right, + type: "continuous" + }), + left: new five.Servo({ + pin: opts.left, + type: "continuous" + }) + }; + + this.direction = opts.direction || { + right: this.center, + left: this.center + }; + + this.speed = opts.speed == null ? 0 : opts.speed; + + this.history = []; + this.which = "forward"; + this.isTurning = false; + + setTimeout(function() { + this.fwd(1).fwd(0); + }.bind(this), 10); +} + +/** + * move + * @param {Number} right Speed/Direction of right servo + * @param {Number} left Speed/Direction of left servo + * @return {Object} this + */ +Navigator.prototype.move = function(right, left) { + + // Quietly ignore duplicate instructions + if (this.direction.right === right && + this.direction.left === left) { + return this; + } + + // Servos are mounted opposite of each other, + // the values for left and right will be in + // opposing directions. + this.servos.right.to(right); + this.servos.left.to(left); + + // Store a recallable history of movement + this.history.push({ + timestamp: Date.now(), + right: right, + left: left + }); + + // Update the stored direction state + this.direction.right = right; + this.direction.left = left; + + return this; +}; + + +// TODO: DRY OUT!!!!!!! + + +/** + * forward Move the bot forward + * fwd Move the bot forward + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ +Navigator.prototype.forward = Navigator.prototype.fwd = function(speed) { + speed = speed == null ? 1 : speed; + + var scaled = scale(speed, this.center, 110); + + this.speed = speed; + this.which = "forward"; + + return this.to(this.center - (scaled - this.center), scaled); +}; + +/** + * reverse Move the bot in reverse + * rev Move the bot in reverse + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ +Navigator.prototype.reverse = Navigator.prototype.rev = function(speed) { + speed = speed == null ? 1 : speed; + + var scaled = scale(speed, this.center, 110); + + this.speed = speed; + this.which = "reverse"; + + console.log(scaled, this.center - (scaled - this.center)); + + return this.to(scaled, this.center - (scaled - this.center)); +}; + +/** + * stop Stops the bot, regardless of current direction + * @return {Object} this + */ +Navigator.prototype.stop = function() { + this.speed = this.center; + this.which = "stop"; + + return this.to(this.center, this.center); +}; + +/** + * right Turn the bot right + * @return {Object} this + */ + +/** + * left Turn the bot lefts + * @return {Object} this + */ + + +["right", "left"].forEach(function(dir) { + Navigator.prototype[dir] = function() { + var actual = this.direction[reverseDirMap[dir]]; + + if (!this.isTurning) { + this.isTurning = true; + this.to(actual, actual); + + // Restore direction after turn + setTimeout(function() { + + this[this.which](this.speed); + this.isTurning = false; + + }.bind(this), 750); + } + + return this; + }; +}); + +expandWhich = function(which) { + var parts, translations; + + translations = [{ + f: "forward", + r: "reverse", + fwd: "forward", + rev: "reverse" + }, { + r: "right", + l: "left" + }]; + + if (which.length === 2) { + parts = [which[0], which[1]]; + } + + if (!parts.length && /\-/.test(which)) { + parts = which.split("-"); + } + + return parts.map(function(val, i) { + return translations[i][val]; + }).join("-"); +}; + +Navigator.prototype.pivot = function(which, time) { + var actual, directions, scaled; + + scaled = scale(this.speed, this.center, 110); + which = expandWhich(which); + + directions = { + "forward-right": function() { + this.to(this.center, scaled); + }, + "forward-left": function() { + this.to(this.center - (scaled - this.center), this.center); + }, + "reverse-right": function() { + this.to(scaled, this.center); + }, + "reverse-left": function() { + this.to(this.center, this.center - (scaled - this.center)); + } + }; + + directions[which].call(this, this.speed); + + setTimeout(function() { + + this[this.which](this.speed); + + }.bind(this), time || 1000); + + return this; +}; + + +board = new five.Board(); +board.on("ready", function() { + + sonar = new five.Sonar({ + pin: "A2", + freq: 100 + }); + sonar.on("change", function() { + console.log("Object is " + this.inches + "inches away"); + }); + + scanner = new five.Servo(12); + scanner.sweep(); + + this.repl.inject({ + // create a bot, right servo = pin 10, left servo = pin 11 + b: new Navigator({ + right: 10, + left: 11 + }) + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/brat.js b/JavaScript/node_modules/johnny-five/eg/brat.js new file mode 100644 index 0000000..3315194 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/brat.js @@ -0,0 +1,602 @@ +var five = require("../lib/johnny-five.js"), + compulsive = require("compulsive"); + +var ED, + priv = new WeakMap(); + + +/** + * ED + * + * Enforcement Droid Series + * (Lynxmotion Biped BRAT) + * + * http://www.lynxmotion.com/images/jpg/bratjr00.jpg + * http://www.lynxmotion.com/images/html/build112.htm + * Hardware: + - 1 x Alum. Channel - 3" Single Pack (ASB-503) + - 2 x Multi-Purpose Servo Bracket Two Pack (ASB-04) + - 1 x "L" Connector Bracket Two Pack (ASB-06) + - 1 x "C" Servo Bracket w/ Ball Bearings Two Pack (ASB-09) + - 1 x Robot Feet Pair (ARF-01) + - 1 x SES Electronics Carrier (EC-02) + - 1 x SSC-32 Servo Controller (SSC-32) + - 4 x HS-422 (57oz.in.) Standard Servo (S422) + * + * @param {Object} opts Optional properties object + */ + +function ED(opts) { + + opts = opts || {}; + + // Standard servos center at 90° + this.center = opts.center || 90; + + // Initiale movement is forward + this.direction = "fwd"; + + // Accessor for reading the current servo position will + // be defined and assigned to this.degrees object. + this.degrees = {}; + + // holds a reference to the current repeating/looping sequence + this.sequence = null; + + // Table of times (avg) to complete tasks + this.times = { + step: 0, + attn: 0 + }; + + // Minor normalization of incoming properties + opts.right = opts.right || {}; + opts.left = opts.left || {}; + + // Initialize the right and left cooperative servos + // TODO: Support pre-initialized servo instances + this.servos = { + right: { + hip: opts.right.hip && new five.Servo(opts.right.hip), + foot: opts.right.foot && new five.Servo(opts.right.foot) + }, + left: { + hip: opts.left.hip && new five.Servo(opts.left.hip), + foot: opts.left.foot && new five.Servo(opts.left.foot) + } + }; + + // Create shortcut properties + this.right = this.servos.right; + this.left = this.servos.left; + + // Create accessor descriptors: + // + // .left { .foot, .hip } + // .right { .foot, .hip } + // + ["right", "left"].forEach(function(key) { + + var descriptor = {}; + + ["foot", "hip"].forEach(function(part) { + descriptor[part] = { + get: function() { + var history = this.servos[key][part].history, + last = history[history.length - 1]; + + return last && last.degrees || 90; + }.bind(this) + }; + }, this); + + this.degrees[key] = {}; + + // And finally, create properties with the generated descriptor + Object.defineProperties(this.degrees[key], descriptor); + }, this); + + + Object.defineProperty(this, "isCentered", { + get: function() { + var right, left; + + right = this.degrees.right; + left = this.degrees.left; + + if ((right.foot === 90 && right.hip === 90) && + (left.foot === 90 && left.foot === 90)) { + return true; + } + return false; + } + }); + + // Store a recallable history of movement + // TODO: Include in savable history + this.history = [{ + timestamp: Date.now(), + side: "right", + right: { + hip: 0, + foot: 0 + }, + left: { + hip: 0, + foot: 0 + } + }]; + + // Create an entry in the private data store. + priv.set(this, { + // `isWalking` is used in: + // ED.prototype.(attn|stop) + // ED.prototype.(forward|fwd;reverse|rev) + isWalking: false, + + // Allowed to hit the dance floor. + canDance: true + }); +} + +/** + * attn Stop and stand still + * @return {Object} this + */ +//ED.prototype.attn = ED.prototype.stop = function() { +ED.prototype.attn = function(options) { + options = options || {}; + + if (!options.isWalking) { + + if (this.sequence) { + this.sequence.stop(); + this.sequence = null; + } + + priv.set(this, { + isWalking: false + }); + } + + this.move({ + type: "attn", + right: { + hip: 90, + foot: 90 + }, + left: { + hip: 90, + foot: 90 + } + }); +}; + +/** + * step Take a step + * + * @param {String} instruct Give the step function a specific instruction, + * one of: (fwd, rev, left, right) + * + */ +ED.prototype.step = function(direct) { + var isLeft, isFwd, opposing, direction, state; + + state = priv.get(this); + + if (/fwd|rev/.test(direct)) { + direction = direct; + direct = undefined; + } else { + direction = "fwd"; + } + + // Derive which side to step on; based on last step or explicit step + this.side = direct || (this.side !== "right" ? "right" : "left"); + + // Update the value of the current direction + this.direction = direction; + + // Determine if the bot is moving fwd + // Used in phase 3 to conditionally control the servo degrees + isFwd = this.direction === "fwd"; + + // Determine if this is the left foot + // Used in phase 3 to conditionally control the servo degrees + isLeft = this.side === "left"; + + // Opposing leg side, used in prestep and phase 2; + // opposing = isLeft ? "right" : "left"; + + // Begin stepping movements. + // + this.queue([ + + // Phase 1 + { + wait: 500, + task: function() { + var stepping, opposing, instruct; + + stepping = isLeft ? "left" : "right"; + opposing = isLeft ? "right" : "left"; + + instruct = {}; + + // Lift the currently stepping foot, while + // leaning on the currently opposing foot. + instruct[stepping] = { + foot: isLeft ? 40 : 140 + }; + instruct[opposing] = { + foot: isLeft ? 70 : 110 + }; + + // Swing currently stepping hips + this.move(instruct); + }.bind(this) + }, + + // Phase 2 + { + wait: 500, + task: function() { + var degrees = isLeft ? + (isFwd ? 120 : 60) : + (isFwd ? 60 : 120); + + // Swing currently stepping hips + this.move({ + type: "swing", + right: { + hip: degrees + }, + left: { + hip: degrees + } + }); + + }.bind(this) + }, + + // Phase 3 + { + wait: 500, + task: function() { + + // Flatten feet to surface + this.servos.right.foot.center(); + this.servos.left.foot.center(); + + + + }.bind(this) + } + ]); +}; + +[ + /** + * forward, fwd + * + * Move the bot forward + */ + { + name: "forward", + abbr: "fwd" + }, + + /** + * reverse, rev + * + * Move the bot in reverse + */ + { + name: "reverse", + abbr: "rev" + } + +].forEach(function(dir) { + + ED.prototype[dir.name] = ED.prototype[dir.abbr] = function() { + var startAt, stepper, state; + + startAt = 10; + state = priv.get(this); + + // If ED is already walking in this direction, return immediately; + // This prevents multiple movement loops from being scheduled. + if (this.direction === dir.abbr && state.isWalking) { + return; + } + + // If a sequence reference exists, kill it. This will + // clear all pending queue repeaters. + if (this.sequence) { + this.sequence.stop(); + this.sequence = null; + } + + + this.direction = dir.abbr; + + // Update the private state to indicate + // that the bot is currently walking. + // + // This is used by the behaviour loop to + // conditionally continue walking or to terminate. + // + // Walk termination occurs in the ED.prototype.attn method + // + priv.set(this, { + isWalking: true + }); + + stepper = function(loop) { + // Capture of sequence queue reference + if (this.sequence === null) { + this.sequence = loop; + } + + this.step(dir.abbr); + + if (!priv.get(this).isWalking) { + loop.stop(); + } + }.bind(this); + + // If the bot is not centered, ie. all servos at 90degrees, + // bring the bot to attention before proceeding. + if (!this.isCentered) { + this.attn({ + isWalking: true + }); + // Offset the amount ms required for attn() to complete + startAt = 750; + } + + this.queue([{ + wait: startAt, + task: function() { + this.step(dir.abbr); + }.bind(this) + }, { + loop: 1500, + task: stepper + }]); + }; +}); + +ED.prototype.dance = function() { + var isLeft, restore, state; + + // Derive which side to step on; based on last step or explicit step + this.side = this.side !== "right" ? "right" : "left"; + + // Determine if this is the left foot + // Used in phase 3 to conditionally control the servo degrees + isLeft = this.side === "left"; + + this.attn(); + + if (typeof this.moves === "undefined") { + this.moves = 0; + } + + this.queue([ + // Phase 1 + { + wait: 500, + task: function() { + var degrees = isLeft ? 120 : 60; + + if (this.moves % 2 === 0) { + this.move({ + type: "attn", + right: { + hip: 90, + foot: 60 + }, + left: { + hip: 90, + foot: 120 + } + }); + } else { + + this.move({ + type: "attn", + right: { + hip: 90, + foot: 120 + }, + left: { + hip: 90, + foot: 60 + } + }); + } + + // Swing currently stepping hips + this.move({ + type: "swing", + right: { + hip: degrees + }, + left: { + hip: degrees + } + }); + + // restore = this.servos[ this.side ].foot.last.degrees; + // this.servos[ this.side ].foot.move( restore === 140 ? 120 : 60 ); + + }.bind(this) + }, + + // Phase 2 + { + wait: 500, + task: function() { + var degrees = isLeft ? 60 : 120; + + // Swing currently stepping hips + this.move({ + type: "swing", + right: { + hip: degrees + }, + left: { + hip: degrees + } + }); + + // this.servos[ this.side ].foot.move( restore ); + + }.bind(this) + }, + + // Phase 3 + { + wait: 500, + task: function() { + + this.move({ + type: "attn", + right: { + hip: 90, + foot: 90 + }, + left: { + hip: 90, + foot: 90 + } + }); + + this.dance(); + + }.bind(this) + } + ]); + + this.moves++; +}; + + +/** + * move Move the bot in an arbitrary direction + * @param {Object} positions left/right hip/foot positions + * + */ +ED.prototype.move = function(positions) { + var start, type; + + if (this.history.length) { + start = this.history[this.history.length - 1]; + } + + type = positions.type || "step"; + + ["foot", "hip"].forEach(function(section) { + ["right", "left"].forEach(function(side) { + var interval, endAt, startAt, servo, step, s; + + if (typeof positions[side] === "undefined") { + return; + } + + endAt = positions[side][section]; + servo = this.servos[side][section]; + startAt = this.degrees[side][section]; + + // Degrees per step + step = 2; + + s = Date.now(); + + if (!endAt || endAt === startAt) { + return; + } + + if (start) { + // Determine degree step direction + if (endAt < startAt) { + step *= -1; + } + + // Repeat each step for required number of steps to move + // servo into new position. Each step is ~20ms duration + this.repeat(Math.abs(endAt - startAt) / 2, 10, function() { + // console.log( startAt ); + servo.move(startAt += step); + + if (startAt === endAt) { + this.times[type] = (this.times[type] + (Date.now() - s)) / 2; + } + }.bind(this)); + + } else { + // TODO: Stop doing this + servo.move(endAt); + five.Fn.sleep(500); + } + }, this); + }, this); + + // Push a record object into the stepping history + this.history.push({ + timestamp: Date.now(), + side: this.side, + right: five.Fn.extend({ + hip: 0, + foot: 0 + }, this.degrees.right, positions.right), + left: five.Fn.extend({ + hip: 0, + foot: 0 + }, this.degrees.left, positions.left) + }); +}; + +// Borrow API from Compulsive +["wait", "loop", "queue", "repeat"].forEach(function(api) { + ED.prototype[api] = compulsive[api]; +}); + +// Begin program when the board, serial and +// firmata are connected and ready +(new five.Board()).on("ready", function() { + var biped; + + // Create new Enforcement Droid + // assign servos + biped = new ED({ + right: { + hip: 9, + foot: 11 + }, + left: { + hip: 10, + foot: 12 + } + }); + + // Inject into REPL for manual controls + this.repl.inject({ + s: new five.Servo.Array(), + b: biped + }); + + biped.attn(); + + biped.wait(1000, function() { + biped.fwd(); + }); + + // Controlled via REPL: + // b.fwd(), b.rev(), b.attn() +}); + + + +// http://www.lynxmotion.com/images/html/build112.htm diff --git a/JavaScript/node_modules/johnny-five/eg/bug.js b/JavaScript/node_modules/johnny-five/eg/bug.js new file mode 100644 index 0000000..e3b1e87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/bug.js @@ -0,0 +1,198 @@ +var five = require("../lib/johnny-five.js"); + +function Bug(servos) { + var part, k; + + this.isMoving = false; + + // Initialize list of body parts + this.parts = ["front", "left", "right", "rear"]; + + // Servo positions + this.history = []; + + // Interval id table + this.intervals = { + fwd: null, + rev: null + }; + + k = -1; + // Initialize Servo properties from "servos" argument + while (++k < this.parts.length) { + part = this.parts[k]; + + this[part] = servos[part] || null; + } + + // Unwind and wait ~10ms, center servos + setTimeout(function() { + this.idle(); + }.bind(this), 10); +} + +Bug.STEP_MAP = { + // steps + fwd: [ + [10, -30], + [-15, 30] + ], + rev: [ + [-15, 30], + [15, -30] + ] +}; + +/** + * idle Set the bug legs to center position and + * @return {Bug} + */ +Bug.prototype.idle = function() { + + // If the bug is actually in motion, + // stop the servo intervals + if (this.isMoving) { + this.stop(); + } + + // set to center position° + this.front.to(90); + this.rear.to(90); + + //return this; +}; + +/** + * step Take a full or half step + * + * @param {Dict} opts Properties: + * half {Boolean} + * dir {String} + * @return {Bug} + */ +Bug.prototype.step = function(opts) { + var dir, move, last, front, rear, step; + + opts = opts || {}; + + // Get last move from history if any history exists + // Provide a "fake" history if needed (first call) + last = this.history.length ? + this.history[this.history.length - 1] : { + step: 1 + }; + + // increment the last step + step = last.step + 1; + + // If step is too high, step back to 0 + if (step > 1) { + step = 0; + } + + // Derive direction if provided, + // defaults to fwd + dir = opts.dir || "fwd"; + + // Derive position° for next move + move = Bug.STEP_MAP[dir][step]; + + // Assign position° from center + front = 90 + move[0]; + rear = 90 + move[1]; + + // Write position° to servos + this.front.to(front); + this.rear.to(rear); + + // Allow half step or full if provided, + // defaults to full + // enum(false|null|undefined) + if (!opts.half) { + // Wait one second and move servos back to + // center idling position, 90° + setTimeout(function() { + this.idle(); + }.bind(this), 1000); + } + + // Push a step into history array; + // will be used as a reference for the subsequent step + this.history.push( + // NOTE: this is a great use case example for + // ES.next concise object initializers + { + dir: dir, + step: step, + front: front, + rear: rear + } + ); +}; + +/** + * stop Stop the bug by clearing the intervals + * @return {Bug} + */ +Bug.prototype.stop = function() { + Object.keys(this.intervals).forEach(function(key) { + if (this.intervals[key]) { + clearInterval(this.intervals[key]); + } + }, this); + //return this; +}; + +[ + /** + * fwd Move the bug forward continuously + * @return {Bug} + */ + "fwd", + + /** + * rev Move the bug backwards continuously + * @return {Bug} + */ + "rev" + +].forEach(function(dir, k) { + + Bug.prototype[dir] = function() { + + this.isMoving = true; + + this.intervals[dir] = setInterval(function() { + this.step({ + dir: dir, + half: true + }); + }.bind(this), 750); + + // //return this; + }; +}); + + + + +five.Board().on("ready", function() { + var bug, ranges, servos; + + bug = new Bug({ + front: new five.Servo(9), + rear: new five.Servo(10) + //, + //left: new five.Servo({ pin: 5, range: [ 70, 115 ] }), + //right: new five.Servo({ pin: 6, range: [ 70, 115 ] }) + }); + + // Inject the Servo Array into the REPL as "s" + this.repl.inject({ + bug: bug, + s: new five.Servos() + }); + + + // bug.step(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/button-bumper.js b/JavaScript/node_modules/johnny-five/eg/button-bumper.js new file mode 100644 index 0000000..6fc74a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/button-bumper.js @@ -0,0 +1,18 @@ +var five = require("../lib/johnny-five.js"), + bumper, led; + +five.Board().on("ready", function() { + + bumper = new five.Button(7); + led = new five.Led(13); + + bumper.on("hit", function() { + + led.on(); + + }).on("release", function() { + + led.off(); + + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/button-hold-blink.js b/JavaScript/node_modules/johnny-five/eg/button-hold-blink.js new file mode 100644 index 0000000..5570d96 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/button-hold-blink.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + // Johnny-Five provides pre-packages shield configurations! + // http://johnny-five.io/api/motor/#pre-packaged-shield-configs + var motors = new five.Motors([ + five.Motor.SHIELD_CONFIGS.POLOLU_DRV8835_SHIELD.M1, + five.Motor.SHIELD_CONFIGS.POLOLU_DRV8835_SHIELD.M2, + ]); + + this.repl.inject({ + motors: motors + }); + + motors.speed(50); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/button-options.js b/JavaScript/node_modules/johnny-five/eg/button-options.js new file mode 100644 index 0000000..45ccc10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/button-options.js @@ -0,0 +1,41 @@ +var five = require("../lib/johnny-five.js"), + board, button; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `button` hardware instance + button = new five.Button({ + board: board, + pin: 7, + holdtime: 1000, + invert: false // Default: "false". Set to "true" if button is Active-Low + }); + + // Inject the `button` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + button: button + }); + + // Button Event API + + // "down" the button is pressed + button.on("down", function() { + console.log("down"); + }); + + // "hold" the button is pressed for specified time. + // defaults to 500ms (1/2 second) + // set + button.on("hold", function() { + console.log("hold"); + }); + + // "up" the button is released + button.on("up", function() { + console.log("up"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/button-pullup.js b/JavaScript/node_modules/johnny-five/eg/button-pullup.js new file mode 100644 index 0000000..c4fe536 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/button-pullup.js @@ -0,0 +1,33 @@ +// The `isPullup` button option enables the pullup +// resistor on the pin and automatically sets the +// `invert` option to true + +// In this circuit configuration, the LED would always +// be on without the pullup resistor enabled + +// For more info on pullup resistors, see: +// http://arduino.cc/en/Tutorial/InputPullupSerial +// http://arduino.cc/en/Tutorial/DigitalPins +// https://learn.sparkfun.com/tutorials/pull-up-resistors + +var five = require("../lib/johnny-five"), + button, led; + +five.Board().on("ready", function() { + + button = new five.Button({ + pin: 2, + isPullup: true + }); + + led = new five.Led(13); + + button.on("down", function(value) { + led.on(); + }); + + button.on("up", function() { + led.off(); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/button.js b/JavaScript/node_modules/johnny-five/eg/button.js new file mode 100644 index 0000000..83d3cb1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/button.js @@ -0,0 +1,38 @@ +var five = require("../lib/johnny-five.js"), + board, button; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `button` hardware instance. + // This example allows the button module to + // create a completely default instance + button = new five.Button(2); + + // Inject the `button` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + button: button + }); + + // Button Event API + + // "down" the button is pressed + button.on("down", function() { + console.log("down"); + }); + + // "hold" the button is pressed for specified time. + // defaults to 500ms (1/2 second) + // set + button.on("hold", function() { + console.log("hold"); + }); + + // "up" the button is released + button.on("up", function() { + console.log("up"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/change.js b/JavaScript/node_modules/johnny-five/eg/change.js new file mode 100644 index 0000000..7378b9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/change.js @@ -0,0 +1,47 @@ +"use strict"; +/** + * Change + * + * Produces change "tracking" instances + * to determine if a given value has changed + * drastically enough + */ + +function Change(margin) { + if (!(this instanceof Change)) { + return new Change(margin); + } + this.last = 0; + this.margin = margin || 0; +} + +/** + * isNoticeable + * + * Determine if a given value has changed + * enough to be considered "noticeable". + * + * @param {Number} value [description] + * @param {Number} margin Optionally override the + * change instance's margin + * + * @return {Boolean} returns true if value is different + * enough from the last value + * to be considered "noticeable" + */ +Change.prototype.isNoticeable = function(value, margin) { + margin = margin || this.margin; + + if (!Number.isFinite(value)) { + return false; + } + + if ((value > this.last + margin) || (value < this.last - margin)) { + this.last = value; + return true; + } + return false; +}; + + +module.exports = Change; diff --git a/JavaScript/node_modules/johnny-five/eg/classic-controller.js b/JavaScript/node_modules/johnny-five/eg/classic-controller.js new file mode 100644 index 0000000..0db61ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/classic-controller.js @@ -0,0 +1,98 @@ +var five = require("../lib/johnny-five.js"), + board, nunchuk; + +board = new five.Board(); + + +// Setup for bread board +// Wire Color => Meaning => Arduino Pin Down +// Yellow => SCK => A04 +// White => GND => Ground +// Red => 5v => 5v +// Green => SDA => A05 + + +board.on("ready", function() { + + // Create a new `Wii.Classic` hardware instance, + // specifically the RVL-005 device (classic controller). + var classicController = five.Wii.Classic({ + freq: 100 + }); + + + // Nunchuk Event API + // + + // "read" (nunchuk) + // + // Fired when the joystick detects a change in + // axis position. + // + // nunchuk.on( "read", function( err ) { + + // }); + + // "change", "axischange" (joystick) + // + // Fired when the joystick detects a change in + // axis position. + // + nunchuk.joystick.left.on("change", function(err, event) { + console.log( + "Left joystick " + event.axis, + event.target[event.axis], + event.axis, event.direction + ); + }); + + nunchuk.joystick.right.on("change", function(err, event) { + console.log( + "Right joystick " + event.axis, + event.target[event.axis], + event.axis, event.direction + ); + }); + + // "down" + // aliases: "press", "tap", "impact", "hit" + // + // Fired when any nunchuk button is "down" + // + + // "up" + // alias: "release" + // + // Fired when any nunchuk button is "up" + // + + // "hold" + // + // Fired when any nunchuk button is in the "down" state for + // a specified amount of time. Defaults to 500ms + // + // To specify a custom hold time, use the "holdtime" + // option of the Nunchuk constructor. + // + + + ["down", "up", "hold"].forEach(function(type) { + + nunchuk.on(type, function(err, event) { + console.log( + event.target.which + " is " + type, + + { + isUp: event.target.isUp, + isDown: event.target.isDown + } + ); + }); + + }); + + + // Further reading + // http://media.pragprog.com/titles/msard/tinker.pdf + // http://lizarum.com/assignments/physical_computing/2008/wii_nunchuck.html +}); diff --git a/JavaScript/node_modules/johnny-five/eg/claw.js b/JavaScript/node_modules/johnny-five/eg/claw.js new file mode 100644 index 0000000..0bb87e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/claw.js @@ -0,0 +1,43 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var claw = new five.Servo(9); + var arm = five.Servo(10); + var degrees = 10; + var incrementer = 10; + var last; + + this.loop(25, function() { + + if (degrees >= 180 || degrees === 0) { + incrementer *= -1; + } + + degrees += incrementer; + + if (degrees === 180) { + if (!last || last === 90) { + last = 180; + } else { + last = 90; + } + arm.to(last); + } + + claw.to(degrees); + }); +}); + + +// @markdown +// +// - [Robotic Claw](https://www.sparkfun.com/products/11524) +// - [Robotic Claw Pan/Tilt](https://www.sparkfun.com/products/11674) +// - [Robotic Claw Assembly](https://www.sparkfun.com/tutorials/258) +// +//  +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/color-test.html b/JavaScript/node_modules/johnny-five/eg/color-test.html new file mode 100644 index 0000000..6f53a84 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/color-test.html @@ -0,0 +1,87 @@ + + + + + + + + + + + + Red 5 + Yellow 4 + Lime 3 + Blue 2 + + White 6 + Black 1 + + + + + + + + diff --git a/JavaScript/node_modules/johnny-five/eg/compass-hmc5883l.js b/JavaScript/node_modules/johnny-five/eg/compass-hmc5883l.js new file mode 100644 index 0000000..716ed48 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/compass-hmc5883l.js @@ -0,0 +1,22 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var compass = new five.Compass({ + controller: "HMC5883L" + }); + + compass.on("headingchange", function() { + console.log("headingchange"); + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); + + compass.on("data", function() { + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/compass-hmc6352.js b/JavaScript/node_modules/johnny-five/eg/compass-hmc6352.js new file mode 100644 index 0000000..6f368d4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/compass-hmc6352.js @@ -0,0 +1,22 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var compass = new five.Compass({ + controller: "HMC6352" + }); + + compass.on("headingchange", function() { + console.log("headingchange"); + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); + + compass.on("data", function() { + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/compass.js b/JavaScript/node_modules/johnny-five/eg/compass.js new file mode 100644 index 0000000..5c2d8b7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/compass.js @@ -0,0 +1,27 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var compass = new five.Compass({ + controller: "HMC6352" + }); + + // Or... + // var compass = new five.Compass({ + // controller: "HMC5883L" + // }); + + compass.on("headingchange", function() { + console.log("headingchange"); + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); + + compass.on("data", function() { + console.log(" heading : ", Math.floor(this.heading)); + console.log(" bearing : ", this.bearing.name); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/current-monitor.js b/JavaScript/node_modules/johnny-five/eg/current-monitor.js new file mode 100644 index 0000000..eab81c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/current-monitor.js @@ -0,0 +1,114 @@ +var five = require("../lib/johnny-five.js"); +var scale = five.Fn.scale; +var board = new five.Board(); +// Measured with multimeter @ 4.440V +var VCC = 4440; + +function toMV(value) { + // Scale an ADC reading to milli-volts. + return scale(value, 0, 1023, 0, VCC) | 0; +} + +function render(mA) { + // mA means milli-amps + var mAF = mA.toFixed(2); + + mA = Number(mAF); + + // Limit bar rendering to values that are unique from the + // previous reading. This prevents an overwhelming number + // of duplicate bars from being displayed. + if (render.last !== mA) { + console.log( + mAF + ": " + "▇".repeat(scale(mA, 0.03, 2, 1, 50)) + ); + } + render.last = mA; +} + +board.on("ready", function() { + // Set up a 1kHz frequency sensor, with a name + // that's similar to the type of sensor we're using. + // This is a smart way to keep track of your physical + // devices throughout the program. + var acs = new five.Sensor({ + pin: "A0", + freq: 1 + }); + var time = Date.now(); + var samples = 100; + var accumulator = 0; + var count = 0; + var amps = 0; + var qV = 0; + + acs.on("data", function() { + // ADC stands for Analog-to-Digital Converter + // (https://en.wikipedia.org/wiki/Analog-to-digital_converter) + // which reads the voltage returning to an analog pin from + // a sensor circuit. The value is a 10-bit representation + // (0-1023) of a voltage quantity from 0V-5V. + var adc = 0; + var currentAmps = 0; + + // The "amps factor" or `aF` is calculated by dividing the + // the voltage by the max ADC value to produce the + // incremental value, which is ~0.0049V for each step + // from 0-1023. + // Use real VCC (from milli-volts) + var aF = (VCC / 100) / 1023; + + + // 1. Measure the the ACS712 reading with no load (0A); + // this is known as the quiescent output voltage, + // which is named `qV` in this program. + if (!qV) { + if (!count) { + console.log("Calibrating..."); + } + // Calibration phase takes measurements for ~5 seconds + if (count < (samples * 40)) { + count++; + accumulator += this.value; + } else { + qV = Math.max(512, (accumulator / (samples * 40)) | 0); + accumulator = count = 0; + + console.log("qV: %d (%d) ", toMV(qV), qV); + console.log("Elapsed: ", Date.now() - time); + } + } else { + + if (count < samples) { + // 2. Collect readings to calculate a current value + count++; + adc = this.value - qV; + accumulator += adc * adc; + } else { + // 3. Update the running root mean square value + currentAmps = Math.sqrt(accumulator / samples) * aF; + accumulator = count = 0; + + // ACS is fairly innaccurate below 0.03 + if (currentAmps < 0.03) { + currentAmps = 0; + } + } + + // If there is a currentAmps value: + // If there is an amps value: + // return average of currentAmps and amps + // Else: + // return currentAmps + // Else: + // return amps + amps = currentAmps ? + (amps ? (currentAmps + amps) / 2 : currentAmps) : + amps; + + if (qV && amps) { + render(amps); + } + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/edison-io-arduino.js b/JavaScript/node_modules/johnny-five/eg/edison-io-arduino.js new file mode 100644 index 0000000..d012114 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/edison-io-arduino.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var Edison = require("edison-io"); +var board = new five.Board({ + io: new Edison() +}); + +board.on("ready", function() { + var led = new five.Led(13); + led.blink(); +}); + +// @markdown +// +// In order to use the Edison-IO library, you will need to flash the Intel IoTDevKit Image +// on your Edison. Once the environment is created, install Johnny-Five and Edison-IO. +// +// ```sh +// npm install johnny-five edison-io +// ``` +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/edison-io-miniboard.js b/JavaScript/node_modules/johnny-five/eg/edison-io-miniboard.js new file mode 100644 index 0000000..16b38cc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/edison-io-miniboard.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var Edison = require("edison-io"); +var board = new five.Board({ + io: new Edison() +}); + +board.on("ready", function() { + var led = new five.Led(1); + led.blink(); +}); + +// @markdown +// +// In order to use the Edison-IO library, you will need to flash the Intel IoTDevKit Image +// on your Edison. Once the environment is created, install Johnny-Five and Edison-IO. +// +// ```sh +// npm install johnny-five edison-io +// ``` +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/edison.js b/JavaScript/node_modules/johnny-five/eg/edison.js new file mode 100644 index 0000000..6e90ec7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/edison.js @@ -0,0 +1,15 @@ +var five = require("johnny-five"); +var Edison = require("galileo-io"); +var board = new five.Board({ + io: new Edison() +}); + +board.on("ready", function() { + console.log("ready"); + var led = new five.Led(11); + led.blink(); + + this.repl.inject({ + led: led + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/encoder-digital.js b/JavaScript/node_modules/johnny-five/eg/encoder-digital.js new file mode 100644 index 0000000..4519ca7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/encoder-digital.js @@ -0,0 +1,14 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var encoder = new five.Encoder({ + pins: [ 12, 11 ], + positions: 24, + }); + + + encoder.on("change", function() { + console.log(this.position); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/esc-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/esc-PCA9685.js new file mode 100644 index 0000000..4937a11 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esc-PCA9685.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var esc = new five.ESC({ + controller: "PCA9685", + pin: 1 + }); + + var pot = new five.Sensor("A0"); + + pot.scale(0, 100).on("change", function() { + esc.speed(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/esc-bidirectional-forward-reverse.js b/JavaScript/node_modules/johnny-five/eg/esc-bidirectional-forward-reverse.js new file mode 100644 index 0000000..a265a69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esc-bidirectional-forward-reverse.js @@ -0,0 +1,35 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var start = Date.now(); + var esc = new five.ESC({ + device: "FORWARD_REVERSE", + neutral: 50, + pin: 11 + }); + var throttle = new five.Sensor("A0"); + var brake = new five.Button(4); + + brake.on("press", function() { + esc.brake(); + }); + + throttle.scale(0, 100).on("change", function() { + // 2 Seconds for arming. + if (Date.now() - start < 2e3) { + return; + } + + var isForward = this.value > esc.neutral; + var value = isForward ? + // Scale 50-100 to 0-100 + five.Fn.scale(this.value, esc.neutral, esc.range[1], 0, 100) : + // Scale 0-50 to 100-0 + five.Fn.scale(this.value, esc.range[0], esc.neutral, 100, 0); + + if (esc.value !== value) { + esc[ isForward ? "forward" : "reverse" ](value); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/esc-bidirectional.js b/JavaScript/node_modules/johnny-five/eg/esc-bidirectional.js new file mode 100644 index 0000000..87d5560 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esc-bidirectional.js @@ -0,0 +1,28 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var start = Date.now(); + var esc = new five.ESC({ + device: "FORWARD_REVERSE", + neutral: 50, + pin: 11 + }); + var throttle = new five.Sensor("A0"); + var brake = new five.Button(4); + + brake.on("press", function() { + esc.brake(); + }); + + throttle.scale(0, 100).on("change", function() { + // 2 Seconds for arming. + if (Date.now() - start < 2e3) { + return; + } + + if (esc.value !== this.value) { + esc.speed(this.value); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/esc-dualshock.js b/JavaScript/node_modules/johnny-five/eg/esc-dualshock.js new file mode 100644 index 0000000..8671ffe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esc-dualshock.js @@ -0,0 +1,53 @@ +var five = require("../lib/johnny-five.js"); +var dualShock = require("dualshock-controller"); + +var board = new five.Board(); +var controller = dualShock({ + config: "dualShock3", + analogStickSmoothing: false +}); + +function scale(x, fromLow, fromHigh, toLow, toHigh) { + return (x - fromLow) * (toHigh - toLow) / + (fromHigh - fromLow) + toLow; +} + +board.on("ready", function() { + + var esc = new five.ESC(9); + + controller.on("connected", function() { + controller.isConnected = true; + }); + + controller.on("dpadUp:press", function() { + var speed = esc.last ? esc.speed : 0; + speed += 0.01; + esc.to(speed); + }); + + controller.on("dpadDown:press", function() { + var speed = esc.last ? esc.speed : 0; + speed -= 0.01; + esc.to(speed); + }); + + controller.on("circle:press", function() { + esc.stop(); + }); + + controller.on("right:move", function(position) { + var y = scale(position.y, 255, 0, 0, 180) | 0; + + if (y > 100) { + // from the deadzone and up + esc.to(scale(y, 100, 180, 0, 1)); + } + }); + + controller.connect(); +}); + + +// Brushless motor breadboard diagram originally published here: +// http://robotic-controls.com/learn/projects/dji-esc-and-brushless-motor diff --git a/JavaScript/node_modules/johnny-five/eg/esc-keypress.js b/JavaScript/node_modules/johnny-five/eg/esc-keypress.js new file mode 100644 index 0000000..7ff4b33 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esc-keypress.js @@ -0,0 +1,38 @@ +var five = require("../lib/johnny-five.js"); +var keypress = require("keypress"); +var board = new five.Board(); + +board.on("ready", function() { + + var esc = new five.ESC(9); + + // Hold shift+arrow-up, shift+arrow-down to incrementally + // increase or decrease speed. + + function controller(ch, key) { + var isThrottle = false; + var speed = esc.last ? esc.speed : 0; + + if (key && key.shift) { + if (key.name === "up") { + speed += 0.01; + isThrottle = true; + } + + if (key.name === "down") { + speed -= 0.01; + isThrottle = true; + } + + if (isThrottle) { + esc.speed(speed); + } + } + } + + keypress(process.stdin); + + process.stdin.on("keypress", controller); + process.stdin.setRawMode(true); + process.stdin.resume(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/esplora.js b/JavaScript/node_modules/johnny-five/eg/esplora.js new file mode 100644 index 0000000..c022b8e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/esplora.js @@ -0,0 +1,271 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +// Select: Tools > Board > Arduino Leonardo +// (Ignore the "Arduino Esplora" option) +board.on("ready", function() { + + var estick = new five.Joystick({ + controller: "ESPLORA" + }); + + + estick.on("change", function() { + console.log("x", this.x); + }); +}); + +// -------------------------------------- + +// var Emitter = require("events").EventEmitter; +// var util = require("util"); +// var priv = new Map(); +// var axes = ["x", "y"]; + +// function Multiplexer(options) { +// this.pins = options.pins; +// this.io = options.io; + +// this.io.pinMode(this.pins[0], this.io.MODES.OUTPUT); +// this.io.pinMode(this.pins[1], this.io.MODES.OUTPUT); +// this.io.pinMode(this.pins[2], this.io.MODES.OUTPUT); +// this.io.pinMode(this.pins[3], this.io.MODES.OUTPUT); +// } + +// Multiplexer.prototype.select = function(channel) { +// this.io.digitalWrite(this.pins[0], channel & 1 ? this.io.HIGH : this.io.LOW); +// this.io.digitalWrite(this.pins[1], channel & 2 ? this.io.HIGH : this.io.LOW); +// this.io.digitalWrite(this.pins[2], channel & 4 ? this.io.HIGH : this.io.LOW); +// this.io.digitalWrite(this.pins[3], channel & 8 ? this.io.HIGH : this.io.LOW); +// }; + +// var Controllers = { +// ESPLORA: { +// initialize: { +// value: function(opts, dataHandler) { +// var multiplexer = new Multiplexer({ +// pins: [ 14, 15, 16, 17 ], +// io: this.io +// }); +// var channels = [ 11, 12 ]; +// var channel = 1; +// var dataPoints = { +// x: 0, +// y: 0 +// }; + +// this.io.analogRead(18, function(value) { +// dataPoints[axes[channel]] = value; + +// if (channel === 1) { +// dataHandler(dataPoints) +// } +// }); + +// setInterval(function() { +// multiplexer.select(channel ^= 1); +// }, 20); +// } +// }, +// toAxis: function(raw) { +// var state = priv.get(this); +// return raw - 512; +// } +// } +// } + +// function Joystick(opts) { +// if (!(this instanceof Joystick)) { +// return new Joystick(opts); +// } + +// var controller = null; + +// var state = { +// x: { +// value: 0, +// previous: 0, +// }, +// y: { +// value: 0, +// previous: 0, +// }, +// }; + +// Board.Component.call( +// this, opts = Board.Options(opts) +// ); + +// if (opts.controller && typeof opts.controller === "string") { +// controller = Controllers[opts.controller.toUpperCase()]; +// } else { +// controller = opts.controller; +// } + +// if (controller == null) { +// controller = Controllers["ANALOG"]; +// } + +// Object.defineProperties(this, controller); + +// if (!this.toAxis) { +// this.toAxis = opts.toAxis || function(raw) { return raw; }; +// } + +// priv.set(this, state); + +// if (typeof this.initialize === "function") { +// this.initialize(opts, function(data) { +// var isChange = false; + +// Object.keys(data).forEach(function(axis) { +// var value = data[axis]; +// var sensor = state[axis]; + +// sensor.value = value; + +// if (this.x !== sensor.x) { +// sensor.x = this.x; +// isChange = true; +// } + +// if (this.y !== sensor.y) { +// sensor.y = this.y; +// isChange = true; +// } +// }, this); + +// this.emit("data", { +// x: state.x.value, +// y: state.y.value +// }); + +// if (isChange) { +// this.emit("change", { +// x: this.x, +// y: this.y, +// z: this.z +// }); +// } +// }.bind(this)); +// } + +// Object.defineProperties(this, { +// hasAxis: { +// value: function(axis) { +// return state[axis] ? state[axis].stash.length > 0 : false; +// } +// }, +// x: { +// get: function() { +// return this.toAxis(state.x.value); +// } +// }, +// y: { +// get: function() { +// return this.toAxis(state.y.value); +// } +// } +// }); +// } + +// util.inherits(Joystick, Emitter); + + + + +// const HIGH = 1; +// const LOW = 0; +// const INPUT_PULLUP = 2; + +// const MUX_ADDR_PINS = [ 14, 15, 16, 17 ]; +// const MUX_COM_PIN = 18; + + +// const CH_SWITCH_1 = 0; +// const CH_SWITCH_2 = 1; +// const CH_SWITCH_3 = 2; +// const CH_SWITCH_4 = 3; +// const CH_SLIDER = 4; +// const CH_LIGHT = 5; +// const CH_TEMPERATURE = 6; +// const CH_MIC = 7; +// const CH_TINKERKIT_A = 8; +// const CH_TINKERKIT_B = 9; +// const CH_JOYSTICK_SW = 10; +// const CH_JOYSTICK_X = 11; +// const CH_JOYSTICK_Y = 12; + +// var channels = [ +// CH_SWITCH_1, +// CH_SWITCH_2, +// CH_SWITCH_3, +// CH_SWITCH_4, +// CH_SLIDER, +// CH_LIGHT, +// CH_TEMPERATURE, +// CH_MIC, +// CH_TINKERKIT_A, +// CH_TINKERKIT_B, +// CH_JOYSTICK_SW, +// CH_JOYSTICK_X, +// CH_JOYSTICK_Y, +// ]; + +// var channelNames = [ +// "CH_SWITCH_1", +// "CH_SWITCH_2", +// "CH_SWITCH_3", +// "CH_SWITCH_4", +// "CH_SLIDER", +// "CH_LIGHT", +// "CH_TEMPERATURE", +// "CH_MIC", +// "CH_TINKERKIT_A", +// "CH_TINKERKIT_B", +// "CH_JOYSTICK_SW", +// "CH_JOYSTICK_X", +// "CH_JOYSTICK_Y", +// ]; + + + +// function readChannel(channel) { +// digitalWrite(MUX_ADDR_PINS[0], (channel & 1) ? HIGH : LOW); +// digitalWrite(MUX_ADDR_PINS[1], (channel & 2) ? HIGH : LOW); +// digitalWrite(MUX_ADDR_PINS[2], (channel & 4) ? HIGH : LOW); +// digitalWrite(MUX_ADDR_PINS[3], (channel & 8) ? HIGH : LOW); + +// // workaround to cope with lack of pullup resistor on joystick switch +// if (channel == CH_JOYSTICK_SW) { +// pinMode(MUX_COM_PIN, INPUT_PULLUP); +// var joystickSwitchState = (digitalRead(MUX_COM_PIN) == HIGH) ? 1023 : 0; +// digitalWrite(MUX_COM_PIN, LOW); +// return joystickSwitchState; +// } else { +// return analogRead(MUX_COM_PIN); +// } +// } + +// function pinMode(pin, mode) { +// console.log("pinMode(%d, %d)", pin, mode); +// } + +// function digitalWrite(pin, value) { +// console.log("digitalWrite(%d, %d)", pin, value); +// } + +// function digitalRead(pin) { +// return Math.random() * 1 | 0; +// } + +// function analogRead(pin) { +// console.log("analogRead(%d)", pin); +// } + + +// for (var i = 0; i < channels.length; i++) { +// console.log(channelNames[i]); +// readChannel(i); +// console.log("-----------"); +// } diff --git a/JavaScript/node_modules/johnny-five/eg/expander-MCP23008.js b/JavaScript/node_modules/johnny-five/eg/expander-MCP23008.js new file mode 100644 index 0000000..783e873 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-MCP23008.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("MCP23008") + ); + + var leds = new five.Leds( + Array.from({ length: 8 }, function(_, i) { + return new five.Led({ pin: i, board: virtual }); + }) + ); + + leds.on(); + + this.repl.inject({ + leds: leds + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/expander-MCP23017.js b/JavaScript/node_modules/johnny-five/eg/expander-MCP23017.js new file mode 100644 index 0000000..49437d8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-MCP23017.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("MCP23017") + ); + + var leds = new five.Leds( + Array.from({ length: 8 }, function(_, i) { + return new five.Led({ pin: i * 2, board: virtual }); + }) + ); + + leds.on(); + + this.repl.inject({ + leds: leds + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/expander-PCA9685.js new file mode 100644 index 0000000..1cefbb2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCA9685.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("PCA9685") + ); + + var leds = new five.Leds( + Array.from({ length: 8 }, function(_, i) { + return new five.Led({ pin: i * 2, board: virtual }); + }) + ); + + leds.pulse(); + + this.repl.inject({ + leds: leds + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-input-output.js b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-input-output.js new file mode 100644 index 0000000..8b761d8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-input-output.js @@ -0,0 +1,31 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board({ port: "/dev/cu.usbmodem1411" }); + +board.on("ready", function() { + var expander = new five.Expander("PCF8574"); + + var virtual = new five.Board.Virtual(expander); + + var led = new five.Led({ + board: virtual, + pin: 0, + }); + + // led.on(); + + var button = new five.Button({ + board: virtual, + pin: 7, + }); + + button.on("press", function() { + console.log("button press"); + led.on(); + }); + + button.on("release", function() { + console.log("button release"); + led.off(); + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-sweep.js b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-sweep.js new file mode 100644 index 0000000..099f15a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574-sweep.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board({ port: "/dev/cu.usbmodem1411" }); + +board.on("ready", function() { + var expander = new five.Expander("PCF8574"); + var pin = 1; + + setInterval(function() { + if (pin > 0) { + expander.digitalWrite(pin - 1, 0); + } + expander.digitalWrite(pin++, 1); + + if (pin === 7) { + pin = 0; + } + }, 500); + + +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCF8574.js b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574.js new file mode 100644 index 0000000..c128740 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCF8574.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("PCF8574") + ); + + var leds = new five.Leds( + Array.from({ length: 8 }, function(_, i) { + return new five.Led({ pin: i, board: virtual }); + }) + ); + + leds.on(); + + this.repl.inject({ + leds: leds + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCF8575.js b/JavaScript/node_modules/johnny-five/eg/expander-PCF8575.js new file mode 100644 index 0000000..cf7fd41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCF8575.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("PCF8575") + ); + + var leds = new five.Leds( + Array.from({ length: 8 }, function(_, i) { + return new five.Led({ pin: i * 2, board: virtual }); + }) + ); + + leds.on(); + + this.repl.inject({ + leds: leds + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/expander-PCF8591.js b/JavaScript/node_modules/johnny-five/eg/expander-PCF8591.js new file mode 100644 index 0000000..5c8f79a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-PCF8591.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var virtual = new five.Board.Virtual( + new five.Expander("PCF8591") + ); + + var a = new five.Sensor({ + pin: "A0", + board: virtual + }); + + a.on("change", function() { + console.log(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/expander-bricktronics.js b/JavaScript/node_modules/johnny-five/eg/expander-bricktronics.js new file mode 100644 index 0000000..2788aec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander-bricktronics.js @@ -0,0 +1,139 @@ +// var five = require("../lib/johnny-five.js"); +// var board = new five.Board(); + +// board.on("ready", function() { + +// // Bricktronics +// var en = 79; +// var pwm = 10; +// var dir = 78; + +// var expander = new five.Expander({ +// controller: "MCP23017" +// }); + +// var virtual = new five.Board.Virtual({ +// io: expander +// }); + +// var byte = 0; +// var index = 0; +// var leds = new five.Leds(); + +// for (var i = 0; i < 16; i++) { +// leds.push(new five.Led({ pin: i, board: virtual })); +// } + + + +// // leds.on(); + + +// // function next() { +// // byte |= (byte === 0 ? 1 : byte * 2); + + + +// // return byte; +// // } + + +// // var interval = setInterval(function() { + +// // leds[index++].on(); + +// // if (index === 16) { +// // clearInterval(interval); +// // } +// // }, 500); + +// function display(value) { +// if (value > 0xffff) { +// value -= 0xffff; +// } + +// for (var i = 0; i < 16; i++) { +// if ((value >> i) & 1) { +// leds[i].on(); +// } else { +// leds[i].off(); +// } +// } +// } + +// this.repl.inject({ + +// set bits(value) { +// display(value); +// } +// }); + + +// // var a = new five.Led({ +// // pin: 0, +// // board: virtual +// // }); + +// // console.log(expander.normalize); +// // var b = new five.Led({ +// // pin: 15, +// // board: virtual +// // }); + +// // a.blink(); +// // b.blink(); +// // led.blink(); + + +// // this.repl.inject({ +// // ex: expander +// // }); + + +// // // for (var i = 0; i < 16; i++) { +// // // expander.pinMode(i, 1); +// // // expander.digitalWrite(i, 1); +// // // } + + + +// // expander.pinMode(0, 1); +// // expander.pinMode(8, 1); + +// // expander.digitalWrite(0, 0); +// // expander.digitalWrite(8, 0); + +// // expander.pinMode(7, 0); + +// // expander.digitalRead(7, function(data) { +// // console.log(data); + +// // }); + + +// // expander.pinMode(en, this.MODES.OUTPUT); +// // expander.pinMode(pwm, this.MODES.OUTPUT); +// // expander.pinMode(dir, this.MODES.OUTPUT); + + +// // expander.digitalWrite(dir, this.MODES.LOW); +// // expander.analogWrite(pwm, 255); +// // expander.digitalWrite(en, this.MODES.HIGH); + + +// // setTimeout(function() { + +// // expander.digitalWrite(en, this.MODES.LOW); +// // expander.analogWrite(pwm, 0); +// // expander.digitalWrite(dir, this.MODES.LOW); + +// // setTimeout(function() { + +// // expander.digitalWrite(dir, this.MODES.LOW); +// // expander.analogWrite(pwm, 255); +// // expander.digitalWrite(en, this.MODES.HIGH); +// // }.bind(this), 2000); + +// // }.bind(this), 2000); + +// }); diff --git a/JavaScript/node_modules/johnny-five/eg/expander.js b/JavaScript/node_modules/johnny-five/eg/expander.js new file mode 100644 index 0000000..2788aec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/expander.js @@ -0,0 +1,139 @@ +// var five = require("../lib/johnny-five.js"); +// var board = new five.Board(); + +// board.on("ready", function() { + +// // Bricktronics +// var en = 79; +// var pwm = 10; +// var dir = 78; + +// var expander = new five.Expander({ +// controller: "MCP23017" +// }); + +// var virtual = new five.Board.Virtual({ +// io: expander +// }); + +// var byte = 0; +// var index = 0; +// var leds = new five.Leds(); + +// for (var i = 0; i < 16; i++) { +// leds.push(new five.Led({ pin: i, board: virtual })); +// } + + + +// // leds.on(); + + +// // function next() { +// // byte |= (byte === 0 ? 1 : byte * 2); + + + +// // return byte; +// // } + + +// // var interval = setInterval(function() { + +// // leds[index++].on(); + +// // if (index === 16) { +// // clearInterval(interval); +// // } +// // }, 500); + +// function display(value) { +// if (value > 0xffff) { +// value -= 0xffff; +// } + +// for (var i = 0; i < 16; i++) { +// if ((value >> i) & 1) { +// leds[i].on(); +// } else { +// leds[i].off(); +// } +// } +// } + +// this.repl.inject({ + +// set bits(value) { +// display(value); +// } +// }); + + +// // var a = new five.Led({ +// // pin: 0, +// // board: virtual +// // }); + +// // console.log(expander.normalize); +// // var b = new five.Led({ +// // pin: 15, +// // board: virtual +// // }); + +// // a.blink(); +// // b.blink(); +// // led.blink(); + + +// // this.repl.inject({ +// // ex: expander +// // }); + + +// // // for (var i = 0; i < 16; i++) { +// // // expander.pinMode(i, 1); +// // // expander.digitalWrite(i, 1); +// // // } + + + +// // expander.pinMode(0, 1); +// // expander.pinMode(8, 1); + +// // expander.digitalWrite(0, 0); +// // expander.digitalWrite(8, 0); + +// // expander.pinMode(7, 0); + +// // expander.digitalRead(7, function(data) { +// // console.log(data); + +// // }); + + +// // expander.pinMode(en, this.MODES.OUTPUT); +// // expander.pinMode(pwm, this.MODES.OUTPUT); +// // expander.pinMode(dir, this.MODES.OUTPUT); + + +// // expander.digitalWrite(dir, this.MODES.LOW); +// // expander.analogWrite(pwm, 255); +// // expander.digitalWrite(en, this.MODES.HIGH); + + +// // setTimeout(function() { + +// // expander.digitalWrite(en, this.MODES.LOW); +// // expander.analogWrite(pwm, 0); +// // expander.digitalWrite(dir, this.MODES.LOW); + +// // setTimeout(function() { + +// // expander.digitalWrite(dir, this.MODES.LOW); +// // expander.analogWrite(pwm, 255); +// // expander.digitalWrite(en, this.MODES.HIGH); +// // }.bind(this), 2000); + +// // }.bind(this), 2000); + +// }); diff --git a/JavaScript/node_modules/johnny-five/eg/galileo-io.js b/JavaScript/node_modules/johnny-five/eg/galileo-io.js new file mode 100644 index 0000000..d0756b4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/galileo-io.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var Galileo = require("galileo-io"); +var board = new five.Board({ + io: new Galileo() +}); + +board.on("ready", function() { + var led = new five.Led(13); + led.blink(); +}); + +// @markdown +// +// In order to use the Galileo-IO library, you will need to flash the Intel IoTDevKit Image +// on your Galileo Gen 2. Once the environment is created, install Johnny-Five and Galileo-IO. +// +// ```sh +// npm install johnny-five galileo-io +// ``` +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/game-of-life.js b/JavaScript/node_modules/johnny-five/eg/game-of-life.js new file mode 100644 index 0000000..3e24fde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/game-of-life.js @@ -0,0 +1,294 @@ +// var fs = require("fs"); +// var five = require("../lib/johnny-five"); +// var board = new five.Board(); + +// board.on("ready", function() { + +// var game = new GameOfLife({ +// auto: true, +// interval: 500, +// maxCycles: Infinity, +// render: function(bytes, world) { +// console.log(String(world)); +// console.log("----------------"); + +// if (this.inPattern) { +// matrix.draw(bytes); +// } else { +// matrix.clear(); +// } +// } +// }); + +// var matrix = new five.Led.Matrix({ +// addresses: [0x70], +// controller: "HT16K33", +// rotation: 2, +// }); + +// var button = new five.Button({ +// isPullup: true, +// pin: 8 +// }); + +// button.on("hold", function() { +// game.reset().start(); +// }); + +// button.on("press", function() { +// fs.writeFile("gol-pattern-" + Date.now() + ".json", JSON.stringify(game.pattern, null, 2), "utf8"); +// }); + +// // this.repl.inject({ +// // GameOfLife: GameOfLife, +// // World: GameOfLife.World, +// // game: game +// // }); +// }); + + + + + + +// var priv = new Map(); + +// function random(howBig) { +// howBig >>>= 0; +// return Math.random() * howBig | 0; +// } + +// function toBytes(world) { +// var out = [0, 0, 0, 0, 0, 0, 0, 0]; +// for (var row = 0; row < 8; row++) { +// for (var col = 0; col < 8; col++) { +// out[row] |= world[row][col] << col; +// } +// } +// return out; +// } + +// function GameOfLife(options) { +// var layout; + +// if (Array.isArray(options)) { +// layout = options; +// options = { +// layout: layout +// }; +// } + +// var state = { +// auto: options.auto || false, +// dimensions: options.dimensions || [8, 8], +// interval: options.interval || 500, +// layout: options.layout || null, +// maxCycles: options.maxCycles || 255, +// render: options.render || console.log.bind(console), +// inPattern: false, +// isStill: false, +// cycle: 0, +// timer: null, +// history: [], +// pattern: [], +// mod: function(num) { +// num >>>= 0; +// return (num + this.dimensions[0]) % this.dimensions[0]; +// } +// }; + +// priv.set(this, state); + +// Object.defineProperties(this, { +// inPattern: { +// get: function() { +// return state.inPattern; +// } +// }, +// pattern: { +// get: function() { +// return state.pattern.slice(); +// } +// } +// }); + +// this.reset(); + +// if (options.auto) { +// this.start(); +// } +// } + +// GameOfLife.prototype.randomize = function() { +// var state = priv.get(this); + +// for (var row = 0; row < state.dimensions[0]; row++) { +// for (var col = 0; col < state.dimensions[1]; col++) { +// if (random(state.dimensions[1] - (state.dimensions[1] / 4)) > (state.dimensions[1] / 2)) { +// this.present[row][col] ^= 1; +// } +// } +// } +// }; + +// GameOfLife.prototype.reset = function() { +// var state = priv.get(this); + +// this.stop(); + +// this.present = new GameOfLife.World(state.layout || state.history.pop()); +// this.next = new GameOfLife.World(); + +// state.isStill = false; +// state.inPattern = false; + +// state.pattern.length = 0; +// state.cycle = state.maxCycles; + + +// if (!state.layout) { +// this.randomize(); +// this.randomize(); +// } + +// return this; +// }; + +// GameOfLife.prototype.start = function() { +// var state = priv.get(this); +// state.timer = setInterval(function() { +// this.generation(); + +// if (!--state.cycle || state.isStill) { +// this.reset(); + +// if (state.auto) { +// this.start(); +// } +// } +// }.bind(this), state.interval); +// return this; +// }; + +// GameOfLife.prototype.stop = function() { +// var state = priv.get(this); +// if (state.timer) { +// clearInterval(state.timer); +// } +// return this; +// }; + +// GameOfLife.prototype.generation = function() { +// var state = priv.get(this); + +// for (var row = 0; row < state.dimensions[0]; row++) { +// for (var col = 0; col < state.dimensions[1]; col++) { +// // Count living neighbors +// var alive = 0; + +// for (var cellX = -1; cellX <= 1; cellX++) { +// for (var cellY = -1; cellY <= 1; cellY++) { +// if (this.present[state.mod(row + cellX)][state.mod(col + cellY)] !== 0) { +// alive++; +// } +// } +// } + +// if (this.present[row][col]) { +// if (alive < 2 || alive > 3) { +// // Any cell with < 2 neighbors dies, due to under-population. +// // Any cell with > 3 neighbors dies, due to over-crowding. +// this.next[row][col] = 0; +// } else { +// // Any cell with 2 or 3 neighbors lives on to the next generation. +// this.next[row][col] = 1; +// } +// } else { +// if (alive === 3) { +// // Re-animate a dead cell if it has exactly 3 live neighbors. +// this.next[row][col] = 1; +// } +// } +// } +// } + +// // Copy next generation to present. +// var isStill = true; + +// for (var row = 0; row < state.dimensions[0]; row++) { +// for (var col = 0; col < state.dimensions[1]; col++) { +// isStill &= ((this.present[row][col] > 0) === (this.next[row][col] > 0)); +// // isStill &= this.present[row][col] === this.next[row][col]; +// this.present[row][col] = this.next[row][col]; +// } +// } + +// // The World is dead. +// if (toBytes(this.present).reduce(function(a, b) {return a + b; }) === 0) { +// this.reset().start(); +// return; +// } + + +// state.isStill = Boolean(isStill); +// state.history.push(new GameOfLife.World(this.present)); +// state.render.call(this, toBytes(this.present), state.history[state.history.length - 1]); + +// state.history = state.history.slice(-32); + +// var wasInPattern = state.inPattern; + +// for (var i = 0; i < 31; i++) { +// state.inPattern = false; +// if (this.present.equals(state.history[i])) { +// state.inPattern = true; +// state.pattern.push(this.present); +// break; +// } +// } + +// if (wasInPattern) { +// if (!state.inPattern) { +// state.pattern.length = 0; +// } else { +// // console.log("pattern: ", state.pattern); +// } +// } +// }; + +// GameOfLife.World = function(source, dimensions) { +// Array.call(this); + +// if (!dimensions) { +// dimensions = [8, 8]; +// } + +// for (var i = 0; i < dimensions[0]; i++) { +// this.push(source ? source[i].slice() : new Array(dimensions[1]).fill(0)); +// } +// }; + +// GameOfLife.World.prototype = Object.create(Array.prototype, { +// constructor: { +// value: GameOfLife.World +// } +// }); + +// GameOfLife.World.prototype.equals = function(other) { +// var a = toBytes(this); +// var b = toBytes(other); + +// for (var i = 0; i < (a.length / 2); i++) { +// if (a[i] !== b[i] || a[(a.length - 1) - i] !== b[(a.length - 1) - i]) { +// return false; +// } +// } +// return true; +// }; + +// GameOfLife.World.prototype.toString = function() { +// return this.reduce(function(accum, row) { +// accum += row.join("").replace(/0/g, " ").replace(/1/g, " ●") + "\n"; +// return accum; +// }, ""); +// }; diff --git a/JavaScript/node_modules/johnny-five/eg/gripper.js b/JavaScript/node_modules/johnny-five/eg/gripper.js new file mode 100644 index 0000000..21922e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/gripper.js @@ -0,0 +1,75 @@ +var five = require("../lib/johnny-five.js"), + compulsive = require("compulsive"), + wrist, gripper, motion, repeater; + +(new five.Board()).on("ready", function() { + + // Create a new `gripper` hardware instance. + // This example allows the gripper module to + // create a completely default instance + + wrist = new five.Servo(9); + gripper = new five.Gripper(10); + + + function slice() { + wrist.to(100); + + compulsive.wait(100, function() { + wrist.to(120); + }); + } + + function chop() { + compulsive.loop(200, function(loop) { + if (!repeater) { + repeater = loop; + } + slice(); + }); + } + + // Inject the `gripper` hardware into + // the Repl instance's context; + // allows direct command line access + this.repl.inject({ + w: wrist, + g: gripper, + chop: chop, + slice: slice + }); + + + motion = new five.IR.Motion(7); + + // gripper.open() + // + // gripper.close() + // + // gripper.set([0-10]) + // + // + // g.*() from REPL + // + // + motion.on("motionstart", function(err, ts) { + chop(); + }); + + // "motionstart" events are fired following a "motionstart event + // when no movement has occurred in X ms + motion.on("motionend", function(err, ts) { + if (repeater) { + repeater.stop(); + repeater = null; + } + }); + + + + }); + +// @markdown +// - [Parallax Boe-Bot Gripper](http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/GripperManual-v3.0.pdf) +// - [DFRobot LG-NS Gripper](http://www.dfrobot.com/index.php?route=product/product&filter_name=gripper&product_id=628#.UCvGymNST_k) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-button.js b/JavaScript/node_modules/johnny-five/eg/grove-button.js new file mode 100644 index 0000000..15a946b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-button.js @@ -0,0 +1,35 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Button module into the + // Grove Shield's D4 jack + var button = new five.Button(4); + + // Plug the LED module into the + // Grove Shield's D6 jack. See + // grove-led.js for more information. + var led = new five.Led(6); + + // The following will turn the Led + // on and off as the button is + // pressed and released. + button.on("press", function() { + led.on(); + }); + + button.on("release", function() { + led.off(); + }); +}); +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-lcd-i2c.js b/JavaScript/node_modules/johnny-five/eg/grove-lcd-i2c.js new file mode 100644 index 0000000..afdaf5c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-lcd-i2c.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the LCD module into any of the + // Grove Shield's I2C jacks. + var lcd = new five.LCD({ + controller: "JHD1313M1" + }); + + lcd.useChar("heart"); + + lcd.cursor(0, 0).print("hello :heart:"); + + lcd.blink().cursor(1, 0).print("Blinking? "); +}); +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb-temperature-display.js b/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb-temperature-display.js new file mode 100644 index 0000000..def9b56 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb-temperature-display.js @@ -0,0 +1,53 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Temperature sensor module + // into the Grove Shield's A0 jack + var temperature = new five.Temperature({ + controller: "GROVE", + pin: "A0" + }); + + // Plug the LCD module into any of the + // Grove Shield's I2C jacks. + var lcd = new five.LCD({ + controller: "JHD1313M1" + }); + + temperature.on("data", function() { + + // The LCD's background will change + // color according to the temperature. + // + // Experiment with sources of hot and + // cold temperatures! + // + var f = temperature.fahrenheit; + var r = linear(0x00, 0xFF, f, 100); + var g = linear(0x00, 0x00, f, 100); + var b = linear(0xFF, 0x00, f, 100); + + console.log("temp: ", f); + + lcd.bgColor(r, g, b).cursor(0, 0).print(f.toFixed(2)); + }); +}); + +// [Linear Interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) +function linear(start, end, step, steps) { + return (end - start) * step / steps + start; +} + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb.js b/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb.js new file mode 100644 index 0000000..4d4477a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-lcd-rgb.js @@ -0,0 +1,48 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Rotary Angle sensor module + // into the Grove Shield's A0 jack + var rotary = new five.Sensor("A0"); + + // Plug the LCD module into any of the + // Grove Shield's I2C jacks. + var lcd = new five.LCD({ + controller: "JHD1313M1" + }); + + // Set scaling of the Rotary angle + // sensor's output to 0-255 (8-bit) + // range. Set the LCD's background + // color to a RGB value between + // Red and Violet based on the + // value of the rotary sensor. + rotary.scale(0, 255).on("change", function() { + var r = linear(0xFF, 0x4B, this.value, 0xFF); + var g = linear(0x00, 0x00, this.value, 0xFF); + var b = linear(0x00, 0x82, this.value, 0xFF); + + lcd.bgColor(r, g, b); + }); +}); + +// [Linear Interpolation](https://en.wikipedia.org/wiki/Linear_interpolation) +function linear(start, end, step, steps) { + return (end - start) * step / steps + start; +} + + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// @markdown + + diff --git a/JavaScript/node_modules/johnny-five/eg/grove-led.js b/JavaScript/node_modules/johnny-five/eg/grove-led.js new file mode 100644 index 0000000..1815b3d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-led.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the LED module into the + // Grove Shield's D6 jack. + // + // Select an LED from the kit + // (red, green, blue) and insert + // it into the LED module, with + // the long pin in + and short + // pin in -. + var led = new five.Led(6); + + // This will blink the LED over + // 500ms periods. + led.blink(500); +}); + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-sensor.js b/JavaScript/node_modules/johnny-five/eg/grove-sensor.js new file mode 100644 index 0000000..7f2d5e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-sensor.js @@ -0,0 +1,33 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Rotary Angle sensor module + // into the Grove Shield's A0 jack + var rotary = new five.Sensor("A0"); + + // Plug the LED module into the + // Grove Shield's D6 jack. See + // grove-led.js for more information. + var led = new five.Led(6); + + // Set scaling of the Rotary angle + // sensor's output to 0-255 (8-bit) + // range. Set the LED's brightness + // based on the value of the sensor. + rotary.scale(0, 255).on("change", function() { + led.brightness(this.value); + }); +}); + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-servo.js b/JavaScript/node_modules/johnny-five/eg/grove-servo.js new file mode 100644 index 0000000..952dacd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-servo.js @@ -0,0 +1,33 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Rotary Angle sensor module + // into the Grove Shield's A0 jack + var rotary = new five.Sensor("A0"); + + // Plug the Servo module + // into the Grove Shield's D5 jack + var servo = new five.Servo(5); + + // Set scaling of the Rotary angle + // sensor's output to 0-180° (8-bit) + // range. Set the servo angle in + // degrees corresponding to the + // value of the sensor + rotary.scale(0, 180).on("change", function() { + servo.to(this.value); + }); +}); + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/grove-touch.js b/JavaScript/node_modules/johnny-five/eg/grove-touch.js new file mode 100644 index 0000000..d0a86a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/grove-touch.js @@ -0,0 +1,37 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + // Plug the Touch module into the + // Grove Shield's D4 jack. Use + // the Button class to control. + var touch = new five.Button(4); + + // Plug the LED module into the + // Grove Shield's D6 jack. See + // grove-led.js for more information. + var led = new five.Led(6); + + // The following will turn the Led + // on and off as the touch is + // pressed and released. + touch.on("press", function() { + led.on(); + }); + + touch.on("release", function() { + led.off(); + }); +}); + +// @markdown +// For this program, you'll need: +// +//  +// +//  +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/gyro-lpr5150l.js b/JavaScript/node_modules/johnny-five/eg/gyro-lpr5150l.js new file mode 100644 index 0000000..f58bf93 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/gyro-lpr5150l.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var gyro = new five.Gyro({ + pins: ["A0", "A1"] + }); + + gyro.on("change", function() { + console.log("gyro"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" yaw : ", this.yaw); + console.log(" rate : ", this.rate); + console.log(" isCalibrated : ", this.isCalibrated); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/gyro-mpu6050.js b/JavaScript/node_modules/johnny-five/eg/gyro-mpu6050.js new file mode 100644 index 0000000..ceb8c8c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/gyro-mpu6050.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var gyro = new five.Gyro({ + controller: "MPU6050" + }); + + gyro.on("change", function() { + console.log("gyro"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log(" z : ", this.z); + console.log(" pitch : ", this.pitch); + console.log(" roll : ", this.roll); + console.log(" yaw : ", this.yaw); + console.log(" rate : ", this.rate); + console.log(" isCalibrated : ", this.isCalibrated); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/gyro.js b/JavaScript/node_modules/johnny-five/eg/gyro.js new file mode 100644 index 0000000..3d22fa7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/gyro.js @@ -0,0 +1,78 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var servo = new five.Servo("O2"); + var gyro = new five.Gyro({ + pins: ["I0", "I1"], + sensitivity: 0.67 // TK_4X + }); + + servo.center(); + + var threshold = 2; + var position = 0; + var lapse = 0; + + var sampleTime = 10; + var time = Date.now(); + + var pitch = { + value: 0, + last: 0, + angle: 0 + }; + + var roll = { + value: 0, + last: 0, + angle: 0 + }; + + gyro.on("change", function(err, data) { + var now = Date.now(); + + console.log("X raw: %d rate: %d", this.x, this.rate.x); + console.log("Y raw: %d rate: %d", this.y, this.rate.y); + + pitch.value = this.pitch.rate; + roll.value = this.roll.rate; + + // Ignore the gyro if our angular velocity does not meet our threshold + if (pitch.value >= threshold || pitch.value <= -threshold) { + pitch.angle += ((pitch.last + pitch.value) * 10) / 1000; + } + + if (roll.value >= threshold || roll.value <= -threshold) { + roll.angle += ((roll.last + roll.value) * 10) / 1000; + } + + pitch.last = pitch.value; + roll.last = roll.value; + + if (roll.angle < 0) { + roll.angle += 360; + } + + if (roll.angle > 359) { + roll.angle -= 360; + } + + // counterclockwise rotation of the gyro... + if (roll.angle >= 0 && roll.angle <= 90) { + // ...produces rotation from 90 to 180 deg on servo + position = (90 + roll) | 0; + } + + // clockwise rotation of the gyro... + if (roll.angle >= 270) { + // ...produces rotation from 90 to 0 deg on servo + position = (roll.angle - 270) | 0; + } + + // console.log( position ); + servo.to(position); + + console.log("-----------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/handclaw42-client.js b/JavaScript/node_modules/johnny-five/eg/handclaw42-client.js new file mode 100644 index 0000000..d715cf3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/handclaw42-client.js @@ -0,0 +1,32 @@ +/* global io */ +$(document).ready(function() { + var $body = $("body"); + var socket = window.socket; + + socket = io.connect("http://192.168.1.186:8080"); + + socket.on("createServo", function(data) { + var div, span, input; + + div = $(""); + // should probably just make this a + span = $("", { + html: data.servo + }).addClass("label"); + input = $("", { + min: data.min, + max: data.max, + type: "range" + }); + + input.on("change", function() { + socket.emit("range", { + id: data.id, + value: $(this).val() + }); + }); + + div.append(span, input); + $body.append(div); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/handclaw42.html b/JavaScript/node_modules/johnny-five/eg/handclaw42.html new file mode 100644 index 0000000..85f167d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/handclaw42.html @@ -0,0 +1,55 @@ + + + + + + clawhand + + + + + + + + + diff --git a/JavaScript/node_modules/johnny-five/eg/handclaw42.js b/JavaScript/node_modules/johnny-five/eg/handclaw42.js new file mode 100644 index 0000000..a05b583 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/handclaw42.js @@ -0,0 +1,95 @@ +var five = require("../lib/johnny-five.js"), + http = require("http"), + socket = require("socket.io"), + fs = require("fs"), + app, board, io; + +function handler(req, res) { + var path = __dirname; + + if (req.url === "/") { + path += "/handclaw42.html"; + } else { + path += req.url; + } + + fs.readFile(path, function(err, data) { + if (err) { + res.writeHead(500); + return res.end("Error loading " + path); + } + + res.writeHead(200); + res.end(data); + }); +} + +app = http.createServer(handler); +app.listen(8080); + +io = socket.listen(app); +io.set("log level", 1); + +board = new five.Board(); + +board.on("ready", function() { + var defs, servos; + + // http://www.ranchbots.com/robot_arm/images/arm_diagram.jpg + defs = [ + // Pivot/Rotator + { + id: "rotator", + pin: 6, + range: [10, 170], + startAt: 90 + }, + // Shoulder + { + id: "shoulder", + pin: 9, + range: [20, 150], + startAt: 90 + }, + // Elbow + { + id: "elbow", + pin: 10, + range: [10, 120], + startAt: 90 + }, + // Wrist + { + id: "wrist", + pin: 11, + range: [10, 170], + startAt: 40 + }, + // Grip + { + id: "claw", + pin: 12, + range: [10, 170], + startAt: 0 + } + ]; + + // Reduce the des array into an object of servo instances, + // where the servo id is the property name + servos = defs.reduce(function(accum, def) { + return (accum[def.id] = five.Servo(def)) && accum; + }, {}); + + io.sockets.on("connection", function(socket) { + defs.forEach(function(key) { + socket.emit("createServo", { + id: key.id, + min: key.range[0], + max: key.range[1] + }); + }); + socket.on("range", function(data) { + servos[data.id].to(data.value); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/hy505.js b/JavaScript/node_modules/johnny-five/eg/hy505.js new file mode 100644 index 0000000..6670ca1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/hy505.js @@ -0,0 +1,21 @@ +var five = require("johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var led = new five.Led(8); + var temp = new five.Temperature({ + controller: "GROVE", + pin: "A2" + }); + var sensor = new five.Sensor("A0"); + + sensor.on("change", function() { + if (this.value < 25) { + led.on(); + console.log("Slot interrupted @ %d", Date.now()); + console.log("Temperature: %d°C", Math.round(temp.celsius)); + } else { + led.off(); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/imp-io.js b/JavaScript/node_modules/johnny-five/eg/imp-io.js new file mode 100644 index 0000000..665b84e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/imp-io.js @@ -0,0 +1,40 @@ +var five = require("johnny-five"); +var Imp = require("imp-io"); + +var board = new five.Board({ + io: new Imp({ + agent: process.env.IMP_AGENT_ID + }) +}); + +board.on("ready", function() { + var led = new five.Led(9); + led.blink(); +}); + +// @markdown +// +// To communicate with an Electric Imp using Johnny-Five w/ Imp-IO, +// you will need to upload the special +// [Tyrion](https://github.com/rwaldron/tyrion) +// **[agent](https://github.com/rwaldron/tyrion/blob/master/agent.nut)** and +// **[device](https://github.com/rwaldron/tyrion/blob/master/device.nut)** +// firmware through Electric Imp's [IDE](https://ide.electricimp.com/login). +// We recommend you review +// [Electric Imp's Getting Started](http://www.electricimp.com/docs/gettingstarted/) +// before continuing. +// +// Store your agent ID in a dot file so it can be accessed as a property of `process.env`. +// Create a file in your home directory called `.imprc` that contains: +// +// ```sh +// export IMP_AGENT_ID="your agent id" +// ``` +// +// Then add the following to your dot-rc file of choice: +// +// ```sh +// source ~/.imprc +// ``` +// +// @markdown \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/eg/imu-mpu6050.js b/JavaScript/node_modules/johnny-five/eg/imu-mpu6050.js new file mode 100644 index 0000000..e89f4d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/imu-mpu6050.js @@ -0,0 +1,39 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var imu = new five.IMU({ + controller: "MPU6050" + }); + + imu.on("change", function() { + console.log("temperature"); + console.log(" celsius : ", this.temperature.celsius); + console.log(" fahrenheit : ", this.temperature.fahrenheit); + console.log(" kelvin : ", this.temperature.kelvin); + console.log("--------------------------------------"); + + console.log("accelerometer"); + console.log(" x : ", this.accelerometer.x); + console.log(" y : ", this.accelerometer.y); + console.log(" z : ", this.accelerometer.z); + console.log(" pitch : ", this.accelerometer.pitch); + console.log(" roll : ", this.accelerometer.roll); + console.log(" acceleration : ", this.accelerometer.acceleration); + console.log(" inclination : ", this.accelerometer.inclination); + console.log(" orientation : ", this.accelerometer.orientation); + console.log("--------------------------------------"); + + console.log("gyro"); + console.log(" x : ", this.gyro.x); + console.log(" y : ", this.gyro.y); + console.log(" z : ", this.gyro.z); + console.log(" pitch : ", this.gyro.pitch); + console.log(" roll : ", this.gyro.roll); + console.log(" yaw : ", this.gyro.yaw); + console.log(" rate : ", this.gyro.rate); + console.log(" isCalibrated : ", this.gyro.isCalibrated); + console.log("--------------------------------------"); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/ir-distance.js b/JavaScript/node_modules/johnny-five/eg/ir-distance.js new file mode 100644 index 0000000..387cb71 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ir-distance.js @@ -0,0 +1,47 @@ +// Run this program with a device model: +// +// node eg/ir-distance.js GP2Y0A02YK0F +// +// You may also use the model number printed on the +// device itself. eg +// +// 2Y0A21 +// 2D120X +// 2Y0A02 +// OA41SK +// +// Without a specific model number, the readings will +// be wrong (unless you've connected a GP2Y0A02YK0F/2Y0A02) +// +// Valid models: +// +// - GP2Y0A21YK +// https://www.sparkfun.com/products/242 +// - GP2D120XJ00F +// https://www.sparkfun.com/products/8959 +// - GP2Y0A02YK0F +// https://www.sparkfun.com/products/8958 +// - GP2Y0A41SK0F +// https://www.sparkfun.com/products/12728 +// +// +var five = require("../lib/johnny-five.js"), + board = new five.Board(), + controller = process.argv[2] || "GP2Y0A02YK0F"; + +board.on("ready", function() { + var distance = new five.IR.Proximity({ + controller: controller, + pin: "A0", + freq: 500 + }); + + distance.on("data", function() { + if (controller) { + console.log("inches: ", this.inches); + console.log("cm: ", this.centimeters, this.raw); + } else { + console.log("value: ", this.value); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/ir-motion.js b/JavaScript/node_modules/johnny-five/eg/ir-motion.js new file mode 100644 index 0000000..ae51e89 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ir-motion.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.IR.Motion(7); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/ir-proximity.js b/JavaScript/node_modules/johnny-five/eg/ir-proximity.js new file mode 100644 index 0000000..9c8d7e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ir-proximity.js @@ -0,0 +1,43 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); +var controller = process.argv[2] || "GP2Y0A02YK0F"; + +board.on("ready", function() { + var proximity = new five.IR.Proximity({ + controller: controller, + pin: "A0" + }); + + proximity.on("data", function() { + console.log("inches: ", this.inches); + console.log("cm: ", this.cm); + }); +}); + +// Run this program with a device model for the controller: +// +// node eg/ir-distance.js GP2Y0A02YK0F +// +// You may also use the model number printed on the +// device itself. eg +// +// 2Y0A21 +// 2D120X +// 2Y0A02 +// OA41SK +// +// Without a specific model number, the readings will +// be wrong (unless you've connected a GP2Y0A02YK0F/2Y0A02) +// +// Valid models: +// +// - GP2Y0A21YK +// https://www.sparkfun.com/products/242 +// - GP2D120XJ00F +// https://www.sparkfun.com/products/8959 +// - GP2Y0A02YK0F +// https://www.sparkfun.com/products/8958 +// - GP2Y0A41SK0F +// https://www.sparkfun.com/products/12728 +// + diff --git a/JavaScript/node_modules/johnny-five/eg/ir-reflect-array.js b/JavaScript/node_modules/johnny-five/eg/ir-reflect-array.js new file mode 100644 index 0000000..609f2c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ir-reflect-array.js @@ -0,0 +1,24 @@ +var five = require("../lib/johnny-five"); + +five.Board().on("ready", function() { + var calibrating = true; + var eyes = new five.IR.Reflect.Array({ + emitter: 13, + pins: ["A0", "A1", "A2", "A3", "A4", "A5"] + }); + + // calibrate for two seconds + eyes.calibrateUntil(function() { return !calibrating; }); + setTimeout(function() { calibrating = false; }, 2000); + + eyes.enable(); + + // "line" + // + // Fires continuously once calibrated + // + eyes.on("line", function(err, line) { + console.log("line: ", line); + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/ir-reflect.js b/JavaScript/node_modules/johnny-five/eg/ir-reflect.js new file mode 100644 index 0000000..daca85f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ir-reflect.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five.js"); + +five.Board().on("ready", function() { + // Create a new `IR.Reflect` hardware instance. + // + // five.IR.Reflect(); + // + // (Alias of: + // new five.IR({ + // device: "QRE1113GR", + // freq: 50 + // }); + // ) + // + + var ir = new five.IR.Reflect(); + + // "data" + // + // Fires continuously, every 66ms. + // + ir.on("data", function(err, timestamp) { + console.log("data"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/johnny.png b/JavaScript/node_modules/johnny-five/eg/johnny.png new file mode 100644 index 0000000..45288a6 Binary files /dev/null and b/JavaScript/node_modules/johnny-five/eg/johnny.png differ diff --git a/JavaScript/node_modules/johnny-five/eg/joystick-claw.js b/JavaScript/node_modules/johnny-five/eg/joystick-claw.js new file mode 100644 index 0000000..92be349 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick-claw.js @@ -0,0 +1,27 @@ +var five = require("../lib/johnny-five.js"), + board, claw, joystick; + +board = new five.Board(); + +board.on("ready", function() { + + var claw = new five.Servo({ + pin: 9, + range: [0, 170] + }), + joystick = new five.Joystick({ + pins: ["A0", "A1"], + freq: 250 + }); + + // Set the claw degrees to half way + // (the joystick deadzone) + claw.to(90); + + joystick.on("axismove", function() { + // Open/close the claw by setting degrees according + // to Y position of joystick. + // limit to 170 on medium servos (ei. the servo used on the claw) + claw.to(Math.ceil(170 * this.fixed.y)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/joystick-esplora.js b/JavaScript/node_modules/johnny-five/eg/joystick-esplora.js new file mode 100644 index 0000000..5af5e55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick-esplora.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + /* + Be sure to reflash your Esplora with StandardFirmata! + + In the Arduino IDE: + + Tools > Boards > Arduino Leonard or Arduino Esplora + */ + var joystick = new five.Joystick({ + controller: "ESPLORA" + }); + + joystick.on("change", function() { + console.log("Joystick"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/joystick-motor-led.js b/JavaScript/node_modules/johnny-five/eg/joystick-motor-led.js new file mode 100644 index 0000000..619d461 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick-motor-led.js @@ -0,0 +1,68 @@ +var five = require("../lib/johnny-five.js"), + board, joystick, motor, led; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `joystick` hardware instance. + joystick = new five.Joystick({ + // Joystick pins are an array of pins + // Pin orders: + // [ up, down, left, right ] + // [ ud, lr ] + pins: ["A0", "A1"], + freq: 25 + }); + + // Attach a motor to PWM pin 5 + motor = new five.Motor({ + pin: 5 + }); + + // Attach a led to PWM pin 9 + led = new five.Led({ + pin: 9 + }); + + // Inject the hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + joystick: joystick, + motor: motor, + led: led + }); + + + // Pushing the joystick to up position should start the motor, + // releasing it will turn the motor off. + joystick.on("axismove", function(err, timestamp) { + + if (!motor.isOn && this.axis.y > 0.51) { + motor.start(); + } + + if (motor.isOn && this.axis.y < 0.51) { + motor.stop(); + } + }); + + // While the motor is on, blink the led + motor.on("start", function() { + // 250ms + led.strobe(250); + }); + + motor.on("stop", function() { + led.stop(); + }); +}); + + +// Schematic +// https://1965269182786388413-a-1802744773732722657-s-sites.googlegroups.com/site/parallaxinretailstores/home/2-axis-joystick/Joystick-6.png +// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-Axis%20JoyStick_B%20Schematic.pdf + +// Further Reading +// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-2-AxisJoystick-v1.2.pdf diff --git a/JavaScript/node_modules/johnny-five/eg/joystick-pantilt.js b/JavaScript/node_modules/johnny-five/eg/joystick-pantilt.js new file mode 100644 index 0000000..16c0c11 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick-pantilt.js @@ -0,0 +1,34 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var range = [0, 170]; + + // Servo to control panning + var pan = new five.Servo({ + pin: 9, + range: range, + center: true + }); + + // Servo to control tilt + var tilt = new five.Servo({ + pin: 10, + range: range, + center: true + }); + + // Joystick to control pan/tilt + // Read Analog 0, 1 + // Limit events to every 50ms + var joystick = new five.Joystick({ + pins: ["A0", "A1"], + freq: 100 + }); + + + joystick.on("change", function() { + tilt.to(five.Fn.scale(this.y, -1, 1, 0, 170)); + pan.to(five.Fn.scale(this.x, -1, 1, 0, 170)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/joystick-shield.js b/JavaScript/node_modules/johnny-five/eg/joystick-shield.js new file mode 100644 index 0000000..ed4eeb2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick-shield.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var joystick = new five.Joystick({ + pins: ["A0", "A1"], + invertY: true + }); + + joystick.on("change", function() { + console.log("Joystick"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/joystick.js b/JavaScript/node_modules/johnny-five/eg/joystick.js new file mode 100644 index 0000000..8e84dff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/joystick.js @@ -0,0 +1,18 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `joystick` hardware instance. + var joystick = new five.Joystick({ + // [ x, y ] + pins: ["A0", "A1"] + }); + + joystick.on("change", function() { + console.log("Joystick"); + console.log(" x : ", this.x); + console.log(" y : ", this.y); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/keypad-MPR121.js b/JavaScript/node_modules/johnny-five/eg/keypad-MPR121.js new file mode 100644 index 0000000..14a2e73 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/keypad-MPR121.js @@ -0,0 +1,39 @@ +var argv = require("minimist")(process.argv.slice(2), { default: { show: 1 } }); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + // MPR121 3x4 Capacitive Touch Pad + var keypad; + + if (argv.show === 1) { + keypad = new five.Keypad({ + controller: "MPR121" + }); + } + + if (argv.show === 2) { + keypad = new five.Keypad({ + controller: "MPR121", + keys: [ + ["!", "@", "#"], + ["$", "%", "^"], + ["&", "-", "+"], + ["_", "=", ":"] + ] + }); + } + + if (argv.show === 3) { + keypad = new five.Keypad({ + controller: "MPR121", + keys: ["!", "@", "#", "$", "%", "^", "&", "-", "+", "_", "=", ":"] + }); + } + + ["change", "press", "hold", "release"].forEach(function(eventType) { + keypad.on(eventType, function(data) { + console.log("Event: %s, Target: %s", eventType, data.which); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/keypad-MPR121QR2.js b/JavaScript/node_modules/johnny-five/eg/keypad-MPR121QR2.js new file mode 100644 index 0000000..87e46d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/keypad-MPR121QR2.js @@ -0,0 +1,38 @@ +var argv = require("minimist")(process.argv.slice(2), { default: { show: 1 } }); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + // MPR121QR2 3x3 Capacitive Touch Shield + var keypad; + + if (argv.show === 1) { + keypad = new five.Keypad({ + controller: "MPR121QR2" + }); + } + + if (argv.show === 2) { + keypad = new five.Keypad({ + controller: "MPR121QR2", + keys: [ + ["!", "@", "#"], + ["$", "%", "^"], + ["&", "-", "+"], + ] + }); + } + + if (argv.show === 3) { + keypad = new five.Keypad({ + controller: "MPR121QR2", + keys: ["!", "@", "#", "$", "%", "^", "&", "-", "+"] + }); + } + + ["change", "press", "hold", "release"].forEach(function(eventType) { + keypad.on(eventType, function(data) { + console.log("Event: %s, Target: %s", eventType, data.which); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/keypad-analog-ad.js b/JavaScript/node_modules/johnny-five/eg/keypad-analog-ad.js new file mode 100644 index 0000000..991d62e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/keypad-analog-ad.js @@ -0,0 +1,42 @@ +var argv = require("minimist")(process.argv.slice(2), { default: { show: 1 } }); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + // WaveShare AD Keypad + var keypad; + + if (argv.show === 1) { + keypad = new five.Keypad({ + pin: "A0", + length: 16 + }); + } + + if (argv.show === 2) { + keypad = new five.Keypad({ + pin: "A0", + keys: [ + ["1", "!", "@", "#"], + ["2", "$", "%", "^"], + ["3", "&", "-", "+"], + ["4", "<", ">", "?"], + ] + }); + } + + if (argv.show === 3) { + keypad = new five.Keypad({ + pin: "A0", + keys: ["1", "!", "@", "#", "2", "$", "%", "^", "3", "&", "-", "+", "4", "<", ">", "?"] + }); + } + + ["change", "press", "hold", "release"].forEach(function(eventType) { + keypad.on(eventType, function(data) { + console.log("Event: %s, Target: %s", eventType, data.which); + }); + }); +}); + + diff --git a/JavaScript/node_modules/johnny-five/eg/keypad-analog-vkey.js b/JavaScript/node_modules/johnny-five/eg/keypad-analog-vkey.js new file mode 100644 index 0000000..18d079d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/keypad-analog-vkey.js @@ -0,0 +1,44 @@ +var argv = require("minimist")(process.argv.slice(2), { default: { show: 1 } }); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + // Sparkfun's VKey Voltage Keypad + var keypad; + + if (argv.show === 1) { + keypad = new five.Keypad({ + controller: "VKEY", + pin: "A0", + }); + } + + if (argv.show === 2) { + keypad = new five.Keypad({ + controller: "VKEY", + pin: "A0", + keys: [ + ["!", "@", "#"], + ["$", "%", "^"], + ["&", "-", "+"], + ["<", ">", "?"], + ] + }); + } + + if (argv.show === 3) { + keypad = new five.Keypad({ + controller: "VKEY", + pin: "A0", + keys: ["!", "@", "#", "$", "%", "^", "&", "-", "+", "<", ">", "?"] + }); + } + + ["change", "press", "hold", "release"].forEach(function(eventType) { + keypad.on(eventType, function(data) { + console.log("Event: %s, Target: %s", eventType, data.which); + }); + }); +}); + + diff --git a/JavaScript/node_modules/johnny-five/eg/keypad.js b/JavaScript/node_modules/johnny-five/eg/keypad.js new file mode 100644 index 0000000..180482c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/keypad.js @@ -0,0 +1,34 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var vkey = new five.Keypad("A0"); + + // TODO: digital 10 pin keypad + // var dkey = new five.Keypad({ + // // Digital Pins must be mapped to + // // appropriate keypad number. + // // pin => num/char + // pins: { + // // ? + // } + // }); + + var ikey = new five.Keypad({ + controller: "MPR121", + address: 0x5A + }); + + var pads = { + vkey: vkey, + ikey: ikey, + }; + + Object.keys(pads).forEach(function(key) { + ["change", "press", "hold", "release"].forEach(function(event) { + pads[key].on(event, function(data) { + console.log("Pad: %s, Event: %s, Which: %s", key, event, data); + }); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/kinect-arm-controller.js b/JavaScript/node_modules/johnny-five/eg/kinect-arm-controller.js new file mode 100644 index 0000000..0989da3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/kinect-arm-controller.js @@ -0,0 +1,353 @@ +var five = require("../lib/johnny-five.js"); +/** + * PVector is a slightly-ported version of + * Processing.js's PVector. + */ +var PVector = require("./pvector.js").PVector; +/** + * To run this program you must first install + * libusb and OpenNI... Good luck with that. + * + * Two sets of instructions are available: + * - https://github.com/OpenNI/OpenNI + * - https://code.google.com/p/simple-openni/wiki/Installation + */ +var OpenNI = require("openni"); + +/** + * Skeletons + * @type Array An array of completed skeletons + */ +var Skeletons = []; + +var status = { + true: "IN FRAME", + false: "OUT OF FRAME" +}; + +var board = new five.Board(); + +board.on("ready", function() { + + var servos = { + rotator: new five.Servo({ + pin: 6, + range: [0, 180], + startAt: 90 + }), + upper: new five.Servo({ + pin: 9, + range: [0, 180], + startAt: 180 + }), + fore: new five.Servo({ + pin: 10, + range: [90, 180], + startAt: 90 + }), + }; + + var kinect = new OpenNI(); + + // For each declared Skeleton.Joints, bind + // an event handler to the joint event by name. + Skeleton.Joints.forEach(function(joint) { + // When joint data is received, update the + // associated Skeleton's joints array + // with data for the given joint. + kinect.on(joint, function(id, x, y, z) { + var skeleton, vector; + + skeleton = Skeletons[id]; + + if (skeleton) { + vector = skeleton.joints[joint]; + + if (vector) { + vector.x = x; + vector.y = y; + vector.z = z; + } + } + }); + }); + + Skeleton.Events.forEach(function(type) { + kinect.on(type, function(id) { + var isPresence, skeleton; + + // Limit the number of skeletons to one. + if (id !== 1) { + return; + } + + console.log("%s (%d)", type, id); + + isPresence = ["newuser", "lostuser"].some(function(val) { + return val === type; + }); + + if (isPresence) { + skeleton = Skeletons[id]; + + if (!skeleton) { + skeleton = Skeletons[id] = new Skeleton(); + } + + skeleton.inFrame = type === "newuser" ? + true : false; + + console.log(status[skeleton.inFrame]); + } + }); + }); + + var last = Date.now(); + var interval = 1000 / 30; + var rlow = 0; + var rhigh = 0; + var change = { + rotator: new Change(2), + upper: new Change(2), + fore: new Change(2), + }; + + void (function main() { + setImmediate(main); + + var joints, right, orientation, upper, fore, rotator, axis; + + var now = Date.now(); + + if (now < last + interval) { + return; + } + + last = now; + + var values = { + upper: 0, + fore: 0, + rotator: 0 + }; + + var angles = { + upper: 0, + fore: 0 + }; + + if (Skeletons.length && (joints = Skeletons[1].joints)) { + upper = joints.right_shoulder; + fore = joints.right_elbow; + rotator = joints.right_hand; + axis = joints.right_hip; + + if (upper && fore && rotator && axis) { + + right = { + upper: new PVector(upper.x, upper.y), + fore: new PVector(fore.x, fore.y), + rotator: new PVector(rotator.x, rotator.y), + axis: new PVector(axis.x, axis.y) + }; + + orientation = { + torso: PVector.sub(right.upper, right.axis), + arm: PVector.sub(right.fore, right.upper) + }; + + if (rlow === 0 || rlow > rotator.z) { + rlow = Math.round(rotator.z); + } + + if (rhigh === 0 || rhigh < rotator.z) { + rhigh = Math.round(rotator.z); + } + + angles.upper = Math.round( + angleOf(right.fore, right.upper, orientation.torso) + ); + + angles.fore = Math.round( + angleOf(right.rotator, right.fore, orientation.arm) + ); + + values.upper = scale(angles.upper, 0, 180, 180, 0); + values.fore = scale(angles.fore, 180, 0, 90, 180); + + // When the elbow/hand are higher then the shoulder, + // flip the scaled rotator value. + values.rotator = values.upper < 110 && values.fore > 110 ? + scale(rotator.z, rlow, rhigh, 180, 0) : + scale(rotator.z, rlow, rhigh, 0, 180); + + // Once all of the Kinect joint vectors have been + // calculated and scaled to a value in degrees, + // do a final check to ensure that a move is worth + // making and if so, set the servo position + // + if (change.rotator.isNoticeable(values.rotator)) { + servos.rotator.to(values.rotator); + } + + if (change.upper.isNoticeable(values.upper)) { + servos.upper.to(values.upper); + } + + if (change.fore.isNoticeable(values.fore)) { + servos.fore.to(values.fore); + } + } + } + })(); + // References + // http://www.ranchbots.com/robot_arm/images/arm_diagram.jpg + // https://github.com/OpenNI/OpenNI/blob/master/Include/XnCppWrapper.h + // http://www.mrtmrcn.com/en/post/2011/11/08/Kinect-Part-5-Kinect-Skeleton-Tracking.aspx + // http://code.google.com/p/bikinect/source/browse/trunk/MappInect/Skeleton.pde + // https://github.com/Sensebloom/OSCeleton-examples/blob/master/processing/Stickmanetic/Stickmanetic.pde + // http://www.pcl-users.org/openni-device-h-47-26-fatal-error-XnCppWrapper-h-No-such-file-or-directory-td3174297.html + // http://kinectcar.ronsper.com/docs/openni/_xn_cpp_wrapper_8h_source.html +}); + +/** + * Joint + * @param {Object} initializer { [x, [y, [z]]] } + */ +function Joint(initializer) { + Object.assign(this, Joint.DEFAULTS, initializer || {}); +} + +Object.freeze( + Joint.DEFAULTS = { + x: 0, + y: 0, + z: 0 + } +); +/** + * Skeleton + * + * Initialize a "collection" of Joint objects + * as a cohesive data type + * + * @param {Object} initializer { joints = {} } + */ +function Skeleton(initializer) { + /** + * skeleton { + * joints, kinect + * } + */ + five.Fn.assign( + this, Skeleton.DEFAULTS, initializer || {} + ); + + // Initialize each declared Joint in Skeleton.Joints + Skeleton.Joints.forEach(function(joint) { + this.joints[joint] = new Joint(); + }, this); +} + +Object.freeze( + Skeleton.DEFAULTS = { + inFrame: false, + joints: {} + } +); + +Skeleton.Joints = [ + "head", + "neck", + + "torso", + "waist", + + "left_shoulder", + "left_elbow", + "left_hand", + + "right_shoulder", + "right_elbow", + "right_hand", + + "left_hip", + "left_knee", + "left_foot", + + "right_hip", + "right_knee", + "right_foot" +]; + +Skeleton.Events = [ + "newuser", + "lostuser", + "posedetected", + "calibrationstart", + "calibrationsuccess", + "calibrationfail" +]; + +/** + * Change + * + * Produces change "tracking" instances + * to determine if a given value has changed + * drastically enough + */ +function Change(margin) { + this.last = 0; + this.margin = margin || 0; +} +/** + * isNoticeable + * + * Determine if a given value has changed + * enough to be considered "noticeable". + * + * @param {Number} value [description] + * @param {Number} margin Optionally override the + * change instance's margin + * + * @return {Boolean} returns true if value is different + * enough from the last value + * to be considered "noticeable" + */ +Change.prototype.isNoticeable = function(value, margin) { + margin = margin || this.margin; + + if (!Number.isFinite(value)) { + return false; + } + + if ((value > this.last + margin) || (value < this.last - margin)) { + this.last = value; + return true; + } + return false; +}; + +/** + * scale Alias + */ +var scale = five.Fn.scale; + +/** + * angleOf + * + * Produce the angle of 2 vectors on a given axis. + * + * @param {PVector} vec1 + * @param {PVector} vec2 + * @param {PVector} axis + * + * @return {Number} Radians converted to degrees + */ +function angleOf(vec1, vec2, axis) { + return PVector.degrees( + PVector.between( + PVector.sub(vec2, vec1), axis + ) + ); +} diff --git a/JavaScript/node_modules/johnny-five/eg/laser-trip-wire.js b/JavaScript/node_modules/johnny-five/eg/laser-trip-wire.js new file mode 100644 index 0000000..3c98aed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/laser-trip-wire.js @@ -0,0 +1,22 @@ +var five = require("johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var laser = new five.Led(9); + var detection = new five.Sensor("A0"); + var isSecure = false; + + laser.on(); + + detection.scale(0, 1).on("change", function() { + var reading = !(this.value | 0); + + if (isSecure !== reading) { + isSecure = reading; + + if (!isSecure) { + console.log("Intruder"); + } + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-PCF8574AT.js b/JavaScript/node_modules/johnny-five/eg/lcd-PCF8574AT.js new file mode 100644 index 0000000..676498d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-PCF8574AT.js @@ -0,0 +1,15 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var l = new five.LCD({ + controller: "PCF8574AT" + }); + + l.useChar("heart"); + l.cursor(0, 0).print("hello :heart:"); + l.blink(); + l.cursor(1, 0).print("Blinking? "); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-all.js b/JavaScript/node_modules/johnny-five/eg/lcd-all.js new file mode 100644 index 0000000..f87892e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-all.js @@ -0,0 +1,51 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + + var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase(); + + // Controller: PARALLEL (default) + var p = new five.LCD({ + pins: [8, 9, 4, 5, 6, 7], + backlight: 10, + }); + + p.useChar("heart"); + p.cursor(0, 0).print("hello :heart:"); + p.blink(); + p.cursor(1, 0).print("Blinking? "); + p.cursor(0, 10).print(random); + + + // Controller: JHD1313M1 (Grove) + var j = new five.LCD({ + controller: "JHD1313M1" + }); + + j.useChar("heart"); + j.cursor(0, 0).print("hello :heart:"); + j.blink(); + j.cursor(1, 0).print("Blinking? "); + j.cursor(0, 10).print(random); + + + // Controller: PCF8574A (Generic I2C) + // Locate the controller chip model number on the chip itself. + var l = new five.LCD({ + controller: "PCF8574A" + }); + + l.useChar("heart"); + l.cursor(0, 0).print("hello :heart:"); + l.blink(); + l.cursor(1, 0).print("Blinking? "); + l.cursor(0, 10).print(random); + + + setTimeout(function() { + process.exit(0); + }, 3000); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-enumeratechars.js b/JavaScript/node_modules/johnny-five/eg/lcd-enumeratechars.js new file mode 100644 index 0000000..603df1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-enumeratechars.js @@ -0,0 +1,50 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var lcd = new five.LCD({ + // LCD pin name RS EN DB4 DB5 DB6 DB7 + // Arduino pin # 7 8 9 10 11 12 + pins: [7, 8, 9, 10, 11, 12], + rows: 4, + cols: 20 + }); + + var k = 0; + var i = 0; + var keys = Object.keys(five.LCD.Characters); + var length = keys.length; + var eights = []; + + while (i < length) { + eights.push(keys.slice(i, i + 8)); + i += 8; + } + + console.log("Wait 5 seconds..."); + + this.loop(2000, function() { + var charset = eights[k], + display = ""; + + lcd.clear(); + + if (k < eights.length) { + + charset.forEach(function(char, index) { + lcd.useChar(char); + display += ":" + char + ":"; + }); + + lcd.clear().cursor(0, 0).print(display); + + k++; + } + }); +}); + +// @markdown +// - [16 x 2 LCD White on Blue](http://www.hacktronics.com/LCDs/16-x-2-LCD-White-on-Blue/flypage.tpl.html) +// - [20 x 4 LCD White on Blue](http://www.hacktronics.com/LCDs/20-x-4-LCD-White-on-Blue/flypage.tpl.html) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-i2c-PCF8574.js b/JavaScript/node_modules/johnny-five/eg/lcd-i2c-PCF8574.js new file mode 100644 index 0000000..f87892e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-i2c-PCF8574.js @@ -0,0 +1,51 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + + var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase(); + + // Controller: PARALLEL (default) + var p = new five.LCD({ + pins: [8, 9, 4, 5, 6, 7], + backlight: 10, + }); + + p.useChar("heart"); + p.cursor(0, 0).print("hello :heart:"); + p.blink(); + p.cursor(1, 0).print("Blinking? "); + p.cursor(0, 10).print(random); + + + // Controller: JHD1313M1 (Grove) + var j = new five.LCD({ + controller: "JHD1313M1" + }); + + j.useChar("heart"); + j.cursor(0, 0).print("hello :heart:"); + j.blink(); + j.cursor(1, 0).print("Blinking? "); + j.cursor(0, 10).print(random); + + + // Controller: PCF8574A (Generic I2C) + // Locate the controller chip model number on the chip itself. + var l = new five.LCD({ + controller: "PCF8574A" + }); + + l.useChar("heart"); + l.cursor(0, 0).print("hello :heart:"); + l.blink(); + l.cursor(1, 0).print("Blinking? "); + l.cursor(0, 10).print(random); + + + setTimeout(function() { + process.exit(0); + }, 3000); +}); + diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-i2c-runner.js b/JavaScript/node_modules/johnny-five/eg/lcd-i2c-runner.js new file mode 100644 index 0000000..60e22ff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-i2c-runner.js @@ -0,0 +1,37 @@ +var colors = require("../eg/color-list"); +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var clist = Object.keys(colors); + var clength = clist.length; + var lcd = new five.LCD({ + controller: "JHD1313M1" + }); + + var frame = 1; + var col = 0; + var row = 0; + + lcd.useChar("runninga"); + lcd.useChar("runningb"); + + this.loop(300, function() { + + lcd.clear().cursor(row, col).print( + ":running" + ((frame ^= 1) === 0 ? "a" : "b") + ":" + ); + + if (++col === lcd.cols) { + col = 0; + + if (++row === lcd.rows) { + row = 0; + } + } + }); + + this.loop(1000, function() { + lcd.bgColor(clist[Math.floor(Math.random() * clength)]); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-i2c.js b/JavaScript/node_modules/johnny-five/eg/lcd-i2c.js new file mode 100644 index 0000000..55293e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-i2c.js @@ -0,0 +1,23 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var lcd = new five.LCD({ + controller: "JHD1313M1" + }); + + lcd.useChar("heart"); + + lcd.cursor(0, 0).print("hello :heart:"); + + lcd.blink(); + + lcd.cursor(1, 0).print("Blinking? "); +}); + + +// @markdown +// [Grove - LCD RGB w/ Backlight](http://www.seeedstudio.com/depot/grove-lcd-rgb-backlight-p-1643.html) +//  +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-runner-20x4.js b/JavaScript/node_modules/johnny-five/eg/lcd-runner-20x4.js new file mode 100644 index 0000000..ca4db46 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-runner-20x4.js @@ -0,0 +1,42 @@ +var five = require("../lib/johnny-five"), + board, lcd; + +board = new five.Board(); + +board.on("ready", function() { + + lcd = new five.LCD({ + // LCD pin name RS EN DB4 DB5 DB6 DB7 + // Arduino pin # 7 8 9 10 11 12 + pins: [7, 8, 9, 10, 11, 12], + rows: 4, + cols: 20 + }); + + var frame = 1; + var col = 0; + var row = 0; + + lcd.useChar("runninga"); + lcd.useChar("runningb"); + + board.loop(300, function() { + + lcd.clear().cursor(row, col).print( + ":running" + (++frame % 2 === 0 ? "a" : "b") + ":" + ); + + if (++col === lcd.cols) { + col = 0; + + if (++row === lcd.rows) { + row = 0; + } + } + }); +}); + +// @markdown +// - [16 x 2 LCD White on Blue](http://www.hacktronics.com/LCDs/16-x-2-LCD-White-on-Blue/flypage.tpl.html) +// - [20 x 4 LCD White on Blue](http://www.hacktronics.com/LCDs/20-x-4-LCD-White-on-Blue/flypage.tpl.html) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/lcd-runner.js b/JavaScript/node_modules/johnny-five/eg/lcd-runner.js new file mode 100644 index 0000000..103f22f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd-runner.js @@ -0,0 +1,41 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var lcd = new five.LCD({ + // LCD pin name RS EN DB4 DB5 DB6 DB7 + // Arduino pin # 7 8 9 10 11 12 + pins: [8, 9, 4, 5, 6, 7], + backlight: 10, + rows: 2, + cols: 16 + }); + + var frame = 1; + var col = 0; + var row = 0; + + lcd.display(); + lcd.useChar("runninga"); + lcd.useChar("runningb"); + + this.loop(300, function() { + + lcd.clear().cursor(row, col).print( + ":running" + (++frame % 2 === 0 ? "a" : "b") + ":" + ); + + if (++col === lcd.cols) { + col = 0; + + if (++row === lcd.rows) { + row = 0; + } + } + }); +}); + + +// @device [16 x 2 LCD White on Blue](http://www.hacktronics.com/LCDs/16-x-2-LCD-White-on-Blue/flypage.tpl.html) +// @device [20 x 4 LCD White on Blue](http://www.hacktronics.com/LCDs/20-x-4-LCD-White-on-Blue/flypage.tpl.html) diff --git a/JavaScript/node_modules/johnny-five/eg/lcd.js b/JavaScript/node_modules/johnny-five/eg/lcd.js new file mode 100644 index 0000000..0adbfe8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/lcd.js @@ -0,0 +1,50 @@ +var five = require("../lib/johnny-five"), + board, lcd; + +board = new five.Board(); + +board.on("ready", function() { + + lcd = new five.LCD({ + // LCD pin name RS EN DB4 DB5 DB6 DB7 + // Arduino pin # 7 8 9 10 11 12 + pins: [7, 8, 9, 10, 11, 12], + backlight: 6, + rows: 2, + cols: 20 + + + // Options: + // bitMode: 4 or 8, defaults to 4 + // lines: number of lines, defaults to 2 + // dots: matrix dimensions, defaults to "5x8" + }); + + // Tell the LCD you will use these characters: + lcd.useChar("check"); + lcd.useChar("heart"); + lcd.useChar("duck"); + + // Line 1: Hi rmurphey & hgstrp! + lcd.clear().print("rmurphey, hgstrp"); + lcd.cursor(1, 0); + + // Line 2: I <3 johnny-five + // lcd.print("I").write(7).print(" johnny-five"); + // can now be written as: + lcd.print("I :heart: johnny-five"); + + this.wait(3000, function() { + lcd.clear().cursor(0, 0).print("I :check::heart: 2 :duck: :)"); + }); + + this.repl.inject({ + lcd: lcd + }); +}); + + +// @markdown +// [16 x 2 LCD White on Blue](http://www.hacktronics.com/LCDs/16-x-2-LCD-White-on-Blue/flypage.tpl.html) +// [20 x 4 LCD White on Blue](http://www.hacktronics.com/LCDs/20-x-4-LCD-White-on-Blue/flypage.tpl.html) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/led-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/led-PCA9685.js new file mode 100644 index 0000000..cc51499 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-PCA9685.js @@ -0,0 +1,23 @@ +var five = require("../lib/johnny-five.js"); + +five.Board().on("ready", function() { + var led = new five.Led({ + pin: process.argv[2] || 0, + address: 0x40, + controller: "PCA9685" + }); + + // address: The address of the shield. + // Defaults to 0x40 + // pin: The pin the LED is connected to + // Defaults to 0 + // controller: The type of controller being used. + // Defaults to "standard". + + // Add LED to REPL (optional) + this.repl.inject({ + led: led + }); + + led.pulse(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-analog-pins.js b/JavaScript/node_modules/johnny-five/eg/led-analog-pins.js new file mode 100644 index 0000000..ab25ae1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-analog-pins.js @@ -0,0 +1,8 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var led = new five.Led("A3"); + + led.blink(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-array.js b/JavaScript/node_modules/johnny-five/eg/led-array.js new file mode 100644 index 0000000..49f0a24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-array.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var array = new five.Leds([3, 5, 6]); + + array.pulse(); +}); + +// @markdown +// +// Control multiple LEDs at once by creating an LED collection (`Leds`). +// All must be on PWM pins if you want to use methods such +// as `pulse()` or `fade()` +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/led-blink.js b/JavaScript/node_modules/johnny-five/eg/led-blink.js new file mode 100644 index 0000000..6d1411f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-blink.js @@ -0,0 +1,10 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var led = new five.Led(13); + + // "blink" the led in 500ms on-off phase periods + led.blink(500); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-demo-sequence.js b/JavaScript/node_modules/johnny-five/eg/led-demo-sequence.js new file mode 100644 index 0000000..a0497d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-demo-sequence.js @@ -0,0 +1,85 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); +var led; + +// Do we want the sequence to loop? +var loop = true; + +// Create a simple demo sequece that calls various +// five.Led methods with specified arguments and +// let it run for the given duration (defaults to 3 seconds). +var demoSequence = [{ + method: "pulse", + args: [1000], + duration: 5000 +}, { + method: "strobe", + args: [500], + duration: 3000 +}, { + method: "fadeIn", + args: [ + 2000, + function() { + console.log("fadeIn complete!"); + } + ], + duration: 2500 +}, { + method: "fadeOut", + args: [ + 5000, + function() { + console.log("fadeOut complete!"); + } + ], + duration: 5500 +}, { + method: "brightness", + args: [10], + duration: 3000 +}, { + method: "off" +}]; + + +// Execute a method in the demo sequence +function execute(step) { + + // Grab everything we need for this step + var method = demoSequence[step].method; + var args = demoSequence[step].args; + var duration = demoSequence[step].duration || 3000; + + // Just print out what we're executing + console.log("led." + method + "(" + (args ? args.join() : "") + ")"); + + // Make the actual call to the LED + five.Led.prototype[method].apply(led, args); + + // Increment the step + step++; + + // If we're at the end, start over (loop==true) or exit + if (step === demoSequence.length) { + if (loop) { + step = 0; + } else { + // We're done! + process.exit(0); + } + } + + // Recursively call the next step after specified duration + board.wait(duration, function() { + execute(step); + }); +} + +board.on("ready", function() { + // Defaults to pin 11 (must be PWM) + led = new five.Led(process.argv[2] || 11); + + // Kick off the first step + execute(0); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-digits-clock-arduino.js b/JavaScript/node_modules/johnny-five/eg/led-digits-clock-arduino.js new file mode 100644 index 0000000..9ba7d17 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-digits-clock-arduino.js @@ -0,0 +1,35 @@ +var moment = require("moment"); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var digits = new five.Led.Digits({ + pins: { + data: 2, + cs: 3, + clock: 4, + } + }); + + setInterval(function() { + digits.print(time()); + }, 1000); +}); + +function time() { + /* + The desired display looks something + like these examples: + + 02.25.54 P + 12.30.00 A + + moment.js doesn't have an option for + a single letter meridiem (nor should it, + that would be silly), so we need to + manipulate the string a bit to so that + it the string matches our desired display. + */ + return moment().format("hh.mm.ssA") + .replace(/([AP])M/, " $1"); +} diff --git a/JavaScript/node_modules/johnny-five/eg/led-digits-clock-galileo.js b/JavaScript/node_modules/johnny-five/eg/led-digits-clock-galileo.js new file mode 100644 index 0000000..e858a71 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-digits-clock-galileo.js @@ -0,0 +1,38 @@ +var moment = require("moment"); +var five = require("../lib/johnny-five"); +var Galileo = require("galileo-io"); +var board = new five.Board({ + io: new Galileo() +}); + +board.on("ready", function() { + var digits = new five.Led.Digits({ + pins: { + data: 2, + cs: 3, + clock: 4, + } + }); + + setInterval(function() { + digits.print(time()); + }, 1000); +}); + +function time() { + /* + The desired display looks something + like these examples: + + 02.25.54 P + 12.30.00 A + + moment.js doesn't have an option for + a single letter meridiem (nor should it, + that would be silly), so we need to + manipulate the string a bit to so that + it the string matches our desired display. + */ + return moment().format("hh.mm.ssA") + .replace(/([AP])M/, " $1"); +} diff --git a/JavaScript/node_modules/johnny-five/eg/led-digits-clock.js b/JavaScript/node_modules/johnny-five/eg/led-digits-clock.js new file mode 100644 index 0000000..a8447bb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-digits-clock.js @@ -0,0 +1,44 @@ +var moment = require("moment"); +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var digits = new five.Led.Digits({ + pins: { + data: 2, + cs: 3, + clock: 4, + } + }); + + setInterval(function() { + digits.print(time()); + }, 1000); +}); + +function time() { + /* + The desired display looks something + like these examples: + + 02.25.54 P + 12.30.00 A + + moment.js doesn't have an option for + a single letter meridiem (nor should it, + that would be silly), so we need to + manipulate the string a bit to so that + it the string matches our desired display. + */ + return moment().format("hh.mm.ssA") + .replace(/([AP])M/, " $1"); +} + + +// @markdown +// +// Learn More: +// +// - [JavaScript: A Digital Clock with Johnny-Five](http://bocoup.com/weblog/javascript-arduino-digital-clock-johnny-five/) +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/led-fade-animation.js b/JavaScript/node_modules/johnny-five/eg/led-fade-animation.js new file mode 100644 index 0000000..486e0ca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-fade-animation.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var led = new five.Led(11); + + led.fade({ + easing: "linear", + duration: 1000, + cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1], + keyFrames: [0, 250, 25, 150, 100, 125], + onstop: function() { + console.log("Animation stopped"); + } + }); + + // Toggle the led after 2 seconds (shown in ms) + this.wait(2000, function() { + led.fadeOut(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-fade-callback.js b/JavaScript/node_modules/johnny-five/eg/led-fade-callback.js new file mode 100644 index 0000000..f84e364 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-fade-callback.js @@ -0,0 +1,36 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + // Set up the following PWM pins as LEDs. + // Fade an LED out, and the complete callback will start + // fading the next LED in sequence out, and so on. + // If randomFade is true, then fading will happen in random + // order instead of sequentially. + var leds = new five.Leds([11, 10, 9, 6, 5, 3]); + var timing = 250; + var randomFade = true; + var fadeIndex = 0; + var ledCount = leds.length; + var i; + + function fadeNext() { + var candidateIndex = fadeIndex; + leds[fadeIndex].fadeIn(timing); + + // Determine the next LED to fade + if (randomFade) { + while (candidateIndex === fadeIndex) { + candidateIndex = Math.round(Math.random() * (ledCount - 1)); + } + } else { + candidateIndex = (fadeIndex < ledCount - 1) ? fadeIndex + 1 : 0; + } + fadeIndex = candidateIndex; + + leds[fadeIndex].fadeOut(timing, fadeNext); + } + + leds.on(); + leds[fadeIndex].fadeOut(timing, fadeNext); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-fade.js b/JavaScript/node_modules/johnny-five/eg/led-fade.js new file mode 100644 index 0000000..2a1c3e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-fade.js @@ -0,0 +1,14 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var led = new five.Led(11); + + led.fadeIn(); + + // Toggle the led after 5 seconds (shown in ms) + this.wait(5000, function() { + led.fadeOut(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-16x8.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-16x8.js new file mode 100644 index 0000000..652a658 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-16x8.js @@ -0,0 +1,47 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var open = [ + "0000000000000000", + "0011110000111100", + "0100001001000010", + "1001100110011001", + "1001100110011001", + "0100001001000010", + "0011110000111100", + "0000000000000000", + ]; + + var wink = [ + "0000000000000000", + "0011110000000000", + "0100001000000000", + "1001100111111111", + "1001100111111111", + "0100001000000000", + "0011110000000000", + "0000000000000000", + ]; + + + var matrix = new five.Led.Matrix({ + addresses: [0x70], + controller: "HT16K33", + dims: "8x16", + rotation: 2 + }); + + matrix.draw(open); + + this.repl.inject({ + wink: function() { + matrix.draw(wink); + + setTimeout(function() { + matrix.draw(open); + }, 500); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-chained.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-chained.js new file mode 100644 index 0000000..37c5996 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-chained.js @@ -0,0 +1,49 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var k = 999; + + var matrix = new five.Led.Matrix({ + addresses: [0x70, 0x71], + controller: "HT16K33", + rotation: 3, + devices: 2 + }); + + var button = new five.Button({ + isPullup: true, + pin: 8 + }); + + button.on("press", function() { + increment(); + }); + + increment(); + + function increment() { + display(k); + k++; + } + + function display(value) { + var chars = Array.from(String(value)); + var length = chars.length; + var chunks = []; + + while (chars.length) { + var slice = chars.length >= 2 ? 2 : chars.length; + var lastTwo = chars.slice(-slice); + // console.log(lastTwo.join("")); + chars.length = chars.length - slice; + chunks.push(lastTwo.join("")); + } + + chunks = chunks.reverse(); + + matrix.draw(0, chunks[0]); + matrix.draw(1, chunks[1]); + } +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-dual.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-dual.js new file mode 100644 index 0000000..99987c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33-dual.js @@ -0,0 +1,58 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var k = 999; + + var a = new five.Led.Matrix({ + address: 0x70, + controller: "HT16K33", + rotation: 3, + }); + + var b = new five.Led.Matrix({ + address: 0x71, + controller: "HT16K33", + rotation: 3, + }); + + var order = [a, b]; + + var button = new five.Button({ + isPullup: true, + pin: 8 + }); + + button.on("press", function() { + increment(); + + }); + + increment(); + + function increment() { + display(k); + k++; + } + + function display(value) { + var chars = Array.from(String(value)); + var length = chars.length; + var chunks = []; + + while (chars.length) { + var slice = chars.length >= 2 ? 2 : chars.length; + var lastTwo = chars.slice(-slice); + // console.log(lastTwo.join("")); + chars.length = chars.length - slice; + chunks.push(lastTwo.join("")); + } + + chunks = chunks.reverse(); + + for (var i = 0; i < order.length; i++) { + order[i].draw(chunks[i]); + } + } +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33.js new file mode 100644 index 0000000..2e242eb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-HT16K33.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var heart = [ + "01100110", + "10011001", + "10000001", + "10000001", + "01000010", + "00100100", + "00011000", + "00000000" + ]; + + var matrix = new five.Led.Matrix({ + addresses: [0x70], + controller: "HT16K33", + rotation: 3, + }); + + matrix.clear(); + matrix.draw(heart); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-demo.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-demo.js new file mode 100644 index 0000000..6a27e3f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-demo.js @@ -0,0 +1,117 @@ +var five = require("../lib/johnny-five"); +var temporal = require("temporal"); +var minimist = require("minimist"); +var omits = minimist(process.argv.slice(2)).omit.split(",").map(Number); +var board = new five.Board(); + + +board.on("ready", function() { + + var lc = new five.Led.Matrix({ + pins: { + data: 2, + clock: 3, + cs: 4 + }, + devices: 2 + }); + + lc.on(); + + var delays = [ + // Rows: On, Off + 3000, 3000, + // Columns: On, Off + 6000, 6000, + // All: On, Pulse + 2000, 4000 + ]; + var fns = [ + // function() { + // for (var x = 0; x < 8; x++) { + // for (var y = 0; y < 8; y++) { + // lc.led(0, x, y, 1); + // lc.led(1, x, y, 1); + // } + // } + // }, + // function() { + // for (var x = 0; x < 8; x++) { + // for (var y = 0; y < 8; y++) { + // lc.led(0, x, y, 0); + // lc.led(1, x, y, 0); + // } + // } + // }, + function() { + console.log("Row: 255"); + for (var x = 0; x < 8; x++) { + lc.row(x, 255); + } + }, + function() { + console.log("Row: 0"); + for (var x = 0; x < 8; x++) { + lc.row(x, 0); + } + }, + function() { + console.log("Column: 255"); + for (var y = 0; y < 8; y++) { + lc.column(y, 255); + } + }, + function() { + console.log("Column: 0"); + for (var y = 0; y < 8; y++) { + lc.column(0, y, 0); + lc.column(1, y, 0); + } + }, + function() { + console.log("All on"); + + lc.each(function(addr) { + this.draw(addr, [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]); + }); + }, + function() { + console.log("Pulse"); + + var brightness = 0; + var direction = 1; + + temporal.loop(25, function() { + brightness += direction * 20; + lc.brightness(brightness); + + // console.log( "Call #%d set brightness to: %d", this.called, brightness ); + + if (brightness === 100 || !brightness) { + direction = !brightness ? 1 : -1; + } + + if (this.called === 25) { + lc.brightness(100); + this.stop(); + demo(); + } + }); + }, + ]; + + function demo() { + temporal.queue( + fns.map(function(task, index) { + return { + delay: delays[index], + task: task + }; + }).filter(function(_, i) { + return omits.indexOf(i) === -1; + }) + ); + } + + demo(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix-tutorial.js b/JavaScript/node_modules/johnny-five/eg/led-matrix-tutorial.js new file mode 100644 index 0000000..ad187ba --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix-tutorial.js @@ -0,0 +1,108 @@ +var temporal = require("temporal"); +var readline = require("readline"); +var five = require("../lib/johnny-five"); +var board = new five.Board({ + repl: false +}); + +var CHARS = five.LedControl.MATRIX_CHARS; + +board.on("ready", function() { + var canWink = true; + var output = ""; + var index = 0; + + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + + var display = new five.Led.Matrix({ + pins: { + data: 2, + cs: 3, + clock: 4, + }, + devices: 2 + }); + + display.on(0); + display.on(1); + + function draw() { + if (output.length) { + + if (CHARS[output]) { + display.draw(0, CHARS[output]); + + output = 0; + index = 0; + } else { + display.draw(0, output[index++]); + } + + // Reached the end? + if (index === output.length) { + setTimeout(function() { + canWink = true; + }, 100); + index = 0; + return; + } + + setTimeout(draw, 500); + } + } + + + function winker() { + var a = [0, 102, 102, 102, 0, 129, 66, 60]; + var b = [0, 96, 96, 102, 0, 129, 66, 60]; + + if (canWink) { + display.draw(1, a); + } + + temporal.queue([{ + delay: 50, + task: function() { + if (canWink) { + display.draw(1, b); + } + } + }, { + delay: 50, + task: function() { + if (canWink) { + display.draw(1, a); + } + } + }, { + delay: 50, + task: function() { + if (canWink) { + display.draw(1, b); + } + } + }, { + delay: 50, + task: function() { + if (canWink) { + display.draw(1, a); + } + temporal.wait(4000, winker); + } + }]); + } + + winker(); + + rl.prompt(); + rl.on("line", function(text) { + output = text; + canWink = false; + rl.prompt(); + draw(); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-matrix.js b/JavaScript/node_modules/johnny-five/eg/led-matrix.js new file mode 100644 index 0000000..15aa4cc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-matrix.js @@ -0,0 +1,49 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var heart = [ + "01100110", + "10011001", + "10000001", + "10000001", + "01000010", + "00100100", + "00011000", + "00000000" + ]; + + var matrix = new five.Led.Matrix({ + pins: { + data: 2, + clock: 3, + cs: 4 + } + }); + + matrix.on(); + + var msg = "johnny-five".split(""); + + // Display each letter for 1 second + function next() { + var c; + + if (c = msg.shift()) { + matrix.draw(c); + setTimeout(next, 1000); + } + } + + next(); + + this.repl.inject({ + matrix: matrix, + // Type "heart()" in the REPL to + // display a heart! + heart: function() { + matrix.draw(heart); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-pulse-animation.js b/JavaScript/node_modules/johnny-five/eg/led-pulse-animation.js new file mode 100644 index 0000000..a28f2cf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-pulse-animation.js @@ -0,0 +1,31 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a standard `led` component + // on a valid pwm pin + var led = new five.Led(11); + + // Instead of passing a time and rate, you can + // pass any valid Animation() segment opts object + // https://github.com/rwaldron/johnny-five/wiki/Animation#segment-properties + led.pulse({ + easing: "linear", + duration: 3000, + cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1], + keyFrames: [0, 10, 0, 50, 0, 255], + onstop: function() { + console.log("Animation stopped"); + } + }); + + // Stop and turn off the led pulse loop after + // 12 seconds (shown in ms) + this.wait(12000, function() { + + // stop() terminates the interval + // off() shuts the led off + led.stop().off(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-pulse.js b/JavaScript/node_modules/johnny-five/eg/led-pulse.js new file mode 100644 index 0000000..07392ff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-pulse.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a standard `led` component + // on a valid pwm pin + var led = new five.Led(11); + + led.pulse(); + + // Stop and turn off the led pulse loop after + // 10 seconds (shown in ms) + this.wait(10000, function() { + + // stop() terminates the interval + // off() shuts the led off + led.stop().off(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-rainbow.js b/JavaScript/node_modules/johnny-five/eg/led-rainbow.js new file mode 100644 index 0000000..db0a7fe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rainbow.js @@ -0,0 +1,15 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var rgb = new five.Led.RGB([6, 5, 3]); + var rainbow = ["FF0000", "FF7F00", "00FF00", "FFFF00", "0000FF", "4B0082", "8F00FF"]; + var index = 0; + + setInterval(function() { + if (index + 1 === rainbow.length) { + index = 0; + } + rgb.color(rainbow[index++]); + }, 500); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-rgb-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/led-rgb-PCA9685.js new file mode 100644 index 0000000..b275348 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rgb-PCA9685.js @@ -0,0 +1,34 @@ +var five = require("../lib/johnny-five.js"); + + +five.Board().on("ready", function() { + + // Initialize the RGB LED + var led = new five.Led.RGB({ + pins: { + red: 2, + green: 1, + blue: 0 + }, + controller: "PCA9685" + }); + + // RGB LED alternate constructor + // This will normalize an array of pins in [r, g, b] + // order to an object (like above) that's shaped like: + // { + // red: r, + // green: g, + // blue: b + // } + // var led = new five.Led.RGB({ + // pins: [2, 1, 0], + // controller: "PCA9685" + // }); + + // Add led to REPL (optional) + this.repl.inject({ + led: led + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-rgb-anode-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/led-rgb-anode-PCA9685.js new file mode 100644 index 0000000..7a85371 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rgb-anode-PCA9685.js @@ -0,0 +1,42 @@ +var five = require("../lib/johnny-five.js"); + + +five.Board().on("ready", function() { + + // Initialize the RGB LED + var led = new five.Led.RGB({ + pins: { + red: 2, + green: 1, + blue: 0 + }, + isAnode: true, + controller: "PCA9685" + }); + + // RGB LED alternate constructor + // This will normalize an array of pins in [r, g, b] + // order to an object (like above) that's shaped like: + // { + // red: r, + // green: g, + // blue: b + // } + // var led = new five.Led.RGB({ + // pins: [2, 1, 0], + // isAnode: true, + // controller: "PCA9685" + // }); + + // Add led to REPL (optional) + this.repl.inject({ + led: led + }); + + // Turn it on and set the initial color + led.on(); + led.color("#FF0000"); + + led.blink(1000); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-rgb-anode.js b/JavaScript/node_modules/johnny-five/eg/led-rgb-anode.js new file mode 100644 index 0000000..3e43696 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rgb-anode.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var anode = new five.Led.RGB({ + pins: { + red: 6, + green: 5, + blue: 3 + }, + isAnode: true + }); + + // Add led to REPL (optional) + this.repl.inject({ + anode: anode + }); + + // Turn it on and set the initial color + anode.on(); + anode.color("#FF0000"); + + anode.blink(1000); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-rgb-intensity.js b/JavaScript/node_modules/johnny-five/eg/led-rgb-intensity.js new file mode 100644 index 0000000..63032a7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rgb-intensity.js @@ -0,0 +1,34 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Initialize the RGB LED + var led = new five.Led.RGB([6,5,3]); + + // Set to full intensity red + console.log("100% red"); + led.color("#FF0000"); + + + // After 3 seconds, dim to 30% intensity + setTimeout(function() { + console.log("30% red"); + led.intensity(30); + + // 3 secs then turn blue, still 30% intensity + setTimeout(function() { + console.log("30% blue"); + led.color("#0000FF"); + + // Another 3 seconds, go full intensity blue + setTimeout(function() { + console.log("100% blue"); + led.intensity(100); + }, 3000); + + }, 3000); + + }, 3000); + +}); \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/eg/led-rgb.js b/JavaScript/node_modules/johnny-five/eg/led-rgb.js new file mode 100644 index 0000000..e45ee7e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-rgb.js @@ -0,0 +1,36 @@ +var five = require("../lib/johnny-five.js"); + + +five.Board().on("ready", function() { + + // Initialize the RGB LED + var led = new five.Led.RGB({ + pins: { + red: 6, + green: 5, + blue: 3 + } + }); + + // RGB LED alternate constructor + // This will normalize an array of pins in [r, g, b] + // order to an object (like above) that's shaped like: + // { + // red: r, + // green: g, + // blue: b + // } + //var led = new five.Led.RGB([3,5,6]); + + // Add led to REPL (optional) + this.repl.inject({ + led: led + }); + + // Turn it on and set the initial color + led.on(); + led.color("#FF0000"); + + led.blink(1000); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-slider.js b/JavaScript/node_modules/johnny-five/eg/led-slider.js new file mode 100644 index 0000000..a652283 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-slider.js @@ -0,0 +1,13 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var slider = new five.Sensor("A0"); + var led = new five.Led(11); + + // Scale the sensor's value to the LED's brightness range + slider.scale([0, 255]).on("data", function() { + led.brightness(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led-status.js b/JavaScript/node_modules/johnny-five/eg/led-status.js new file mode 100644 index 0000000..e3efc70 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led-status.js @@ -0,0 +1,58 @@ +// +// Simple demonstration of Led.value, Led.mode, +// Led.isOn, and Led.isRunning following a variety +// of Led method calls. +// +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + // Default to pin 11 (must be PWM) + var led = new five.Led(process.argv[2] || 11); + + this.repl.inject({ + led: led + }); + + // Print defaut status + console.log("default status"); + status(); + + // Turn LED on and print status + console.log("led.on()"); + led.on(); + status(); + + // Start blink and print status + console.log("led.blink()"); + led.blink(); + status(); + led.stop(); + + // Set brightness and print status + console.log("led.brightness(25)"); + led.brightness(25); + status(); + + // Start pulse and print status + console.log("led.pulse(500)"); + led.pulse(500); + status(); + + // Wait 3 seconds, stop, and print status + this.wait(3000, function() { + console.log("led.stop()"); + led.stop(); + // Note that value/isOn will reflect the state of + // the pulse when stop() was called. + status(); + }); + + function status() { + console.log("led.value = %d", led.value); // print analog brightness of LED + console.log("led.mode = %d", led.mode); // print the pin mode (1 is OUTPUT, 3 is PWM) + console.log("led.isOn = %s", led.isOn); // print if the LED is on + console.log("led.isRunning = %s", led.isRunning); // print if animation currently running + console.log(""); + } +}); diff --git a/JavaScript/node_modules/johnny-five/eg/led.js b/JavaScript/node_modules/johnny-five/eg/led.js new file mode 100644 index 0000000..40a7211 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/led.js @@ -0,0 +1,29 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var led = new five.Led(13); + + // This will grant access to the led instance + // from within the REPL that's created when + // running this program. + this.repl.inject({ + led: led + }); + + led.blink(); +}); + +// @markdown +// This script will make `led` available in the REPL, by default on pin 13. +// Now you can try, e.g.: +// +// ```js +// >> led.stop() // to stop blinking +// // then +// >> led.off() // to shut it off (stop doesn't mean "off") +// // then +// >> led.on() // to turn on, but not blink +// ``` +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/line-follower.js b/JavaScript/node_modules/johnny-five/eg/line-follower.js new file mode 100644 index 0000000..ea1e33d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/line-follower.js @@ -0,0 +1,189 @@ +// This is an example of a line following robot. It uses a +// Pololu QTR-8A reflectance array to read a line on my +// counter drawn with electrical tape. You can see the +// bot in action here: https://www.youtube.com/watch?v=i6n4CwqQer0 + +var fs = require("fs"), + five = require("johnny-five"), + ReflectArray = require("./reflect.array"), + board = new five.Board(); + +// Setup Standard input. We use this to let the bot know that we"ve finished +// calibrating +var stdin = process.stdin; +stdin.setRawMode(true); +stdin.resume(); + +var calibrationFile = ".calibration"; + +// VERY simple driving rules. It uses a mapping from the line value that comes +// from the Reflectance Array to the left and right wheel of the bot. +// This can be made much better, but it is a good start. +var drivingRules = { + 0: { + left: { + dir: "cw", + speed: 0.01 + }, + right: { + dir: "ccw", + speed: 0.07 + } + }, + + 1000: { + left: { + dir: "cw", + speed: 0.02 + }, + right: { + dir: "ccw", + speed: 0.05 + } + }, + + 2000: { + left: { + dir: "cw", + speed: 0.04 + }, + right: { + dir: "ccw", + speed: 0.05 + } + }, + + 2500: { + left: { + dir: "cw", + speed: 0.05 + }, + right: { + dir: "ccw", + speed: 0.05 + } + }, + + 3000: { + left: { + dir: "cw", + speed: 0.05 + }, + right: { + dir: "ccw", + speed: 0.04 + } + }, + + 4000: { + left: { + dir: "cw", + speed: 0.05 + }, + right: { + dir: "ccw", + speed: 0.02 + } + }, + + 5001: { + left: { + dir: "cw", + speed: 0.07 + }, + right: { + dir: "ccw", + speed: 0.01 + } + } +}; + +board.on("ready", function() { + + // Create an instance of the reflectance array. + var eyes = new five.IR.Reflect.Array({ + emitter: 13, + pins: ["A0", "A1", "A2", "A3", "A4", "A5"], + freq: 20 + }); + + // These are the continuous servos that control the wheels + var wheels = { + left: new five.Servo({ + pin: 10, + type: "continuous" + }), + right: new five.Servo({ + pin: 9, + type: "continuous" + }) + }; + + // Make the eyes and wheels available in the REPL UI + this.repl.inject({ + eyes: eyes, + wheels: wheels + }); + + // When the bot starts up, enable the IR emitters and tell the wheels + // to stop. Calibrate the device. When complete, drive. + function init() { + eyes.enable(); + wheels.left.stop(); + wheels.right.stop(); + + calibrate(drive); + } + + // Calibrate the bot. If the calibration has been persisted, use it. + // If not, calibrate the bot until the user presses a key. Move the sensor + // over light and dark regions several times. Persist the calibration data + // to a file so it doesn"t need to do it again next time. + function calibrate(whenComplete) { + var savedCalibration, calibrating = true; + + if (fs.existsSync(calibrationFile)) { + eyes.loadCalibration(JSON.parse(fs.readFileSync(calibrationFile))); + whenComplete(); + return; + } + + console.log("Calibrating. Press a key..."); + + eyes.calibrateUntil(function() { + return !calibrating; + }); + + stdin.once("keypress", function() { + calibrating = false; + console.log("Done:", eyes.calibration); + fs.writeFile(calibrationFile, JSON.stringify(eyes.calibration)); + whenComplete(); + }); + } + + // Drive the bot. Every time a line value event comes in, figure out which + // rule to follow from the rules mapping. Tell the left and right wheels + // which direction and how fast to spin. + function drive() { + eyes.on("line", function(err, line) { + var rule; + var threshold = Object.keys(drivingRules).find(function(r) { + return line <= parseInt(r); + }); + + if (!threshold) { + console.log("Could not find threshold for " + line); + } + + rule = drivingRules[threshold]; + + wheels.left[rule.left.dir](rule.left.speed); + wheels.right[rule.right.dir](rule.right.speed); + }); + } + + // Start the bot + init(); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/line-reflection-follower.js b/JavaScript/node_modules/johnny-five/eg/line-reflection-follower.js new file mode 100644 index 0000000..c4d075a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/line-reflection-follower.js @@ -0,0 +1,208 @@ +var PID = require("../lib/pid"); +var Barcli = require("barcli"); +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + + +board.on("ready", function() { + var r = new Barcli({label: "R", range: [0, 100]}); + var l = new Barcli({label: "L", range: [0, 100]}); + var i = new Barcli({label: "I", range: [0, 100]}); + + + var tank = new Tank(); + + + // var speed = new PID({ + // kp: 1, ki: 0.25, kd: 0.25, range: [5, 65] + // }); + var reflected = new five.Light({ + controller: "EVS_EV3", + mode: "reflected", + pin: "BAS1" + }); + + var Tp = 50; + var offset = 45; + + var white = 40; + var black = 20; + var midpoint = ((white - black) / 2) + black; + + + // var kp = 1, ki = 1, kd = 1; + // var lasterror = 0; + // var integral = 0; + // var derivative = 0; + + + var kp = 3, ki = 1, kd = 1; + var lasterror = 0; + var integral = 0; + var derivative = 0; + + reflected.on("change", function() { + console.log(this.level); + + i.update(this.level); + + + var value = this.level; + var error = midpoint - value; + + // var correction = kp * (midpoint - value); + // var right = Tp + correction; + // var left = Tp - correction; + + integral = error + integral; + derivative = error - lasterror; + + var correction = (kp * error + ki * integral + kd * derivative) | 0; + + var right = Tp + correction; + var left = Tp - correction; + + // console.log(error); + + // console.log("Right: ", speed + correction); + // console.log("Left: ", speed - correction); + // var Turn = kp * error; + + // var right = Tp + Turn; + // var left = Tp - Turn; + + // console.log("Right: ", right); + // console.log("Left: ", left); + // console.log("Right: ", right); + // console.log("Left: ", left); + + tank.fwd(right, left); + // lasterror = error; + + + r.update(right); + l.update(left); + + + + + + + + // var value = this.level; + // var error = midpoint - value; + + // integral = error + integral; + // derivative = error - lasterror; + + // var correction = (kp * error + ki * integral + kd * derivative) | 0; + + + // // console.log(error); + + // // console.log("Right: ", speed + correction); + // // console.log("Left: ", speed - correction); + + // var right = five.Fn.constrain(speed + correction, 30, 60); + // var left = five.Fn.constrain(speed - correction, 30, 60); + + // console.log("Right: ", speed + correction, right); + // console.log("Left: ", speed - correction, left); + // // console.log("Right: ", right); + // // console.log("Left: ", left); + + // tank.fwd(right, left); + // lasterror = error; + + // if (five.Color.hexCode(this.rgb) !== "000000") { + // console.log("Off the line"); + + // if (!tank.isLooking) { + // tank.stop(); + // tank.findLine(reflected); + // } + // } else { + // console.log("On the line, Proceed."); + // tank.fwd(); + // } + }); +}); + +function Tank() { + this.isLooking = false; + this.motors = new five.Motors([ + { controller: "EVS_EV3", pin: "BAM1" }, + { controller: "EVS_EV3", pin: "BBM1" }, + ]); +} + +// Tank.DIRECTIONS = ["fwd", "left", "right", "rev"]; + +Tank.prototype.speed = function(speed) { + return speed !== undefined ? speed : 100; +}; + +Tank.prototype.fwd = function(right, left) { + this.motors[0].rev(right); + this.motors[1].rev(left); +}; + +// Tank.prototype.rev = function(speed) { +// this.motors.fwd(this.speed(speed)); +// }; + +// Tank.prototype.right = function(speed) { +// this.motors[0].fwd(this.speed(speed)); +// this.motors[1].rev(this.speed(speed)); +// }; + +// Tank.prototype.left = function(speed) { +// this.motors[0].rev(this.speed(speed)); +// this.motors[1].fwd(this.speed(speed)); +// }; + +// Tank.prototype.stop = function() { +// this.motors.stop(); +// }; + +// Tank.prototype.findLine = function(source, attempt) { +// var timer; +// var direction; + +// if (attempt === undefined) { +// attempt = 0; +// } else { +// attempt++; +// } + +// if (attempt && this.isLooking === false) { +// return; +// } + +// if (attempt === 9) { +// this.isLooking = false; +// return; +// } + +// direction = Tank.DIRECTIONS[Math.random() * 4 | 0]; + +// if (attempt === 0 && direction === "fwd") { +// process.nextTick(this.findLine.bind(this, source)); +// return; +// } + +// this.isLooking = true; +// this[direction](); + +// if (source) { +// source.once("change", function() { +// clearTimeout(timer); +// this.isLooking = false; +// }.bind(this)); +// } + +// timer = setTimeout(function() { +// this.stop(); +// this.findLine(source, attempt); +// }.bind(this), 2000); +// }; diff --git a/JavaScript/node_modules/johnny-five/eg/linefollower.js b/JavaScript/node_modules/johnny-five/eg/linefollower.js new file mode 100644 index 0000000..4ab6ffa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/linefollower.js @@ -0,0 +1,102 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var tank = new Tank(); + var color = new five.Color({ + controller: "EVS_EV3", + pin: "BAS1" + }); + + color.on("change", function() { + if (five.Color.hexCode(this.rgb) !== "000000") { + console.log("Off the line"); + + if (!tank.isLooking) { + tank.stop(); + tank.findLine(color); + } + } else { + console.log("On the line, Proceed."); + tank.fwd(); + } + }); +}); + +function Tank() { + this.isLooking = false; + this.motors = new five.Motors([ + { controller: "EVS_EV3", pin: "BAM1" }, + { controller: "EVS_EV3", pin: "BBM1" }, + ]); +} + +Tank.DIRECTIONS = ["fwd", "left", "right", "rev"]; + +Tank.prototype.speed = function(speed) { + return speed !== undefined ? speed : 100; +}; + +Tank.prototype.fwd = function(speed) { + this.motors.rev(this.speed(speed)); +}; + +Tank.prototype.rev = function(speed) { + this.motors.fwd(this.speed(speed)); +}; + +Tank.prototype.right = function(speed) { + this.motors[0].fwd(this.speed(speed)); + this.motors[1].rev(this.speed(speed)); +}; + +Tank.prototype.left = function(speed) { + this.motors[0].rev(this.speed(speed)); + this.motors[1].fwd(this.speed(speed)); +}; + +Tank.prototype.stop = function() { + this.motors.stop(); +}; + +Tank.prototype.findLine = function(source, attempt) { + var timer; + var direction; + + if (attempt === undefined) { + attempt = 0; + } else { + attempt++; + } + + if (attempt && this.isLooking === false) { + return; + } + + if (attempt === 9) { + this.isLooking = false; + return; + } + + direction = Tank.DIRECTIONS[Math.random() * 4 | 0]; + + if (attempt === 0 && direction === "fwd") { + process.nextTick(this.findLine.bind(this, source)); + return; + } + + this.isLooking = true; + this[direction](); + + if (source) { + source.once("change", function() { + clearTimeout(timer); + this.isLooking = false; + }.bind(this)); + } + + timer = setTimeout(function() { + this.stop(); + this.findLine(source, attempt); + }.bind(this), 2000); +}; diff --git a/JavaScript/node_modules/johnny-five/eg/magnetometer-log.js b/JavaScript/node_modules/johnny-five/eg/magnetometer-log.js new file mode 100644 index 0000000..1a6bcab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/magnetometer-log.js @@ -0,0 +1,115 @@ +var chalk = require("chalk"), + five = require("../lib/johnny-five.js"), + board, colors, servo, mag, count, dirs, lock; + +(board = new five.Board()).on("ready", function() { + + count = -1; + dirs = ["cw", "ccw"]; + lock = false; + + [ + // Medium Speed Counter Clock Wise + [92, "ccw"], + // Medium Speed Clock Wise + [88, "cw"] + + ].forEach(function(def) { + + // Define a directional method and default speed + five.Servo.prototype[def[1]] = function(speed) { + speed = speed || def[0]; + + this.move(speed); + }; + }); + + + // Create a new `servo` hardware instance. + servo = new five.Servo({ + pin: 9, + // `type` defaults to standard servo. + // For continuous rotation servos, override the default + // by setting the `type` here + type: "continuous" + }); + + + // Create an I2C `Magnetometer` instance + mag = new five.Magnetometer(); + + // Inject the servo and magnometer into the REPL + this.repl.inject({ + servo: servo, + mag: mag + }); + + // set the continuous servo to stopped + servo.move(90); + + // As the heading changes, log heading value + mag.on("headingchange", function() { + var log; + var color = colors[this.bearing.abbr]; + + log = (this.bearing.name + " " + Math.floor(this.heading) + "°"); + + console.log( + chalk[color](log) + ); + + + + if (!lock && this.bearing.name === "North") { + // Set redirection lock + lock = true; + + // Redirect + servo[dirs[++count % 2]](); + + // Release redirection lock + board.wait(2000, function() { + lock = false; + }); + } + }); + + this.wait(2000, function() { + servo[dirs[++count % 2]](); + }); + }); + +colors = { + N: "red", + NbE: "red", + NNE: "red", + NEbN: "red", + NE: "yellow", + NEbE: "yellow", + ENE: "yellow", + EbN: "yellow", + E: "green", + EbS: "green", + ESE: "green", + SEbE: "green", + SE: "green", + SEbS: "cyan", + SSE: "cyan", + SbE: "cyan", + S: "cyan", + SbW: "cyan", + SSW: "cyan", + SWbS: "blue", + SW: "blue", + SWbW: "blue", + WSW: "blue", + WbS: "blue", + W: "magenta", + WbN: "magenta", + WNW: "magenta", + NWbW: "magenta", + NW: "magenta", + NWbN: "magenta", + NNW: "magenta", + NbW: "red" +}; diff --git a/JavaScript/node_modules/johnny-five/eg/magnetometer-north.js b/JavaScript/node_modules/johnny-five/eg/magnetometer-north.js new file mode 100644 index 0000000..c6a0a4f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/magnetometer-north.js @@ -0,0 +1,76 @@ +var chalk = require("chalk"), + five = require("../lib/johnny-five.js"), + board, servo, mag, count, dirs, isNorth, isSeeking, last; + +board = new five.Board(); + +board.on("ready", function() { + + count = -1; + dirs = ["cw", "ccw"]; + isNorth = false; + isSeeking = false; + + [ + [95, "ccw"], + [85, "cw"] + + ].forEach(function(def) { + five.Servo.prototype[def[1]] = function() { + this.to(def[0]); + }; + }); + + + // Create a new `servo` hardware instance. + servo = new five.Servo({ + pin: 9, + // `type` defaults to standard servo. + // For continuous rotation servos, override the default + // by setting the `type` here + type: "continuous" + }); + + + // Create an I2C `Magnetometer` instance + mag = new five.Magnetometer(); + + this.repl.inject({ + servo: servo, + mag: mag + }); + + // set the continuous servo to stopped + servo.to(90); + + // As the heading changes, log heading value + mag.on("data", function() { + var heading = Math.floor(this.heading); + + if (heading > 345 || heading < 15) { + + if (!isNorth) { + console.log("FOUND north!".yellow); + isSeeking = false; + } + + isNorth = true; + servo.stop(); + + } else { + isNorth = false; + + if (!isSeeking) { + console.log(chalk.red("find north!"), heading); + isSeeking = true; + } + + + if (heading < 270) { + servo.ccw(); + } else { + servo.cw(); + } + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/magnetometer.js b/JavaScript/node_modules/johnny-five/eg/magnetometer.js new file mode 100644 index 0000000..f361961 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/magnetometer.js @@ -0,0 +1,59 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `Magnetometer` hardware instance. + // + // five.Magnetometer(); + // + // (Alias of: + // new five.Compass({ + // controller: "HMC5883L", + // freq: 50, + // gauss: 1.3 + // }); + // ) + // + + var magnetometer = new five.Magnetometer(); + + + // Properties + + // mag.raw + // + // x, y, z + // + + // mag.scaled + // + // axis x, y, z + // + // based on value stored at (mag.scale) + // + + // mag.heading + // + // Calculated heading in degrees (calibrated for magnetic north) + // + + // mag.bearing + // + // Bearing data object + // + + + // Magnetometer Event API + + // "headingchange" + // + // Fires when the calculated heading has changed + // + magnetometer.on("headingchange", function() { + + console.log("heading", Math.floor(this.heading)); + // console.log("bearing", this.bearing); + + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/matrix-display-number.js b/JavaScript/node_modules/johnny-five/eg/matrix-display-number.js new file mode 100644 index 0000000..15aa4cc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/matrix-display-number.js @@ -0,0 +1,49 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var heart = [ + "01100110", + "10011001", + "10000001", + "10000001", + "01000010", + "00100100", + "00011000", + "00000000" + ]; + + var matrix = new five.Led.Matrix({ + pins: { + data: 2, + clock: 3, + cs: 4 + } + }); + + matrix.on(); + + var msg = "johnny-five".split(""); + + // Display each letter for 1 second + function next() { + var c; + + if (c = msg.shift()) { + matrix.draw(c); + setTimeout(next, 1000); + } + } + + next(); + + this.repl.inject({ + matrix: matrix, + // Type "heart()" in the REPL to + // display a heart! + heart: function() { + matrix.draw(heart); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/matrix-number-display.js b/JavaScript/node_modules/johnny-five/eg/matrix-number-display.js new file mode 100644 index 0000000..63e2e2c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/matrix-number-display.js @@ -0,0 +1,28 @@ +var five = require("../"); +var board = new five.Board(); + + + +board.on("ready", function() { + var votes = 5; + + var bumper = new five.Button({ + isPullup: true, + pin: 8 + }); + var matrix = new five.Led.Matrix({ + pins: { + data: 2, + clock: 3, + cs: 4 + } + }); + + matrix.clear().draw(votes); + + bumper.on("hit", function() { + votes++; + + matrix.draw(votes); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/microphone.js b/JavaScript/node_modules/johnny-five/eg/microphone.js new file mode 100644 index 0000000..af519cf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/microphone.js @@ -0,0 +1,11 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + var mic = new five.Sensor("A0"); + var led = new five.Led(11); + + mic.on("data", function() { + led.brightness(this.value >> 2); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A51SK0F.js b/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A51SK0F.js new file mode 100644 index 0000000..d708d18 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A51SK0F.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion({ + controller: "GP2Y0A51SK0F", + pin: "A0" + }); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A60SZLF.js b/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A60SZLF.js new file mode 100644 index 0000000..694128b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion-GP2Y0A60SZLF.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion({ + controller: "GP2Y0A60SZLF", + pin: "A0" + }); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d805z0f.js b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d805z0f.js new file mode 100644 index 0000000..d7b03d4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d805z0f.js @@ -0,0 +1,34 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion({ + controller: "GP2Y0D805Z0F" + }); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); + + // "data" events are fired at the interval set in opts.freq + // or every 25ms. Uncomment the following to see all + // motion detection readings. + // motion.on("data", function(data) { + // console.log(data); + // }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d810z0f.js b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d810z0f.js new file mode 100644 index 0000000..4be3806 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d810z0f.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion({ + controller: "GP2Y0D810Z0F", + pin: "A0" + }); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d815z0f.js b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d815z0f.js new file mode 100644 index 0000000..4be3806 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion-gp2y0d815z0f.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion({ + controller: "GP2Y0D810Z0F", + pin: "A0" + }); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motion.js b/JavaScript/node_modules/johnny-five/eg/motion.js new file mode 100644 index 0000000..cc51919 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motion.js @@ -0,0 +1,32 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `motion` hardware instance. + var motion = new five.Motion(7); + + // "calibrated" occurs once, at the beginning of a session, + motion.on("calibrated", function() { + console.log("calibrated"); + }); + + // "motionstart" events are fired when the "calibrated" + // proximal area is disrupted, generally by some form of movement + motion.on("motionstart", function() { + console.log("motionstart"); + }); + + // "motionend" events are fired following a "motionstart" event + // when no movement has occurred in X ms + motion.on("motionend", function() { + console.log("motionend"); + }); + + // "data" events are fired at the interval set in opts.freq + // or every 25ms. Uncomment the following to see all + // motion detection readings. + // motion.on("data", function(data) { + // console.log(data); + // }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motobot.js b/JavaScript/node_modules/johnny-five/eg/motobot.js new file mode 100644 index 0000000..e1bc95f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motobot.js @@ -0,0 +1,67 @@ +var five = require("../lib/johnny-five.js"); +var keypress = require("keypress"); +var board = new five.Board(); + + +board.on("ready", function() { + var speed, commands, motors; + + speed = 100; + commands = null; + motors = { + a: new five.Motor([3, 12]), + b: new five.Motor([11, 13]) + }; + + this.repl.inject({ + motors: motors + }); + + function controller(ch, key) { + if (key) { + if (key.name === "space") { + motors.a.stop(); + motors.b.stop(); + } + if (key.name === "up") { + motors.a.rev(speed); + motors.b.fwd(speed); + } + if (key.name === "down") { + motors.a.fwd(speed); + motors.b.rev(speed); + } + if (key.name === "right") { + motors.a.fwd(speed * 0.75); + motors.b.fwd(speed * 0.75); + } + if (key.name === "left") { + motors.a.rev(speed * 0.75); + motors.b.rev(speed * 0.75); + } + + commands = [].slice.call(arguments); + } else { + if (ch >= 1 && ch <= 9) { + speed = five.Fn.scale(ch, 1, 9, 0, 255); + controller.apply(null, commands); + } + } + } + + + keypress(process.stdin); + + process.stdin.on("keypress", controller); + process.stdin.setRawMode(true); + process.stdin.resume(); +}); + +// @markdown +// +//  +// +//  +// +// @markdown + diff --git a/JavaScript/node_modules/johnny-five/eg/motor-3-pin.js b/JavaScript/node_modules/johnny-five/eg/motor-3-pin.js new file mode 100644 index 0000000..5a1a90d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-3-pin.js @@ -0,0 +1,81 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var motor; + /* + Seeed Studio Motor Shield V1.0, V2.0 + Motor A + pwm: 9 + dir: 8 + cdir: 11 + + Motor B + pwm: 10 + dir: 12 + cdir: 13 + + Freetronics Motor Shield + Motor A + pwm: 6 + dir: 5 + cdir: 7 + + Motor B + pwm: 4 + dir: 3 + cdir: 2 + + */ + + + motor = new five.Motor({ + pins: { + pwm: 9, + dir: 8, + cdir: 11 + } + }); + + + + + board.repl.inject({ + motor: motor + }); + + motor.on("start", function(err, timestamp) { + console.log("start", timestamp); + }); + + motor.on("stop", function(err, timestamp) { + console.log("automated stop on timer", timestamp); + }); + + motor.on("brake", function(err, timestamp) { + console.log("automated brake on timer", timestamp); + }); + + motor.on("forward", function(err, timestamp) { + console.log("forward", timestamp); + + // demonstrate switching to reverse after 5 seconds + board.wait(5000, function() { + motor.reverse(255); + }); + }); + + motor.on("reverse", function(err, timestamp) { + console.log("reverse", timestamp); + + // demonstrate braking after 5 seconds + board.wait(5000, function() { + + // Brake for 500ms and call stop() + motor.brake(500); + }); + }); + + // set the motor going forward full speed + motor.forward(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/motor-PCA9685.js new file mode 100644 index 0000000..0f10ad9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-PCA9685.js @@ -0,0 +1,49 @@ +var five = require("../lib/johnny-five.js"), + board, motor, led; + +board = new five.Board(); + +/* + * The PCA9685 controller has been test on + * the Adafruit Motor/Stepper/Servo Shield v2 + */ + +board.on("ready", function() { + // Create a new `motor` hardware instance. + motor = new five.Motor({ + pins: [8, 9, 10], + controller: "PCA9685", + address: 0x60 + }); + + // Inject the `motor` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + motor: motor, + }); + + // Motor Event API + + // "start" events fire when the motor is started. + motor.on("start", function() { + console.log("start"); + + // Demonstrate motor stop in 2 seconds + board.wait(2000, function() { + motor.stop(); + }); + }); + + // "stop" events fire when the motor is started. + motor.on("stop", function() { + console.log("stop"); + }); + + // Motor API + + // start() + // Start the motor. `isOn` property set to |true| + motor.start(); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-brake.js b/JavaScript/node_modules/johnny-five/eg/motor-brake.js new file mode 100644 index 0000000..a724cc6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-brake.js @@ -0,0 +1,66 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var motor; + /* + Arduino Motor Shield R3 + Motor A + pwm: 3 + dir: 12 + brake: 9 + + Motor B + pwm: 11 + dir: 13 + brake: 8 + + */ + + motor = new five.Motor({ + pins: { + pwm: 3, + dir: 12, + brake: 9 + } + }); + + board.repl.inject({ + motor: motor + }); + + motor.on("start", function() { + console.log("start"); + }); + + motor.on("stop", function() { + console.log("automated stop on timer"); + }); + + motor.on("brake", function() { + console.log("automated brake on timer"); + }); + + motor.on("forward", function() { + console.log("forward"); + + // demonstrate switching to reverse after 5 seconds + board.wait(5000, function() { + motor.reverse(150); + }); + }); + + motor.on("reverse", function() { + console.log("reverse"); + + // demonstrate stopping after 5 seconds + board.wait(5000, function() { + + // Apply the brake for 500ms and call stop() + motor.brake(500); + }); + }); + + // set the motor going forward full speed + motor.forward(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-current.js b/JavaScript/node_modules/johnny-five/eg/motor-current.js new file mode 100644 index 0000000..81385c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-current.js @@ -0,0 +1,79 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var motor; + /* + Arduino Motor Shield R3 + Motor A + pwm: 3 + dir: 12 + brake: 9 + current: "A0" + + Motor B + pwm: 11 + dir: 13 + brake: 8 + current: "A1" + + */ + + motor = new five.Motor({ + pins: { + pwm: 3, + dir: 12, + brake: 9 + }, + + // The current options are passed to a new instance of Sensor + current: { + pin: "A0", + freq: 250, + threshold: 10 + } + }); + + board.repl.inject({ + motor: motor + }); + + motor.current.scale([0, 3030]).on("change", function() { + console.log("Motor A: " + this.value.toFixed(2) + "mA"); + }); + + motor.on("start", function() { + console.log("start"); + }); + + motor.on("stop", function() { + console.log("automated stop on timer"); + }); + + motor.on("brake", function() { + console.log("automated brake on timer"); + }); + + motor.on("forward", function() { + console.log("forward"); + + // demonstrate switching to reverse after 5 seconds + board.wait(5000, function() { + motor.reverse(150); + }); + }); + + motor.on("reverse", function() { + console.log("reverse"); + + // demonstrate stopping after 5 seconds + board.wait(5000, function() { + + // Apply the brake for 500ms and call stop() + motor.brake(500); + }); + }); + + // set the motor going forward full speed + motor.forward(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-directional.js b/JavaScript/node_modules/johnny-five/eg/motor-directional.js new file mode 100644 index 0000000..b5cc051 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-directional.js @@ -0,0 +1,91 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var motor; + /* + ArduMoto + Motor A + pwm: 3 + dir: 12 + + Motor B + pwm: 11 + dir: 13 + + + AdaFruit Motor Shield + Motor A + pwm: ? + dir: ? + + Motor B + pwm: ? + dir: ? + + + Bi-Directional Motors can be initialized by: + + new five.Motor([ 3, 12 ]); + + ...is the same as... + + new five.Motor({ + pins: [ 3, 12 ] + }); + + ...is the same as... + + new five.Motor({ + pins: { + pwm: 3, + dir: 12 + } + }); + + */ + + + motor = new five.Motor({ + pins: { + pwm: 3, + dir: 12 + } + }); + + + + + board.repl.inject({ + motor: motor + }); + + motor.on("start", function() { + console.log("start"); + }); + + motor.on("stop", function() { + console.log("automated stop on timer"); + }); + + motor.on("forward", function() { + console.log("forward"); + + // demonstrate switching to reverse after 5 seconds + board.wait(5000, function() { + motor.reverse(50); + }); + }); + + motor.on("reverse", function() { + console.log("reverse"); + + // demonstrate stopping after 5 seconds + board.wait(5000, function() { + motor.stop(); + }); + }); + + // set the motor going forward full speed + motor.forward(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-drv8835-particle.js b/JavaScript/node_modules/johnny-five/eg/motor-drv8835-particle.js new file mode 100644 index 0000000..5dc2982 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-drv8835-particle.js @@ -0,0 +1,15 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var motor = new five.Motor({ + pins: { pwm: 5, dir: 4 } + }); + + this.repl.inject({ + motor: motor + }); + + // Speed is an 8bit value: 0-255 + motor.speed(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor-hbridge.js b/JavaScript/node_modules/johnny-five/eg/motor-hbridge.js new file mode 100644 index 0000000..92ed27d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor-hbridge.js @@ -0,0 +1,64 @@ +/* + IMPORTANT!!! This example is not intended for off the shelf + H-Bridge based motor controllers. It is for home made H-Bridge + controllers. Off the shelf controllers abstract away the need + to invert the PWM (AKA Speed) value when the direction pin is set + to high. This is for controllers that do not have that feature. +*/ + +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var motor; + /* + Motor A + pwm: 3 + dir: 12 + */ + + + motor = new five.Motor({ + pins: { + pwm: 3, + dir: 12 + }, + invertPWM: true + }); + + + + + board.repl.inject({ + motor: motor + }); + + motor.on("start", function() { + console.log("start"); + }); + + motor.on("stop", function() { + console.log("automated stop on timer"); + }); + + motor.on("forward", function() { + console.log("forward"); + + // demonstrate switching to reverse after 5 seconds + board.wait(5000, function() { + motor.reverse(255); + }); + }); + + motor.on("reverse", function() { + console.log("reverse"); + + // demonstrate stopping after 5 seconds + board.wait(5000, function() { + motor.stop(); + }); + }); + + // set the motor going forward full speed + motor.forward(255); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motor.js b/JavaScript/node_modules/johnny-five/eg/motor.js new file mode 100644 index 0000000..7c5c616 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motor.js @@ -0,0 +1,47 @@ +var five = require("../lib/johnny-five.js"), + board, motor, led; + +board = new five.Board(); + +board.on("ready", function() { + // Create a new `motor` hardware instance. + motor = new five.Motor({ + pin: 5 + }); + + // Inject the `motor` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + motor: motor + }); + + // Motor Event API + + // "start" events fire when the motor is started. + motor.on("start", function() { + console.log("start"); + + // Demonstrate motor stop in 2 seconds + board.wait(2000, function() { + motor.stop(); + }); + }); + + // "stop" events fire when the motor is stopped. + motor.on("stop", function() { + console.log("stop"); + }); + + // Motor API + + // start([speed) + // Start the motor. `isOn` property set to |true| + // Takes an optional parameter `speed` [0-255] + // to define the motor speed if a PWM Pin is + // used to connect the motor. + motor.start(); + + // stop() + // Stop the motor. `isOn` property set to |false| +}); diff --git a/JavaScript/node_modules/johnny-five/eg/motors-EVS_EV3-bot.js b/JavaScript/node_modules/johnny-five/eg/motors-EVS_EV3-bot.js new file mode 100644 index 0000000..a08214d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/motors-EVS_EV3-bot.js @@ -0,0 +1,37 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var motors = new five.Motors([ + { controller: "EVS_EV3", pin: "BAM1" }, + { controller: "EVS_EV3", pin: "BBM1" }, + ]); + + function fwd(speed) { + motors.rev(speed); + } + + function rev(speed) { + motors.fwd(speed); + } + + function right(speed) { + motors[0].fwd(speed); + motors[1].rev(speed); + } + + function left(speed) { + motors[0].rev(speed); + motors[1].fwd(speed); + } + + this.repl.inject( + [ fwd, rev, left, right ].reduce(function(accum, command) { + accum[command.name] = function(speed) { + speed = speed !== undefined ? speed : 40; + command(speed); + }; + return accum; + }, {}) + ); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/multi-bmp180.js b/JavaScript/node_modules/johnny-five/eg/multi-bmp180.js new file mode 100644 index 0000000..e1be9f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/multi-bmp180.js @@ -0,0 +1,20 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var multi = new five.Multi({ + controller: "BMP180" + }); + + multi.on("change", function() { + console.log("temperature"); + console.log(" celsius : ", this.temperature.celsius); + console.log(" fahrenheit : ", this.temperature.fahrenheit); + console.log(" kelvin : ", this.temperature.kelvin); + console.log("--------------------------------------"); + + console.log("barometer"); + console.log(" pressure : ", this.barometer.pressure); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/multi-mpl115a2.js b/JavaScript/node_modules/johnny-five/eg/multi-mpl115a2.js new file mode 100644 index 0000000..b105330 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/multi-mpl115a2.js @@ -0,0 +1,20 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var multi = new five.Multi({ + controller: "MPL115A2" + }); + + multi.on("change", function() { + console.log("temperature"); + console.log(" celsius : ", this.temperature.celsius); + console.log(" fahrenheit : ", this.temperature.fahrenheit); + console.log(" kelvin : ", this.temperature.kelvin); + console.log("--------------------------------------"); + + console.log("barometer"); + console.log(" pressure : ", this.barometer.pressure); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/navigator-joystick.js b/JavaScript/node_modules/johnny-five/eg/navigator-joystick.js new file mode 100644 index 0000000..e6b0682 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/navigator-joystick.js @@ -0,0 +1,69 @@ +var five = require("../lib/johnny-five.js"), + when = require("when"), + boards, readyList, joystick, led, servo; + +boards = {}; +readyList = []; + +["navigator", "controller"].forEach(function(name) { + var deferred = when.defer(); + + readyList.push(deferred.promise); + + ( + boards[name] = new five.Board({ + id: name + }) + ).on("ready", function() { + + deferred.resolve(this); + }); +}); + +when.all(readyList, function() { + // console.log( "resolved" ); + var last, dirs, turn; + + joystick = new five.Joystick({ + board: boards.controller, + pins: ["A0", "A1"], + freq: 100 + }); + + led = new five.Led({ + board: boards.navigator, + pin: 13 + }); + + servo = new five.Servo({ + board: boards.navigator, + pin: 12, + range: [10, 170] + }); + + last = 1; + dirs = ["left", undefined, "right"]; + turn = ["max", "center", "min"]; + + servo.center(); + + joystick.on("axismove", function() { + // 0: left, 1: center, 2: right + var position = Math.ceil(2 * this.fixed.x); + + // console.log( position ); + + // If the joystick has actually moved and it's + // not in the center... + if (last !== position) { + last = position; + + if (position !== 1) { + console.log(dirs[position]); + } + + + servo[turn[position]](); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/navigator-original.js b/JavaScript/node_modules/johnny-five/eg/navigator-original.js new file mode 100644 index 0000000..8b05e99 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/navigator-original.js @@ -0,0 +1,444 @@ +var five = require("../lib/johnny-five.js"), + board, Navigator, navigator, servos, + expandWhich, directionMap, scale; + +directionMap = { + reverse: { + right: "left", + left: "right" + }, + translations: [{ + f: "forward", + r: "reverse", + fwd: "forward", + rev: "reverse" + }, { + r: "right", + l: "left" + }] +}; + +scale = function(speed, low, high) { + return Math.floor(five.Fn.map(speed, 0, 5, low, high)); +}; + + +/** + * Navigator + * @param {Object} opts Optional properties object + */ + +function Navigator(opts) { + + // Boe Navigator continuous are calibrated to stop at 90° + this.center = opts.center || 90; + + // Initialize the right and left cooperative servos + this.servos = { + right: new five.Servo({ + pin: opts.right, + type: "continuous" + }), + left: new five.Servo({ + pin: opts.left, + type: "continuous" + }) + }; + + // Set the initial servo cooperative direction + this.direction = opts.direction || { + right: this.center, + left: this.center + }; + + // Store the cooperative speed + this.speed = opts.speed === undefined ? 0 : opts.speed; + + // Store a recallable history of movement + // TODO: Include in savable history + this.history = []; + + // Initial direction + this.which = "forward"; + + // Track directional state + this.isTurning = false; + + // Wait 10ms, send fwd pulse on, then off to + // "wake up" the servos + setTimeout(function() { + this.fwd(1).fwd(0); + }.bind(this), 10); +} + + +Navigator.DIR_MAP = directionMap; + +/** + * move Move the bot in an arbitrary direction + * @param {Number} right Speed/Direction of right servo + * @param {Number} left Speed/Direction of left servo + * @return {Object} this + */ +Navigator.prototype.move = function(right, left) { + + // Quietly ignore duplicate instructions + if (this.direction.right === right && + this.direction.left === left) { + return this; + } + + // Cooperative servo motion. + // Servos are mounted opposite of each other, + // the values for left and right will be in + // opposing directions. + this.servos.right.to(right); + this.servos.left.to(left); + + // Push a record object into the history + this.history.push({ + timestamp: Date.now(), + right: right, + left: left + }); + + // Update the stored direction state + this.direction.right = right; + this.direction.left = left; + + return this; +}; + + +// TODO: DRY OUT!!!!!!! + + +[ + /** + * forward Move the bot forward + * fwd Move the bot forward + * + * @param {Number} 0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + args: function(center, val) { + return [center - (val - center), val]; + } + }, + + /** + * reverse Move the bot in reverse + * rev Move the bot in reverse + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + args: function(center, val) { + return [val, center - (val - center)]; + } + } + +].forEach(function(dir) { + + var method = function(speed) { + // Set default direction method + speed = speed === undefined ? 1 : speed; + + this.speed = speed; + this.which = dir.name; + + return this.move.apply(this, + dir.args(this.center, scale(speed, this.center, 110)) + ); + }; + + Navigator.prototype[dir.name] = Navigator.prototype[dir.abbr] = method; +}); + +/** + * stop Stops the bot, regardless of current direction + * @return {Object} this + */ +Navigator.prototype.stop = function() { + this.speed = this.center; + this.which = "stop"; + + return this.to(this.center, this.center); +}; + + +[ + /** + * right Turn the bot right + * @return {Object} this + */ + "right", + + /** + * left Turn the bot left + * @return {Object} this + */ + "left" + +].forEach(function(dir) { + Navigator.prototype[dir] = function() { + + // Use direction value and reverse direction map to + // derive the direction values for moving the + // cooperative servos + var actual = this.direction[directionMap.reverse[dir]]; + + if (!this.isTurning) { + // Set turning lock + this.isTurning = true; + + // Send turning command + this.to(actual, actual); + + // Cap turning time to 750ms + setTimeout(function() { + + // Restore direction after turn + this[this.which](this.speed); + + // Release turning lock + this.isTurning = false; + + }.bind(this), 750); + } + + return this; + }; +}); + +expandWhich = function(which) { + var parts; + + if (which.length === 2) { + parts = [which[0], which[1]]; + } + + if (!parts.length && /\-/.test(which)) { + parts = which.split("-"); + } + + return parts.map(function(val, i) { + return directionMap.translations[i][val]; + }).join("-"); +}; + + +/** + * pivot Pivot the bot with combo directions: + * rev Move the bot in reverse + * + * @param {String} which Combination directions: + * "forward-right", "forward-left", + * "reverse-right", "reverse-left" + * (aliased as: "f-l", "f-r", "r-r", "r-l") + * + * @return {Object} this + */ +Navigator.prototype.pivot = function(which, time) { + var actual, directions, scaled; + + scaled = scale(this.speed, this.center, 110); + which = expandWhich(which); + + directions = { + "forward-right": function() { + this.to(this.center, scaled); + }, + "forward-left": function() { + this.to(this.center - (scaled - this.center), this.center); + }, + "reverse-right": function() { + this.to(scaled, this.center); + }, + "reverse-left": function() { + this.to(this.center, this.center - (scaled - this.center)); + } + }; + + directions[which].call(this, this.speed); + + setTimeout(function() { + + this[this.which](this.speed); + + }.bind(this), time || 1000); + + return this; +}; + + + + +// Begin program when the board, serial and +// firmata are connected and ready + +board = new five.Board(); +board.on("ready", function() { + + // TODO: Refactor into modular program code + + var center, collideAt, degrees, step, facing, lastTurn, + range, laser, look, isScanning, scanner, sonar; + + // Collision distance (inches) + collideAt = 6; + + // Servo scanning steps (degrees) + step = 10; + + // Current facing direction + facing = ""; + + // Scanning range (degrees) + range = [20, 140]; + + // Servo center point (degrees) + center = ((range[1] - range[0]) / 2) + range[0]; + + // Starting scanner scanning position (degrees) + degrees = center; + + // Direction to look after releasing scanner lock (degrees) + // look = { + // forward: center, + // left: 130, + // right: 40 + // }; + + // Scanning state + isScanning = true; + + // New base navigator + // right servo = pin 10, left servo = pin 11 + navigator = new Navigator({ + right: 10, + left: 11 + }); + + // Inject navigator object into REPL + this.repl.inject({ + b: navigator + }); + + // The laser is just a special case Led + laser = new five.Led(9); + + // Sonar instance (distance detection) + sonar = new five.Sonar("A2"); + + // Servo scanner instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + // Initialize the scanner at it's center point + // Will be exactly half way between the range's + // lower and upper bound + scanner.center(); + + // Wait 1000ms, then initialize forward movement + this.wait(1000, function() { + + laser.on(); + navigator.fwd(3); + }); + + + // Scanner/Panning loop + this.loop(75, function() { + var bounds; + + bounds = { + left: center - 5, //center + 10, + right: center - 5 //center - 10 + }; + + // During course change, scanning is paused to avoid + // overeager redirect instructions[1] + if (isScanning) { + // Calculate the next step position + if (degrees >= scanner.range[1] || degrees === scanner.range[0]) { + step *= -1; + } + + // Update the position in degrees + degrees += step; + + // The following three conditions will help determine + // which way the navigator should turn if a potential collideAt + // may occur in the sonar "change" event handler[2] + if (degrees > bounds.left) { + facing = "left"; + } + + if (degrees < bounds.right) { + facing = "right"; + } + + if (degrees > bounds.right && degrees < bounds.left) { + facing = "forward"; + } + + scanner.to(degrees); + } + }); + + // [2] Sonar "change" events are emitted when the value of a + // distance reading has changed since the previous reading + // + sonar.on("change", function(err) { + var turnTo; + + // Detect collideAt + if (Math.abs(this.inches) <= collideAt && isScanning) { + + laser.strobe(); + + // Scanning lock will prevent multiple collideAt + // detections piling up for the same obstacle + isScanning = false; + + // Determine direction to turn + turnTo = Navigator.DIR_MAP.reverse[facing] || lastTurn; + + // Log collideAt detection to REPL + console.log( + [Date.now(), + "\tCollision detected " + this.inches + " inches away.", + "\tTurning " + turnTo.toUpperCase() + " to avoid" + ].join("\n") + ); + + // Turn the navigator + navigator[turnTo](); + + // Store the last turning direction + lastTurn = turnTo; + + // [1] Allow Nms to pass and release the scanning lock + // by setting isScanning state to true. + board.wait(1500, function() { + console.log("Release Scanner Lock"); + laser.on(); + isScanning = true; + }); + } + }); +}); + + +// References +// +// http://www.maxbotix.com/documents/MB1010_Datasheet.pdf diff --git a/JavaScript/node_modules/johnny-five/eg/navigator.js b/JavaScript/node_modules/johnny-five/eg/navigator.js new file mode 100644 index 0000000..d2fb0bc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/navigator.js @@ -0,0 +1,535 @@ +var five = require("../lib/johnny-five.js"), + __ = require("../lib/fn.js"), + board, Navigator, navigator, servos, + pivotExpansion, directionMap, scale; + + +directionMap = { + reverse: { + right: "left", + left: "right", + fwd: "rev", + rev: "fwd" + }, + translations: [{ + f: "forward", + r: "reverse", + fwd: "forward", + rev: "reverse" + }, { + r: "right", + l: "left" + }] +}; + +scale = function(speed, low, high) { + return Math.floor(five.Fn.map(speed, 0, 5, low, high)); +}; + + +/** + * Navigator + * @param {Object} opts Optional properties object + */ + +function Navigator(opts) { + + // Boe Navigator continuous are calibrated to stop at 90° + this.center = opts.center || 90; + + // Initialize the right and left cooperative servos + this.servos = { + right: new five.Servo({ + pin: opts.right, + type: "continuous" + }), + left: new five.Servo({ + pin: opts.left, + type: "continuous" + }) + }; + + // Set the initial servo cooperative direction + this.direction = opts.direction || { + right: this.center, + left: this.center + }; + + this.compass = opts.compass || null; + this.gripper = opts.gripper || null; + + // Store the cooperative speed + this.speed = opts.speed === undefined ? 0 : opts.speed; + + // Store a recallable history of movement + // TODO: Include in savable history + this.history = []; + + // Initial direction + this.which = "forward"; + + // Track directional state + this.isTurning = false; + + // Wait 10ms, send fwd pulse on, then off to + // "wake up" the servos + setTimeout(function() { + this.fwd(1).fwd(0); + }.bind(this), 10); +} + + +Navigator.DIR_MAP = directionMap; + +/** + * move Move the bot in an arbitrary direction + * @param {Number} right Speed/Direction of right servo + * @param {Number} left Speed/Direction of left servo + * @return {Object} this + */ +Navigator.prototype.move = function(right, left) { + + // Quietly ignore duplicate instructions + if (this.direction.right === right && + this.direction.left === left) { + return this; + } + + // Cooperative servo motion. + // Servos are mounted opposite of each other, + // the values for left and right will be in + // opposing directions. + this.servos.right.to(right); + this.servos.left.to(left); + + // Push a record object into the history + this.history.push({ + timestamp: Date.now(), + right: right, + left: left + }); + + // Update the stored direction state + this.direction.right = right; + this.direction.left = left; + + return this; +}; + + +[ + /** + * forward Move the bot forward + * fwd Move the bot forward + * + * @param {Number} 0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + args: function(center, val) { + return [center - (val - center), val]; + } + }, + + /** + * reverse Move the bot in reverse + * rev Move the bot in reverse + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + args: function(center, val) { + return [val, center - (val - center)]; + } + } + +].forEach(function(dir) { + + var method = function(speed) { + // Set default direction method + speed = speed === undefined ? 1 : speed; + + this.speed = speed; + this.which = dir.name; + + return this.move.apply(this, + dir.args(this.center, scale(speed, this.center, 110)) + ); + }; + + Navigator.prototype[dir.name] = Navigator.prototype[dir.abbr] = method; +}); + +/** + * stop Stops the bot, regardless of current direction + * @return {Object} this + */ +Navigator.prototype.stop = function() { + this.speed = this.center; + this.which = "stop"; + + return this.to(this.center, this.center); +}; + + +[ + /** + * right Turn the bot right + * @return {Object} this + */ + "right", + + /** + * left Turn the bot left + * @return {Object} this + */ + "left" + +].forEach(function(dir) { + Navigator.prototype[dir] = function(time) { + + // Use direction value and reverse direction map to + // derive the direction values for moving the + // cooperative servos + var actual = this.direction[directionMap.reverse[dir]]; + + time = time || 500; + + if (!this.isTurning) { + // Set turning lock + this.isTurning = true; + + // Send turning command + this.to(actual, actual); + + // Cap turning time + setTimeout(function() { + + // Restore direction after turn + this[this.which](this.speed || 2); + + // Release turning lock + this.isTurning = false; + + }.bind(this), time); + } + + return this; + }; +}); + +pivotExpansion = function(which) { + var parts; + + if (which.length === 2) { + parts = [which[0], which[1]]; + } + + if (/\-/.test(which)) { + parts = which.split("-"); + } + + return parts.map(function(val, i) { + console.log(val); + return directionMap.translations[i][val]; + }).join("-"); +}; + + +/** + * pivot Pivot the bot with combo directions: + * rev Move the bot in reverse + * + * @param {String} which Combination directions: + * "forward-right", "forward-left", + * "reverse-right", "reverse-left" + * (aliased as: "f-l", "f-r", "r-r", "r-l") + * + * @return {Object} this + */ +Navigator.prototype.pivot = function(which, time) { + var actual, directions, scaled; + + scaled = scale(this.speed, this.center, 110); + + directions = { + "forward-right": function() { + this.to(this.center, scaled); + }, + "forward-left": function() { + this.to(this.center - (scaled - this.center), this.center); + }, + "reverse-right": function() { + this.to(scaled, this.center); + }, + "reverse-left": function() { + this.to(this.center, this.center - (scaled - this.center)); + } + }; + + which = directions[which] || directions[pivotExpansion(which)]; + + which.call(this, this.speed); + + setTimeout(function() { + + this[this.which](this.speed); + + }.bind(this), time || 1000); + + return this; +}; + + + + +// Begin program when the board, serial and +// firmata are connected and ready + +(board = new five.Board()).on("ready", function() { + + // TODO: Refactor into modular program code + + var center, collideAt, degrees, step, facing, + range, laser, look, isScanning, scanner, gripper, isGripping, sonar, gripAt, ping, mag, bearing; + + // Collision distance (inches) + collideAt = 6; + + gripAt = 2; + + // Servo scanning steps (degrees) + step = 2; + + // Current facing direction + facing = ""; + + // Scanning range (degrees) + range = [10, 170]; + + // Servo center point (degrees) + center = ((range[1] - range[0]) / 2) + range[0]; + + // Starting scanner scanning position (degrees) + degrees = center; + + // Direction to look after releasing scanner lock (degrees) + // look = { + // forward: center, + // left: 130, + // right: 40 + // }; + + // Scanning state + isScanning = true; + + // Gripping state + isGripping = false; + + // compass/magnetometer + mag = new five.Magnetometer(); + + // Servo gripper + gripper = new five.Gripper({ + servo: { + pin: 13, + range: [20, 160] + }, + scale: [0, 10] + }); + + // New base navigator + // right servo = pin 10, left servo = pin 11 + navigator = new Navigator({ + right: 10, + left: 11, + compass: mag, + gripper: gripper + }); + + // The laser is just a special case Led + laser = new five.Led(9); + + // Digital PWM (range) + ping = new five.Ping(7); + + // Analog Voltage (range) + // sonar = new five.Sonar("A0"); + + + // Servo scanner instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + + // Inject navigator object into REPL + this.repl.inject({ + b: navigator, + g: gripper + }); + + + // Initialize the scanner at it's center point + // Will be exactly half way between the range's + // lower and upper bound + scanner.center(); + + // Wait 1000ms, then initialize forward movement + this.wait(1000, function() { + // navigator.fwd(3); + }); + + + // Scanner/Panning loop + this.loop(50, function() { + var bounds; + + bounds = { + left: center + 15, //center + 10, + right: center - 15 //center - 10 + }; + + // During course change, scanning is paused to avoid + // overeager redirect instructions[1] + if (isScanning) { + // Calculate the next step position + if (degrees >= scanner.range[1] || degrees <= scanner.range[0]) { + step *= -1; + } + + // Update the position in degrees + degrees += step; + + // The following three conditions will help determine + // which way the navigator should turn if a potential collideAt + // may occur in the ping "change" event handler[2] + if (degrees > bounds.left) { + facing = "left"; + } + + if (degrees < bounds.right) { + facing = "right"; + } + + // if ( degrees > bounds.right && degrees < bounds.left ) { + if (__.range(bounds.right, bounds.left).indexOf(degrees) > -1) { + facing = "fwd"; + } + + + scanner.to(degrees); + } + }); + + // sonar.on("change", function() { + // ping.on("change", function() { + // var distance = Math.abs(this.inches); + + // // TODO: Wrap this behaviour in an abstraction + // if ( distance <= collideAt && !isGripping ) { + // gripper.max(); + + // // simulate drop instruction + // setTimeout(function() { + // isGripping = false; + // gripper.min(); + // }, 5000); + // } + // }); + + // Compass heading monitor + // mag.on("headingchange", function() { + + // if ( !/[\-by]/.test(this.bearing.name) && this.bearing.name !== bearing ) { + // bearing = this.bearing.name; + + // console.log( this.bearing ); + // } + // }); + + // [2] ping "change" events are emitted when the value of a + // distance reading has changed since the previous reading + // + // TODO: Avoid false positives? + ping.on("data", function(err) { + var release = 750, + distance = Math.abs(this.inches), + isReverse = false, + turnTo; + + if (navigator.isTurning) { + return; + } + + // If distance value is null or NaN + if (distance === null || isNaN(distance)) { + return; + } + + + + // Detect collideAt + // && isScanning + if (distance <= collideAt && isScanning) { + + laser.strobe(); + + // Scanning lock will prevent multiple collideAt + // detections piling up for the same obstacle + isScanning = false; + + // Determine direction to turn + turnTo = Navigator.DIR_MAP.reverse[facing]; + + // Set reversal flag. + isReverse = turnTo === "rev"; + + // Log collideAt detection to REPL + console.log( + [Date.now(), + "\tCollision detected " + this.inches + " inches away.", + "\tTurning " + turnTo.toUpperCase() + " to avoid" + ].join("\n") + ); + + // Turn the navigator + navigator[turnTo](navigator.speed); + + + if (isReverse) { + release = 1500; + } + + // [1] Allow Nms to pass and release the scanning lock + // by setting isScanning state to true. + board.wait(release, function() { + console.log("Release Scanner Lock"); + + degrees = 89; + + scanner.center(); + + if (isReverse) { + // navigator.fwd( navigator.speed ); + navigator.pivot("reverse-right"); + navigator.which = "fwd"; + } + + laser.brightness(0); + isScanning = true; + }); + } + }); +}); + + +// References +// +// http://www.maxbotix.com/documents/MB1010_Datasheet.pdf diff --git a/JavaScript/node_modules/johnny-five/eg/nino-io.js b/JavaScript/node_modules/johnny-five/eg/nino-io.js new file mode 100644 index 0000000..e69de29 diff --git a/JavaScript/node_modules/johnny-five/eg/nodebot.js b/JavaScript/node_modules/johnny-five/eg/nodebot.js new file mode 100644 index 0000000..93b8732 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nodebot.js @@ -0,0 +1,77 @@ +var five, temporal, Nodebot; + +five = require("../lib/johnny-five.js"); +/** + * Any time-based scheduling + * should use temporal + */ +temporal = require("temporal"); + +/** + * Programs MUST initialize a serial + * communication "channel" with the board + * before executing hardware-specific code + */ +five.Board().on("ready", function() { + + /** + * Initialize an instance of Nodebot + * with properties "right" and "left" + * whose values must correspond to the + * pin for each respective servo. + */ + Nodebot = new five.Nodebot({ + right: 10, + left: 11 + }); + + /** + * Inject Nodebot instance into REPL, + * this will allow a user to navigate + * and control the Nodebot via the + * command line + */ + this.repl.inject({ + n: Nodebot + }); + + /** + * The following methods may be called + * from the "n" object on the command + * line to control/navigate the + * Nodebot. + * + * speed + * A number 1-5; 1 is slow, 5 is fast. + * + * n.fwd(speed) + * Drive the Nodebot forward at a + * specified speed. + * + * n.rev(speed) + * Drive the Nodebot in reverse at a + * specified speed. + * + * n.left(time = 500) + * Turn the Nodebot left for a + * specified amount of time in ms. + * Defaults to 500ms + * + * n.right(time = 500) + * Turn the Nodebot right for a + * specified amount of time in ms. + * Defaults to 500ms + * + * n.stop() + * Stop the Nodebot + * + * n.pivot(instruction) + * Pivot the Nodebot based on an + * instruction string. + * Instructions include: + * - "forward-right" or "f-r" + * - "forward-left" or "f-l" + * - "reverse-right" or "r-r" + * - "reverse-left" or "r-l" + */ +}); diff --git a/JavaScript/node_modules/johnny-five/eg/nodeconf-compass.js b/JavaScript/node_modules/johnny-five/eg/nodeconf-compass.js new file mode 100644 index 0000000..7c5b81b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nodeconf-compass.js @@ -0,0 +1,53 @@ +var chalk = require("chalk"); +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create an I2C `Magnetometer` instance + var mag = new five.Magnetometer(); + + // As the heading changes, log heading value + mag.on("headingchange", function() { + var color = colors[this.bearing.abbr]; + + console.log( + chalk[color](this.bearing.name + " " + Math.floor(this.heading) + "°") + ); + }); +}); + +var colors = { + N: "red", + NbE: "red", + NNE: "red", + NEbN: "red", + NE: "yellow", + NEbE: "yellow", + ENE: "yellow", + EbN: "yellow", + E: "green", + EbS: "green", + ESE: "green", + SEbE: "green", + SE: "green", + SEbS: "cyan", + SSE: "cyan", + SbE: "cyan", + S: "cyan", + SbW: "cyan", + SSW: "cyan", + SWbS: "blue", + SW: "blue", + SWbW: "blue", + WSW: "blue", + WbS: "blue", + W: "magenta", + WbN: "magenta", + WNW: "magenta", + NWbW: "magenta", + NW: "magenta", + NWbN: "magenta", + NNW: "magenta", + NbW: "red" +}; diff --git a/JavaScript/node_modules/johnny-five/eg/nodeconf-navigator.js b/JavaScript/node_modules/johnny-five/eg/nodeconf-navigator.js new file mode 100644 index 0000000..5c78241 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nodeconf-navigator.js @@ -0,0 +1,491 @@ +var five = require("../lib/johnny-five.js"), + __ = five.Fn, + board, Navigator, navigator, servos, + expandedWhich, directionMap, scale; + + +directionMap = { + reverse: { + right: "left", + left: "right", + fwd: "rev", + rev: "fwd" + }, + translations: [{ + f: "forward", + r: "reverse", + fwd: "forward", + rev: "reverse" + }, { + r: "right", + l: "left" + }] +}; + +scale = function(speed, low, high) { + return Math.floor(five.Fn.map(speed, 0, 5, low, high)); +}; + + +/** + * Navigator + * @param {Object} opts Optional properties object + */ + +function Navigator(opts) { + + // Boe Navigator continuous are calibrated to stop at 90° + this.center = opts.center || 90; + + // Initialize the right and left cooperative servos + this.servos = { + right: new five.Servo({ + pin: opts.right, + type: "continuous" + }), + left: new five.Servo({ + pin: opts.left, + type: "continuous" + }) + }; + + // Set the initial servo cooperative direction + this.direction = opts.direction || { + right: this.center, + left: this.center + }; + + // Store the cooperative speed + this.speed = opts.speed === undefined ? 0 : opts.speed; + + // Store a recallable history of movement + // TODO: Include in savable history + this.history = []; + + // Initial direction + this.which = "forward"; + + // Track directional state + this.isTurning = false; + + // Wait 10ms, send fwd pulse on, then off to + // "wake up" the servos + setTimeout(function() { + this.fwd(1).fwd(0); + }.bind(this), 10); +} + + +Navigator.DIR_MAP = directionMap; + +/** + * move Move the bot in an arbitrary direction + * @param {Number} right Speed/Direction of right servo + * @param {Number} left Speed/Direction of left servo + * @return {Object} this + */ +Navigator.prototype.move = function(right, left) { + + // Quietly ignore duplicate instructions + if (this.direction.right === right && + this.direction.left === left) { + return this; + } + + // Cooperative servo motion. + // Servos are mounted opposite of each other, + // the values for left and right will be in + // opposing directions. + this.servos.right.to(right); + this.servos.left.to(left); + + // Push a record object into the history + this.history.push({ + timestamp: Date.now(), + right: right, + left: left + }); + + // Update the stored direction state + this.direction.right = right; + this.direction.left = left; + + return this; +}; + + +[ + /** + * forward Move the bot forward + * fwd Move the bot forward + * + * @param {Number} 0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + args: function(center, val) { + return [center - (val - center), val]; + } + }, + + /** + * reverse Move the bot in reverse + * rev Move the bot in reverse + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + args: function(center, val) { + return [val, center - (val - center)]; + } + } + +].forEach(function(dir) { + + var method = function(speed) { + // Set default direction method + speed = speed === undefined ? 1 : speed; + + this.speed = speed; + this.which = dir.name; + + return this.move.apply(this, + dir.args(this.center, scale(speed, this.center, 110)) + ); + }; + + Navigator.prototype[dir.name] = Navigator.prototype[dir.abbr] = method; +}); + +/** + * stop Stops the bot, regardless of current direction + * @return {Object} this + */ +Navigator.prototype.stop = function() { + this.speed = this.center; + this.which = "stop"; + + return this.to(this.center, this.center); +}; + + +[ + /** + * left Turn the bot left + * @return {Object} this + */ + "left", + + /** + * right Turn the bot right + * @return {Object} this + */ + "right" + +].forEach(function(dir) { + Navigator.prototype[dir] = function() { + + // Use direction value and reverse direction map to + // derive the direction values for moving the + // cooperative servos + var actual = this.direction[directionMap.reverse[dir]]; + + if (!this.isTurning) { + // Set turning lock + this.isTurning = true; + + // Send turning command + this.to(actual, actual); + + // Cap turning time + setTimeout(function() { + + // Restore direction after turn + this[this.which](this.speed); + + // Release turning lock + this.isTurning = false; + + }.bind(this), 500); + } + + return this; + }; +}); + +expandedWhich = function(which) { + var parts; + + if (which.length === 2) { + parts = [which[0], which[1]]; + } + + if (/\-/.test(which)) { + parts = which.split("-"); + } + + return parts.map(function(val, i) { + console.log(val); + return directionMap.translations[i][val]; + }).join("-"); +}; + + +/** + * pivot Pivot the bot with combo directions: + * rev Move the bot in reverse + * + * @param {String} which Combination directions: + * "forward-right", "forward-left", + * "reverse-right", "reverse-left" + * (aliased as: "f-l", "f-r", "r-r", "r-l") + * + * @return {Object} this + */ +Navigator.prototype.pivot = function(which, time) { + var actual, directions, scaled; + + scaled = scale(this.speed, this.center, 110); + + directions = { + "forward-right": function() { + this.to(this.center, scaled); + }, + "forward-left": function() { + this.to(this.center - (scaled - this.center), this.center); + }, + "reverse-right": function() { + this.to(scaled, this.center); + }, + "reverse-left": function() { + this.to(this.center, this.center - (scaled - this.center)); + } + }; + + which = directions[which] || directions[expandedWhich(which)]; + + which.call(this, this.speed); + + setTimeout(function() { + + this[this.which](this.speed); + + }.bind(this), time || 1000); + + return this; +}; + + + + +// Begin program when the board, serial and +// firmata are connected and ready + +board = new five.Board(); +board.on("ready", function() { + + // TODO: Refactor into modular program code + + var center, collideAt, degrees, step, facing, + range, laser, look, isScanning, scanner, ping, mag, bearing; + + // Collision distance (inches) + collideAt = 6; + + // Servo scanning steps (degrees) + step = 2; + + // Current facing direction + facing = ""; + + // Scanning range (degrees) + range = [10, 170]; + + // Servo center point (degrees) + center = ((range[1] - range[0]) / 2) + range[0]; + + // Starting scanner scanning position (degrees) + degrees = center; + + // Direction to look after releasing scanner lock (degrees) + // look = { + // forward: center, + // left: 130, + // right: 40 + // }; + + // Scanning state + isScanning = true; + + // New base navigator + // right servo = pin 10, left servo = pin 11 + navigator = new Navigator({ + right: 10, + left: 11 + }); + + // Inject navigator object into REPL + this.repl.inject({ + b: navigator + }); + + // The laser is just a special case Led + laser = new five.Led(9); + + // ping instance (distance detection) + ping = new five.Ping(7); + + // compass/magnetometer + // mag = new five.Magnetometer(); + + // Servo scanner instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + // Initialize the scanner at it's center point + // Will be exactly half way between the range's + // lower and upper bound + scanner.center(); + + // Wait 1000ms, then initialize forward movement + this.wait(1000, function() { + navigator.fwd(3); + }); + + + // Scanner/Panning loop + this.loop(50, function() { + var bounds; + + bounds = { + left: center + 15, //center + 10, + right: center - 15 //center - 10 + }; + + // During course change, scanning is paused to avoid + // overeager redirect instructions[1] + if (isScanning) { + // Calculate the next step position + if (degrees >= scanner.range[1] || degrees <= scanner.range[0]) { + step *= -1; + } + + // Update the position in degrees + degrees += step; + + // The following three conditions will help determine + // which way the navigator should turn if a potential collideAt + // may occur in the ping "change" event handler[2] + if (degrees > bounds.left) { + facing = "left"; + } + + if (degrees < bounds.right) { + facing = "right"; + } + + // if ( degrees > bounds.right && degrees < bounds.left ) { + if (__.range(bounds.right, bounds.left).indexOf(degrees) > -1) { + facing = "fwd"; + } + + + scanner.to(degrees); + } + }); + + + // Compass heading monitor + // mag.on("headingchange", function() { + + // if ( !/[\-by]/.test(this.bearing.name) && this.bearing.name !== bearing ) { + // bearing = this.bearing.name; + + // console.log( this.bearing ); + // } + // }); + + // [2] ping "change" events are emitted when the value of a + // distance reading has changed since the previous reading + // + // TODO: Avoid false positives? + ping.on("data", function(err) { + var release = 750, + distance = Math.abs(this.inches), + isReverse = false, + turnTo; + + if (navigator.isTurning) { + return; + } + + // If distance value is null or NaN + if (!distance) { + return; + } + + // Detect collideAt + // && isScanning + if (distance <= collideAt && isScanning) { + + laser.strobe(); + + // Scanning lock will prevent multiple collideAt + // detections piling up for the same obstacle + isScanning = false; + + // Determine direction to turn + turnTo = Navigator.DIR_MAP.reverse[facing]; + + // Set reversal flag. + isReverse = turnTo === "rev"; + + // Log collideAt detection to REPL + console.log( + [Date.now(), + "\tCollision detected " + this.inches + " inches away.", + "\tTurning " + turnTo.toUpperCase() + " to avoid" + ].join("\n") + ); + + // Turn the navigator + navigator[turnTo](navigator.speed); + + + if (isReverse) { + release = 1500; + } + + // [1] Allow Nms to pass and release the scanning lock + // by setting isScanning state to true. + board.wait(release, function() { + console.log("Release Scanner Lock"); + + degrees = 89; + + scanner.center(); + + if (isReverse) { + // navigator.fwd( navigator.speed ); + navigator.pivot("reverse-right"); + navigator.which = "fwd"; + } + + laser.brightness(0); + isScanning = true; + }); + } + }); +}); + + +// References +// +// http://www.maxbotix.com/documents/MB1010_Datasheet.pdf diff --git a/JavaScript/node_modules/johnny-five/eg/nodeconf-radar.js b/JavaScript/node_modules/johnny-five/eg/nodeconf-radar.js new file mode 100644 index 0000000..6d34f28 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nodeconf-radar.js @@ -0,0 +1,129 @@ +var five = require("../lib/johnny-five.js"), + child = require("child_process"), + http = require("http"), + socket = require("socket.io"), + fs = require("fs"), + app, board, io; + +function handler(req, res) { + var path = __dirname; + + if (req.url === "/") { + path += "/radar.html"; + } else { + path += req.url; + } + + fs.readFile(path, function(err, data) { + if (err) { + res.writeHead(500); + return res.end("Error loading " + path); + } + + res.writeHead(200); + res.end(data); + }); +} + +app = http.createServer(handler); +app.listen(8080); + +io = socket.listen(app); +io.set("log level", 1); + +board = new five.Board(); + +board.on("ready", function() { + var center, degrees, step, facing, range, scanner, soi, ping, last; + + + // Open Radar view + child.exec("open http://localhost:8080/"); + + // Starting scanner scanning position (degrees) + degrees = 1; + + // Servo scanning steps (degrees) + step = 1; + + // Current facing direction + facing = ""; + + last = 0; + + // Scanning range (degrees) + range = [0, 170]; + + // Servo center point (degrees) + center = range[1] / 2; + + // ping instance (distance detection) + ping = new five.Ping(7); + + // Servo instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + this.repl.inject({ + scanner: scanner + }); + + // Initialize the scanner servo at 0° + scanner.min(); + + // Scanner/Panning loop + this.loop(100, function() { + var bounds, isOver, isUnder; + + bounds = { + left: center + 5, + right: center - 5 + }; + + isOver = degrees > scanner.range[1]; + isUnder = degrees <= scanner.range[0]; + + // Calculate the next step position + if (isOver || isUnder) { + if (isOver) { + io.sockets.emit("reset"); + degrees = 0; + step = 1; + last = -1; + } else { + step *= -1; + } + } + + // Update the position by N° step + degrees += step; + + // Update servo position + scanner.to(degrees); + }); + + io.sockets.on("connection", function(socket) { + console.log("Socket Connected"); + + soi = socket; + + ping.on("read", function() { + + if (last !== degrees) { + io.sockets.emit("ping", { + degrees: degrees, + distance: this.cm + }); + } + + last = degrees; + }); + }); +}); + + +// // Reference +// // +// // http://www.maxbotix.com/pictures/articles/012_Diagram_690X480.jpg diff --git a/JavaScript/node_modules/johnny-five/eg/nodeconf-slider.js b/JavaScript/node_modules/johnny-five/eg/nodeconf-slider.js new file mode 100644 index 0000000..4f5c735 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nodeconf-slider.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"), + board, slider, servo, scalingRange; + +board = new five.Board(); + +board.on("ready", function() { + + slider = new five.Sensor({ + pin: "A0", + freq: 50 + }); + + // log out the slider values to the console. + slider.on("slide", function(err, value) { + if (err) { + console.log("error: ", err); + } else { + console.log(Math.floor(this.value)); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/nunchuk.js b/JavaScript/node_modules/johnny-five/eg/nunchuk.js new file mode 100644 index 0000000..92c2c9c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/nunchuk.js @@ -0,0 +1,100 @@ +var five = require("../lib/johnny-five.js"), + board, nunchuk; + +board = new five.Board(); + +board.on("ready", function() { + + // When using the WiiChuck adapter with an UNO, + // these pins act as the Ground and Power lines. + // This will not work on a Leonardo, so these + // lines can be removed. + new five.Pin("A2").low(); + new five.Pin("A3").high(); + + // Create a new `nunchuk` hardware instance. + nunchuk = new five.Wii.Nunchuk({ + freq: 50 + }); + + + // Nunchuk Event API + // + + // "read" (nunchuk) + // + // Fired when the joystick detects a change in + // axis position. + // + // nunchuk.on( "read", function( err ) { + + // }); + + // "change", "axischange" (joystick) + // + // Fired when the joystick detects a change in + // axis position. + // + nunchuk.joystick.on("change", function(err, event) { + console.log( + "joystick " + event.axis, + event.target[event.axis], + event.axis, event.direction + ); + }); + + // "change", "axischange" (accelerometer) + // + // Fired when the accelerometer detects a change in + // axis position. + // + nunchuk.accelerometer.on("change", function(err, event) { + console.log( + "accelerometer " + event.axis, + event.target[event.axis], + event.axis, event.direction + ); + }); + + // "down" + // aliases: "press", "tap", "impact", "hit" + // + // Fired when any nunchuk button is "down" + // + + // "up" + // alias: "release" + // + // Fired when any nunchuk button is "up" + // + + // "hold" + // + // Fired when any nunchuk button is in the "down" state for + // a specified amount of time. Defaults to 500ms + // + // To specify a custom hold time, use the "holdtime" + // option of the Nunchuk constructor. + // + + + ["down", "up", "hold"].forEach(function(type) { + + nunchuk.on(type, function(err, event) { + console.log( + event.target.which + " is " + type, + + { + isUp: event.target.isUp, + isDown: event.target.isDown + } + ); + }); + + }); + + + // Further reading + // http://media.pragprog.com/titles/msard/tinker.pdf + // http://lizarum.com/assignments/physical_computing/2008/wii_nunchuck.html +}); diff --git a/JavaScript/node_modules/johnny-five/eg/oled.js b/JavaScript/node_modules/johnny-five/eg/oled.js new file mode 100644 index 0000000..ecd7ecc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/oled.js @@ -0,0 +1,32 @@ +var pngtolcd = require("png-to-lcd"); +var five = require("../"); +var board = new five.Board(); +var Oled = require("oled-js"); +var font = require("oled-font-5x7"); + +board.on("ready", function() { + + var opts = { + width: 128, + height: 64, + address: 0x3D + }; + + var oled = new Oled(board, five, opts); + oled.clearDisplay(); + oled.setCursor(0, 0); + oled.writeString(font, 1, "Cats and dogs are really cool animals, you know.", 1, true); + + // oled.drawPixel([ + // [127, 0, 1], + // [127, 31, 1], + // [127, 16, 1], + // [64, 16, 1] + // ]); + // // display a bitmap + // pngtolcd(__dirname + "/johnny.png", true, function(err, bitmapbuf) { + // console.log(bitmapbuf); + // oled.buffer = bitmapbuf; + // // oled.update(); + // }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/pcduino-io.js b/JavaScript/node_modules/johnny-five/eg/pcduino-io.js new file mode 100644 index 0000000..2229fc8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pcduino-io.js @@ -0,0 +1,24 @@ +var five = require("../lib/johnny-five.js"); +var pcDuino = require("pcduino-io"); +var board = new five.Board({ + io: new pcDuino() +}); + +board.on("ready", function() { + var led = new five.Led(13); + led.blink(); +}); + +// @markdown +// +// In order to use the pcduino-io library, you will need to install node.js (0.10.x or better) +// and npm on your pcduino. Once the environment is created, install Johnny-Five and pcDuino-IO. +// +// [Setup environment](https://github.com/rwaldron/pcduino-io#install-a-compatible-version-of-nodenpm) +// +// ```sh +// npm install johnny-five pcduino-io +// ``` +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/pee-wee.js b/JavaScript/node_modules/johnny-five/eg/pee-wee.js new file mode 100644 index 0000000..077867f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pee-wee.js @@ -0,0 +1,66 @@ +var five = require("../lib/johnny-five.js"); +var keypress = require("keypress"); +var board = new five.Board(); + + +board.on("ready", function() { + var speed = 200; + var commands = null; + var configs = five.Motor.SHIELD_CONFIGS.POLOLU_DRV8835_SHIELD; + var motors = { + right: new five.Motor(configs.M1), + left: new five.Motor(configs.M2) + }; + + this.repl.inject({ + motors: motors + }); + + function controller(ch, key) { + if (key) { + if (key.name === "space") { + motors.right.stop(); + motors.left.stop(); + } + if (key.name === "up") { + motors.right.fwd(speed); + motors.left.fwd(speed); + } + if (key.name === "down") { + motors.right.rev(speed); + motors.left.rev(speed); + } + if (key.name === "right") { + motors.right.rev(speed * 0.75); + motors.left.fwd(speed * 0.75); + } + if (key.name === "left") { + motors.right.fwd(speed * 0.75); + motors.left.rev(speed * 0.75); + } + + commands = [].slice.call(arguments); + } else { + if (ch >= 1 && ch <= 9) { + speed = five.Fn.scale(ch, 1, 9, 0, 255); + controller.apply(null, commands); + } + } + } + + + keypress(process.stdin); + + process.stdin.on("keypress", controller); + process.stdin.setRawMode(true); + process.stdin.resume(); +}); + +// @markdown +// +//  +// +//  +// +// @markdown + diff --git a/JavaScript/node_modules/johnny-five/eg/phoenix.js b/JavaScript/node_modules/johnny-five/eg/phoenix.js new file mode 100644 index 0000000..11fe86f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/phoenix.js @@ -0,0 +1,422 @@ +/** + * This example is used to control a Lynxmotion Phoenix hexapod + * via an Arduino Mega and DFRobot Mega Sensor Shield along with + * an Arduino Uno and Sparkfun Joystick Shield + * + * Robot + * http://www.lynxmotion.com/c-117-phoenix.aspx + * http://arduino.cc/en/Main/ArduinoBoardMegaADK + * http://www.dfrobot.com/index.php?route=product/product&path=35_124&product_id=560 + * + * You will want to update a couple of things if you are going to use this code: + * 1. You can tweak your walk with the "lift" and "s" objects. + * 2. You can trim your servos by changing the offset values on each servo + * + */ + +var five = require("../lib/johnny-five.js"), + temporal = require("temporal"), + board, ph = { + state: "sleep" + }, + easeIn = "inQuad", + easeOut = "outQuad", + easeInOut = "inOutQuad", + + // This object describes the "leg lift" used in walking + lift = { + femur: 30, + tibia: -20 + }, + + // By default, the gait length is about 2". Adjusting this + // value scales the gait and can really help out if your + // using servos don't have enough torque resulting in a + // saggy bottomed Phoenix. Note that the femur and tibia + // positions are optimized for a gait scale of 1.0. + gait = 1, + + // This object contains the home positions of each + // servo in its forward, mid and rear position for + // walking. + s = { + front: { + coxa: [66 - 26 * gait, 66, 66 + 19 * gait], + femur: [100, 94, 65], + tibia: [115, 93, 40] + }, + mid: { + coxa: [68 - 16 * gait, 68, 68 + 16 * gait], + femur: [92, 93, 86], + tibia: [95, 96, 82] + }, + rear: { + coxa: [59 + 18 * gait, 59, 59 - 22 * gait], + femur: [80, 92, 100], + tibia: [70, 100, 113] + } + }; + +// Your port addresses will vary +board = new five.Board().on("ready", function() { + + ph.r1c = new five.Servo({ + pin: 23, + offset: 10, + startAt: 45 + }); + ph.r1f = new five.Servo({ + pin: 22, + offset: -6, + startAt: 180 + }); + ph.r1t = new five.Servo({ + pin: 21, + offset: -7, + startAt: 180 + }); + ph.r1 = new five.Servo.Array([ph.r1c, ph.r1f, ph.r1t]); + + ph.l1c = new five.Servo({ + pin: 27, + invert: true, + offset: -7, + startAt: 45 + }); + ph.l1f = new five.Servo({ + pin: 25, + invert: true, + offset: -2, + startAt: 180 + }); + ph.l1t = new five.Servo({ + pin: 24, + invert: true, + offset: -8, + startAt: 180 + }); + ph.l1 = new five.Servo.Array([ph.l1c, ph.l1f, ph.l1t]); + + ph.r2c = new five.Servo({ + pin: 17, + offset: 16, + startAt: 45 + }); + ph.r2f = new five.Servo({ + pin: 16, + offset: 12, + startAt: 180 + }); + ph.r2t = new five.Servo({ + pin: 15, + offset: 2, + startAt: 180 + }); + ph.r2 = new five.Servo.Array([ph.r2c, ph.r2f, ph.r2t]); + + ph.l2c = new five.Servo({ + pin: 20, + invert: true, + offset: 21, + startAt: 45 + }); + ph.l2f = new five.Servo({ + pin: 19, + invert: true, + offset: -19, + startAt: 180 + }); + ph.l2t = new five.Servo({ + pin: 18, + invert: true, + offset: -3, + startAt: 180 + }); + ph.l2 = new five.Servo.Array([ph.l2c, ph.l2f, ph.l2t]); + + ph.r3c = new five.Servo({ + pin: 9, + invert: true, + offset: 10, + startAt: 45 + }); + ph.r3f = new five.Servo({ + pin: 4, + offset: 1, + startAt: 180 + }); + ph.r3t = new five.Servo({ + pin: 5, + offset: -10, + startAt: 180 + }); + ph.r3 = new five.Servo.Array([ph.r3c, ph.r3f, ph.r3t]); + + ph.l3c = new five.Servo({ + pin: 14, + offset: 5, + startAt: 45 + }); + ph.l3f = new five.Servo({ + pin: 2, + invert: true, + offset: -5, + startAt: 180 + }); + ph.l3t = new five.Servo({ + pin: 3, + invert: true, + startAt: 180 + }); + ph.l3 = new five.Servo.Array([ph.l3c, ph.l3f, ph.l3t]); + + ph.femurs = new five.Servo.Array([ph.r1f, ph.l1f, ph.r2f, ph.l2f, ph.r3f, ph.l3f]); + ph.tibia = new five.Servo.Array([ph.r1t, ph.l1t, ph.r2t, ph.l2t, ph.r3t, ph.l3t]); + ph.coxa = new five.Servo.Array([ph.r1c, ph.l1c, ph.r2c, ph.l2c, ph.r3c, ph.l3c]); + ph.joints = new five.Servo.Array([ph.coxa, ph.femurs, ph.tibia]); + + ph.legs = new five.Servo.Array([ph.r1c, ph.r1f, ph.r1t, ph.l1c, ph.l1f, ph.l1t, ph.r2c, ph.r2f, ph.r2t, ph.l2c, ph.l2f, ph.l2t, ph.r3c, ph.r3f, ph.r3t, ph.l3c, ph.l3f, ph.l3t]); + + var legsAnimation = new five.Animation(ph.legs); + + var stand = { + target: ph.joints, + duration: 500, + loop: false, + fps: 100, + cuePoints: [0, 0.1, 0.3, 0.7, 1.0], + oncomplete: function() { + ph.state = "stand"; + }, + keyFrames: [ + [null, { + degrees: s.front.coxa[1] + }], + [null, false, false, { + degrees: s.front.femur[1] + 26, + easing: easeOut + }, { + degrees: s.front.femur[1], + easing: easeIn + }], + [null, false, { + degrees: s.front.tibia[1] + 13 + }, + false, { + degrees: s.front.tibia[1] + } + ] + ] + }; + + var sleep = { + duration: 500, + cuePoints: [0, 0.5, 1.0], + fps: 100, + target: ph.joints, + oncomplete: function() { + ph.state = "sleep"; + }, + keyFrames: [ + [null, false, { degrees: 45, easing: easeOut }], + [null, { degrees: 136, easing: easeInOut }, { degrees: 180, easing: easeInOut }], + [null, { degrees: 120, easing: easeInOut }, { step: 60, easing: easeInOut }] + ] + }; + + var waveRight = { + duration: 1500, + cuePoints: [0, 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], + target: ph.r1, + oncomplete: function() { + ph.state = "stand"; + }, + keyFrames: [ + [null, false, { degrees: 120, easing: easeInOut }, false, false, false, false, false, { degrees: 52, easing: easeInOut }, {copyDegrees: 0, easing: easeInOut} ], // r1c + [null, { step: 55, easing: easeInOut }, false, false, false, false, false, false, { step: -55, easing: easeInOut }, {copyDegrees: 0, easing: easeInOut} ], // r1f + [null, { degrees: 85, easing: easeInOut }, { degrees: 45, easing: easeInOut }, { step: -15, easing: easeInOut}, { step: 30, easing: easeInOut}, { copyDegrees: 3, easing: easeInOut}, { copyFrame: 4 }, { copyDegrees: 2, easing: easeInOut}, { copyFrame: 1 }, {copyDegrees: 0, easing: easeInOut} ] + ] + }; + + var waveLeft = { + duration: 1500, + cuePoints: [0, 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], + target: ph.l1, + oncomplete: function() { + ph.state = "stand"; + }, + keyFrames: [ + [null, false, { degrees: 120, easing: easeInOut }, false, false, false, false, false, { degrees: 52, easing: easeInOut }, {copyDegrees: 0, easing: easeInOut} ], // l1c + [null, { step: 55, easing: easeInOut }, false, false, false, false, false, false, { step: -55, easing: easeInOut }, {copyDegrees: 0, easing: easeInOut} ], // l1f + [null, { degrees: 85, easing: easeInOut }, { degrees: 45, easing: easeInOut }, { step: -15, easing: easeInOut}, { step: 30, easing: easeInOut}, { copyDegrees: 3, easing: easeInOut}, { copyFrame: 4 }, { copyDegrees: 2, easing: easeInOut}, { copyFrame: 1 }, {copyDegrees: 0, easing: easeInOut} ] + ] + }; + + ph.walk = function(dir) { + var a = dir === "rev" ? 0 : 2, + b = dir === "rev" ? 2 : 0; + + legsAnimation.enqueue({ + duration: 1500, + cuePoints: [0, 0.25, 0.5, 0.625, 0.75, 0.875, 1.0], + loop: true, + loopback: 0.5, + fps: 100, + onstop: function() { + ph.att(); + }, + oncomplete: function() {}, + keyFrames: [ + [ null, null, {degrees: s.front.coxa[a]}, {degrees: s.front.coxa[1]}, {degrees: s.front.coxa[b]}, null, {degrees: s.front.coxa[a]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[a], easing: easeIn}, {degrees: s.front.femur[1]}, {degrees: s.front.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[a], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[a], easing: easeIn}, {degrees: s.front.tibia[1]}, {degrees: s.front.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[a], easing: easeIn}], + + [ null, null, {degrees: s.front.coxa[b]}, null, {degrees: s.front.coxa[a]}, {degrees: s.front.coxa[1]}, {degrees: s.front.coxa[b]}], + [ null, null, {degrees: s.front.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[a], easing: easeIn}, {degrees: s.front.femur[1]}, {degrees: s.front.femur[b]}], + [ null, null, {degrees: s.front.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[a], easing: easeIn}, {degrees: s.front.tibia[1]}, {degrees: s.front.tibia[b]}], + + [ null, null, {degrees: s.mid.coxa[b]}, null, {degrees: s.mid.coxa[a]}, {degrees: s.mid.coxa[1]}, {degrees: s.mid.coxa[b]}], + [ null, null, {degrees: s.mid.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[a], easing: easeIn}, {degrees: s.mid.femur[1]}, {degrees: s.mid.femur[b]}], + [ null, null, {degrees: s.mid.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[a], easing: easeIn}, {degrees: s.mid.tibia[1]}, {degrees: s.mid.tibia[b]}], + + [ null, null, {degrees: s.mid.coxa[a]}, {degrees: s.mid.coxa[1]}, {degrees: s.mid.coxa[b]}, null, {degrees: s.mid.coxa[a]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[a], easing: easeIn}, {degrees: s.mid.femur[1]}, {degrees: s.mid.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[a], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[a], easing: easeIn}, {degrees: s.mid.tibia[1]}, {degrees: s.mid.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[a], easing: easeIn}], + + [ null, null, {degrees: s.rear.coxa[a]}, {degrees: s.rear.coxa[1]}, {degrees: s.rear.coxa[b]}, null, {degrees: s.rear.coxa[a]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[a], easing: easeIn}, {degrees: s.rear.femur[1]}, {degrees: s.rear.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[a], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[a], easing: easeIn}, {degrees: s.rear.tibia[1]}, {degrees: s.rear.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[a], easing: easeIn}], + + [ null, null, {degrees: s.rear.coxa[b]}, null, {degrees: s.rear.coxa[a]}, {degrees: s.rear.coxa[1]}, {degrees: s.rear.coxa[b]}], + [ null, null, {degrees: s.rear.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[a], easing: easeIn}, {degrees: s.rear.femur[1]}, {degrees: s.rear.femur[b]}], + [ null, null, {degrees: s.rear.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[a], easing: easeIn}, {degrees: s.rear.tibia[1]}, {degrees: s.rear.tibia[b]}], + ] + }); + return this; + }; + + ph.turn = function(dir) { + var a = dir === "left" ? 0 : 2, + b = dir === "left" ? 2 : 0; + + legsAnimation.enqueue({ + duration: 1500, + fps: 100, + cuePoints: [0, 0.25, 0.5, 0.625, 0.75, 0.875, 1.0], + loop: true, + loopback: 0.5, + onstop: function() { + ph.att(); + }, + keyFrames: [ + [ null, null, {degrees: s.front.coxa[a]}, null, {degrees: s.front.coxa[b]}, null, {degrees: s.front.coxa[a]}], + [ null, null, {degrees: s.front.femur[a]}, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[b]}, null, {degrees: s.front.femur[a]}], + [ null, null, {degrees: s.front.tibia[a]}, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[b]}, null, {degrees: s.front.tibia[a]}], + + [ null, null, {degrees: s.front.coxa[a]}, null, {degrees: s.front.coxa[b]}, null, {degrees: s.front.coxa[a]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[a], easing: easeIn}, null, {degrees: s.front.femur[b], easing: easeIn}, { step: lift.femur, easing: easeOut }, {degrees: s.front.femur[a], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[a], easing: easeIn}, null, {degrees: s.front.tibia[b], easing: easeIn}, { step: lift.tibia, easing: easeOut }, {degrees: s.front.tibia[a], easing: easeIn}], + + [ null, null, {degrees: s.mid.coxa[b]}, null, {degrees: s.mid.coxa[a]}, null, {degrees: s.mid.coxa[b]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[b], easing: easeIn}, null, {degrees: s.mid.femur[a], easing: easeIn}, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[b], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[b], easing: easeIn}, null, {degrees: s.mid.tibia[a], easing: easeIn}, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[b], easing: easeIn}], + + [ null, null, {degrees: s.mid.coxa[b]}, null, {degrees: s.mid.coxa[a]}, null, {degrees: s.mid.coxa[b]}], + [ null, null, {degrees: s.mid.femur[b]}, { step: lift.femur, easing: easeOut }, {degrees: s.mid.femur[a]}, null, {degrees: s.mid.femur[b]}], + [ null, null, {degrees: s.mid.tibia[b]}, { step: lift.tibia, easing: easeOut }, {degrees: s.mid.tibia[a]}, null, {degrees: s.mid.tibia[b]}], + + [ null, null, {degrees: s.rear.coxa[a]}, null, {degrees: s.rear.coxa[b]}, null, {degrees: s.rear.coxa[a]}], + [ null, null, {degrees: s.rear.femur[a]}, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[b]}, null, {degrees: s.rear.femur[a]}], + [ null, null, {degrees: s.rear.tibia[a]}, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[b]}, null, {degrees: s.rear.tibia[a]}], + + [ null, null, {degrees: s.rear.coxa[a]}, null, {degrees: s.rear.coxa[b]}, null, {degrees: s.rear.coxa[a]}], + [ null, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[a], easing: easeIn}, null, {degrees: s.rear.femur[b], easing: easeIn}, { step: lift.femur, easing: easeOut }, {degrees: s.rear.femur[a], easing: easeIn}], + [ null, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[a], easing: easeIn}, null, {degrees: s.rear.tibia[b], easing: easeIn}, { step: lift.tibia, easing: easeOut }, {degrees: s.rear.tibia[a], easing: easeIn}] + ] + }); + + return this; + + }; + + ph.att = function() { + var most = 0, grouped, mostIndex, ani, work = [ + { name: "r1", offset: 0, home: s.front.femur[1], thome: s.front.tibia[1], chome: s.front.coxa[1]}, + { name: "r2", offset: 0, home: s.mid.femur[1], thome: s.mid.tibia[1], chome: s.front.coxa[1] }, + { name: "r3", offset: 0, home: s.rear.femur[1], thome: s.rear.tibia[1], chome: s.front.coxa[1] }, + { name: "l1", offset: 0, home: s.front.femur[1], thome: s.front.tibia[1], chome: s.front.coxa[1] }, + { name: "l2", offset: 0, home: s.mid.femur[1], thome: s.mid.tibia[1], chome: s.front.coxa[1] }, + { name: "l3", offset: 0, home: s.rear.femur[1], thome: s.rear.tibia[1], chome: s.front.coxa[1] } + ]; + + work.forEach(function(leg, i) { + work[i].offset = Math.abs(ph[leg.name + "f"].last.reqDegrees - leg.home); + }); + + if (work[1].offset > work[4].offset) { + grouped = [ + [0, 2, 4], + [1, 3, 5] + ]; + } else { + grouped = [ + [1, 3, 5], + [0, 2, 4] + ]; + } + + grouped.forEach(function(group, i) { + group.forEach(function(leg, j) { + temporal.queue([{ + delay: 250 * i, + task: function() { + ph[work[leg].name + "f"].to(work[leg].home + lift.femur); + ph[work[leg].name + "t"].to(work[leg].thome + lift.tibia); + } + }, { + delay: 50, + task: function() { + ph[work[leg].name + "c"].to(work[leg].chome); + } + }, { + delay: 50, + task: function() { + ph[work[leg].name + "f"].to(work[leg].home); + ph[work[leg].name + "t"].to(work[leg].thome); + } + }]); + }); + }); + ph.state = "stand"; + }; + + ph.sleep = function() { + legsAnimation.enqueue(sleep); + }; + + ph.waveLeft = function() { + legsAnimation.enqueue(waveLeft); + }; + + ph.waveRight = function() { + legsAnimation.enqueue(waveRight); + }; + + ph.stand = function() { + legsAnimation.enqueue(stand); + }; + + ph.stop = function() { + legsAnimation.stop(); + }; + + // Inject the `ph` object into + // the Repl instance's context + // allows direct command line access + this.repl.inject({ + ph: ph + }); + + ph.sleep(); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/photoresistor.js b/JavaScript/node_modules/johnny-five/eg/photoresistor.js new file mode 100644 index 0000000..18225a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/photoresistor.js @@ -0,0 +1,30 @@ +var five = require("../lib/johnny-five.js"), + board, photoresistor; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `photoresistor` hardware instance. + photoresistor = new five.Sensor({ + pin: "A2", + freq: 250 + }); + + // Inject the `sensor` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + pot: photoresistor + }); + + // "data" get the current reading from the photoresistor + photoresistor.on("data", function() { + console.log(this.value); + }); +}); + + +// References +// +// http://nakkaya.com/2009/10/29/connecting-a-photoresistor-to-an-arduino/ diff --git a/JavaScript/node_modules/johnny-five/eg/piezo-note-scale.js b/JavaScript/node_modules/johnny-five/eg/piezo-note-scale.js new file mode 100644 index 0000000..a465881 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/piezo-note-scale.js @@ -0,0 +1,128 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + // Creates a piezo object and defines the pin to be used for the signal + var piezo = new five.Piezo(3); + + // Injects the piezo into the repl + board.repl.inject({ + piezo: piezo + }); + + // Full note list available to johnny-five. Note + // that notes at both ends of the list are indistingushable + // from one another. Octaves 3 to 6 work best. + piezo.play({ + song: [ + ["c0", 1 / 6], + ["c#0", 1 / 6], + ["d0", 1 / 6], + ["d#0", 1 / 6], + ["e0", 1 / 6], + ["f0", 1 / 6], + ["f#0", 1 / 6], + ["g0", 1 / 6], + ["g#0", 1 / 6], + ["a0", 1 / 6], + ["a#0", 1 / 6], + ["b0", 1 / 6], + ["c1", 1 / 6], + ["c#1", 1 / 6], + ["d1", 1 / 6], + ["d#1", 1 / 6], + ["e1", 1 / 6], + ["f1", 1 / 6], + ["f#1", 1 / 6], + ["g1", 1 / 6], + ["g#1", 1 / 6], + ["a1", 1 / 6], + ["a#1", 1 / 6], + ["b1", 1 / 6], + ["c2", 1 / 6], //Start of noticable range + ["c#2", 1 / 6], + ["d2", 1 / 6], + ["d#2", 1 / 6], + ["e2", 1 / 6], + ["f2", 1 / 6], + ["f#2", 1 / 6], + ["g2", 1 / 6], + ["g#2", 1 / 6], + ["a2", 1 / 6], + ["a#2", 1 / 6], + ["b2", 1 / 6], + ["c3", 1 / 6], + ["c#3", 1 / 6], + ["d3", 1 / 6], + ["d#3", 1 / 6], + ["e3", 1 / 6], + ["f3", 1 / 6], + ["f#3", 1 / 6], + ["g3", 1 / 6], + ["g#3", 1 / 6], + ["a3", 1 / 6], + ["a#3", 1 / 6], + ["b3", 1 / 6], + ["c4", 1 / 6], + ["c#4", 1 / 6], + ["d4", 1 / 6], + ["d#4", 1 / 6], + ["e4", 1 / 6], + ["f4", 1 / 6], + ["f#4", 1 / 6], + ["g4", 1 / 6], + ["g#4", 1 / 6], + ["a4", 1 / 6], + ["a#4", 1 / 6], + ["b4", 1 / 6], + ["c5", 1 / 6], + ["c#5", 1 / 6], + ["d5", 1 / 6], + ["d#5", 1 / 6], + ["e5", 1 / 6], + ["f5", 1 / 6], + ["f#5", 1 / 6], + ["g5", 1 / 6], + ["g#5", 1 / 6], + ["a5", 1 / 6], + ["a#5", 1 / 6], + ["b5", 1 / 6], + ["c6", 1 / 6], //End of noticable range + ["c#6", 1 / 6], + ["d6", 1 / 6], + ["d#6", 1 / 6], + ["e6", 1 / 6], + ["f6", 1 / 6], + ["f#6", 1 / 6], + ["g6", 1 / 6], + ["g#6", 1 / 6], + ["a6", 1 / 6], + ["a#6", 1 / 6], + ["b6", 1 / 6], + ["c7", 1 / 6], + ["c#7", 1 / 6], + ["d7", 1 / 6], + ["d#7", 1 / 6], + ["e7", 1 / 6], + ["f7", 1 / 6], + ["f#7", 1 / 6], + ["g7", 1 / 6], + ["g#7", 1 / 6], + ["a7", 1 / 6], + ["a#7", 1 / 6], + ["b7", 1 / 6], + ["c8", 1 / 6], + ["c#8", 1 / 6], + ["d8", 1 / 6], + ["d#8", 1 / 6], + ["e8", 1 / 6], + ["f8", 1 / 6], + ["f#8", 1 / 6], + ["g8", 1 / 6], + ["g#8", 1 / 6], + ["a8", 1 / 6], + ["a#8", 1 / 6], + ["b8", 1 / 6] + ] + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/piezo.js b/JavaScript/node_modules/johnny-five/eg/piezo.js new file mode 100644 index 0000000..56da785 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/piezo.js @@ -0,0 +1,51 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + // Creates a piezo object and defines the pin to be used for the signal + var piezo = new five.Piezo(3); + + // Injects the piezo into the repl + board.repl.inject({ + piezo: piezo + }); + + // Plays a song + piezo.play({ + // song is composed by an array of pairs of notes and beats + // The first argument is the note (null means "no note") + // The second argument is the length of time (beat) of the note (or non-note) + song: [ + ["C4", 1 / 4], + ["D4", 1 / 4], + ["F4", 1 / 4], + ["D4", 1 / 4], + ["A4", 1 / 4], + [null, 1 / 4], + ["A4", 1], + ["G4", 1], + [null, 1 / 2], + ["C4", 1 / 4], + ["D4", 1 / 4], + ["F4", 1 / 4], + ["D4", 1 / 4], + ["G4", 1 / 4], + [null, 1 / 4], + ["G4", 1], + ["F4", 1], + [null, 1 / 2] + ], + tempo: 100 + }); + + // Plays the same song with a string representation + piezo.play({ + // song is composed by a string of notes + // a default beat is set, and the default octave is used + // any invalid note is read as "no note" + song: "C D F D A - A A A A G G G G - - C D F D G - G G G G F F F F - -", + beats: 1 / 4, + tempo: 100 + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/pin-circuit-event.js b/JavaScript/node_modules/johnny-five/eg/pin-circuit-event.js new file mode 100644 index 0000000..9a1e270 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pin-circuit-event.js @@ -0,0 +1,12 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + var pin = new five.Pin(5); + + // Event tests + ["high", "low"].forEach(function(type) { + pin.on(type, function() { + console.log("Circuit Event: ", type); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/pin-dtoa.js b/JavaScript/node_modules/johnny-five/eg/pin-dtoa.js new file mode 100644 index 0000000..9e695bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pin-dtoa.js @@ -0,0 +1,7 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var pin = new five.Pin(14); + pin.high(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/pin.js b/JavaScript/node_modules/johnny-five/eg/pin.js new file mode 100644 index 0000000..77bc329 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pin.js @@ -0,0 +1,31 @@ +var five = require("../lib/johnny-five.js"); +var temporal = require("temporal"); +var board = new five.Board(); + +board.on("ready", function() { + var events = []; + var strobe = new five.Pin(13); + + temporal.loop(500, function(loop) { + strobe[loop.called % 2 === 0 ? "high" : "low"](); + }); + + + // Pin emits "high" and "low" events, whether it's + // input or output. + ["high", "low"].forEach(function(state) { + strobe.on(state, function() { + if (events.indexOf(state) === -1) { + console.log("Event emitted for:", state, "on", this.addr); + events.push(state); + } + }); + }); + + var analog = new five.Pin("A0"); + + // Query the analog pin for its current state. + analog.query(function(state) { + console.log(state); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/ping.js b/JavaScript/node_modules/johnny-five/eg/ping.js new file mode 100644 index 0000000..be3c38f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/ping.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `ping` hardware instance. + var ping = new five.Ping(7); + + // Properties + + // ping.in/ping.inches + // + // Calculated distance to object in inches + // + + // ping.cm + // + // Calculated distance to object in centimeters + // + + + ping.on("change", function() { + console.log("Object is " + this.in + " inches away"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/plugin.js b/JavaScript/node_modules/johnny-five/eg/plugin.js new file mode 100644 index 0000000..bc5a7b1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/plugin.js @@ -0,0 +1,45 @@ +var Board = require("../lib/board.js"); + +module.exports = function(five) { + return (function() { + + function Component(opts) { + if (!(this instanceof Component)) { + return new Component(opts); + } + + // Board.Component + // - Register the component with an + // existing Board instance. + // + // Board.Options + // - Normalize incoming options + // - Convert string or number pin values + // to `this.pin = value` + // - Calls an IO Plugin's `normalize` method + // + Board.Component.call( + this, opts = Board.Options(opts) + ); + + + // Define Component initialization + + } + + // Define Component Prototype + + + return Component; + }()); +}; + + +/** + * To use the plugin in a program: + * + * var five = require("johnny-five"); + * var Component = require("component")(five); + * + * + */ diff --git a/JavaScript/node_modules/johnny-five/eg/potentiometer.js b/JavaScript/node_modules/johnny-five/eg/potentiometer.js new file mode 100644 index 0000000..84a46ad --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/potentiometer.js @@ -0,0 +1,30 @@ +var five = require("../lib/johnny-five.js"), + board, potentiometer; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `potentiometer` hardware instance. + potentiometer = new five.Sensor({ + pin: "A2", + freq: 250 + }); + + // Inject the `sensor` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + pot: potentiometer + }); + + // "data" get the current reading from the potentiometer + potentiometer.on("data", function() { + console.log(this.value, this.raw); + }); +}); + + +// References +// +// http://arduino.cc/en/Tutorial/AnalogInput diff --git a/JavaScript/node_modules/johnny-five/eg/protosnap.js b/JavaScript/node_modules/johnny-five/eg/protosnap.js new file mode 100644 index 0000000..51bf61d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/protosnap.js @@ -0,0 +1,64 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + var button = new five.Button({ + pin: 7, + isPullup: true + }); + + var rgb = new five.Led.RGB({ + pins: [3, 5, 6], + isAnode: true + }); + + button.on("down", function(value) { + rgb.color(rainbow[colors[index++]]); + + if (index === colors.length) { + index = 0; + } + }); + + button.on("up", function() { + rgb.stop(); + }); + + button.on("hold", function() { + rgb.pulse(500); + }); + + this.repl.inject({ + rgb: rgb + }); +}); + +var rgb = { + red: [0xff, 0x00, 0x00], + orange: [0xff, 0x7f, 0x00], + yellow: [0xff, 0xff, 0x00], + green: [0x00, 0xff, 0x00], + blue: [0x00, 0x00, 0xff], + indigo: [0x31, 0x00, 0x62], + violet: [0x4b, 0x00, 0x82], + white: [0xff, 0xff, 0xff], +}; + +var rainbow = Object.keys(rgb).reduce(function(colors, color) { + // While testing, I found that the BlinkM produced + // more vibrant colors when provided a 7 bit value. + return (colors[color] = rgb[color].map(to7bit), colors); +}, {}); + +var colors = Object.keys(rainbow); +var index = 0; + +function scale(value, inMin, inMax, outMin, outMax) { + return (value - inMin) * (outMax - outMin) / + (inMax - inMin) + outMin; +} + +function to7bit(value) { + return scale(value, 0, 255, 0, 127) | 0; +} diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-find-exponent.js b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-find-exponent.js new file mode 100644 index 0000000..c30f29e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-find-exponent.js @@ -0,0 +1,27 @@ +var Barcli = require("barcli"); +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var g1 = new Barcli({ + label: "Modifier", + range: [0, 4] + }); + + var g2 = new Barcli({ + label: "CM", + range: [55, 182] + }); + + var proximity = new five.Proximity({ + controller: "GP2Y0A710K0F", + pin: "A0" + }); + + var modifier = new five.Sensor("A1").scale(0, 4); + + proximity.on("change", function() { + g1.update(modifier.value); + g2.update(3.8631e8 * Math.pow(this.cm, -modifier.value)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-graph.js b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-graph.js new file mode 100644 index 0000000..2f341d2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F-graph.js @@ -0,0 +1,19 @@ +var Barcli = require("barcli"); +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var graph = new Barcli({ + label: "Distance", + range: [55, 500] + }); + + var proximity = new five.Proximity({ + controller: "GP2Y0A710K0F", + pin: "A0" + }); + + proximity.on("change", function() { + graph.update(Math.round(this.cm)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F.js b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F.js new file mode 100644 index 0000000..b68a172 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-GP2Y0A710K0F.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "GP2Y0A710K0F", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-hcsr04.js b/JavaScript/node_modules/johnny-five/eg/proximity-hcsr04.js new file mode 100644 index 0000000..027749d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-hcsr04.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "HCSR04", + pin: 7 + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-lidarlite.js b/JavaScript/node_modules/johnny-five/eg/proximity-lidarlite.js new file mode 100644 index 0000000..33bfa8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-lidarlite.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "LIDARLITE" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log(this.cm + "cm"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-mb1000.js b/JavaScript/node_modules/johnny-five/eg/proximity-mb1000.js new file mode 100644 index 0000000..54cd725 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-mb1000.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "MB1000", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-mb1003.js b/JavaScript/node_modules/johnny-five/eg/proximity-mb1003.js new file mode 100644 index 0000000..a5820ff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-mb1003.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "MB1003", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-mb1010.js b/JavaScript/node_modules/johnny-five/eg/proximity-mb1010.js new file mode 100644 index 0000000..2eff60d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-mb1010.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "MB1010", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-mb1230.js b/JavaScript/node_modules/johnny-five/eg/proximity-mb1230.js new file mode 100644 index 0000000..d258abb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-mb1230.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "MB1230", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity-srf10.js b/JavaScript/node_modules/johnny-five/eg/proximity-srf10.js new file mode 100644 index 0000000..452aa1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity-srf10.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "SRF10" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/proximity.js b/JavaScript/node_modules/johnny-five/eg/proximity.js new file mode 100644 index 0000000..02d9171 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/proximity.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var proximity = new five.Proximity({ + controller: "GP2Y0A21YK", + pin: "A0" + }); + + proximity.on("data", function() { + console.log(this.cm + "cm", this.in + "in"); + }); + + proximity.on("change", function() { + console.log("The obstruction has moved."); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/pvector.js b/JavaScript/node_modules/johnny-five/eg/pvector.js new file mode 100644 index 0000000..3f4b778 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/pvector.js @@ -0,0 +1,190 @@ +/* + +PVector + +Processing.js +Copyright (C) 2008 John Resig +Copyright (C) 2009-2011; see the AUTHORS file for authors and +copyright holders. +*/ + +function PVector(x, y, z) { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; +} + +PVector.degrees = function(angle) { + return (angle * 180) / Math.PI; +}; + +PVector.fromAngle = function(angle, v) { + if (v === undefined || v === null) { + v = new PVector(); + } + v.x = Math.cos(angle); + v.y = Math.sin(angle); + return v; +}; + + +PVector.dist = function(v1, v2) { + return v1.dist(v2); +}; + +PVector.dot = function(v1, v2) { + return v1.dot(v2); +}; + +PVector.cross = function(v1, v2) { + return v1.cross(v2); +}; + +PVector.sub = function(v1, v2) { + return new PVector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); +}; + +PVector.between = function(v1, v2) { + return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); +}; + +// Common vector operations for PVector +PVector.prototype = { + constructor: PVector, + set: function(v, y, z) { + if (arguments.length === 1) { + this.set(v.x || v[0] || 0, + v.y || v[1] || 0, + v.z || v[2] || 0); + } else { + this.x = v; + this.y = y; + this.z = z; + } + }, + get: function() { + return new PVector(this.x, this.y, this.z); + }, + mag: function() { + var x = this.x, + y = this.y, + z = this.z; + return Math.sqrt(x * x + y * y + z * z); + }, + magSq: function() { + var x = this.x, + y = this.y, + z = this.z; + return (x * x + y * y + z * z); + }, + setMag: function(v_or_len, len) { + if (len === undefined) { + len = v_or_len; + this.normalize(); + this.mult(len); + } else { + var v = v_or_len; + v.normalize(); + v.mult(len); + return v; + } + }, + add: function(v, y, z) { + if (arguments.length === 1) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + } else { + this.x += v; + this.y += y; + this.z += z; + } + }, + sub: function(v, y, z) { + if (arguments.length === 1) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + } else { + this.x -= v; + this.y -= y; + this.z -= z; + } + }, + mult: function(v) { + if (typeof v === "number") { + this.x *= v; + this.y *= v; + this.z *= v; + } else { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + } + }, + div: function(v) { + if (typeof v === "number") { + this.x /= v; + this.y /= v; + this.z /= v; + } else { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; + } + }, + rotate: function(angle) { + var prev_x = this.x; + var c = Math.cos(angle); + var s = Math.sin(angle); + this.x = c * this.x - s * this.y; + this.y = s * prev_x + c * this.y; + }, + dist: function(v) { + var dx = this.x - v.x, + dy = this.y - v.y, + dz = this.z - v.z; + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + dot: function(v, y, z) { + if (arguments.length === 1) { + return (this.x * v.x + this.y * v.y + this.z * v.z); + } + return (this.x * v + this.y * y + this.z * z); + }, + cross: function(v) { + var x = this.x, + y = this.y, + z = this.z; + return new PVector(y * v.z - v.y * z, + z * v.x - v.z * x, + x * v.y - v.x * y); + }, + normalize: function() { + var m = this.mag(); + if (m > 0) { + this.div(m); + } + }, + toString: function() { + return "[" + this.x + ", " + this.y + ", " + this.z + "]"; + } +}; + + +function returnFunc(method) { + return function(v1, v2) { + var v = v1.get(); + v[method](v2); + return v; + }; +} + + +for (var method in PVector.prototype) { + if (!PVector[method]) { + PVector[method] = returnFunc(method); + } +} + +exports.PVector = PVector; diff --git a/JavaScript/node_modules/johnny-five/eg/radar-client.js b/JavaScript/node_modules/johnny-five/eg/radar-client.js new file mode 100644 index 0000000..1ceebbf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/radar-client.js @@ -0,0 +1,271 @@ +(function(exports, io) { + + // private: `radars` cache array for storing instances of Radar, + + var socket, radars, colors, addl; + + socket = io.connect("http://localhost"); + radars = []; + colors = { + // Color Constants + yellow: "255, 255, 0", + + red: "255, 0, 0", + + green: "0, 199, 59", + + gray: "182, 184, 186" + }; + addl = { + distance: "cm", + degrees: "°" + }; + + socket.on("ping", function(data) { + if (radars.length) { + radars[0].ping(data.degrees, data.distance); + + + // TODO: This is bas + Object.keys(data).forEach(function(key) { + var node = document.querySelector("#" + key); + + if (node !== null) { + node.innerHTML = data[key] + addl[key]; + + if (node.dataset.moved === undefined) { + node.style.top = radars[0].height + "px"; + node.style.position = "relative"; + node.dataset.moved = true; + } + } + }); + } + }); + + socket.on("reset", function() { + console.log("RESET"); + + radars.length = 0; + new Radar("#canvas"); + }); + + + // Radar Constructor + + function Radar(selector, opts) { + var node, k; + + if (!(this instanceof Radar)) { + return new Radar(selector); + } + + node = document.querySelector(selector); + + if (node === null) { + throw new Error("Missing canvas"); + } + + opts = opts || {}; + + this.direction = opts.direction || "forward"; + + // Assign a context to this radar, from the cache of contexts + this.ctx = node.getContext("2d"); + + // Clear the canvas + this.ctx.clearRect(0, 0, node.width, node.height); + + // Store canvas width as diameter of arc + this.diameter = this.ctx.width; + + // Calculate this radar's radius - is used in arc drawing arguments + this.radius = this.diameter / 2; + + // Initialize step array + this.steps = [Math.PI]; + + // Calculate number of steps in sweep + this.step = Math.PI / 180; + + // Fill in step start radians + for (k = 1; k < 180; k++) { + this.steps.push(this.steps[k - 1] + this.step); + } + + // Set last seen angle to 0 + this.last = 0; + + // Draw the "grid" + this.grid(); + + radars.push(this); + } + + Radar.prototype = { + + draw: function(distance, start, end) { + + var x, y; + + x = this.ctx.canvas.width; + y = this.ctx.canvas.height; + + + this.ctx.beginPath(); + this.ctx.arc( + x / 2, + y, + distance / 2, + start, + end, + false + ); + + // Set color of arc line + this.ctx.strokeStyle = "lightgreen"; + this.ctx.lineWidth = distance; + + // Commit the line and close the path + this.ctx.stroke(); + this.ctx.closePath(); + + return this; + }, + + ping: function(azimuth, distance) { + + distance = Math.round(distance); + + + // If facing forward, invert the azimuth value, as it + // is actually moving 0-180, left-to-right + if (this.direction === "forward") { + azimuth = Math.abs(azimuth - 180); + + // Normalize display from mid sweep, forward + if (this.last === 0 && azimuth < 175) { + this.last = this.steps[azimuth + 1]; + } + + this.draw(distance, this.steps[azimuth], this.last); + } else { + + // Normalize display from mid sweep, backward + if (this.last === 0 && azimuth > 5) { + this.last = this.steps[azimuth - 1]; + } + + this.draw(distance, this.last, this.steps[azimuth]); + } + + + this.last = this.steps[azimuth]; + + return this; + }, + + grid: function() { + + var ctx, line, i, + grid = document.createElement("canvas"), + gridNode = document.querySelector("#radar_grid"), + dims = { + width: null, + height: null + }, + canvas = this.ctx.canvas, + radarDist = 0, + upper = 340; + + + if (gridNode === null) { + grid.id = "radar_grid"; + // Setup position of grid overlay + grid.style.position = "relative"; + grid.style.top = "-" + (canvas.height + 3) + "px"; + grid.style.zIndex = "9"; + + + // Setup size of grid overlay + grid.width = canvas.width; + grid.height = canvas.height; + + // Insert into DOM, directly following canvas to overlay + canvas.parentNode.insertBefore(grid, canvas.nextSibling); + + // Capture grid overlay canvas context + ctx = grid.getContext("2d"); + + + ctx.fillStyle = "black"; + ctx.fillRect(0, 0, grid.width, grid.height); + ctx.closePath(); + + ctx.font = "bold 12px Helvetica"; + + ctx.strokeStyle = "green"; + ctx.fillStyle = "green"; + ctx.lineWidth = 1; + + for (i = 0; i <= 6; i++) { + + ctx.beginPath(); + ctx.arc( + grid.width / 2, + grid.height, + + 60 * i, + + Math.PI * 2, 0, + true + ); + + if (i < 6) { + ctx.fillText( + radarDist + 60, + grid.width / 2 - 7, + upper + ); + } + + ctx.stroke(); + ctx.closePath(); + upper -= 60; + radarDist += 60; + } + } + + return this; + } + }; + + + + + // `radars` cache array access + Radar.get = function(index) { + return index !== undefined && radars[index]; + }; + + // Expose Radar API + exports.Radar = Radar; + +}(this, this.io)); + + +document.addEventListener("DOMContentLoaded", function() { + new Radar("#canvas", { + /** + * direction + * forward (facing away from controller) + * backward (facing controller) + * + * Defaults to "forward" + * + * @type {Object} + */ + + // direction: "forward" + }); +}, false); diff --git a/JavaScript/node_modules/johnny-five/eg/radar.html b/JavaScript/node_modules/johnny-five/eg/radar.html new file mode 100644 index 0000000..a72cc6b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/radar.html @@ -0,0 +1,17 @@ + + + + + Radar + + + + + + + + + + + + diff --git a/JavaScript/node_modules/johnny-five/eg/radar.js b/JavaScript/node_modules/johnny-five/eg/radar.js new file mode 100644 index 0000000..9ce36c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/radar.js @@ -0,0 +1,129 @@ +var five = require("../lib/johnny-five.js"), + child = require("child_process"), + http = require("http"), + socket = require("socket.io"), + fs = require("fs"), + app, board, io; + +function handler(req, res) { + var path = __dirname; + + if (req.url === "/") { + path += "/radar.html"; + } else { + path += req.url; + } + + fs.readFile(path, function(err, data) { + if (err) { + res.writeHead(500); + return res.end("Error loading " + path); + } + + res.writeHead(200); + res.end(data); + }); +} + +app = http.createServer(handler); +app.listen(8080); + +io = socket.listen(app); +io.set("log level", 1); + +board = new five.Board(); + +board.on("ready", function() { + var center, degrees, step, facing, range, scanner, soi, ping, last; + + + // Open Radar view + child.exec("open http://localhost:8080/"); + + // Starting scanner scanning position (degrees) + degrees = 1; + + // Servo scanning steps (degrees) + step = 1; + + // Current facing direction + facing = ""; + + last = 0; + + // Scanning range (degrees) + range = [0, 170]; + + // Servo center point (degrees) + center = range[1] / 2; + + // ping instance (distance detection) + ping = new five.Ping(7); + + // Servo instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + this.repl.inject({ + scanner: scanner + }); + + // Initialize the scanner servo at 0° + scanner.min(); + + // Scanner/Panning loop + this.loop(100, function() { + var bounds, isOver, isUnder; + + bounds = { + left: center + 5, + right: center - 5 + }; + + isOver = degrees > scanner.range[1]; + isUnder = degrees <= scanner.range[0]; + + // Calculate the next step position + if (isOver || isUnder) { + if (isOver) { + io.sockets.emit("reset"); + degrees = 0; + step = 1; + last = -1; + } else { + step *= -1; + } + } + + // Update the position by N° step + degrees += step; + + // Update servo position + scanner.to(degrees); + }); + + io.sockets.on("connection", function(socket) { + console.log("Socket Connected"); + + soi = socket; + + ping.on("data", function() { + + if (last !== degrees) { + io.sockets.emit("ping", { + degrees: degrees, + distance: this.cm + }); + } + + last = degrees; + }); + }); +}); + + +// // Reference +// // +// // http://www.maxbotix.com/pictures/articles/012_Diagram_690X480.jpg diff --git a/JavaScript/node_modules/johnny-five/eg/raspi-io.js b/JavaScript/node_modules/johnny-five/eg/raspi-io.js new file mode 100644 index 0000000..3d56319 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/raspi-io.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var Raspi = require("raspi-io"); +var board = new five.Board({ + io: new Raspi() +}); + +board.on("ready", function() { + var led = new five.Led("P1-13"); + led.blink(); +}); + +// @markdown +// +// In order to use the Raspi-IO library, it is recommended that you use +// the Raspbian OS. Others may work, but are untested. +// +// ```sh +// npm install johnny-five raspi-io +// ``` +// +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/relay.js b/JavaScript/node_modules/johnny-five/eg/relay.js new file mode 100644 index 0000000..7bc00d1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/relay.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var relay = new five.Relay(10); + + // Control the relay in real time + // from the REPL by typing commands, eg. + // + // relay.on(); + // + // relay.off(); + // + this.repl.inject({ + relay: relay + }); +}); +// @markdown +// +// - [JavaScript: Relay Control with Johnny-Five on Node.js](http://bocoup.com/weblog/javascript-relay-with-johnny-five/) +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/repl.js b/JavaScript/node_modules/johnny-five/eg/repl.js new file mode 100644 index 0000000..1db35c6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/repl.js @@ -0,0 +1,32 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + console.log("Ready event. Repl instance auto-initialized!"); + + var led = new five.Led(13); + + this.repl.inject({ + // Allow limited on/off control access to the + // Led instance from the REPL. + on: function() { + led.on(); + }, + off: function() { + led.off(); + } + }); +}); + + +// @markdown +// This script will make `on()` and `off()` functions +// available in the REPL: +// +// ```js +// >> on() // will turn on the LED +// // or +// >> off() // will turn off the LED +// ``` +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/rotary-encoder.js b/JavaScript/node_modules/johnny-five/eg/rotary-encoder.js new file mode 100644 index 0000000..7520463 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/rotary-encoder.js @@ -0,0 +1,92 @@ +var Emitter = require("events").EventEmitter; +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); +var emitter = new Emitter(); + + +function Encoder(opts) { + Emitter.call(this); + + var last = 0; + var lValue = 0; + var value = 0; + var rotation = 0; + + var a = new five.Digital(opts.a); + var b = new five.Digital(opts.b); + + var handler = function() { + this.emit("data", this.value); + + var MSB = a.value; + var LSB = b.value; + var pos, turn; + + if (LSB === 1) { + pos = MSB === 1 ? 0 : 1; + } else { + pos = MSB === 0 ? 2 : 3; + } + + turn = pos - last; + + if (Math.abs(turn) !== 2) { + if (turn === -1 || turn === 3) { + value++; + } else if (turn === 1 || turn === -3) { + value--; + } + } + + last = pos; + + if (lValue !== value) { + this.emit("change", value); + } + + if (value % 80 === 0 && value / 80 !== rotation) { + rotation = value / 80; + this.emit("rotation"); + } + + lValue = value; + }.bind(this); + + a.on("data", handler); + b.on("data", handler); + + Object.defineProperties(this, { + value: { + get: function() { + return value; + } + } + }); +} + +Encoder.prototype = Object.create(Emitter.prototype, { + constructor: { + value: Encoder + } +}); + +board.on("ready", function() { + var encoder = new Encoder({ + a: 8, + b: 9 + }); + + var button = new five.Button(11); + + button.on("press", function() { + console.log("pressed"); + }); + + encoder.on("change", function() { + console.log("Encoder At: %d", this.value); + }); + + encoder.on("rotation", function() { + console.log("Rotations: %d", Math.abs(this.value / 80)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-digital.js b/JavaScript/node_modules/johnny-five/eg/sensor-digital.js new file mode 100644 index 0000000..c1dc256 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-digital.js @@ -0,0 +1,14 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + + var pin = new five.Sensor({ + pin: 8, + type: "digital" + }); + + pin.on("data", function() { + console.log(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-fsr.js b/JavaScript/node_modules/johnny-five/eg/sensor-fsr.js new file mode 100644 index 0000000..aca9749 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-fsr.js @@ -0,0 +1,22 @@ +var five = require("../lib/johnny-five.js"), + fsr, led; + +(new five.Board()).on("ready", function() { + + // Create a new `fsr` hardware instance. + fsr = new five.Sensor({ + pin: "A0", + freq: 25 + }); + + led = new five.Led(9); + + // Scale the sensor's value to the LED's brightness range + fsr.scale([0, 255]).on("data", function() { + + // set the led's brightness based on force + // applied to force sensitive resistor + + led.brightness(this.value); + }); + }); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-generic.js b/JavaScript/node_modules/johnny-five/eg/sensor-generic.js new file mode 100644 index 0000000..f78c23d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-generic.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board({ + port: "/dev/cu.usbmodem1411" +}); + +board.on("ready", function() { + + var sensor = new five.Sensor({ + pin: "A0", + freq: 2000 + }); + + var B = 3975; + var R = (1023 - 498) * 10000 / 498; + var T = 1 / (Math.log(R / 10000) / B + 1 / 298.15) - 273.15; + console.log(T); + + // sensor.on("data", function() { + + // var B = 3975; + // var R = (1023 - this.raw) * 10000 / this.raw; + // var T = 1 / (Math.log(R / 10000) / B + 1 / 298.15) - 273.15; + // console.log(T); + // // console.log(this.value, this.raw); + // }); +}); + + diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-ir-led-receiver.js b/JavaScript/node_modules/johnny-five/eg/sensor-ir-led-receiver.js new file mode 100644 index 0000000..a640378 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-ir-led-receiver.js @@ -0,0 +1,30 @@ +var five = require("../lib/johnny-five.js"), + board, ir; + +board = new five.Board(); +board.on("ready", function() { + + ir = { + reference: new five.Led(13), + transmit: new five.Led(9), + receive: new five.Sensor({ + pin: 8, + freq: 10 + }) + }; + + ir.receive.scale([0, 100]).on("data", function() { + + // console.log( this.value ); + + }); + + ir.reference.on(); + + ir.transmit.strobe(1); + + + this.repl.inject({ + t: ir.transmit + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-output-with-barcli.js b/JavaScript/node_modules/johnny-five/eg/sensor-output-with-barcli.js new file mode 100644 index 0000000..a053432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-output-with-barcli.js @@ -0,0 +1,16 @@ +var Barcli = require("barcli"); +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var sensor = new five.Sensor("A0"); + var graph = new Barcli({ + label: "Sensor", + range: [0, 100] + }); + + sensor.scale([0, 100]).on("change", function() { + graph.update(this.value >>> 0); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor-slider.js b/JavaScript/node_modules/johnny-five/eg/sensor-slider.js new file mode 100644 index 0000000..aad0a4a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor-slider.js @@ -0,0 +1,12 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var slider = new five.Sensor("A0"); + + // "slide" is an alias for "change" + slider.scale([0, 100]).on("slide", function() { + console.log("slide", this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sensor.js b/JavaScript/node_modules/johnny-five/eg/sensor.js new file mode 100644 index 0000000..0616bdf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sensor.js @@ -0,0 +1,14 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new generic sensor instance for + // a sensor connected to an analog (ADC) pin + var sensor = new five.Sensor("A0"); + + // When the sensor value changes, log the value + sensor.on("change", function() { + console.log(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-EVS_EV3.js b/JavaScript/node_modules/johnny-five/eg/servo-EVS_EV3.js new file mode 100644 index 0000000..0cd39c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-EVS_EV3.js @@ -0,0 +1,67 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var servo = new five.Servo({ + controller: "EVS_EV3", + pin: "BBM1", + + }); + + servo.on("move:complete", function() { + console.log("COMPLETE"); + console.log("Position: ", this.value); + }); + // Add servo to REPL for live control (optional) + this.repl.inject({ + servo: servo + }); + + servo.to(360, 10000); +}); + + +// 375ms to travel 360 at 100% speed + + + + +// 100% = 170rpm = 1020dps + +// 75% = 127rpm = 765dps + +// 50% = 85rpm = 510dps; + +// 25% = 43rpm = 255dps; + + +// 90° = 2000ms = 45dps + +// (90 / 2000) * 1000 + + +// (degrees / time) * 1000 = Rdps + +// (Rdps / MAXdps) * 100; + + + + +// 100% = 160rpm = 960dps + +// 75% = 120rpm = 720dps + +// 50% = 80rpm = 480dps; + +// 25% = 40rpm = 240dps; + +// 90° = 2000ms = 45dps + +// (90 / 2000) * 1000 + + +// (degrees / time) * 1000 = Rdps + +// (Rdps / MAXdps) * 100; + diff --git a/JavaScript/node_modules/johnny-five/eg/servo-PCA9685-multi-pin-same-address.js b/JavaScript/node_modules/johnny-five/eg/servo-PCA9685-multi-pin-same-address.js new file mode 100644 index 0000000..aff6731 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-PCA9685-multi-pin-same-address.js @@ -0,0 +1,29 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var a = new five.Servo({ + address: 0x40, + controller: "PCA9685", + pin: 0, + }); + + var b = new five.Servo({ + address: 0x40, + controller: "PCA9685", + pin: 1, + }); + + var c = new five.Servo({ + address: 0x40, + controller: "PCA9685", + pin: 2, + }); + + var d = new five.Servo({ + address: 0x40, + controller: "PCA9685", + pin: 3, + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-PCA9685.js b/JavaScript/node_modules/johnny-five/eg/servo-PCA9685.js new file mode 100644 index 0000000..ebc3e32 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-PCA9685.js @@ -0,0 +1,73 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + console.log("Connected"); + + // Initialize the servo + var servo = new five.Servo({ + address: 0x40, + controller: "PCA9685", + pin: 0, + }); + + // Add servo to REPL for live control (optional) + this.repl.inject({ + servo: servo + }); + + + // Servo API + + // min() + // + // set the servo to the minimum degrees + // defaults to 0 + // + // eg. servo.min(); + + // max() + // + // set the servo to the maximum degrees + // defaults to 180 + // + // eg. servo.max(); + + // center() + // + // centers the servo to 90° + // + // servo.center(); + + // to( deg[, duration] ) + // + // Moves the servo to position by degrees + // duration (optional) sets duration of movement. + // + // servo.to( 90 ); + + // step( deg ) + // + // Moves the servo step degrees relative to current position + // + // servo.step( -10 ); + + // sweep( obj ) + // + // Perform a min-max cycling servo sweep (defaults to 0-180) + // optionally accepts an object of sweep settings: + // { + // lapse: time in milliseconds to wait between moves + // defaults to 500ms + // degrees: distance in degrees to move + // defaults to 10° + // } + // + servo.sweep(); + +}); + + +// References +// +// http://servocity.com/html/hs-7980th_servo.html diff --git a/JavaScript/node_modules/johnny-five/eg/servo-animation-leg.js b/JavaScript/node_modules/johnny-five/eg/servo-animation-leg.js new file mode 100644 index 0000000..59647f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-animation-leg.js @@ -0,0 +1,92 @@ +var five = require("../lib/johnny-five.js"), + ph = { + state: "sleep" + }; + +var board = new five.Board().on("ready", function() { + + /** + * This animation controls three servos + * The servos are the coxa, femur and tibia of a single + * leg on a hexapod. A full hexapod might need 18 + * servo instances (assuming 3 degrees of freedom) + */ + ph.coxa = new five.Servo({ + pin: 9, + startAt: 45 + }); + ph.femur = new five.Servo({ + pin: 10, + startAt: 180 + }); + ph.tibia = new five.Servo({ + pin: 11, + startAt: 180 + }); + + // Create a Servo.Array for those leg parts + ph.leg = new five.Servo.Array([ph.coxa, ph.femur, ph.tibia]); + + /** + * Create an Animation(target) object. A newly initialized + * animation object is essentially an empty queue (array) for + * animation segments that will run asynchronously. + * @param {target} A Servo or Servo.Array to be animated + */ + var legAnimation = new five.Animation(ph.leg); + + /** + * This object describes an animation segment and is passed into + * our animation with the enqueue method. The only required + * property is keyFrames. See the Animation wiki page for a full + * list of available properties + */ + var sleep = { + duration: 500, + cuePoints: [0, 0.5, 1.0], + oncomplete: function() { + ph.state = "sleep"; + }, + keyFrames: [ + [null, false, { degrees: 45, easing: "outCirc" }], + [null, { degrees: 136, easing: "inOutCirc" }, { degrees: 180, easing: "inOutCirc" }], + [null, { degrees: 120, easing: "inOutCirc" }, { step: 60, easing: "inOutCirc" }] + ] + }; + + /** + * Another animation segment + */ + var stand = { + duration: 500, + loop: false, + cuePoints: [0, 0.1, 0.3, 0.7, 1.0], + oncomplete: function() { + ph.state = "stand"; + }, + keyFrames: [ + [null, { degrees: 66 }], + [null, false, false, { degrees: 130, easing: "outCirc"}, { degrees: 104, easing: "inCirc"}], + [null, false, { degrees: 106}, false, { degrees: 93 }] + ] + }; + + // Functions we can call from the REPL + ph.sleep = function() { + legAnimation.enqueue(sleep); + }; + + ph.stand = function() { + legAnimation.enqueue(stand); + }; + + // Inject the `servo` hardware into; + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + ph: ph + }); + + console.log("Try running ph.stand() or ph.sleep()"); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-animation.js b/JavaScript/node_modules/johnny-five/eg/servo-animation.js new file mode 100644 index 0000000..33522a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-animation.js @@ -0,0 +1,27 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Create a new `servo` hardware instance. + var servo = new five.Servo(10); + + // Create a new `animation` instance. + var animation = new five.Animation(servo); + + // Enqueue an animation segment with options param + // See Animation example and docs for details + animation.enqueue({ + cuePoints: [0, 0.25, 0.75, 1], + keyFrames: [90, { value: 180, easing: "inQuad" }, { value: 0, easing: "outQuad" }, 90], + duration: 2000 + }); + + // Inject the `servo` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + servo: servo, + animation: animation + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-array.js b/JavaScript/node_modules/johnny-five/eg/servo-array.js new file mode 100644 index 0000000..41ccebf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-array.js @@ -0,0 +1,64 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + // Initialize a Servo collection + var servos = new five.Servos([9, 10]); + + + servos.center(); + + + // Inject the `servo` hardware into + // the Repl instance's context; + // allows direct command line access + this.repl.inject({ + servos: servos + }); + + + // min() + // + // set all servos to the minimum degrees + // defaults to 0 + // + // eg. servos.min(); + + // max() + // + // set all servos to the maximum degrees + // defaults to 180 + // + // eg. servos.max(); + + // to( deg ) + // + // set all servos to deg + // + // eg. servos.to( deg ); + + // step( deg ) + // + // step all servos by deg + // + // eg. servos.step( -20 ); + + // stop() + // + // stop all servos + // + // eg. servos.stop(); + + // each( callbackFn ) + // + // Execute callbackFn for each active servo instance + // + // eg. + // servos.each(function( servo, index ) { + // + // `this` refers to the current servo instance + // + // }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-continuous.js b/JavaScript/node_modules/johnny-five/eg/servo-continuous.js new file mode 100644 index 0000000..7d243ef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-continuous.js @@ -0,0 +1,38 @@ +var five = require("../lib/johnny-five.js"); +var keypress = require("keypress"); + +keypress(process.stdin); + +var board = new five.Board(); + +board.on("ready", function() { + + console.log("Use Up and Down arrows for CW and CCW respectively. Space to stop."); + + var servo = new five.Servo.Continuous(10).stop(); + + process.stdin.resume(); + process.stdin.setEncoding("utf8"); + process.stdin.setRawMode(true); + + process.stdin.on("keypress", function(ch, key) { + + if (!key) { + return; + } + + if (key.name === "q") { + console.log("Quitting"); + process.exit(); + } else if (key.name === "up") { + console.log("CW"); + servo.cw(); + } else if (key.name === "down") { + console.log("CCW"); + servo.ccw(); + } else if (key.name === "space") { + console.log("Stopping"); + servo.stop(); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-diagnostic.js b/JavaScript/node_modules/johnny-five/eg/servo-diagnostic.js new file mode 100644 index 0000000..9f39153 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-diagnostic.js @@ -0,0 +1,58 @@ +var five = require("../lib/johnny-five.js"), + args, pins, ranges; + +/** + * This program is useful for manual servo administration. + * + * ex. node eg/servo-diagnostic.js [ pin list ] + * + * To setup servos on pins 10 and 11: + * + * node eg/servo-diagnostic.js 10 11 + * + * To setup servos on pins 10 and 11 with custom ranges: + * + * node eg/servo-diagnostic.js 10:10:170 11 + * + * Note: Ranges default to 0-180 + * + */ + +args = process.argv.slice(2); + +pins = []; +ranges = []; + +args.forEach(function(val) { + var vals = val.split(":").map(function(v) { + return +v; + }); + + pins.push(vals[0]); + + ranges.push( + vals.length === 3 ? + vals.slice(1) : [0, 180] + ); +}); + +(new five.Board()).on("ready", function() { + var servos; + + // With each provided pin number, create a servo instance + pins.forEach(function(pin, k) { + new five.Servo({ + pin: pin, + range: ranges[k] + }); + }, this); + + servos = new five.Servos(); + + servos.center(); + + // Inject a Servo Array into the REPL as "s" + this.repl.inject({ + s: servos + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-drive.js b/JavaScript/node_modules/johnny-five/eg/servo-drive.js new file mode 100644 index 0000000..91520c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-drive.js @@ -0,0 +1,46 @@ +var five = require("../lib/johnny-five.js"), + board, wheels; + +board = new five.Board(); + +board.on("ready", function() { + + wheels = {}; + + // Create two servos as our wheels + wheels.left = new five.Servo({ + pin: 9, + // `type` defaults to standard servo. + // For continuous rotation servos, override the default + // by setting the `type` here + type: "continuous" + + }); + + wheels.right = new five.Servo({ + pin: 10, + // `type` defaults to standard servo. + // For continuous rotation servos, override the default + // by setting the `type` here + type: "continuous", + invert: true // one wheel mounted inverted of the other + }); + + wheels.both = new five.Servos().stop(); // reference both together + + // Add servos to REPL (optional) + this.repl.inject({ + wheels: wheels + }); + + // Drive forwards + // Note, cw() vs ccw() might me different for you + // depending on how you mount the servos + wheels.both.cw(); + + // Stop driving after 3 seconds + this.wait(3000, function() { + wheels.both.stop(); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-prompt.js b/JavaScript/node_modules/johnny-five/eg/servo-prompt.js new file mode 100644 index 0000000..2ef11d7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-prompt.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var readline = require("readline"); + +var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +five.Board().on("ready", function() { + var servo = new five.Servo(10); + + rl.setPrompt("SERVO TEST (0-180)> "); + rl.prompt(); + + rl.on("line", function(line) { + servo.to(+line.trim()); + rl.prompt(); + }).on("close", function() { + process.exit(0); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-slider.js b/JavaScript/node_modules/johnny-five/eg/servo-slider.js new file mode 100644 index 0000000..cb630b8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-slider.js @@ -0,0 +1,28 @@ +var five = require("../lib/johnny-five.js"), + board, slider, servo, scalingRange; + +board = new five.Board(); + +board.on("ready", function() { + + scalingRange = [0, 170]; + + slider = new five.Sensor({ + pin: "A0", + freq: 50 + }); + + servo = new five.Servo({ + pin: 10, + range: scalingRange + }); + + + // The slider's value will be scaled to match the servo's movement range + + slider.scale(scalingRange).on("slide", function(err, value) { + + servo.to(Math.floor(this.value)); + + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo-sweep.js b/JavaScript/node_modules/johnny-five/eg/servo-sweep.js new file mode 100644 index 0000000..02bb477 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo-sweep.js @@ -0,0 +1,39 @@ +var five = require("../lib/johnny-five.js"), + board = new five.Board(); + +board.on("ready", function() { + var servo = new five.Servo({ + pin: 10, + startAt: 90 + }); + var lap = 0; + + servo.sweep().on("sweep:full", function() { + console.log("lap", ++lap); + + if (lap === 1) { + this.sweep({ + range: [40, 140], + step: 10 + }); + } + + if (lap === 2) { + this.sweep({ + range: [60, 120], + step: 5 + }); + } + + if (lap === 3) { + this.sweep({ + range: [80, 100], + step: 1 + }); + } + + if (lap === 5) { + process.exit(0); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/servo.js b/JavaScript/node_modules/johnny-five/eg/servo.js new file mode 100644 index 0000000..d71eb35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/servo.js @@ -0,0 +1,65 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var servo = new five.Servo(10); + + // Servo alternate constructor with options + /* + var servo = new five.Servo({ + id: "MyServo", // User defined id + pin: 10, // Which pin is it attached to? + type: "standard", // Default: "standard". Use "continuous" for continuous rotation servos + range: [0,180], // Default: 0-180 + fps: 100, // Used to calculate rate of movement between positions + invert: false, // Invert all specified positions + startAt: 90, // Immediately move to a degree + center: true, // overrides startAt if true and moves the servo to the center of the range + specs: { // Is it running at 5V or 3.3V? + speed: five.Servo.Continuous.speeds["@5.0V"] + } + }); + */ + + // Add servo to REPL (optional) + this.repl.inject({ + servo: servo + }); + + + // Servo API + + // min() + // + // set the servo to the minimum degrees + // defaults to 0 + // + // eg. servo.min(); + + // max() + // + // set the servo to the maximum degrees + // defaults to 180 + // + // eg. servo.max(); + + // center() + // + // centers the servo to 90° + // + // servo.center(); + + // to( deg ) + // + // Moves the servo to position by degrees + // + // servo.to( 90 ); + + // step( deg ) + // + // step all servos by deg + // + // eg. array.step( -20 ); + + servo.sweep(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/shift-register-daisy-chain.js b/JavaScript/node_modules/johnny-five/eg/shift-register-daisy-chain.js new file mode 100644 index 0000000..53d112c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/shift-register-daisy-chain.js @@ -0,0 +1,224 @@ +/** + * This example illustrates a 20-sided die roller using two seven-segment + * displays and two daisy-chained 74HC595 shift registers. + * + * The button is a "momentary off" button. + * + * See docs/breadboard/seven-segment-daisy-chain.png + * for the wiring. + */ +var five = require("../lib/johnny-five.js"), + async = require("async"), + _ = require("lodash"); + +var board = new five.Board(), + Button = five.Button, + ShiftRegister = five.ShiftRegister, + Pin = five.Pin, + + /** + * Change this to "true" if you are using common anode displays. + * + * This example uses common cathode displays. If you only have common + * anode seven-segment displays, you will need to change the wiring to use VCC + * in place of GND. + * @type {boolean} + */ + COMMON_ANODE = false, + + /** + * This is optional; you can reset the 74HC595's if one or both has + * bizarre stuff stored in its EEPROM. + * + * Comment out if unused. + * @type {number} + */ + RESET_PIN = 9, + + /** + * Segments we'll be using. Die rolls produce no decimals, so we will + * not be using "DP". + * @type {string[]} + */ + SEGMENTS = ["a", "b", "c", "d", "e", "f", "g"], + + /** + * Mapping of LED segment names to their numeric values. + * See "segments" definition within shift-register-seven-segment.js for + * functionally equivalent code. + * @type {Object.} + */ + segments = _.mapValues(_.object(SEGMENTS, _.range(SEGMENTS.length)), + function(seg) { + return 1 << seg; + }), + + /** + * Array of digits used in our die-roller. + * @type {number[]} + */ + digits = (function() { + var A = segments.a, + B = segments.b, + C = segments.c, + D = segments.d, + E = segments.e, + F = segments.f, + G = segments.g; + + /** + * These two-value arrays represent numbers from 1 through 20. + * By performing a bitwise OR on segments, we can combine them to find + * the numeric value of a digit. + * + * Constructing the numbers in this manner may help you visualize how it + * works. + * + * These arrays are logically reversed; the second digit is the first, + * and the first is the second. When 0 is present, it means the display + * is unused. + * + * @type {number[]} + */ + return [ + [F | E | D | C | B | A, 0], // 0 + [C | B, 0], // 1 + [G | E | D | A | B, 0], // 2 + [G | D | C | B | A, 0], // 3 + [G | F | C | B, 0], // 4 + [G | F | D | C | A, 0], // 5 + [G | F | E | D | C | A, 0], // 6 + [C | B | A, 0], // 7 + [G | F | E | D | C | B | A, 0], // 8 + [G | F | D | C | B | A, 0], // 9 + [F | E | D | C | B | A, C | B], // 10 + [C | B, C | B], // 11 + [G | E | D | A | B, C | B], // 12 + [G | D | C | B | A, C | B], // 13 + [G | F | C | B, C | B], // 14 + [G | F | D | C | A, C | B], // 15 + [G | F | E | D | C | A, C | B], // 16 + [C | B | A, C | B], // 17 + [G | F | E | D | C | B | A, C | B], // 18 + [G | F | D | C | B | A, C | B], // 19 + [F | E | D | C | B | A, G | E | D | A | B] // 20 + ]; + + })(); + +board.on("ready", function() { + + /** + * While we may have multiple ShiftRegisters, + * we only need one to control them both. + * @type {exports.ShiftRegister} + */ + var register = new ShiftRegister({ + pins: { + data: 2, + clock: 3, + latch: 4 + } + }), + + /** + * Pressing this button will trigger the die roll. Because we're using a + * "momentary-off" switch, "invert: true" is appropriate here. If you have + * a "momentary-on" switch, set "invert: false". + * @type {Button} + */ + btn = new Button({ + pin: 8, + invert: true + }), + + /** + * Clears both displays + */ + clear = function clear() { + register.send.apply(register, COMMON_ANODE ? [255, 255] : [0, 0]); + }, + + /** + * Resets the storage of the shift register. Helpful if you stuff something + * weird in the IC's EEPROM. + * + * To reset a 74HC595, you must make a low-to-high transition on STCP + * (clock) while the MR pin (reset) is low. Return reset to high thereafter + * to end the reset function. At least, I'm pretty sure that's what the + * datasheet is getting at... + * @type {function(this:*)} + */ + reset = function reset() { + if (typeof RESET_PIN !== "undefined") { + this.digitalWrite(register.pins.clock, this.io.LOW); + this.digitalWrite(RESET_PIN, this.io.LOW); + this.digitalWrite(register.pins.clock, this.io.HIGH); + this.digitalWrite(RESET_PIN, this.io.HIGH); + } + }.bind(this), + + /** + * Inverts the pin output if we are using common anode. + * @param {number} num + * @returns {number} + */ + invert = function invert(num) { + return ((~num << 24) >> 24) & 255; + }, + + /** + * Prints a digit (0-20) on the display(s). + * @param {(Array|number)} num If number, will look up in digits array. + */ + digit = function digit(num) { + if (!_.isArray(num)) { + num = digits[num - 1] || [0, 0]; + } + register.send.apply(register, COMMON_ANODE ? _.map(num, invert) : num); + }, + + /** + * Sends a random number to the shift register. + */ + randomNumber = function randomNumber() { + return digit(_.sample(digits)); + }, + + /** + * This is an array of delays in ms. When a button is pressed, + * we'll iterate over this array and display a random number after the + * delay. This simulates a die bouncing on a table. + * @type {Array.} + */ + delays = new Array(10).fill(16) + .concat(new Array(8).fill(32)) + .concat(new Array(6).fill(64)) + .concat(new Array(4).fill(128)) + .concat(new Array(2).fill(256)) + .concat(512); + + this.repl.inject({ + digit: digit, + digits: digits, + clear: clear, + randomNumber: randomNumber, + reset: reset + }); + + reset(); + clear(); + + btn.on("press", function() { + console.log("Rolling..."); + clear(); + async.eachSeries(delays, function(delay, done) { + randomNumber(); + setTimeout(function() { + clear(); + done(); + }, delay); + }, randomNumber); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/shift-register-seven-segment.js b/JavaScript/node_modules/johnny-five/eg/shift-register-seven-segment.js new file mode 100644 index 0000000..c08698d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/shift-register-seven-segment.js @@ -0,0 +1,102 @@ +/** + * This example uses a single seven-segment display (common anode) and a + * 74HC595 shift register. See docs/breadboard/seven-segment.png for wiring. + */ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + /* + + This assumes the segments are as follows: + + A + --- + F | | B + --- <---- G + E | | C + --- + D o DP + + */ + + var isCommonAnode = true; + var digits = [ + // .GFEDCBA + parseInt("00111111", 2), + parseInt("00000110", 2), + parseInt("01011011", 2), + parseInt("01001111", 2), + parseInt("01100110", 2), + parseInt("01101101", 2), + parseInt("01111101", 2), + parseInt("00000111", 2), + parseInt("01111111", 2), + parseInt("01101111", 2), + ]; + + var segments = { + // .GFEDCBA + a: parseInt("00000001", 2), + b: parseInt("00000010", 2), + c: parseInt("00000100", 2), + d: parseInt("00001000", 2), + e: parseInt("00010000", 2), + f: parseInt("00100000", 2), + g: parseInt("01000000", 2), + dp: parseInt("10000000", 2) + }; + + var register = new five.ShiftRegister({ + pins: { + data: 2, + clock: 3, + latch: 4 + } + }); + + var led = new five.Led(5); + + function invert(num) { + return ((~num << 24) >> 24) & 255; + } + + function digit(num) { + clear(); + + register.send( + isCommonAnode ? invert(digits[num]) : digits[num] + ); + } + + function segment(s) { + clear(); + + register.send( + isCommonAnode ? invert(segments[s]) : segments[s] + ); + } + + function clear() { + register.send( + isCommonAnode ? 255 : 0 + ); + } + + var i = 9; + + function next() { + led.stop(); + digit(i--); + + if (i < 0) { + i = 9; + led.strobe(50); + setTimeout(next, 2000); + } else { + setTimeout(next, 1000); + } + } + + next(); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/shift-register.js b/JavaScript/node_modules/johnny-five/eg/shift-register.js new file mode 100644 index 0000000..8bab328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/shift-register.js @@ -0,0 +1,25 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +// For use with 74HC595 chip + +board.on("ready", function() { + var register = new five.ShiftRegister({ + pins: { + data: 2, + clock: 3, + latch: 4 + } + }); + + var value = 0; + + function next() { + value = value > 0x11 ? value >> 1 : 0x88; + register.send(value); + setTimeout(next, 200); + } + + next(); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/shiftregister.js b/JavaScript/node_modules/johnny-five/eg/shiftregister.js new file mode 100644 index 0000000..67430f0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/shiftregister.js @@ -0,0 +1,27 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +// This works with the 74HC595 that comes with the SparkFun Inventor's kit. +// Your mileage may vary with other chips. For more information on working +// with shift registers, see http://arduino.cc/en/Tutorial/ShiftOut + +board.on("ready", function() { + var register = new five.ShiftRegister({ + pins: { + data: 2, + clock: 3, + latch: 4 + } + }); + + var value = 0; + + function next() { + value = value > 0x11 ? value >> 1 : 0x88; + register.send(value); + setTimeout(next, 200); + } + + next(); + +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sonar-scan.js b/JavaScript/node_modules/johnny-five/eg/sonar-scan.js new file mode 100644 index 0000000..ca1ce69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sonar-scan.js @@ -0,0 +1,147 @@ +var five = require("../lib/johnny-five.js"), + board; + +board = new five.Board(); + +board.on("ready", function() { + var center, collision, degrees, step, facing, + range, redirect, look, isScanning, scanner, sonar, servos; + + // Collision distance (inches) + collision = 6; + + // Starting scanner scanning position (degrees) + degrees = 90; + + // Servo scanning steps (degrees) + step = 10; + + // Current facing direction + facing = ""; + + // Scanning range (degrees) + range = [0, 170]; + + // Servo center point (degrees) + center = range[1] / 2; + + // Redirection map + redirect = { + left: "right", + right: "left" + }; + + // Direction to look after releasing scanner lock (degrees) + look = { + forward: center, + left: 130, + right: 40 + }; + + // Scanning state + isScanning = true; + + // Sonar instance (distance detection) + sonar = new five.Sonar("A2"); + // Servo instance (panning) + scanner = new five.Servo({ + pin: 12, + range: range + }); + + servos = { + right: new five.Servo({ + pin: 10, + type: "continuous" + }), + left: new five.Servo({ + pin: 11, + type: "continuous" + }) + }; + + // Initialize the scanner at it's center point + // Will be exactly half way between the range's + // lower and upper bound + scanner.center(); + + servos.right.to(90); + servos.left.to(90); + + // Scanner/Panning loop + this.loop(100, function() { + var bounds; + + bounds = { + left: center + 10, + right: center - 10 + }; + + // During course change, scanning is paused to avoid + // overeager redirect instructions[1] + if (isScanning) { + // Calculate the next step position + if (degrees >= scanner.range[1] || degrees === scanner.range[0]) { + step *= -1; + } + + // Update the position in degrees + degrees += step; + + // The following three conditions will help determine + // which way the bot should turn if a potential collision + // may occur in the sonar "change" event handler[2] + if (degrees > bounds.left) { + facing = "left"; + } + + if (degrees < bounds.right) { + facing = "right"; + } + + if (degrees > bounds.right && degrees < bounds.left) { + facing = "forward"; + } + + scanner.to(degrees); + } + }); + + // [2] Sonar "change" events are emitted when the value of a + // distance reading has changed since the previous reading + // + sonar.on("change", function(err) { + var turnTo; + + // Detect collision + if (Math.abs(this.inches) < collision && isScanning) { + // Scanning lock will prevent multiple collision detections + // of the same obstacle + isScanning = false; + turnTo = redirect[facing] || Object.keys(redirect)[Date.now() % 2]; + + // Log collision detection to REPL + console.log( + [Date.now(), + "Collision detected " + this.inches + " inches away.", + "Turning " + turnTo.toUpperCase() + " to avoid" + ].join("\n") + ); + + // Override the next scan position (degrees) + // degrees = look[ turnTo ]; + + // [1] Allow 1000ms to pass and release the scanning lock + // by setting isScanning state to true. + board.wait(1500, function() { + console.log("Release Scanner Lock"); + isScanning = true; + }); + } + }); +}); + + +// Reference +// +// http://www.maxbotix.com/pictures/articles/012_Diagram_690X480.jpg diff --git a/JavaScript/node_modules/johnny-five/eg/sonar-srf10.js b/JavaScript/node_modules/johnny-five/eg/sonar-srf10.js new file mode 100644 index 0000000..fde5962 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sonar-srf10.js @@ -0,0 +1,21 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + + var sonar = new five.Sonar({ + device: "SRF10" + }); + + function display(type, value, unit) { + console.log("%s event: object is %d %s away", type, value, unit); + } + + sonar.on("data", function() { + display("data", this.inches, "inches"); + }); + + sonar.on("change", function() { + display("data", this.inches, "inches"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/sonar.js b/JavaScript/node_modules/johnny-five/eg/sonar.js new file mode 100644 index 0000000..a03268c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/sonar.js @@ -0,0 +1,50 @@ +var five = require("../lib/johnny-five.js"), + board, sonar; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `sonar` hardware instance. + sonar = new five.Sonar("A2"); + + // Sonar Properties + + // sonar.voltage + // + // Raw voltage + // + + // sonar.inches + // + // Distance reading in inches + // + + // sonar.cm + // + // Distance reading in centimeters + // + + + // Sonar Event API + // + // "data" fired continuously + // + sonar.on("data", function() { + /* + + this.voltage - raw voltage reading + this.inches - calculated distance, inches + this.cm - calculated distance, centimeters + + */ + console.log("data", "Object is " + this.inches + "inches away"); + }); + + // + // "change" fired when distance reading changes + // + sonar.on("change", function() { + console.log("change", "Object is " + this.inches + "inches away"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/spark-io-blink.js b/JavaScript/node_modules/johnny-five/eg/spark-io-blink.js new file mode 100644 index 0000000..3a6616a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/spark-io-blink.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var Spark = require("spark-io"); + +var board = new five.Board({ + io: new Spark({ + token: process.env.SPARK_TOKEN, + deviceId: process.env.SPARK_DEVICE_ID + }) +}); + +board.on("ready", function() { + var pin = "A7"; + var led = new five.Led(pin); + + led.strobe(500); + + // this.repl.inject({ + // led: led + // }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/spark-io.js b/JavaScript/node_modules/johnny-five/eg/spark-io.js new file mode 100644 index 0000000..61eec12 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/spark-io.js @@ -0,0 +1,45 @@ +var five = require("../lib/johnny-five.js"); +var Spark = require("spark-io"); +var board; + +// Create Johnny-Five board connected via Spark. +// Assumes access tokens are stored as environment variables +// but you can enter them directly below instead. +board = new five.Board({ + io: new Spark({ + token: process.env.SPARK_TOKEN, + deviceId: process.env.SPARK_DEVICE_ID + }) +}); + +board.on("ready", function() { + console.log("CONNECTED"); + + // Once connected, we can do normal Johnny-Five stuff + var led = new five.Led("D1"); + led.blink(); + +}); + +// @markdown +// +// In order to use the spark-io library, you will need to load the special +// [voodoospark](https://github.com/voodootikigod/voodoospark) firmware onto your +// device. We recommend you review [VoodooSpark's Getting Started](https://github.com/voodootikigod/voodoospark#getting-started) before continuing. +// +// We also recommend storing your Spark token and device ID in a dot file so they can be accessed as properties of `process.env`. Create a file in your home directory called `.sparkrc` that contains: +// +// ```sh +// export SPARK_TOKEN="your spark token" +// export SPARK_DEVICE_ID="your device id" +// ``` +// +// Then add the following to your dot-rc file of choice: +// +// ```sh +// source ~/.sparkrc +// ``` +// +// Ensure your host computer (where you're running your Node.js application) and the Spark are on the same local network. +// +// @markdown \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/eg/stepper-driver.js b/JavaScript/node_modules/johnny-five/eg/stepper-driver.js new file mode 100644 index 0000000..9eeb3a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/stepper-driver.js @@ -0,0 +1,47 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + + /** + * In order to use the Stepper class, your board must be flashed with + * either of the following: + * + * - AdvancedFirmata https://github.com/soundanalogous/AdvancedFirmata + * - ConfigurableFirmata https://github.com/firmata/arduino/releases/tag/v2.6.2 + * + */ + + var stepper = new five.Stepper({ + type: five.Stepper.TYPE.DRIVER, + stepsPerRev: 200, + pins: { + step: 11, + dir: 13 + } + }); + + // Make 10 full revolutions counter-clockwise at 180 rpm with acceleration and deceleration + stepper.rpm(180).ccw().accel(1600).decel(1600).step(2000, function() { + + console.log("Done moving CCW"); + + // once first movement is done, make 10 revolutions clockwise at previously + // defined speed, accel, and decel by passing an object into stepper.step + stepper.step({ + steps: 2000, + direction: five.Stepper.DIRECTION.CW + }, function() { + console.log("Done moving CW"); + }); + }); +}); + +// @markdown +// - [A4988 Stepper Motor Driver Carrier](http://www.pololu.com/catalog/product/1182) +// - [100uf 35v electrolytic cap](http://www.amazon.com/100uF-Radial-Mini-Electrolytic-Capacitor/dp/B0002ZP530) +// - [Stepper Motor (4 wire, bipolar)](https://www.sparkfun.com/products/9238) +// +//  +// +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/stepper-four_wire.js b/JavaScript/node_modules/johnny-five/eg/stepper-four_wire.js new file mode 100644 index 0000000..1b4da06 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/stepper-four_wire.js @@ -0,0 +1,39 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); +var Stepper = five.Stepper; + +board.on("ready", function() { + /** + * In order to use the Stepper class, your board must be flashed with + * either of the following: + * + * - AdvancedFirmata https://github.com/soundanalogous/AdvancedFirmata + * - ConfigurableFirmata https://github.com/firmata/arduino/releases/tag/v2.6.2 + * + */ + + var stepper = new Stepper({ + type: Stepper.TYPE.FOUR_WIRE, + stepsPerRev: 200, + pins: { + motor1: 10, + motor2: 11, + motor3: 12, + motor4: 13 + } + }); + + // make 10 full revolutions counter-clockwise at 180 rpm with acceleration and deceleration + stepper.rpm(180).direction(Stepper.DIRECTION.CCW).accel(1600).decel(1600).step(2000, function() { + console.log("done moving CCW"); + + // once first movement is done, make 10 revolutions clockwise at previously + // defined speed, accel, and decel by passing an object into stepper.step + stepper.step({ + steps: 2000, + direction: Stepper.DIRECTION.CW + }, function() { + console.log("done moving CW"); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/stepper-sweep.js b/JavaScript/node_modules/johnny-five/eg/stepper-sweep.js new file mode 100644 index 0000000..322a229 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/stepper-sweep.js @@ -0,0 +1,24 @@ +var five = require("../lib/johnny-five"); +var board = new five.Board(); + +board.on("ready", function() { + /** + * In order to use the Stepper class, your board must be flashed with + * either of the following: + * + * - AdvancedFirmata https://github.com/soundanalogous/AdvancedFirmata + * - ConfigurableFirmata https://github.com/firmata/arduino/releases/tag/v2.6.2 + * + */ + + var k = 0; + var stepper = new five.Stepper({ + type: five.Stepper.TYPE.DRIVER, + stepsPerRev: 200, + pins: [11, 12] + }); + + stepper.rpm(180).ccw().step(2000, function() { + console.log("done"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/switch.js b/JavaScript/node_modules/johnny-five/eg/switch.js new file mode 100644 index 0000000..213051d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/switch.js @@ -0,0 +1,15 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var spdt = new five.Switch(8); + var led = new five.Led(13); + + spdt.on("open", function() { + led.off(); + }); + + spdt.on("close", function() { + led.on(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-BMP180.js b/JavaScript/node_modules/johnny-five/eg/temperature-BMP180.js new file mode 100644 index 0000000..144f36f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-BMP180.js @@ -0,0 +1,17 @@ +var five = require("../"); +var board = new five.Board(); + +board.on("ready", function() { + var temperature = new five.Temperature({ + controller: "BMP180", + freq: 250 + }); + + temperature.on("change", function() { + console.log("temperature"); + console.log(" celsius : ", this.celsius); + console.log(" fahrenheit : ", this.fahrenheit); + console.log(" kelvin : ", this.kelvin); + console.log("--------------------------------------"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-ds18b20.js b/JavaScript/node_modules/johnny-five/eg/temperature-ds18b20.js new file mode 100644 index 0000000..fc80f27 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-ds18b20.js @@ -0,0 +1,18 @@ +var five = require("../lib/johnny-five"); + +five.Board().on("ready", function() { + // This requires OneWire support using the ConfigurableFirmata + var temperature = new five.Temperature({ + controller: "DS18B20", + pin: 2 + }); + + temperature.on("data", function(err, data) { + console.log(data.celsius + "°C", data.fahrenheit + "°F"); + console.log("0x" + this.address.toString(16)); + }); +}); + +// @markdown +// - [DS18B20 - Temperature Sensor](http://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/DS18S20.html) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-dual-ds18b20.js b/JavaScript/node_modules/johnny-five/eg/temperature-dual-ds18b20.js new file mode 100644 index 0000000..091ca91 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-dual-ds18b20.js @@ -0,0 +1,29 @@ +var five = require("../lib/johnny-five"); + +five.Board().on("ready", function() { + // This requires OneWire support using the ConfigurableFirmata + var temperatureA = new five.Temperature({ + controller: "DS18B20", + pin: 2, + address: 0x687f1fe + }); + + var temperatureB = new five.Temperature({ + controller: "DS18B20", + pin: 2, + address: 0x6893a41 + }); + + + temperatureA.on("data", function(err, data) { + console.log("A", data.celsius + "°C", data.fahrenheit + "°F"); + }); + + temperatureB.on("data", function(err, data) { + console.log("B", data.celsius + "°C", data.fahrenheit + "°F"); + }); +}); + +// @markdown +// - [DS18B20 - Temperature Sensor](http://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/DS18S20.html) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-lm35.js b/JavaScript/node_modules/johnny-five/eg/temperature-lm35.js new file mode 100644 index 0000000..7a11515 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-lm35.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five"); + +five.Board().on("ready", function() { + var temperature = new five.Temperature({ + controller: "LM35", + pin: "A0" + }); + + temperature.on("data", function(err, data) { + console.log(data.celsius + "°C", data.fahrenheit + "°F"); + }); +}); + +// @markdown +// - [LM35 - Temperature Sensor](http://www.ti.com/product/lm35) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-mpl115a2.js b/JavaScript/node_modules/johnny-five/eg/temperature-mpl115a2.js new file mode 100644 index 0000000..f2ba412 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-mpl115a2.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var temperature = new five.Temperature({ + controller: "MPL115A2" + }); + + temperature.on("data", function() { + console.log("temperature"); + console.log(" celsius : ", this.celsius); + console.log(" fahrenheit : ", this.fahrenheit); + console.log(" kelvin : ", this.kelvin); + console.log("--------------------------------------"); + }); +}); + +// @markdown +// - [MPL115A2 - I2C Barometric Pressure/Temperature Sensor](https://www.adafruit.com/product/992) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-mpu6050.js b/JavaScript/node_modules/johnny-five/eg/temperature-mpu6050.js new file mode 100644 index 0000000..156cdc2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-mpu6050.js @@ -0,0 +1,20 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + var temperature = new five.Temperature({ + controller: "MPU6050" + }); + + temperature.on("change", function() { + console.log("temperature"); + console.log(" celsius : ", this.celsius); + console.log(" fahrenheit : ", this.fahrenheit); + console.log(" kelvin : ", this.kelvin); + console.log("--------------------------------------"); + }); +}); + +// @markdown +// - [MPU-6050 - IMU with Temperature Sensor](http://www.invensense.com/products/motion-tracking/6-axis/mpu-6050/) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/temperature-tmp36.js b/JavaScript/node_modules/johnny-five/eg/temperature-tmp36.js new file mode 100644 index 0000000..7677959 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/temperature-tmp36.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); + +five.Board().on("ready", function() { + var temperature = new five.Temperature({ + controller: "TMP36", + pin: "A0" + }); + + temperature.on("data", function(err, data) { + console.log(data.celsius + "°C", data.fahrenheit + "°F"); + }); +}); + +// @markdown +// - [TMP36 - Temperature Sensor](https://www.sparkfun.com/products/10988) +// @markdown diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-accelerometer.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-accelerometer.js new file mode 100644 index 0000000..f99d8db --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-accelerometer.js @@ -0,0 +1,40 @@ +var five = require("../lib/johnny-five.js"), + board, accel; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `Accelerometer` hardware instance. + // + // Devices: + // + // - Dual Axis http://tinkerkit.tihhs.nl/accelerometer/ + // + + accel = new five.Accelerometer({ + pins: ["I0", "I1"], + freq: 100 + }); + + // Accelerometer Event API + + // "acceleration" + // + // Fires once every N ms, equal to value of freg + // Defaults to 500ms + // + accel.on("acceleration", function(err, timestamp) { + + console.log("acceleration", this.pitch, this.roll); + }); + + // "axischange" + // + // Fires only when X, Y or Z has changed + // + accel.on("axischange", function(err, timestamp) { + + console.log("axischange", this.raw); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-blink.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-blink.js new file mode 100644 index 0000000..a3e6003 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-blink.js @@ -0,0 +1,5 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + new five.Led("O0").strobe(250); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-button.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-button.js new file mode 100644 index 0000000..a309f6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-button.js @@ -0,0 +1,14 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + // Attaching to an O* pin in a deviation from + // TinkerKit tutorials which instruct to attach + // the button to an I* pin. + var button = new five.Button("O5"); + + ["down", "up", "hold"].forEach(function(type) { + button.on(type, function() { + console.log(type); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-combo.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-combo.js new file mode 100644 index 0000000..2907142 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-combo.js @@ -0,0 +1,36 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + var accel, slider, servos; + + accel = new five.Accelerometer({ + id: "accelerometer", + pins: ["I0", "I1"] + }); + + slider = new five.Sensor({ + id: "slider", + pin: "I2" + }); + + new five.Servo({ + id: "servo", + pin: "O0", + type: "continuous" + }); + + new five.Servo({ + id: "servo", + pin: "O1" + }); + + servos = new five.Servo.Array(); + + slider.scale(0, 180).on("change", function() { + servos.to(this.value); + }); + + accel.on("acceleration", function() { + // console.log( this.raw.x, this.raw.y ); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-continuous-servo.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-continuous-servo.js new file mode 100644 index 0000000..ca10d25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-continuous-servo.js @@ -0,0 +1,12 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + var servo = new five.Servo({ + pin: "O0", + type: "continuous" + }); + + new five.Sensor("I0").scale(0, 1).on("change", function() { + servo.cw(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-gyroscope.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-gyroscope.js new file mode 100644 index 0000000..4d83f60 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-gyroscope.js @@ -0,0 +1,16 @@ +var five = require("../lib/johnny-five.js"); +var board = new five.Board(); + +board.on("ready", function() { + // Create a new `Gyro` hardware instance. + + var gyro = new five.Gyro({ + pins: ["I0", "I1"], + sensitivity: 0.67 + }); + + gyro.on("change", function() { + console.log("X raw: %d rate: %d", this.x, this.rate.x); + console.log("Y raw: %d rate: %d", this.y, this.rate.y); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-joystick.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-joystick.js new file mode 100644 index 0000000..285afbb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-joystick.js @@ -0,0 +1,46 @@ +var five = require("../lib/johnny-five.js"), + Change = require("../eg/change.js"); + +new five.Board().on("ready", function() { + // var servo = new five.Servo("O0"); + + var joystick = { + x: new five.Sensor({ + pin: "I0" + }), + y: new five.Sensor({ + pin: "I1" + }) + }; + + var changes = { + x: new Change(), + y: new Change() + }; + + var dirs = { + x: { + 1: "left", + 3: "right" + }, + y: { + 1: "down", + 3: "up" + } + }; + + + ["x", "y"].forEach(function(axis) { + joystick[axis].scale(1, 3).on("change", function() { + var round = Math.round(this.value); + + if (round !== 2 && changes[axis].isNoticeable(round)) { + console.log( + "%s changed noticeably (%d): %s", axis, round, dirs[axis][round] + ); + } else { + changes[axis].last = round; + } + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-linear-pot.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-linear-pot.js new file mode 100644 index 0000000..ee16a34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-linear-pot.js @@ -0,0 +1,7 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + new five.Sensor("I0").scale(0, 255).on("data", function() { + console.log(Math.round(this.value)); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-rotary.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-rotary.js new file mode 100644 index 0000000..117b113 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-rotary.js @@ -0,0 +1,9 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + var servo = new five.Servo("O0"); + + new five.Sensor("I1").scale(0, 180).on("change", function() { + servo.to(this.value); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-thermistor.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-thermistor.js new file mode 100644 index 0000000..8d57e7e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-thermistor.js @@ -0,0 +1,8 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + new five.Temperature({controller: "TINKERKIT", pin: "I0"}).on("change", function() { + console.log("F: ", this.fahrenheit); + console.log("C: ", this.celsius); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-tilt.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-tilt.js new file mode 100644 index 0000000..a416c79 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-tilt.js @@ -0,0 +1,9 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + // var servo = new five.Servo("O0"); + + new five.Sensor("I2").on("change", function() { + console.log(this.boolean); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/tinkerkit-touch.js b/JavaScript/node_modules/johnny-five/eg/tinkerkit-touch.js new file mode 100644 index 0000000..75ac7ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/tinkerkit-touch.js @@ -0,0 +1,17 @@ +var five = require("../lib/johnny-five.js"); + +new five.Board().on("ready", function() { + // Attaching to an O* pin in a deviation from + // TinkerKit tutorials which instruct to attach + // the touch to an I* pin. + // + // For the "touch" module, simply use a Button + // instance, like this: + var touch = new five.Button("O5"); + + ["down", "up", "hold"].forEach(function(type) { + touch.on(type, function() { + console.log(type); + }); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/toggle-switch.js b/JavaScript/node_modules/johnny-five/eg/toggle-switch.js new file mode 100644 index 0000000..ae1f3f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/toggle-switch.js @@ -0,0 +1,31 @@ +var five = require("../lib/johnny-five.js"), + board, toggleSwitch; + +board = new five.Board(); + +board.on("ready", function() { + + // Create a new `switch` hardware instance. + // This example allows the switch module to + // create a completely default instance + toggleSwitch = new five.Switch(8); + + // Inject the `switch` hardware into + // the Repl instance's context; + // allows direct command line access + board.repl.inject({ + toggleSwitch: toggleSwitch + }); + + // Switch Event API + + // "closed" the switch is closed + toggleSwitch.on("close", function() { + console.log("closed"); + }); + + // "open" the switch is opened + toggleSwitch.on("open", function() { + console.log("open"); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/eg/whisker.js b/JavaScript/node_modules/johnny-five/eg/whisker.js new file mode 100644 index 0000000..ae6703d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/eg/whisker.js @@ -0,0 +1,114 @@ +var Change, five; + +Change = require("../eg/change.js"); +five = require("../lib/johnny-five.js"); + +new five.Boards(["control", "nodebot"]).on("ready", function(boards) { + var controllers, changes, nodebot, whiskers, opposing, directions, speed; + + controllers = { + x: new five.Sensor({ + board: boards.controller, + pin: "I0" + }), + y: new five.Sensor({ + board: boards.controller, + pin: "I1" + }), + speed: new five.Sensor({ + board: boards.controller, + pin: "I2" + }) + }; + + nodebot = new five.Nodebot({ + board: boards.nodebot, + right: 10, + left: 11 + }); + + whiskers = { + left: new five.Pin({ + board: boards.nodebot, + addr: 5, + }), + right: new five.Pin({ + board: boards.nodebot, + addr: 7 + }), + }; + + changes = { + x: new Change(), + y: new Change(), + speed: new Change() + }; + + opposing = { + left: "right", + right: "left" + }; + + directions = { + x: { + 1: "left", + 3: "right" + }, + y: { + 1: "rev", + 3: "fwd" + } + }; + + ["left", "right"].forEach(function(impact) { + whiskers[impact].on("high", function() { + var turn = opposing[impact]; + + console.log( + "%s impact, turning %s", + impact.toUpperCase(), + turn.toUpperCase() + ); + + nodebot.stop()[turn](500); + }); + }); + + + + ["x", "y"].forEach(function(axis) { + controllers[axis].scale(1, 3).on("change", function() { + var round = Math.round(this.value); + + if (changes[axis].isNoticeable(round)) { + if (round === 2) { + nodebot.stop(); + } else { + // console.log( axis, round, directions[ axis ][ round ] ); + nodebot[directions[axis][round]](); + } + } else { + changes[axis].last = round; + } + }); + }); + + controllers.speed.scale(0, 6).on("change", function() { + var value = Math.round(this.value); + + if (changes.speed.isNoticeable(value)) { + // console.log( "update nodebot.speed: %d", value ); + // console.log( nodebot.motion ); + nodebot.speed = value; + + if (nodebot.motion !== "stop") { + nodebot[nodebot.motion](); + } + } + }); + + boards.control.repl.inject({ + n: nodebot + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/grep b/JavaScript/node_modules/johnny-five/grep new file mode 100644 index 0000000..8d49389 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/grep @@ -0,0 +1,3 @@ +johnny-five@0.8.81 /Users/rwaldron/clonez/johnny-five +└── (empty) + diff --git a/JavaScript/node_modules/johnny-five/lib/accelerometer.js b/JavaScript/node_modules/johnny-five/lib/accelerometer.js new file mode 100644 index 0000000..48a155e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/accelerometer.js @@ -0,0 +1,526 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + __ = require("../lib/fn.js"), + sum = __.sum, + fma = __.fma, + constrain = __.constrain, + int16 = __.int16; + +var priv = new Map(); +var rad2deg = 180 / Math.PI; +var calibrationSize = 10; +var axes = ["x", "y", "z"]; + +function analogInitialize(opts, dataHandler) { + var pins = opts.pins || [], + state = priv.get(this), + dataPoints = {}; + + state.zeroV = opts.zeroV || this.DEFAULTS.zeroV; + state.sensitivity = opts.sensitivity || this.DEFAULTS.sensitivity; + + pins.forEach(function(pin, index) { + this.io.pinMode(pin, this.io.MODES.ANALOG); + this.io.analogRead(pin, function(data) { + var axis = axes[index]; + dataPoints[axis] = data; + dataHandler(dataPoints); + }.bind(this)); + }, this); +} + +function analogToGravity(raw, axis) { + var state = priv.get(this); + var zeroV = state.zeroV; + + if (Array.isArray(zeroV) && zeroV.length > 0) { + var axisIndex = axes.indexOf(axis); + zeroV = zeroV[axisIndex || 0]; + } + + return (raw - zeroV) / state.sensitivity; +} + +var Controllers = { + ANALOG: { + DEFAULTS: { + value: { + zeroV: 478, + sensitivity: 96 + } + }, + initialize: { + value: analogInitialize + }, + toGravity: { + value: analogToGravity + } + }, + // http://www.invensense.com/mems/gyro/mpu6050.html + MPU6050: { + initialize: { + value: function(opts, dataHandler) { + var IMU = require("../lib/imu"); + var driver = IMU.Drivers.get(this.board, "MPU6050", opts); + var state = priv.get(this); + + state.sensitivity = opts.sensitivity || 16384; + + driver.on("data", function(data) { + dataHandler(data.accelerometer); + }); + } + }, + toGravity: { + value: function(raw) { + var state = priv.get(this); + return raw / state.sensitivity; + } + } + }, + ADXL335: { + DEFAULTS: { + value: { + zeroV: 330, + sensitivity: 66.5 + } + }, + initialize: { + value: analogInitialize + }, + toGravity: { + value: analogToGravity + } + }, + ADXL345: { + // http://www.analog.com/en/mems-sensors/mems-inertial-sensors/adxl345/products/product.html + // http://www.i2cdevlib.com/devices/adxl345#source + + ADDRESSES: { + value: [0x53] + }, + COMMANDS: { + value: { + POWER: 0x2D, + RANGE: 0x31, + READREGISTER: 0x32 + } + }, + initialize: { + value: function(opts, dataHandler) { + var READLENGTH = 6; + var io = this.board.io; + var address = opts.address || this.ADDRESSES[0]; + var state = priv.get(this); + + // Sensitivity: + // + // (ADXL345_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD) = (0.004 * 9.80665) = 0.0390625 + // + // Reference: + // https://github.com/adafruit/Adafruit_Sensor/blob/master/Adafruit_Sensor.h#L34-L37 + // https://github.com/adafruit/Adafruit_ADXL345/blob/master/Adafruit_ADXL345_U.h#L73 + // https://github.com/adafruit/Adafruit_ADXL345/blob/master/Adafruit_ADXL345_U.cpp#L298-L309 + // + // Invert for parity with other controllers + // + // (1 / 0.0390625) * (1 / 9.8) + // + // OR + // + // (1 / ADXL345_MG2G_MULTIPLIER) = (1 / 0.004) + // + // OR + // + // 250 + // + state.sensitivity = opts.sensitivity || 250; + + io.i2cConfig(); + + // Standby mode + io.i2cWrite(address, this.COMMANDS.POWER, 0); + + // Enable measurements + io.i2cWrite(address, this.COMMANDS.POWER, 8); + + // Set range (this is 2G range, should be user defined?) + io.i2cWrite(address, this.COMMANDS.RANGE, 8); + + io.i2cRead(address, this.COMMANDS.READREGISTER, READLENGTH, function(data) { + dataHandler.call(this, { + x: int16(data[1], data[0]), + y: int16(data[3], data[2]), + z: int16(data[5], data[4]) + }); + }.bind(this)); + }, + }, + toGravity: { + value: function(raw) { + var state = priv.get(this); + return raw / state.sensitivity; + } + } + }, + MMA7361: { + DEFAULTS: { + value: { + zeroV: [336, 372, 287], + sensitivity: 170 + } + }, + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this); + + if (opts.sleepPin !== undefined) { + state.sleepPin = opts.sleepPin; + this.board.pinMode(state.sleepPin, 1); + this.board.digitalWrite(state.sleepPin, 1); + } + + analogInitialize.call(this, opts, dataHandler); + } + }, + toGravity: { + value: analogToGravity + }, + enabledChanged: { + value: function(value) { + var state = priv.get(this); + + if (state.sleepPin !== undefined) { + this.board.digitalWrite(state.sleepPin, value ? 1 : 0); + } + } + } + }, + ESPLORA: { + DEFAULTS: { + value: { + zeroV: [320, 330, 310], + sensitivity: 170 + } + }, + initialize: { + value: function(opts, dataHandler) { + opts.pins = [5, 11, 6]; + analogInitialize.call(this, opts, dataHandler); + } + }, + toGravity: { + value: analogToGravity + } + } +}; + +// Otherwise known as... +Controllers["MPU-6050"] = Controllers.MPU6050; +Controllers["TINKERKIT"] = Controllers.ANALOG; + +function ToPrecision(val, precision) { + return +(val).toPrecision(precision); +} + +function magnitude(x, y, z) { + var a; + + a = x * x; + a = fma(y, y, a); + a = fma(z, z, a); + + return Math.sqrt(a); +} + +/** + * Accelerometer + * @constructor + * + * five.Accelerometer([ x, y[, z] ]); + * + * five.Accelerometer({ + * pins: [ x, y[, z] ] + * zeroV: ... + * sensitivity: ... + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Accelerometer(opts) { + if (!(this instanceof Accelerometer)) { + return new Accelerometer(opts); + } + + var controller = null; + + var state = { + enabled: true, + x: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + calibration: [] + }, + y: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + calibration: [] + }, + z: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + calibration: [] + } + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["ANALOG"]; + } + + Object.defineProperties(this, controller); + + if (!this.toGravity) { + this.toGravity = opts.toGravity || function(raw) { return raw; }; + } + + if (!this.enabledChanged) { + this.enabledChanged = function() {}; + } + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var isChange = false; + + if (!state.enabled) { + return; + } + + Object.keys(data).forEach(function(axis) { + var value = data[axis]; + var sensor = state[axis]; + + if (opts.autoCalibrate && sensor.calibration.length < calibrationSize) { + var axisIndex = axes.indexOf(axis); + sensor.calibration.push(value); + + if (!Array.isArray(state.zeroV)) { + state.zeroV = []; + } + + state.zeroV[axisIndex] = __.sum(sensor.calibration) / sensor.calibration.length; + if (axis === "z") { + state.zeroV[axisIndex] -= state.sensitivity; + } + } + + // The first run needs to prime the "stash" + // of data values. + if (sensor.stash.length === 0) { + for (var i = 0; i < 5; i++) { + sensor.stash[i] = value; + } + } + + sensor.previous = sensor.value; + sensor.stash.shift(); + sensor.stash.push(value); + + sensor.value = (sum(sensor.stash) / 5) | 0; + + if (this.acceleration !== sensor.acceleration) { + sensor.acceleration = this.acceleration; + isChange = true; + this.emit("acceleration", sensor.acceleration); + } + + if (this.orientation !== sensor.orientation) { + sensor.orientation = this.orientation; + isChange = true; + this.emit("orientation", sensor.orientation); + } + + if (this.inclination !== sensor.inclination) { + sensor.inclination = this.inclination; + isChange = true; + this.emit("inclination", sensor.inclination); + } + }, this); + + this.emit("data", { + x: state.x.value, + y: state.y.value, + z: state.z.value + }); + + if (isChange) { + this.emit("change", { + x: this.x, + y: this.y, + z: this.z + }); + } + }.bind(this)); + } + + Object.defineProperties(this, { + hasAxis: { + value: function(axis) { + return state[axis] ? state[axis].stash.length > 0 : false; + } + }, + enable: { + value: function() { + state.enabled = true; + this.enabledChanged(true); + return this; + } + }, + disable: { + value: function() { + state.enabled = false; + this.enabledChanged(false); + return this; + } + }, + zeroV: { + get: function() { + return state.zeroV; + } + }, + /** + * [read-only] Calculated pitch value + * @property pitch + * @type Number + */ + pitch: { + get: function() { + var x, y, z, rads; + + x = this.x; + y = this.y; + z = this.z; + + + rads = this.hasAxis("z") ? + Math.atan2(x, Math.hypot(y, z)) : + Math.asin(constrain(x, -1, 1)); + + return ToPrecision(rads * rad2deg, 2); + } + }, + /** + * [read-only] Calculated roll value + * @property roll + * @type Number + */ + roll: { + get: function() { + var x, y, z, rads; + + x = this.x; + y = this.y; + z = this.z; + + rads = this.hasAxis("z") ? + Math.atan2(y, Math.hypot(x, z)) : + Math.asin(constrain(y, -1, 1)); + + return ToPrecision(rads * rad2deg, 2); + } + }, + x: { + get: function() { + return ToPrecision(this.toGravity(state.x.value, "x"), 2); + } + }, + y: { + get: function() { + return ToPrecision(this.toGravity(state.y.value, "y"), 2); + } + }, + z: { + get: function() { + return this.hasAxis("z") ? + ToPrecision(this.toGravity(state.z.value, "z"), 2) : 0; + } + }, + acceleration: { + get: function() { + return magnitude( + this.x, + this.y, + this.z + ); + } + }, + inclination: { + get: function() { + return Math.atan2(this.y, this.x) * rad2deg; + } + }, + orientation: { + get: function() { + var abs = Math.abs; + var x = this.x; + var y = this.y; + var z = this.hasAxis(z) ? this.z : 1; + var xAbs = abs(x); + var yAbs = abs(y); + var zAbs = abs(z); + + if (xAbs < yAbs && xAbs < zAbs) { + if (x > 0) { + return 1; + } + return -1; + } + if (yAbs < xAbs && yAbs < zAbs) { + if (y > 0) { + return 2; + } + return -2; + } + if (zAbs < xAbs && zAbs < yAbs) { + if (z > 0) { + return 3; + } + return -3; + } + return 0; + } + } + }); +} + + +util.inherits(Accelerometer, events.EventEmitter); + +module.exports = Accelerometer; diff --git a/JavaScript/node_modules/johnny-five/lib/altimeter.js b/JavaScript/node_modules/johnny-five/lib/altimeter.js new file mode 100644 index 0000000..6356042 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/altimeter.js @@ -0,0 +1,416 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + __ = require("../lib/fn.js"), + sum = __.sum, + fma = __.fma, + constrain = __.constrain, + int16 = __.int16; + +var priv = new Map(); +var rad2deg = 180 / Math.PI; +var axes = ["x", "y", "z"]; + +var Controllers = { + ANALOG: { + DEFAULTS: { + value: { + zeroV: 478, + sensitivity: 96 + } + }, + initialize: { + value: function(opts, dataHandler) { + var pins = opts.pins || [], + state = priv.get(this), + dataPoints = {}; + + state.zeroV = opts.zeroV || this.DEFAULTS.zeroV; + state.sensitivity = opts.sensitivity || this.DEFAULTS.sensitivity; + + pins.forEach(function(pin, index) { + this.io.pinMode(pin, this.io.MODES.ANALOG); + this.io.analogRead(pin, function(data) { + var axis = axes[index]; + dataPoints[axis] = data; + dataHandler(dataPoints); + }.bind(this)); + }, this); + } + }, + toGravity: { + value: function(raw) { + var state = priv.get(this); + return (raw - state.zeroV) / state.sensitivity; + } + } + }, + // http://www.invensense.com/mems/gyro/mpu6050.html + BMP180: { + initialize: { + value: function(opts, dataHandler) { + var IMU = require("../lib/imu"); + var driver = IMU.Drivers.get(this.board, "BMP180", opts); + var state = priv.get(this); + + state.sensitivity = opts.sensitivity || 16384; + + driver.on("data", function(data) { + dataHandler.call(this, data.accelerometer); + }.bind(this)); + } + }, + toGravity: { + value: function(raw) { + var state = priv.get(this); + return raw / state.sensitivity; + } + } + }, + ADXL345: { + // http://www.analog.com/en/mems-sensors/mems-inertial-sensors/adxl345/products/product.html + // http://www.i2cdevlib.com/devices/adxl345#source + + ADDRESSES: { + value: [0x53] + }, + COMMANDS: { + value: { + POWER: 0x2D, + RANGE: 0x31, + READREGISTER: 0x32 + } + }, + initialize: { + value: function(opts, dataHandler) { + var READLENGTH = 6; + var io = this.board.io; + // var freq = opts.freq || 100; + var address = opts.address || this.ADDRESSES[0]; + var state = priv.get(this); + + // Sensitivity: + // + // (ADXL345_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD) = (0.004 * 9.80665) = 0.0390625 + // + // Reference: + // https://github.com/adafruit/Adafruit_Sensor/blob/master/Adafruit_Sensor.h#L34-L37 + // https://github.com/adafruit/Adafruit_ADXL345/blob/master/Adafruit_ADXL345_U.h#L73 + // https://github.com/adafruit/Adafruit_ADXL345/blob/master/Adafruit_ADXL345_U.cpp#L298-L309 + // + // Invert for parity with other controllers + // + // (1 / 0.0390625) * (1 / 9.8) + // + // OR + // + // (1 / ADXL345_MG2G_MULTIPLIER) = (1 / 0.004) + // + // OR + // + // 250 + // + state.sensitivity = opts.sensitivity || 250; + + io.i2cConfig(); + + // Standby mode + io.i2cWrite(address, this.COMMANDS.POWER, 0); + + // Enable measurements + io.i2cWrite(address, this.COMMANDS.POWER, 8); + + // Set range (this is 2G range, should be user defined?) + io.i2cWrite(address, this.COMMANDS.RANGE, 8); + + io.i2cRead(address, this.COMMANDS.READREGISTER, READLENGTH, function(data) { + dataHandler.call(this, { + x: int16(data[1], data[0]), + y: int16(data[3], data[2]), + z: int16(data[5], data[4]) + }); + }.bind(this)); + }, + }, + toGravity: { + value: function(raw) { + var state = priv.get(this); + return raw / state.sensitivity; + } + } + } +}; + +// Otherwise known as... +Controllers["MPU-6050"] = Controllers.BMP180; +Controllers["TINKERKIT"] = Controllers.ANALOG; +Controllers["ADXL335"] = { + DEFAULTS: { + value: { + zeroV: 330, + sensitivity: 66.5 + } + }, + initialize: Controllers.ANALOG.initialize, + toGravity: Controllers.ANALOG.toGravity +}; + +function ToPrecision(val, precision) { + return +(val).toPrecision(precision); +} + +function magnitude(x, y, z) { + var a; + + a = x * x; + a = fma(y, y, a); + a = fma(z, z, a); + + return Math.sqrt(a); +} + +/** + * Accelerometer + * @constructor + * + * five.Accelerometer([ x, y[, z] ]); + * + * five.Accelerometer({ + * pins: [ x, y[, z] ] + * zeroV: ... + * sensitivity: ... + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Accelerometer(opts) { + if (!(this instanceof Accelerometer)) { + return new Accelerometer(opts); + } + + var controller = null; + + var state = { + x: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + }, + y: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + }, + z: { + value: 0, + previous: 0, + stash: [], + orientation: null, + inclination: null, + acceleration: null, + } + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["ANALOG"]; + } + + Object.defineProperties(this, controller); + + if (!this.toGravity) { + this.toGravity = opts.toGravity || function(raw) { return raw; }; + } + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var isChange = false; + + Object.keys(data).forEach(function(axis) { + var value = data[axis]; + var sensor = state[axis]; + + // The first run needs to prime the "stash" + // of data values. + if (sensor.stash.length === 0) { + for (var i = 0; i < 5; i++) { + sensor.stash[i] = value; + } + } + + sensor.previous = sensor.value; + sensor.stash.shift(); + sensor.stash.push(value); + + sensor.value = (sum(sensor.stash) / 5) | 0; + + if (this.acceleration !== sensor.acceleration) { + sensor.acceleration = this.acceleration; + isChange = true; + this.emit("acceleration", sensor.acceleration); + } + + if (this.orientation !== sensor.orientation) { + sensor.orientation = this.orientation; + isChange = true; + this.emit("orientation", sensor.orientation); + } + + if (this.inclination !== sensor.inclination) { + sensor.inclination = this.inclination; + isChange = true; + this.emit("inclination", sensor.inclination); + } + }, this); + + this.emit("data", { + x: state.x.value, + y: state.y.value, + z: state.z.value + }); + + if (isChange) { + this.emit("change", { + x: this.x, + y: this.y, + z: this.z + }); + } + }.bind(this)); + } + + Object.defineProperties(this, { + hasAxis: { + value: function(axis) { + return state[axis] ? state[axis].stash.length > 0 : false; + } + }, + /** + * [read-only] Calculated pitch value + * @property pitch + * @type Number + */ + pitch: { + get: function() { + var x, y, z, rads; + + x = this.x; + y = this.y; + z = this.z; + + + rads = this.hasAxis("z") ? + Math.atan2(x, Math.hypot(y, z)) : + Math.asin(constrain(x, -1, 1)); + + return ToPrecision(rads * rad2deg, 2); + } + }, + /** + * [read-only] Calculated roll value + * @property roll + * @type Number + */ + roll: { + get: function() { + var x, y, z, rads; + + x = this.x; + y = this.y; + z = this.z; + + rads = this.hasAxis("z") ? + Math.atan2(y, Math.hypot(x, z)) : + Math.asin(constrain(y, -1, 1)); + + return ToPrecision(rads * rad2deg, 2); + } + }, + x: { + get: function() { + return ToPrecision(this.toGravity(state.x.value), 2); + } + }, + y: { + get: function() { + return ToPrecision(this.toGravity(state.y.value), 2); + } + }, + z: { + get: function() { + return this.hasAxis("z") ? + ToPrecision(this.toGravity(state.z.value), 2) : 0; + } + }, + acceleration: { + get: function() { + return magnitude( + this.x, + this.y, + this.z + ); + } + }, + inclination: { + get: function() { + return Math.atan2(this.y, this.x) * rad2deg; + } + }, + orientation: { + get: function() { + var abs = Math.abs; + var x = this.x; + var y = this.y; + var z = this.hasAxis(z) ? this.z : 1; + var xAbs = abs(x); + var yAbs = abs(y); + var zAbs = abs(z); + + if (xAbs < yAbs && xAbs < zAbs) { + if (x > 0) { + return 1; + } + return -1; + } + if (yAbs < xAbs && yAbs < zAbs) { + if (y > 0) { + return 2; + } + return -2; + } + if (zAbs < xAbs && zAbs < yAbs) { + if (z > 0) { + return 3; + } + return -3; + } + return 0; + } + } + }); +} + + +util.inherits(Accelerometer, events.EventEmitter); + +module.exports = Accelerometer; diff --git a/JavaScript/node_modules/johnny-five/lib/animation.js b/JavaScript/node_modules/johnny-five/lib/animation.js new file mode 100644 index 0000000..293f7d2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/animation.js @@ -0,0 +1,466 @@ +// TODO list +// Use functions as keyFrames +// Test metronomic on real animation + +// Create jquery FX like queue + +var ease = require("ease-component"), + Emitter = require("events").EventEmitter, + util = require("util"), + __ = require("../lib/fn.js"), + temporal; + +Animation.DEFAULTS = { + cuePoints: [0, 1], + duration: 1000, + easing: "linear", + loop: false, + loopback: 0, + metronomic: false, + currentSpeed: 1, + progress: 0, + fps: 60, + rate: 1000 / 60, + paused: false, + segments: [], + onstart: null, + onpause: null, + onstop: null, + oncomplete: null, + onloop: null +}; + +/** + * Placeholders for Symbol + */ +Animation.normalize = "@@normalize"; +Animation.render = "@@render"; + +/** + * Animation + * @constructor + * + * @param {target} A Servo or Servo.Array to be animated + * + * Animating a single servo + * + * var servo = new five.Servo(10); + * var animation = new five.Animation(servo); + * animation.enqueue({ + * cuePoints: [0, 0.25, 0.75, 1], + * keyFrames: [{degrees: 90}, 60, -120, {degrees: 90}], + * duration: 2000 + * }); + * + * + * Animating a servo array + * + * var a = new five.Servo(9), + * b = new five.Servo(10); + * var servos = new five.Servo.Array([a, b]); + * var animation = new five.Animation(servos); + * animation.enqueue({ + * cuePoints: [0, 0.25, 0.75, 1], + * keyFrames: [ + * [{degrees: 90}, 60, -120, {degrees: 90}], + * [{degrees: 180}, -120, 90, {degrees: 180}], + * ], + * duration: 2000 + * }); + * + */ + +function Animation(target) { + + // Necessary to avoid loading temporal unless necessary + if (!temporal) { + temporal = require("temporal"); + } + + if (!(this instanceof Animation)) { + return new Animation(target); + } + + this.defaultTarget = target; + + __.extend(this, Animation.DEFAULTS); + +} + +util.inherits(Animation, Emitter); + +/** + * Add an animation segment to the animation queue + * @param {Object} opts Options: cuePoints, keyFrames, duration, + * easing, loop, metronomic, progress, fps, onstart, onpause, + * onstop, oncomplete, onloop + */ +Animation.prototype.enqueue = function(opts) { + + if (typeof opts.target === "undefined") { + opts.target = this.defaultTarget; + } + + __.defaults(opts, Animation.DEFAULTS); + this.segments.push(opts); + + if (!this.paused) { + this.next(); + } + + return this; + +}; + +/** + * Plays next segment in queue + * Users need not call this. It's automatic + */ +Animation.prototype.next = function() { + + if (this.segments.length > 0) { + + __.extend(this, this.segments.shift()); + + if (this.onstart) { + this.onstart(); + } + + this.normalizedKeyFrames = __.cloneDeep(this.keyFrames); + this.normalizedKeyFrames = this.target[Animation.normalize](this.normalizedKeyFrames); + this.normalizedKeyFrames = this.normalizeKeyframes(this.normalizedKeyFrames, this.cuePoints); + + if (this.reverse) { + this.currentSpeed *= -1; + } + + if (this.currentSpeed !== 0) { + this.play(); + } else { + this.paused = true; + } + } else { + this.playLoop.stop(); + } + +}; + +/** + * pause + * + * Pause animation while maintaining progress, speed and segment queue + * + */ + +Animation.prototype.pause = function() { + + this.emit("animation:pause"); + + this.playLoop.stop(); + this.paused = true; + + if (this.onpause) { + this.onpause(); + } + +}; + +/** + * stop + * + * Stop all animations + * + */ + +Animation.prototype.stop = function() { + + this.emit("animation:stop"); + + this.segments = []; + temporal.clear(); + + if (this.onstop) { + this.onstop(); + } + +}; + +/** + * speed + * + * Get or set the current playback speed + * + * @param {Number} speed + * + */ + +Animation.prototype.speed = function(speed) { + + if (typeof speed === "undefined") { + return this.currentSpeed; + } else { + this.currentSpeed = speed; + + // Find our timeline endpoints and refresh rate + this.scaledDuration = this.duration / Math.abs(this.currentSpeed); + this.startTime = Date.now() - this.scaledDuration * this.progress; + this.endTime = this.startTime + this.scaledDuration; + return this; + } +}; + +/** + * play + * + * Start a segment + */ + +Animation.prototype.play = function() { + + if (this.playLoop) { + this.playLoop.stop(); + } + + this.paused = false; + + // Find our timeline endpoints and refresh rate + this.scaledDuration = this.duration / Math.abs(this.currentSpeed); + this.startTime = Date.now() - this.scaledDuration * this.progress; + this.endTime = this.startTime + this.scaledDuration; + + if (this.fps) { + this.rate = 1000 / this.fps; + } + + this.rate = this.rate | 0; + + this.playLoop = temporal.loop(this.rate, function(loop) { + // Note: "this" is bound to the animation object + + // Find the current timeline progress + var progress = this.calculateProgress(loop.calledAt); + + // Find the left and right cuePoints/keyFrames; + var indices = this.findIndices(progress); + + // Get tweened value + var val = this.tweenedValue(indices, progress); + + // call render function + this.target[Animation.render](val); + + // See if we have reached the end of the animation + if ((progress === 1 && !this.reverse) || (progress === this.loopback && this.reverse)) { + + if (this.loop || (this.metronomic && !this.reverse)) { + + if (this.onloop) { + this.onloop(); + } + + if (this.metronomic) { + this.reverse = this.reverse ? false : true; + } + + this.normalizedKeyFrames = __.cloneDeep(this.keyFrames); + this.normalizedKeyFrames = this.target[Animation.normalize](this.normalizedKeyFrames); + this.normalizedKeyFrames = this.normalizeKeyframes(); + + this.progress = this.loopback; + this.startTime = Date.now() - this.scaledDuration * this.progress; + this.endTime = this.startTime + this.scaledDuration; + + } else { + + this.stop(); + if (this.oncomplete) { + this.oncomplete(); + } + this.next(); + + } + } + + }.bind(this)); + +}; + +Animation.prototype.findIndices = function(progress) { + var indices = { + left: null, + right: null + }; + + // Find our current before and after cuePoints + indices.right = this.cuePoints.findIndex(function(point) { + return point >= progress; + }); + + indices.left = indices.right === 0 ? 0 : indices.right - 1; + + return indices; +}; + +Animation.prototype.calculateProgress = function(calledAt) { + var progress = (calledAt - this.startTime) / this.scaledDuration; + + if (progress > 1) { + progress = 1; + } + + this.progress = progress; + + if (this.reverse) { + progress = 1 - progress; + } + + // Ease the timeline + // to do: When reverse replace inFoo with outFoo and vice versa. skip inOutFoo + progress = ease[this.easing](progress); + + progress = __.constrain(progress, 0, 1); + + return progress; +}; + +Animation.prototype.tweenedValue = function(indices, progress) { + + var tween = { + duration: null, + progress: null + }; + + var result = this.normalizedKeyFrames.map(function(keyFrame) { + // Note: "this" is bound to the animation object + + var memberIndices = { + left: null, + right: null + }; + + // If the keyframe at indices.left is null, move left + for (memberIndices.left = indices.left; memberIndices.left > -1; memberIndices.left--) { + if (keyFrame[memberIndices.left] !== null) { + break; + } + } + + // If the keyframe at indices.right is null, move right + memberIndices.right = keyFrame.findIndex(function(frame, index) { + return index >= indices.right && frame !== null; + }); + + // Find our progress for the current tween + tween.duration = this.cuePoints[memberIndices.right] - this.cuePoints[memberIndices.left]; + tween.progress = (progress - this.cuePoints[memberIndices.left]) / tween.duration; + + // Catch divide by zero + if (!Number.isFinite(tween.progress)) { + tween.progress = this.reverse ? 0 : 1; + } + + var left = keyFrame[memberIndices.left], + right = keyFrame[memberIndices.right]; + + // Apply tween easing to tween.progress + // to do: When reverse replace inFoo with outFoo and vice versa. skip inOutFoo + tween.progress = ease[right.easing](tween.progress); + + // Calculate this tween value + var calcValue; + + if (right.position) { + // This is a tuple + calcValue = right.position.map(function(value, index) { + return (value - left.position[index]) * + tween.progress + left.position[index]; + }); + } else { + calcValue = (right.value - left.value) * + tween.progress + left.value; + } + + return calcValue; + + }, this); + + return result; +}; + +// Make sure our keyframes conform to a standard +Animation.prototype.normalizeKeyframes = function() { + + var previousVal, + keyFrameSet = this.normalizedKeyFrames, + cuePoints = this.cuePoints; + + // keyFrames can be passed as a single dimensional array if + // there is just one servo/device. If the first element is not an + // array, nest keyFrameSet so we only have to deal with one format + if (!Array.isArray(keyFrameSet[0])) { + keyFrameSet = [keyFrameSet]; + } + + keyFrameSet.forEach(function(keyFrames) { + + // Pad the right side of keyFrames arrays with null + for (var i = keyFrames.length; i < cuePoints.length; i++) { + keyFrames.push(null); + } + + keyFrames.forEach(function(keyFrame, i, source) { + + if (keyFrame !== null) { + + // keyFrames need to be converted to objects + if (typeof keyFrame !== "object") { + keyFrame = { + step: keyFrame, + easing: "linear" + }; + } + + // Replace step values + if (typeof keyFrame.step !== "undefined") { + keyFrame.value = keyFrame.step === false ? + previousVal : previousVal + keyFrame.step; + } + + // Set a default easing function + if (!keyFrame.easing) { + keyFrame.easing = "linear"; + } + + // Copy value from another frame + if (typeof keyFrame.copyValue !== "undefined") { + keyFrame.value = source[keyFrame.copyValue].value; + } + + // Copy everything from another keyframe in this array + if (keyFrame.copyFrame) { + keyFrame = source[keyFrame.copyFrame]; + } + + previousVal = keyFrame.value; + + } else { + + if (i === source.length - 1) { + keyFrame = { + value: previousVal, + easing: "linear" + }; + } else { + keyFrame = null; + } + + } + source[i] = keyFrame; + + }, this); + + }); + return keyFrameSet; +}; + +module.exports = Animation; diff --git a/JavaScript/node_modules/johnny-five/lib/barometer.js b/JavaScript/node_modules/johnny-five/lib/barometer.js new file mode 100644 index 0000000..80fb4af --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/barometer.js @@ -0,0 +1,128 @@ +var Board = require("../lib/board.js"); +var Emitter = require("events").EventEmitter; +var util = require("util"); + + +var Controllers = { + MPL115A2: { + initialize: { + value: function(opts, dataHandler) { + var Multi = require("../lib/imu"); + var driver = Multi.Drivers.get(this.board, "MPL115A2", opts); + driver.on("data", function(data) { + dataHandler.call(this, data.pressure); + }.bind(this)); + } + }, + // kPa (Kilopascals) + toPressure: { + value: function(raw) { + // http://cache.freescale.com/files/sensors/doc/data_sheet/MPL115A2.pdf + // P. 6, Eqn. 2 + return ((65.0 / 1023.0) * raw) + 50.0; + } + } + }, + BMP180: { + initialize: { + value: function(opts, dataHandler) { + var Multi = require("../lib/imu"); + var driver = Multi.Drivers.get(this.board, "BMP180", opts); + driver.on("data", function(data) { + dataHandler.call(this, data.pressure); + }.bind(this)); + } + }, + // kPa (Kilopascals) + toPressure: { + value: function(raw) { + return raw / 1000; + } + } + } +}; + +/** + * Barometer + * @constructor + * + * five.Barometer(opts); + * + * five.Barometer({ + * controller: "CONTROLLER" + * address: 0x00 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Barometer(opts) { + if (!(this instanceof Barometer)) { + return new Barometer(opts); + } + + var controller = null; + var last = null; + var raw = null; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + var freq = opts.freq || 25; + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + // controller = Controllers["ANALOG"]; + throw new Error("Missing Barometer controller"); + } + + Object.defineProperties(this, controller); + + if (!this.toPressure) { + this.toPressure = opts.toPressure || function(raw) { return raw; }; + } + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + raw = data; + }); + } + + Object.defineProperties(this, { + pressure: { + get: function() { + return this.toPressure(raw).toFixed(4); + } + } + }); + + setInterval(function() { + if (raw === null) { + return; + } + + var data = { + pressure: this.pressure + }; + + this.emit("data", data); + + if (this.pressure !== last) { + last = this.pressure; + this.emit("change", data); + } + }.bind(this), freq); +} + + +util.inherits(Barometer, Emitter); + +module.exports = Barometer; diff --git a/JavaScript/node_modules/johnny-five/lib/board.js b/JavaScript/node_modules/johnny-five/lib/board.js new file mode 100644 index 0000000..5957b27 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/board.js @@ -0,0 +1,1151 @@ +require("es6-shim"); +require("array-includes").shim(); + +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Emitter = require("events").EventEmitter; +var util = require("util"); +// var os = require("os"); +var chalk = require("chalk"); +var _ = require("lodash"); +var Collection = require("../lib/mixins/collection"); +var __ = require("../lib/fn.js"); +var Repl = require("../lib/repl.js"); +var Options = require("../lib/board.options.js"); +var Pins = require("../lib/board.pins.js"); +//var temporal = require("temporal"); +//var IO; + +// Environment Setup +var boards = []; +var rport = /usb|acm|^com/i; + +// TODO: +// +// At some point we should figure out a way to +// make execution-on-board environments uniformally +// detected and reported. +// +// var isGalileo = (function() { +// var release = os.release(); +// return release.includes("yocto") || +// release.includes("edison"); +// })(); +// var isOnBoard = isGalileo; + +// if (isOnBoard) { +// if (isGalileo) { +// IO = require("galileo-io"); +// } +// } + +/** + * Process Codes + * SIGHUP 1 Term Hangup detected on controlling terminal + or death of controlling process + * SIGINT 2 Term Interrupt from keyboard + * SIGQUIT 3 Core Quit from keyboard + * SIGILL 4 Core Illegal Instruction + * SIGABRT 6 Core Abort signal from abort(3) + * SIGFPE 8 Core Floating point exception + * SIGKILL 9 Term Kill signal + * SIGSEGV 11 Core Invalid memory reference + * SIGPIPE 13 Term Broken pipe: write to pipe with no readers + * SIGALRM 14 Term Timer signal from alarm(2) + * SIGTERM 15 Term Termination signal + * + * + * + * http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/Tools/Batch/exitcode.html + * + */ + +var Serial = { + + used: [], + attempts: [], + + detect: function(callback) { + var serialport = IS_TEST_MODE ? + require("../test/util/mock-serial") : + require("serialport"); + + // Request a list of available ports, from + // the result set, filter for valid paths + // via known path pattern match. + serialport.list(function(err, result) { + + // serialport.list() will never result in an error. + // On failure, an empty array is returned. (#768) + + var ports, + length; + + ports = result.filter(function(val) { + var available = true; + + // Match only ports that Arduino cares about + // ttyUSB#, cu.usbmodem#, COM# + if (!rport.test(val.comName)) { + available = false; + } + + // Don't allow already used/encountered usb device paths + if (Serial.used.includes(val.comName)) { + available = false; + } + + return available; + }).map(function(val) { + return val.comName; + }); + + length = ports.length; + + // If no ports are detected... + if (!length) { + + // Create an attempt counter + if (!Serial.attempts[Serial.used.length]) { + Serial.attempts[Serial.used.length] = 0; + + // Log notification... + this.info("Board", "Looking for connected device"); + } + + // Set the attempt number + Serial.attempts[Serial.used.length]++; + + // Retry Serial connection + Serial.detect.call(this, callback); + + return; + } + + this.info( + "Device(s)", + chalk.grey(ports) + ); + + // Get the first available device path from the list of + // detected ports + callback.call(this, ports[0]); + }.bind(this)); + }, + + connect: function(portOrPath, callback) { + var IO = IS_TEST_MODE ? + require("../test/util/mock-firmata") : + require("firmata").Board; + + var err, io, isConnected, path, type; + + if (typeof portOrPath === "object" && portOrPath.path) { + // + // Board({ port: SerialPort Object }) + // + path = portOrPath.path; + + this.info( + (portOrPath.transport || "SerialPort"), + chalk.grey(path) + ); + } else { + // + // Board({ port: path String }) + // + // Board() + // ie. auto-detected + // + path = portOrPath; + } + + // Add the usb device path to the list of device paths that + // are currently in use - this is used by the filter function + // above to remove any device paths that we've already encountered + // or used to avoid blindly attempting to reconnect on them. + Serial.used.push(path); + + try { + io = new IO(portOrPath, function(error) { + if (error !== undefined) { + err = error; + } + + callback.call(this, err, err ? "error" : "ready", io); + }.bind(this)); + + // Extend io instance with special expandos used + // by Johny-Five for the IO Plugin system. + io.name = "Firmata"; + io.defaultLed = 13; + io.port = path; + + // Made this far, safely connected + isConnected = true; + } catch (error) { + err = error; + } + + if (err) { + err = err.message || err; + } + + // Determine the type of event that will be passed on to + // the board emitter in the callback passed to Serial.detect(...) + type = isConnected ? "connect" : "error"; + + // Execute "connect" callback + callback.call(this, err, type, io); + } +}; + +/** + * Board + * @constructor + * + * @param {Object} opts + */ + +function Board(opts) { + + if (!(this instanceof Board)) { + return new Board(opts); + } + + // Ensure opts is an object + opts = opts || {}; + + // Used to define the board instance's own + // properties in the REPL's scope. + var replContext = {}; + + // It's feasible that an IO-Plugin may emit + // "connect" and "ready" events out of order. + // This is used to enforce the order, by + // postponing the "ready" event if the IO-Plugin + // hasn't emitted a "connect" event. Once + // the "connect" event is emitted, the + // postponement is lifted and the board may + // proceed with emitting the events in the + // correct order. + var isPostponed = false; + + // Initialize this Board instance with + // param specified properties. + _.assign(this, opts); + + this.timer = null; + + this.isConnected = false; + + // Easily track state of hardware + this.isReady = false; + + // Initialize instance property to reference io board + this.io = this.io || null; + + // Registry of components + this.register = []; + + // Pins, Addr (alt Pin name), Addresses + this.occupied = []; + + // Registry of drivers by address (i.e. I2C Controllers) + this.Drivers = {}; + + // Identify for connect hardware cache + if (!this.id) { + this.id = __.uid(); + } + + // If no debug flag, default to true + if (typeof this.debug === "undefined") { + this.debug = true; + } + + // If no repl flag, default to true + if (typeof this.repl === "undefined") { + this.repl = true; + } + + // If no sigint flag, default to true + if (typeof this.sigint === "undefined") { + this.sigint = true; + } + + // Specially processed pin capabilities object + // assigned when physical board has reported + // "ready" via Firmata or IO-Plugin. + this.pins = null; + + // Create a Repl instance and store as + // instance property of this io/board. + // This will reduce the amount of boilerplate + // code required to _always_ have a Repl + // session available. + // + // If a sesssion exists, use it + // (instead of creating a new session) + // + if (this.repl) { + if (Repl.ref) { + + replContext[this.id] = this; + + Repl.ref.on("ready", function() { + Repl.ref.inject(replContext); + }); + + this.repl = Repl.ref; + } else { + replContext[this.id] = replContext.board = this; + this.repl = new Repl(replContext); + } + } + + if (opts.io) { + // If you already have a connected io instance + this.io = opts.io; + this.isReady = opts.io.isReady; + this.transport = this.io.transport || null; + this.port = this.io.name; + this.pins = Board.Pins(this); + } else { + + // if (isOnBoard) { + // this.io = new IO(); + // this.port = this.io.name; + // } else { + if (this.port && opts.port) { + Serial.connect.call(this, this.port, broadcast); + } else { + // TODO: refactor to do the path lookups + // as soon as this file is required. + Serial.detect.call(this, function(path) { + Serial.connect.call(this, path, broadcast); + }); + } + // } + } + + // Either an IO instance was provided or isOnBoard is true + if (!opts.port && this.io !== null) { + this.info( + "Device(s)", chalk.grey(this.io.name || "unknown") + ); + + ["connect", "ready"].forEach(function(type) { + this.io.once(type, function() { + // Since connection and readiness happen asynchronously, + // it's actually possible for Johnny-Five to receive the + // events out of order and that should be ok. + if (type === "ready" && !this.isConnected) { + isPostponed = true; + } else { + // Will emit the "connect" and "ready" events + // if received in order. If out of order, this + // will only emit the "connect" event. The + // "ready" event will be handled in the next + // condition's consequent. + broadcast.call(this, null, type, this.io); + } + + if (type === "connect" && isPostponed) { + broadcast.call(this, null, "ready", this.io); + } + }.bind(this)); + + if (this.io.isReady) { + // If the IO instance is reached "ready" + // state, queue tick tasks to emit the + // "connect" and "ready" events + + process.nextTick(function() { + this.io.emit(type); + }.bind(this)); + } + }, this); + + // Bubble "string" events from IO layer + this.io.on("string", function(data) { + this.emit("string", data); + }.bind(this)); + } + + // Cache instance to allow access from module constructors + boards.push(this); +} + +function broadcast(err, type, io) { + // Assign found io to instance + if (!this.io) { + this.io = io; + } + + if (type === "error") { + if (err && err.message) { + console.log(err.message.red); + } + } + + if (type === "connect") { + this.isConnected = true; + this.port = io.port || io.name; + + this.info( + "Connected", + chalk.grey(this.port) + ); + + // 10 Second timeout... + // + // If "ready" hasn't fired and cleared the timer within + // 10 seconds of the connect event, then it's likely + // there is an issue with the device or firmware. + this.timer = setTimeout(function() { + + this.error( + "Device or Firmware Error", + "A timeout occurred while connecting to the Board. \n\n" + + "Please check that you've properly flashed the board with the correct firmware.\n" + + "See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting" + ); + + this.emit("error", new Error("A timeout occurred while connecting to the Board.")); + }.bind(this), 1e4); + } + + if (type === "ready") { + clearTimeout(this.timer); + + // Update instance `ready` flag + this.isReady = true; + this.pins = Board.Pins(this); + this.MODES = this.io.MODES; + + // In multi-board mode, block the REPL from + // activation. This will be started directly + // by the Board.Array constructor. + // + // In single-board mode, the REPL will not + // be blocked at all. + // + // If the user program has not disabled the + // REPL, initialize it. + if (this.repl) { + this.repl.initialize(this.emit.bind(this, "ready")); + } + + if (io.name !== "Mock" && this.sigint) { + process.on("SIGINT", function() { + this.warn("Board", "Closing."); + process.exit(0); + }.bind(this)); + } + + // Bubble "string" events from IO layer + io.on("string", function(data) { + this.emit("string", data); + }.bind(this)); + } + + // If there is a REPL... + if (this.repl) { + // "ready" will be emitted once repl.initialize + // is complete, so the only event that needs to + // be propagated here is the "connect" event. + if (type === "connect") { + this.emit(type, err); + } + } else { + // The REPL is disabled, propagate all events + this.emit(type, err); + } +} + +// Inherit event api +util.inherits(Board, Emitter); + + + +/** + * Pass through methods + */ +[ + "digitalWrite", "analogWrite", "servoWrite", "sendI2CWriteRequest", + "analogRead", "digitalRead", "sendI2CReadRequest", + "pinMode", "queryPinState", "sendI2CConfig", + "stepperStep", "stepperConfig", "servoConfig", + "i2cConfig", "i2cWrite", "i2cWriteReg", "i2cRead", "i2cReadOnce", +].forEach(function(method) { + Board.prototype[method] = function() { + this.io[method].apply(this.io, arguments); + return this; + }; +}); + + +Board.prototype.serialize = function(filter) { + var blacklist = this.serialize.blacklist; + var special = this.serialize.special; + + return JSON.stringify( + this.register.map(function(device) { + return Object.getOwnPropertyNames(device).reduce(function(data, prop) { + var value = device[prop]; + + if (!blacklist.includes(prop) && + typeof value !== "function") { + + data[prop] = special[prop] ? + special[prop](value) : value; + + if (filter) { + data[prop] = filter(prop, data[prop], device); + } + } + return data; + }, {}); + }, this) + ); +}; + +Board.prototype.serialize.blacklist = [ + "board", "io", "_events" +]; + +Board.prototype.samplingInterval = function(ms) { + + if (this.io.setSamplingInterval) { + this.io.setSamplingInterval(ms); + } else { + console.log("This IO plugin does not implement an interval adjustment method"); + } + return this; +}; + + +Board.prototype.serialize.special = { + mode: function(value) { + return ["INPUT", "OUTPUT", "ANALOG", "PWM", "SERVO"][value] || "unknown"; + } +}; + +/** + * shiftOut + * + */ +Board.prototype.shiftOut = function(dataPin, clockPin, isBigEndian, value) { + var mask, write; + + write = function(value, mask) { + this.digitalWrite(clockPin, this.io.LOW); + this.digitalWrite( + dataPin, this.io[value & mask ? "HIGH" : "LOW"] + ); + this.digitalWrite(clockPin, this.io.HIGH); + }.bind(this); + + if (arguments.length === 3) { + value = arguments[2]; + isBigEndian = true; + } + + if (isBigEndian) { + for (mask = 128; mask > 0; mask = mask >> 1) { + write(value, mask); + } + } else { + for (mask = 0; mask < 128; mask = mask << 1) { + write(value, mask); + } + } +}; + +var logging = { + specials: [ + "error", + "fail", + "warn", + "info", + ], + colors: { + log: "white", + error: "red", + fail: "inverse", + warn: "yellow", + info: "cyan" + } +}; + +Board.prototype.log = function( /* type, klass, message [, long description] */ ) { + var args = [].slice.call(arguments); + + // If this was a direct call to `log(...)`, make sure + // there is a correct "type" to emit below. + if (!logging.specials.includes(args[0])) { + args.unshift("log"); + } + + var type = args.shift(); + var klass = args.shift(); + var message = args.shift(); + var color = logging.colors[type]; + var now = Date.now(); + var event = { + type: type, + timestamp: now, + class: klass, + message: "", + data: null, + }; + + if (typeof args[args.length - 1] === "object") { + event.data = args.pop(); + } + + message += " " + args.join(", "); + event.message = message.trim(); + + if (this.debug) { + console.log([ + // Timestamp + chalk.grey(now), + // Module, color matches type of log + chalk.magenta(klass), + // Details + chalk[color](message), + // Miscellaneous args + args.join(", ") + ].join(" ")); + } + + this.emit(type, event); + this.emit("message", event); +}; + + +// Make shortcuts to all logging methods +logging.specials.forEach(function(type) { + Board.prototype[type] = function() { + var args = [].slice.call(arguments); + args.unshift(type); + + this.log.apply(this, args); + }; +}); + + +/** + * delay, loop, queue + * + * Pass through methods to temporal + */ +/* +[ + "delay", "loop", "queue" +].forEach(function( method ) { + Board.prototype[ method ] = function( time, callback ) { + temporal[ method ]( time, callback ); + return this; + }; +}); + +// Alias wait to delay to match existing Johnny-five API +Board.prototype.wait = Board.prototype.delay; +*/ + +// -----THIS IS A TEMPORARY FIX UNTIL THE ISSUES WITH TEMPORAL ARE RESOLVED----- +// Aliasing. +// (temporary, while ironing out API details) +// The idea is to match existing hardware programming apis +// or simply find the words that are most intuitive. + +// Eventually, there should be a queuing process +// for all new callbacks added +// +// TODO: Repalce with temporal or compulsive API + +Board.prototype.wait = function(time, callback) { + setTimeout(callback.bind(this), time); + return this; +}; + +Board.prototype.loop = function(time, callback) { + setInterval(callback.bind(this), time); + return this; +}; + +// ---------- +// Static API +// ---------- + +// Board.map( val, fromLow, fromHigh, toLow, toHigh ) +// +// Re-maps a number from one range to another. +// Based on arduino map() +Board.map = __.map; +Board.fmap = __.fmap; + +// Board.constrain( val, lower, upper ) +// +// Constrains a number to be within a range. +// Based on arduino constrain() +Board.constrain = __.constrain; + +// Board.range( upper ) +// Board.range( lower, upper ) +// Board.range( lower, upper, tick ) +// +// Returns a new array range +// +Board.range = __.range; + +// Board.range.prefixed( prefix, upper ) +// Board.range.prefixed( prefix, lower, upper ) +// Board.range.prefixed( prefix, lower, upper, tick ) +// +// Returns a new array range, each value prefixed +// +Board.range.prefixed = __.range.prefixed; + +// Board.uid() +// +// Returns a reasonably unique id string +// +Board.uid = __.uid; + +// Board.mount() +// Board.mount( index ) +// Board.mount( object ) +// +// Return hardware instance, based on type of param: +// @param {arg} +// object, user specified +// number/index, specified in cache +// none, defaults to first in cache +// +// Notes: +// Used to reduce the amount of boilerplate +// code required in any given module or program, by +// giving the developer the option of omitting an +// explicit Board reference in a module +// constructor's options +Board.mount = function(arg) { + var index = typeof arg === "number" && arg, + hardware; + + // board was explicitly provided + if (arg && arg.board) { + return arg.board; + } + + // index specified, attempt to return + // hardware instance. Return null if not + // found or not available + if (index) { + hardware = boards[index]; + return hardware && hardware || null; + } + + // If no arg specified and hardware instances + // exist in the cache + if (boards.length) { + return boards[0]; + } + + // No mountable hardware + return null; +}; + + + +/** + * Board.Component + * + * Initialize a new device instance + * + * Board.Component is a |this| sensitive constructor, + * and must be called as: + * + * Board.Component.call( this, opts ); + * + * + * + * TODO: Migrate all constructors to use this + * to avoid boilerplate + */ + +Board.Component = function(opts, componentOpts) { + if (typeof opts === "undefined") { + opts = {}; + } + + if (typeof componentOpts === "undefined") { + componentOpts = {}; + } + + // Board specific properties + this.board = Board.mount(opts); + this.io = this.board.io; + + // Component/Module instance properties + this.id = opts.id || null; + + var originalPins; + + if (typeof opts.pin === "number" || typeof opts.pin === "string") { + originalPins = [opts.pin]; + } else { + if (Array.isArray(opts.pins)) { + originalPins = opts.pins.slice(); + } else { + if (typeof opts.pins === "object" && opts.pins !== null) { + + var pinset = opts.pins || opts.pin; + + originalPins = []; + for (var p in pinset) { + originalPins.push(pinset[p]); + } + } + } + } + + componentOpts = Board.Component.initialization(componentOpts); + + if (componentOpts.normalizePin) { + opts = Board.Pins.normalize(opts, this.board); + } + + var requesting = []; + + if (typeof opts.pins !== "undefined") { + this.pins = opts.pins || []; + + if (Array.isArray(this.pins)) { + requesting = requesting.concat( + this.pins.map(function(pin) { + return { + value: pin, + type: "pin" + }; + }) + ); + } else { + requesting = requesting.concat( + Object.keys(this.pins).map(function(key) { + return { + value: this.pins[key], + type: "pin" + }; + }, this) + ); + } + } + + if (typeof opts.pin !== "undefined") { + this.pin = opts.pin; + requesting.push({ + value: this.pin, + type: "pin" + }); + } + + if (typeof opts.emitter !== "undefined") { + this.emitter = opts.emitter; + requesting.push({ + value: this.emitter, + type: "emitter" + }); + } + + // TODO: Kill this. + if (typeof opts.addr !== "undefined") { + this.addr = opts.addr; + requesting.push({ + value: this.addr, + type: "addr" + }); + } + + if (typeof opts.address !== "undefined" && requesting.length) { + this.address = opts.address; + requesting.forEach(function(request) { + request.address = this.address; + }, this); + } + + if (typeof opts.controller !== "undefined" && requesting.length) { + this.controller = opts.controller; + requesting.forEach(function(request) { + request.controller = this.controller; + }, this); + } + + if (componentOpts.requestPin) { + // With the pins being requested for use by this component, + // compare with the list of pins that are already known to be + // in use by other components. If any are known to be in use, + // produce a warning for the user. + requesting.forEach(function(request, index) { + var hasController = typeof request.controller !== "undefined"; + var hasAddress = typeof request.address !== "undefined"; + var isOccupied = false; + var message = ""; + + request.value = originalPins[index]; + + if (this.board.occupied.length) { + isOccupied = this.board.occupied.some(function(occupied) { + var isPinOccupied = request.value === occupied.value && request.type === occupied.type; + + if (typeof occupied.controller !== "undefined") { + if (hasController) { + return isPinOccupied && (request.controller === occupied.controller); + } + return false; + } + + if (typeof occupied.address !== "undefined") { + if (hasAddress) { + return isPinOccupied && (request.address === occupied.address); + } + return false; + } + + return isPinOccupied; + }); + } + + if (isOccupied) { + message = request.type + ": " + request.value; + + if (hasController) { + message += ", controller: " + request.controller; + } + + if (hasAddress) { + message += ", address: " + request.address; + } + + this.board.warn("Component", message + " is already in use"); + } else { + this.board.occupied.push(request); + } + }, this); + } + + this.board.register.push(this); +}; + +Board.Component.initialization = function(opts) { + var defaults = { + requestPin: true, + normalizePin: true + }; + + return Object.assign({}, defaults, opts); +}; + + +Board.Device = function(opts) { + Board.Component.call(this, opts); +}; + + +/** + * Pin Capability Signature Mapping + */ + +Board.Pins = Pins; + +Board.Options = Options; + +// Define a user-safe, unwritable hardware cache access +Object.defineProperty(Board, "cache", { + get: function() { + return boards; + } +}); + +/** + * Board event constructor. + * opts: + * type - event type. eg: "read", "change", "up" etc. + * target - the instance for which the event fired. + * 0..* other properties + */ +Board.Event = function(opts) { + + if (!(this instanceof Board.Event)) { + return new Board.Event(opts); + } + + opts = opts || {}; + + // default event is read + this.type = opts.type || "read"; + + // actual target instance + this.target = opts.target || null; + + // Initialize this Board instance with + // param specified properties. + _.assign(this, opts); +}; + + +/** + * Boards or Board.Array; Used when the program must connect to + * more then one board. + * + * @memberof Board + * + * @param {Array} ports List of port objects { id: ..., port: ... } + * List of id strings (initialized in order) + * + * @return {Boards} board object references + */ +function Boards(opts) { + if (!(this instanceof Boards)) { + return new Boards(opts); + } + + var ports; + + // new Boards([ ...Array of board opts ]) + if (Array.isArray(opts)) { + ports = opts.slice(); + opts = { + ports: ports, + }; + } + + // new Boards({ ports: [ ...Array of board opts ], .... }) + if (!Array.isArray(opts) && typeof opts === "object" && opts.ports !== undefined) { + ports = opts.ports; + } + + // new Boards(non-Array?) + // new Boards({ ports: non-Array? }) + if (!Array.isArray(ports)) { + throw new Error("Expected ports to be an array"); + } + + if (typeof opts.debug === "undefined") { + opts.debug = true; + } + + if (typeof opts.repl === "undefined") { + opts.repl = true; + } + + var initialized = {}; + var noRepl = ports.some(function(port) { return port.repl === false; }); + var noDebug = ports.some(function(port) { return port.debug === false; }); + + this.length = ports.length; + this.debug = opts.debug; + this.repl = opts.repl; + + // If any of the port definitions have + // explicitly shut off debug output, bubble up + // to the Boards instance + if (noDebug) { + this.debug = false; + } + + // If any of the port definitions have + // explicitly shut off the repl, bubble up + // to the Boards instance + if (noRepl) { + this.repl = false; + } + + var expecteds = ports.map(function(port, index) { + var portOpts; + + if (typeof port === "string") { + portOpts = { + id: port + }; + } else { + portOpts = port; + } + + // Shut off per-board repl instance creation + portOpts.repl = false; + + this[index] = initialized[portOpts.id] = new Board(portOpts); + + // "error" event is not async, register immediately + this[index].on("error", function(error) { + this.emit("error", error); + }.bind(this)); + + return new Promise(function(resolve) { + this[index].on("ready", function() { + resolve(initialized[portOpts.id]); + }); + }.bind(this)); + }, this); + + Promise.all(expecteds).then(function(boards) { + Object.assign(this, boards); + + this.each(function(board) { + board.info("Board ID: ", chalk.green(board.id)); + }); + + // If the Boards instance requires a REPL, + // make sure it's created before calling "ready" + if (this.repl) { + this.repl = new Repl( + Object.assign({}, initialized, { + board: this + }) + ); + this.repl.initialize(this.emit.bind(this, "ready", initialized)); + } else { + // Otherwise, call ready immediately + this.emit("ready", initialized); + } + }.bind(this)); +} + +util.inherits(Boards, Emitter); + +Object.assign(Boards.prototype, Collection.prototype); + +Boards.prototype.log = Board.prototype.log; + +Object.keys(logging.specials).forEach(function(type) { + Boards.prototype[type] = function() { + var args = [].slice.call(arguments); + args.unshift(type); + + this.log.apply(this, args); + }; +}); + + +if (IS_TEST_MODE) { + Board.__spy = { + Serial: Serial + }; + + Board.purge = function() { + Board.Pins.normalize.clear(); + boards.length = 0; + }; +} + + +Board.Array = Boards; + +module.exports = Board; + + +// References: +// http://arduino.cc/en/Main/arduinoBoardUno diff --git a/JavaScript/node_modules/johnny-five/lib/board.options.js b/JavaScript/node_modules/johnny-five/lib/board.options.js new file mode 100644 index 0000000..87554e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/board.options.js @@ -0,0 +1,32 @@ +var _ = require("lodash"); + +/** + * Options + * + * @param {String} arg Pin address. + * @param {Number} arg Pin address. + * @param {Array} arg List of Pin addresses. + * + * @return {Options} normalized board options instance. + */ + +function Options(arg) { + if (!(this instanceof Options)) { + return new Options(arg); + } + + var opts = {}; + + if (typeof arg === "number" || + typeof arg === "string") { + opts.pin = arg; + } else if (Array.isArray(arg)) { + opts.pins = arg; + } else { + opts = arg; + } + + _.assign(this, opts); +} + +module.exports = Options; diff --git a/JavaScript/node_modules/johnny-five/lib/board.pins.js b/JavaScript/node_modules/johnny-five/lib/board.pins.js new file mode 100644 index 0000000..039f1e9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/board.pins.js @@ -0,0 +1,260 @@ +var Options = require("./board.options.js"); + +var MODES = { + INPUT: 0x00, + OUTPUT: 0x01, + ANALOG: 0x02, + PWM: 0x03, + SERVO: 0x04 +}; + + +/** + * Pin Capability Signature Mapping + */ + +var pinsToType = { + 20: "UNO", + 25: "LEONARDO", + 70: "MEGA" +}; + +function Pins(board) { + if (!(this instanceof Pins)) { + return new Pins(board); + } + + var io = board.io; + var pins = io.pins.slice(); + var length = pins.length; + var type = pinsToType[length] || "OTHER"; + + board.type = type; + + // Copy pin data to index + for (var i = 0; i < length; i++) { + this[i] = pins[i]; + } + + Object.defineProperties(this, { + type: { + value: type + }, + length: { + value: length + } + }); +} + +Object.keys(MODES).forEach(function(mode) { + Object.defineProperty(Pins, mode, { + value: MODES[mode] + }); +}); + +function isFirmata(board) { + return board.io.name === "Firmata" || board.io.name === "Mock"; +} + +function hasPins(opts) { + return typeof opts.pin !== "undefined" || + (typeof opts.pins !== "undefined" && opts.pins.length); +} + +Pins.isFirmata = isFirmata; + +Pins.Error = function(opts) { + throw new Error( + "Pin Error: " + opts.pin + + " is not a valid " + opts.type + + " pin (" + opts.via + ")" + ); +}; + +var normalizers = new Map(); + +Pins.normalize = function(opts, board) { + var type = board.pins.type; + var isArduino = isFirmata(board); + var normalizer = normalizers.get(board); + var isNormalizing; + + if (typeof opts === "string" || + typeof opts === "number" || + Array.isArray(opts)) { + + opts = new Options(opts); + } + + if (!normalizer) { + isNormalizing = board.io && typeof board.io.normalize === "function"; + + normalizer = function(pin) { + return isArduino ? + Pins.fromAnalog(Pins.translate(pin, type)) : + (isNormalizing ? board.io.normalize(pin) : pin); + }; + + normalizers.set(board, normalizer); + } + + // Auto-normalize pin values, this reduces boilerplate code + // inside module constructors + if (hasPins(opts)) { + + // When an array of pins is present, attempt to + // normalize them if necessary + if (opts.pins) { + opts.pins = opts.pins.map(normalizer); + } else { + opts.pin = normalizer(opts.pin); + } + } + + return opts; +}; + +Pins.normalize.clear = function() { + normalizers.clear(); +}; + +// Special kit-centric pin translations +Pins.translations = { + UNO: { + dtoa: { + 14: "A0", + 15: "A1", + 16: "A2", + 17: "A3", + 18: "A4", + 19: "A5" + }, + + // TinkerKit + tinker: { + I0: "A0", + I1: "A1", + I2: "A2", + I3: "A3", + I4: "A4", + I5: "A5", + + O0: 11, + O1: 10, + O2: 9, + O3: 6, + O4: 5, + O5: 3, + + D13: 13, + D12: 12, + D8: 8, + D7: 7, + D4: 4, + D2: 2 + } + }, + MEGA: { + dtoa: { + 54: "A0", + 55: "A1", + 56: "A2", + 57: "A3", + 58: "A4", + 59: "A5", + 60: "A6", + 61: "A7", + 62: "A8", + 63: "A9" + }, + + // TinkerKit + tinker: { + I0: "A0", + I1: "A1", + I2: "A2", + I3: "A3", + I4: "A4", + I5: "A5", + I6: "A6", + I7: "A7", + I8: "A8", + I9: "A9", + + O0: 11, + O1: 10, + O2: 9, + O3: 6, + O4: 5, + O5: 3, + + D13: 13, + D12: 12, + D8: 8, + D7: 7, + D4: 4, + D2: 2 + } + } +}; + +Pins.translations.LEONARDO = Pins.translations.UNO; + +Pins.translate = function(pin, type) { + var translations = Pins.translations[type.toUpperCase()]; + + if (!translations) { + return pin; + } + + return Object.keys(translations).reduce(function(pin, map) { + return translations[map][pin] || pin; + }, pin); +}; + +Pins.fromAnalog = function(pin) { + if (typeof pin === "string" && pin[0] === "A") { + return parseInt(pin.slice(1), 10); + } + return pin; +}; + +Pins.identity = function(pins, needle) { + return [].findIndex.call(pins, function(pin) { + return pin.name === needle || pin.id === needle || pin.port === needle; + }); +}; + +/** + * (generated methods) + * + * Pins.prototype.isInput + * Pins.prototype.isOutput + * Pins.prototype.isAnalog + * Pins.prototype.isPwm + * Pins.prototype.isServo + * + */ +Object.keys(MODES).forEach(function(key) { + var name = key[0] + key.slice(1).toLowerCase(); + + Pins.prototype["is" + name] = function(pin) { + var attrs = this[pin] || this[Pins.identity(this, pin)]; + + if (attrs && attrs.supportedModes.includes(MODES[key])) { + return true; + } + return false; + }; +}); + +Pins.prototype.isDigital = function(pin) { + var attrs = this[pin] || this[Pins.identity(this, pin)]; + + if (attrs && attrs.supportedModes.length) { + return true; + } + return false; +}; + +module.exports = Pins; diff --git a/JavaScript/node_modules/johnny-five/lib/button.js b/JavaScript/node_modules/johnny-five/lib/button.js new file mode 100644 index 0000000..4292e5d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/button.js @@ -0,0 +1,244 @@ +var Board = require("../lib/board.js"); +var Pins = Board.Pins; +var __ = require("../lib/fn.js"); +var events = require("events"); +var util = require("util"); + +// Button instance private data +var priv = new Map(), + aliases = { + down: ["down", "press", "tap", "impact", "hit"], + up: ["up", "release"] + }; + + +var Controllers = { + DEFAULT: { + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this); + + if (Pins.isFirmata(this) && typeof opts.pinValue === "string" && opts.pinValue[0] === "A") { + opts.pinValue = this.io.analogPins[+opts.pinValue.slice(1)]; + } + + this.pin = +opts.pinValue; + + this.io.pinMode(this.pin, this.io.MODES.INPUT); + + // Enable the pullup resistor after setting pin mode + if (this.pullup) { + this.io.digitalWrite(this.pin, this.io.HIGH); + } + + this.io.digitalRead(this.pin, function(data) { + if (data !== state.last) { + dataHandler(data); + } + }); + } + }, + toBoolean: { + value: function(raw) { + return raw === this.downValue; + } + } + } +}; + +/** + * Button + * @constructor + * + * five.Button(); + * + * five.Button({ + * pin: 10 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Button(opts) { + if (!(this instanceof Button)) { + return new Button(opts); + } + + var pinValue; + var raw; + var invert = false; + var downValue = 1; + var upValue = 0; + var controller = null; + var state = { + timeout: null, + last: null + }; + + // Create a 5 ms debounce boundary on event triggers + // this avoids button events firing on + // press noise and false positives + var trigger = __.debounce(function(key) { + aliases[key].forEach(function(type) { + this.emit(type, null); + }, this); + }, 7); + + pinValue = typeof opts === "object" ? opts.pin : opts; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + opts.pinValue = pinValue; + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers.DEFAULT; + } + + Object.defineProperties(this, controller); + + // `holdtime` is used by a timeout to determine + // if the button has been released within a specified + // time frame, in milliseconds. + this.holdtime = opts.holdtime || 500; + + // `opts.isPullup` is included as part of an effort to + // phase out "isFoo" options properties + this.pullup = opts.pullup || opts.isPullup || false; + + // Turns out some button circuits will send + // 0 for up and 1 for down, and some the inverse, + // so we can invert our function with this option. + // Default to invert in pullup mode, but use opts.invert + // if explicitly defined (even if false) + invert = typeof opts.invert !== "undefined" ? + opts.invert : (this.pullup || false); + + if (invert) { + downValue = downValue ^ 1; + upValue = upValue ^ 1; + } + + state.last = upValue; + + // Create a "state" entry for privately + // storing the state of the button + priv.set(this, state); + + Object.defineProperties(this, { + value: { + get: function() { + return Number(this.isDown); + } + }, + invert: { + get: function() { + return invert; + }, + set: function(value) { + invert = value; + downValue = invert ? 0 : 1; + upValue = invert ? 1 : 0; + + state.last = upValue; + } + }, + downValue: { + get: function() { + return downValue; + }, + set: function(value) { + downValue = value; + upValue = value ^ 1; + invert = value ? true : false; + + state.last = upValue; + } + }, + upValue: { + get: function() { + return upValue; + }, + set: function(value) { + upValue = value; + downValue = value ^ 1; + invert = value ? true : false; + + state.last = downValue; + } + }, + isDown: { + get: function() { + return this.toBoolean(raw); + } + } + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var err = null; + + // Update the raw data value, which + // is used by isDown = toBoolean() + raw = data; + + if (!this.isDown) { + if (state.timeout) { + clearTimeout(state.timeout); + } + trigger.call(this, "up"); + } + + if (this.isDown) { + trigger.call(this, "down"); + + state.timeout = setTimeout(function() { + if (this.isDown) { + this.emit("hold", err); + } + }.bind(this), this.holdtime); + } + + state.last = data; + }.bind(this)); + } +} + +util.inherits(Button, events.EventEmitter); + + +/** + * Fired when the button is pressed down + * + * @event + * @name down + * @memberOf Button + */ + +/** + * Fired when the button is held + * + * @event + * @name hold + * @memberOf Button + */ + +/** + * Fired when the button is released + * + * @event + * @name up + * @memberOf Button + */ + + +module.exports = Button; diff --git a/JavaScript/node_modules/johnny-five/lib/compass.js b/JavaScript/node_modules/johnny-five/lib/compass.js new file mode 100644 index 0000000..ff28d6b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/compass.js @@ -0,0 +1,601 @@ +var Board = require("../lib/board.js"), + Emitter = require("events").EventEmitter, + util = require("util"), + __ = require("../lib/fn.js"), + int16 = __.int16; + + +var priv = new Map(); + +var Controllers = { + + /** + * HMC5883L: 3-Axis Compass Module + * 0x1E + * + * https://sites.google.com/site/parallaxinretailstores/home/compass-module-3-axis-hmc5883l + * + * http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf + * P. 10,11,12,13 + * + * http://www.memsense.com/docs/MTD-0801_1_0_Calculating_Heading_Elevation_Bank_Angle.pdf + * + * https://www.loveelectronics.co.uk/Tutorials/13/tilt-compensated-compass-arduino-tutorial + * + */ + HMC5883L: { + COMMANDS: { + value: { + // Configuration Register A + CRA: 0x00, + // Configuration Register B + // This may change, depending on gauss + CRB: 0x01, + MEASUREMENTMODE: 0x02, + READREGISTER: 0x03 + } + }, + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this); + var address = 0x1E; + var READLENGTH = 6; + + state.scale = 1; + state.register = 0x40; + + Object.assign(state, new Compass.Scale(opts.gauss || 0.88)); + + this.io.i2cConfig(); + + // Set CRA + this.io.i2cWrite(address, this.COMMANDS.CRA, 0x70); + + // Set CRB + this.io.i2cWrite(address, this.COMMANDS.CRB, state.register); + + // Measurement: Continuous + this.io.i2cWrite(address, this.COMMANDS.MEASUREMENTMODE, 0x00); + + // Initialize continuous read + this.io.i2cRead(address, this.COMMANDS.READREGISTER, READLENGTH, function(bytes) { + dataHandler.call(this, { + x: int16(bytes[0], bytes[1]), + y: int16(bytes[4], bytes[5]), + z: int16(bytes[2], bytes[3]), + }); + }.bind(this)); + } + }, + toScaledHeading: { + value: function(data) { + var x = data.x * data.scale; + var y = data.y * data.scale; + + return ToHeading(x, y); + } + } + }, + + /** + * HMC6352: 2-Axis Compass Module + * 0x42 + * + * http://www.sparkfun.com/datasheets/Components/HMC6352.pdf + * http://bildr.org/2011/01/hmc6352/ + */ + HMC6352: { + COMMANDS: { + value: { + READREGISTER: 0x41 + } + }, + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this); + var address = 0x42 >> 1; // 0x42 >> 1 + var READLENGTH = 2; + + state.scale = 1; + + this.io.i2cConfig(10); + + this.io.i2cWrite(address, this.COMMANDS.READREGISTER); + + // Initialize continuous read + this.io.i2cRead(address, this.COMMANDS.READREGISTER, READLENGTH, function(bytes) { + dataHandler.call(this, { + x: (((bytes[0] << 8) + bytes[1]) / 10) | 0, + y: null, + z: null, + }); + }.bind(this)); + } + }, + toScaledHeading: { + value: function(data) { + return data.x * data.scale; + } + } + }, +}; + + +/** + * Compass + * @constructor + * + * five.Compass(); + * + * five.Compass({ + * controller: "HMC5883L", + * freq: 50, + * }); + * + * + * Device Shorthands: + * + * "HMC5883L": new five.Magnetometer() + * + * + * @param {Object} opts [description] + * + */ + +function Compass(opts) { + + if (!(this instanceof Compass)) { + return new Compass(opts); + } + + var controller = null; + var state = { + x: 0, + y: 0, + z: 0, + scale: 0, + register: 0, + heading: 0 + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller === null || typeof controller !== "object") { + throw new Error("Missing valid Compass controller"); + } + + Object.defineProperties(this, controller); + + if (!this.toScaledHeading) { + this.toScaledHeading = opts.toScaledHeading || function(raw) { return raw; }; + } + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var isChange = false; + + state.x = data.x; + state.y = data.y; + state.z = data.z; + + var heading = this.heading; + + if (heading !== state.heading) { + state.heading = heading; + isChange = true; + } + + this.emit("data", { + heading: state.heading + }); + + if (isChange) { + this.emit("change", { + heading: state.heading + }); + } + }); + } +} + + +util.inherits(Compass, Emitter); + + +Object.defineProperties(Compass.prototype, { + /** + * [read-only] Bearing information + * @name bearing + * @property + * @type Object + * + * + name + abbr + low + mid + high + heading + * + */ + + bearing: { + get: function() { + var length = Compass.Points.length; + var heading = Math.floor(this.heading); + var point; + + for (var i = 0; i < length; i++) { + point = Compass.Points[i]; + + if (point.range.includes(heading)) { + // Specify fields to return to avoid returning the + // range array (too much noisy data) + return { + name: point.point, + abbr: point.abbr, + low: point.low, + mid: point.mid, + high: point.high, + heading: heading + }; + } + } + } + }, + + /** + * [read-only] Heading (azimuth) + * @name heading + * @property + * @type number + */ + heading: { + get: function() { + var state = priv.get(this); + return this.toScaledHeading(state); + } + } +}); + + +function ToHeading(x, y) { + /** + * + * Applications of Magnetoresistive Sensors in Navigation Systems + * by Michael J. Caruso of Honeywell Inc. + * http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf + * + * + * Azimuth (x=0, y<0) = 90.0 (3) + * Azimuth (x=0, y>0) = 270.0 + * Azimuth (x<0) = 180 - [arcTan(y/x)]*180/PI + * Azimuth (x>0, y<0) = - [arcTan(y/x)]*180/PI + * Azimuth (x>0, y>0) = 360 - [arcTan(y/x)]*180/PI + * + * + * + * + * + */ + /** + * + * + * http://bildr.org/2012/02/hmc5883l_arduino/ + * @type {[type]} + * Copyright (C) 2011 Love Electronics (loveelectronics.co.uk) + + This program is free software: you can redistribute it and/or modify it under the terms of the version 3 GNU General Public License as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + + */ + + var heading = Math.atan2(y, x); + + if (heading < 0) { + heading += 2 * Math.PI; + } + + if (heading > 2 * Math.PI) { + heading -= 2 * Math.PI; + } + + return heading * (180 / Math.PI); +} + + +/** + * Compass.scale Set the scale gauss for compass readings + * @param {Number} gauss [description] + * @return {register} [description] + * + * Ported from: + * http://bildr.org/2012/02/hmc5883l_arduino/ + */ + +Compass.Scale = function(gauss) { + + if (gauss === 0.88) { + this.register = 0x00; + this.scale = 0.73; + } else if (gauss === 1.3) { + this.register = 0x01; + this.scale = 0.92; + } else if (gauss === 1.9) { + this.register = 0x02; + this.scale = 1.22; + } else if (gauss === 2.5) { + this.register = 0x03; + this.scale = 1.52; + } else if (gauss === 4.0) { + this.register = 0x04; + this.scale = 2.27; + } else if (gauss === 4.7) { + this.register = 0x05; + this.scale = 2.56; + } else if (gauss === 5.6) { + this.register = 0x06; + this.scale = 3.03; + } else if (gauss === 8.1) { + this.register = 0x07; + this.scale = 4.35; + } else { + this.register = 0x00; + this.scale = 1; + } + + // Setting is in the top 3 bits of the register. + this.register = this.register << 5; +}; + + +/** + * Compass.Points + * + * 32 Point Compass + * +1 for North + * + */ + +Compass.Points = [{ + point: "North", + abbr: "N", + low: 354.38, + mid: 360, + high: 360 +}, { + point: "North", + abbr: "N", + low: 0, + mid: 0, + high: 5.62 +}, { + point: "North by East", + abbr: "NbE", + low: 5.63, + mid: 11.25, + high: 16.87 +}, { + point: "North-NorthEast", + abbr: "NNE", + low: 16.88, + mid: 22.5, + high: 28.12 +}, { + point: "NorthEast by North", + abbr: "NEbN", + low: 28.13, + mid: 33.75, + high: 39.37 +}, { + point: "NorthEast", + abbr: "NE", + low: 39.38, + mid: 45, + high: 50.62 +}, { + point: "NorthEast by East", + abbr: "NEbE", + low: 50.63, + mid: 56.25, + high: 61.87 +}, { + point: "East-NorthEast", + abbr: "ENE", + low: 61.88, + mid: 67.5, + high: 73.12 +}, { + point: "East by North", + abbr: "EbN", + low: 73.13, + mid: 78.75, + high: 84.37 +}, { + point: "East", + abbr: "E", + low: 84.38, + mid: 90, + high: 95.62 +}, { + point: "East by South", + abbr: "EbS", + low: 95.63, + mid: 101.25, + high: 106.87 +}, { + point: "East-SouthEast", + abbr: "ESE", + low: 106.88, + mid: 112.5, + high: 118.12 +}, { + point: "SouthEast by East", + abbr: "SEbE", + low: 118.13, + mid: 123.75, + high: 129.37 +}, { + point: "SouthEast", + abbr: "SE", + low: 129.38, + mid: 135, + high: 140.62 +}, { + point: "SouthEast by South", + abbr: "SEbS", + low: 140.63, + mid: 146.25, + high: 151.87 +}, { + point: "South-SouthEast", + abbr: "SSE", + low: 151.88, + mid: 157.5, + high: 163.12 +}, { + point: "South by East", + abbr: "SbE", + low: 163.13, + mid: 168.75, + high: 174.37 +}, { + point: "South", + abbr: "S", + low: 174.38, + mid: 180, + high: 185.62 +}, { + point: "South by West", + abbr: "SbW", + low: 185.63, + mid: 191.25, + high: 196.87 +}, { + point: "South-SouthWest", + abbr: "SSW", + low: 196.88, + mid: 202.5, + high: 208.12 +}, { + point: "SouthWest by South", + abbr: "SWbS", + low: 208.13, + mid: 213.75, + high: 219.37 +}, { + point: "SouthWest", + abbr: "SW", + low: 219.38, + mid: 225, + high: 230.62 +}, { + point: "SouthWest by West", + abbr: "SWbW", + low: 230.63, + mid: 236.25, + high: 241.87 +}, { + point: "West-SouthWest", + abbr: "WSW", + low: 241.88, + mid: 247.5, + high: 253.12 +}, { + point: "West by South", + abbr: "WbS", + low: 253.13, + mid: 258.75, + high: 264.37 +}, { + point: "West", + abbr: "W", + low: 264.38, + mid: 270, + high: 275.62 +}, { + point: "West by North", + abbr: "WbN", + low: 275.63, + mid: 281.25, + high: 286.87 +}, { + point: "West-NorthWest", + abbr: "WNW", + low: 286.88, + mid: 292.5, + high: 298.12 +}, { + point: "NorthWest by West", + abbr: "NWbW", + low: 298.13, + mid: 303.75, + high: 309.37 +}, { + point: "NorthWest", + abbr: "NW", + low: 309.38, + mid: 315.00, + high: 320.62 +}, { + point: "NorthWest by North", + abbr: "NWbN", + low: 320.63, + mid: 326.25, + high: 331.87 +}, { + point: "North-NorthWest", + abbr: "NNW", + low: 331.88, + mid: 337.5, + high: 343.12 +}, { + point: "North by West", + abbr: "NbW", + low: 343.13, + mid: 348.75, + high: 354.37 +}]; + +// Add ranges to each compass point record +Compass.Points.forEach(function(point, k) { + this[k].range = __.range(Math.floor(point.low), Math.floor(point.high)); +}, Compass.Points); + + + +/** + * Fires once every N ms, equal to value of `freq`. Defaults to 66ms + * + * @event + * @name read + * @memberOf Compass + */ + + +/** + * Fires when the calculated heading has changed + * + * @event + * @name headingchange + * @memberOf Compass + */ + + +module.exports = Compass; + + +// http://en.wikipedia.org/wiki/Relative_direction diff --git a/JavaScript/node_modules/johnny-five/lib/definitions/mpr121.js b/JavaScript/node_modules/johnny-five/lib/definitions/mpr121.js new file mode 100644 index 0000000..b89e182 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/definitions/mpr121.js @@ -0,0 +1,217 @@ +// MPR121* Register Defines +module.exports = { + MAPS: { + MPR121QR2: { + KEYS: { + 0: 1, + 1: 2, + 2: 3, + 3: 4, + 4: 5, + 5: 6, + 6: 7, + 7: 8, + 8: 9, + }, + TARGETS: { + 256: 0, + 32: 1, + 4: 2, + 128: 3, + 16: 4, + 2: 5, + 64: 6, + 8: 7, + 1: 8, + } + }, + // MPR121: { + // 3: 1, + // 7: 2, + // 11: 3, + // 2: 4, + // 6: 5, + // 10: 6, + // 1: 7, + // 5: 8, + // 9: 9, + // 0: 10, + // 4: 11, + // 8: 12, + // }, + MPR121: { + KEYS: { + 0: 1, + 1: 2, + 2: 3, + 3: 4, + 4: 5, + 5: 6, + 6: 7, + 7: 8, + 8: 9, + 9: 10, + 10: 11, + 11: 12, + }, + TARGETS: { + 8: 0, + 128: 1, + 2048: 2, + 4: 3, + 64: 4, + 1024 : 5, + 2: 6, + 32: 7, + 512: 8, + 1: 9, + 16: 10, + 256: 11, + } + }, + }, + MPR121_DEFAULT_ADDRESS: 0x5A, + + // MPR121 Registers (from data sheet) + ELE0_ELE7_TOUCH_STATUS: 0x00, + ELE8_ELE11_ELEPROX_TOUCH_STATUS: 0x01, + + ELE0_7_OOR_STATUS: 0x02, + ELE8_11_ELEPROX_OOR_STATUS: 0x03, + + ELE0_FILTERED_DATA_LSB: 0x04, + ELE0_FILTERED_DATA_MSB: 0x05, + ELE1_FILTERED_DATA_LSB: 0x06, + ELE1_FILTERED_DATA_MSB: 0x07, + ELE2_FILTERED_DATA_LSB: 0x08, + ELE2_FILTERED_DATA_MSB: 0x09, + ELE3_FILTERED_DATA_LSB: 0x0A, + ELE3_FILTERED_DATA_MSB: 0x0B, + ELE4_FILTERED_DATA_LSB: 0x0C, + ELE4_FILTERED_DATA_MSB: 0x0D, + ELE5_FILTERED_DATA_LSB: 0x0E, + ELE5_FILTERED_DATA_MSB: 0x0F, + ELE6_FILTERED_DATA_LSB: 0x10, + ELE6_FILTERED_DATA_MSB: 0x11, + ELE7_FILTERED_DATA_LSB: 0x12, + ELE7_FILTERED_DATA_MSB: 0x13, + ELE8_FILTERED_DATA_LSB: 0x14, + ELE8_FILTERED_DATA_MSB: 0x15, + ELE9_FILTERED_DATA_LSB: 0x16, + ELE9_FILTERED_DATA_MSB: 0x17, + ELE10_FILTERED_DATA_LSB: 0x18, + ELE10_FILTERED_DATA_MSB: 0x19, + ELE11_FILTERED_DATA_LSB: 0x1A, + ELE11_FILTERED_DATA_MSB: 0x1B, + ELEPROX_FILTERED_DATA_LSB: 0x1C, + ELEPROX_FILTERED_DATA_MSB: 0x1D, + + ELE0_BASELINE_VALUE: 0x1E, + ELE1_BASELINE_VALUE: 0x1F, + ELE2_BASELINE_VALUE: 0x20, + ELE3_BASELINE_VALUE: 0x21, + ELE4_BASELINE_VALUE: 0x22, + ELE5_BASELINE_VALUE: 0x23, + ELE6_BASELINE_VALUE: 0x24, + ELE7_BASELINE_VALUE: 0x25, + ELE8_BASELINE_VALUE: 0x26, + ELE9_BASELINE_VALUE: 0x27, + ELE10_BASELINE_VALUE: 0x28, + ELE11_BASELINE_VALUE: 0x29, + ELEPROX_BASELINE_VALUE: 0x2A, + + MHD_RISING: 0x2B, + NHD_AMOUNT_RISING: 0x2C, + NCL_RISING: 0x2D, + FDL_RISING: 0x2E, + MHD_FALLING: 0x2F, + NHD_AMOUNT_FALLING: 0x30, + NCL_FALLING: 0x31, + FDL_FALLING: 0x32, + NHD_AMOUNT_TOUCHED: 0x33, + NCL_TOUCHED: 0x34, + FDL_TOUCHED: 0x35, + ELEPROX_MHD_RISING: 0x36, + ELEPROX_NHD_AMOUNT_RISING: 0x37, + ELEPROX_NCL_RISING: 0x38, + ELEPROX_FDL_RISING: 0x39, + ELEPROX_MHD_FALLING: 0x3A, + ELEPROX_NHD_AMOUNT_FALLING: 0x3B, + ELEPROX_FDL_FALLING: 0x3C, + ELEPROX_NHD_AMOUNT_TOUCHED: 0x3E, + ELEPROX_NCL_TOUCHED: 0x3F, + ELEPROX_FDL_TOUCHED: 0x40, + + ELE0_TOUCH_THRESHOLD: 0x41, + ELE0_RELEASE_THRESHOLD: 0x42, + ELE1_TOUCH_THRESHOLD: 0x43, + ELE1_RELEASE_THRESHOLD: 0x44, + ELE2_TOUCH_THRESHOLD: 0x45, + ELE2_RELEASE_THRESHOLD: 0x46, + ELE3_TOUCH_THRESHOLD: 0x47, + ELE3_RELEASE_THRESHOLD: 0x48, + ELE4_TOUCH_THRESHOLD: 0x49, + ELE4_RELEASE_THRESHOLD: 0x4A, + ELE5_TOUCH_THRESHOLD: 0x4B, + ELE5_RELEASE_THRESHOLD: 0x4C, + ELE6_TOUCH_THRESHOLD: 0x4D, + ELE6_RELEASE_THRESHOLD: 0x4E, + ELE7_TOUCH_THRESHOLD: 0x4F, + ELE7_RELEASE_THRESHOLD: 0x50, + ELE8_TOUCH_THRESHOLD: 0x51, + ELE8_RELEASE_THRESHOLD: 0x52, + ELE9_TOUCH_THRESHOLD: 0x53, + ELE9_RELEASE_THRESHOLD: 0x54, + ELE10_TOUCH_THRESHOLD: 0x55, + ELE10_RELEASE_THRESHOLD: 0x56, + ELE11_TOUCH_THRESHOLD: 0x57, + ELE11_RELEASE_THRESHOLD: 0x58, + ELEPROX_TOUCH_THRESHOLD: 0x59, + ELEPROX_RELEASE_THRESHOLD: 0x5A, + DEBOUNCE_TOUCH_AND_RELEASE: 0x5B, + AFE_CONFIGURATION: 0x5C, + + FILTER_CONFIG: 0x5D, + ELECTRODE_CONFIG: 0x5E, + ELE0_CURRENT: 0x5F, + ELE1_CURRENT: 0x60, + ELE2_CURRENT: 0x61, + ELE3_CURRENT: 0x62, + ELE4_CURRENT: 0x63, + ELE5_CURRENT: 0x64, + ELE6_CURRENT: 0x65, + ELE7_CURRENT: 0x66, + ELE8_CURRENT: 0x67, + ELE9_CURRENT: 0x68, + ELE10_CURRENT: 0x69, + ELE11_CURRENT: 0x6A, + ELEPROX_CURRENT: 0x6B, + + ELE0_ELE1_CHARGE_TIME: 0x6C, + ELE2_ELE3_CHARGE_TIME: 0x6D, + ELE4_ELE5_CHARGE_TIME: 0x6E, + ELE6_ELE7_CHARGE_TIME: 0x6F, + ELE8_ELE9_CHARGE_TIME: 0x70, + ELE10_ELE11_CHARGE_TIME: 0x71, + ELEPROX_CHARGE_TIME: 0x72, + + GPIO_CONTROL_0: 0x73, + GPIO_CONTROL_1: 0x74, + GPIO_DATA: 0x75, + GPIO_DIRECTION: 0x76, + GPIO_ENABLE: 0x77, + GPIO_SET: 0x78, + GPIO_CLEAR: 0x79, + GPIO_TOGGLE: 0x7A, + AUTO_CONFIG_CONTROL_0: 0x7B, + AUTO_CONFIG_CONTROL_1: 0x7C, + AUTO_CONFIG_USL: 0x7D, + AUTO_CONFIG_LSL: 0x7E, + AUTO_CONFIG_TARGET_LEVEL: 0x7F, + + // Other Constants + // these are suggested values from app note 3944 + TOUCH_THRESHOLD: 0x0F, + RELEASE_THRESHOLD: 0x0A, + NUM_CHANNELS: 12 +}; diff --git a/JavaScript/node_modules/johnny-five/lib/distance.js b/JavaScript/node_modules/johnny-five/lib/distance.js new file mode 100644 index 0000000..ebd6ea9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/distance.js @@ -0,0 +1,176 @@ +var Sensor = require("../lib/sensor.js"), + util = require("util"); + + +// References +// - http://www.acroname.com/articles/linearizing-sharp-ranger.html +// - http://luckylarry.co.uk/arduino-projects/arduino-using-a-sharp-ir-sensor-for-distance-calculation/ +// - http://forum.arduino.cc/index.php?topic=63433.0 +// - https://github.com/pjwerneck/Diaspar/blob/master/robots/sensors/sharp_table.py +// +// +var Controllers = { + GP2Y0A21YK: { + // https://www.sparkfun.com/products/242 + initialize: { + value: function(opts) { + Sensor.call(this, opts); + } + }, + toCm: { + value: function(raw) { + return +(12343.85 * Math.pow(raw, -1.15)).toFixed(2); + } + } + }, + GP2D120XJ00F: { + // https://www.sparkfun.com/products/8959 + initialize: { + value: function(opts) { + Sensor.call(this, opts); + } + }, + toCm: { + value: function(raw) { + return +((2914 / (raw + 5)) - 1).toFixed(2); + } + } + }, + GP2Y0A02YK0F: { + // https://www.sparkfun.com/products/8958 + // 15cm - 150cm + initialize: { + value: function(opts) { + Sensor.call(this, opts); + } + }, + toCm: { + value: function(raw) { + return +(10650.08 * Math.pow(raw, -0.935) - 10).toFixed(2); + } + } + }, + GP2Y0A41SK0F: { + // https://www.sparkfun.com/products/12728 + // 4cm - 30cm + initialize: { + value: function(opts) { + Sensor.call(this, opts); + } + }, + toCm: { + value: function(raw) { + return +(2076 / (raw - 11)).toFixed(2); + } + } + } +}; + +// Otherwise known as... +Controllers["2Y0A21"] = Controllers.GP2Y0A21YK; +Controllers["2D120X"] = Controllers.GP2D120XJ00F; +Controllers["2Y0A02"] = Controllers.GP2Y0A02YK0F; +Controllers["OA41SK"] = Controllers.GP2Y0A41SK0F; + +// As shown here: http://www.acroname.com/articles/sharp.html +Controllers["0A21"] = Controllers.GP2Y0A21YK; +Controllers["0A02"] = Controllers.GP2Y0A02YK0F; + +/** + * IR.Distance + * + * @deprecated + * @constructor + * + * five.IR.Distance("A0"); + * + * five.IR.Distance({ + * device: "GP2Y0A41SK0F", + * pin: "A0", + * freq: 100 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Distance(opts) { + + if (!(this instanceof Distance)) { + return new Distance(opts); + } + + var controller = null; + + if (typeof opts.controller === "string") { + controller = Controllers[opts.controller]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["GP2Y0A21YK"]; + } + + Object.defineProperties(this, controller); + + if (!this.toCm) { + this.toCm = opts.toCm || function(x) { + return x; + }; + } + + Object.defineProperties(this, { + /** + * [read-only] Calculated centimeter value + * @property centimeters + * @type Number + */ + centimeters: { + get: function() { + return this.toCm(this.value); + } + }, + cm: { + get: function() { + return this.centimeters; + } + }, + /** + * [read-only] Calculated inch value + * @property inches + * @type Number + */ + inches: { + get: function() { + return +(this.centimeters * 0.39).toFixed(2); + } + }, + in : { + get: function() { + return this.inches; + } + }, + }); + + if (typeof this.initialize === "function") { + this.initialize(opts); + } +} + +Distance.Controllers = [ + "2Y0A21", "GP2Y0A21YK", + "2D120X", "GP2D120XJ00F", + "2Y0A02", "GP2Y0A02YK0F", + "OA41SK", "GP2Y0A41SK0F", + "0A21", "GP2Y0A21YK", + "0A02", "GP2Y0A02YK0F", +]; + +util.inherits(Distance, Sensor); + +module.exports = Distance; + + +// http://www.acroname.com/robotics/info/articles/sharp/sharp.html diff --git a/JavaScript/node_modules/johnny-five/lib/encoder.js b/JavaScript/node_modules/johnny-five/lib/encoder.js new file mode 100644 index 0000000..dfb6f41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/encoder.js @@ -0,0 +1,370 @@ +var Board = require("../lib/board"); +// var EVS = require("../lib/evshield"); +var Emitter = require("events").EventEmitter; +var util = require("util"); +// var __ = require("../lib/fn"); +var priv = new Map(); + +var bytes = ["a", "b"]; + +var Controllers = { + // This is a placeholder... + DEFAULT: { + initialize: { + value: function(opts, dataHandler) { + var pins = opts.pins || []; + var readBytes = { a: 0, b: 0 }; + var lastBytes = { a: 0, b: 0 }; + var reading = 0; + var value = 0; + var lowest = 1; + var highest = opts.positions; + var step = 1; + + pins.forEach(function(pin, index) { + this.io.pinMode(pin, this.io.MODES.INPUT); + this.io.digitalWrite(pin, this.io.HIGH); + + this.io.digitalRead(pin, function(data) { + var byte = bytes[index]; + + readBytes[byte] = data; + + if (index === reading) { + reading++; + } + + if (reading === 2) { + reading = 0; + decode(); + } + }.bind(this)); + }, this); + + function decode() { + // A has gone from low to high. + if (readBytes.a && !lastBytes.a) { + if (!readBytes.b) { + value = value + step; + } else { + value = value - step; + } + + if (value > highest) { + value = value - highest; + } + + if (value < lowest) { + value = value + highest; + } + + dataHandler(value); + } + + lastBytes.a = readBytes.a; + lastBytes.b = readBytes.b; + + readBytes.a = 0; + readBytes.b = 0; + } + } + }, + toPosition: { + value: function(raw) { + return raw; + } + } + }, + // EVS_EV3: { + // initialize: { + // value: function(opts, dataHandler) { + // var state = priv.get(this); + + // if (opts.mode) { + // opts.mode = opts.mode.toUpperCase(); + // } + + // state.mode = opts.mode === "RAW" ? EVS.Type_EV3_COLOR_RGBRAW : EVS.Type_EV3_COLOR; + // state.bytes = state.mode === EVS.Type_EV3_COLOR_RGBRAW ? 6 : 2; + + // // Do not change the order of these items. They are listed such that the + // // index corresponds to the color code produced by the EV3 color sensor. + // // The range is very limited. + // state.colors = [ + // [], + // [0, 0, 0], + // [0, 0, 255], + // [0, 128, 0], + // [255, 255, 0], + // [255, 0, 0], + // [255, 255, 255], + // [139, 69, 19], + // ]; + + // state.shield = EVS.shieldPort(opts.pin); + // state.ev3 = new EVS(Object.assign(opts, { io: this.io })); + + // state.ev3.setup(state.shield, EVS.Type_EV3); + // state.ev3.write(state.shield, 0x81 + state.shield.offset, state.mode); + // state.ev3.read(state.shield, EVS.EncoderMeasure, state.bytes, function(data) { + // var value = ""; + // if (state.bytes === 2) { + // value += String((data[0] | (data[1] << 8)) || 1); + // } else { + // for (var i = 0; i < 3; i++) { + // value += pad(data[i * 2].toString(16), 2); + // } + // } + // dataHandler(value); + // }); + // } + // }, + // toRGB: { + // value: function(raw) { + // var state = priv.get(this); + // var rgb; + + // if (state.mode === EVS.Type_EV3_COLOR) { + // return raw > 0 && raw < 8 ? state.colors[raw] : state.colors[0]; + // } else { + // raw = String(raw); + // return [0, 0, 0].map(function(zero, index) { + // return parseInt(raw.slice(index * 2, index * 2 + 2), 16); + // }); + // } + // } + // } + // }, + // EVS_NXT: { + // initialize: { + // value: function(opts, dataHandler) { + // var state = priv.get(this); + + // if (opts.mode) { + // opts.mode = opts.mode.toUpperCase(); + // } + + // state.mode = opts.mode === "RAW" ? EVS.Type_NXT_COLOR_RGBRAW : EVS.Type_NXT_COLOR; + // state.bytes = state.mode === EVS.Type_NXT_COLOR_RGBRAW ? 10 : 1; + + // if (state.mode === EVS.Type_NXT_COLOR_RGBRAW) { + // throw new Error("Raw RGB is not currently supported for the NXT.") + // } + + // // Do not change the order of these items. They are listed such that the + // // index corresponds to the color code produced by the EV3 color sensor. + // // The range is very limited. + // state.colors = [ + // [], + // [0, 0, 0], + // [0, 0, 255], + // [0, 128, 0], + // [255, 255, 0], + // [255, 0, 0], + // [255, 255, 255], + // ]; + + // state.shield = EVS.shieldPort(opts.pin); + // state.ev3 = new EVS(Object.assign(opts, { io: this.io })); + // state.ev3.setup(state.shield, EVS.Type_NXT_COLOR); + // state.ev3.read(state.shield, 0x70 + state.shield.offset, state.bytes, function(data) { + // var value = ""; + + // if (state.bytes === 1) { + // value += String(data[0]); + // } else { + + // // One day I'll figure this out :| + // // There is a lot of documentation that + // // claims this is possible, but I couldn't + // // figure out how to make sense of the + // // data that's returned. + // // + // // http://www.mathworks.com/help/supportpkg/legomindstormsnxt/ref/legomindstormsnxtcolorsensor.html#zmw57dd0e700 + // // https://msdn.microsoft.com/en-us/library/ff631052.aspx + // // http://www.lejos.org/nxt/nxj/api/lejos/nxt/EncoderSensor.html + // // http://www.robotc.net/forums/viewtopic.php?f=52&t=6939 + // // http://code.metager.de/source/xref/lejos/classes/src/lejos/nxt/SensorPort.java#calData + // // http://code.metager.de/source/xref/lejos/classes/src/lejos/nxt/SensorPort.java#SP_MODE_INPUT + // // http://code.metager.de/source/xref/lejos/classes/src/lejos/nxt/SensorPort.java#416 + // } + + // // if (data[4] !== 0) { + // dataHandler(value); + // // } + // }); + // } + // }, + // toRGB: { + // value: function(raw) { + // var state = priv.get(this); + // var rgb; + + // if (state.mode === EVS.Type_NXT_COLOR) { + // return raw > 0 && raw < 7 ? state.colors[raw] : state.colors[0]; + // } else { + // raw = String(raw); + // return [0, 0, 0].map(function(zero, index) { + // return parseInt(raw.slice(index * 2, index * 2 + 2), 16); + // }); + // } + // } + // } + // }, + // ISL29125: { + // // http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29125.pdf + // REGISTER: { + // value: { + // RESET: 0x00, + // // mode/lux range + // CONFIG1: 0x01, + // // ir adjust/filtering + // CONFIG2: 0x02, + // // interrupt control + // CONFIG3: 0x03, + // // Same as "GREEN DATA - LOW BYTE" + // READ: 0x09 + // } + // }, + // initialize: { + // value: function(opts, dataHandler) { + // var state = priv.get(this); + + // // Cannot change address, so all values const/closed. + // var address = 0x44; + + // // TODO: make configs user "definable" + + // this.io.i2cConfig(); + + // // Reset chip + // this.io.i2cWriteReg(address, this.REGISTER.RESET, 0x46); + + // // RGB | 10K Lux | 12bits + // this.io.i2cWriteReg(address, this.REGISTER.CONFIG1, 0x05 | 0x08 | 0x00); + + // // High adjust + // this.io.i2cWriteReg(address, this.REGISTER.CONFIG2, 0x3F); + + // // No Interrupts + // this.io.i2cWriteReg(address, this.REGISTER.CONFIG3, 0x00); + + // this.io.i2cRead(address, this.REGISTER.READ, 6, function(data) { + // var value = ""; + + // // Register order: GLSB, GMSB, RLSB, RMSB, BLSB, BMSB + // var g = (data[1] << 8) | data[0]; + // var r = (data[3] << 8) | data[2]; + // var b = (data[5] << 8) | data[4]; + + // var rgb = [r >> 2, g >> 2, b >> 2].map(function(value) { + // return __.constrain(value, 0, 255) + // }); + + // for (var i = 0; i < 3; i++) { + // value += pad(rgb[i].toString(16), 2); + // } + + // dataHandler(value); + // }); + // } + // }, + // toRGB: { + // value: function(raw) { + // raw = String(raw); + // return [0, 0, 0].map(function(zero, index) { + // return parseInt(raw.slice(index * 2, index * 2 + 2), 16); + // }); + // } + // } + // }, +}; + + + +/** + * Encoder + * @constructor + * + */ + +function Encoder(opts) { + + if (!(this instanceof Encoder)) { + return new Encoder(opts); + } + + var controller = null; + var state = {}; + var freq = opts.freq || 25; + var raw = 0; + var last = null; + + // var trigger = __.debounce(function(type, data) { + // this.emit(type, data); + // }, 7); + + Board.Device.call( + this, opts = Board.Options(opts) + ); + + if (typeof opts.controller === "string") { + controller = Controllers[opts.controller]; + } else { + controller = opts.controller || Controllers.DEFAULT; + } + + Object.defineProperties(this, controller); + + if (!this.toRGB) { + this.toRGB = opts.toRGB || function(x) { + return x; + }; + } + + priv.set(this, state); + + Object.defineProperties(this, { + value: { + get: function() { + return raw; + } + }, + position: { + get: function() { + return this.toPosition(raw); + } + } + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + raw = data; + }); + } + + setInterval(function() { + if (raw === undefined) { + return; + } + + var data = { + position: this.position, + }; + + this.emit("data", data); + + if (raw !== last) { + last = raw; + // trigger.call(this, "change", data); + this.emit("change", data); + } + }.bind(this), freq); +} + +util.inherits(Encoder, Emitter); + + + + +module.exports = Encoder; diff --git a/JavaScript/node_modules/johnny-five/lib/esc.js b/JavaScript/node_modules/johnny-five/lib/esc.js new file mode 100644 index 0000000..582faa2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/esc.js @@ -0,0 +1,502 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../lib/board"); +var Pins = Board.Pins; +var Emitter = require("events").EventEmitter; +var util = require("util"); +var Collection = require("../lib/mixins/collection"); +var __ = require("./fn"); +var nanosleep = require("./sleep").nano; + +var priv = new Map(); + + +var Controllers = { + PCA9685: { + COMMANDS: { + value: { + PCA9685_MODE1: 0x0, + PCA9685_PRESCALE: 0xFE, + LED0_ON_L: 0x6 + } + }, + initialize: { + value: function(opts) { + this.address = opts.address || 0x40; + this.pwmRange = opts.pwmRange || [544, 2400]; + + if (!this.board.Drivers[this.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.address] = { + initialized: false + }; + + // Reset + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x00); + // Sleep + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x10); + // Set prescalar + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_PRESCALE, 0x70); + // Wake up + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x00); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0xa1); + + this.board.Drivers[this.address].initialized = true; + } + } + }, + write: { + writable: true, + value: function(pin, degrees) { + var on = 0; + var off = __.map(degrees, 0, 180, this.pwmRange[0] / 4, this.pwmRange[1] / 4); + + this.io.i2cWrite(this.address, [this.COMMANDS.LED0_ON_L + 4 * pin, on, on >> 8, off, off >> 8]); + } + } + }, + DEFAULT: { + initialize: { + value: function(opts) { + + // When in debug mode, if pin is not a PWM pin, emit an error + if (opts.debug && !this.board.pins.isServo(this.pin)) { + Board.Pins.Error({ + pin: this.pin, + type: "PWM", + via: "Servo", + }); + } + + this.io.servoConfig(this.pin, this.pwmRange[0], this.pwmRange[1]); + } + }, + write: { + writable: true, + value: function(pin, degrees) { + this.io.servoWrite(pin, degrees); + } + } + } +}; + +var Devices = { + FORWARD: { + deviceName: { + get: function() { + return "FORWARD"; + } + }, + dir: { + value: function(speed, dir) { + if (dir.name === "forward") { + return this.speed(speed); + } + } + } + }, + FORWARD_REVERSE: { + deviceName: { + get: function() { + return "FORWARD_REVERSE"; + } + }, + dir: { + value: function(speed, dir) { + if (dir.name === "forward") { + return this.speed(__.fscale(speed, 0, 100, this.neutral, this.range[1])); + } else { + return this.speed(__.fscale(speed, 0, 100, this.neutral, this.range[0])); + } + } + } + }, + FORWARD_BRAKE_REVERSE: { + deviceName: { + get: function() { + return "FORWARD_BRAKE_REVERSE"; + } + }, + dir: { + value: function(speed, dir) { + + /* + As far as I can tell, this isn't possible. + + To enable reverse, the brakes must first be applied, + but it's not nearly as simple as it sounds since there + appears to be a timing factor that differs across + speed controllers. + */ + + if (dir.name === "forward") { + this.speed(__.fscale(speed, 0, 100, this.neutral, this.range[1])); + } else { + this.speed(__.fscale(speed, 0, 100, this.neutral, this.range[0])); + } + } + } + } +}; + +/** + * ESC + * @constructor + * + * @param {Object} opts Options: pin, range + * @param {Number} pin Pin number + */ + +function ESC(opts) { + if (!(this instanceof ESC)) { + return new ESC(opts); + } + + var pinValue; + var device; + var controller; + var state = { + // All speed history for this ESC + // history = [ + // { + // timestamp: Date.now(), + // speed: speed + // } + // ]; + history: [], + value: 0 + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + priv.set(this, state); + + this.id = opts.id || Board.uid(); + this.startAt = typeof opts.startAt !== "undefined" ? opts.startAt : null; + this.neutral = opts.neutral; + this.range = opts.range || [0, 100]; + this.pwmRange = opts.pwmRange || [544, 2400]; + this.interval = null; + + // StandardFirmata on Arduino allows controlling + // servos from analog pins. + // If we're currently operating with an Arduino + // and the user has provided an analog pin name + // (eg. "A0", "A5" etc.), parse out the numeric + // value and capture the fully qualified analog + // pin number. + if (typeof opts.controller === "undefined" && Pins.isFirmata(this)) { + if (typeof pinValue === "string" && pinValue[0] === "A") { + pinValue = this.io.analogPins[+pinValue.slice(1)]; + } + + pinValue = +pinValue; + + // If the board's default pin normalization + // came up with something different, use the + // the local value. + if (!Number.isNaN(pinValue) && this.pin !== pinValue) { + this.pin = pinValue; + } + } + + // Allow users to pass in custom device types + device = typeof opts.device === "string" ? + Devices[opts.device] : opts.device; + + if (!device) { + device = Devices.FORWARD; + } + + /** + * Used for adding special controllers (i.e. PCA9685) + **/ + controller = typeof opts.controller === "string" ? + Controllers[opts.controller] : opts.controller; + + if (!controller) { + controller = Controllers.DEFAULT; + } + + Object.defineProperties(this, Object.assign({}, device, controller, { + value: { + get: function() { + return state.value; + } + }, + history: { + get: function() { + return state.history.slice(-5); + } + }, + last: { + get: function() { + return state.history[state.history.length - 1] || { last: null }; + } + } + })); + + this.initialize(opts); + + if (this.deviceName !== "FORWARD") { + if (Number.isNaN(+this.neutral)) { + throw new Error("Directional speed controllers require a neutral point from 0-100 (number)"); + } + + this.startAt = this.neutral; + } + + // Match either null or undefined, but not 0 + if (this.startAt !== null && this.startAt !== undefined) { + this.speed(this.startAt); + } +} + +util.inherits(ESC, Emitter); + +/** + * speed + * + * Set the ESC's speed + * + * @param {Float} speed 0...100 (full range) + * + * @return {ESC} instance + */ + +ESC.prototype.speed = function(speed) { + var state = priv.get(this); + var history = state.history; + var noInterval = false; + var steps = 0; + var lspeed, hspeed; + + speed = __.constrain(speed, this.range[0], this.range[1]); + + if (this.interval) { + // Bail out if speed is the same as whatever was + // last _provided_ + if (this.value === speed) { + return this; + } else { + clearInterval(this.interval); + this.interval = null; + } + } + + state.value = speed; + + // This is the very first speed command being received. + // Safe to assume that the ESC and Brushless motor are + // not yet moving. + if (history.length === 0) { + noInterval = true; + } + + // Bail out if speed is the same as whatever was + // last _written_ + + if (this.last.speed === speed) { + return this; + } + + lspeed = this.last.speed; + hspeed = speed; + steps = Math.ceil(Math.abs(lspeed - hspeed)); + + if (!steps || steps === 1) { + noInterval = true; + } + + if (noInterval) { + this.write(this.pin, __.fscale(speed, 0, 100, 0, 180)); + + history.push({ + timestamp: Date.now(), + speed: speed + }); + return this; + } + + var throttle = lspeed; + + this.interval = setInterval(function() { + + if (hspeed > throttle) { + throttle++; + } else { + throttle--; + } + + this.write(this.pin, (throttle * 180 / 100)); + + history.push({ + timestamp: Date.now(), + speed: throttle + }); + + if (steps) { + steps--; + + if (!steps) { + clearInterval(this.interval); + this.interval = null; + } + } + }.bind(this), 1); + + return this; +}; + + +/** + * brake Stop the ESC by hitting the brakes ;) + * @return {Object} instance + */ +ESC.prototype.brake = function() { + var state = priv.get(this); + var speed = this.neutral || 0; + + this.speed(speed); + + state.history.push({ + timestamp: Date.now(), + speed: speed + }); + + return this; +}; + +[ + /** + * forward Set forward speed + * fwd Set forward speed + * + * @param {Number} 0-100, 0 is stopped, 100 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + value: 1 + }, + /** + * reverse Set revese speed + * rev Set revese speed + * + * @param {Number} 0-100, 0 is stopped, 100 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + value: 0 + } +].forEach(function(dir) { + var method = function(speed) { + this.dir(speed, dir); + return this; + }; + + ESC.prototype[dir.name] = ESC.prototype[dir.abbr] = method; +}); + + +/** + * stop Stop the ESC + * @return {Object} instance + */ +ESC.prototype.stop = function() { + var state = priv.get(this); + var history = state.history; + var speed = this.type === "bidirectional" ? this.neutral : 0; + + this.write(this.pin, __.fscale(speed, 0, 100, 0, 180)); + + history.push({ + timestamp: Date.now(), + speed: speed + }); + + return this; +}; + +/** + * ESC.Array() + * new ESC.Array() + * + * Constructs an Array-like instance of all escs + */ +function ESCs(numsOrObjects) { + if (!(this instanceof ESCs)) { + return new ESCs(numsOrObjects); + } + + Object.defineProperty(this, "type", { + value: ESC + }); + + Collection.call(this, numsOrObjects); +} + +ESCs.prototype = Object.create(Collection.prototype, { + constructor: { + value: ESCs + } +}); + +/** + * + * ESCs, speed(0-100%) + * + * set all escs to the specified speed from 0-100% + * + * eg. array.min(); + + * ESCs, min() + * + * set all escs to the minimum throttle + * + * eg. array.min(); + + * ESCs, max() + * + * set all escs to the maximum throttle + * + * eg. array.max(); + + * ESCs, stop() + * + * stop all escs + * + * eg. array.stop(); + */ + +Object.keys(ESC.prototype).forEach(function(method) { + // Create ESCs wrappers for each method listed. + // This will allow us control over all ESC instances + // simultaneously. + ESCs.prototype[method] = function() { + var length = this.length; + + for (var i = 0; i < length; i++) { + this[i][method].apply(this[i], arguments); + } + return this; + }; +}); + +if (IS_TEST_MODE) { + ESC.purge = function() { + priv.clear(); + }; +} + +// Assign ESCs Collection class as static "method" of ESC. +ESC.Array = ESCs; + +module.exports = ESC; diff --git a/JavaScript/node_modules/johnny-five/lib/expander.js b/JavaScript/node_modules/johnny-five/lib/expander.js new file mode 100644 index 0000000..325fd35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/expander.js @@ -0,0 +1,901 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../lib/board"); +var Emitter = require("events").EventEmitter; +var util = require("util"); +var nanosleep = require("../lib/sleep").nano; +var __ = require("../lib/fn"); +var priv = new Map(); +var used = new Map(); + +function Base() { + Emitter.call(this); + + this.HIGH = 1; + this.LOW = 0; + this.isReady = false; + + this.MODES = {}; + this.pins = []; + this.analogPins = []; +} + +util.inherits(Base, Emitter); + +var Controllers = { + // http://www.adafruit.com/datasheets/mcp23017.pdf + MCP23017: { + REGISTER: { + value: { + ADDRESS: 0x20, + // IO A + IODIRA: 0x00, + GPPUA: 0x0C, + GPIOA: 0x12, + OLATA: 0x14, + // IO B + IODIRB: 0x01, + GPPUB: 0x0D, + GPIOB: 0x13, + OLATB: 0x15, + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.iodir = [ 0xff, 0xff ]; + state.olat = [ 0xff, 0xff ]; + state.gpio = [ 0xff, 0xff ]; + state.gppu = [ 0x00, 0x00 ]; + + this.address = opts.address || this.REGISTER.ADDRESS; + + this.io.i2cConfig(); + this.io.i2cWrite(this.address, [ this.REGISTER.IODIRA, state.iodir[this.REGISTER.IODIRA] ]); + this.io.i2cWrite(this.address, [ this.REGISTER.IODIRB, state.iodir[this.REGISTER.IODIRB] ]); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 16; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.INPUT, + this.MODES.OUTPUT + ], + mode: 0, + value: 0, + report: 0, + analogChannel: 127 + }); + + this.pinMode(i, this.MODES.OUTPUT); + this.digitalWrite(i, this.LOW); + } + + this.name = "MCP23017"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + return pin; + } + }, + // 1.6.1 I/O DIRECTION REGISTER + pinMode: { + value: function(pin, mode) { + var state = priv.get(this); + var pinIndex = pin; + var port = 0; + var iodir = null; + + if (pin < 8) { + port = this.REGISTER.IODIRA; + } else { + port = this.REGISTER.IODIRB; + pin -= 8; + } + + iodir = state.iodir[port]; + + if (mode === this.io.MODES.INPUT) { + iodir |= 1 << pin; + } else { + iodir &= ~(1 << pin); + } + + this.pins[pinIndex].mode = mode; + this.io.i2cWrite(this.address, [ port, iodir ]); + + state.iodir[port] = iodir; + } + }, + // 1.6.10 PORT REGISTER + digitalWrite: { + value: function(pin, value) { + var state = priv.get(this); + var pinIndex = pin; + var port = 0; + var gpio = 0; + // var olataddr = 0; + var gpioaddr = 0; + + if (pin < 8) { + port = this.REGISTER.IODIRA; + // olataddr = this.REGISTER.OLATA; + gpioaddr = this.REGISTER.GPIOA; + } else { + port = this.REGISTER.IODIRB; + // olataddr = this.REGISTER.OLATB; + gpioaddr = this.REGISTER.GPIOB; + pin -= 8; + } + + gpio = state.olat[port]; + + if (value === this.io.HIGH) { + gpio |= 1 << pin; + } else { + gpio &= ~(1 << pin); + } + + this.pins[pinIndex].report = 0; + this.pins[pinIndex].value = value; + this.io.i2cWrite(this.address, [ gpioaddr, gpio ]); + + state.olat[port] = gpio; + state.gpio[port] = gpio; + } + }, + // 1.6.7 PULL-UP RESISTOR + // CONFIGURATION REGISTER + pullUp: { + value: function(pin, value) { + var state = priv.get(this); + var port = 0; + var gppu = 0; + var gppuaddr = 0; + + if (pin < 8) { + port = this.REGISTER.IODIRA; + gppuaddr = this.REGISTER.GPPUA; + } else { + port = this.REGISTER.IODIRB; + gppuaddr = this.REGISTER.GPPUB; + pin -= 8; + } + + gppu = state.gppu[port]; + + if (value === this.io.HIGH) { + gppu |= 1 << pin; + } else { + gppu &= ~(1 << pin); + } + + this.io.i2cWrite(this.address, [ gppuaddr, gppu ]); + + state.gppu[port] = gppu; + } + }, + digitalRead: { + value: function(pin, callback) { + var pinIndex = pin; + var gpioaddr = 0; + + if (pin < 8) { + gpioaddr = this.REGISTER.GPIOA; + } else { + gpioaddr = this.REGISTER.GPIOB; + pin -= 8; + } + + this.pins[pinIndex].report = 1; + + this.on("digital-read-" + pin, callback); + + this.io.i2cRead(this.address, gpioaddr, 1, function(data) { + var byte = data[0]; + var value = byte >> pin & 0x01; + + this.pins[pinIndex].value = value; + + this.emit("digital-read-" + pin, value); + }.bind(this)); + } + }, + }, + MCP23008: { + REGISTER: { + value: { + ADDRESS: 0x20, + IODIR: 0x00, + GPPU: 0x06, + GPIO: 0x09, + OLAT: 0x0A, + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.iodir = [ 0xff ]; + state.olat = [ 0xff ]; + state.gpio = [ 0xff ]; + state.gppu = [ 0x00 ]; + + this.address = opts.address || this.REGISTER.ADDRESS; + + this.io.i2cConfig(); + this.io.i2cWrite(this.address, [ this.REGISTER.IODIR, state.iodir[this.REGISTER.IODIR] ]); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 8; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.INPUT, + this.MODES.OUTPUT + ], + mode: 0, + value: 0, + report: 0, + analogChannel: 127 + }); + + this.pinMode(i, this.MODES.OUTPUT); + this.digitalWrite(i, this.LOW); + } + + this.name = "MCP23008"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + return pin; + } + }, + // 1.6.1 I/O DIRECTION REGISTER + pinMode: { + value: function(pin, mode) { + var state = priv.get(this); + var pinIndex = pin; + var port = this.REGISTER.IODIR; + var iodir = state.iodir[port]; + + if (mode === this.io.MODES.INPUT) { + iodir |= 1 << pin; + } else { + iodir &= ~(1 << pin); + } + + this.pins[pinIndex].mode = mode; + this.io.i2cWrite(this.address, [ port, iodir ]); + + state.iodir[port] = iodir; + } + }, + // 1.6.10 PORT REGISTER + digitalWrite: { + value: function(pin, value) { + var state = priv.get(this); + var pinIndex = pin; + var port = this.REGISTER.IODIR; + var gpioaddr = this.REGISTER.GPIO; + var gpio = state.olat[port]; + + if (value === this.io.HIGH) { + gpio |= 1 << pin; + } else { + gpio &= ~(1 << pin); + } + + this.pins[pinIndex].report = 0; + this.pins[pinIndex].value = value; + this.io.i2cWrite(this.address, [ gpioaddr, gpio ]); + + state.olat[port] = gpio; + state.gpio[port] = gpio; + } + }, + // 1.6.7 PULL-UP RESISTOR + // CONFIGURATION REGISTER + pullUp: { + value: function(pin, value) { + var state = priv.get(this); + var port = this.REGISTER.IODIR; + var gppuaddr = this.REGISTER.GPPU; + var gppu = state.gppu[port]; + + if (value === this.io.HIGH) { + gppu |= 1 << pin; + } else { + gppu &= ~(1 << pin); + } + + this.io.i2cWrite(this.address, [ gppuaddr, gppu ]); + + state.gppu[port] = gppu; + } + }, + digitalRead: { + value: function(pin, callback) { + var pinIndex = pin; + var gpioaddr = this.REGISTER.GPIO; + + this.pins[pinIndex].report = 1; + + this.on("digital-read-" + pin, callback); + + this.io.i2cRead(this.address, gpioaddr, 1, function(data) { + var byte = data[0]; + var value = byte >> pin & 0x01; + + this.pins[pinIndex].value = value; + + this.emit("digital-read-" + pin, value); + }.bind(this)); + } + }, + }, + PCF8574: { + REGISTER: { + value: { + ADDRESS: 0x20, + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.port = 0x00; + state.ddr = 0x00; + state.pins = 0x00; + + this.address = opts.address || this.REGISTER.ADDRESS; + + this.io.i2cConfig(); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 8; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.INPUT, + this.MODES.OUTPUT + ], + mode: 1, + value: 0, + report: 0, + analogChannel: 127 + }); + + this.pinMode(i, this.MODES.OUTPUT); + this.digitalWrite(i, this.LOW); + } + + this.name = "PCF8574"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + return pin; + } + }, + pinMode: { + value: function(pin, mode) { + var state = priv.get(this); + var pinIndex = pin; + var port = state.port; + var ddr = state.ddr; + var pins = state.pins; + + if (mode === this.MODES.INPUT) { + ddr &= ~(1 << pin); + port &= ~(1 << pin); + } else { + ddr |= (1 << pin); + port &= ~(1 << pin); + } + + this.pins[pinIndex].mode = mode; + + state.port = port; + state.ddr = ddr; + + this.io.i2cWrite(this.address, (pins & ~ddr) | port); + } + }, + digitalWrite: { + value: function(pin, value) { + var state = priv.get(this); + var pinIndex = pin; + var port = state.port; + var ddr = state.ddr; + var pins = state.pins; + + if (value) { + port |= 1 << pin; + } else { + port &= ~(1 << pin); + } + + this.pins[pinIndex].report = 0; + this.pins[pinIndex].value = value; + + state.port = port; + + this.io.i2cWrite(this.address, (pins & ~ddr) | port); + } + }, + digitalRead: { + value: function(pin, callback) { + var state = priv.get(this); + var pinIndex = pin; + + this.pins[pinIndex].report = 1; + + this.on("digital-read-" + pin, callback); + + this.io.i2cRead(this.address, 1, function(data) { + var byte = data[0]; + var value = byte >> pin & 0x01; + + state.pins = byte; + + this.pins[pinIndex].value = value; + + this.emit("digital-read-" + pin, value); + }.bind(this)); + } + }, + }, + PCF8575: { + REGISTER: { + value: { + ADDRESS: 0x20, + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.port = [0x00, 0x01]; + state.gpio = [0x00, 0x00]; + + this.address = opts.address || this.REGISTER.ADDRESS; + + this.io.i2cConfig(); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 16; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.INPUT, + this.MODES.OUTPUT + ], + mode: 1, + value: 0, + report: 0, + analogChannel: 127 + }); + + this.pinMode(i, this.MODES.OUTPUT); + this.digitalWrite(i, this.LOW); + } + + // Set all pins low on initialization + this.io.i2cWrite(this.address, state.gpio); + + this.name = "PCF8575"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + return pin; + } + }, + pinMode: { + value: function(pin, mode) { + var pinIndex = pin; + this.pins[pinIndex].mode = mode; + } + }, + digitalWrite: { + value: function(pin, value) { + var state = priv.get(this); + var pinIndex = pin; + var port; + + if (pin < 8) { + port = 0; + } else { + port = 1; + pin -= 8; + } + + if (value === this.io.HIGH) { + state.gpio[port] |= 1 << pin; + } else { + state.gpio[port] &= ~(1 << pin); + } + + this.pins[pinIndex].report = 0; + this.pins[pinIndex].value = value; + + this.io.i2cWrite(this.address, state.gpio); + } + }, + digitalRead: { + value: function(pin, callback) { + var pinIndex = pin; + var port; + + if (pin < 8) { + port = 0; + } else { + port = 1; + pin -= 8; + } + + this.pins[pinIndex].report = 1; + + this.on("digital-read-" + pin, callback); + + this.io.i2cRead(this.address, 2, function(data) { + var byte = data[port]; + var value = byte >> pin & 0x01; + + this.pins[pinIndex].value = value; + + this.emit("digital-read-" + pin, value); + }.bind(this)); + } + }, + }, + PCA9685: { + REGISTER: { + value: { + ADDRESS: 0x40, + MODE1: 0x00, + PRESCALE: 0xFE, + BASE: 0x06 + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.frequency = opts.frequency || 50; + + this.address = opts.address || this.REGISTER.ADDRESS; + this.range = opts.range || [0, 4095]; + + this.io.i2cConfig(); + + // Reset + this.io.i2cWriteReg(this.address, this.REGISTER.MODE1, 0x00); + // Sleep + this.io.i2cWriteReg(this.address, this.REGISTER.MODE1, 0x10); + // Set prescalar + this.io.i2cWriteReg(this.address, this.REGISTER.PRESCALE, this.prescale); + // Wake up + this.io.i2cWriteReg(this.address, this.REGISTER.MODE1, 0x00); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWriteReg(this.address, this.REGISTER.MODE1, 0xa1); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 16; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.OUTPUT, + this.MODES.PWM, + this.MODES.SERVO, + ], + mode: 0, + value: 0, + report: 0, + analogChannel: 127 + }); + + this.pinMode(i, this.MODES.OUTPUT); + this.digitalWrite(i, this.LOW); + } + + Object.defineProperties(this, { + prescale: { + get: function() { + // PCA9685 has an on-board 25MHz clock source + return (25000000 / (4096 * (state.frequency || 50))) | 0; + } + }, + frequency: { + get: function() { + return state.frequency; + } + } + }); + + this.name = "PCA9685"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + return pin; + } + }, + pinMode: { + value: function(pin, mode) { + if (this.pins[pin] === undefined) { + throw new RangeError("Invalid PCA9685 pin: " + pin); + } + this.pins[pin].mode = mode; + } + }, + digitalWrite: { + value: function(pin, value) { + this.pwmWrite(pin, value ? 255 : 0); + } + }, + analogWrite: { + value: function(pin, value) { + this.pwmWrite(pin, value); + } + }, + servoWrite: { + value: function(pin, degrees) { + this.pwmWrite(pin, __.map(degrees, 0, 180, 0, 255)); + } + }, + pwmWrite: { + value: function(pin, value) { + if (this.pins[pin] === undefined) { + throw new RangeError("Invalid PCA9685 pin: " + pin); + } + + value = Board.constrain(value, 0, 255); + + var off = this.range[1] * value / 255; + + this.io.i2cWrite(this.address, [ + this.REGISTER.BASE + 4 * pin, + 0, 0, + off, off >> 8 + ]); + + this.pins[pin].value = value; + } + } + }, + // http://www.nxp.com/documents/data_sheet/PCF8591.pdf + PCF8591: { + REGISTER: { + value: { + ADDRESS: 0x48, + } + }, + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.control = 0x45; + state.reading = false; + + this.address = opts.address || this.REGISTER.ADDRESS; + + this.io.i2cConfig(); + + Object.assign(this.MODES, this.io.MODES); + + for (var i = 0; i < 4; i++) { + this.pins.push({ + supportedModes: [ + this.MODES.ANALOG + ], + mode: 1, + value: 0, + report: 0, + analogChannel: i + }); + } + + this.analogPins.push(0, 1, 2, 3); + + this.io.i2cWrite(this.address, state.control); + + this.name = "PCF8591"; + this.isReady = true; + + this.emit("connect"); + this.emit("ready"); + } + }, + normalize: { + value: function(pin) { + if (typeof pin === "string" && pin[0] === "A") { + return +pin.slice(1); + } + return pin; + } + }, + pinMode: { + value: function(pin, mode) { + this.pins[pin].mode = mode; + } + }, + analogRead: { + value: function(pin, callback) { + var state = priv.get(this); + var pinIndex = pin; + + this.pins[pinIndex].report = 1; + + this.on("analog-read-" + pin, callback); + + // Since this operation will read all 4 pins, + // it only needs to be initiated once. + if (!state.reading) { + state.reading = true; + + this.io.i2cRead(this.address, 4, function(data) { + var value; + for (var i = 0; i < 4; i++) { + value = data[i] << 2; + this.pins[i].value = value; + + if (this.pins[i].report) { + this.emit("analog-read-" + pin, value); + } + } + }.bind(this)); + } + } + }, + }, +}; + +Controllers.PCF8574A = Object.assign({}, Controllers.PCF8574, { + REGISTER: { + value: { + ADDRESS: 0x38, + } + }, +}); + +var methods = Object.keys(Board.prototype); + +Object.keys(Controllers).forEach(function(name) { + methods.forEach(function(key) { + if (Controllers[name][key] === undefined) { + Controllers[name][key] = { + writable: true, + configurable: true, + value: function() { + throw new Error("Expander:" + name + " does not support " + key); + } + }; + } + }); +}); + +function Expander(opts) { + if (!(this instanceof Expander)) { + return new Expander(opts); + } + + Base.call(this); + + var controller = null; + var state = {}; + var controllerValue; + + if (typeof opts === "string") { + controllerValue = opts; + } + + Board.Component.call( + this, opts = Board.Options(opts), { normalizePin: false } + ); + + if (typeof opts.controller === "undefined" && controllerValue) { + opts.controller = controllerValue; + } + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + throw new Error("Expander expects a valid controller"); + } + + Object.defineProperties(this, controller); + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts); + } + + used.set(this.address, this); +} + +util.inherits(Expander, Base); + +Expander.Active = { + + has: function(filter) { + var byAddress = filter.address !== undefined; + var byController = filter.controller !== undefined; + + if (byAddress && byController) { + // If the address is in use, then the controller doesn't matter. + if (this.byAddress(filter.address)) { + return true; + } + + if (this.byController(filter.controller)) { + return true; + } + } else { + if (byAddress) { + return Boolean(this.byAddress(filter.address)); + } + + if (byController) { + return Boolean(this.byController(filter.controller)); + } + } + + return false; + }, + + byAddress: function(address) { + return used.get(address); + }, + + byController: function(name) { + var controller; + + used.forEach(function(value) { + if (value.name === name.toUpperCase()) { + controller = value; + } + }); + return controller; + } +}; + +if (IS_TEST_MODE) { + Expander.purge = function() { + priv.clear(); + used.clear(); + }; +} + +module.exports = Expander; diff --git a/JavaScript/node_modules/johnny-five/lib/fn.js b/JavaScript/node_modules/johnny-five/lib/fn.js new file mode 100644 index 0000000..fd7c91c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/fn.js @@ -0,0 +1,231 @@ +var lodash = require("lodash"); + +var Fn = { + assign: lodash.assign, + extend: lodash.extend, + defaults: lodash.defaults, + debounce: lodash.debounce, + cloneDeep: lodash.cloneDeep, + mixin: lodash.mixin, + every: lodash.every, + pluck: lodash.pluck + }; + +// Fn.fmap( val, fromLow, fromHigh, toLow, toHigh ) +// +// Re-maps a number from one range to another. +// Based on arduino map() +// +// Return float +// +Fn.fmap = function(value, fromLow, fromHigh, toLow, toHigh) { + return (value - fromLow) * (toHigh - toLow) / + (fromHigh - fromLow) + toLow; +}; + +// Alias +Fn.fscale = Fn.fmap; + +// Fn.map( val, fromLow, fromHigh, toLow, toHigh ) +// +// Re-maps a number from one range to another. +// Based on arduino map() +// +// Retun int +// +Fn.map = function(value, fromLow, fromHigh, toLow, toHigh) { + return Fn.fmap(value, fromLow, fromHigh, toLow, toHigh) | 0; +}; + +// Alias +Fn.scale = Fn.map; + +// Fn.constrain( val, lower, upper ) +// +// Constrains a number to be within a range. +// Based on arduino constrain() +// +Fn.constrain = function(value, lower, upper) { + return Math.min(upper, Math.max(lower, value)); +}; + +// Fn.range( upper ) +// Fn.range( lower, upper ) +// Fn.range( lower, upper, tick ) +// +// Returns a new array range +// +Fn.range = function(lower, upper, tick) { + + if (arguments.length === 1) { + upper = lower - 1; + lower = 0; + } + + lower = lower || 0; + upper = upper || 0; + tick = tick || 1; + + var len = Math.max(Math.ceil((upper - lower) / tick), 0), + idx = 0, + range = []; + + while (idx <= len) { + range[idx++] = lower; + lower += tick; + } + + return range; +}; + +// Fn.range.prefixed( prefix, upper ) +// Fn.range.prefixed( prefix, lower, upper ) +// Fn.range.prefixed( prefix, lower, upper, tick ) +// +// Returns a new array range, each value prefixed +// +Fn.range.prefixed = function(prefix) { + return Fn.range.apply(null, [].slice.call(arguments, 1)).map(function(val) { + return prefix + val; + }); +}; + +// Fn.uid() +// +// Returns a reasonably unique id string +// +Fn.uid = function() { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(chr) { + var rnd = Math.random() * 16 | 0; + return (chr === "x" ? rnd : (rnd & 0x3 | 0x8)).toString(16); + }).toUpperCase(); +}; + +// Fn.square() +// +// Returns squared x +// +Fn.square = function(x) { + return x * x; +}; + +// Fn.sum( values ) +// +// Returns the sum of all values from array +// +Fn.sum = function sum(values) { + var vals; + if (Array.isArray(values)) { + vals = values; + } else { + vals = [].slice.call(arguments); + } + return vals.reduce(function(accum, value) { + return accum + value; + }, 0); +}; + +// fma function +// Copyright (c) 2012, Jens Nockert +// All rights reserved. +// +// 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +Fn.fma = function(a, b, c) { + var aHigh = 134217729 * a; + var aLow; + + aHigh = aHigh + (a - aHigh); + aLow = a - aHigh; + + var bHigh = 134217729 * b; + var bLow; + + bHigh = bHigh + (b - bHigh); + bLow = b - bHigh; + + var r1 = a * b; + var r2 = -r1 + aHigh * bHigh + aHigh * bLow + aLow * bHigh + aLow * bLow; + + var s = r1 + c; + var t = (r1 - (s - c)) + (c - (s - r1)); + + return s + (t + r2); +}; +// end fma function copyright + + +// Fn._BV(bit) +// +// (from avr/io.h; "BV" => Bit Value) +// +// Return byte value with that bit set. +// +Fn._BV = Fn.bitValue = Fn.bv = function(bit) { + return 1 << bit; +}; + +/* + Example of _BV/bitValue usage... + + Logically OR these bits together: + var ORed = _BV(0) | _BV(2) | _BV(7); + + BIT 7 6 5 4 3 2 1 0 + --------------------------------------------------------- + _BV(0) = 0 0 0 0 0 0 0 1 + _BV(2) = 0 0 0 0 0 1 0 0 + _BV(7) = 1 0 0 0 0 0 0 0 + ORed = 1 0 0 0 0 1 0 1 + + ORed === 133; + +*/ + + +// Fn.int16(high, low) + +Fn.int16 = function(high, low) { + var result = (high << 8) | low; + + // if highest bit is on, it is negative + return result >> 15 ? ((result ^ 0xFFFF) + 1) * -1 : result; +}; + +Fn.uint16 = function(high, low) { + return (high << 8) | low; +}; + +Fn.int24 = function(high, low, xlow) { + var result = (high << 16) | (low << 8) | xlow; + + // if highest bit is on, it is negative + return result >> 23 ? ((result ^ 0xFFFFFF) + 1) * -1 : result; +}; + +Fn.uint24 = function(high, low, xlow) { + return (high << 16) | (low << 8) | xlow; +}; + + +module.exports = Fn; + diff --git a/JavaScript/node_modules/johnny-five/lib/gripper.js b/JavaScript/node_modules/johnny-five/lib/gripper.js new file mode 100644 index 0000000..beb6a09 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/gripper.js @@ -0,0 +1,95 @@ +var Servo = require("../lib/servo.js"), + __ = require("../lib/fn.js"); + +/** + * Gripper + * + * Supports: + * [Parallax Boe-Bot gripper](http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/GripperManual-v3.0.pdf) + * + * [DFRobot LG-NS](http://www.dfrobot.com/index.php?route=product/product&filter_name=gripper&product_id=628#.UCvGymNST_k) + * + * + * @param {[type]} servo [description] + */ + +function Gripper(opts) { + + if (!(this instanceof Gripper)) { + return new Gripper(opts); + } + + // Default options mode, assume only when opts is a pin number + if (typeof opts === "number") { + opts = { + servo: { + pin: opts, + range: [0, 180] + }, + scale: [0, 10] + }; + } + + // Default set() args to 0-10 + this.scale = opts.scale || [0, 10]; + + // Setup servo + // Allows pre-constructed servo or creating new servo. + // Defaults for new Servo creation fall back to Servo defaults + this.servo = opts.servo instanceof Servo ? + opts.servo : new Servo(opts.servo); +} + +[ + /** + * open Open the gripper + * + * @return {Object} this + */ + { + name: "open", + args: function() { + return this.servo.range[0]; + } + }, + /** + * close Close the gripper + * + * @return {Object} this + */ + { + name: "close", + args: function() { + return this.servo.range[1]; + } + }, + /** + * set Set the gripper's open width + * + * @param {Number} 0-10, 0 is closed, 10 is open + * + * @return {Object} this + */ + { + name: "set", + args: function(position) { + // Map/Scale position value to a value within + // the servo's lo/hi range + return Math.floor( + __.map( + position, + this.scale[0], this.scale[1], + this.servo.range[1], this.servo.range[0] + ) + ); + } + } +].forEach(function(api) { + Gripper.prototype[api.name] = function() { + return this.servo.to( + api.args.apply(this, [].slice.call(arguments)) + ); + }; +}); + +module.exports = Gripper; diff --git a/JavaScript/node_modules/johnny-five/lib/gyro.js b/JavaScript/node_modules/johnny-five/lib/gyro.js new file mode 100644 index 0000000..2063e7a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/gyro.js @@ -0,0 +1,301 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + __ = require("../lib/fn.js"), + sum = __.sum; + +var priv = new Map(); +var axes = ["x", "y", "z"]; + +function ToPrecision(val, precision) { + return +(val).toPrecision(precision); +} + +var Controllers = { + ANALOG: { + initialize: { + value: function(opts, dataHandler) { + var pins = opts.pins || [], + sensitivity, resolution, + state = priv.get(this), + dataPoints = {}; + + if (opts.sensitivity === undefined) { + throw new Error("Expected a Sensitivity"); + } + + // 4.88mV / (0.167mV/dps * 2) + // 0.67 = 4X + // 0.167 = 1X + sensitivity = opts.sensitivity; + resolution = opts.resolution || 4.88; + state.K = resolution / sensitivity; + + pins.forEach(function(pin, index) { + this.io.pinMode(pin, this.io.MODES.ANALOG); + this.io.analogRead(pin, function(data) { + var axis = axes[index]; + dataPoints[axis] = data; + dataHandler(dataPoints); + }.bind(this)); + }, this); + } + }, + toNormal: { + value: function(raw) { + return raw >> 2; + } + }, + toDegreesPerSecond: { + value: function(raw, rawCenter) { + var normal = this.toNormal(raw); + var center = this.toNormal(rawCenter); + var state = priv.get(this); + + return ((normal - center) * state.K) | 0; + } + } + }, + // http://www.invensense.com/mems/gyro/mpu6050.html + // Default to the +- 250 which has a 131 LSB/dps + MPU6050: { + initialize: { + value: function(opts, dataHandler) { + var IMU = require("../lib/imu"); + var state = priv.get(this), + driver = IMU.Drivers.get(this.board, "MPU-6050", opts); + + state.sensitivity = opts.sensitivity || 131; + + driver.on("data", function(data) { + dataHandler(data.gyro); + }); + } + }, + toNormal: { + value: function(raw) { + return (raw >> 11) + 127; + } + }, + toDegreesPerSecond: { + value: function(raw, rawCenter) { + var state = priv.get(this); + + return (raw - rawCenter) / state.sensitivity; + } + } + } +}; + +// Otherwise known as... +Controllers["MPU-6050"] = Controllers.MPU6050; + +function Gyro(opts) { + if (!(this instanceof Gyro)) { + return new Gyro(opts); + } + + var controller = null; + var isCalibrated = false; + var sampleSize = 100; + + var state = { + x: { + angle: 0, + value: 0, + previous: 0, + calibration: [], + stash: [0, 0, 0, 0, 0], + center: 0, + hasValue: false + }, + y: { + angle: 0, + value: 0, + previous: 0, + calibration: [], + stash: [0, 0, 0, 0, 0], + center: 0, + hasValue: false + }, + z: { + angle: 0, + value: 0, + previous: 0, + calibration: [], + stash: [0, 0, 0, 0, 0], + center: 0, + hasValue: false + } + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["ANALOG"]; + } + + Object.defineProperties(this, controller); + + if (!this.toNormal) { + this.toNormal = opts.toNormal || function(raw) { return raw; }; + } + + if (!this.toDegreesPerSecond) { + this.toDegreesPerSecond = opts.toDegreesPerSecond || function(raw) { return raw; }; + } + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var isChange = false; + + Object.keys(data).forEach(function(axis) { + var value = data[axis]; + var sensor = state[axis]; + + sensor.previous = sensor.value; + sensor.stash.shift(); + sensor.stash.push(value); + sensor.hasValue = true; + sensor.value = (sum(sensor.stash) / 5) | 0; + + if (!isCalibrated && + (state.x.calibration.length === sampleSize && + state.y.calibration.length === sampleSize && + (this.z === undefined || state.z.calibration.length === sampleSize))) { + + isCalibrated = true; + state.x.center = (sum(state.x.calibration) / sampleSize) | 0; + state.y.center = (sum(state.y.calibration) / sampleSize) | 0; + state.z.center = (sum(state.z.calibration) / sampleSize) | 0; + + state.x.calibration.length = 0; + state.y.calibration.length = 0; + state.z.calibration.length = 0; + } else { + if (sensor.calibration.length < sampleSize) { + sensor.calibration.push(value); + } + } + + if (sensor.previous !== sensor.value) { + isChange = true; + } + }, this); + + if (isCalibrated) { + state.x.angle += this.rate.x / 100; + state.y.angle += this.rate.y / 100; + state.z.angle += this.rate.z / 100; + + this.emit("data", { + x: this.x, + y: this.y, + z: this.z + }); + + if (isChange) { + this.emit("change", { + x: this.x, + y: this.y, + z: this.z + }); + } + } + }.bind(this)); + } + + Object.defineProperties(this, { + isCalibrated: { + get: function() { + return isCalibrated; + }, + set: function(value) { + if (typeof value === "boolean") { + isCalibrated = value; + } + } + }, + pitch: { + get: function() { + return { + rate: ToPrecision(this.rate.y, 2), + angle: ToPrecision(state.y.angle, 2) + }; + } + }, + roll: { + get: function() { + return { + rate: ToPrecision(this.rate.x, 2), + angle: ToPrecision(state.x.angle, 2) + }; + } + }, + yaw: { + get: function() { + return { + rate: this.z !== undefined ? ToPrecision(this.rate.z, 2) : 0, + angle: this.z !== undefined ? ToPrecision(state.z.angle, 2) : 0 + }; + } + }, + x: { + get: function() { + return ToPrecision(this.toNormal(state.x.value), 4); + } + }, + y: { + get: function() { + return ToPrecision(this.toNormal(state.y.value), 4); + } + }, + z: { + get: function() { + return state.z.hasValue ? ToPrecision(this.toNormal(state.z.value), 4) : undefined; + } + }, + rate: { + get: function() { + var x = this.toDegreesPerSecond(state.x.value, state.x.center); + var y = this.toDegreesPerSecond(state.y.value, state.y.center); + var z = state.z.hasValue ? + this.toDegreesPerSecond(state.z.value, state.z.center) : 0; + + return { + x: ToPrecision(x, 2), + y: ToPrecision(y, 2), + z: ToPrecision(z, 2) + }; + } + } + }); +} + +Object.defineProperties(Gyro, { + TK_4X: { + value: 0.67 + }, + TK_1X: { + value: 0.167 + } +}); + + +util.inherits(Gyro, events.EventEmitter); + +Gyro.prototype.recalibrate = function() { + this.isCalibrated = false; +}; + +module.exports = Gyro; diff --git a/JavaScript/node_modules/johnny-five/lib/imu.js b/JavaScript/node_modules/johnny-five/lib/imu.js new file mode 100644 index 0000000..cfaec66 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/imu.js @@ -0,0 +1,530 @@ +var Board = require("../lib/board.js"); +var Emitter = require("events").EventEmitter; +var util = require("util"); +var __ = require("../lib/fn.js"); +var Accelerometer = require("../lib/accelerometer.js"); +var Barometer = require("../lib/barometer.js"); +var Temperature = require("../lib/temperature.js"); +var Gyro = require("../lib/gyro.js"); +var int16 = __.int16; +var uint16 = __.uint16; +var uint24 = __.uint24; + +var priv = new Map(); +var activeDrivers = new Map(); + +var Drivers = { + // Based on the example code from + // http://playground.arduino.cc/Main/MPU-6050 + // http://www.invensense.com/mems/gyro/mpu6050.html + MPU6050: { + ADDRESSES: { + value: [0x68, 0x69] + }, + REGISTER: { + value: { + SETUP: [0x6B, 0x00], // += 250 + READ: 0x3B + } + }, + initialize: { + value: function(board, opts) { + var READLENGTH = 14; + var io = board.io; + var address = opts.address || this.ADDRESSES[0]; + + var computed = { + accelerometer: {}, + temperature: {}, + gyro: {} + }; + + io.i2cConfig(); + io.i2cWrite(address, this.REGISTER.SETUP); + + io.i2cRead(address, this.REGISTER.READ, READLENGTH, function(data) { + computed.accelerometer = { + x: int16(data[0], data[1]), + y: int16(data[2], data[3]), + z: int16(data[4], data[5]) + }; + + computed.temperature = int16(data[6], data[7]); + + computed.gyro = { + x: int16(data[8], data[9]), + y: int16(data[10], data[11]), + z: int16(data[12], data[13]) + }; + + this.emit("data", computed); + }.bind(this)); + }, + }, + identifier: { + value: function(opts) { + var address = opts.address || Drivers["MPU6050"].ADDRESSES.value[0]; + return "mpu-6050-" + address; + } + } + }, + MPL115A2: { + ADDRESSES: { + value: [0x60] + }, + REGISTER: { + value: { + COEFFICIENTS: 0x04, + READ: 0x00, + STARTCONVERSION: 0x12, + } + }, + initialize: { + value: function(board, opts) { + var READLENGTH = 4; + var io = board.io; + var address = opts.address || this.ADDRESSES[0]; + + var cof = { + a0: null, + b1: null, + b2: null, + c12: null + }; + + io.i2cConfig(); + + var pCoefficients = new Promise(function(resolve) { + io.i2cReadOnce(address, this.REGISTER.COEFFICIENTS, 8, function(data) { + var A0 = int16(data[0], data[1]); + var B1 = int16(data[2], data[3]); + var B2 = int16(data[4], data[5]); + var C12 = int16(data[6], data[7]) >> 2; + + // Source: + // https://github.com/adafruit/Adafruit_MPL115A2 + // a0 is the pressure offset coefficient + // b1 is the pressure sensitivity coefficient + // b2 is the temperature coefficient of offset (TCO) + // c12 is the temperature coefficient of sensitivity (TCS) + cof.a0 = A0 / 8; + cof.b1 = B1 / 8192; + cof.b2 = B2 / 16384; + cof.c12 = C12 / 4194304; + + resolve(); + }.bind(this)); + }.bind(this)); + + pCoefficients.then(function() { + io.i2cWrite(address, [this.REGISTER.STARTCONVERSION, 0x00]); + + io.i2cRead(address, this.REGISTER.READ, READLENGTH, function(data) { + var padc = uint16(data[0], data[1]) >> 6; + var tadc = uint16(data[2], data[3]) >> 6; + + var pressure = cof.a0 + (cof.b1 + cof.c12 * tadc) * padc + cof.b2 * tadc; + var temperature = tadc; + + this.emit("data", { + pressure: pressure, + temperature: temperature, + }); + }.bind(this)); + }.bind(this)); + } + }, + identifier: { + value: function(opts) { + var address = opts.address || Drivers["MPL115A2"].ADDRESSES.value[0]; + return "mpl115a2-" + address; + } + } + }, + BMP180: { + ADDRESSES: { + value: [0x77] + }, + REGISTER: { + value: { + COEFFICIENTS: 0xAA, + READ: 0x00, + READ_START: 0xF4, + READ_RESULT: 0xF6, + } + }, + initialize: { + value: function(board, opts) { + var io = board.io; + var address = opts.address || this.ADDRESSES[0]; + + /** + * http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf + * Table 1: Operating conditions, output signal and mechanical characteristics + * + * Pressure Conversion Delay (ms) + * + * [ + * 5, LOW + * 8, STANDARD + * 14, HIGH + * 26, ULTRA + * ] + */ + + var mode = opts.mode || 3; + var kpDelay = [ 5, 8, 14, 26 ][ mode ]; + var oss = __.constrain(mode, 0, 3); + + var cof = { + a1: null, + a2: null, + a3: null, + a4: null, + a5: null, + a6: null, + b1: null, + b2: null, + b5: null, + mb: null, + mc: null, + md: null, + }; + + io.i2cConfig(); + + var pCoefficients = new Promise(function(resolve) { + io.i2cReadOnce(address, this.REGISTER.COEFFICIENTS, 22, function(data) { + // http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf + // Pages 11, 15 + // 3.3 Measurement of pressure and temperature + // 3.5 Calculating pressure and temperature + cof.a1 = int16(data[0], data[1]); + cof.a2 = int16(data[2], data[3]); + cof.a3 = int16(data[4], data[5]); + cof.a4 = uint16(data[6], data[7]); + cof.a5 = uint16(data[8], data[9]); + cof.a6 = uint16(data[10], data[11]); + cof.b1 = int16(data[12], data[13]); + cof.b2 = int16(data[14], data[15]); + cof.mb = int16(data[16], data[17]); + cof.mc = int16(data[18], data[19]); + cof.md = int16(data[20], data[21]); + + resolve(); + }); + }.bind(this)); + + pCoefficients.then(function() { + var computed = { + pressure: null, + temperature: null, + }; + + var cycle = 0; + + // http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf + // Pages 11, 15 + // 3.3 Measurement of pressure and temperature + // 3.5 Calculating pressure and temperature + var readCycle = function() { + + // cycle 0: temperature + // cycle 1: pressure + + var isTemperatureCycle = cycle === 0; + var component = isTemperatureCycle ? 0x2E : 0x34 + (oss << 6); + var numBytes = isTemperatureCycle ? 2 : 3; + var delay = isTemperatureCycle ? 5 : kpDelay; + + + io.i2cWriteReg(address, this.REGISTER.READ_START, component); + + // Once the READ_START register is set, + // delay the READ_RESULT request based on the + // mode value provided by the user, or default. + setTimeout(function() { + io.i2cReadOnce(address, this.REGISTER.READ_RESULT, numBytes, function(data) { + var compensated, uncompensated; + var x1, x2, x3, b3, b4, b6, b7, b6s, bx; + + if (isTemperatureCycle) { + // TEMPERATURE + uncompensated = int16(data[0], data[1]); + + // Compute the true temperature + x1 = ((uncompensated - cof.a6) * cof.a5) >> 15; + x2 = ((cof.mc << 11) / (x1 + cof.md)) >> 0; + + // Compute b5, which is used by the pressure cycle + cof.b5 = (x1 + x2) | 0; + + // Steps of 0.1°C + computed.temperature = ((cof.b5 + 8) >> 4) / 10; + } else { + // PRESSURE + uncompensated = uint24(data[0], data[1], data[2]) >> (8 - oss); + + b6 = cof.b5 - 4000; + b6s = b6 * b6; + bx = b6s >> 12; + + // Intermediary x1 & x2 to calculate x3 for b3 + x1 = (cof.b2 * bx) >> 11; + x2 = (cof.a2 * b6) >> 11; + x3 = x1 + x2; + b3 = ((((cof.a1 * 4 + x3) << oss) + 2) / 4) >> 0; + + // Intermediary x1 & x2 to calculate x3 for b4 + x1 = (cof.a3 * b6) >> 13; + x2 = (cof.b1 * bx) >> 16; + x3 = ((x1 + x2) + 2) >> 2; + b4 = (cof.a4 * (x3 + 32768)) >> 15; + b7 = (uncompensated - b3) * (50000 >> oss); + + if (b7 < 0x80000000) { + compensated = (b7 * 2) / b4; + } else { + compensated = (b7 / b4) * 2; + } + + compensated >>= 0; + + x1 = (compensated >> 8) * (compensated >> 8); + x1 = (x1 * 3038) >> 16; + x2 = (-7357 * compensated) >> 16; + + compensated += (x1 + x2 + 3791) >> 4; + + // Steps of 1Pa (= 0.01hPa = 0.01mbar) (=> 0.001kPa) + computed.pressure = compensated; + } + + if (++cycle === 2) { + cycle = 0; + this.emit("data", computed); + } + + readCycle(); + }.bind(this)); + }.bind(this), delay); + }.bind(this); + + // Kick off "read loop" + // + readCycle(); + }.bind(this)); + } + }, + identifier: { + value: function(opts) { + var address = opts.address || Drivers["BMP180"].ADDRESSES.value[0]; + return "bmp180-" + address; + } + } + } +}; + +// Otherwise known as... +Drivers["MPU-6050"] = Drivers.MPU6050; + +Drivers.get = function(board, driverName, opts) { + var drivers, driverKey, driver; + + if (!activeDrivers.has(board)) { + activeDrivers.set(board, {}); + } + + drivers = activeDrivers.get(board); + + driverKey = Drivers[driverName].identifier.value(opts); + + if (!drivers[driverKey]) { + driver = new Emitter(); + Object.defineProperties(driver, Drivers[driverName]); + driver.initialize(board, opts); + drivers[driverKey] = driver; + } + + return drivers[driverKey]; +}; + +Drivers.clear = function() { + activeDrivers.clear(); +}; + +var Controllers = { + /** + * MPU-6050 3-axis Gyro/Accelerometer and Temperature + * + * http://playground.arduino.cc/Main/MPU-6050 + */ + + MPU6050: { + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.accelerometer = new Accelerometer({ + controller: "MPU6050", + freq: opts.freq, + board: this.board + }); + + state.temperature = new Temperature({ + controller: "MPU6050", + freq: opts.freq, + board: this.board + }); + + state.gyro = new Gyro({ + controller: "MPU6050", + freq: opts.freq, + board: this.board + }); + } + }, + components: { + value: ["accelerometer", "temperature", "gyro"] + }, + accelerometer: { + get: function() { + return priv.get(this).accelerometer; + } + }, + temperature: { + get: function() { + return priv.get(this).temperature; + } + }, + gyro: { + get: function() { + return priv.get(this).gyro; + } + } + }, + MPL115A2: { + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.barometer = new Barometer({ + controller: "MPL115A2", + freq: opts.freq, + board: this.board + }); + + state.temperature = new Temperature({ + controller: "MPL115A2", + freq: opts.freq, + board: this.board + }); + } + }, + components: { + value: ["barometer", "temperature"] + }, + barometer: { + get: function() { + return priv.get(this).barometer; + } + }, + temperature: { + get: function() { + return priv.get(this).temperature; + } + } + }, + BMP180: { + initialize: { + value: function(opts) { + var state = priv.get(this); + + state.barometer = new Barometer({ + controller: "BMP180", + freq: opts.freq, + board: this.board + }); + + state.temperature = new Temperature({ + controller: "BMP180", + freq: opts.freq, + board: this.board + }); + } + }, + components: { + value: ["barometer", "temperature", /* "altitude" */] + }, + barometer: { + get: function() { + return priv.get(this).barometer; + } + }, + temperature: { + get: function() { + return priv.get(this).temperature; + } + } + } +}; + +// Otherwise known as... +Controllers["MPU-6050"] = Controllers.MPU6050; +Controllers["GY521"] = Controllers["GY-521"] = Controllers.MPU6050; + +function IMU(opts) { + + if (!(this instanceof IMU)) { + return new IMU(opts); + } + + var controller, state; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["MPU6050"]; + } + + this.freq = opts.freq || 500; + + state = {}; + priv.set(this, state); + + Object.defineProperties(this, controller); + + if (typeof this.initialize === "function") { + this.initialize(opts); + } + + setInterval(function() { + this.emit("data", this); + }.bind(this), this.freq); + + if (this.components && this.components.length > 0) { + this.components.forEach(function(component) { + if (!(this[component] instanceof Emitter)) { + return; + } + + this[component].on("change", function() { + this.emit("change", this, component); + }.bind(this)); + }, this); + } +} + +util.inherits(IMU, Emitter); + +IMU.Drivers = Drivers; + +module.exports = IMU; diff --git a/JavaScript/node_modules/johnny-five/lib/ir.js b/JavaScript/node_modules/johnny-five/lib/ir.js new file mode 100644 index 0000000..c5f861b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/ir.js @@ -0,0 +1,183 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"); + +var priv = new Map(), + Devices; + +Devices = { + /** + * Sharp GP2Y0D805Z0F IR Sensor + * 0×20, 0×22, 0×24, 0×26 + * + * http://osepp.com/products/sensors-arduino-compatible/osepp-ir-proximity-sensor-module/ + * + * + * http://sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y0d805z_e.pdf + * + */ + + /* @deprecated */ + "GP2Y0D805Z0F": { + type: "proximity", + address: 0x26, + bytes: 1, + delay: 250, + + // read request data handler + data: function(read, data) { + var state = priv.get(this).state, + value = data[0], + timestamp = new Date(), + err = null; + + if (value !== state && value === 1) { + this.emit("motionstart", err, timestamp); + } + + if (state === 1 && value === 3) { + this.emit("motionend", err, timestamp); + } + + priv.set(this, { + state: value + }); + }, + + // These are added to the property descriptors defined + // within the constructor + descriptor: { + value: { + get: function() { + return priv.get(this).state; + } + } + }, + setup: [ + // CRA + [0x3, 0xFE] + ], + preread: [ + [0x0] + ] + }, + + "QRE1113GR": { + // http://www.pololu.com/file/0J117/QRE1113GR.pdf + type: "reflect", + address: 0x4B, + bytes: 2, + delay: 100, + + // read request data handler + data: function(data) { + var temp = { + left: data[0], + right: data[1] + }; + + // if ( temp.left < 200 ) { + // this.emit( "left", err, timestamp ); + // } + + // if ( temp.right < 200 ) { + // this.emit( "right", err, timestamp ); + // } + + + priv.set(this, temp); + }, + + descriptor: { + left: { + get: function() { + return priv.get(this).left; + } + }, + right: { + get: function() { + return priv.get(this).right; + } + } + }, + + setup: [ + // Reset the ADC (analog-to-digital converter) + // NXP PCA969 + [0x0, 0x0] + ], + preread: [ + // left, right + [0x0, 0x1] + ] + } +}; + + + +function IR(opts) { + + if (!(this instanceof IR)) { + return new IR(opts); + } + + var address, bytes, data, device, delay, descriptor, + preread, setup; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + device = Devices[opts.device]; + + address = opts.address || device.address; + bytes = device.bytes; + data = device.data; + delay = device.delay; + setup = device.setup; + descriptor = device.descriptor; + preread = device.preread; + + // Read event throttling + this.freq = opts.freq || 500; + + // Make private data entry + priv.set(this, { + state: 0 + }); + + // Set up I2C data connection + this.io.i2cConfig(); + + // Enumerate and write each set of setup instructions + setup.forEach(function(byteArray) { + this.io.i2cWrite(address, byteArray); + }, this); + + // Read Request Loop + setInterval(function() { + // Set pointer to X most signficant byte/register + this.io.i2cWrite(address, preread); + + // Read from register + this.io.i2cReadOnce(address, bytes, data.bind(this)); + + }.bind(this), delay); + + // Continuously throttled "read" event + setInterval(function() { + // @DEPRECATE + this.emit("read"); + // The "read" event has been deprecated in + // favor of a "data" event. + this.emit("data"); + }.bind(this), this.freq); + + if (descriptor) { + Object.defineProperties(this, descriptor); + } +} + +util.inherits(IR, events.EventEmitter); + +module.exports = IR; diff --git a/JavaScript/node_modules/johnny-five/lib/johnny-five.js b/JavaScript/node_modules/johnny-five/lib/johnny-five.js new file mode 100644 index 0000000..9719083 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/johnny-five.js @@ -0,0 +1,158 @@ +require("es6-shim"); +require("array-includes").shim(); + + +module.exports = { + // extract-start:apinames + Accelerometer: require("./accelerometer"), + Animation: require("./animation"), + Barometer: require("./barometer"), + Board: require("./board"), + Button: require("./button"), + Compass: require("./compass"), + Distance: require("./distance"), + ESC: require("./esc"), + Expander: require("./expander"), + Fn: require("./fn"), + Gripper: require("./gripper"), + Gyro: require("./gyro"), + IMU: require("./imu"), + IR: require("./ir"), + Keypad: require("./keypad"), + LCD: require("./lcd"), + Led: require("./led"), + LedControl: require("./led/ledcontrol"), + Joystick: require("./joystick"), + Motion: require("./motion"), + Motor: require("./motor"), + Nodebot: require("./nodebot"), + Piezo: require("./piezo"), + Ping: require("./ping"), + Pir: require("./pir"), + Pin: require("./pin"), + Proximity: require("./proximity"), + Relay: require("./relay"), + Repl: require("./repl"), + Sensor: require("./sensor"), + Servo: require("./servo"), + ShiftRegister: require("./shiftregister"), + Sonar: require("./sonar"), + Stepper: require("./stepper"), + Switch: require("./switch"), + Temperature: require("./temperature"), + Wii: require("./wii") + // extract-end:apinames +}; + +// Customized constructors +// +// +module.exports.Board.Virtual = function(opts) { + var temp; + + if (opts instanceof module.exports.Expander) { + temp = { + io: opts + }; + } else { + temp = opts; + } + + return new module.exports.Board( + Object.assign({}, { repl: false, debug: false, sigint: false }, temp) + ); +}; + +module.exports.Multi = module.exports.IMU; + +module.exports.Analog = function(opts) { + return new module.exports.Sensor(opts); +}; + +module.exports.Digital = function(opts) { + var pin; + + if (typeof opts === "number") { + pin = opts; + opts = { + type: "digital", + pin: pin + }; + } else { + opts.type = opts.type || "digital"; + } + + return new module.exports.Sensor(opts); +}; + +module.exports.Sensor.Analog = module.exports.Analog; +module.exports.Sensor.Digital = module.exports.Digital; + +/** + * @deprecated Will be deleted in version 1.0.0. Use Proximity instead. + */ +module.exports.IR.Distance = function(opts) { + console.log("IR.Distance is deprecated. Use Proximity instead"); + return new module.exports.Distance(opts); +}; + +/** + * @deprecated Will be deleted in version 1.0.0. Use Motion instead. + */ +module.exports.IR.Motion = function(opt) { + console.log("IR.Motion is deprecated. Use Motion instead"); + return new module.exports.Pir( + typeof opt === "number" ? opt : ( + opt.pin === undefined ? 7 : opt.pin + ) + ); +}; + +/** + * @deprecated Will be deleted in version 1.0.0. Use Proximity instead. + */ +module.exports.IR.Proximity = function(opts) { + console.log("IR.Proximity is deprecated. Use Proximity instead"); + // Fix a naming mistake. + if (module.exports.Distance.Controllers.includes(opts.controller)) { + return new module.exports.Distance(opts); + } + + return new module.exports.IR({ + device: opts || "GP2Y0D805Z0F", + freq: 50 + }); +}; + +module.exports.IR.Proximity.Controllers = module.exports.Distance.Controllers; + +module.exports.IR.Reflect = function(model) { + return new module.exports.IR({ + device: model || "QRE1113GR", + freq: 50 + }); +}; + +module.exports.IR.Reflect.Array = require("./reflectancearray"); + +module.exports.Magnetometer = function() { + return new module.exports.Compass({ + controller: "HMC5883L", + freq: 100, + gauss: 1.3 + }); +}; + +// Short-handing, Aliases +module.exports.Boards = module.exports.Board.Array; +module.exports.ESCs = module.exports.ESC.Array; +module.exports.Leds = module.exports.Led.Array; +module.exports.Motors = module.exports.Motor.Array; +module.exports.Pins = module.exports.Pin.Array; +module.exports.Servos = module.exports.Servo.Array; + +// Direct Alias +module.exports.Touchpad = module.exports.Keypad; + +// Back Compat +module.exports.Nunchuk = module.exports.Wii.Nunchuk; diff --git a/JavaScript/node_modules/johnny-five/lib/joystick.js b/JavaScript/node_modules/johnny-five/lib/joystick.js new file mode 100644 index 0000000..8a5c074 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/joystick.js @@ -0,0 +1,255 @@ +var Board = require("../lib/board"); +var Emitter = require("events").EventEmitter; +var util = require("util"); +var __ = require("../lib/fn"); +var priv = new Map(); +var axes = ["x", "y"]; + +function Multiplexer(options) { + this.pins = options.pins; + this.io = options.io; + + // Setup these "analog" pins as digital output. + this.io.pinMode(this.pins[0], this.io.MODES.OUTPUT); + this.io.pinMode(this.pins[1], this.io.MODES.OUTPUT); + this.io.pinMode(this.pins[2], this.io.MODES.OUTPUT); + this.io.pinMode(this.pins[3], this.io.MODES.OUTPUT); +} + +Multiplexer.prototype.select = function(channel) { + this.io.digitalWrite(this.pins[0], channel & 1 ? this.io.HIGH : this.io.LOW); + this.io.digitalWrite(this.pins[1], channel & 2 ? this.io.HIGH : this.io.LOW); + this.io.digitalWrite(this.pins[2], channel & 4 ? this.io.HIGH : this.io.LOW); + this.io.digitalWrite(this.pins[3], channel & 8 ? this.io.HIGH : this.io.LOW); +}; + +var Controllers = { + ANALOG: { + initialize: { + value: function(opts, dataHandler) { + var axisValues = { + x: null, + y: null + }; + + opts.pins.forEach(function(pin, index) { + this.io.pinMode(pin, this.io.MODES.ANALOG); + this.io.analogRead(pin, function(value) { + axisValues[axes[index]] = value; + + if (axisValues.x !== null && axisValues.y !== null) { + dataHandler({ + x: axisValues.x, + y: axisValues.y + }); + + axisValues.x = null; + axisValues.y = null; + } + }.bind(this)); + }, this); + } + }, + toAxis: { + value: function(raw, axis) { + var state = priv.get(this); + return __.constrain(__.fscale(raw - state[axis].zeroV, -511, 511, -1, 1), -1, 1); + } + } + }, + ESPLORA: { + initialize: { + value: function(opts, dataHandler) { + // References: + // + // https://github.com/arduino/Arduino/blob/master/libraries/Esplora/src/Esplora.h + // https://github.com/arduino/Arduino/blob/master/libraries/Esplora/src/Esplora.cpp + // + var multiplexer = new Multiplexer({ + // Since Multiplexer uses digitalWrite, + // we have to send the analog pin numbers + // in their "digital" pin order form. + pins: [ 18, 19, 20, 21 ], + io: this.io + }); + var channels = [ 11, 12 ]; + var index = 1; + var axisValues = { + x: null, + y: null + }; + + this.io.pinMode(4, this.io.MODES.ANALOG); + + var handler = function(value) { + axisValues[axes[index]] = value; + + if (axisValues.x !== null && axisValues.y !== null) { + dataHandler({ + x: axisValues.x, + y: axisValues.y + }); + + axisValues.x = null; + axisValues.y = null; + } + + // Remove this handler to all the multiplexer + // to setup the next pin for the next read. + this.io.removeListener("analog-read-4", handler); + + setTimeout(read, 10); + }.bind(this); + + var read = function() { + multiplexer.select(channels[index ^= 1]); + this.io.analogRead(4, handler); + }.bind(this); + + read(); + } + }, + toAxis: { + value: function(raw, axis) { + var state = priv.get(this); + return __.constrain(__.fscale(raw - state[axis].zeroV, -511, 511, -1, 1), -1, 1); + } + } + } +}; + +/** + * Joystick + * @constructor + * + * five.Joystick([ x, y[, z] ]); + * + * five.Joystick({ + * pins: [ x, y[, z] ] + * freq: ms + * }); + * + * + * @param {Object} opts [description] + * + */ +function Joystick(opts) { + if (!(this instanceof Joystick)) { + return new Joystick(opts); + } + + var controller = null; + + var state = { + x: { + invert: false, + value: 0, + previous: 0, + zeroV: 0, + calibrated: false + }, + y: { + invert: false, + value: 0, + previous: 0, + zeroV: 0, + calibrated: false + } + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["ANALOG"]; + } + + Object.defineProperties(this, controller); + + if (!this.toAxis) { + this.toAxis = opts.toAxis || function(raw) { return raw; }; + } + + this.threshold = opts.threshold === undefined ? 0.01 : opts.threshold; + + state.x.zeroV = opts.zeroV === undefined ? 0 : (opts.zeroV.x || 0); + state.y.zeroV = opts.zeroV === undefined ? 0 : (opts.zeroV.y || 0); + + state.x.invert = opts.invertX || opts.invert || false; + state.y.invert = opts.invertY || opts.invert || false; + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var isChange = false; + var computed = { + x: null, + y: null + }; + + Object.keys(data).forEach(function(axis) { + var value = data[axis]; + var sensor = state[axis]; + + // Set the internal ADC reading value... + sensor.value = value; + + if (!state[axis].calibrated) { + state[axis].calibrated = true; + state[axis].zeroV = value; + isChange = true; + } + + // ... Get the computed axis value. + computed[axis] = this[axis]; + + var absAxis = Math.abs(computed[axis]); + var absPAxis = Math.abs(sensor.previous); + + if ((absAxis < absPAxis - this.threshold) || + (absAxis > absPAxis + this.threshold)) { + isChange = true; + } + + sensor.previous = computed[axis]; + }, this); + + this.emit("data", { + x: computed.x, + y: computed.y + }); + + if (isChange) { + this.emit("change", { + x: computed.x, + y: computed.y + }); + } + }.bind(this)); + } + + Object.defineProperties(this, { + x: { + get: function() { + return this.toAxis(state.x.value, "x") * (state.x.invert ? -1 : 1); + } + }, + y: { + get: function() { + return this.toAxis(state.y.value, "y") * (state.y.invert ? -1 : 1); + } + } + }); +} + +util.inherits(Joystick, Emitter); + +module.exports = Joystick; diff --git a/JavaScript/node_modules/johnny-five/lib/keypad.js b/JavaScript/node_modules/johnny-five/lib/keypad.js new file mode 100644 index 0000000..bef901a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/keypad.js @@ -0,0 +1,349 @@ +var Emitter = require("events").EventEmitter; +var util = require("util"); +var Board = require("../lib/board.js"); +var __ = require("../lib/fn.js"); +var int16 = __.int16; + +var priv = new Map(); + +var aliases = { + down: ["down", "press", "tap", "impact", "hit"], + up: ["up", "release"], + hold: ["hold"] +}; + +var trigger = function(key, value) { + var event = { which: value, timestamp: Date.now() }; + aliases[key].forEach(function(type) { + this.emit(type, event); + }, this); +}; + + +function flatKeys(opts) { + var keys = []; + + if (opts.keys && Array.isArray(opts.keys)) { + keys = opts.keys.slice(); + + if (keys.every(Array.isArray)) { + keys = keys.reduce(function(accum, row) { + return accum.concat(row); + }, []); + } + } + + return keys; +} + +// TODO: +// +// Provide a mechanism for explicitly naming aliases for buttons +// +// +var Controllers = { + MPR121QR2: { + REGISTER: { + value: require("../lib/definitions/mpr121.js") + }, + initialize: { + value: function(opts, dataHandler) { + + var state = priv.get(this); + var address = opts.address || 0x5A; + var keys = flatKeys(opts); + var keyMap = this.REGISTER.MAPS[opts.controller].KEYS; + var targets = this.REGISTER.MAPS[opts.controller].TARGETS; + var mapping = Object.keys(keyMap).reduce(function(accum, index) { + accum[index] = keyMap[index]; + return accum; + }, []); + + var length = mapping.length; + + this.io.i2cConfig(); + + this.io.i2cWrite(address, this.REGISTER.MHD_RISING, 0x01); + this.io.i2cWrite(address, this.REGISTER.NHD_AMOUNT_RISING, 0x01); + this.io.i2cWrite(address, this.REGISTER.NCL_RISING, 0x00); + this.io.i2cWrite(address, this.REGISTER.FDL_RISING, 0x00); + + this.io.i2cWrite(address, this.REGISTER.MHD_FALLING, 0x01); + this.io.i2cWrite(address, this.REGISTER.NHD_AMOUNT_FALLING, 0x01); + this.io.i2cWrite(address, this.REGISTER.NCL_FALLING, 0xFF); + this.io.i2cWrite(address, this.REGISTER.FDL_FALLING, 0x02); + + for (var i = 0; i < 12; i++) { + this.io.i2cWrite(address, this.REGISTER.ELE0_TOUCH_THRESHOLD + (i << 1), 40); + this.io.i2cWrite(address, this.REGISTER.ELE0_RELEASE_THRESHOLD + (i << 1), 20); + } + + this.io.i2cWrite(address, this.REGISTER.FILTER_CONFIG, 0x04); + this.io.i2cWrite(address, this.REGISTER.ELECTRODE_CONFIG, 0x0C); + + + if (!keys.length) { + keys = Array.from(Object.assign({}, keyMap, {length: length})); + } + + state.length = length; + state.touches = touches(length); + state.keys = keys; + state.mapping = mapping; + state.targets = targets; + + this.io.i2cRead(address, 0x00, 2, function(bytes) { + dataHandler(int16(bytes[1], bytes[0])); + }); + } + }, + toAlias: { + value: function(index) { + var state = priv.get(this); + return state.keys[index]; + } + }, + toIndex: { + value: function(raw) { + var state = priv.get(this); + // console.log("raw", raw, state.targets[raw]); + return state.targets[raw]; + } + } + }, + + // https://learn.sparkfun.com/tutorials/vkey-voltage-keypad-hookup-guide + VKEY: { + initialize: { + value: function(opts, dataHandler) { + + var state = priv.get(this); + var keys = flatKeys(opts); + var mapping = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; + var length = 0; + + if (!keys.length) { + keys = mapping; + } + + length = mapping.length; + + state.length = length; + state.scale = { bottom: 17, step: 40, top: 496 }; + state.touches = touches(length); + state.mapping = mapping; + state.keys = keys; + + this.io.pinMode(this.pin, this.io.MODES.ANALOG); + this.io.analogRead(this.pin, function(adc) { + dataHandler(adc); + }.bind(this)); + }, + }, + toAlias: { + value: function(index) { + var state = priv.get(this); + return state.keys[index]; + } + }, + toIndex: { + value: function(raw) { + var state = priv.get(this); + var scale = state.scale; + var length = state.length; + + if (raw < scale.bottom || raw > scale.top) { + return null; + } + + return (length - ((raw - scale.bottom) / scale.step)) | 0; + } + } + }, + + // WaveShare AD + // - http://www.amazon.com/WaveShare-Accessory-buttons-controlled-keyboard/dp/B00KM6UXVS + // - http://www.wvshare.com/product/A_D-Keypad.htm + // + // TODO: Create docs to show how to create a DIY keypad + // that works with this class. + // + ANALOG: { + initialize: { + value: function(opts, dataHandler) { + + var keys = flatKeys(opts); + var mapping = []; + var length = 0; + + if (opts.length && !keys.length) { + keys = Array.from({ length: opts.length }, function(_, key) { + return key; + }); + } + + if (!keys.length) { + throw new Error( + "Missing `keys`. Analog Keypad requires either a numeric `length` or a `keys` array." + ); + } + + mapping = keys; + length = mapping.length; + + var state = priv.get(this); + // keys + Idle state == length + 1 + var total = length + 1; + var vrange = Math.round(1023 / total); + var ranges = Array.from({ length: total }, function(_, index) { + var start = vrange * index; + return Array.from({ length: vrange - 1 }, function(_, index) { + return start + index; + }); + }); + + state.length = length; + state.ranges = ranges; + state.touches = touches(length); + state.mapping = mapping; + state.keys = keys; + + this.io.pinMode(this.pin, this.io.MODES.ANALOG); + this.io.analogRead(this.pin, function(adc) { + dataHandler(adc); + }); + } + }, + toAlias: { + value: function(index) { + var state = priv.get(this); + return state.keys[index]; + } + }, + toIndex: { + value: function(raw) { + var state = priv.get(this); + var ranges = state.ranges; + var index = ranges.findIndex(function(range) { + return range.includes(raw); + }); + + if (index === state.length) { + index--; + } + + if (index < 0) { + return null; + } + + return index; + } + } + } +}; + + +// Otherwise known as... +Controllers["MPR121"] = Controllers.MPR121QR2; + +function touches(length) { + return Array.from({ length: length }, function() { + return 0; + }); +} + +function Keypad(opts) { + + if (!(this instanceof Keypad)) { + return new Keypad(opts); + } + + // Initialize a Device instance on a Board + Board.Device.call( + this, opts = Board.Options(opts) + ); + + var raw = null; + var controller = null; + var state = { + touches: null, + timeout: null, + length: null, + keys: null, + mapping: null, + holdtime: null, + }; + + + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers.ANALOG; + } + + Object.defineProperties(this, controller); + + state.holdtime = opts.holdtime ? opts.holdtime : 500; + + priv.set(this, state); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + var target = this.toIndex(data); + var length = state.length; + var alias = null; + + raw = data; + + for (var i = 0; i < length; i++) { + alias = this.toAlias(i); + + if (target === i) { + if (state.touches[i] === 0) { + + state.timeout = Date.now() + state.holdtime; + trigger.call(this, "down", alias); + + } else if (state.touches[i] === 1) { + if (state.timeout !== null && Date.now() > state.timeout) { + state.timeout = Date.now() + state.holdtime; + trigger.call(this, "hold", alias); + } + } + + state.touches[i] = 1; + } else { + if (state.touches[i] === 1) { + state.timeout = null; + trigger.call(this, "up", alias); + } + + state.touches[i] = 0; + } + alias = null; + } + }.bind(this)); + } + + Object.defineProperties(this, { + value: { + get: function() { + return raw; + } + }, + target: { + get: function() { + return state.keys[this.toIndex(this.value)]; + } + } + }); +} + +util.inherits(Keypad, Emitter); + +module.exports = Keypad; diff --git a/JavaScript/node_modules/johnny-five/lib/lcd-chars.js b/JavaScript/node_modules/johnny-five/lib/lcd-chars.js new file mode 100644 index 0000000..c01a452 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/lcd-chars.js @@ -0,0 +1,120 @@ +// http://www.quinapalus.com/hd44780udg.html +// http://www.darreltaylor.com/files/CustChar.htm + +module.exports = { + DEFAULT: { + "0": [0xe, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0xe], + "1": [0x2, 0x6, 0xe, 0x6, 0x6, 0x6, 0x6], + "2": [0xe, 0x1b, 0x3, 0x6, 0xc, 0x18, 0x1f], + "3": [0xe, 0x1b, 0x3, 0xe, 0x3, 0x1b, 0xe], + "4": [0x3, 0x7, 0xf, 0x1b, 0x1f, 0x3, 0x3], + "5": [0x1f, 0x18, 0x1e, 0x3, 0x3, 0x1b, 0xe], + "6": [0xe, 0x1b, 0x18, 0x1e, 0x1b, 0x1b, 0xe], + "7": [0x1f, 0x3, 0x6, 0xc, 0xc, 0xc, 0xc], + "8": [0xe, 0x1b, 0x1b, 0xe, 0x1b, 0x1b, 0xe], + "9": [0xe, 0x1b, 0x1b, 0xf, 0x3, 0x1b, 0xe], + "10": [0x17, 0x15, 0x15, 0x15, 0x17, 0x0, 0x1f], + "11": [0xa, 0xa, 0xa, 0xa, 0xa, 0x0, 0x1f], + "12": [0x17, 0x11, 0x17, 0x14, 0x17, 0x0, 0x1f], + "13": [0x17, 0x11, 0x13, 0x11, 0x17, 0x0, 0x1f], + "14": [0x15, 0x15, 0x17, 0x11, 0x11, 0x0, 0x1f], + "15": [0x17, 0x14, 0x17, 0x11, 0x17, 0x0, 0x1f], + "16": [0x17, 0x14, 0x17, 0x15, 0x17, 0x0, 0x1f], + "17": [0x17, 0x11, 0x12, 0x12, 0x12, 0x0, 0x1f], + "18": [0x17, 0x15, 0x17, 0x15, 0x17, 0x0, 0x1f], + "19": [0x17, 0x15, 0x17, 0x11, 0x17, 0x0, 0x1f], + circle: [0x0, 0xe, 0x11, 0x11, 0x11, 0xe, 0x0], + cdot: [0x0, 0xe, 0x11, 0x15, 0x11, 0xe, 0x0], + donut: [0x0, 0xe, 0x1f, 0x1b, 0x1f, 0xe, 0x0], + ball: [0x0, 0xe, 0x1f, 0x1f, 0x1f, 0xe, 0x0], + + square: [0x0, 0x1f, 0x11, 0x11, 0x11, 0x1f, 0x0], + sdot: [0x0, 0x1f, 0x11, 0x15, 0x11, 0x1f, 0x0], + fbox: [0x0, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0], + sbox: [0x0, 0x0, 0xe, 0xa, 0xe, 0x0, 0x0], + sfbox: [0x0, 0x0, 0xe, 0xe, 0xe, 0x0, 0x0], + bigpointerright: [0x8, 0xc, 0xa, 0x9, 0xa, 0xc, 0x8], + bigpointerleft: [0x2, 0x6, 0xa, 0x12, 0xa, 0x6, 0x2], + arrowright: [0x8, 0xc, 0xa, 0x9, 0xa, 0xc, 0x8], + arrowleft: [0x2, 0x6, 0xa, 0x12, 0xa, 0x6, 0x2], + ascprogress1: [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10], + ascprogress2: [0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18], + ascprogress3: [0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c], + ascprogress4: [0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e], + fullprogress: [0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f], + descprogress1: [1, 1, 1, 1, 1, 1, 1, 1], + descprogress2: [3, 3, 3, 3, 3, 3, 3, 3], + descprogress3: [7, 7, 7, 7, 7, 7, 7, 7], + descprogress4: [15, 15, 15, 15, 15, 15, 15, 15], + ascchart1: [31, 0, 0, 0, 0, 0, 0, 0], + ascchart2: [31, 31, 0, 0, 0, 0, 0, 0], + ascchart3: [31, 31, 31, 0, 0, 0, 0, 0], + ascchart4: [31, 31, 31, 31, 0, 0, 0, 0], + ascchart5: [31, 31, 31, 31, 31, 0, 0, 0], + ascchart6: [31, 31, 31, 31, 31, 31, 0, 0], + ascchart7: [31, 31, 31, 31, 31, 31, 31, 0], + descchart1: [0, 0, 0, 0, 0, 0, 0, 31], + descchart2: [0, 0, 0, 0, 0, 0, 31, 31], + descchart3: [0, 0, 0, 0, 0, 31, 31, 31], + descchart4: [0, 0, 0, 0, 31, 31, 31, 31], + descchart5: [0, 0, 0, 31, 31, 31, 31, 31], + descchart6: [0, 0, 31, 31, 31, 31, 31, 31], + descchart7: [0, 31, 31, 31, 31, 31, 31, 31], + borderleft1: [1, 1, 1, 1, 1, 1, 1, 1], + borderleft2: [3, 2, 2, 2, 2, 2, 2, 3], + borderleft3: [7, 4, 4, 4, 4, 4, 4, 7], + borderleft4: [15, 8, 8, 8, 8, 8, 8, 15], + borderleft5: [31, 16, 16, 16, 16, 16, 16, 31], + bordertopbottom5: [31, 0, 0, 0, 0, 0, 0, 31], + borderright1: [16, 16, 16, 16, 16, 16, 16, 16], + borderright2: [24, 8, 8, 8, 8, 8, 8, 24], + borderright3: [28, 4, 4, 4, 4, 4, 4, 28], + borderright4: [30, 2, 2, 2, 2, 2, 2, 30], + borderright5: [31, 1, 1, 1, 1, 1, 1, 31], + box1: [3, 3, 3, 0, 0, 0, 0], + box2: [24, 24, 24, 0, 0, 0, 0], + box3: [27, 27, 27, 0, 0, 0, 0], + box4: [0, 0, 0, 0, 3, 3, 3], + box5: [3, 3, 3, 0, 3, 3, 3], + box6: [24, 24, 24, 0, 3, 3, 3], + box7: [27, 27, 27, 0, 3, 3, 3], + box8: [0, 0, 0, 0, 24, 24, 24], + box9: [3, 3, 3, 0, 24, 24, 24], + box10: [24, 24, 24, 0, 24, 24, 24], + box11: [27, 27, 27, 0, 24, 24, 24], + box12: [0, 0, 0, 0, 27, 27, 27], + box13: [3, 3, 3, 0, 27, 27, 27], + box14: [24, 24, 24, 0, 27, 27, 27], + box15: [27, 27, 27, 0, 27, 27, 27], + euro: [3, 4, 30, 8, 30, 8, 7], + cent: [0, 0, 14, 17, 16, 21, 14, 8], + speaker: [1, 3, 15, 15, 15, 3, 1], + sound: [8, 16, 0, 24, 0, 16, 8], + x: [0, 27, 14, 4, 14, 27, 0], + target: [0, 10, 17, 21, 17, 10, 0], + pointerright: [0, 8, 12, 14, 12, 8, 0], + pointerup: [0, 0, 4, 14, 31, 0, 0], + pointerleft: [0, 2, 6, 14, 6, 2, 0], + pointerdown: [0, 0, 31, 14, 4, 0, 0], + arrowne: [0, 15, 3, 5, 9, 16, 0], + arrownw: [0, 30, 24, 20, 18, 1, 0], + arrowsw: [0, 1, 18, 20, 24, 30, 0], + arrowse: [0, 16, 9, 5, 3, 15, 0], + dice1: [0, 0, 0, 4, 0, 0, 0], + dice2: [0, 16, 0, 0, 0, 1, 0], + dice3: [0, 16, 0, 4, 0, 1, 0], + dice4: [0, 17, 0, 0, 0, 17, 0], + dice5: [0, 17, 0, 4, 0, 17, 0], + dice6: [0, 17, 0, 17, 0, 17, 0], + bell: [4, 14, 14, 14, 31, 0, 4], + smile: [0, 10, 0, 17, 14, 0, 0], + note: [2, 3, 2, 14, 30, 12, 0], + clock: [0, 14, 21, 23, 17, 14, 0], + heart: [0, 10, 31, 31, 31, 14, 4, 0], + duck: [0, 12, 29, 15, 15, 6, 0], + check: [0, 1, 3, 22, 28, 8, 0], + retarrow: [1, 1, 5, 9, 31, 8, 4], + runninga: [6, 6, 5, 14, 20, 4, 10, 17], + runningb: [6, 6, 4, 14, 14, 4, 10, 10] + } +}; diff --git a/JavaScript/node_modules/johnny-five/lib/lcd.js b/JavaScript/node_modules/johnny-five/lib/lcd.js new file mode 100644 index 0000000..a39c88f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/lcd.js @@ -0,0 +1,970 @@ +var Board = require("../lib/board.js"), + Pin = require("../lib/pin.js"), + lcdCharacters = require("../lib/lcd-chars.js"), + converter = require("color-convert")(); + +var priv = new Map(); + +/** + * This atrocitity is unfortunately necessary. + * If any other approach can be found, patches + * will gratefully be accepted. + */ +function sleep(ms) { + var start = Date.now(); + while (Date.now() < start + ms) {} +} + + +// Ported from https://bitbucket.org/fmalpartida/new-liquidcrystal +function Expander(address, io) { + this.address = address; + this.mask = 0xFF; + this.shadow = 0x00; + this.io = io; + this.io.i2cConfig(); +} + +Expander.prototype.pinMode = function(pin, dir) { + if (dir === 0x01) { + this.mask &= ~(1 << pin); + } else { + this.mask |= 1 << pin; + } +}; + +Expander.prototype.portMode = function(dir) { + this.mask = dir === 0x00 ? 0xFF : 0x00; +}; + +Expander.prototype.write = function(value) { + this.shadow = value & ~(this.mask); + this.io.i2cWrite(this.address, this.shadow); +}; + + + + +// const-caps throughout serve to indicate the +// "const-ness" of the binding to the reader +// and nothing more. + +var OPS = { + DEFAULT: { + CLEAR: 0x01, + HOME: 0x02, + ENTRY: 0x04, + DISPLAY: 0x08, + DIMENSIONS: 0x20, + CURSORSHIFT: 0x10, + + SETCGRAMADDR: 0x40, + SETDDRAMADDR: 0x80, + + // Command And Control + + DATA: 0x40, + COMMAND: 0x80, + + // flags for display entry mode + ENTRYRIGHT: 0x00, + ENTRYLEFT: 0x02, + ENTRYSHIFTINCREMENT: 0x01, + ENTRYSHIFTDECREMENT: 0x00, + + // flags for display on/off control + DISPLAYON: 0x04, + DISPLAYOFF: 0x00, + CURSORON: 0x02, + CURSOROFF: 0x00, + BLINKON: 0x01, + BLINKOFF: 0x00, + + // flags for display/cursor shift + DISPLAYMOVE: 0x08, + CURSORMOVE: 0x00, + MOVERIGHT: 0x04, + MOVELEFT: 0x00, + + // flags for function set + BITMODE: { + 4: 0x00, + 8: 0x10, + }, + + LINE: { + 1: 0x00, + 2: 0x08 + }, + + DOTS: { + "5x10": 0x04, + "5x8": 0x00 + }, + + // flags for backlight control + BACKLIGHT_ON: 0x08, + BACKLIGHT_OFF: 0x00, + + MEMORYLIMIT: 0x08, + + // Control + // Enable + EN: 0x04, + // Read/Write + RW: 0x02, + // Register Select + RS: 0x01, + + // DATA + D4: 0x04, + D5: 0x05, + D6: 0x06, + D7: 0x07, + } +}; + +var Controllers = { + JHD1313M1: { + OP: { + value: OPS.DEFAULT, + }, + CHARS: { + value: lcdCharacters.DEFAULT, + }, + initialize: { + value: function(opts) { + + this.io.i2cConfig(); + + this.lines = opts.lines || 2; + this.rows = opts.rows || 2; + this.cols = opts.cols || 16; + this.dots = opts.dots || "5x8"; + + // LCD: 0x3E + // RGB: 0x62 + this.address = { + lcd: opts.address || 0x3E, + rgb: 0x62 + }; + + var display = this.OP.DISPLAY | this.OP.DISPLAYON | this.OP.CURSOROFF | this.OP.BLINKOFF; + + var state = { + display: display, + characters: {}, + index: this.OP.MEMORYLIMIT - 1, + backlight: { + polarity: 1, + pin: null, + value: null + } + }; + + priv.set(this, state); + + // Operations within the following labelled block are init-only, + // but _do_ block the process negligible number of milliseconds. + blocking: { + var lines = this.OP.DIMENSIONS | this.OP.LINE[2]; + // Copied from Grove Studio lib. + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! + // according to datasheet, we need at least 40ms after + // power rises above 2.7V before sending commands. + // Arduino can turn on way befer 4.5V so we'll wait 50 + + + + sleep(50); + this.command(lines); + sleep(5); + this.command(lines); + this.command(lines); + this.command(lines); + sleep(5); + + this.command( + this.OP.ENTRY | + this.OP.ENTRYLEFT | + this.OP.ENTRYSHIFTDECREMENT + ); + + this.on(); + this.clear(); + this.home(); + } + + // Backlight initialization + this.io.i2cWrite(this.address.rgb, [ 0, 0 ]); + this.io.i2cWrite(this.address.rgb, [ 1, 0 ]); + this.io.i2cWrite(this.address.rgb, [ 0x08, 0xAA ]); + + this.bgColor(opts.color || "white"); + }, + }, + clear: { + value: function() { + return this.command(this.OP.CLEAR); + } + }, + setCursor: { + value: function(col, row) { + return this.command(row === 0 ? col | 0x80 : col | 0xc0); + } + }, + bgColor: { + value: function(r, g, b) { + var rgb = [r, g, b]; + if (arguments.length === 1 && typeof r === "string") { + rgb = converter.keyword(r).rgb(); + } + + [0x04, 0x03, 0x02].forEach(function(cmd, i) { + this.io.i2cWrite(this.address.rgb, [ cmd, rgb[i] ]); + }, this); + + return this; + } + }, + command: { + value: function(mode, value) { + if (arguments.length === 1) { + value = mode; + mode = this.OP.COMMAND; + } + + if (mode === this.OP.DATA) { + return this.send(value); + } + + return this.writeBits(this.OP.COMMAND, value); + } + }, + send: { + value: function(value) { + return this.writeBits(this.OP.DATA, value); + } + }, + writeBits: { + value: function(mode, value) { + this.io.i2cWrite(this.address.lcd, [ mode, value ]); + return this; + } + }, + hilo: { + value: function(callback) { + callback.call(this); + } + }, + }, + + + PCF8574: { + + OP: { + value: Object.assign({}, OPS.DEFAULT, { + COMMAND: 0x00, + DATA: 0x01, + BACKLIGHT_ON: 0xFF, + BACKLIGHT_OFF: 0X00 + }), + }, + CHARS: { + value: lcdCharacters.DEFAULT, + }, + initialize: { + value: function(opts) { + + this.io.i2cConfig(); + + this.bitMode = opts.bitMode || 4; + this.lines = opts.lines || 2; + this.rows = opts.rows || 2; + this.cols = opts.cols || 16; + this.dots = opts.dots || "5x8"; + + if (!opts.address) { + opts.address = ["PCF8574A", "PCF8574AT"].includes(opts.controller) ? + 0x3F : 0x27; + + /* + | A2 | A1 | A0 | PCF8574(T) | PCF8574A(T) | + |----|----|----|---------|----------| + | L | L | L | 0x20 | 0x38 | + | L | L | H | 0x21 | 0x39 | + | L | H | L | 0x22 | 0x3A | + | L | H | H | 0x23 | 0x3B | + | H | L | L | 0x24 | 0x3C | + | H | L | H | 0x25 | 0x3D | + | H | H | L | 0x26 | 0x3E | + | H | H | H | 0x27 | 0x3F | + + TODO: move to API docs + */ + } + + this.address = { + lcd: opts.address + }; + + // Ported from https://bitbucket.org/fmalpartida/new-liquidcrystal + this.expander = new Expander(this.address.lcd, this.io); + this.expander.portMode(this.io.MODES.OUTPUT); + this.expander.write(0); + + var backlight = opts.backlight || { + polarity: 0, + pin: 3 + }; + + backlight.pin = typeof backlight.pin === "undefined" ? 3 : backlight.pin; + backlight.polarity = typeof backlight.polarity === "undefined" ? 0 : backlight.polarity; + + var dimensions = this.OP.BITMODE[this.bitMode] | + this.OP.LINE[this.lines] | + this.OP.DOTS[this.dots]; + + var display = this.OP.DISPLAY | + this.OP.DISPLAYON | + this.OP.CURSOROFF | + this.OP.BLINKOFF; + + var entry = this.OP.ENTRYLEFT | + this.OP.ENTRYSHIFTDECREMENT; + + + var state = { + display: display, + characters: {}, + index: this.OP.MEMORYLIMIT - 1, + backlight: { + polarity: backlight.polarity, + pinMask: 1 << backlight.pin, + statusMask: 0x00 + }, + data: [ + 1 << this.OP.D4, + 1 << this.OP.D5, + 1 << this.OP.D6, + 1 << this.OP.D7 + ] + }; + + priv.set(this, state); + + // Operations within the following labelled block are init-only, + // but _do_ block the process for negligible number of milliseconds. + blocking: { + // + // Toggle wrte/pulse to reset the LCD component. + // + this.expander.write(0x03 << 4); + this.pulse(0x03 << 4); + sleep(4); + + this.expander.write(0x03 << 4); + this.pulse(0x03 << 4); + sleep(4); + + this.expander.write(0x03 << 4); + this.pulse(0x03 << 4); + + this.expander.write(0x02 << 4); + this.pulse(0x02 << 4); + + // Initialize the reset component + this.command(this.OP.DIMENSIONS | dimensions); + this.on(); + this.clear(); + + this.command(this.OP.ENTRY | entry); + this.backlight(); + } + }, + }, + clear: { + value: function() { + this.command(this.OP.CLEAR); + sleep(2); + return this; + + } + }, + backlight: { + value: function(value) { + var state = priv.get(this); + var mask; + + value = typeof value === "undefined" ? 255 : value; + + if (state.backlight.pinMask !== 0x00) { + if ((state.backlight.polarity === 0 && value > 0) || + (state.backlight.polarity === 1 && value === 0)) { + + mask = 0xFF; + } else { + mask = 0x00; + } + + state.backlight.statusMask = state.backlight.pinMask & mask; + + this.expander.write(state.backlight.statusMask); + } + + return this; + } + }, + + createChar: { + value: function(name, charMap) { + var state = priv.get(this); + var address; + + if (typeof name === "number") { + address = name & 0x07; + } else { + address = state.index; + state.index--; + if (state.index === -1) { + state.index = this.OP.MEMORYLIMIT - 1; + } + } + + this.command(this.OP.SETCGRAMADDR | (address << 3)); + + blocking: { + sleep(1); + + for (var i = 0; i < 8; i++) { + this.command(this.OP.DATA, charMap[i]); + sleep(1); + } + } + + state.characters[name] = address; + + return address; + } + }, + noBacklight: { + value: function() { + this.backlight(0); + } + }, + hilo: { + value: function(callback) { + callback.call(this); + } + }, + command: { + value: function(mode, value) { + + if (arguments.length === 1) { + value = mode; + mode = this.OP.COMMAND; + } + + this.send(mode, value); + + return this; + } + }, + send: { + writable: true, + value: function(mode, value) { + + this.writeBits(mode, value >> 4); + this.writeBits(mode, value & 0x0F); + + return this; + } + }, + writeBits: { + writable: true, + value: function(mode, value) { + var state = priv.get(this); + var pinMapValue = 0; + + for (var i = 0; i < 4; i++) { + if ((value & 0x01) === 1) { + pinMapValue |= state.data[i]; + } + value = (value >> 1); + } + + if (mode === this.OP.DATA) { + mode = this.OP.RS; + } + + pinMapValue |= mode | state.backlight.statusMask; + + this.pulse(pinMapValue); + return this; + } + }, + pulse: { + writable: true, + value: function(data) { + this.expander.write(data | this.OP.EN); // En HIGH + this.expander.write(data & ~this.OP.EN); // En LOW + } + } + }, + + + PARALLEL: { + OP: { + value: OPS.DEFAULT, + }, + CHARS: { + value: lcdCharacters.DEFAULT, + }, + initialize: { + value: function(opts) { + + this.bitMode = opts.bitMode || 4; + this.lines = opts.lines || 2; + this.rows = opts.rows || 2; + this.cols = opts.cols || 16; + this.dots = opts.dots || "5x8"; + + if (Array.isArray(opts.pins)) { + this.pins = { + rs: opts.pins[0], + en: opts.pins[1], + // TODO: Move to device map profile + data: [ + opts.pins[5], + opts.pins[4], + opts.pins[3], + opts.pins[2] + ] + }; + } else { + this.pins = opts.pins; + } + + var display = this.OP.DISPLAY | this.OP.DISPLAYON; + var state = { + display: display, + characters: {}, + index: this.OP.MEMORYLIMIT - 1, + backlight: { + polarity: 1, + pin: null, + value: null + } + }; + + priv.set(this, state); + + opts.pins.forEach(function(pin) { + this.io.pinMode(pin, 1); + }, this); + + this.io.digitalWrite(this.pins.rs, this.io.LOW); + this.io.digitalWrite(this.pins.en, this.io.LOW); + + if (opts.backlight) { + if (typeof opts.backlight === "number") { + var temp = opts.backlight; + opts.backlight = { + pin: temp + }; + } + + if (opts.backlight.pin) { + state.backlight.pin = new Pin({ + pin: opts.backlight.pin, + board: this.board + }); + + state.backlight.pin.high(); + } + } + + // Operations within the following labelled block are init-only, + // but _do_ block the process negligible number of milliseconds. + blocking: { + // Send 0011 thrice to make sure LCD + // is initialized properly + this.command(0x03); + sleep(4); + this.command(0x03); + sleep(4); + this.command(0x03); + + // Switch to 4-bit mode + if (this.bitMode === 4) { + // this.OP.DIMENSIONS | + this.command(0x02); + } + + // Set number of lines and dots + // TODO: Move to device map profile + this.command( + + this.OP.LINE[this.lines] | + this.OP.DOTS[this.dots] + ); + + // Clear display and turn it on + this.command(display); + this.clear(); + this.home(); + } + } + } + } +}; + + +// Alias controllers +Controllers.HD44780 = Controllers.JHD1313M1; + + +Controllers.LCM1602 = Controllers.LCD1602 = Controllers.LCM1602IIC = Controllers.LCD2004 = Controllers.PCF8574A = Controllers.PCF8574AT = Controllers.PCF8574T = Controllers.PCF8574; + + + +/** + * LCD + * @param {[type]} opts [description] + */ + +function LCD(opts) { + + if (!(this instanceof LCD)) { + return new LCD(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + var controller; + + if (opts.controller) { + controller = typeof opts.controller === "string" ? + Controllers[opts.controller.toUpperCase()] : + opts.controller; + } + + if (!controller) { + controller = Controllers.PARALLEL; + } + + Object.defineProperties(this, controller); + + this.ctype = opts.controller; + + if (this.initialize) { + this.initialize(opts); + } +} + +LCD.prototype.command = function(mode, value) { + if (typeof value === "undefined") { + value = mode; + mode = 0x80; + } + + if (this.bitMode === 4) { + this.send(value >> 4); + } + + this.send(value); + + return this; +}; + +LCD.prototype.send = function(value) { + var pin = 0; + var mask = { + 4: 8, + 8: 128 + }[this.bitMode]; + + for (; mask > 0; mask = mask >> 1) { + this.io.digitalWrite( + this.pins.data[pin], + this.io[value & mask ? "HIGH" : "LOW"] + ); + pin++; + } + + ["LOW", "HIGH", "LOW"].forEach(function(val) { + this.io.digitalWrite(this.pins.en, this.io[val]); + }, this); + + return this; +}; + +LCD.prototype.hilo = function(callback) { + // RS High for write mode + this.io.digitalWrite(this.pins.rs, this.io.HIGH); + + callback.call(this); + + // RS Low for command mode + this.io.digitalWrite(this.pins.rs, this.io.LOW); +}; + + + +var RE_SPECIALS = /:(\w+):/g; + +LCD.prototype.print = function(message, opts) { + var state, dontProcessSpecials, hasCharacters, processed; + + message = message + ""; + opts = opts || {}; + + state = priv.get(this); + dontProcessSpecials = opts.dontProcessSpecials || false; + hasCharacters = !dontProcessSpecials && RE_SPECIALS.test(message); + + if (message.length === 1) { + this.hilo(function() { + this.command(this.OP.DATA, message.charCodeAt(0)); + }); + } else { + + if (hasCharacters) { + processed = message.replace(RE_SPECIALS, function(match, name) { + var address = state.characters[name]; + + return typeof address === "number" ? String.fromCharCode(address) : match; + }); + + this.print(processed, { + dontProcessSpecials: true + }); + } else { + this.hilo(function() { + Array.from(message).forEach(function(character) { + this.command(this.OP.DATA, character.charCodeAt(0)); + }, this); + // var char; + + // while ((char = chars[k++])) { + // this.command(this.OP.DATA, char.charCodeAt(0)); + // } + }); + } + } + + return this; +}; + +LCD.prototype.write = function(charCode) { + this.hilo.call(this, function() { + this.command(this.OP.DATA, charCode); + }); + + return this; +}; + +LCD.prototype.clear = function() { + this.command(this.OP.CLEAR); + sleep(2); + return this; +}; + +LCD.prototype.home = function() { + this.command(this.OP.HOME); + sleep(2); + return this; +}; + +LCD.prototype.setCursor = function(col, row) { + var rowOffsets = [0x00, 0x40, 0x14, 0x54]; + this.command(this.OP.SETDDRAMADDR | (col + rowOffsets[row])); + return this; +}; + +LCD.prototype.backlight = function(highOrLow) { + var state = priv.get(this); + + highOrLow = typeof highOrLow === "undefined" ? true : false; + + if (state.backlight.pin instanceof Pin) { + if (highOrLow) { + state.backlight.pin.high(); + } else { + state.backlight.pin.low(); + } + } + + if (highOrLow) { + state.display |= this.OP.DISPLAYON; + } else { + state.display &= ~this.OP.DISPLAYON; + } + + this.command(state.display); + + return this; +}; + +LCD.prototype.noBacklight = function() { + var state = priv.get(this); + + if (state.backlight.pin instanceof Pin) { + state.backlight.pin.high(); + } + + // if (highOrLow) { + // state.display |= this.OP.DISPLAYON; + // } else { + // state.display &= ~this.OP.DISPLAYON; + // } + + // this.command(state.display); + + return this.backlight(false); +}; + +LCD.prototype.on = function() { + var state = priv.get(this); + + state.display |= this.OP.DISPLAYON; + this.command(state.display); + + return this; +}; + +LCD.prototype.off = function() { + var state = priv.get(this); + + state.display &= ~this.OP.DISPLAYON; + this.command(state.display); + + return this; +}; + +LCD.prototype.cursor = function(row, col) { + // When provided with col & row, cursor will behave like setCursor, + // except that it has row and col in the order that most people + // intuitively expect it to be in. + if (typeof col !== "undefined" && typeof row !== "undefined") { + return this.setCursor(col, row); + } + var state = priv.get(this); + + state.display |= this.OP.CURSORON; + this.command(state.display); + + return this; +}; + +LCD.prototype.noCursor = function() { + var state = priv.get(this); + + state.display &= ~this.OP.CURSORON; + this.command(state.display); + + return this; +}; + +LCD.prototype.blink = function() { + var state = priv.get(this); + + state.display |= this.OP.BLINKON; + this.command(state.display); + + return this; +}; + +LCD.prototype.noBlink = function() { + var state = priv.get(this); + + state.display &= ~this.OP.BLINKON; + this.command(state.display); + + return this; +}; + +LCD.prototype.autoscroll = function() { + var state = priv.get(this); + + state.display |= this.OP.ENTRYSHIFTINCREMENT; + this.command(this.OP.ENTRY | state.display); + + return this; +}; + +LCD.prototype.noAutoscroll = function() { + var state = priv.get(this); + + state.display &= ~this.OP.ENTRYSHIFTINCREMENT; + this.command(this.OP.ENTRY | state.display); + + return this; +}; + +LCD.prototype.createChar = function(name, charMap) { + // Ensure location is never above 7 + var state = priv.get(this); + var address; + + if (typeof name === "number") { + address = name & 0x07; + } else { + address = state.index; + state.index--; + if (state.index === -1) { + state.index = this.OP.MEMORYLIMIT - 1; + } + } + + this.command(this.OP.SETCGRAMADDR | (address << 3)); + + this.hilo(function() { + for (var i = 0; i < 8; i++) { + this.command(this.OP.DATA, charMap[i]); + } + }); + + // Fill in address + state.characters[name] = address; + + return address; +}; + + +LCD.prototype.useChar = function(name) { + var state = priv.get(this); + + if (!state.characters[name]) { + // Create the character in LCD memory and + // Add character to current LCD character map + state.characters[name] = this.createChar(name, this.CHARS[name]); + } + + return this; +}; + + +/** + * + +TODO: + + +burst() + +scrollDisplayLeft() +scrollDisplayRight() + +leftToRight() +rightToLeft() + + +*/ + +LCD.POSITIVE = 0; +LCD.NEGATIVE = 1; + +module.exports = LCD; diff --git a/JavaScript/node_modules/johnny-five/lib/led/digits.js b/JavaScript/node_modules/johnny-five/lib/led/digits.js new file mode 100644 index 0000000..2d9cc08 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/digits.js @@ -0,0 +1,13 @@ +var LedControl = require("./ledcontrol"); + +// stub implementation; extract functionality from ledcontrol.js +function Digits(opts) { + opts.isMatrix = false; + return new LedControl(opts); +} + +Object.assign(Digits, LedControl, { + CHARS: LedControl.DIGIT_CHARS +}); + +module.exports = Digits; diff --git a/JavaScript/node_modules/johnny-five/lib/led/index.js b/JavaScript/node_modules/johnny-five/lib/led/index.js new file mode 100644 index 0000000..5cb6645 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/index.js @@ -0,0 +1,7 @@ +var Led = require("./led"); +Led.Array = require("./leds"); +Led.RGB = require("./rgb"); +Led.Matrix = require("./matrix"); +Led.Digits = require("./digits"); + +module.exports = Led; diff --git a/JavaScript/node_modules/johnny-five/lib/led/led.js b/JavaScript/node_modules/johnny-five/lib/led/led.js new file mode 100644 index 0000000..e33cefe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/led.js @@ -0,0 +1,485 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../board.js"); +var nanosleep = require("../sleep.js").nano; +var Animation = require("../animation.js"); +var __ = require("../../lib/fn.js"); +var Pins = Board.Pins; + +var priv = new Map(); + +var Controllers = { + PCA9685: { + COMMANDS: { + value: { + PCA9685_MODE1: 0x0, + PCA9685_PRESCALE: 0xFE, + LED0_ON_L: 0x6 + } + }, + initialize: { + value: function(opts) { + + var state = priv.get(this); + + this.address = opts.address || 0x40; + this.pwmRange = opts.pwmRange || [0, 4095]; + + if (!this.board.Drivers[this.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.address] = { + initialized: false + }; + + // Reset + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Sleep + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x10]); + // Set prescalar + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_PRESCALE, 0x70]); + // Wake up + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0xa1]); + + this.board.Drivers[this.address].initialized = true; + } + + this.pin = typeof opts.pin === "undefined" ? 0 : opts.pin; + + state.mode = this.io.MODES.PWM; + } + }, + write: { + value: function() { + + var on, off; + var state = priv.get(this); + var value = state.isAnode ? 255 - Board.constrain(state.value, 0, 255) : state.value; + + on = 0; + off = this.pwmRange[1] * value / 255; + + this.io.i2cWrite(this.address, [this.COMMANDS.LED0_ON_L + 4 * (this.pin), on, on >> 8, off, off >> 8]); + } + } + }, + DEFAULT: { + initialize: { + value: function(opts, pinValue) { + + var state = priv.get(this); + var isFirmata = true; + var defaultLed; + + isFirmata = Pins.isFirmata(this); + + if (isFirmata && typeof pinValue === "string" && pinValue[0] === "A") { + pinValue = this.io.analogPins[+pinValue.slice(1)]; + } + + defaultLed = this.io.defaultLed || 13; + pinValue = +pinValue; + + if (isFirmata && this.io.analogPins.includes(pinValue)) { + this.pin = pinValue; + state.mode = this.io.MODES.OUTPUT; + } else { + this.pin = typeof opts.pin === "undefined" ? defaultLed : opts.pin; + state.mode = this.io.MODES[ + (this.board.pins.isPwm(this.pin) ? "PWM" : "OUTPUT") + ]; + } + + this.io.pinMode(this.pin, state.mode); + } + }, + write: { + value: function() { + var state = priv.get(this); + var value = state.value; + + // If pin is not a PWM pin and brightness is not HIGH or LOW, emit an error + if (value !== this.io.LOW && value !== this.io.HIGH && this.mode !== this.io.MODES.PWM) { + Board.Pins.Error({ + pin: this.pin, + type: "PWM", + via: "Led" + }); + } + + if (state.mode === this.io.MODES.OUTPUT) { + this.io.digitalWrite(this.pin, value); + } + + if (state.mode === this.io.MODES.PWM) { + if (state.isAnode) { + value = 255 - Board.constrain(value, 0, 255); + } + + this.io.analogWrite(this.pin, value); + } + } + } + } +}; + +/** + * Led + * @constructor + * + * five.Led(pin); + * + * five.Led({ + * pin: number + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Led(opts) { + if (!(this instanceof Led)) { + return new Led(opts); + } + + var state; + var controller; + var pinValue = typeof opts === "object" ? opts.pin : opts; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["DEFAULT"]; + } + + Object.defineProperties(this, controller); + + state = { + isOn: false, + isRunning: false, + value: null, + direction: 1, + mode: null, + isAnode: opts.isAnode, + interval: null + }; + + priv.set(this, state); + + Object.defineProperties(this, { + value: { + get: function() { + return state.value; + } + }, + mode: { + get: function() { + return state.mode; + } + }, + isOn: { + get: function() { + return !!state.value; + } + }, + isRunning: { + get: function() { + return state.isRunning; + } + }, + animation: { + get: function() { + return state.animation; + } + } + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, pinValue); + } +} + +/** + * on Turn the led on + * @return {Led} + */ +Led.prototype.on = function() { + var state = priv.get(this); + + if (state.mode === this.io.MODES.OUTPUT) { + state.value = this.io.HIGH; + } + + if (state.mode === this.io.MODES.PWM) { + // Assume we need to simply turn this all the way on, when: + + // ...state.value is null + if (state.value === null) { + state.value = 255; + } + + // ...there is no active interval + if (!state.interval) { + state.value = 255; + } + + // ...the last value was 0 + if (state.value === 0) { + state.value = 255; + } + } + + this.write(); + + return this; +}; + +/** + * off Turn the led off + * @return {Led} + */ +Led.prototype.off = function() { + var state = priv.get(this); + + state.value = 0; + + this.write(); + + return this; +}; + +/** + * toggle Toggle the on/off state of an led + * @return {Led} + */ +Led.prototype.toggle = function() { + return this[this.isOn ? "off" : "on"](); +}; + +/** + * brightness + * @param {Number} value analog brightness value 0-255 + * @return {Led} + */ +Led.prototype.brightness = function(value) { + var state = priv.get(this); + + state.value = value; + + this.write(); + + return this; +}; + +/** + * Animation.normalize + * + * @param [number || object] keyFrames An array of step values or a keyFrame objects + */ + +Led.prototype[Animation.normalize] = function(keyFrames) { + + var state = priv.get(this); + var last = state.value || 0; + + // If user passes null as the first element in keyFrames use current value + if (keyFrames[0] === null) { + keyFrames[0] = { + value: last + }; + } + + keyFrames.forEach(function(keyFrame, i) { + + if (keyFrame !== null) { + // keyFrames that are just numbers represent values + if (typeof keyFrame === "number") { + keyFrames[i] = { + value: keyFrame, + easing: "linear" + }; + } + } + + }); + + return keyFrames; + +}; + +/** + * Animation.render + * + * @position [number] value to set the led to + */ + +Led.prototype[Animation.render] = function(position) { + var state = priv.get(this); + state.value = position[0]; + return this.write(); +}; + +/** + * pulse Fade the Led in and out in a loop with specified time + * @param {number} rate Time in ms that a fade in/out will elapse + * @return {Led} + * + * - or - + * + * @param {Object} val An Animation() segment config object + */ + +Led.prototype.pulse = function(rate, callback) { + var state = priv.get(this); + + var options = { + duration: typeof rate === "number" ? rate : 1000, + keyFrames: [0, 0xff], + metronomic: true, + loop: true, + easing: "inOutSine", + onloop: function() { + if (typeof callback === "function") { + callback(); + } + } + }; + + if (typeof rate === "object") { + __.extend(options, rate); + } + + if (typeof rate === "function") { + callback = rate; + } + + state.isRunning = true; + + state.animation = state.animation || new Animation(this); + state.animation.enqueue(options); + return this; +}; + +/** + * fade Fade an led in and out + * @param {Number} val Analog brightness value 0-255 + * @param {Number} time Time in ms that a fade in/out will elapse + * @return {Led} + * + * - or - + * + * @param {Object} val An Animation() segment config object + */ + +Led.prototype.fade = function(val, time, callback) { + + var state = priv.get(this); + + var options = { + duration: typeof time === "number" ? time : 1000, + keyFrames: [null, typeof val === "number" ? val : 0xff], + easing: "outSine", + oncomplete: function() { + state.isRunning = false; + if (typeof callback === "function") { + callback(); + } + } + }; + + if (typeof val === "object") { + __.extend(options, val); + } + + if (typeof val === "function") { + callback = val; + } + + if (typeof time === "function") { + callback = time; + } + + state.isRunning = true; + + state.animation = state.animation || new Animation(this); + state.animation.enqueue(options); + +}; + +Led.prototype.fadeIn = function(time, callback) { + return this.fade(255, time || 1000, callback); +}; + +Led.prototype.fadeOut = function(time, callback) { + return this.fade(0, time || 1000, callback); +}; + +/** + * strobe + * @param {Number} rate Time in ms to strobe/blink + * @return {Led} + */ +Led.prototype.strobe = function(rate, callback) { + var state = priv.get(this); + + // Avoid traffic jams + if (state.interval) { + clearInterval(state.interval); + } + + if (typeof rate === "function") { + callback = rate; + rate = null; + } + + state.isRunning = true; + + state.interval = setInterval(function() { + this.toggle(); + if (typeof callback === "function") { + callback(); + } + }.bind(this), rate || 100); + + return this; +}; + +Led.prototype.blink = Led.prototype.strobe; + +/** + * stop Stop the led from strobing, pulsing or fading + * @return {Led} + */ +Led.prototype.stop = function() { + var state = priv.get(this); + + clearInterval(state.interval); + + if (state.animation) { + state.animation.stop(); + } + + state.isRunning = false; + + return this; +}; + +if (IS_TEST_MODE) { + Led.purge = function() { + priv.clear(); + }; +} + + +module.exports = Led; diff --git a/JavaScript/node_modules/johnny-five/lib/led/ledcontrol.js b/JavaScript/node_modules/johnny-five/lib/led/ledcontrol.js new file mode 100644 index 0000000..d4d8afd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/ledcontrol.js @@ -0,0 +1,1160 @@ +/* + About the original version of ledcontrol.js: + + This was originally a port by Rebecca Murphey of the LedControl library + and also includes a port of the AdaFruit LEDBackpack library + (MIT License, Copyright (c) 2012 Adafruit Industries) + + The license of the original LedControl library is as follows: + + LedControl.cpp - A library for controling Leds with a MAX7219/MAX7221 + Copyright (c) 2007 Eberhard Fahle + + 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: + + 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. + + */ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../board.js"); + +// Led instance private data +var priv = new Map(), + Controllers; + +function LedControl(opts) { + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + /* + device instance uses an interface from Controllers: + either MAX 7219 (default) or HT16K33 + */ + var controller; + + if (typeof opts.controller === "string") { + controller = Controllers[opts.controller]; + } else { + controller = opts.controller; + } + + if (typeof controller === "undefined") { + controller = Controllers.DEFAULT; + } + + // functions from Controller interface + + this.clear = controller.clear; + this.digit = controller.digit; + this.led = controller.led; + this.print = controller.print; + this.row = controller.row; + this.scanLimit = controller.scanLimit; + this.send = controller.send; + this.initialize = controller.initialize; + + // controller specific op codes + this.OP = controller.OP; + + // extra functions for HT16K33 devices only + if (controller.writeDisplay) { + this.writeDisplay = controller.writeDisplay; + } + if (controller.blink) { + this.blink = controller.blink; + } + /* + devices variable indicates number of connected LED devices + Here's an example of multiple devices: + http://tronixstuff.com/2013/10/11/tutorial-arduino-max7219-led-display-driver-ic/ + */ + var devices = opts.devices || (opts.addresses ? opts.addresses.length : 1); + + // TODO: Store this in priv Map. + this.status = []; + + for (var i = 0; i < 64; i++) { + this.status[i] = 0x00; + } + opts.dims = opts.dims || LedControl.MATRIX_DIMENSIONS["8x8"]; + if (typeof opts.dims === "string") { + opts.dims = LedControl.MATRIX_DIMENSIONS[opts.dims]; + } + if (Array.isArray(opts.dims)) { + opts.dims = { + rows: opts.dims[0], + columns: opts.dims[1], + }; + } + var state = { + devices: devices, + digits: opts.digits || 8, + isMatrix: !!opts.isMatrix, + isBicolor: !!opts.isBicolor, + rows: opts.dims.rows, + columns: opts.dims.columns + }; + + if (!(state.columns === 8 || state.columns === 16) || !(state.rows === 8 || state.rows === 16) || (state.columns + state.rows === 32)) { + throw new Error("Invalid matrix dimensions specified: must be 8x8, 16x8 or 8x16"); + } + + Object.defineProperties(this, { + devices: { + get: function() { + return state.devices; + } + }, + digits: { + get: function() { + return state.digits; + } + }, + isMatrix: { + get: function() { + return state.isMatrix; + } + }, + isBicolor: { + get: function() { + return state.isBicolor; + } + }, + rows: { + get: function() { + return state.rows; + } + }, + columns: { + get: function() { + return state.columns; + } + } + }); + + priv.set(this, state); + controller.initialize.call(this, opts); +} + +LedControl.prototype.each = function(callbackfn) { + for (var i = 0; i < this.devices; i++) { + callbackfn.call(this, i); + } +}; + +LedControl.prototype.on = function(addr) { + if (typeof addr === "undefined") { + this.each(function(device) { + this.on(device); + }); + } else { + this.send(addr, this.OP.SHUTDOWN || LedControl.OP.SHUTDOWN, 1); + } + return this; +}; + +LedControl.prototype.off = function(addr) { + if (typeof addr === "undefined") { + this.each(function(device) { + this.off(device); + }); + } else { + this.send(addr, this.OP.SHUTDOWN || LedControl.OP.SHUTDOWN, 0); + } + return this; +}; + +LedControl.prototype.setLed = function(addr, chr, val, dp) { + console.log("The `setLed` method is deprecated, use `led` instead"); + return this.led(addr, chr, val, dp); +}; + +/* + * brightness + * @param {Number} addr Address of Led device + * @param {Number} val Brightness value + */ +LedControl.prototype.brightness = function(addr, val) { + if (arguments.length === 1) { + val = addr; + this.each(function(device) { + this.brightness(device, val); + }); + } else { + this.send(addr, this.OP.BRIGHTNESS || LedControl.OP.BRIGHTNESS, Board.map(val, 0, 100, 0, 15)); + } + return this; +}; +/** + * column Update an entire column with an 8 or 16 bit value + * @param {Number} addr Device address + * @param {Number} col 0 indexed col number 0-7 + * @param {Number} val 8-bit 0-0xFF (for 8x8 or 16x8 matrix) or 16-bit 0-0xFFFF (for 8x16) value + * @return {LedControl} + */ +LedControl.prototype.column = function(addr, col, value ) { + var state; + if (!this.isMatrix) { + console.log("The `column` method is only supported for Matrix devices"); + } + if (arguments.length === 2) { + value = col; + col = addr; + this.each(function(device) { + this.column(device, col, value); + }); + } else { + for (var row = 0; row < this.rows; row++) { + state = value >> ((this.rows - 1) - row); + state = state & 0x01; + this.led(addr, row, col, state); + } + } + + return this; +}; + +/** + * draw Draw a character + * @param {Number} addr Device address + * @param {Number} chr Character to draw + * + * Used as pass-through to .digit + * + * @param {Number} val 8-bit value 0-255 + * @param {Number} dp ugly + * @return {LedControl} + */ +LedControl.prototype.draw = function(addr, chr) { + // in matrix mode, this takes two arguments: + // addr and the character to display + var character; + + if (arguments.length === 1) { + chr = addr; + this.each(function(device) { + this.draw(device, chr); + }); + } else { + + if (this.isMatrix) { + if (Array.isArray(chr)) { + character = chr; + } else { + character = LedControl.MATRIX_CHARS[chr]; + } + + if (character !== undefined) { + if (character.length !== this.rows && character.length !== this.columns) { + throw new Error("character is invalid: " + character); + } + // pad character to match number of rows suppported by device + var charLength = character.length; + + for (var i = 0; i < (this.rows - charLength); i++) { + character.push(0); + } + + character.forEach(function(rowData, idx) { + this.row(addr, idx, rowData); + }, this); + } + } else { + + // in seven-segment mode, this takes four arguments, which + // are just passed through to digit + this.digit.apply(this, arguments); + } + } + + return this; +}; + +LedControl.prototype.shift = function(addr, direction, distance) { + + if (arguments.length === 2) { + distance = direction; + direction = addr; + this.each(function() { + this.shift(addr, direction, distance); + }); + } else { + + } + + return this; +}; + +LedControl.prototype.char = function(addr, chr, val, dp) { + console.log("The `char` method is deprecated, use `draw` instead"); + + return this.draw(addr, chr, val, dp); +}; + +LedControl.prototype.device = function(addr) { + var bound = {}; + + /* keys from prototype */ + Object.keys(LedControl.prototype).forEach(function(key) { + bound[key] = this[key].bind(this, addr); + }, this); + + /* functions from interface */ + Object.getOwnPropertyNames(this).forEach(function(key) { + if (this[key] && typeof this[key] === "function") { + bound[key] = this[key].bind(this, addr); + } + }, this); + return bound; +}; + +var addresses = new Set([0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77]); + +Controllers = { + HT16K33: { + OP: { + SHUTDOWN: 0x20, + BRIGHTNESS: 0xE0, + BLINK: 0x80 + }, + initialize: function(opts) { + var state = priv.get(this); + var available = Array.from(addresses); + + if (available.length === 0) { + throw new Error("There are no available HT16K33 controller addresses"); + } + + this.addresses = opts.addresses || (opts.address ? [opts.address] : null); + + // use default range of addresses if addresses aren't specified + if (this.addresses === null) { + this.addresses = available.slice(0, state.devices); + } + + this.addresses.forEach(function(address) { + if (!addresses.has(address)) { + throw new Error("Invalid HT16K33 controller address: " + address); + } + addresses.delete(address); + }); + + this.rotation = opts.rotation || 1; + // set a default rotation that works with AdaFruit 16x8 matrix if using 16 columns + if (this.columns === 16 && !opts.rotation) { + this.rotation = 0; + } + this.displaybuffers = []; + for (var i = 0; i < this.rows; i++) { + this.displaybuffers[i] = []; + } + // Set up I2C data connection + this.io.i2cConfig(); + // TODO allow setup to be configured through opts + this.each(function(device) { + this.on(device); + this.blink(device, 1); + this.brightness(device, 100); + this.clear(device); + }); + }, + blink: function(addr, val) { + if (arguments.length === 1) { + val = addr; + this.each(function(device) { + this.brightness(device, val); + }); + } else { + //var BLINK = 0x80; + //this.io.i2cWrite(this.addresses[addr], [BLINK | val]); + this.send(addr, this.OP.BLINK, val); + } + return this; + }, + + /* + * clear + * @param {Number} addr Address of Led device + */ + clear: function(addr) { + var offset; + if (typeof addr === "undefined") { + this.each(function(device) { + this.clear(device); + }); + } else { + offset = addr * this.columns; + + for (var i = 0; i < this.rows; i++) { + this.status[offset + i] = 0; + this.displaybuffers[addr][i] = 0; + } + this.writeDisplay(addr); + } + return this; + }, + digit: function() { + console.log("The digit function is not implemented for HT16K33 devices"); + return this; + }, + /** + * led or setLed Set the status of a single Led. + * + * @param {Number} addr Address of Led + * @param {Number} row Row number of Led (0-7) + * @param {Number} column Column number of Led (0-7) + * @param {Boolean} state [ true: on, false: off ] [ 1, 0 ] or an LedControl color code + * + */ + led: function(addr, row, col, state) { + if (arguments.length === 3) { + state = col; + col = row; + row = addr; + this.each(function(device) { + this.led(device, row, col, state); + }); + } else { + var x = col; + var y = row; + var tmp, rows = this.rows, columns = this.columns; + if ((y < 0) || (y >= rows)) { + return; + } + if ((x < 0) || (x >= columns)) { + return; + } + switch (this.rotation) { + case 1: + columns = this.rows; + rows = this.columns; + tmp = x; + x = y; + y = tmp; + x = columns - x - 1; + break; + case 2: + x = columns - x - 1; + y = rows - y - 1; + break; + case 3: + columns = this.rows; + rows = this.columns; + tmp = x; + x = y; + y = tmp; + y = rows - y - 1; + break; + } + if (!this.isBicolor) { + // x needs to be wrapped around for single color 8x8 AdaFruit matrix + if (columns === 8 && rows === 8) { + x += columns - 1; + x %= columns; + } + if (state) { + this.displaybuffers[addr][y] |= 1 << x; + } else { + this.displaybuffers[addr][y] &= ~(1 << x); + } + } else { + // 8x8 bi-color matrixes only + if (state === LedControl.COLORS.GREEN) { + // Turn on green LED. + this.displaybuffers[addr][y] |= 1 << x; + // Turn off red LED. + this.displaybuffers[addr][y] &= ~(1 << (x + 8)); + } else if (state === LedControl.COLORS.YELLOW) { + // Turn on green and red LED. + this.displaybuffers[addr][y] |= (1 << (x + 8)) | (1 << x); + } else if (state) { + // Turn on red LED. + this.displaybuffers[addr][y] |= 1 << (x + 8); + // Turn off green LED. + this.displaybuffers[addr][y] &= ~(1 << x); + } else { + // Turn off green and red LED. + this.displaybuffers[addr][y] &= ~(1 << x) & ~(1 << (x + 8)); + } + } + this.writeDisplay(addr); + } + return this; + }, + print: function() { + console.log("The print function is not implemented for HT16K33 devices"); + return this; + }, + writeDisplay: function(addr) { + var bytes = [0x00]; + // always writes 8 rows (for 8x16, the values have already been rotated) + for (var i = 0; i < 8; i++) { + bytes.push(this.displaybuffers[addr][i] & 0xFF); + bytes.push(this.displaybuffers[addr][i] >> 8); + } + this.io.i2cWrite(this.addresses[addr], bytes); + }, + + /** + * row Update an entire row with an 8 bit value + * @param {Number} addr Device address + * @param {Number} row 0 indexed row number 0-7 + * @param {Number} val 8-bit value 0-255 + * @return {LedControl} + */ + row: function(addr, row, val /* 0 - 0xFFFF or string */ ) { + if (!this.isMatrix) { + console.log("The `row` method is only supported for Matrix devices"); + } + if (typeof val === "number") { + val = ("0000000000000000" + parseInt(val, 10).toString(2)).substr(0-(this.columns), this.columns); + } + if (arguments.length === 2) { + val = row; + row = addr; + this.each(function(device) { + this.row(device, row, val); + }); + } else { + + // call the led function because the handling of rotation + // and wrapping for monochrome matrixes is done there + for (var i = 0; i < this.columns; i++) { + this.led(addr, row, i, parseInt(val[i], 10)); + } + } + + return this; + }, + + scanLimit: function() { + console.log("The scanLimit function is not implemented for HT16K33 devices"); + return this; + }, + + /* + * doSend + * @param {Number} addr Address of Led device + * @param {Number} opcode Operation code + * @param {Number} data Data + */ + send: function(addr, opcode, data) { + if (arguments.length !== 3) { + throw new Error("`send` expects three arguments: device, opcode, data"); + } + this.io.i2cWrite(this.addresses[addr], [opcode | data]); + return this; + } + }, + + DEFAULT: { + OP: {}, + initialize: function(opts) { + + this.pins = { + data: opts.pins.data, + clock: opts.pins.clock, + cs: opts.pins.cs || opts.pins.latch + }; + ["data", "clock", "cs"].forEach(function(pin) { + this.io.pinMode(this.pins[pin], this.io.MODES.OUTPUT); + }, this); + // NOTE: Currently unused, these will form + // the basis for the `setup` constructor option + // var setup = Object.assign({}, LedControl.DEFAULTS, opts.setup || {}); + // var keys = Object.keys(setup); + + for (var device = 0; device < this.devices; device++) { + /* + TODO: Add support for custom initialization + + An example of initialization, added to the constructor options: + + setup: { + // OPCODE: VALUE + DECODING: 0, + BRIGHTNESS: 3, + SCANLIMIT: 7, + SHUTDOWN: 1, + DISPLAYTEST: 1 + }, + + + In context: + + var lc = new five.LedControl({ + pins: { + data: 2, + clock: 3, + cs: 4 + }, + setup: { + DECODING: 0, + BRIGHTNESS: 3, + SCANLIMIT: 7, + SHUTDOWN: 1, + DISPLAYTEST: 1 + }, + isMatrix: true + }); + + + The custom initializers are invoked as: + + keys.forEach(function(key) { + this.send(device, LedControl.OP[key], setup[key]); + }, this); + + + I might be missing something obvious, but this isn't working. + Using the same options shown below, the above should behave exactly the + same way that the code below does, but that's not the case. The result is + all leds in the matrix are lit and none can be cleared. + */ + if (this.isMatrix) { + this.send(device, LedControl.OP.DECODING, 0); + } + + this.send(device, LedControl.OP.BRIGHTNESS, 3); + this.send(device, LedControl.OP.SCANLIMIT, 7); + this.send(device, LedControl.OP.SHUTDOWN, 1); + this.send(device, LedControl.OP.DISPLAYTEST, 0); + + this.clear(device); + this.on(device); + } + return this; + + }, + clear: function(addr) { + var offset; + + if (typeof addr === "undefined") { + this.each(function(device) { + this.clear(device); + }); + } else { + offset = addr * 8; + + for (var i = 0; i < 8; i++) { + this.status[offset + i] = 0; + this.send(addr, i + 1, 0); + } + } + return this; + }, + /** + * digit Display a digit + * @param {Number} addr Device address + * @param {Number} position 0-7 + * @param {Number} val 0-9 + * @param {Boolean} dp Show Decimal Point? + * This is a truly awful design t + * be p + * + * + * @return {LedControl} + */ + digit: function(addr, position, chr) { + var args, offset, index, character, value; + var hasDecimal = false; + + if (arguments.length < 3) { + args = Array.from(arguments); + this.each(function(device) { + this.digit.apply(this, (args.unshift(device), args)); + }); + } else { + if (this.isMatrix) { + // Not sure this is the best path, will check when segment + // devices are available. + // + this.draw.apply(this, arguments); + } else { + + offset = addr * 8; + + character = String(chr); + position = Number(position); + + // Flip this around, because no one will + // ever intuitively think that positions + // start on the right and end on the left. + index = 7 - position; + + if (character.length === 2 && character[1] === ".") { + hasDecimal = true; + character = character[0]; + } + + value = LedControl.DIGIT_CHARS[character]; + + if (!value) { + value = Math.abs(Number(character)); + } + + if (hasDecimal) { + value = value | 0x80; + } + + this.status[offset + index] = value; + this.send(addr, index + 1, value); + } + } + + return this; + }, + /** + * led or setLed Set the status of a single Led. + * + * @param {Number} addr Address of Led + * @param {Number} row Row number of Led (0-7) + * @param {Number} column Column number of Led (0-7) + * @param {Boolean} state [ true: on, false: off ] [ 1, 0 ] + * + */ + led: function(addr, row, col, state) { + var offset, val; + + if (arguments.length === 3) { + state = col; + col = row; + row = addr; + this.each(function(device) { + this.led(device, row, col, state); + }); + } else { + offset = addr * this.columns; + val = 0x80 >> col; + + if (state) { + this.status[offset + row] = this.status[offset + row] | val; + } else { + val = ~val; + this.status[offset + row] = this.status[offset + row] & val; + } + this.send(addr, row + 1, this.status[offset + row]); + } + + return this; + }, + + print: function(message, opts) { + var rdigchars = /([0-9A-Z][.]|[0-9A-Z]|[\s])/g; + var characters; + + opts = opts || { + device: 0 + }; + + if (this.isMatrix) { + + throw new Error("Led.Matrix does not yet support the print method"); + // figure out what to do with Matrix displays + + // this.each(function(device) { + // this.draw(device, message[device]); + // }); + + } else { + characters = message.match(rdigchars); + + (characters || []).forEach(function(character, position) { + this.digit(opts.device, position, character); + }, this); + } + }, + + /** + * row Update an entire row with an 8 bit value + * @param {Number} addr Device address + * @param {Number} row 0 indexed row number 0-7 + * @param {Number} val 8-bit value 0-255 + * @return {LedControl} + */ + row: function(addr, row, val /* 0 - 255 or string */ ) { + if (!this.isMatrix) { + console.log("The `row` method is only supported for Matrix devices"); + } + var offset; + if (typeof val === "string") { + val = parseInt(val, 2); + } + if (arguments.length === 2) { + val = row; + row = addr; + this.each(function(device) { + this.row(device, row, val); + }); + } else { + offset = addr * this.columns; + this.status[offset + row] = val; + this.send(addr, row + 1, this.status[offset + row]); + } + + return this; + }, + /* + * scanLimit (function from interface) + * @param {Number} addr Address of Led device + * @param {Number} limit + */ + scanLimit: function(addr, limit) { + if (arguments.length === 1) { + limit = addr; + this.each(function(device) { + this.scanLimit(device, limit); + }); + } else { + this.send(addr, LedControl.OP.SCANLIMIT, limit); + } + return this; + }, + send: function(addr, opcode, data) { + if (arguments.length !== 3) { + throw new Error("`send` expects three arguments: device, opcode, data"); + } + var offset = addr * 2; + var maxBytes = this.devices * 2; + var spiData = []; + + if (addr < this.devices) { + for (var i = 0; i < maxBytes; i++) { + spiData[i] = 0; + } + + spiData[offset + 1] = opcode; + spiData[offset] = data; + + this.board.digitalWrite(this.pins.cs, this.io.LOW); + + for (var j = maxBytes; j > 0; j--) { + this.board.shiftOut(this.pins.data, this.pins.clock, spiData[j - 1]); + } + + this.board.digitalWrite(this.pins.cs, this.io.HIGH); + } + + return this; + } + } +}; + +// NOTE: Currently unused, these will form +// the basis for the `setup` constructor option +LedControl.DEFAULTS = { + DECODING: 0x00, + BRIGHTNESS: 0x03, + SCANLIMIT: 0x07, + SHUTDOWN: 0x01, + DISPLAYTEST: 0x00 +}; + +Object.freeze(LedControl.DEFAULTS); + +LedControl.OP = {}; + +LedControl.OP.NOOP = 0x00; + +LedControl.OP.DIGIT0 = 0x01; +LedControl.OP.DIGIT1 = 0x02; +LedControl.OP.DIGIT2 = 0x03; +LedControl.OP.DIGIT3 = 0x04; +LedControl.OP.DIGIT4 = 0x05; +LedControl.OP.DIGIT5 = 0x06; +LedControl.OP.DIGIT6 = 0x07; +LedControl.OP.DIGIT7 = 0x08; + +LedControl.OP.DECODEMODE = 0x09; +LedControl.OP.INTENSITY = 0x0a; +LedControl.OP.SCANLIMIT = 0x0b; +LedControl.OP.SHUTDOWN = 0x0c; +LedControl.OP.DISPLAYTEST = 0x0f; + +// Aliases +LedControl.OP.BRIGHTNESS = LedControl.OP.INTENSITY; +LedControl.OP.DECODING = LedControl.OP.DECODEMODE; +LedControl.OP.DISPLAY = LedControl.OP.DISPLAYTEST; +LedControl.OP.POWERDOWN = LedControl.OP.SHUTDOWN; + +Object.freeze(LedControl.OP); + +LedControl.COLORS = { + "RED": 1, + "YELLOW": 2, + "GREEN": 3 +}; + +LedControl.DIRECTIONS = { + UP: 1, + RIGHT: 2, + DOWN: 3, + LEFT: 4, + 1: "UP", + 2: "RIGHT", + 3: "DOWN", + 4: "LEFT", +}; + +Object.freeze(LedControl.DIRECTIONS); + +LedControl.DIGIT_CHARS = { + "0": 0x7E, + "1": 0x30, + "2": 0x6D, + "3": 0x79, + "4": 0x33, + "5": 0x5B, + "6": 0x5F, + "7": 0x70, + "8": 0x7F, + "9": 0x7B, + " ": 0x00, + "!": 0xB0, + "A": 0x77, + "a": 0x7D, + "B": 0x7F, + "b": 0x1F, + "C": 0x4E, + "c": 0x0D, + "D": 0x7E, + "d": 0x3D, + "E": 0x4F, + "e": 0x6f, + "F": 0x47, + "f": 0x47, + "G": 0x5E, + "g": 0x7B, + "H": 0x37, + "h": 0x17, + "I": 0x30, + "i": 0x10, + "J": 0x3C, + "j": 0x38, + "K": 0x37, + "k": 0x17, + "L": 0x0E, + "l": 0x06, + "M": 0x55, + "m": 0x55, + "N": 0x15, + "n": 0x15, + "O": 0x7E, + "o": 0x1D, + "P": 0x67, + "p": 0x67, + "Q": 0x73, + "q": 0x73, + "R": 0x77, + "r": 0x05, + "S": 0x5B, + "s": 0x5B, + "T": 0x46, + "t": 0x0F, + "U": 0x3E, + "u": 0x1C, + "V": 0x27, + "v": 0x23, + "W": 0x3F, + "w": 0x2B, + "X": 0x25, + "x": 0x25, + "Y": 0x3B, + "y": 0x33, + "Z": 0x6D, + "z": 0x6D, +}; + +// https://dl.dropboxusercontent.com/u/3531958/digits.html + +LedControl.MATRIX_CHARS = { + " ": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "!": [0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00], + "\"": [0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00], + "#": [0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A, 0x00], + "$": [0x04, 0x0F, 0x14, 0x0E, 0x05, 0x1E, 0x04, 0x00], + "%": [0x18, 0x19, 0x02, 0x04, 0x08, 0x13, 0x03, 0x00], + "&": [0x0C, 0x12, 0x14, 0x08, 0x15, 0x12, 0x0D, 0x00], + "'": [0x0C, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00], + "(": [0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02, 0x00], + ")": [0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00], + "*": [0x00, 0x04, 0x15, 0x0E, 0x15, 0x04, 0x00, 0x00], + "+": [0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00, 0x00], + ",": [0x00, 0x00, 0x00, 0x00, 0x0C, 0x04, 0x08, 0x00], + "-": [0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00], + ".": [0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00], + "/": [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00], + "0": [0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E, 0x00], + "1": [0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00], + "2": [0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F, 0x00], + "3": [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E, 0x00], + "4": [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02, 0x00], + "5": [0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E, 0x00], + "6": [0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E, 0x00], + "7": [0x1F, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00], + "8": [0x1E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E, 0x00], + "9": [0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C, 0x00], + ":": [0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00, 0x00], + ";": [0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x04, 0x08, 0x00], + "<": [0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02, 0x00], + "=": [0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x00], + ">": [0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x00], + "?": [0x0E, 0x11, 0x01, 0x02, 0x04, 0x00, 0x04, 0x00], + "@": [0x0E, 0x11, 0x01, 0x0D, 0x15, 0x15, 0x0E, 0x00], + + "A": [0x08, 0x14, 0x22, 0x3E, 0x22, 0x22, 0x22, 0x22], + "B": [0x3C, 0x22, 0x22, 0x3E, 0x22, 0x22, 0x3C, 0x00], + "C": [0x3C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x3C, 0x00], + "D": [0x7C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7C, 0x00], + "E": [0x7C, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x7C], + "F": [0x7C, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40], + "G": [0x3C, 0x40, 0x40, 0x40, 0x40, 0x44, 0x44, 0x3C], + "H": [0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x44], + "I": [0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7C], + "J": [0x3C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x48, 0x30], + "K": [0x00, 0x24, 0x28, 0x30, 0x20, 0x30, 0x28, 0x24], + "L": [0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C], + "M": [0x81, 0xC3, 0xA5, 0x99, 0x81, 0x81, 0x81, 0x81], + "N": [0x00, 0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x00], + "O": [0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C], + "P": [0x3C, 0x22, 0x22, 0x22, 0x3C, 0x20, 0x20, 0x20], + "Q": [0x1C, 0x22, 0x22, 0x22, 0x22, 0x26, 0x22, 0x1D], + "R": [0x3C, 0x22, 0x22, 0x22, 0x3C, 0x24, 0x22, 0x21], + "S": [0x00, 0x1E, 0x20, 0x20, 0x3E, 0x02, 0x02, 0x3C], + "T": [0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08], + "U": [0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1C], + "V": [0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18], + "W": [0x00, 0x49, 0x49, 0x49, 0x49, 0x2A, 0x1C, 0x00], + "X": [0x00, 0x41, 0x22, 0x14, 0x08, 0x14, 0x22, 0x41], + "Y": [0x41, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08], + "Z": [0x00, 0x7F, 0x02, 0x04, 0x08, 0x10, 0x20, 0x7F], + // "A": [0x0E, 0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x00], + // "B": [0x1E, 0x09, 0x09, 0x0E, 0x09, 0x09, 0x1E, 0x00], + // "C": [0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E, 0x00], + // "D": [0x1E, 0x09, 0x09, 0x09, 0x09, 0x09, 0x1E, 0x00], + // "E": [0x1F, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x00], + // "F": [0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10, 0x00], + // "G": [0x0E, 0x11, 0x10, 0x13, 0x11, 0x11, 0x0F, 0x00], + // "H": [0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00], + // "I": [0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00], + // "J": [0x07, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0C, 0x00], + // "K": [0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11, 0x00], + // "L": [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00], + // "M": [0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11, 0x00], + // "N": [0x11, 0x19, 0x19, 0x15, 0x13, 0x13, 0x11, 0x00], + // "O": [0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00], + // "P": [0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10, 0x00], + // "Q": [0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x1D, 0x00], + // "R": [0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11, 0x00], + // "S": [0x0E, 0x11, 0x10, 0x0E, 0x01, 0x11, 0x0E, 0x00], + // "T": [0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00], + // "U": [0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00], + // "V": [0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00], + // "W": [0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x11, 0x00], + // "X": [0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11, 0x00], + // "Y": [0x11, 0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x00], + // "Z": [0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F, 0x00], + "[": [0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00], + "\\": [0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00], + "]": [0x0E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0E, 0x00], + "^": [0x04, 0x0A, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00], + "_": [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00], + "`": [0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00], + "a": [0x00, 0x00, 0x0E, 0x01, 0x0F, 0x11, 0x0F, 0x00], + "b": [0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x1E, 0x00], + "c": [0x00, 0x00, 0x0E, 0x11, 0x10, 0x11, 0x0E, 0x00], + "d": [0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0F, 0x00], + "e": [0x00, 0x00, 0x0E, 0x11, 0x1F, 0x10, 0x0E, 0x00], + "f": [0x02, 0x05, 0x04, 0x0E, 0x04, 0x04, 0x04, 0x00], + "g": [0x00, 0x0D, 0x13, 0x13, 0x0D, 0x01, 0x0E, 0x00], + "h": [0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x11, 0x00], + "i": [0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x0E, 0x00], + "j": [0x02, 0x00, 0x06, 0x02, 0x02, 0x12, 0x0C, 0x00], + "k": [0x08, 0x08, 0x09, 0x0A, 0x0C, 0x0A, 0x09, 0x00], + "l": [0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00], + "m": [0x00, 0x00, 0x1A, 0x15, 0x15, 0x15, 0x15, 0x00], + "n": [0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11, 0x00], + "o": [0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00], + "p": [0x00, 0x16, 0x19, 0x19, 0x16, 0x10, 0x10, 0x00], + "q": [0x00, 0x0D, 0x13, 0x13, 0x0D, 0x01, 0x01, 0x00], + "r": [0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10, 0x00], + "s": [0x00, 0x00, 0x0F, 0x10, 0x1E, 0x01, 0x1F, 0x00], + "t": [0x08, 0x08, 0x1C, 0x08, 0x08, 0x09, 0x06, 0x00], + "u": [0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x0D, 0x00], + "v": [0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00], + "w": [0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A, 0x00], + "x": [0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00], + "y": [0x00, 0x00, 0x11, 0x11, 0x13, 0x0D, 0x01, 0x0E], + "z": [0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F, 0x00], + "{": [0x02, 0x04, 0x04, 0x08, 0x04, 0x04, 0x02, 0x00], + "|": [0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x00], + "}": [0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0x00], + "~": [0x08, 0x15, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00], +}; + +// Double Digit Numbers +// +// Each digit: +// +// - is drawn as far to the left as possible. +// - uses 3 bits +// +var digits = [ + [0xe0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xe0, 0x00], + [0x40, 0xc0, 0x40, 0x40, 0x40, 0x40, 0xe0, 0x00], + [0xe0, 0x20, 0x20, 0xe0, 0x80, 0x80, 0xe0, 0x00], + [0xe0, 0x20, 0x20, 0x60, 0x20, 0x20, 0xe0, 0x00], + [0x20, 0x60, 0xa0, 0xe0, 0x20, 0x20, 0x20, 0x00], + [0xe0, 0x80, 0x80, 0xe0, 0x20, 0x20, 0xe0, 0x00], + [0xe0, 0x80, 0x80, 0xe0, 0xa0, 0xa0, 0xe0, 0x00], + [0xe0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00], + [0xe0, 0xa0, 0xa0, 0x40, 0xa0, 0xa0, 0xe0, 0x00], + [0xe0, 0xa0, 0xa0, 0xe0, 0x20, 0x20, 0xe0, 0x00], +]; + +var charName = ""; + +for (var i = 0; i < 10; i++) { + for (var k = 0; k < 10; k++) { + charName = i + "" + k; + LedControl.MATRIX_CHARS[charName] = []; + + for (var j = 0; j < 8; j++) { + // Left digit takes 3 bits, plus 1 to between digits = 4 bits to the right. + LedControl.MATRIX_CHARS[charName][j] = digits[i][j] | (digits[k][j] >>> 4); + } + } +} + +LedControl.MATRIX_DIMENSIONS = { + "16x8": { rows: 16, columns: 8 }, + "8x16": { rows: 8, columns: 16 }, + "8x8": { rows: 8, columns: 8 } +}; + +if (IS_TEST_MODE) { + LedControl.reset = function() { + addresses = new Set([0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77]); + priv.clear(); + }; +} +module.exports = LedControl; diff --git a/JavaScript/node_modules/johnny-five/lib/led/leds.js b/JavaScript/node_modules/johnny-five/lib/led/leds.js new file mode 100644 index 0000000..d903b24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/leds.js @@ -0,0 +1,54 @@ +var Led = require("./led"); +var Collection = require("../mixins/collection"); + +/** + * Leds() + * new Leds() + * + * Create an Array-like object instance of Leds + * @alias Led.Array + * @constructor + * @return {Leds} + */ +function Leds(numsOrObjects) { + if (!(this instanceof Leds)) { + return new Leds(numsOrObjects); + } + + Object.defineProperty(this, "type", { + value: Led + }); + + Collection.call(this, numsOrObjects); +} + +Leds.prototype = Object.create(Collection.prototype, { + constructor: { + value: Leds + } +}); + +[ + + "on", "off", "toggle", "brightness", + "fade", "fadeIn", "fadeOut", + "pulse", "strobe", + "stop" + +].forEach(function(method) { + // Create Leds wrappers for each method listed. + // This will allow us control over all Led instances + // simultaneously. + Leds.prototype[method] = function() { + var length = this.length; + + for (var i = 0; i < length; i++) { + this[i][method].apply(this[i], arguments); + } + return this; + }; +}); + +Leds.prototype.blink = Leds.prototype.strobe; + +module.exports = Leds; diff --git a/JavaScript/node_modules/johnny-five/lib/led/matrix.js b/JavaScript/node_modules/johnny-five/lib/led/matrix.js new file mode 100644 index 0000000..4bd4f74 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/matrix.js @@ -0,0 +1,13 @@ +var LedControl = require("./ledcontrol"); + +// stub implementation; extract functionality from ledcontrol.js +function Matrix(opts) { + opts.isMatrix = true; + return new LedControl(opts); +} + +Object.assign(Matrix, LedControl, { + CHARS: LedControl.MATRIX_CHARS +}); + +module.exports = Matrix; diff --git a/JavaScript/node_modules/johnny-five/lib/led/rgb.js b/JavaScript/node_modules/johnny-five/lib/led/rgb.js new file mode 100644 index 0000000..3507ef2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/led/rgb.js @@ -0,0 +1,436 @@ +var Board = require("../board.js"); +var nanosleep = require("../sleep.js").nano; +var __ = require("../fn.js"); + +var priv = new Map(); + +var Controllers = { + DEFAULT: { + initialize: { + value: function(opts) { + RGB.colors.forEach(function(color, index) { + var pin = opts.pins[index]; + + if (!this.board.pins.isPwm(pin)) { + Board.Pins.Error({ + pin: pin, + type: "PWM", + via: "Led.RGB" + }); + } + + this.io.pinMode(pin, this.io.MODES.PWM); + this.pins[index] = pin; + }, this); + } + }, + write: { + writable: true, + value: function(colors) { + var state = priv.get(this); + + RGB.colors.forEach(function(color, index) { + var pin = this.pins[index]; + var value = colors[color]; + + if (state.isAnode) { + value = 255 - Board.constrain(value, 0, 255); + } + + this.io.analogWrite(pin, value); + }, this); + } + } + }, + PCA9685: { + COMMANDS: { + value: { + PCA9685_MODE1: 0x0, + PCA9685_PRESCALE: 0xFE, + LED0_ON_L: 0x6 + } + }, + initialize: { + value: function(opts) { + this.address = opts.address || 0x40; + + if (!this.board.Drivers[this.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.address] = { + initialized: false + }; + + // Reset + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Sleep + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x10]); + // Set prescalar + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_PRESCALE, 0x70]); + // Wake up + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWrite(this.address, [this.COMMANDS.PCA9685_MODE1, 0xa1]); + + this.board.Drivers[this.address].initialized = true; + } + + RGB.colors.forEach(function(color, index) { + var pin = opts.pins[index]; + this.pins[index] = pin; + }, this); + } + }, + write: { + writable: true, + value: function(colors) { + var state = priv.get(this); + + RGB.colors.forEach(function(color, index) { + var pin = this.pins[index]; + var value = colors[color]; + var on, off; + + if (state.isAnode) { + value = 255 - Board.constrain(value, 0, 255); + } + + on = 0; + off = value * 4095 / 255; + + // Special value for fully off + if (state.isAnode && value === 255) { + on = 4096; + off = 0; + } + + this.io.i2cWrite(this.address, [this.COMMANDS.LED0_ON_L + 4 * pin, on, on >> 8, off, off >> 8]); + }, this); + } + } + }, + BLINKM: { + COMMANDS: { + value: { + GO_TO_RGB_COLOR_NOW: 0x6e, + STOP_SCRIPT: 0x6f + } + }, + initialize: { + value: function(opts) { + this.address = opts.address || 0x09; + + if (!this.board.Drivers[this.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.address] = { + initialized: false + }; + + // Stop the current script + this.io.i2cWrite(this.address, [this.COMMANDS.STOP_SCRIPT]); + + this.board.Drivers[this.address].initialized = true; + } + } + }, + write: { + writable: true, + value: function(colors) { + this.io.i2cWrite(this.address, + [this.COMMANDS.GO_TO_RGB_COLOR_NOW, colors.red, colors.green, colors.blue]); + } + } + } +}; + +Controllers.ESPLORA = { + initialize: { + value: function(opts) { + opts.pins = [5, 10, 9]; + this.pins = []; + Controllers.DEFAULT.initialize.value.call(this, opts); + } + }, + write: Controllers.DEFAULT.write +}; + +/** + * RGB + * @constructor + * + * @param {Object} opts [description] + * @alias Led.RGB + */ +var RGB = function(opts) { + if (!(this instanceof RGB)) { + return new RGB(opts); + } + + var state; + var controller; + + if (Array.isArray(opts)) { + // RGB([Byte, Byte, Byte]) shorthand + // Convert to opts.pins array definition + opts = { + pins: opts + }; + // If opts.pins is an object, convert to array + } else if (typeof opts.pins === "object" && !Array.isArray(opts.pins)) { + opts.pins = [opts.pins.red, opts.pins.green, opts.pins.blue]; + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["DEFAULT"]; + } + + Object.defineProperties(this, controller); + + // The default color is #ffffff, but the light will be off + state = { + red: 255, + green: 255, + blue: 255, + intensity: 100, + isAnode: opts.isAnode || false, + interval: null + }; + + // red, green, and blue store the raw color set via .color() + // values takes state into account, such as on/off and intensity + state.values = { + red: state.red, + green: state.green, + blue: state.blue + }; + + priv.set(this, state); + + Object.defineProperties(this, { + isOn: { + get: function() { + return RGB.colors.some(function(color) { + return state[color] > 0; + }); + } + }, + isRunning: { + get: function() { + return !!state.interval; + } + }, + isAnode: { + get: function () { + return state.isAnode; + } + }, + values: { + get: function() { + return Object.assign({}, state.values); + } + }, + update: { + value: function(colors) { + var state = priv.get(this); + var scale = state.intensity / 100; + + colors = colors || this.color(); + var scaledColors = RGB.colors.reduce(function(current, color) { + return (current[color] = Math.round(colors[color] * scale), current); + }, {}); + + this.write(scaledColors); + + state.values = scaledColors; + Object.assign(state, colors); + } + } + }); + + this.initialize(opts); + this.off(); +}; + +RGB.colors = ["red", "green", "blue"]; + +/** +* color +* +* @param {String} color Hexadecimal color string +* @param {Array} color Array of color values +* @param {Object} color object {red, green, blue} +* +* @return {RGB} +*/ +RGB.prototype.color = function(red, green, blue) { + var state = priv.get(this); + var update = {}; + var input; + var colors; + + if (arguments.length === 0) { + // Return a copy of the state values, + // not a reference to the state object itself. + colors = this.isOn ? state : state.prev; + return RGB.colors.reduce(function(current, color) { + return (current[color] = Math.round(colors[color]), current); + }, {}); + } + + if (arguments.length === 1) { + input = red; + + if (input == null) { + throw new Error("Led.RGB.color: invalid color (" + input + ")"); + } + + if (Array.isArray(input)) { + // color([Byte, Byte, Byte]) + update = { + red: input[0], + green: input[1], + blue: input[2] + }; + } else if (typeof input === "object") { + // colors({ + // red: Byte, + // green: Byte, + // blue: Byte + // }); + update = { + red: input.red, + green: input.green, + blue: input.blue + }; + } else if (typeof input === "string") { + // color("#ffffff") + if (input.length === 7 && input[0] === "#") { + input = input.slice(1); + } + + if (!input.match(/^[0-9A-Fa-f]{6}$/)) { + throw new Error("Led.RGB.color: invalid color (#" + input + ")"); + } + + // color("ffffff") + update = { + red: parseInt(input.slice(0, 2), 16), + green: parseInt(input.slice(2, 4), 16), + blue: parseInt(input.slice(4, 6), 16) + }; + } + } else { + // color(Byte, Byte, Byte) + update = { + red: red, + green: green, + blue: blue + }; + } + + // Validate all color values before writing any values + RGB.colors.forEach(function(color) { + var value = update[color]; + + if (value == null) { + throw new Error("Led.RGB.color: invalid color ([" + [update.red, update.green, update.blue].join(",") + "])"); + } + + value = __.constrain(value, 0, 255); + update[color] = value; + }, this); + + this.update(update); + + return this; +}; + +RGB.prototype.on = function() { + var state = priv.get(this); + var colors; + + // If it's not already on, we set them to the previous color + if (!this.isOn) { + colors = state.prev || { red: 255, green: 255, blue: 255 }; + delete state.prev; + + this.update(colors); + } + + return this; +}; + +RGB.prototype.off = function() { + var state = priv.get(this); + + // If it's already off, do nothing so the pervious state stays intact + if (this.isOn) { + state.prev = RGB.colors.reduce(function(current, color) { + return (current[color] = state[color], current); + }.bind(this), {}); + + this.update({ red: 0, green: 0, blue: 0 }); + } + + return this; +}; + +/** + * strobe + * @param {Number} rate Time in ms to strobe/blink + * @return {Led} + */ +RGB.prototype.strobe = function(rate) { + var state = priv.get(this); + + // Avoid traffic jams + if (state.interval) { + clearInterval(state.interval); + } + + state.interval = setInterval(this.toggle.bind(this), rate || 100); + + return this; +}; + +RGB.prototype.blink = RGB.prototype.strobe; + +RGB.prototype.toggle = function() { + return this[this.isOn ? "off" : "on"](); +}; + +RGB.prototype.stop = function() { + var state = priv.get(this); + + clearInterval(state.interval); + delete state.interval; + + return this; +}; + +RGB.prototype.intensity = function(intensity) { + var state = priv.get(this); + + if (arguments.length === 0) { + return state.intensity; + } + + state.intensity = __.constrain(intensity, 0, 100); + + this.update(); + + return this; +}; + +module.exports = RGB; diff --git a/JavaScript/node_modules/johnny-five/lib/mixins/collection.js b/JavaScript/node_modules/johnny-five/lib/mixins/collection.js new file mode 100644 index 0000000..2832d08 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/mixins/collection.js @@ -0,0 +1,41 @@ +function Collection(numsOrObjects) { + var Type = this.type; + + this.length = 0; + + if (numsOrObjects) { + while (numsOrObjects.length) { + var numOrObject = numsOrObjects.shift(); + + if (!(numOrObject instanceof Type || numOrObject instanceof this.constructor)) { + numOrObject = new Type(numOrObject); + } + this.add(numOrObject); + } + } +} + +Collection.prototype.add = function() { + var length = this.length; + var aLen = arguments.length; + + for (var i = 0; i < aLen; i++) { + if (arguments[i] instanceof this.type || arguments[i] instanceof this.constructor) { + this[length++] = arguments[i]; + } + } + + return (this.length = length); +}; + +Collection.prototype.each = function(callbackFn) { + var length = this.length; + + for (var i = 0; i < length; i++) { + callbackFn.call(this[i], this[i], i); + } + + return this; +}; + +module.exports = Collection; diff --git a/JavaScript/node_modules/johnny-five/lib/mixins/within.js b/JavaScript/node_modules/johnny-five/lib/mixins/within.js new file mode 100644 index 0000000..e86f827 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/mixins/within.js @@ -0,0 +1,39 @@ +var mixins = { + + within: function(range, unit, callback) { + var upper; + + if (typeof range === "number") { + upper = range; + range = [0, upper]; + } + + if (!Array.isArray(range)) { + this.emit("error", { + message: "range must be an array" + }); + return; + } + + if (typeof unit === "function") { + callback = unit; + unit = "value"; + } + + if (typeof this[unit] === "undefined") { + return this; + } + + // Use the continuous read event for high resolution + this.on("data", function() { + var value = this[unit] | 0; + if (value >= range[0] && value <= range[1]) { + callback.call(this, null, value); + } + }.bind(this)); + + return this; + } +}; + +module.exports = mixins; diff --git a/JavaScript/node_modules/johnny-five/lib/motion.js b/JavaScript/node_modules/johnny-five/lib/motion.js new file mode 100644 index 0000000..b4f0c42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/motion.js @@ -0,0 +1,217 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + priv = new Map(); + + +function analogInitializer(opts, dataHandler) { + var state = priv.get(this); + + this.io.pinMode(opts.pin, this.io.MODES.ANALOG); + + setTimeout(function() { + state.isCalibrated = true; + this.emit("calibrated"); + }.bind(this), 10); + + this.io.analogRead(opts.pin, dataHandler); +} +var Controllers = { + PIR: { + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this); + var calibrationDelay = typeof opts.calibrationDelay !== "undefined" ? + opts.calibrationDelay : 2000; + + this.io.pinMode(opts.pin, this.io.MODES.INPUT); + + setTimeout(function() { + state.isCalibrated = true; + this.emit("calibrated"); + }.bind(this), calibrationDelay); + + this.io.digitalRead(opts.pin, dataHandler); + } + }, + toBoolean: { + value: function(raw) { + return !!raw; + } + } + }, + GP2Y0D805Z0F: { + initialize: { + value: function(opts, dataHandler) { + var address = opts.address || 0x26; + var state = priv.get(this); + + // This is meaningless for GP2Y0D805Z0F. + // The event is implemented for consistency + // with the digital passive infrared sensor + setTimeout(function() { + state.isCalibrated = true; + this.emit("calibrated"); + }.bind(this), 10); + + // Set up I2C data connection + this.io.i2cConfig(); + + this.io.i2cWriteReg(address, 0x03, 0xFE); + this.io.i2cWrite(address, [0x00]); + this.io.i2cRead(address, 1, function(data) { + dataHandler(data[0] & 0x02); + }); + } + }, + toBoolean: { + value: function(raw) { + return raw === 0; + } + } + }, + GP2Y0D810Z0F: { + initialize: { + value: analogInitializer + }, + toBoolean: { + value: function(raw) { + return raw >> 9 === 0; + } + } + }, + GP2Y0A60SZLF: { + initialize: { + value: analogInitializer + }, + toBoolean: { + value: function(raw) { + return raw >> 9 === 1; + } + } + } +}; + +Controllers.GP2Y0D815Z0F = Controllers.GP2Y0D810Z0F; + +Controllers["HC-SR501"] = Controllers.PIR; +Controllers["HCSR501"] = Controllers.PIR; +Controllers["0D805"] = Controllers.GP2Y0D805Z0F; +Controllers["805"] = Controllers.GP2Y0D805Z0F; +Controllers["0D810"] = Controllers.GP2Y0D810Z0F; +Controllers["810"] = Controllers.GP2Y0D810Z0F; +Controllers["0D815"] = Controllers.GP2Y0D815Z0F; +Controllers["815"] = Controllers.GP2Y0D815Z0F; +Controllers["0A60SZLF"] = Controllers.GP2Y0A60SZLF; +Controllers["60SZLF"] = Controllers.GP2Y0A60SZLF; + +/** + * Motion + * @constructor + * + * five.Motion(7); + * + * five.Motion({ + * controller: "PIR", + * pin: 7, + * freq: 100, + * calibrationDelay: 1000 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Motion(opts) { + + if (!(this instanceof Motion)) { + return new Motion(opts); + } + + var freq = opts.freq || 25; + var last = false; + var controller; + var state; + + Board.Device.call( + this, opts = Board.Options(opts) + ); + + if (typeof opts.controller === "string") { + controller = Controllers[opts.controller]; + } else { + controller = opts.controller || Controllers["PIR"]; + } + + Object.defineProperties(this, controller); + + state = { + value: false, + isCalibrated: false + }; + + priv.set(this, state); + + Object.defineProperties(this, { + /** + * [read-only] Current sensor state + * @property detectedMotion + * @type Boolean + */ + detectedMotion: { + get: function() { + return this.toBoolean(state.value); + } + }, + /** + * [read-only] Sensor calibration status + * @property isCalibrated + * @type Boolean + */ + isCalibrated: { + get: function() { + return state.isCalibrated; + } + }, + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + state.value = data; + }); + } + + setInterval(function() { + var isChange = false; + var eventData = { + timestamp: Date.now(), + detectedMotion: this.detectedMotion, + isCalibrated: state.isCalibrated + }; + + if (state.isCalibrated && this.detectedMotion && !last) { + this.emit("motionstart", eventData); + } + + if (state.isCalibrated && !this.detectedMotion && last) { + this.emit("motionend", eventData); + } + + if (last !== this.detectedMotion) { + isChange = true; + } + + this.emit("data", eventData); + + if (isChange) { + this.emit("change", eventData); + } + + last = this.detectedMotion; + }.bind(this), freq); +} + +util.inherits(Motion, events.EventEmitter); + +module.exports = Motion; diff --git a/JavaScript/node_modules/johnny-five/lib/motor.js b/JavaScript/node_modules/johnny-five/lib/motor.js new file mode 100644 index 0000000..8e84ebd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/motor.js @@ -0,0 +1,866 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../lib/board.js"); +var events = require("events"); +var util = require("util"); +var Collection = require("../lib/mixins/collection"); +var Sensor = require("../lib/sensor.js"); +var ShiftRegister = require("../lib/shiftregister.js"); +var nanosleep = require("../lib/sleep.js").nano; + +var priv = new Map(); +var registers = new Map(); + +function registerKey(registerOpts) { + return Object.keys(registerOpts).sort().reduce(function(accum, key) { + accum = accum + "." + registerOpts[key]; + return accum; + }, ""); +} + +function latch(state, bit, on) { + return on ? state |= (1 << bit) : state &= ~(1 << bit); +} + +function updateShiftRegister(motor, dir) { + var rKey = registerKey(motor.opts.register), + register = registers.get(motor.board)[rKey], + latchState = register.value, + bits = priv.get(motor).bits, + forward = dir !== "reverse"; + + // There are two ShiftRegister bits which we need to change based on the + // direction of the motor. These will be the pins that control the HBridge + // on the board. They will get flipped high/low based on the current flow + // in the HBridge. + latchState = latch(latchState, bits.a, forward); + latchState = latch(latchState, bits.b, !forward); + + if (register.value !== latchState) { + register.send(latchState); + } +} + +var Controllers = { + ShiftRegister: { + initialize: { + value: function (opts) { + var rKey = registerKey(opts.register); + + if (!opts.bits || opts.bits.a === undefined || opts.bits.b === undefined) { + throw new Error("ShiftRegister Motors MUST contain HBRIDGE bits {a, b}"); + } + + priv.get(this).bits = opts.bits; + + if (!registers.has(this.board)) { + registers.set(this.board, {}); + } + + if (!registers.get(this.board)[rKey]) { + registers.get(this.board)[rKey] = new ShiftRegister({ + board: this.board, + pins: opts.register + }); + } + + this.io.pinMode(this.pins.pwm, this.io.MODES.PWM); + } + }, + dir: { + value: function(speed, dir) { + this.stop(); + + updateShiftRegister(this, dir.name); + + this.direction = dir; + + process.nextTick(this.emit.bind(this, dir.name)); + + return this; + } + } + }, + PCA9685: { + COMMANDS: { + value: { + PCA9685_MODE1: 0x0, + PCA9685_PRESCALE: 0xFE, + LED0_ON_L: 0x6 + } + }, + address: { + get: function() { + return this.opts.address; + } + }, + setPWM: { + value: function(pin, off, on) { + if (typeof on === "undefined") { + on = 0; + } + on *= 16; + off *= 16; + this.io.i2cWrite(this.opts.address, [this.COMMANDS.LED0_ON_L + 4 * (pin), on, on >> 8, off, off >> 8]); + } + }, + setPin: { + value: function(pin, value, duty, phaseShift) { + var on = 0; + + if (value !== 0) { + value = 255; + } + + if (typeof duty !== "undefined") { + value = duty; + } + + if (typeof phaseShift !== "undefined") { + on = phaseShift; + value = value + on; + } + + this.setPWM(pin, value, on); + + } + }, + initialize: { + value: function() { + + if (!this.board.Drivers[this.opts.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.opts.address] = { + initialized: false + }; + + // Reset + this.io.i2cWrite(this.opts.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Sleep + this.io.i2cWrite(this.opts.address, [this.COMMANDS.PCA9685_MODE1, 0x10]); + // Set prescalar + this.io.i2cWrite(this.opts.address, [this.COMMANDS.PCA9685_PRESCALE, 0x3]); + // Wake up + this.io.i2cWrite(this.opts.address, [this.COMMANDS.PCA9685_MODE1, 0x0]); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWrite(this.opts.address, [this.COMMANDS.PCA9685_MODE1, 0xa1]); + + // Reset all PWM values + for (var i = 0; i < 16; i++) { + this.setPWM(i, 0, 0); + } + + this.board.Drivers[this.opts.address].initialized = true; + } + } + } + } +}; + +var Devices = { + NONDIRECTIONAL: { + pins: { + get: function() { + return { + pwm: this.opts.pin + }; + } + }, + dir: { + value: function(speed) { + speed = speed || this.speed(); + return this; + } + }, + resume: { + value: function() { + var speed = this.speed(); + this.speed({ + speed: speed + }); + return this; + } + } + }, + DIRECTIONAL: { + pins: { + get: function() { + if (Array.isArray(this.opts.pins)) { + return { + pwm: this.opts.pins[0], + dir: this.opts.pins[1] + }; + } else { + return this.opts.pins; + } + } + }, + dir: { + configurable: true, + value: function(speed, dir) { + + speed = speed || this.speed(); + + this.stop(); + + this.setPin(this.pins.dir, dir.value); + this.direction = dir; + + process.nextTick(this.emit.bind(this, dir.name)); + + return this; + } + } + }, + CDIR: { + pins: { + get: function() { + if (Array.isArray(this.opts.pins)) { + return { + pwm: this.opts.pins[0], + dir: this.opts.pins[1], + cdir: this.opts.pins[2] + }; + } else { + return this.opts.pins; + } + } + }, + dir: { + value: function(speed, dir) { + + if (typeof speed === "undefined") { + speed = this.speed(); + } + + this.stop(); + this.direction = dir; + + this.setPin(this.pins.cdir, 1 ^ dir.value); + this.setPin(this.pins.dir, dir.value); + + process.nextTick(this.emit.bind(this, dir.name)); + + return this; + } + }, + brake: { + value: function(duration) { + + this.speed({ + speed: 0, + saveSpeed: false + }); + this.setPin(this.pins.dir, 1, 127); + this.setPin(this.pins.cdir, 1, 128, 127); + this.speed({ + speed: 255, + saveSpeed: false, + braking: true + }); + process.nextTick(this.emit.bind(this, "brake")); + + if (duration) { + var motor = this; + this.board.wait(duration, function() { + motor.stop(); + }); + } + + return this; + } + } + } +}; + +/** + * Motor + * @constructor + * + * @param {Object} opts Options: pin|pins{pwm, dir[, cdir]}, device, controller, current + * @param {Number} pin A single pin for basic + * @param {Array} pins A two or three digit array of pins [pwm, dir]|[pwm, dir, cdir] + * + * + * Initializing "Hobby Motors" + * + * new five.Motor(9); + * + * ...is the same as... + * + * new five.Motor({ + * pin: 9 + * }); + * + * + * Initializing 2 pin, Bi-Directional DC Motors: + * + * new five.Motor([ 3, 12 ]); + * + * ...is the same as... + * + * new five.Motor({ + * pins: [ 3, 12 ] + * }); + * + * ...is the same as... + * + * new five.Motor({ + * pins: { + * pwm: 3, + * dir: 12 + * } + * }); + * + * + * Initializing 3 pin, I2C PCA9685 Motor Controllers: + * i.e. The Adafruit Motor Shield V2 + * + * new five.Motor({ + * pins: [ 8, 9, 10 ], + * controller: "PCA9685", + * address: 0x60 + * }); + * + * + * Initializing 3 pin, Bi-Directional DC Motors: + * + * new five.Motor([ 3, 12, 11 ]); + * + * ...is the same as... + * + * new five.Motor({ + * pins: [ 3, 12, 11 ] + * }); + * + * ...is the same as... + * + * new five.Motor({ + * pins: { + * pwm: 3, + * dir: 12, + * cdir: 11 + * } + * }); + * + * + * Initializing Bi-Directional DC Motors with brake: + * + * new five.Motor({ + * pins: { + * pwm: 3, + * dir: 12, + * brake: 11 + * } + * }); + * + * + * Initializing Bi-Directional DC Motors with current sensing pins: + * See Sensor.js for details on options + * + * new five.Motor({ + * pins: [3, 12], + * current: { + * pin: "A0", + * freq: 250, + * range: [0, 2000] + * } + * }); + * + * + * Initializing Bi-Directional DC Motors with inverted speed for reverse: + * Most likely used for non-commercial H-Bridge controllers + * + * new five.Motor({ + * pins: [3, 12], + * invertPWM: true + * }); + * + */ + +function Motor(opts) { + + var device, controller; + + if (!(this instanceof Motor)) { + return new Motor(opts); + } + + Board.Component.call( + this, this.opts = Board.Options(opts) + ); + + // Derive device based on pins passed + if (typeof this.opts.device === "undefined") { + + this.opts.device = (typeof this.opts.pins === "undefined" && typeof this.opts.register !== "object") ? + "NONDIRECTIONAL" : "DIRECTIONAL"; + + if (this.opts.pins && (this.opts.pins.cdir || this.opts.pins.length > 2)) { + this.opts.device = "CDIR"; + } + + } + + // Allow users to pass in custom device types + device = typeof this.opts.device === "string" ? + Devices[this.opts.device] : this.opts.device; + + this.threshold = typeof this.opts.threshold !== "undefined" ? + this.opts.threshold : 30; + + this.invertPWM = typeof this.opts.invertPWM !== "undefined" ? + this.opts.invertPWM : false; + + Object.defineProperties(this, device); + + if (this.opts.register) { + this.opts.controller = "ShiftRegister"; + } + + /** + * Note: Controller decorates the device. Used for adding + * special controllers (i.e. PCA9685) + **/ + if (this.opts.controller) { + controller = typeof this.opts.controller === "string" ? + Controllers[this.opts.controller] : this.opts.controller; + + Object.defineProperties(this, controller); + } + + // current just wraps a Sensor + if (this.opts.current) { + this.opts.current.board = this.board; + this.current = new Sensor(this.opts.current); + } + + // Create a "state" entry for privately + // storing the state of the motor + priv.set(this, { + isOn: false, + currentSpeed: typeof this.opts.speed !== "undefined" ? + this.opts.speed : 128, + braking: false + }); + + if (this.initialize) { + this.initialize(opts); + } + + Object.defineProperties(this, { + // Calculated, read-only motor on/off state + // true|false + isOn: { + get: function() { + return priv.get(this).isOn; + } + }, + currentSpeed: { + get: function() { + return priv.get(this).currentSpeed; + } + }, + braking: { + get: function() { + return priv.get(this).braking; + } + } + }); + + // We need to store and initialize the state of the dir pin(s) + this.direction = { + value: 1 + }; + this.dir(0, this.direction); + +} + +util.inherits(Motor, events.EventEmitter); + +Motor.prototype.initialize = function() { + + this.io.pinMode(this.pins.pwm, this.io.MODES.PWM); + + ["dir", "cdir", "brake"].forEach(function(pin) { + if (this.pins[pin]) { + this.io.pinMode(this.pins[pin], this.io.MODES.OUTPUT); + } + }, this); + +}; + +Motor.prototype.setPin = function(pin, value) { + this.io.digitalWrite(pin, value); +}; + +Motor.prototype.setPWM = function(pin, value) { + this.io.analogWrite(pin, value); +}; + +Motor.prototype.speed = function(opts) { + if (typeof opts === "undefined") { + return this.currentSpeed; + } else { + + if (typeof opts === "number") { + opts = { + speed: opts + }; + } + + opts.speed = Board.constrain(opts.speed, 0, 255); + + opts.saveSpeed = typeof opts.saveSpeed !== "undefined" ? + opts.saveSpeed : true; + + if (opts.speed < this.threshold) { + opts.speed = 0; + } + + var state = priv.get(this); + + state.isOn = opts.speed === 0 ? false : true; + + if (opts.saveSpeed) { + state.currentSpeed = opts.speed; + } + + if (opts.braking) { + state.braking = true; + } + + priv.set(this, state); + + if (this.invertPWM && this.direction.value === 1) { + opts.speed ^= 0xff; + } + + this.setPWM(this.pins.pwm, opts.speed); + + return this; + } + +}; + +// start a motor - essentially just switch it on like a normal motor +Motor.prototype.start = function(speed) { + // Send a signal to turn on the motor and run at given speed in whatever + // direction is currently set. + if (this.pins.brake && this.braking) { + this.setPin(this.pins.brake, 0); + } + + // get current speed if nothing provided. + speed = typeof speed !== "undefined" ? + speed : this.speed(); + + this.speed({ + speed: speed, + braking: false + }); + + // "start" event is fired when the motor is started + if (speed > 0) { + process.nextTick(this.emit.bind(this, "start")); + } + + return this; +}; + +Motor.prototype.stop = function() { + this.speed({ + speed: 0, + saveSpeed: false + }); + process.nextTick(this.emit.bind(this, "stop")); + + return this; +}; + +Motor.prototype.brake = function(duration) { + if (typeof this.pins.brake === "undefined") { + if (this.board.io.name !== "Mock") { + console.log("Non-braking motor type"); + } + this.stop(); + } else { + this.setPin(this.pins.brake, 1); + this.setPin(this.pins.dir, 1); + this.speed({ + speed: 255, + saveSpeed: false, + braking: true + }); + process.nextTick(this.emit.bind(this, "brake")); + + if (duration) { + var motor = this; + this.board.wait(duration, function() { + motor.resume(); + }); + } + } + + return this; +}; + +Motor.prototype.release = function() { + this.resume(); + process.nextTick(this.emit.bind(this, "release")); + + return this; +}; + +Motor.prototype.resume = function() { + var speed = this.speed(); + this.dir(speed, this.direction); + this.start(speed); + + return this; +}; + +[ + /** + * forward Turn the Motor in its forward direction + * fwd Turn the Motor in its forward direction + * + * @param {Number} 0-255, 0 is stopped, 255 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + value: 1 + }, + /** + * reverse Turn the Motor in its reverse direction + * rev Turn the Motor in its reverse direction + * + * @param {Number} 0-255, 0 is stopped, 255 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + value: 0 + } +].forEach(function(dir) { + var method = function(speed) { + this.dir(speed, dir); + this.start(speed); + return this; + }; + + Motor.prototype[dir.name] = Motor.prototype[dir.abbr] = method; +}); + +Motor.SHIELD_CONFIGS = { + ADAFRUIT_V1: { + M1: { + pins: { pwm: 11 }, + register: { data: 8, clock: 4, latch: 12 }, + bits: { a: 2, b: 3 } + }, + M2: { + pins: { pwm: 3 }, + register: { data: 8, clock: 4, latch: 12 }, + bits: { a: 1, b: 4 } + }, + M3: { + pins: { pwm: 6 }, + register: { data: 8, clock: 4, latch: 12 }, + bits: { a: 5, b: 7 } + }, + M4: { + pins: { pwm: 5 }, + register: { data: 8, clock: 4, latch: 12 }, + bits: { a: 0, b: 6 } + } + }, + ADAFRUIT_V2: { + M1: { + pins: { pwm: 8, dir: 9, cdir: 10 }, + address: 0x60, + controller: "PCA9685" + }, + M2: { + pins: { pwm: 13, dir: 12, cdir: 11 }, + address: 0x60, + controller: "PCA9685" + }, + M3: { + pins: { pwm: 2, dir: 3, cdir: 4 }, + address: 0x60, + controller: "PCA9685" + }, + M4: { + pins: { pwm: 7, dir: 6, cdir: 5 }, + address: 0x60, + controller: "PCA9685" + } + }, + SEEED_STUDIO: { + A: { + pins: { pwm:9, dir:8, cdir: 11 } + }, + B: { + pins: { pwm:10, dir:12, cdir: 13 } + } + }, + FREETRONICS_HBRIDGE: { + A: { + pins: { pwm: 6, dir: 4, cdir: 7 } + }, + B: { + pins: { pwm: 5, dir: 3, cdir: 2 } + } + }, + ARDUINO_MOTOR_SHIELD_R3_1: { + A: { + pins: { pwm: 3, dir: 12 } + }, + B: { + pins: { pwm: 11, dir: 13 } + } + }, + ARDUINO_MOTOR_SHIELD_R3_2: { + A: { + pins: { pwm: 3, dir: 12, brake: 9 } + }, + B: { + pins: { pwm: 11, dir: 13, brake: 8 } + } + }, + ARDUINO_MOTOR_SHIELD_R3_3: { + A: { + pins: { pwm: 3, dir: 12, brake: 9, current: "A0" } + }, + B: { + pins: { pwm: 11, dir: 13, brake: 8, current: "A1" } + } + }, + DF_ROBOT: { + A: { + pins: { pwm: 6, dir: 7 } + }, + B: { + pins: { pwm: 5, dir: 4 } + } + }, + NKC_ELECTRONICS_KIT: { + A: { + pins: { pwm: 9, dir: 12 } + }, + B: { + pins: { pwm: 10, dir: 13 } + } + }, + RUGGED_CIRCUITS: { + A: { + pins: { pwm: 3, dir: 12 } + }, + B: { + pins: { pwm: 11, dir: 13 } + } + }, + SPARKFUN_ARDUMOTO: { + A: { + pins: { pwm: 3, dir: 12 } + }, + B: { + pins: { pwm: 11, dir: 13 } + } + }, + POLOLU_DRV8835_SHIELD: { + M1: { + pins: { pwm: 9, dir: 7 } + }, + M2: { + pins: { pwm: 10, dir: 8 } + } + } +}; + + +/** + * Motors() + * new Motors() + * + * Constructs an Array-like instance of all servos + */ +function Motors(numsOrObjects) { + if (!(this instanceof Motors)) { + return new Motors(numsOrObjects); + } + + Object.defineProperty(this, "type", { + value: Motor + }); + + Collection.call(this, numsOrObjects); +} + +Motors.prototype = Object.create(Collection.prototype, { + constructor: { + value: Motors + } +}); + + +/* + * Motors, forward(speed)/fwd(speed) + * + * eg. array.forward(speed); + + * Motors, reverse(speed)/rev(speed) + * + * eg. array.reverse(speed); + + * Motors, start(speed) + * + * eg. array.start(speed); + + * Motors, stop() + * + * eg. array.stop(); + + * Motors, brake() + * + * eg. array.brake(); + + * Motors, release() + * + * eg. array.release(); + */ + +Object.keys(Motor.prototype).forEach(function(method) { + // Create Motors wrappers for each method listed. + // This will allow us control over all Motor instances + // simultaneously. + Motors.prototype[method] = function() { + var length = this.length; + + for (var i = 0; i < length; i++) { + this[i][method].apply(this[i], arguments); + } + return this; + }; +}); + + +if (IS_TEST_MODE) { + Motor.purge = function() { + priv.clear(); + registers.clear(); + }; +} + +// Assign Motors Collection class as static "method" of Motor. +Motor.Array = Motors; + +module.exports = Motor; + +// References +// http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM diff --git a/JavaScript/node_modules/johnny-five/lib/nodebot.js b/JavaScript/node_modules/johnny-five/lib/nodebot.js new file mode 100644 index 0000000..d063901 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/nodebot.js @@ -0,0 +1,298 @@ +var Servo = require("../lib/servo.js"), + __ = require("../lib/fn.js"), + DIR_TRANSLATION, + temporal; + + +function scale(speed, low, high) { + return Math.floor(__.scale(speed, 0, 5, low, high)); +} + +DIR_TRANSLATION = { + reverse: { + right: "left", + left: "right", + fwd: "rev", + rev: "fwd" + }, + translations: [{ + f: "forward", + r: "reverse", + fwd: "forward", + rev: "reverse" + }, { + r: "right", + l: "left" + }] +}; + +function Movement(move) { + __.extend(this, move, { + timestamp: Date.now() + }); +} + +Movement.prototype.toString = function() { + return "<" + [this.timestamp, "L" + this.left, "R" + this.right].join(" ") + ">"; +}; + +/** + * Nodebot + * @param {Object} opts Optional properties object + */ + +function Nodebot(opts) { + + opts.board = opts.board || null; + + // Boe Nodebot continuous are calibrated to stop at 90° + this.center = opts.center || 90; + + if (typeof opts.right === "number") { + opts.right = new Servo({ + board: opts.board, + pin: opts.right, + type: "continuous" + }); + } + + if (typeof opts.left === "number") { + opts.left = new Servo({ + board: opts.board, + pin: opts.left, + type: "continuous" + }); + } + + // Initialize the right and left cooperative servos + this.servos = { + right: opts.right, + left: opts.left + }; + + // Set the initial servo cooperative direction + this.direction = { + right: this.center, + left: this.center + }; + + // Store the cooperative speed + this.speed = opts.speed === undefined ? 0 : opts.speed; + + // Used to record a recallable history of movement. + this.history = []; + + // Initial motion state + this.motion = "forward"; + + // Track directional state + this.isTurning = false; + + // Garbage hack to avoid including + if (!temporal) { + temporal = require("temporal"); + } + + + // Wait 10ms, send fwd pulse on, then off to + // "wake up" the servos + temporal.wait(10, function() { + this.fwd(1).fwd(0); + }.bind(this)); +} + + +Nodebot.DIR_TRANSLATION = DIR_TRANSLATION; + +/** + * move Move the bot in an arbitrary direction + * @param {Number} right Speed/Direction of right servo + * @param {Number} left Speed/Direction of left servo + * @return {Object} this + */ +Nodebot.prototype.move = function(right, left) { + + // Quietly ignore duplicate instructions + if (this.direction.right === right && + this.direction.left === left) { + return this; + } + + // Cooperative servo motion. + // Servos are mounted opposite of each other, + // the values for left and right will be in + // opposing directions. + this.servos.right.to(right); + this.servos.left.to(left); + + // Push a record object into the history + this.history.push({ + timestamp: Date.now(), + right: right, + left: left + }); + + // Update the stored direction state + this.direction.right = right; + this.direction.left = left; + + return this; +}; + + +[ + /** + * forward Move the bot forward + * fwd Move the bot forward + * + * @param {Number} 0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "forward", + abbr: "fwd", + toArguments: function(center, val) { + return [center - (val - center), val]; + } + }, + + /** + * reverse Move the bot in reverse + * rev Move the bot in reverse + * + * @param {Number}0-5, 0 is stopped, 5 is fastest + * @return {Object} this + */ + { + name: "reverse", + abbr: "rev", + toArguments: function(center, val) { + return [val, center - (val - center)]; + } + } + +].forEach(function(dir) { + + var method = function(speed) { + // Set default direction method + speed = speed === undefined ? this.speed : speed; + + this.speed = speed; + this.motion = dir.name; + + return this.move.apply(this, + dir.toArguments(this.center, scale(speed, this.center, 110)) + ); + }; + + Nodebot.prototype[dir.name] = Nodebot.prototype[dir.abbr] = method; +}); + +/** + * stop Stops the bot, regardless of current direction + * @return {Object} this + */ +Nodebot.prototype.stop = function() { + this.speed = this.center; + this.motion = "stop"; + + return this.move(this.center, this.center); +}; + + +[ + /** + * right Turn the bot right + * @return {Object} this + */ + "right", + + /** + * left Turn the bot left + * @return {Object} this + */ + "left" + +].forEach(function(dir) { + Nodebot.prototype[dir] = function(time) { + + if (dir === "right") { + this.move(110, 110); + } else { + this.move(70, 70); + } + + if (time) { + temporal.wait(time, this[this.motion].bind(this)); + } + + return this; + }; +}); + + +/** + * pivot Pivot the bot with combo directions: + * rev Move the bot in reverse + * + * @param {String} which Combination directions: + * "forward-right", "forward-left", + * "reverse-right", "reverse-left" + * (aliased as: "f-l", "f-r", "r-r", "r-l") + * + * @return {Object} this + */ +Nodebot.prototype.pivot = function(instruct, time) { + var directions, scaled, expansion; + + scaled = scale(this.speed, this.center, 110); + + // Directions are declared where |this| is in scope + directions = { + "forward-right": function() { + this.move(this.center, scaled); + }, + "forward-left": function() { + this.move(this.center - (scaled - this.center), this.center); + }, + "reverse-right": function() { + this.move(scaled, this.center); + }, + "reverse-left": function() { + this.move(this.center, this.center - (scaled - this.center)); + } + }; + + // + expansion = this.pivot.translate(instruct); + instruct = directions[instruct] || directions[expansion]; + + // Commence pivot... + instruct.call(this, this.speed); + + // ...Until... time or 1000ms and then + temporal.wait(time || 1000, function() { + this[this.motion](this.speed); + }.bind(this)); + + return this; +}; + + +Nodebot.prototype.pivot.translate = function(instruct) { + var instructions; + + if (instruct.length === 2) { + instructions = [instruct[0], instruct[1]]; + } + + if (/\-/.test(instruct)) { + instructions = instruct.split("-"); + } + + return instructions.map(function(val, i) { + return DIR_TRANSLATION.translations[i][val]; + }).join("-"); +}; + +module.exports = Nodebot; diff --git a/JavaScript/node_modules/johnny-five/lib/pid.js b/JavaScript/node_modules/johnny-five/lib/pid.js new file mode 100644 index 0000000..4182c22 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/pid.js @@ -0,0 +1,163 @@ +if (typeof Map !== "function") { + require("/usr/local/lib/node_modules/es6-shim"); +} + +var priv = new Map(); + +// * (P)roportional +// * (I)ntegral +// * (D)erivative +function PID(opts) { + + var state = { + range: opts.range || [0, 180], + direction: opts.direction || PID.FORWARD, + sampleTime: 100, + lastTime: Date.now() - 100, + lastInput: 0, + kp: opts.kp || 1, + ki: opts.ki || 0.05, + kd: opts.kd || 0.25, + }; + + this.point = 0; + this.output = 0; + + priv.set(this, state); + + this.tune(opts.kp, opts.ki, opts.kd); +} + +PID.FORWARD = 1; +PID.REVERSE = -1; + +PID.prototype = { + constructor: PID, + + get range() { + return priv.get(this).range; + }, + set range(value) { + var state = priv.get(this); + + if (Array.isArray(value)) { + state.range[0] = value[0]; + state.range[1] = value[1]; + } + }, + + get direction() { + return priv.get(this).direction; + }, + set direction(value) { + var state = priv.get(this); + + if (value === PID.FORWARD || value === PID.REVERSE) { + state.direction = value; + } + }, + + get sampleTime() { + return priv.get(this).sampleTime; + }, + set sampleTime(value) { + var state, ratio; + + if (value > 0) { + state = priv.get(this); + + ratio = value / state.sampleTime; + + state.ki *= ratio; + state.kd /= ratio; + + state.sampleTime = value; + } + }, + + tune: function(kp, ki, kd) { + var state, seconds; + + if (kp < 0 || ki < 0 || kd < 0) { + return false; + } + + state = priv.get(this); + seconds = state.sampleTime / 1000; + + state.kp = kp; + state.ki = ki * seconds; + state.kd = kd / seconds; + + state.kp *= state.direction; + state.ki *= state.direction; + state.kd *= state.direction; + + return true; + }, + + compute: function(input) { + var state = priv.get(this); + var now = Date.now(); + var diffTime = (now - state.lastTime); + var min = state.range[0]; + var max = state.range[1]; + var temp = this.output; + var output, error, diffInput; + + if (diffTime >= state.sampleTime) { + state.lastInput = input; + state.lastTime = now; + + error = this.point - input; + + temp += state.ki * error; + temp = Math.max(Math.min(temp, max), min); + + diffInput = input - state.lastInput; + + output = (state.kp * error) + temp - (state.kd * diffInput); + output = Math.max(Math.min(output, max), min); + + this.output = output; + } + + return this.output; + } +}; + +/* +var PITCH_P_VAL = 0.5; +var PITCH_I_VAL = 0; +var PITCH_D_VAL = 1; + +var pitch = new PID({ + kp: PITCH_P_VAL, + ki: PITCH_I_VAL, + kd: PITCH_D_VAL, + direction: PID.REVERSE, + range: [-20, 20] +}); + +// Update to speed value. +pitch.point = 30; + + +var last = 10; +setInterval(function() { + var value = ++last; + + last = value; + + console.log( value, pitch.compute(value) ); + + if (value > 30) { + last = 30; + } +}, 50); +*/ + +module.exports = PID; + + +// kp=0.25, ki=0.0009, kd=0.002 diff --git a/JavaScript/node_modules/johnny-five/lib/piezo.js b/JavaScript/node_modules/johnny-five/lib/piezo.js new file mode 100644 index 0000000..b674ed4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/piezo.js @@ -0,0 +1,330 @@ +var Board = require("../lib/board.js"), + Timer = require("nanotimer"); + +function Piezo(opts) { + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + // Hardware instance properties + this.mode = this.io.MODES.OUTPUT; + this.pin = opts.pin || 3; + + this.io.pinMode(this.pin, this.mode); + + // Piezo instance properties + this.isPlaying = false; +} + +// These notes are rounded up at .5 otherwise down. +Piezo.Notes = { + "c0": 16, + "c#0": 17, + "d0": 18, + "d#0": 19, + "e0": 21, + "f0": 22, + "f#0": 23, + "g0": 25, + "g#0": 26, + "a0": 28, + "a#0": 29, + "b0": 31, + "c1": 33, + "c#1": 35, + "d1": 37, + "d#1": 39, + "e1": 41, + "f1": 44, + "f#1": 47, + "g1": 49, + "g#1": 52, + "a1": 55, + "a#1": 58, + "b1": 62, + "c2": 65, + "c#2": 69, + "d2": 73, + "d#2": 78, + "e2": 82, + "f2": 87, + "f#2": 93, + "g2": 98, + "g#2": 104, + "a2": 110, + "a#2": 117, + "b2": 124, + "c3": 131, + "c#3": 139, + "d3": 147, + "d#3": 156, + "e3": 165, + "f3": 175, + "f#3": 185, + "g3": 196, + "g#3": 208, + "a3": 220, + "a#3": 233, + "b3": 247, + "c4": 262, + "c#4": 277, + "d4": 294, + "d#4": 311, + "e4": 330, + "f4": 349, + "f#4": 370, + "g4": 392, + "g#4": 415, + "a4": 440, + "a#4": 466, + "b4": 494, + "c5": 523, + "c#5": 554, + "d5": 587, + "d#5": 622, + "e5": 659, + "f5": 698, + "f#5": 740, + "g5": 784, + "g#5": 831, + "a5": 880, + "a#5": 932, + "b5": 988, + "c6": 1047, + "c#6": 1109, + "d6": 1175, + "d#6": 1245, + "e6": 1319, + "f6": 1397, + "f#6": 1480, + "g6": 1568, + "g#6": 1661, + "a6": 1760, + "a#6": 1865, + "b6": 1976, + "c7": 2093, + "c#7": 2217, + "d7": 2349, + "d#7": 2489, + "e7": 2637, + "f7": 2794, + "f#7": 2960, + "g7": 3136, + "g#7": 3322, + "a7": 3520, + "a#7": 3729, + "b7": 3951, + "c8": 4186, + "c#8": 4435, + "d8": 4699, + "d#8": 4978, + "e8": 5274, + "f8": 5588, + "f#8": 5920, + "g8": 6272, + "g#8": 6645, + "a8": 7040, + "a#8": 7459, + "b8": 7902 +}; + +function clearTimer() { + if (!this.timer) { + return; + } + + this.timer.clearInterval(); + delete this.timer; +} + +/** + * Get the tone from the current note. note + * could be an int, string, array or null. + * If int or null, leave alone. Otherwise, + * derive what the tone should be. + * @return int | null + */ +function parseTone(note) { + var tone = note; + if (Array.isArray(note)) { + tone = note[0]; + } + if (typeof tone === "string") { + tone = tone.toLowerCase(); + + var needsOctave = isNaN(tone.substr(tone.length -1)); + if (needsOctave) { + tone = tone + Piezo.prototype.defaultOctave().toString(); + } + + tone = (Piezo.Notes[tone]) ? Piezo.Notes[tone] : null; + } + if (isNaN(tone)) { + tone = null; + } + return tone; +} + +/** + * Obtain the beat/duration count from the current + * note. This is either an int or undefined. Default + * to 1. + * @return int (default 1) + */ +function parseBeat(note) { + var beat = 1; + if (Array.isArray(note) && note[1] !== undefined) { + // If extant, beat will be second element of note + beat = note[1]; + } + return beat; +} + +/** + * Validate the octave provided to ensure the value is + * supported and won't crash the board. + * @return bool + */ +function isValidOctave(octave) { + // octave should be a number. + if (octave && !isNaN(octave) && + (octave >= 0 && octave <= 8)) { + return true; + } + + return false; +} + +Piezo.prototype.defaultOctave = function(octave) { + if (typeof this.defaultOctave.value === "undefined") { + this.defaultOctave.value = 4; + } + + if (isValidOctave(octave)) { + this.defaultOctave.value = octave; + } + + return this.defaultOctave.value; +}; + +Piezo.prototype.note = function(note, duration) { + var tone = parseTone(note); + + return this.tone(tone, duration); +}; + +Piezo.prototype.tone = function(tone, duration) { + if (isNaN(tone) || isNaN(duration)) { + // Very Bad Things happen if one tries to play a NaN tone + throw new Error( + "Piezo.tone: invalid tone or duration" + ); + } + + clearTimer.call(this); + + var timer = this.timer = new Timer(); + var value = 1; + + timer.setInterval(function() { + value = value === 1 ? 0 : 1; + this.io.digitalWrite(this.pin, value); + + if ((timer.difTime / 1000000) > duration) { + clearTimer.call(this); + } + }.bind(this), null, tone + "u", function() {}); + + return this; +}; + +Piezo.prototype.frequency = function(frequency, duration) { + var period = 1 / frequency; + var duty = period / 2; + var tone = Math.round(duty * 1000000); + + return this.tone(tone, duration); +}; + +function stringToSong(stringSong, beats) { + beats = beats || 1; + var notes = stringSong.match(/\S+/g); + var song = []; + var note, lastNote; + while (notes.length) { + note = notes.shift(); + if (/^[0-9]+$/.test(note)) { + note = parseInt(note, 10); + } + lastNote = song[song.length - 1]; + if (lastNote && lastNote[0] === note) { + lastNote[1] += beats; + } else { + song.push([note, beats]); + } + } + return song; +} + +Piezo.prototype.play = function(tune, callback) { + if (typeof tune !== "object") { + tune = { + song: tune + }; + } + if (typeof tune.song === "string") { + tune.song = stringToSong(tune.song, tune.beats); + } + var duration, + tempo = tune.tempo || 250, + beatDuration = Math.round(60000 / tempo), // Length for a single beat in ms + song = tune.song || [], + i = 0; + if (song && !Array.isArray(song)) { + song = [song]; + } + var next = function() { + var note, beat; + + note = parseTone(song[i]); + beat = parseBeat(song[i]); + + duration = beat * beatDuration; + + if (i++ === song.length) { + // Song is over + this.isPlaying = false; + if (typeof callback === "function") { + callback(tune); + } + return; + } + + if (note === null) { + this.noTone(); + } else { + this.frequency(note, duration); + } + + setTimeout(next, duration); + }.bind(this); + + // We are playing a song + this.isPlaying = true; + + next(); + + return this; +}; + +Piezo.prototype.noTone = function() { + this.io.digitalWrite(this.pin, 0); + clearTimer.call(this); + + return this; +}; + +Piezo.prototype.off = Piezo.prototype.noTone; + +module.exports = Piezo; diff --git a/JavaScript/node_modules/johnny-five/lib/pin.js b/JavaScript/node_modules/johnny-five/lib/pin.js new file mode 100644 index 0000000..b74e6ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/pin.js @@ -0,0 +1,337 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../lib/board.js"); +var Descriptor = require("descriptor"); +var Emitter = require("events").EventEmitter; +var util = require("util"); +var Collection = require("../lib/mixins/collection"); + +var priv = new Map(); +var modes = { + INPUT: 0x00, + OUTPUT: 0x01, + ANALOG: 0x02, + PWM: 0x03, + SERVO: 0x04 +}; + +/** + * Pin + * @constructor + * + * @description Direct Pin access objects + * + * @param {Object} opts Options: pin, freq, range + */ + +function Pin(opts) { + if (!(this instanceof Pin)) { + return new Pin(opts); + } + if (opts === undefined || (typeof opts === "object" && + opts.addr === undefined && opts.pin === undefined) + ) { + throw new Error("Pins must have a pin number"); + } + + var pinValue = typeof opts === "object" ? (opts.addr || opts.pin || 0) : opts; + var isAnalogInput = Pin.isAnalog(opts); + var isDTOA = false; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + opts.addr = opts.addr || opts.pin; + + if (this.io.analogPins.includes(pinValue)) { + isAnalogInput = false; + isDTOA = true; + } + + var isPin = typeof opts !== "object"; + var addr = isDTOA ? pinValue : (isPin ? opts : opts.addr); + var type = opts.type || (isAnalogInput ? "analog" : "digital"); + + // Create a private side table + var state = { + mode: null, + last: null, + value: 0 + }; + + priv.set(this, state); + + // Create read-only "addr(address)" property + Object.defineProperties(this, { + type: new Descriptor(type), + addr: new Descriptor(addr, "!writable"), + value: { + get: function() { + return state.value; + } + }, + mode: { + set: function(mode) { + var state = priv.get(this); + state.mode = mode; + this.io.pinMode(this.addr, mode); + }, + get: function() { + return priv.get(this).mode; + } + } + }); + + this.mode = typeof opts.as !== "undefined" ? opts.as : + (typeof opts.mode !== "undefined" ? opts.mode : (isAnalogInput ? 0x02 : 0x01)); + + this.freq = typeof opts.freq !== "undefined" ? opts.freq : 20; + + if (this.mode === 0 || this.mode === 2) { + read(this); + } +} + + +function read(pin) { + var state = priv.get(pin); + + pin.io[pin.type + "Read"](pin.addr, function(data) { + state.value = data; + }); + + setInterval(function() { + var isNot, emit; + + isNot = state.value ? "low" : "high"; + emit = state.value ? "high" : "low"; + + if (state.mode === modes.INPUT) { + if (state.last === null) { + state.last = isNot; + } + if (state.last === isNot) { + state.last = emit; + pin.emit(emit, state.value); + pin.emit("change", state.value); + } + } + pin.emit("data", state.value); + }, pin.freq); +} + +util.inherits(Pin, Emitter); + +/** + * Pin.@@MODE + * + * Read-only constants + * Pin.INPUT = 0x00 + * Pin.OUTPUT = 0x01 + * Pin.ANALOG = 0x02 + * Pin.PWM = 0x03 + * Pin.SERVO = 0x04 + * + */ +Object.keys(modes).forEach(function(mode) { + Object.defineProperty(Pin, mode, { + value: modes[mode] + }); +}); + + +Pin.isAnalog = function(opts) { + if (typeof opts === "string" && Pin.isPrefixed(opts, ["I", "A"])) { + return true; + } + + if (typeof opts === "object") { + return Pin.isAnalog( + typeof opts.addr !== "undefined" ? opts.addr : opts.pin + ); + } +}; + +Pin.isPrefixed = function(value, prefixes) { + value = value[0]; + + return prefixes.reduce(function(resolution, prefix) { + if (!resolution) { + return prefix === value; + } + return resolution; + }, false); +}; + +Pin.write = function(pin, val) { + var state = priv.get(pin); + + state.value = val; + + // Set the correct mode (OUTPUT) + // This will only set if it needs to be set, otherwise a no-op + pin.mode = modes.OUTPUT; + + // Create the correct type of write command + pin.io[pin.type + "Write"](pin.addr, val); + + pin.emit("write", null, val); +}; + +Pin.read = function(pin, callback) { + // Set the correct mode (INPUT) + // This will only set if it needs to be set, otherwise a no-op + + var isChanging = false; + + if (pin.type === "digital" && pin.mode !== 0) { + isChanging = true; + pin.mode = modes.INPUT; + } + + if (pin.type === "analog" && pin.mode !== 2) { + isChanging = true; + pin.mode = modes.ANALOG; + } + + if (isChanging) { + read(pin); + } + + pin.on("data", function() { + callback.call(pin, null, pin.value); + }); +}; + + +// Pin.prototype.isDigital = function() { +// return this.addr > 1; +// }; + +// Pin.prototype.isAnalog = function() { +// return this.board > 1; +// }; + +// Pin.prototype.isPWM = function() { +// }; + +// Pin.prototype.isServo = function() { +// }; + +// Pin.prototype.isI2C = function() { +// }; + +// Pin.prototype.isSerial = function() { +// }; + +// Pin.prototype.isInterrupt = function() { +// }; + +// Pin.prototype.isVersion = function() { +// }; + + +Pin.prototype.query = function(callback) { + var index = this.addr; + + if (this.type === "analog") { + index = this.io.analogPins[this.addr]; + } + + function handler() { + callback(this.io.pins[index]); + } + + this.io.queryPinState(index, handler.bind(this)); + + return this; +}; + +/** + * high Write high/1 to the pin + * @return {Pin} + */ + +Pin.prototype.high = function() { + var value = this.type === "analog" ? 255 : 1; + Pin.write(this, value); + this.emit("high"); + return this; +}; + +/** + * low Write low/0 to the pin + * @return {Pin} + */ + +Pin.prototype.low = function() { + Pin.write(this, 0); + this.emit("low"); + return this; +}; + +/** + * read Read from the pin, value is passed to callback continuation + * @return {Pin} + */ + +/** + * write Write to a pin + * @return {Pin} + */ +["read", "write"].forEach(function(operation) { + Pin.prototype[operation] = function(valOrCallback) { + Pin[operation](this, valOrCallback); + return this; + }; +}); + + +/** + * Pins() + * new Pins() + * + * Constructs an Array-like instance of all servos + */ +function Pins(numsOrObjects) { + if (!(this instanceof Pins)) { + return new Pins(numsOrObjects); + } + + Object.defineProperty(this, "type", { + value: Pin + }); + + Collection.call(this, numsOrObjects); +} + +Pins.prototype = Object.create(Collection.prototype, { + constructor: { + value: Pins + } +}); + + +[ + "high", "low", "write" +].forEach(function(method) { + Pins.prototype[method] = function() { + var length = this.length; + + for (var i = 0; i < length; i++) { + this[i][method].apply(this[i], arguments); + } + return this; + }; +}); + +if (IS_TEST_MODE) { + Pin.purge = function() { + priv.clear(); + }; +} + +// Assign Pins Collection class as static "method" of Pin. +Pin.Array = Pins; + +module.exports = Pin; diff --git a/JavaScript/node_modules/johnny-five/lib/ping.js b/JavaScript/node_modules/johnny-five/lib/ping.js new file mode 100644 index 0000000..13a998d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/ping.js @@ -0,0 +1,120 @@ +var Board = require("../lib/board.js"), + Emitter = require("events").EventEmitter, + util = require("util"), + within = require("./mixins/within"), + __ = require("./fn"); + +var priv = new Map(); + +/** + * Ping + * @param {Object} opts Options: pin + */ + +function Ping(opts) { + + if (!(this instanceof Ping)) { + return new Ping(opts); + } + + var last = null; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + this.pin = opts && opts.pin || 7; + this.freq = opts.freq || 20; + // this.pulse = opts.pulse || 250; + + var state = { + value: null + }; + + // Private settings object + var settings = { + pin: this.pin, + value: this.io.HIGH, + pulseOut: 5 + }; + + this.io.setMaxListeners(100); + + // Interval for polling pulse duration as reported in microseconds + setInterval(function() { + this.io.pingRead(settings, function(microseconds) { + state.value = microseconds; + }); + }.bind(this), 225); + + // Interval for throttled event + setInterval(function() { + var err = null; + + if (state.value === null) { + return; + } + + // median = samples.sort()[samples.length / 2 | 0]; + + // if (!median) { + // median = last; + // } + + // @DEPRECATE + this.emit("read", err, state.value); + + // The "read" event has been deprecated in + // favor of a "data" event. + this.emit("data", err, state.value); + + // If the state.value for this interval is not the same as the + // state.value in the last interval, fire a "change" event. + if (state.value !== last) { + this.emit("change", err, state.value); + } + + // Store state.value for comparison in next interval + last = state.value; + + // Reset samples; + // samples.length = 0; + }.bind(this), this.freq); + + Object.defineProperties(this, { + value: { + get: function() { + return state.value; + } + }, + // Based on the round trip travel time in microseconds, + // Calculate the distance in inches and centimeters + inches: { + get: function() { + return +(state.value / 74 / 2).toFixed(2); + } + }, + in: { + get: function() { + return this.inches; + } + }, + cm: { + get: function() { + return +(state.value / 29 / 2).toFixed(3); + } + } + }); + + priv.set(this, state); +} + +util.inherits(Ping, Emitter); +__.mixin(Ping.prototype, within); + +module.exports = Ping; + + +//http://itp.nyu.edu/physcomp/Labs/Servo +//http://arduinobasics.blogspot.com/2011/05/arduino-uno-flex-sensor-and-leds.html +//http://protolab.pbworks.com/w/page/19403657/TutorialPings diff --git a/JavaScript/node_modules/johnny-five/lib/pir.js b/JavaScript/node_modules/johnny-five/lib/pir.js new file mode 100644 index 0000000..c274f1e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/pir.js @@ -0,0 +1,74 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"); + +/** + * Pir, IR.Motion + * @deprecated + * @param {Object} opts Options: pin, type, id, range + */ + +function Pir(opts) { + + if (!(this instanceof Pir)) { + return new Pir(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + // Set the pin to INPUT mode + this.mode = this.io.MODES.INPUT; + this.io.pinMode(this.pin, this.mode); + + // PIR instance properties + this.value = null; + this.isCalibrated = false; + this.freq = opts.freq || 25; + + // Analog Read event loop + // TODO: make this "throttle-able" + this.io.digitalRead(this.pin, function(data) { + var timestamp = Date.now(), + err = null; + + // If this is not a calibration event + if (this.value != null && this.value !== +data) { + + // Update current value of PIR instance + this.value = +data; + + // "motionstart" event fired when motion occurs + // within the observable range of the PIR sensor + if (data) { + this.emit("motionstart", err, timestamp); + } + + // "motionend" event fired when motion has ceased + // within the observable range of the PIR sensor + if (!data) { + this.emit("motionend", err, timestamp); + } + } + + // "calibrated" event fired when PIR sensor is + // ready to detect movement/motion in observable range + if (!this.isCalibrated) { + this.isCalibrated = true; + this.value = +data; + this.emit("calibrated", err, timestamp); + } + }.bind(this)); + + setInterval(function() { + this.emit("data", null, Date.now()); + }.bind(this), this.freq); +} + +util.inherits(Pir, events.EventEmitter); + +module.exports = Pir; + +// More information: +// http://www.ladyada.net/learn/sensors/pir.html diff --git a/JavaScript/node_modules/johnny-five/lib/proximity.js b/JavaScript/node_modules/johnny-five/lib/proximity.js new file mode 100644 index 0000000..d9e4de3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/proximity.js @@ -0,0 +1,376 @@ +var Board = require("../lib/board.js"), + within = require("./mixins/within"), + __ = require("./fn"), + events = require("events"), + util = require("util"); + +function analogHandler(opts, dataHandler) { + + this.io.pinMode(this.pin, this.io.MODES.ANALOG); + + this.io.analogRead(this.pin, function(data) { + dataHandler.call(this, data); + }.bind(this)); + +} + +var Controllers = { + GP2Y0A21YK: { + // https://www.sparkfun.com/products/242 + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + return +(12343.85 * Math.pow(raw, -1.15)).toFixed(2); + } + } + }, + GP2D120XJ00F: { + // https://www.sparkfun.com/products/8959 + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + return +((2914 / (raw + 5)) - 1).toFixed(2); + } + } + }, + GP2Y0A02YK0F: { + // https://www.sparkfun.com/products/8958 + // 15cm - 150cm + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + return +(10650.08 * Math.pow(raw, -0.935) - 10).toFixed(2); + } + } + }, + GP2Y0A41SK0F: { + // https://www.sparkfun.com/products/12728 + // 4cm - 30cm + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + return +(2076 / (raw - 11)).toFixed(2); + } + } + }, + GP2Y0A710K0F: { + // https://www.adafruit.com/products/1568 + // 100cm - 500cm + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + // http://www.basicx.com/Products/robotbook/ir%20curve%20fit.pdf + return 3.8631e8 * Math.pow(raw, -2.463343); + } + } + }, + SRF10: { + initialize: { + value: function(opts, dataHandler) { + + var address = 0x70; + var delay = 65; + + // Set up I2C data connection + this.io.i2cConfig(0); + + // Startup parameter + this.io.i2cWrite(address, [0x01, 16]); + this.io.i2cWrite(address, [0x02, 255]); + + function read() { + this.io.i2cWrite(address, [0x02]); + this.io.i2cReadOnce(address, 2, function(data) { + dataHandler((data[0] << 8) | data[1]); + }.bind(this)); + + prime.call(this); + } + + function prime() { + // 0x51 result in cm (centimeters) + this.io.i2cWrite(address, [0x00, 0x51]); + + setTimeout(read.bind(this), delay); + } + + prime.call(this); + } + }, + toCm: { + value: function(raw) { + return raw; + } + } + }, + // LV-MaxSonar-EZ + // LV-MaxSonar-EZ0 + // LV-MaxSonar-EZ1 + MB1000: { + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + // From http://www.maxbotix.com/articles/032.htm + // ADC -> inches -> cm + return (raw / 2) * 2.54; + } + } + }, + // HRLV-MaxSonar-EZ0 + MB1003: { + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + // http://www.maxbotix.com/articles/032.htm + return raw / 2; + } + } + }, + // XL-MaxSonar-EZ3 + MB1230: { + initialize: { + value: analogHandler + }, + toCm: { + value: function(raw) { + // From http://www.maxbotix.com/articles/016.htm + // Using a Standard Range XL-MaxSonar with an ADC (Analog Digital Converter) + // When using a standard XL-MaxSonar with an ADC, verify that the sensor + // and micro-controller are referencing the same power supply and ground. + // This also assumes that the ADC being used is perfectly accurate. + // When reading the sensor's output with the scaling in centimeters with a + // 10-bit ADC, the range can be read directly off the ADC. + // If the ADC output reads 700 the range in centimeters is 700 centimeters. + // + // ADC -> cm + return raw; + } + } + }, + HCSR04: { + initialize: { + value: function(opts, dataHandler) { + // Private settings object + var settings = { + pin: opts.pin, + value: this.io.HIGH, + pulseOut: 5 + }; + + setInterval(function() { + this.io.pingRead(settings, function(microseconds) { + dataHandler(microseconds); + }); + }.bind(this), opts.freq || 25); + } + }, + toCm: { + value: function(raw) { + return +(raw / 29.1 / 2).toFixed(3); + } + } + }, + LIDARLITE: { + initialize: { + value: function(opts, dataHandler) { + var ADDRESS = 0x62; + var ENABLE = 0x00; + var MEASUREMODE = 0x04; + var READREGISTER = 0x8f; + var BYTES_TO_READ = 0x02; + + this.io.i2cConfig(); + + var read = function() { + this.io.i2cWrite(ADDRESS, ENABLE, MEASUREMODE); + setTimeout(function() { + this.io.i2cReadOnce(ADDRESS, READREGISTER, BYTES_TO_READ, function(bytes) { + // http://www.robotshop.com/media/files/pdf/operating-manual-llm20c132i500s011.pdf + // Step 5 of Quick Start Guide + dataHandler((bytes[0] << 8) + bytes[1]); + read(); + }); + }.bind(this), 20); + }.bind(this); + + read(); + } + }, + toCm: { + value: function(raw) { + return raw; + } + } + } +}; + +// Sensor aliases +// IR +Controllers["2Y0A21"] = Controllers.GP2Y0A21YK; +Controllers["2D120X"] = Controllers.GP2D120XJ00F; +Controllers["2Y0A02"] = Controllers.GP2Y0A02YK0F; +Controllers["0A41"] = Controllers.GP2Y0A41SK0F; +Controllers["0A21"] = Controllers.GP2Y0A21YK; +Controllers["0A02"] = Controllers.GP2Y0A02YK0F; +Controllers["41SK0F"] = Controllers.GP2Y0A41SK0F; +Controllers["21YK"] = Controllers.GP2Y0A21YK; +Controllers["2YK0F"] = Controllers.GP2Y0A02YK0F; + + +// Sonar +Controllers.MB1010 = Controllers.MB1000; + +Controllers["LV-MaxSonar-EZ"] = Controllers.MB1000; +Controllers["LV-MaxSonar-EZ0"] = Controllers.MB1000; +Controllers["LV-MaxSonar-EZ1"] = Controllers.MB1010; +Controllers["HRLV-MaxSonar-EZ0"] = Controllers.MB1003; +Controllers["XL-MaxSonar-EZ3"] = Controllers.MB1230; + +// Ping +Controllers["HC-SR04"] = Controllers.HCSR04; +Controllers["SR04"] = Controllers.HCSR04; +Controllers["SRF05"] = Controllers.HCSR04; +Controllers["SRF06"] = Controllers.HCSR04; +Controllers["PARALLAXPING"] = Controllers.HCSR04; +Controllers["SEEEDPING"] = Controllers.HCSR04; +Controllers["GROVEPING"] = Controllers.HCSR04; +Controllers["PING_PULSE_IN"] = Controllers.HCSR04; + + +// LIDAR Lite +Controllers["LIDAR-Lite"] = Controllers.LIDARLITE; + +/** + * Proximity + * @constructor + * + * five.Proximity("A0"); + * + * five.Proximity({ + * controller: "GP2Y0A41SK0F", + * pin: "A0", + * freq: 100 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Proximity(opts) { + + if (!(this instanceof Proximity)) { + return new Proximity(opts); + } + + var controller; + var raw = 0; + var freq = opts.freq || 25; + var last = 0; + + Board.Device.call( + this, opts = Board.Options(opts) + ); + + if (typeof opts.controller === "string") { + controller = Controllers[opts.controller]; + } else { + controller = opts.controller || Controllers["GP2Y0A21YK"]; + } + + Object.defineProperties(this, controller); + + if (!this.toCm) { + this.toCm = opts.toCm || function(x) { + return x; + }; + } + + Object.defineProperties(this, { + /** + * [read-only] Calculated centimeter value + * @property centimeters + * @type Number + */ + centimeters: { + get: function() { + return this.toCm(raw); + } + }, + cm: { + get: function() { + return this.centimeters; + } + }, + /** + * [read-only] Calculated inch value + * @property inches + * @type Number + */ + inches: { + get: function() { + return +(this.centimeters * 0.39).toFixed(2); + } + }, + in: { + get: function() { + return this.inches; + } + }, + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + raw = data; + }); + } + + setInterval(function() { + if (raw === undefined) { + return; + } + + var data = { + cm: this.cm, + centimeters: this.centimeters, + in : this.in, + inches: this.inches + }; + + this.emit("data", data); + + if (raw !== last) { + last = raw; + this.emit("change", data); + } + }.bind(this), freq); +} + +Proximity.Controllers = [ + "2Y0A21", "GP2Y0A21YK", + "2D120X", "GP2D120XJ00F", + "2Y0A02", "GP2Y0A02YK0F", + "OA41SK", "GP2Y0A41SK0F", + "0A21", "GP2Y0A21YK", + "0A02", "GP2Y0A02YK0F", +]; + +util.inherits(Proximity, events.EventEmitter); + +__.mixin(Proximity.prototype, within); + +module.exports = Proximity; diff --git a/JavaScript/node_modules/johnny-five/lib/reflectancearray.js b/JavaScript/node_modules/johnny-five/lib/reflectancearray.js new file mode 100644 index 0000000..55b41c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/reflectancearray.js @@ -0,0 +1,289 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + __ = require("../lib/fn.js"), + Led = require("../lib/led"), + Sensor = require("../lib/sensor"); + +var CALIBRATED_MIN_VALUE = 0; +var CALIBRATED_MAX_VALUE = 1000; +var LINE_ON_THRESHOLD = 200; +var LINE_NOISE_THRESHOLD = 50; + +var priv = new Map(); + +// Private methods +function initialize() { + var self = this, state = priv.get(this); + + if (typeof this.opts.emitter === "undefined") { + throw new Error("Emitter pin is required"); + } + + if (!this.pins || this.pins.length === 0) { + throw new Error("Pins must be defined"); + } + + state.emitter = new Led({ + board: this.board, + pin: this.opts.emitter + }); + + state.sensorStates = this.pins.map(function(pin) { + var sensorState = { + sensor: new Sensor({ + board: this.board, + freq: this.freq, + pin: pin + }), + rawValue: 0, + dataReceived: false + }; + + + sensorState.sensor.on("data", function() { + onData.call(self, sensorState, this.value); + }); + + return sensorState; + }, this); +} + +function onData(sensorState, value) { + var allRead, state = priv.get(this); + + sensorState.dataReceived = true; + sensorState.rawValue = value; + + allRead = __.every(state.sensorStates, "dataReceived"); + + if (allRead) { + this.emit("data", null, this.raw); + + if (state.autoCalibrate) { + setCalibration(state.calibration, this.raw); + } + + if (this.isCalibrated) { + this.emit("calibratedData", null, this.values); + this.emit("line", null, this.line); + } + + state.sensorStates.forEach(function(sensorState) { + sensorState.dataReceived = false; + }); + } +} + +function setCalibration(calibration, values) { + values.forEach(function(value, i) { + if (calibration.min[i] === undefined || value < calibration.min[i]) { + calibration.min[i] = value; + } + + if (calibration.max[i] === undefined || value > calibration.max[i]) { + calibration.max[i] = value; + } + }); +} + +function calibrationIsValid(calibration, sensors) { + return calibration && + (calibration.max && calibration.max.length === sensors.length) && + (calibration.min && calibration.min.length === sensors.length); +} + + +function calibratedValues() { + return this.raw.map(function(value, i) { + var max = this.calibration.max[i], + min = this.calibration.min[i]; + + var scaled = __.scale(value, min, max, CALIBRATED_MIN_VALUE, CALIBRATED_MAX_VALUE); + return __.constrain(scaled, CALIBRATED_MIN_VALUE, CALIBRATED_MAX_VALUE); + }, this); +} + +function maxLineValue() { + return (this.sensors.length - 1) * CALIBRATED_MAX_VALUE; +} + +// Returns a value between 0 and (n-1)*1000 +// Given 5 sensors, the value will be between 0 and 4000 +function getLine(whiteLine) { + var onLine = false; + var avg = 0, sum = 0; + var state = priv.get(this); + + whiteLine = !!whiteLine; + + this.values.forEach(function(value, i) { + value = whiteLine ? (CALIBRATED_MAX_VALUE - value) : value; + + if (value > LINE_ON_THRESHOLD) { + onLine = true; + } + + if (value > LINE_NOISE_THRESHOLD) { + avg += value * i * CALIBRATED_MAX_VALUE; + sum += value; + } + }); + + if (!onLine) { + var maxPoint = maxLineValue.call(this) + 1; + var centerPoint = maxPoint/2; + + return state.lastLine < centerPoint ? 0 : maxPoint; + } + + return state.lastLine = Math.floor(avg/sum); +} + +// Constructor +function ReflectanceArray(opts) { + + if (!(this instanceof ReflectanceArray)) { + return new ReflectanceArray(opts); + } + + this.opts = Board.Options(opts); + + Board.Component.call( + this, this.opts, { + requestPin: false + } + ); + + // Read event throttling + this.freq = opts.freq || 25; + + // Make private data entry + var state = { + lastLine: 0, + isOn: false, + calibration: { + min: [], + max: [] + }, + autoCalibrate: opts.autoCalibrate || false + }; + + priv.set(this, state); + + initialize.call(this); + + Object.defineProperties(this, { + isOn: { + get: function() { + return state.emitter.isOn; + } + }, + isCalibrated: { + get: function() { + return calibrationIsValid(this.calibration, this.sensors); + } + }, + isOnLine: { + get: function() { + var line = this.line; + return line > CALIBRATED_MIN_VALUE && line < maxLineValue.call(this); + } + }, + sensors: { + get: function() { + return __.pluck(state.sensorStates, "sensor"); + } + }, + calibration: { + get: function() { + return state.calibration; + } + }, + raw: { + get: function() { + return __.pluck(state.sensorStates, "rawValue"); + } + }, + values: { + get: function() { + return this.isCalibrated ? calibratedValues.call(this) : this.raw; + } + }, + line: { + get: function() { + return this.isCalibrated ? getLine.call(this) : 0; + } + } + }); +} + +util.inherits(ReflectanceArray, events.EventEmitter); + +// Public methods +ReflectanceArray.prototype.enable = function() { + var state = priv.get(this); + + state.emitter.on(); + + return this; +}; + +ReflectanceArray.prototype.disable = function() { + var state = priv.get(this); + + state.emitter.off(); + + return this; +}; + +// Calibrate will store the min/max values for this sensor array +// It should be called many times in order to get a lot of readings +// on light and dark areas. See calibrateUntil for a convenience +// for looping until a condition is met. +ReflectanceArray.prototype.calibrate = function() { + var state = priv.get(this); + + this.once("data", function(err, values) { + setCalibration(state.calibration, values); + + this.emit("calibrated"); + }); + + return this; +}; + +// This will continue to calibrate until the predicate is true. +// Allows the user to calibrate n-times, or wait for user input, +// or base it on calibration heuristics. However the user wants. +ReflectanceArray.prototype.calibrateUntil = function(predicate) { + var loop = function() { + this.calibrate(); + this.once("calibrated", function() { + if (!predicate()) { + loop(); + } + }); + }.bind(this); + + loop(); + + return this; +}; + +// Let the user tell us what the calibration data is +// This allows the user to save calibration data and +// reload it without needing to calibrate every time. +ReflectanceArray.prototype.loadCalibration = function(calibration) { + var state = priv.get(this); + + if (!calibrationIsValid(calibration, this.sensors)) { + throw new Error("Calibration data not properly set: {min: [], max: []}"); + } + + state.calibration = calibration; + + return this; +}; + +module.exports = ReflectanceArray; diff --git a/JavaScript/node_modules/johnny-five/lib/relay.js b/JavaScript/node_modules/johnny-five/lib/relay.js new file mode 100644 index 0000000..2939aed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/relay.js @@ -0,0 +1,96 @@ +var Board = require("../lib/board.js"); + +var priv = new Map(); + +function Relay(opts) { + + var state; + + if (!(this instanceof Relay)) { + return new Relay(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + opts.type = opts.type || "NO"; + + state = { + isInverted: opts.type === "NC", + isOn: false, + value: null, + }; + + priv.set(this, state); + + Object.defineProperties(this, { + value: { + get: function() { + return Number(this.isOn); + } + }, + type: { + get: function() { + return state.isInverted ? "NC" : "NO"; + } + }, + isOn: { + get: function() { + return state.isOn; + } + } + }); +} + +/** + * on Turn the relay on + * @return {Relay} + */ +Relay.prototype.on = function() { + var state = priv.get(this); + + this.io.digitalWrite( + this.pin, state.isInverted ? this.io.LOW : this.io.HIGH + ); + state.isOn = true; + + return this; +}; + +Relay.prototype.close = Relay.prototype.on; + +/** + * off Turn the relay off + * @return {Relay} + */ +Relay.prototype.off = function() { + var state = priv.get(this); + + this.io.digitalWrite( + this.pin, state.isInverted ? this.io.HIGH : this.io.LOW + ); + state.isOn = false; + + return this; +}; + +Relay.prototype.open = Relay.prototype.off; + +/** + * toggle Toggle the on/off state of the relay + * @return {Relay} + */ +Relay.prototype.toggle = function() { + var state = priv.get(this); + + if (state.isOn) { + this.off(); + } else { + this.on(); + } + + return this; +}; + +module.exports = Relay; diff --git a/JavaScript/node_modules/johnny-five/lib/repl.js b/JavaScript/node_modules/johnny-five/lib/repl.js new file mode 100644 index 0000000..c1cd6b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/repl.js @@ -0,0 +1,105 @@ +var repl = require("repl"), + events = require("events"), + util = require("util"); + +var priv = new Map(); + +// Ported from +// https://github.com/jgautier/firmata + +function Repl(opts) { + if (!Repl.isActive) { + Repl.isActive = true; + + if (!(this instanceof Repl)) { + return new Repl(opts); + } + + // Store context values in instance property + // this will be used for managing scope when + // injecting new values into an existing Repl + // session. + this.context = {}; + this.ready = false; + + var state = { + opts: opts, + board: opts.board, + }; + + priv.set(this, state); + + // Store an accessible copy of the Repl instance + // on a static property. This is later used by the + // Board constructor to automattically setup Repl + // sessions for all programs, which reduces the + // boilerplate requirement. + Repl.ref = this; + } else { + return Repl.ref; + } +} + +// Inherit event api +util.inherits(Repl, events.EventEmitter); + +Repl.isActive = false; +Repl.isBlocked = false; + +// See Repl.ref notes above. +Repl.ref = null; + +Repl.prototype.initialize = function(callback) { + var state = priv.get(this); + + process.stdin.resume(); + process.stdin.setEncoding("utf8"); + + var replDefaults = { + prompt: ">> ", + useGlobal: false + }; + + // Call this immediately before repl.start to + // avoid crash on Intel Edison + state.board.info("Repl", "Initialized"); + + // Initialize the REPL session with the default + // repl settings. + // Assign the returned repl instance to "cmd" + var cmd = repl.start(replDefaults); + + this.ready = true; + + // Assign a reference to the REPL's "content" object + // This will be use later by the Repl.prototype.inject + // method for allowing user programs to inject their + // own explicit values and reference + this.cmd = cmd; + this.context = cmd.context; + + cmd.on("exit", function() { + state.board.warn("Board", "Closing."); + process.reallyExit(); + }); + + this.inject(state.opts); + + if (callback) { + process.nextTick(callback); + } +}; + +Repl.prototype.close = function() { + this.cmd.emit("exit"); +}; + +Repl.prototype.inject = function(obj) { + Object.keys(obj).forEach(function(key) { + Object.defineProperty( + this.context, key, Object.getOwnPropertyDescriptor(obj, key) + ); + }, this); +}; + +module.exports = Repl; diff --git a/JavaScript/node_modules/johnny-five/lib/resistor-generator.js b/JavaScript/node_modules/johnny-five/lib/resistor-generator.js new file mode 100644 index 0000000..bf788b1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/resistor-generator.js @@ -0,0 +1,73 @@ +// var length = 12; +// var total = length + 1; +// var vrange = Math.floor(1023 / total); +// var ranges = Array.from({ length: total }, function(_, index) { +// var start = vrange * index; + +// console.log(index, index + 1, start, start + vrange - 1); +// return Array.from({ length: vrange - 1 }, function(_, index) { +// return start + index; +// }); +// }); + +/* + 0 1 0 77 + 1 2 78 155 + 2 3 156 233 + 3 4 234 311 + 4 5 312 389 + 5 6 390 467 + 6 7 468 545 + 7 8 546 623 + 8 9 624 701 + 9 10 702 779 + 10 11 780 857 + 11 12 858 935 + 12 13 936 1013 +*/ + +// GND -> +var a = 560; +// -> pin1 +var b = 8200; +// -> pin2 +var c = 18000; +// -> pin3 +// ------> ADC +var d = 910; +// -> pin4 +var e = 9100; +// -> pin5 +var f = 15000; +// -> pin6 +var g = 5100; +// -> pin7 +var h = 51; +// -> VCC + + +var button1 = 1024 * ( a + b ) / ( a + b + d + e + f + g + h ); +var button2 = 1024 * ( a + c ) / ( a + c + d + e + f + g + h ); +var button3 = 1024 * ( a + b ) / ( a + b + f + g + h ); +var button4 = 1024 * ( a + b + c ) / ( a + b + c + h ); +var button5 = 1024 * ( a ) / ( a + h ); +var button6 = 1024 * ( a + b + c ) / ( a + b + c + d + e + h ); +var button7 = 1024 * ( a + b + c ) / ( a + b + c + g + h ); +var button8 = 1024 * ( a ) / ( a + g + h ); +var button9 = 1024 * ( a + b + c ) / ( a + b + c + d + e + g + h ); +var button10 = 1024 * ( a + b + c ) / ( a + b + c + e + f + g + h ); +var button11 = 1024 * ( a ) / ( a + e + f + g + h ); +var button12 = 1024 * ( a + b + c ) / ( a + b + c + d + f + g + h ); + +console.log("button1 ", button1 ); +console.log("button2 ", button2 ); +console.log("button3 ", button3 ); +console.log("button4 ", button4 ); +console.log("button5 ", button5 ); +console.log("button6 ", button6 ); +console.log("button7 ", button7 ); +console.log("button8 ", button8 ); +console.log("button9 ", button9 ); +console.log("button10", button10); +console.log("button11", button11); +console.log("button12", button12); diff --git a/JavaScript/node_modules/johnny-five/lib/sensor.js b/JavaScript/node_modules/johnny-five/lib/sensor.js new file mode 100644 index 0000000..fb76606 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/sensor.js @@ -0,0 +1,312 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + within = require("./mixins/within"), + __ = require("./fn"); + +// Sensor instance private data +var priv = new Map(), + aliases = { + change: [ + // Generic sensor value change + "change", + // Slider sensors (alias) + "slide", + // Soft Potentiometer (alias) + "touch", + // Force Sensor (alias) + "force", + // Flex Sensor (alias) + "bend" + ] + }; + + +/** + * Sensor + * @constructor + * + * @description Generic analog or digital sensor constructor + * + * @param {Object} opts Options: pin, freq, range + */ + +function Sensor(opts) { + + if (!(this instanceof Sensor)) { + return new Sensor(opts); + } + + var value, last, min, max, samples; + + value = null; + min = 1023; + max = 0; + last = -min; + samples = []; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (!opts.type) { + opts.type = "analog"; + } + + // Set the pin to ANALOG (INPUT) mode + this.mode = opts.type === "digital" ? + this.io.MODES.INPUT : + this.io.MODES.ANALOG; + + this.io.pinMode(this.pin, this.mode); + + // Sensor instance properties + this.freq = opts.freq || 25; + this.range = opts.range || [0, 1023]; + this.limit = opts.limit || null; + this.threshold = opts.threshold === undefined ? 1 : opts.threshold; + this.isScaled = false; + + // Read event loop + this.io[opts.type + "Read"](this.pin, function(data) { + // Update the instance-local `value` value. + // This is shared by the accessors defined below. + value = data; + + // Only append to the samples when noise filtering can/will be used + if (opts.type !== "digital") { + samples.push(value); + } + }.bind(this)); + + // Throttle + setInterval(function() { + var err, median, low, high, boundary; + + err = null; + + // For digital sensors, skip the analog + // noise filtering provided below. + if (opts.type === "digital") { + this.emit("data", err, value); + + if (last !== value) { + aliases.change.forEach(function(change) { + this.emit(change, err, value); + }, this); + // Update the instance-local `last` value. + last = value; + } + return; + } + + + // To reduce noise in sensor readings, sort collected samples + // from high to low and select the value in the center. + median = (function(input) { + var half, len, sorted; + // faster than default comparitor (even for small n) + sorted = input.sort(function(a, b) { + return a - b; + }); + len = sorted.length; + half = Math.floor(len / 2); + + // If the length is odd, return the midpoint m + // If the length is even, return average of m & m + 1 + return len % 2 ? sorted[half] : (sorted[half - 1] + sorted[half]) / 2; + }(samples)); + // @DEPRECATE + this.emit("read", err, median); + // The "read" event has been deprecated in + // favor of a "data" event. + this.emit("data", err, median); + // If the median value for this interval is outside last +/- a threshold + // fire a change event + + low = last - this.threshold; + high = last + this.threshold; + + // Includes all aliases + // Prevent events from firing if the latest value is the same as (within + // the threshold of) the last value to trigger a change event + if (median < low || median > high) { + aliases.change.forEach(function(change) { + this.emit(change, err, median); + }, this); + // Update the instance-local `last` value (only) when a new change event + // has been emitted. For comparison in the next interval + last = median; + } + + + if (this.limit) { + if (median <= this.limit[0]) { + boundary = "lower"; + } + if (median >= this.limit[1]) { + boundary = "upper"; + } + + if (boundary) { + this.emit("limit", err, { + boundary: boundary, + value: median + }); + this.emit("limit:" + boundary, err, median); + } + } + + // Reset samples + samples.length = 0; + }.bind(this), this.freq); + + // Create a "state" entry for privately + // storing the state of the sensor + priv.set(this, { + booleanBarrier: opts.type === "digital" ? 0 : 512, + scale: null, + value: 0 + }); + + + Object.defineProperties(this, { + raw: { + get: function() { + return value; + } + }, + analog: { + get: function() { + if (opts.type === "digital") { + return value; + } + + return value === null ? null : + Board.map(this.raw, 0, 1023, 0, 255) | 0; + } + }, + constrained: { + get: function() { + if (opts.type === "digital") { + return value; + } + + return value === null ? null : + Board.constrain(this.raw, 0, 255); + } + }, + boolean: { + get: function() { + return this.value > priv.get(this).booleanBarrier ? + true : false; + } + }, + scaled: { + get: function() { + var mapped, constrain, scale; + + scale = priv.get(this).scale; + + if (scale && value !== null) { + if (opts.type === "digital") { + // Value is either 0 or 1, use as an index + // to return the scaled value. + return scale[value]; + } + + mapped = Board.fmap(value, this.range[0], this.range[1], scale[0], scale[1]); + constrain = Board.constrain(mapped, scale[0], scale[1]); + + return constrain; + } + return this.constrained; + } + }, + value: { + get: function() { + var state; + + state = priv.get(this); + + if (state.scale) { + this.isScaled = true; + return this.scaled; + } + + return value; + } + } + }); +} + +util.inherits(Sensor, events.EventEmitter); + +/** + * EXPERIMENTAL + * + * within When value is within the provided range, execute callback + * + * @param {Number} range Upperbound, converted into an array, + * where 0 is lowerbound + * @param {Function} callback Callback to execute when value falls inside range + * @return {Object} instance + * + * + * @param {Array} range Lower to Upper bounds [ low, high ] + * @param {Function} callback Callback to execute when value falls inside range + * @return {Object} instance + * + */ +__.mixin(Sensor.prototype, within); + + +/** + * scale/scaleTo Set a value scaling range + * + * @param {Number} low Lowerbound + * @param {Number} high Upperbound + * @return {Object} instance + * + * @param {Array} [ low, high] Lowerbound + * @return {Object} instance + * + */ +Sensor.prototype.scale = function(low, high) { + this.isScaled = true; + + priv.get(this).scale = Array.isArray(low) ? + low : [low, high]; + + return this; +}; + +Sensor.prototype.scaleTo = Sensor.prototype.scale; + +/** + * booleanAt Set a midpoint barrier value used to calculate returned value of + * .boolean property. + * + * @param {Number} barrier + * @return {Object} instance + * + */ + +Sensor.prototype.booleanAt = function(barrier) { + priv.get(this).booleanBarrier = barrier; + return this; +}; + + + + +module.exports = Sensor; + +// Reference +// http://itp.nyu.edu/physcomp/Labs/Servo +// http://arduinobasics.blogspot.com/2011/05/arduino-uno-flex-sensor-and-leds.html + + + +// TODO: +// Update comments/docs diff --git a/JavaScript/node_modules/johnny-five/lib/servo.js b/JavaScript/node_modules/johnny-five/lib/servo.js new file mode 100644 index 0000000..9d62a19 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/servo.js @@ -0,0 +1,745 @@ +var IS_TEST_MODE = !!process.env.IS_TEST_MODE; +var Board = require("../lib/board.js"); +var Pins = Board.Pins; +var Emitter = require("events").EventEmitter; +var util = require("util"); +var Collection = require("../lib/mixins/collection"); +var __ = require("../lib/fn.js"); +var nanosleep = require("../lib/sleep.js").nano; +var Animation = require("../lib/animation.js"); + +// Servo instance private data +var priv = new Map(); + +var Controllers = { + PCA9685: { + COMMANDS: { + value: { + PCA9685_MODE1: 0x0, + PCA9685_PRESCALE: 0xFE, + LED0_ON_L: 0x6 + } + }, + servoWrite: { + value: function(pin, degrees) { + + var on, off; + // If same degrees, emit "move:complete" and return immediately. + if (this.last && this.last.degrees === degrees) { + process.nextTick(this.emit.bind(this, "move:complete")); + return this; + } + + on = 0; + off = __.map(degrees, 0, 180, this.pwmRange[0]/4, this.pwmRange[1]/4 ); + + this.io.i2cWrite(this.address, [this.COMMANDS.LED0_ON_L + 4 * pin, on, on >> 8, off, off >> 8]); + + } + }, + initialize: { + /* + + TODO: + + Refactor this initialization as an abstract controller + + + */ + + value: function(opts) { + this.address = opts.address || 0x40; + this.pwmRange = opts.pwmRange || [544, 2400]; + + if (!this.board.Drivers[this.address]) { + this.io.i2cConfig(); + this.board.Drivers[this.address] = { + initialized: false + }; + + // Reset + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x00); + // Sleep + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x10); + // Set prescalar + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_PRESCALE, 0x70); + // Wake up + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0x00); + // Wait 5 nanoseconds for restart + nanosleep(5); + // Auto-increment + this.io.i2cWriteReg(this.address, this.COMMANDS.PCA9685_MODE1, 0xa1); + + this.board.Drivers[this.address].initialized = true; + } + } + } + }, + Standard: { + initialize: { + value: function(opts) { + + // When in debug mode, if pin is not a PWM pin, emit an error + if (opts.debug && !this.board.pins.isServo(this.pin)) { + Board.Pins.Error({ + pin: this.pin, + type: "PWM", + via: "Servo", + }); + } + + if (Array.isArray(opts.pwmRange)) { + this.io.servoConfig(this.pin, opts.pwmRange[0], opts.pwmRange[1]); + } else { + this.io.pinMode(this.pin, this.mode); + } + } + }, + servoWrite: { + value: function(pin, degrees) { + // Servo is restricted to integers + degrees |= 0; + + // If same degrees, emit "move:complete" and return immediately. + if (this.last && this.last.degrees === degrees) { + process.nextTick(this.emit.bind(this, "move:complete")); + return this; + } + + this.io.servoWrite(this.pin, degrees); + } + } + } +}; + +/** + * Servo + * @constructor + * + * @param {Object} opts Options: pin, type, id, range + */ + +function Servo(opts) { + var history = []; + var pinValue; + var controller; + + if (!(this instanceof Servo)) { + return new Servo(opts); + } + + pinValue = typeof opts === "object" ? opts.pin : opts; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + this.id = opts.id || Board.uid(); + this.range = opts.range || [0, 180]; + this.deadband = opts.deadband || [90, 90]; + this.fps = opts.fps || 100; + this.offset = opts.offset || 0; + this.mode = this.io.MODES.SERVO; + this.interval = null; + this.value = null; + + // StandardFirmata on Arduino allows controlling + // servos from analog pins. + // If we're currently operating with an Arduino + // and the user has provided an analog pin name + // (eg. "A0", "A5" etc.), parse out the numeric + // value and capture the fully qualified analog + // pin number. + if (typeof opts.controller === "undefined" && Pins.isFirmata(this)) { + if (typeof pinValue === "string" && pinValue[0] === "A") { + pinValue = this.io.analogPins[+pinValue.slice(1)]; + } + + pinValue = +pinValue; + + // If the board's default pin normalization + // came up with something different, use the + // the local value. + if (!Number.isNaN(pinValue) && this.pin !== pinValue) { + this.pin = pinValue; + } + } + + + // The type of servo determines certain alternate + // behaviours in the API + this.type = opts.type || "standard"; + + // Invert the value of all servoWrite operations + // eg. 80 => 100, 90 => 90, 0 => 180 + if (opts.isInverted) { + console.warn("The 'isInverted' property has been renamed 'invert'"); + } + this.invert = opts.isInverted || opts.invert || false; + + // Specification config + this.specs = opts.specs || { + speed: Servo.Continuous.speeds["@5.0V"] + }; + + // Allow "setup"instructions to come from + // constructor options properties + this.startAt = 90; + + // Collect all movement history for this servo + // history = [ + // { + // timestamp: Date.now(), + // degrees: degrees + // } + // ]; + + priv.set(this, { + history: history + }); + + + /** + * Used for adding special controllers (i.e. PCA9685) + **/ + controller = typeof opts.controller === "string" ? + Controllers[opts.controller] : Controllers.Standard; + + Object.defineProperties(this, Object.assign({}, controller, { + history: { + get: function() { + return history.slice(-5); + } + }, + last: { + get: function() { + return history[history.length - 1]; + } + }, + position: { + get: function() { + return history[history.length - 1].degrees; + } + } + })); + + this.initialize(opts); + + + // If "startAt" is defined and center is falsy + // set servo to min or max degrees + if (opts.startAt !== undefined) { + this.startAt = opts.startAt; + + if (!opts.center) { + this.to(opts.startAt); + } + } + + // If "center" true set servo to 90deg + if (opts.center) { + this.center(); + } +} + +util.inherits(Servo, Emitter); + + +/** + * to + * + * Set the servo horn's position to given degree over time. + * + * @param {Number} degrees Degrees to turn servo to. + * @param {Number} time Time to spend in motion. + * @param {Number} rate The rate of the motion transiton + * + * @return {Servo} instance + */ + +Servo.prototype.to = function(degrees, time, rate) { + + var target = degrees; + + // Enforce limited range of motion + degrees = Board.constrain(degrees, this.range[0], this.range[1]); + + degrees += this.offset; + this.value = degrees; + + var last, distance, percent; + var isReverse = false; + var history = priv.get(this).history; + + if (this.invert) { + degrees = Board.map( + degrees, + 0, 180, + 180, 0 + ); + } + + if (typeof time !== "undefined") { + + // If rate is not passed, calculate based on time and fps + rate = rate || Math.ceil(time / 1000) * this.fps; + + last = this.last && this.last.degrees || 0; + distance = Math.abs(last - degrees); + percent = 0; + + if (distance === 0) { + process.nextTick(this.emit.bind(this, "move:complete")); + return this; + } + + // If steps are limited by Servo resolution + if (distance < rate) { + rate = distance; + } + + if (this.interval) { + clearInterval(this.interval); + } + + if (degrees < last) { + isReverse = true; + } + + this.interval = setInterval(function() { + var delta = ++percent * (distance / rate); + + if (isReverse) { + delta *= -1; + } + + this.servoWrite(this.pin, last + delta); + + history.push({ + timestamp: Date.now(), + degrees: last + delta, + target: target + }); + + if (percent === rate) { + process.nextTick(this.emit.bind(this, "move:complete")); + clearInterval(this.interval); + } + }.bind(this), time / rate); + + } else { + + this.servoWrite(this.pin, degrees); + history.push({ + timestamp: Date.now(), + degrees: degrees, + target: target + }); + } + + // return this instance + return this; +}; + + +/** + * Animation.normalize + * + * @param [number || object] keyFrames An array of step values or a keyFrame objects + */ + +Servo.prototype[Animation.normalize] = function(keyFrames) { + + var last = this.last ? this.last.target : this.startAt; + + // If user passes null as the first element in keyFrames use current position + if (keyFrames[0] === null) { + keyFrames[0] = { + value: last + }; + } + + // There are a couple of properties that are device type sepcific + // that we need to convert to something generic + keyFrames.forEach(function(keyFrame) { + if (typeof keyFrame.degrees !== "undefined") { + keyFrame.value = keyFrame.degrees; + } + if (typeof keyFrame.copyDegrees !== "undefined") { + keyFrame.copyValue = keyFrame.copyDegrees; + } + }); + + return keyFrames; + +}; + +/** + * Animation.render + * + * @position [number] value to set the servo to + */ + +Servo.prototype[Animation.render] = function(position) { + return this.to(position[0]); +}; + +/** + * step + * + * Update the servo horn's position by specified degrees (over time) + * + * @param {Number} degrees Degrees to turn servo to. + * @param {Number} time Time to spend in motion. + * + * @return {Servo} instance + */ + +Servo.prototype.step = function(degrees, time) { + return this.to(this.last.target + degrees, time); +}; + +/** + * move Alias for Servo.prototype.to + */ +Servo.prototype.move = function(degrees, time) { + console.warn("Servo.prototype.move has been renamed to Servo.prototype.to"); + + return this.to(degrees, time); +}; + +/** + * min Set Servo to minimum degrees, defaults to 0deg + * @param {Number} time Time to spend in motion. + * @param {Number} rate The rate of the motion transiton + * @return {Object} instance + */ + +Servo.prototype.min = function(time, rate) { + return this.to(this.range[0], time, rate); +}; + +/** + * max Set Servo to maximum degrees, defaults to 180deg + * @param {Number} time Time to spend in motion. + * @param {Number} rate The rate of the motion transiton + * @return {[type]} [description] + */ +Servo.prototype.max = function(time, rate) { + return this.to(this.range[1], time, rate); +}; + +/** + * center Set Servo to centerpoint, defaults to 90deg + * @param {Number} time Time to spend in motion. + * @param {Number} rate The rate of the motion transiton + * @return {[type]} [description] + */ +Servo.prototype.center = function(time, rate) { + return this.to(Math.abs((this.range[0] + this.range[1]) / 2), time, rate); +}; + +/** + * sweep Sweep the servo between min and max or provided range + * @param {Array} range constrain sweep to range + * + * @param {Object} options Set range or interval. + * + * @return {[type]} [description] + */ +Servo.prototype.sweep = function(opts) { + var degrees, + range = this.range, + interval = 100, + step = 10; + + opts = opts || {}; + + // If opts is an array, then assume a range was passed + // + // - This implies: + // - an interval of 100ms. + // - a step of 10 degrees + // + if (Array.isArray(opts)) { + range = opts; + } else { + + // Otherwise, opts is an object. + // + // - Check for: + // - a range, if present use it, otherwise + // use the servo's range property. + // - an interval, if present use it, otherwise + // use the default interval. + // - a step, if present use it, otherwise + // use the default step + // + range = opts.range || range; + interval = opts.interval || interval; + step = opts.step || step; + } + + degrees = range[0]; + + // If the last recorded movement was not range[0]deg + // move the servo to range[0]deg + if (this.last && this.last.degrees !== degrees) { + this.to(degrees); + } + + if (this.interval) { + clearInterval(this.interval); + } + + this.interval = setInterval(function() { + var abs; + + if (degrees >= range[1] || degrees < range[0]) { + if (degrees >= range[1]) { + process.nextTick(this.emit.bind(this, "sweep:half")); + } + + step *= -1; + } + + if (degrees === range[0]) { + if (step !== (abs = Math.abs(step))) { + process.nextTick(this.emit.bind(this, "sweep:full")); + step = abs; + } + } + + degrees += step; + + this.to(degrees); + }.bind(this), interval); + + return this; +}; + +/** + * stop Stop a moving servo + * @return {[type]} [description] + */ +Servo.prototype.stop = function() { + + if (this.type === "continuous") { + this.to(90); + } else { + clearInterval(this.interval); + } + + return this; +}; + +// +["clockWise", "cw", "counterClockwise", "ccw"].forEach(function(api) { + Servo.prototype[api] = function(rate) { + var range; + rate = rate === undefined ? 1 : rate; + if (this.type !== "continuous") { + this.board.error( + "Servo", + "Servo.prototype." + api + " is only available for continuous servos" + ); + } + if (api === "cw" || api === "clockWise") { + range = [rate, 0, 1, this.deadband[1] + 1, this.range[1]]; + } else { + range = [rate, 0, 1, this.deadband[0] - 1, this.range[0]]; + } + return this.to(__.scale.apply(null, range) | 0); + }; +}); + + +/** + * + * Static API + * + * + */ + +Servo.Continuous = function(pinOrOpts) { + var opts = {}; + + if (typeof pinOrOpts === "object") { + __.extend(opts, pinOrOpts); + } else { + opts.pin = pinOrOpts; + } + + opts.type = "continuous"; + return new Servo(opts); +}; + +Servo.Continuous.speeds = { + // seconds to travel 60 degrees + "@4.8V": 0.23, + "@5.0V": 0.17, + "@6.0V": 0.18 +}; + +/** + * Servos() + * new Servos() + * + * Constructs an Array-like instance of all servos + */ +function Servos(numsOrObjects) { + if (!(this instanceof Servos)) { + return new Servos(numsOrObjects); + } + + Object.defineProperty(this, "type", { + value: Servo + }); + + Collection.call(this, numsOrObjects); +} + +Servos.prototype = Object.create(Collection.prototype, { + constructor: { + value: Servos + } +}); + + +/* + * Servos, center() + * + * centers all servos to 90deg + * + * eg. array.center(); + + * Servos, min() + * + * set all servos to the minimum degrees + * defaults to 0 + * + * eg. array.min(); + + * Servos, max() + * + * set all servos to the maximum degrees + * defaults to 180 + * + * eg. array.max(); + + * Servos, stop() + * + * stop all servos + * + * eg. array.stop(); + */ + +Object.keys(Servo.prototype).forEach(function(method) { + // Create Servos wrappers for each method listed. + // This will allow us control over all Servo instances + // simultaneously. + Servos.prototype[method] = function() { + var length = this.length; + + for (var i = 0; i < length; i++) { + this[i][method].apply(this[i], arguments); + } + return this; + }; +}); + +/** + * Animation.normalize + * + * @param [number || object] keyFrames An array of step values or a keyFrame objects + */ + +Servos.prototype[Animation.normalize] = function(keyFrameSet) { + + keyFrameSet.forEach(function(keyFrames, index) { + + if (keyFrames !== null) { + var servo = this[index]; + + // If servo is a servoArray then user servo[0] for default values + if (servo instanceof Servos) { + servo = servo[0]; + } + + var last = servo.last ? servo.last.target : servo.startAt; + + // If the first position is null use the current position + if (keyFrames[0] === null) { + keyFrameSet[index][0] = { + value: last + }; + } + + if (Array.isArray(keyFrames)) { + if (keyFrames[0] === null) { + keyFrameSet[index][0] = { + value: last + }; + } + } + + keyFrames.forEach(function(keyFrame) { + if (typeof keyFrame.degrees !== "undefined") { + keyFrame.value = keyFrame.degrees; + } + if (typeof keyFrame.copyDegrees !== "undefined") { + keyFrame.copyValue = keyFrame.copyDegrees; + } + }); + + + } + + }, this); + + return keyFrameSet; + +}; + +/** + * Animation.render + * + * @position [number] array of values to set the servos to + */ + +Servos.prototype[Animation.render] = function(position) { + this.each(function(servo, i) { + servo.to(position[i]); + }); + return this; +}; + + +// Alias +// TODO: Deprecate and REMOVE +Servo.prototype.write = Servo.prototype.move; + +if (IS_TEST_MODE) { + Servo.purge = function() { + priv.clear(); + }; +} + +// Assign Servos Collection class as static "method" of Servo. +Servo.Array = Servos; + +module.exports = Servo; + + + +// References +// +// http://www.societyofrobots.com/actuators_servos.shtml +// http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/900-00008-CRServo-v2.2.pdf +// http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM +// http://servocity.com/html/hs-7980th_servo.html +// http://mbed.org/cookbook/Servo + +// Further API info: +// http://www.tinkerforge.com/doc/Software/Bricks/Servo_Brick_Python.html#servo-brick-python-api +// http://www.tinkerforge.com/doc/Software/Bricks/Servo_Brick_Java.html#servo-brick-java-api diff --git a/JavaScript/node_modules/johnny-five/lib/shiftregister.js b/JavaScript/node_modules/johnny-five/lib/shiftregister.js new file mode 100644 index 0000000..aa19a20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/shiftregister.js @@ -0,0 +1,65 @@ +var Board = require("../lib/board.js"); + +var priv = new Map(); + +function ShiftRegister(opts) { + if (!(this instanceof ShiftRegister)) { + return new ShiftRegister(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + this.pins = { + data: opts.pins.data, + clock: opts.pins.clock, + latch: opts.pins.latch + }; + + this.size = opts.size || 1; + + priv.set(this, { + value: this.size > 1 ? new Array(this.size).fill(0) : 0 + }); + + Object.defineProperties(this, { + value: { + get: function() { + return priv.get(this).value; + } + } + }); +} + +/** + * Send one or more values to the shift register. + * @param {...number} value Value to send + * @returns {ShiftRegister} + */ +ShiftRegister.prototype.send = function(value) { + var args = Array.prototype.slice.apply(arguments); + this.board.digitalWrite(this.pins.latch, this.io.LOW); + args.forEach(function(val) { + this.board.shiftOut(this.pins.data, this.pins.clock, true, val); + }, this); + this.board.digitalWrite(this.pins.latch, this.io.HIGH); + + priv.get(this).value = args.length > 1 ? args : value; + + return this; +}; + +/** + * Clear the shift register by replacing each value with a 0. + * @type {ShiftRegister} + */ +ShiftRegister.prototype.clear = function () { + var value = priv.get(this).value; + if (Array.isArray(value)) { + return this.send.apply(this, new Array(value.length).fill(0)); + } + return this.send(0); +}; + +module.exports = ShiftRegister; diff --git a/JavaScript/node_modules/johnny-five/lib/sleep.js b/JavaScript/node_modules/johnny-five/lib/sleep.js new file mode 100644 index 0000000..1b37df2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/sleep.js @@ -0,0 +1,6 @@ +module.exports = { + nano: function(ns) { + var start = process.hrtime(); + while (process.hrtime() < start + ns) {} + } +}; diff --git a/JavaScript/node_modules/johnny-five/lib/sonar.js b/JavaScript/node_modules/johnny-five/lib/sonar.js new file mode 100644 index 0000000..f8ceb48 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/sonar.js @@ -0,0 +1,183 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"), + within = require("./mixins/within"), + __ = require("./fn"); + +var priv = new Map(); +var Devices; + +/** + * Sonar + * @constructor + * + * @param {Object} opts Options: pin (analog) + */ + +function Sonar(opts) { + + if (!(this instanceof Sonar)) { + return new Sonar(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + var device, state; + + // Sonar instance properties + this.freq = opts.freq || 100; + this.value = null; + + state = { + last: 0, + median: 0, + samples: [] + }; + + priv.set(this, state); + + if (typeof opts.device === "string") { + device = Devices[opts.device]; + } else { + device = opts.device; + } + + if (typeof device === "undefined") { + device = Devices.DEFAULT; + } + + device.initialize.call(this); + + if (!device.descriptor.inches) { + device.descriptor.inches = { + get: function() { + return +(this.cm * 0.39).toFixed(2); + } + }; + } + + device.descriptor.in = device.descriptor.inches; + + Object.defineProperties(this, device.descriptor); + + // Throttle + setInterval(function() { + var err = null; + + // Nothing read since previous interval + if (state.samples.length === 0) { + return; + } + + state.median = state.samples.sort()[Math.floor(state.samples.length / 2)]; + this.value = state.median; + + // @DEPRECATE + this.emit("read", err, state.median); + // The "read" event has been deprecated in + // favor of a "data" event. + this.emit("data", err, state.median); + + + // If the state.median value for this interval is not the same as the + // state.median value in the last interval, fire a "change" event. + // + if (state.last && state.median && + (state.median.toFixed(1) !== state.last.toFixed(1))) { + this.emit("change", err, state.median); + } + + // Store this media value for comparison + // in next interval + state.last = state.median; + + // Reset state.samples; + state.samples.length = 0; + }.bind(this), this.freq); +} + +util.inherits(Sonar, events.EventEmitter); +__.mixin(Sonar.prototype, within); + +Devices = { + SRF10: { + initialize: function() { + + var samples = priv.get(this).samples; + var address = 0x70; + var delay = 65; + + // Set up I2C data connection + this.io.i2cConfig(0); + + // Startup parameter + this.io.i2cWrite(address, [0x01, 16]); + this.io.i2cWrite(address, [0x02, 255]); + + this.io.setMaxListeners(100); + + function read() { + this.io.i2cWrite(address, [0x02]); + this.io.i2cReadOnce(address, 2, function(data) { + samples.push((data[0] << 8) | data[1]); + }.bind(this)); + + prime.call(this); + } + + function prime() { + // 0x52 result in us (microseconds) + this.io.i2cWrite(address, [0x00, 0x52]); + + setTimeout(read.bind(this), delay); + } + + prime.call(this); + }, + descriptor: { + cm: { + get: function() { + var median = priv.get(this).median; + return +((((median / 2) * 343.2) / 10) / 1000).toFixed(1); + } + } + } + }, + + DEFAULT: { + initialize: function() { + var samples = priv.get(this).samples; + + // Set the pin to ANALOG mode + this.mode = this.io.MODES.ANALOG; + this.io.pinMode(this.pin, this.mode); + + this.io.analogRead(this.pin, function(data) { + samples.push(data); + }.bind(this)); + }, + descriptor: { + cm: { + get: function() { + var median = priv.get(this).median; + return +((median / 2) * 2.54).toFixed(1); + } + } + } + } +}; + +Devices.SRF02 = Devices.SRF08 = Devices.SRF10; + +module.exports = Sonar; + +// Reference +// +// http://www.maxbotix.com/tutorials.htm#Code_example_for_the_BasicX_BX24p +// http://www.electrojoystick.com/tutorial/?page_id=285 + +// Tutorials +// +// http://www.sensorpedia.com/blog/how-to-interface-an-ultrasonic-rangefinder-with-sensorpedia-via-twitter-guide-2/ diff --git a/JavaScript/node_modules/johnny-five/lib/stepper.js b/JavaScript/node_modules/johnny-five/lib/stepper.js new file mode 100644 index 0000000..0cbcd8b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/stepper.js @@ -0,0 +1,452 @@ +var Board = require("../lib/board.js"); +var priv = new Map(); +var steppers = new Map(); + +var MAXSTEPPERS = 6; // correlates with MAXSTEPPERS in firmware + + +function Step(stepper) { + this.rpm = 180; + this.direction = -1; + this.speed = 0; + this.accel = 0; + this.decel = 0; + + this.stepper = stepper; +} + +Step.PROPERTIES = ["rpm", "direction", "speed", "accel", "decel"]; +Step.DEFAULTS = [180, -1, 0, 0, 0]; + + +function MotorPins(pins) { + var k = 0; + pins = pins.slice(); + while (pins.length) { + this["motor" + (++k)] = pins.shift(); + } +} + +function isSupported(io) { + return io.pins.some(function(pin) { + return pin.supportedModes.includes(io.MODES.STEPPER); + }); +} + +/** + * Stepper + * + * Class for handling steppers using AdvancedFirmata support for asynchronous stepper control + * + * + * five.Stepper({ + * type: constant, // io.STEPPER.TYPE.* + * stepsPerRev: number, // steps to make on revolution of stepper + * pins: { + * step: number, // pin attached to step pin on driver (used for type DRIVER) + * dir: number, // pin attached to direction pin on driver (used for type DRIVER) + * motor1: number, // (used for type TWO_WIRE and FOUR_WIRE) + * motor2: number, // (used for type TWO_WIRE and FOUR_WIRE) + * motor3: number, // (used for type FOUR_WIRE) + * motor4: number, // (used for type FOUR_WIRE) + * } + * }); + * + * + * five.Stepper({ + * type: five.Stepper.TYPE.DRIVER + * stepsPerRev: number, + * pins: { + * step: number, + * dir: number + * } + * }); + * + * five.Stepper({ + * type: five.Stepper.TYPE.DRIVER + * stepsPerRev: number, + * pins: [ step, dir ] + * }); + * + * five.Stepper({ + * type: five.Stepper.TYPE.TWO_WIRE + * stepsPerRev: number, + * pins: { + * motor1: number, + * motor2: number + * } + * }); + * + * five.Stepper({ + * type: five.Stepper.TYPE.TWO_WIRE + * stepsPerRev: number, + * pins: [ motor1, motor2 ] + * }); + * + * five.Stepper({ + * type: five.Stepper.TYPE.FOUR_WIRE + * stepsPerRev: number, + * pins: { + * motor1: number, + * motor2: number, + * motor3: number, + * motor4: number + * } + * }); + * + * five.Stepper({ + * type: five.Stepper.TYPE.FOUR_WIRE + * stepsPerRev: number, + * pins: [ motor1, motor2, motor3, motor4 ] + * }); + * + * + * @param {Object} opts + * + */ + +function Stepper(opts) { + var state, params = []; + + if (!(this instanceof Stepper)) { + return new Stepper(opts); + } + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + if (!isSupported(this.io)) { + throw new Error( + "Stepper is not supported" + ); + } + + if (!opts.pins) { + throw new Error( + "Stepper requires a `pins` object or array" + ); + } + + if (!opts.stepsPerRev) { + throw new Error( + "Stepper requires a `stepsPerRev` number value" + ); + } + + steppers.set(this.board, steppers.get(this.board) || []); + this.id = steppers.get(this.board).length; + + if (this.id >= MAXSTEPPERS) { + throw new Error( + "Stepper cannot exceed max steppers (" + MAXSTEPPERS + ")" + ); + } + + // Convert an array of pins to the appropriate named pin + if (Array.isArray(this.pins)) { + if (this.pins.length === 2) { + // Using an array of 2 pins requres a TYPE + // to disambiguate DRIVER and TWO_WIRE + if (!opts.type) { + throw new Error( + "Stepper requires a `type` number value (DRIVER, TWO_WIRE)" + ); + } + } + + if (opts.type === Stepper.TYPE.DRIVER) { + this.pins = { + step: this.pins[0], + dir: this.pins[1] + }; + } else { + this.pins = new MotorPins(this.pins); + } + } + + // Attempt to guess the type if none is provided + if (!opts.type) { + if (this.pins.dir) { + opts.type = Stepper.TYPE.DRIVER; + } else { + if (this.pins.motor3) { + opts.type = Stepper.TYPE.FOUR_WIRE; + } else { + opts.type = Stepper.TYPE.TWO_WIRE; + } + } + } + + + // Initial Stepper config params (same for all 3 types) + params.push(this.id, opts.type, opts.stepsPerRev); + + + if (opts.type === Stepper.TYPE.DRIVER) { + if (!this.pins.dir || !this.pins.step) { + throw new Error( + "Stepper.TYPE.DRIVER expects: `pins.dir`, `pins.step`" + ); + } + + params.push( + this.pins.dir, this.pins.step + ); + } + + if (opts.type === Stepper.TYPE.TWO_WIRE) { + if (!this.pins.motor1 || !this.pins.motor2) { + throw new Error( + "Stepper.TYPE.TWO_WIRE expects: `pins.motor1`, `pins.motor2`" + ); + } + + params.push( + this.pins.motor1, this.pins.motor2 + ); + } + + if (opts.type === Stepper.TYPE.FOUR_WIRE) { + if (!this.pins.motor1 || !this.pins.motor2 || !this.pins.motor3 || !this.pins.motor4) { + throw new Error( + "Stepper.TYPE.FOUR_WIRE expects: `pins.motor1`, `pins.motor2`, `pins.motor3`, `pins.motor4`" + ); + } + + params.push( + this.pins.motor1, this.pins.motor2, this.pins.motor3, this.pins.motor4 + ); + } + + // Iterate the params and set each pin's mode to MODES.STEPPER + // Params: + // [deviceNum, type, stepsPerRev, dirOrMotor1Pin, stepOrMotor2Pin, motor3Pin, motor4Pin] + // The first 3 are required, the remaining 2-4 will be pins + params.slice(3).forEach(function(pin) { + this.io.pinMode(pin, this.io.MODES.STEPPER); + }, this); + + this.io.stepperConfig.apply(this.io, params); + + steppers.get(this.board).push(this); + + state = Step.PROPERTIES.reduce(function(state, key, i) { + return (state[key] = typeof opts[key] !== "undefined" ? opts[key] : Step.DEFAULTS[i], state); + }, { + isRunning: false, + type: opts.type, + pins: this.pins + }); + + priv.set(this, state); + + Object.defineProperties(this, { + type: { + get: function() { + return state.type; + } + }, + + pins: { + get: function() { + return state.pins; + } + } + }); +} + +Object.defineProperties(Stepper, { + TYPE: { + value: Object.freeze({ + DRIVER: 1, + TWO_WIRE: 2, + FOUR_WIRE: 4 + }) + }, + RUNSTATE: { + value: Object.freeze({ + STOP: 0, + ACCEL: 1, + DECEL: 2, + RUN: 3 + }) + }, + DIRECTION: { + value: Object.freeze({ + CCW: 0, + CW: 1 + }) + } +}); + +/** + * rpm + * + * Gets the rpm value or sets the rpm in revs per minute + * making an internal conversion to speed in `0.01 * rad/s` + * + * @param {Number} rpm Revs per minute + * + * NOTE: *rpm* is optional, if missing + * the method will behave like a getter + * + * @return {Stepper} this Chainable method when used as a setter + */ +Stepper.prototype.rpm = function(rpm) { + var state = priv.get(this); + + if (typeof rpm === "undefined") { + return state.rpm; + } + state.rpm = rpm; + state.speed = Math.round(rpm * (2 * Math.PI) * 100 / 60); + return this; +}; + +/** + * speed + * + * Gets the speed value or sets the speed in `0.01 * rad/s` + * making an internal conversion to rpm + * + * @param {Number} speed Speed given in 0.01 * rad/s + * + * NOTE: *speed* is optional, if missing + * the method will behave like a getter + * + * @return {Stepper} this Chainable method when used as a setter + */ +Stepper.prototype.speed = function(speed) { + var state = priv.get(this); + + if (typeof speed === "undefined") { + return state.speed; + } + state.speed = speed; + state.rpm = Math.round(speed / (2 * Math.PI) / 100 * 60); + return this; +}; + +["direction", "accel", "decel"].forEach(function(prop) { + Stepper.prototype[prop] = function(value) { + var state = priv.get(this); + + if (typeof value === "undefined") { + return state[prop]; + } + state[prop] = value; + return this; + }; +}); + +Stepper.prototype.ccw = function() { + return this.direction(0); +}; + +Stepper.prototype.cw = function() { + return this.direction(1); +}; + +/** + * step + * + * Move stepper motor a number of steps and call the callback on completion + * + * @param {Number} stepsOrOpts Steps to move using current settings for speed, accel, etc. + * @param {Object} stepsOrOpts Options object containing any of the following: + * stepsOrOpts = { + * steps: + * rpm: + * speed: + * direction: + * accel: + * decel: + * } + * + * NOTE: *steps* is required. + * + * @param {Function} callback function(err, complete) + */ +Stepper.prototype.step = function(stepsOrOpts, callback) { + var steps, step, state, params, isValidStep; + + steps = typeof stepsOrOpts === "object" ? + (stepsOrOpts.steps || 0) : Math.floor(stepsOrOpts); + + step = new Step(this); + + state = priv.get(this); + + params = []; + + isValidStep = true; + + function failback(error) { + isValidStep = false; + if (callback) { callback(error); } + } + + params.push(steps); + + if (typeof stepsOrOpts === "object") { + // If an object of property values has been provided, + // call the correlating method with the value argument. + Step.PROPERTIES.forEach(function(key) { + if (typeof stepsOrOpts[key] !== "undefined") { + this[key](stepsOrOpts[key]); + } + }, this); + } + + if (!state.speed) { + this.rpm(state.rpm); + step.speed = this.speed(); + } + + + // Ensure that the property params are set in the + // correct order, but without rpm + Step.PROPERTIES.slice(1).forEach(function(key) { + params.push(step[key] = this[key]()); + }, this); + + + if (steps === 0) { + failback( + new Error( + "Must set a number of steps when calling `step()`" + ) + ); + } + + if (step.direction < 0) { + failback( + new Error( + "Must set a direction before calling `step()`" + ) + ); + } + + if (isValidStep) { + state.isRunning = true; + + params.push(function(complete) { + state.isRunning = false; + callback(null, complete); + }); + + step.move.apply(step, params); + } + + return this; +}; + +Step.prototype.move = function(steps, dir, speed, accel, decel, callback) { + // Restore the param order... (steps, dir => dir, steps) + this.stepper.io.stepperStep.apply( + this.stepper.io, [this.stepper.id, dir, steps, speed, accel, decel, callback] + ); +}; + +module.exports = Stepper; diff --git a/JavaScript/node_modules/johnny-five/lib/switch.js b/JavaScript/node_modules/johnny-five/lib/switch.js new file mode 100644 index 0000000..aa35f2f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/switch.js @@ -0,0 +1,118 @@ +var Board = require("../lib/board.js"); +var __ = require("../lib/fn.js"); +var events = require("events"); +var util = require("util"); + +// Switch instance private data +var priv = new Map(); +var aliases = { + close: ["close", "closed", "on"], + open: ["open", "off"] +}; + + +/** + * Switch + * @constructor + * + * five.Switch(); + * + * five.Switch({ + * pin: 10 + * }); + * + * + * @param {Object} opts [description] + * + */ + +function Switch(opts) { + + if (!(this instanceof Switch)) { + return new Switch(opts); + } + + // Create a 5 ms debounce boundary on event triggers + // this avoids button events firing on + // press noise and false positives + var trigger = __.debounce(function(key) { + aliases[key].forEach(function(type) { + this.emit(type, null); + }, this); + }, 7); + + var state = { + isClosed: false + }; + + Board.Component.call( + this, opts = Board.Options(opts) + ); + + // Set the pin to INPUT mode + this.mode = this.io.MODES.INPUT; + this.io.pinMode(this.pin, this.mode); + + // Create a "state" entry for privately + // storing the state of the Switch + priv.set(this, state); + + // Digital Read event loop + this.io.digitalRead(this.pin, function(data) { + // data = 0, this.isClosed = true + // indicates that the Switch has been opened + // after previously being closed + if (!data && this.isClosed) { + state.isClosed = false; + trigger.call(this, "open"); + } + + // data = 1, this.isClosed = false + // indicates that the Switch has been close + // after previously being open + if (data && !this.isClosed) { + + // Update private data + state.isClosed = true; + + // Call debounced event trigger. + trigger.call(this, "close" /* key */ ); + } + }.bind(this)); + + Object.defineProperties(this, { + isClosed: { + get: function() { + return state.isClosed; + } + }, + isOpen: { + get: function() { + return !state.isClosed; + } + } + }); +} + +util.inherits(Switch, events.EventEmitter); + + +/** + * Fired when the Switch is close + * + * @event + * @name close + * @memberOf Switch + */ + + +/** + * Fired when the Switch is opened + * + * @event + * @name open + * @memberOf Switch + */ + + +module.exports = Switch; diff --git a/JavaScript/node_modules/johnny-five/lib/temperature.js b/JavaScript/node_modules/johnny-five/lib/temperature.js new file mode 100644 index 0000000..b9ca1b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/temperature.js @@ -0,0 +1,413 @@ +var Board = require("../lib/board.js"), + Emitter = require("events").EventEmitter, + util = require("util"); + + +function analogHandler(opts, dataHandler) { + var pin = opts.pin; + + this.io.pinMode(pin, this.io.MODES.ANALOG); + this.io.analogRead(pin, function(data) { + dataHandler.call(this, data); + }.bind(this)); +} + +var activeDrivers = new Map(); + +var Drivers = { + DS18B20: { + initialize: { + value: function(board, opts) { + var CONSTANTS = { + TEMPERATURE_FAMILY: 0x28, + CONVERT_TEMPERATURE_COMMAND: 0x44, + READ_SCRATCHPAD_COMMAND: 0xBE, + READ_COUNT: 2 + }, + pin = opts.pin, + freq = opts.freq || 100, + getAddress, readTemperature, readOne; + + getAddress = function(device) { + // 64-bit device code + // device[0] => Family Code + // device[1..6] => Serial Number (device[1] is LSB) + // device[7] => CRC + var i, result = 0; + for (i = 6; i > 0; i--) { + result = result * 256 + device[i]; + } + return result; + }; + + board.io.sendOneWireConfig(pin, true); + board.io.sendOneWireSearch(pin, function(err, devices) { + if (err) { + this.emit("error", err); + return; + } + + this.devices = devices.filter(function(device) { + return device[0] === CONSTANTS.TEMPERATURE_FAMILY; + }, this); + + if (devices.length === 0) { + this.emit("error", new Error("FAILED TO FIND TEMPERATURE DEVICE")); + return; + } + + this.devices.forEach(function(device) { + this.emit("initialized", getAddress(device)); + }.bind(this)); + + readTemperature = function() { + var devicesToRead, result; + + // request tempeature conversion + if (this.addresses) { + devicesToRead = this.devices.filter(function(device) { + var address = getAddress(device); + return this.addresses.includes(address); + }, this); + } else { + devicesToRead = [this.devices[0]]; + } + + devicesToRead.forEach(function(device) { + board.io.sendOneWireReset(pin); + board.io.sendOneWireWrite(pin, device, CONSTANTS.CONVERT_TEMPERATURE_COMMAND); + }); + + // the delay gives the sensor time to do the calculation + board.io.sendOneWireDelay(pin, 1); + + readOne = function() { + var device; + + if (devicesToRead.length === 0) { + setTimeout(readTemperature, freq); + return; + } + + device = devicesToRead.pop(); + // read from the scratchpad + board.io.sendOneWireReset(pin); + + board.io.sendOneWireWriteAndRead(pin, device, CONSTANTS.READ_SCRATCHPAD_COMMAND, CONSTANTS.READ_COUNT, function(err, data) { + if (err) { + this.emit("error", err); + return; + } + + result = (data[1] << 8) | data[0]; + this.emit("data", getAddress(device), result); + + readOne(); + }.bind(this)); + }.bind(this); + + readOne(); + }.bind(this); + + readTemperature(); + }.bind(this)); + } + }, + register: { + value: function(address) { + if (!this.addresses) { + this.addresses = []; + } + + this.addresses.push(address); + } + } + } +}; + +Drivers.get = function(board, driverName, opts) { + var drivers, driver; + + if (!activeDrivers.has(board)) { + activeDrivers.set(board, {}); + } + + drivers = activeDrivers.get(board); + + if (!drivers[driverName]) { + driver = new Emitter(); + Object.defineProperties(driver, Drivers[driverName]); + driver.initialize(board, opts); + drivers[driverName] = driver; + } + + return drivers[driverName]; +}; + +Drivers.clear = function() { + activeDrivers.clear(); +}; + +// References +// +var Controllers = { + ANALOG: { + initialize: { + value: analogHandler + } + }, + //http://www.ti.com/lit/ds/symlink/lm35.pdf + LM35: { + initialize: { + value: analogHandler + }, + toCelsius: { + value: function(raw) { + return (5.0 * raw * 100.0)/1024.0; + } + } + }, + //https://www.sparkfun.com/products/10988 + TMP36: { + initialize: { + value: analogHandler + }, + toCelsius: { + value: function(raw) { + return (raw * 0.4882814) - 50; + } + } + }, + // Based on code from Westin Pigott: + // https://github.com/westinpigott/one-wire-temps + // And the datasheet: + // http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf + // OneWire protocol. The device needs to be issued a "Convert Temperature" + // command which can take up to 10 microseconds to compute, so we need + // tell the board to delay 1 millisecond before issuing the "Read Scratchpad" command + // + // This device requires the OneWire support enabled via ConfigurableFirmata + DS18B20: { + initialize: { + value: function(opts, dataHandler) { + var state = priv.get(this), + address = opts.address, + driver = Drivers.get(this.board, "DS18B20", opts); + + if (address) { + state.address = address; + driver.register(address); + } else { + if (driver.addressless) { + this.emit("error", "You cannot have more than one DS18B20 without an address"); + } + driver.addressless = true; + } + + driver.once("initialized", function(dataAddress) { + if (!state.address) { + state.address = dataAddress; + } + }); + + driver.on("data", function(dataAddress, data) { + if (!address || dataAddress === address) { + dataHandler(data); + } + }.bind(this)); + } + }, + toCelsius: { + value: function(raw) { + return raw / 16.0; + } + }, + address: { + get: function() { + return priv.get(this).address || 0x00; + } + } + }, + //http://playground.arduino.cc/Main/MPU-6050 + MPU6050: { + initialize: { + value: function(opts, dataHandler) { + var IMU = require("../lib/imu"); + var driver = IMU.Drivers.get(this.board, "MPU6050", opts); + driver.on("data", function(data) { + dataHandler(data.temperature); + }); + } + }, + toCelsius: { + value: function(raw) { + return (raw / 340.00) + 36.53; + } + } + }, + MPL115A2: { + initialize: { + value: function(opts, dataHandler) { + var Multi = require("../lib/imu"); + var driver = Multi.Drivers.get(this.board, "MPL115A2", opts); + driver.on("data", function(data) { + dataHandler(data.temperature); + }); + } + }, + toCelsius: { + value: function(raw) { + // Source: + // https://github.com/adafruit/Adafruit_MPL115A2 + return (raw - 498) / -5.35 + 25.0; + } + } + }, + GROVE: { + initialize: { + value: analogHandler + }, + toCelsius: { + value: function(raw) { + // http://www.seeedstudio.com/wiki/Grove_-_Temperature_Sensor + var adcres = 1023; + // Beta parameter + var beta = 3975; + // 0°C = 273.15 K + var kelvin = 273.15; + // 10 kOhm (sensor resistance) + var rb = 10000; + // Ginf = 1/Rinf + // var ginf = 120.6685; + // Reference Temperature 25°C + var tempr = 298.15; + + var rthermistor = (adcres - raw) * rb / raw; + var tempc = 1 / (Math.log(rthermistor / rb) / beta + 1 / tempr) - kelvin; + + return tempc; + } + } + }, + TINKERKIT: { + initialize: { + value: analogHandler + }, + toCelsius: { + value: function(raw) { + var adcres = 1023; + var beta = 3950; + var kelvin = 273.15; + var rb = 10000; // 10 kOhm + var ginf = 120.6685; // Ginf = 1/Rinf + + var rthermistor = rb * (adcres / raw - 1); + var tempc = beta / (Math.log(rthermistor * ginf)); + + return tempc - kelvin; + } + } + }, + BMP180: { + initialize: { + value: function(opts, dataHandler) { + var Multi = require("../lib/imu"); + var driver = Multi.Drivers.get(this.board, "BMP180", opts); + driver.on("data", function(data) { + dataHandler(data.temperature); + }); + } + }, + toCelsius: { + value: function(raw) { + return raw; + } + } + }, +}; + +// Otherwise known as... +Controllers["MPU-6050"] = Controllers.MPU6050; + +var priv = new Map(); + +function Temperature(opts) { + var controller, freq, last = 0, raw; + + if (!(this instanceof Temperature)) { + return new Temperature(opts); + } + + Board.Device.call( + this, opts = Board.Options(opts) + ); + + freq = opts.freq || 25; + + if (opts.controller && typeof opts.controller === "string") { + controller = Controllers[opts.controller.toUpperCase()]; + } else { + controller = opts.controller; + } + + if (controller == null) { + controller = Controllers["ANALOG"]; + } + + priv.set(this, {}); + + Object.defineProperties(this, controller); + + if (!this.toCelsius) { + this.toCelsius = opts.toCelsius || function(x) { return x; }; + } + + Object.defineProperties(this, { + celsius: { + get: function() { + return this.toCelsius(raw); + } + }, + fahrenheit: { + get: function() { + return (this.celsius * 9.0 / 5.0) + 32; + } + }, + kelvin: { + get: function() { + return this.celsius + 273.15; + } + } + }); + + if (typeof this.initialize === "function") { + this.initialize(opts, function(data) { + raw = data; + }); + } + + setInterval(function() { + if (raw === undefined) { + return; + } + + var data = { + celsius: this.celsius, + fahrenheit: this.fahrenheit, + kelvin: this.kelvin + }; + + this.emit("data", null, data); + + if (this.celsius !== last) { + last = this.celsius; + this.emit("change", null, data); + } + }.bind(this), freq); +} + +util.inherits(Temperature, Emitter); + +Temperature.Drivers = Drivers; + +module.exports = Temperature; diff --git a/JavaScript/node_modules/johnny-five/lib/wii.js b/JavaScript/node_modules/johnny-five/lib/wii.js new file mode 100644 index 0000000..988e975 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/lib/wii.js @@ -0,0 +1,662 @@ +var Board = require("../lib/board.js"), + events = require("events"), + util = require("util"); + +var DEBUG = true; + +var Devices, Change, Update; + +// Event type alias map +var aliases = { + down: ["down", "press", "tap", "impact", "hit"], + up: ["up", "release"], + hold: ["hold"] +}; + +// all private instances +var priv = new Map(); + +// hold time out for buttons. +var holdTimeout = new Map(); + +// keeps data between cycles and fires change event +// if data changes +var last = new Map(); + + + + +/** + * Wii + * @constructor + * + * five.Wii({ + * device: "RVL-004", + * holdtime: ms before firing a hold event on a button, + * freq: ms to throttle the read data loop + * threshold: difference of change to qualify for a change event + * }); + * + * Available events: + * "read" - firehose. + * "down", "press", "tap", "impact", "hit" - button press + * "up", "release" - button release + * "hold" - button hold + * + * @param {Object} opts [description] + * + */ + +function Wii(opts) { + + if (!(this instanceof Wii)) { + return new Wii(opts); + } + + var address, bytes, data, device, + delay, setup, preread; + + Board.Component.call(this, opts); + + // Derive device definition from Devices + device = Devices[opts.device]; + + address = device.address; + bytes = device.bytes; + delay = device.delay; + data = device.data; + setup = device.setup; + preread = device.preread; + + // Wii controller instance properties + this.freq = opts.freq || 500; + + // Button instance properties + this.holdtime = opts.holdtime || 500; + this.threshold = opts.threshold || 10; + + // Initialize components + device.initialize.call(this); + + // Set initial "last data" byte array + last.set(this, [0, 0, 0, 0, 0, 0, 0]); + + // Set up I2C data connection + this.io.i2cConfig(); + + // Iterate and write each set of setup instructions + setup.forEach(function(bytes) { + this.io.i2cWrite(address, bytes); + }, this); + + // Unthrottled i2c read request loop + setInterval(function() { + + // Send this command to get all sensor data and store into + // the 6-byte register within Wii controller. + // This must be execute before reading data from the Wii. + + // Iterate and write each set of setup instructions + preread.forEach(function(bytes) { + this.io.i2cWrite(address, bytes); + }, this); + + + // Request six bytes of data from the controller + this.io.i2cReadOnce(address, bytes, data.bind(this)); + + // Use the high-frequency data read loop as the change event + // emitting loop. This drastically improves change event + // frequency and sensitivity + // + // Emit change events if any delta is greater than + // the threshold + + // RVL-005 does not have a read method at this time. + if (typeof device.read !== "undefined") { + device.read.call(this); + } + }.bind(this), delay || this.freq); + + // Throttled "read" event loop + setInterval(function() { + var event = Board.Event({ + target: this + }); + + // @DEPRECATE + this.emit("read", null, event); + // The "read" event has been deprecated in + // favor of a "data" event. + this.emit("data", null, event); + + }.bind(this), this.freq); +} + +Wii.Components = {}; + +// A nunchuck button (c or z.) +Wii.Components.Button = function(which, controller) { + + if (!(this instanceof Wii.Components.Button)) { + return new Wii.Components.Button(which, controller); + } + + // c or z. + this.which = which; + + // reference to parent controller + this.controller = controller; + + // Set initial values for state tracking + priv.set(this, { + isDown: false + }); + + Object.defineProperties(this, { + // is the button up (not pressed)? + isUp: { + get: function() { + return !priv.get(this).isDown; + } + }, + + // is the button pressed? + isDown: { + get: function() { + return priv.get(this).isDown; + } + } + }); +}; + +Wii.Components.Joystick = function(controller) { + + if (!(this instanceof Wii.Components.Joystick)) { + return new Wii.Components.Joystick(controller); + } + + this.controller = controller; + + var state, accessors; + + // Initialize empty state object + state = {}; + + // Initialize empty accessors object + accessors = {}; + + // Enumerate Joystick properties + ["x", "y", "dx", "dy"].forEach(function(key) { + + state[key] = 0; + + // Define accessors for each property in Joystick list + accessors[key] = { + get: function() { + return priv.get(this)[key]; + } + }; + }, this); + + // Store private state cache + priv.set(this, state); + + // Register newly defined accessors + Object.defineProperties(this, accessors); +}; + +Wii.Components.Accelerometer = function(controller) { + + if (!(this instanceof Wii.Components.Accelerometer)) { + return new Wii.Components.Accelerometer(controller); + } + + this.controller = controller; + + var state, accessors; + + // Initialize empty state object + state = {}; + + // Initialize empty accessors object + accessors = {}; + + // Enumerate Joystick properties + ["x", "y", "z", "dx", "dy", "dz"].forEach(function(key) { + + state[key] = 0; + + // Define accessors for each property in Joystick list + accessors[key] = { + get: function() { + return priv.get(this)[key]; + } + }; + }, this); + + // Store private state cache + priv.set(this, state); + + // Register newly defined accessors + Object.defineProperties(this, accessors); +}; + +util.inherits(Wii, events.EventEmitter); +util.inherits(Wii.Components.Button, events.EventEmitter); +util.inherits(Wii.Components.Joystick, events.EventEmitter); +util.inherits(Wii.Components.Accelerometer, events.EventEmitter); + + +// Regular Wiimote driver bytes will be encoded 0x17 + +function decodeByte(x) { + return (x ^ 0x17) + 0x17; +} + +// Change handlers for disparate controller event types +// +// Note: Change.* methods are |this| sensitive, +// therefore, call sites must use: +// +// Change.button.call( instance, data ); +// +// Change.component.call( instance, data ); +// +// +Change = { + + // Fire a "down", "up" or "hold" (and aliases) event + // for a button context + button: function(key) { + // |this| is button context set by calling as: + // Change.button.call( button instance, event key ); + // + + // Enumerate all button event aliases, + // fire matching types + aliases[key].forEach(function(type) { + var event = new Board.Event({ + // |this| value is a button instance + target: this, + type: type + }); + + // fire button event on the button itself + this.emit(type, null, event); + + // fire button event on the controller + this.controller.emit(type, null, event); + }, this); + }, + + // Fire a "change" event on a component context + component: function(coordinate) { + // |this| is component context set by calling as: + // Change.component.call( component instance, coordinate, val ); + // + + ["axischange", "change"].forEach(function(type) { + var event; + + if (this._events && this._events[type]) { + event = new Board.Event({ + // |this| value is a button instance + target: this, + type: type, + axis: coordinate, + // Check dx/dy/dz change to determine direction + direction: this["d" + coordinate] < 0 ? -1 : 1 + }); + + // Fire change event on actual component + this.emit(type, null, event); + + // Fire change on controller + this.controller.emit(type, null, event); + } + }, this); + } +}; + +// Update handlers for disparate controller event types +// +// Note: Update.* methods are |this| sensitive, +// therefore, call sites must use: +// +// Update.button.call( button instance, boolean down ); +// +// Update.component.call( component instance, coordinate, val ); +// +// + +Update = { + // Set "down" state for button context. + button: function(isDown) { + // |this| is button context set by calling as: + // Update.button.call( button instance, boolean down ); + // + + var state, isFireable; + + // Derive state from private cache + state = priv.get(this); + + // if this is a state change, mark this + // change as fireable. + isFireable = false; + + if (isDown !== state.isDown) { + isFireable = true; + } + + state.isDown = isDown; + + priv.set(this, state); + + if (isFireable) { + // start hold timeout for broadcasting hold. + holdTimeout.set(this, setTimeout(function() { + if (state.isDown) { + Change.button.call(this, "hold"); + } + }.bind(this), this.controller.holdtime)); + + Change.button.call(this, isDown ? "down" : "up"); + } + }, + + // Set "coordinate value" state for component context. + component: function(coordinate, val) { + // |this| is component context set by calling as: + // Update.component.call( component instance, coordinate, val ); + // + + var state = priv.get(this); + state["d" + coordinate] = val - state[coordinate]; + state[coordinate] = val; + priv.set(this, state); + } +}; + + +Devices = { + + // Nunchuk + "RVL-004": { + address: 0x52, + bytes: 6, + delay: 100, + setup: [ + [0x40, 0x00] + ], + preread: [ + [0x00] + ], + // device.read.call(this); + read: function() { + var axes = ["x", "y", "z"]; + + [ + this.joystick, + this.accelerometer + ].forEach(function(component) { + axes.forEach(function(axis) { + var delta = "d" + axis; + if (typeof component[delta] !== "undefined") { + if (Math.abs(component[delta]) > this.threshold) { + Change.component.call(component, axis); + } + } + }, this); + }, this); + }, + // Call as: + // device.initialize.call(this); + initialize: function() { + this.joystick = new Wii.Components.Joystick(this); + this.accelerometer = new Wii.Components.Accelerometer(this); + this.c = new Wii.Components.Button("c", this); + this.z = new Wii.Components.Button("z", this); + }, + data: function(data) { + // TODO: Shift state management to weakmap, this + // should only update an entry in the map + // + + if (data[0] !== 254 && data[1] !== 254 && data[2] !== 254) { + + // Byte 0x00 : X-axis data of the joystick + Update.component.call( + this.joystick, + "x", decodeByte(data[0]) << 2 + ); + + // Byte 0x01 : Y-axis data of the joystick + Update.component.call( + this.joystick, + "y", decodeByte(data[1]) << 2 + ); + + // Byte 0x02 : X-axis data of the accellerometer sensor + Update.component.call( + this.accelerometer, + "x", decodeByte(data[2]) << 2 + ); + + // Byte 0x03 : Y-axis data of the accellerometer sensor + Update.component.call( + this.accelerometer, + "y", decodeByte(data[3]) << 2 + ); + + // Byte 0x04 : Z-axis data of the accellerometer sensor + Update.component.call( + this.accelerometer, + "z", decodeByte(data[4]) << 2 + ); + + // Update Z button + // Grab the first byte of the sixth bit + Update.button.call( + this.z, (decodeByte(data[5]) & 0x01) === 0 ? true : false + ); + + // Update C button + // Grab the second byte of the sixth bit + Update.button.call( + this.c, (decodeByte(data[5]) & 0x02) === 0 ? true : false + ); + + // Update last data array cache + last.set(this, data); + } + } + }, + + // Classic Controller + "RVL-005": { + address: 0x52, + bytes: 6, + delay: 100, + setup: [ + [0x40, 0x00] + ], + preread: [ + [0x00] + ], + + // read: function( this ) { + // var axes = [ "x", "y", "z" ]; + + // [ this.joystick.left, this.joystick.right ].forEach(function( component ) { + // axes.forEach( function( axis ) { + // var delta = "d" + axis; + // if ( typeof component[ delta ] !== "undefined" ) { + // if ( Math.abs( component[ delta ] ) > this.threshold ) { + // Change.component.call( component, axis ); + // } + // } + // }, this ); + // }, this ); + // }, + initialize: function() { + + this.joystick = { + left: new Wii.Components.Joystick(this), + right: new Wii.Components.Joystick(this) + }; + + // obj.direction_pad = new Wii.DirectionPad( obj ); + [ + "y", "x", "up", "down", "left", "right", + "a", "b", "l", "r", "zl", "zr", "start", "home", "select" + ].forEach(function(id) { + + this[id] = new Wii.Components.Button(id, this); + + }, this); + }, + data: function(data) { + // TODO: Shift state management to weakmap, this + // should only update an entry in the map + // + // console.log("data read"); + if (data[0] !== 254 && data[1] !== 254 && data[2] !== 254) { + // Update.button.call( + // this.l, + // ( decodeByte( data[4] ) & 0x05 ) === 0 ? true : false + // ); + // console.log("L:"+( decodeByte( data[4] ) & (1 << 5) ) === 0 ? true : false); + + // LEFT/RIGHT + Update.button.call( + this.l, (decodeByte(data[4]) & 0x20) === 0 ? true : false + ); + + Update.button.call( + this.r, (decodeByte(data[4]) & 0x02) === 0 ? true : false + ); + + // Direction + Update.button.call( + this.up, (decodeByte(data[5]) & 0x01) === 0 ? true : false + ); + + Update.button.call( + this.left, (decodeByte(data[5]) & 0x02) === 0 ? true : false + ); + + Update.button.call( + this.down, (decodeByte(data[4]) & 0x40) === 0 ? true : false + ); + + Update.button.call( + this.right, (decodeByte(data[4]) & 0x80) === 0 ? true : false + ); + + // Z* + Update.button.call( + this.zr, (decodeByte(data[5]) & 0x04) === 0 ? true : false + ); + + Update.button.call( + this.zl, (decodeByte(data[5]) & 0x80) === 0 ? true : false + ); + + // X/Y + Update.button.call( + this.x, (decodeByte(data[5]) & 0x08) === 0 ? true : false + ); + + Update.button.call( + this.y, (decodeByte(data[5]) & 0x20) === 0 ? true : false + ); + + // A/B + Update.button.call( + this.a, (decodeByte(data[5]) & 0x10) === 0 ? true : false + ); + + Update.button.call( + this.b, (decodeByte(data[5]) & 0x40) === 0 ? true : false + ); + + // MENU + Update.button.call( + this.select, (decodeByte(data[4]) & 0x10) === 0 ? true : false + ); + + Update.button.call( + this.start, (decodeByte(data[4]) & 0x04) === 0 ? true : false + ); + + Update.button.call( + this.home, (decodeByte(data[4]) & 0x08) === 0 ? true : false + ); + + + /// debugger to parse out keycodes. + if (DEBUG) { + + // var leftX = ( decodeByte( data[1] ) & 0x0f ); + // var leftX = ( decodeByte( data[1] ) & 0x0f ); + // console.log("--------------------"); + // console.log(data.join(",")); + // console.log("--------------------"); + // for (var b = 3; b < 6; b++) { + // for (var c = 0; c <= 255; c++) { + // var t = ( decodeByte( data[b] ) & c ) === 0 ? true : false; + // if (t) + // console.log(b+">"+c+":"); + // } + // } + // console.log("--------------------"); + // ( pressedRowBit( decodeByte( data[0] ), 5 )); + } + + Update.component.call( + this.joystick.left, + "x", decodeByte(data[0]) & 0x3f + ); + // console.log("X"+decodeByte( data[0] ) << 2); + + // Byte 0x01 : Y-axis data of the joystick + Update.component.call( + this.joystick.left, + "y", decodeByte(data[0]) & 0x3f + ); + + Update.component.call( + this.joystick.right, + "x", ((data[0] & 0xc0) >> 3) + ((data[1] & 0xc0) >> 5) + ((data[2] & 0x80) >> 7) + ); + + Update.component.call( + this.joystick.right, + "y", data[2] & 0x1f + ); + + // Update last data array cache + last.set(this, data); + } + } + } +}; + + +Wii.Nunchuk = function(opts) { + return new Wii({ + freq: opts && "freq" in opts ? opts.freq : 100, + device: "RVL-004" + }); +}; + +Wii.Classic = function(opts) { + return new Wii({ + freq: opts && "freq" in opts ? opts.freq : 100, + device: "RVL-005" + }); +}; + +module.exports = Wii; diff --git a/JavaScript/node_modules/johnny-five/node_modules/.bin/firmata b/JavaScript/node_modules/johnny-five/node_modules/.bin/firmata new file mode 120000 index 0000000..9d62f0c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/.bin/firmata @@ -0,0 +1 @@ +../firmata/repl.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportlist b/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportlist new file mode 120000 index 0000000..5fa87b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportlist @@ -0,0 +1 @@ +../serialport/bin/serialportList.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportterm b/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportterm new file mode 120000 index 0000000..be4d334 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/.bin/serialportterm @@ -0,0 +1 @@ +../serialport/bin/serialportTerminal.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.editorconfig new file mode 100644 index 0000000..eaa2141 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.eslintrc new file mode 100644 index 0000000..db9cd15 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.eslintrc @@ -0,0 +1,172 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [2, "expression"], + "generator-star-spacing": [2, "after"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "linebreak-style": [2, "unix"], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [2, { capIsNewExceptions: ["ToObject", "ToInteger", "ToLength", "SameValueZero", "RequireObjectCoercible"] }], + "newline-after-var": [0], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-continue": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-param-reassign": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-throw-literal": [2], + "no-trailing-spaces": [2, { "skipBlankLines": false }], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unneeded-ternary": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "object-shorthand": [2, "never"], + "one-var": [0], + "operator-assignment": [0, "always"], + "operator-linebreak": [2, "none"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.jscs.json new file mode 100644 index 0000000..0ae174e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.jscs.json @@ -0,0 +1,106 @@ +{ + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requirePaddingNewLinesBeforeLineComments": true, + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 3 + }, + + "requirePaddingNewLinesAfterUseStrict": true +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.travis.yml new file mode 100644 index 0000000..d9aa306 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/.travis.yml @@ -0,0 +1,38 @@ +language: node_js +node_js: + - "iojs-v2.0" + - "iojs-v1.8" + - "iojs-v1.7" + - "iojs-v1.6" + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] || npm install -g npm@~1.4.6' +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v1.7" + - node_js: "iojs-v1.6" + - node_js: "iojs-v1.5" + - node_js: "iojs-v1.4" + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.8" + - node_js: "0.6" + - node_js: "0.4" +sudo: false diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/CHANGELOG.md new file mode 100644 index 0000000..93741e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/CHANGELOG.md @@ -0,0 +1,44 @@ +2.0.0 / 2015-05-23 +================= + * Fix to not skip holes, per https://github.com/tc39/Array.prototype.includes/issues/15 + +1.1.1 / 2015-05-23 +================= + * Test up to `io.js` `v2.0` + * Update `es-abstract`, `tape`, `eslint`, `semver`, `jscs`, `semver` + +1.1.0 / 2015-03-19 +================= + * Update `es-abstract`, `editorconfig-tools`, `nsp`, `eslint`, `semver` + +1.0.6 / 2015-02-17 +================= + * All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. + * Run `travis-ci` tests on `iojs` and `node` v0.12; allow 0.8 failures. + * Update `tape`, `jscs`, `es-abstract`, remove `is`. + +1.0.5 / 2015-01-30 +================= + * Update `tape`, `jscs`, `nsp`, `eslint`, `es-abstract` + +1.0.4 / 2015-01-10 +================= + * Use `es-abstract` for ECMAScript spec internal abstract operations + +1.0.3 / 2015-01-06 +================= + * Speed optimization: use Array#indexOf when available + * Fix ES3, IE 6-8, Opera 10.6, Opera 11.1 support + * Run testling on both sets of tests + +1.0.2 / 2015-01-05 +================= + * Ensure tests are includes in the module on `npm` + +1.0.1 / 2015-01-04 +================= + * Remove mistaken auto-shim. + +1.0.0 / 2015-01-04 +================= + * v1.0.0 diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/LICENSE new file mode 100644 index 0000000..8c271c1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/Makefile new file mode 100644 index 0000000..b9e4fe1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/README.md new file mode 100644 index 0000000..18bbd52 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/README.md @@ -0,0 +1,78 @@ +#array-includes [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +[![browser support][testling-svg]][testling-url] + +A spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3. +Invoke its "shim" method to shim `Array.prototype.includes` if it is unavailable. + +## Example + +```js +var includes = require('array-includes'); +var assert = require('assert'); +var arr = { + 1, + 'foo', + NaN, + -0 +}; +assert.equal(arr.indexOf(0) > -1, true); +assert.equal(arr.indexOf(-0) > -1, true); +assert.equal(includes(arr, 0), false); +assert.equal(includes(arr, -0), true); + +assert.equal(arr.indexOf(NaN) > -1, false); +assert.equal(includes(arr, NaN), true); + +assert.equal(includes(arr, 'foo', 0), true); +assert.equal(includes(arr, 'foo', 1), true); +assert.equal(includes(arr, 'foo', 2), false); +``` + +```js +var includes = require('array-includes'); +var assert = require('assert'); +/* when Array#includes is not present */ +delete Array.prototype.includes; +var shimmedIncludes = includes.shim(); +assert.equal(shimmedIncludes, includes); +assert.deepEqual(arr.includes('foo', 1), includes(arr, 'foo', 1)); +``` + +```js +var includes = require('array-includes'); +var assert = require('assert'); +/* when Array#includes is present */ +var shimmedIncludes = includes.shim(); +assert.notEqual(shimmedIncludes, includes); +assert.equal(shimmedIncludes, Array.prototype.includes); +assert.deepEqual(arr.includes(1, 'foo'), includes(arr, 1, 'foo')); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/array-includes +[npm-version-svg]: http://vb.teelaun.ch/ljharb/array-includes.svg +[travis-svg]: https://travis-ci.org/ljharb/array-includes.svg +[travis-url]: https://travis-ci.org/ljharb/array-includes +[deps-svg]: https://david-dm.org/ljharb/array-includes.svg +[deps-url]: https://david-dm.org/ljharb/array-includes +[dev-deps-svg]: https://david-dm.org/ljharb/array-includes/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/array-includes#info=devDependencies +[testling-svg]: https://ci.testling.com/ljharb/array-includes.png +[testling-url]: https://ci.testling.com/ljharb/array-includes +[npm-badge-png]: https://nodei.co/npm/array-includes.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/array-includes.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/array-includes.svg +[downloads-url]: http://npm-stat.com/charts.html?package=array-includes + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/index.js new file mode 100644 index 0000000..1db4a15 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/index.js @@ -0,0 +1,45 @@ +'use strict'; + +var define = require('define-properties'); +var ES = require('es-abstract/es6'); +var $isNaN = Number.isNaN || function (a) { return a !== a; }; +var $isFinite = Number.isFinite || function (n) { return typeof n === 'number' && global.isFinite(n); }; + +var includesShim = function includes(searchElement) { + var fromIndex = arguments.length > 1 ? ES.ToInteger(arguments[1]) : 0; + if (Array.prototype.indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') { + return Array.prototype.indexOf.apply(this, arguments) > -1; + } + + var O = ES.ToObject(this); + var length = ES.ToLength(O.length); + if (length === 0) { + return false; + } + var k = fromIndex >= 0 ? fromIndex : Math.max(0, length + fromIndex); + while (k < length) { + if (ES.SameValueZero(searchElement, O[k])) { + return true; + } + k += 1; + } + return false; +}; + +/*eslint-disable no-unused-vars */ +var boundIncludesShim = function includes(array, searchElement) { +/*eslint-enable no-unused-vars */ + ES.RequireObjectCoercible(array); + return includesShim.apply(array, Array.prototype.slice.call(arguments, 1)); +}; +define(boundIncludesShim, { + method: includesShim, + shim: function shimArrayPrototypeIncludes() { + define(Array.prototype, { + includes: includesShim + }); + return Array.prototype.includes || includesShim; + } +}); + +module.exports = boundIncludesShim; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.editorconfig new file mode 100644 index 0000000..eaa2141 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.eslintrc new file mode 100644 index 0000000..87bfd46 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.eslintrc @@ -0,0 +1,193 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "accessor-pairs": [2, { getWithoutSet: false, setWithoutGet: true }], + "array-bracket-spacing": [2, "never", { + "singleValue": false, + "objectsInArrays": false, + "arraysInArrays": false + }], + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [2, 10], + "computed-property-spacing": [2, "never"], + "consistent-return": [2], + "consistent-this": [0, "that"], + "constructor-super": [2], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [2, "expression"], + "generator-star-spacing": [2, { "before": false, "after": true }], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "linebreak-style": [2, "unix"], + "lines-around-comment": [2, { + "beforeBlockComment": false, + "afterBlockComment": false, + "beforeLineComment": false, + "beforeLineComment": false, + "allowBlockStart": true, + "allowBlockEnd": true + }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [2, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [2, 2], + "max-params": [2, 4], + "max-statements": [2, 14], + "new-parens": [2], + "new-cap": [2], + "newline-after-var": [0], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-continue": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-character-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-param-reassign": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2, "always"], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-this-before-super": [2], + "no-throw-literal": [2], + "no-trailing-spaces": [2, { "skipBlankLines": false }], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unexpected-multiline": [2], + "no-unneeded-ternary": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "object-curly-spacing": [2, "always"], + "object-shorthand": [2, "never"], + "one-var": [0], + "operator-assignment": [0, "always"], + "operator-linebreak": [2, "none"], + "padded-blocks": [0], + "prefer-const": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-comment": [2, "always"], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true, "onlyEquality": false }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.jscs.json new file mode 100644 index 0000000..a655879 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.jscs.json @@ -0,0 +1,104 @@ +{ + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 3 + }, + + "requirePaddingNewLinesAfterUseStrict": true +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.npmignore new file mode 100644 index 0000000..a777a81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.npmignore @@ -0,0 +1,2 @@ +test/* + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.travis.yml new file mode 100644 index 0000000..ebef644 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/.travis.yml @@ -0,0 +1,44 @@ +language: node_js +node_js: + - "iojs-v2.3" + - "iojs-v2.2" + - "iojs-v2.1" + - "iojs-v2.0" + - "iojs-v1.8" + - "iojs-v1.7" + - "iojs-v1.6" + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" = "0.6" ] || npm install -g npm@1.4.28 && npm install -g npm' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v2.2" + - node_js: "iojs-v2.1" + - node_js: "iojs-v2.0" + - node_js: "iojs-v1.7" + - node_js: "iojs-v1.6" + - node_js: "iojs-v1.5" + - node_js: "iojs-v1.4" + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.8" + - node_js: "0.6" + - node_js: "0.4" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/CHANGELOG.md new file mode 100644 index 0000000..e72acf9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/CHANGELOG.md @@ -0,0 +1,22 @@ +1.1.0 / 2015-07-01 +================= + * [New] Add support for symbol-valued properties. + * [Dev Deps] Update `nsp`, `eslint` + * [Tests] Test up to `io.js` `v2.3` + +1.0.3 / 2015-05-30 +================= + * Using a more reliable check for supported property descriptors. + +1.0.2 / 2015-05-23 +================= + * Test up to `io.js` `v2.0` + * Update `tape`, `jscs`, `nsp`, `eslint`, `object-keys`, `editorconfig-tools`, `covert` + +1.0.1 / 2015-01-06 +================= + * Update `object-keys` to fix ES3 support + +1.0.0 / 2015-01-04 +================= + * v1.0.0 diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/LICENSE new file mode 100644 index 0000000..8c271c1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/README.md new file mode 100644 index 0000000..7c75291 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/README.md @@ -0,0 +1,86 @@ +#define-properties [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +[![browser support][testling-svg]][testling-url] + +Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines. +Existing properties are not overridden. Accepts a map of property names to a predicate that, when true, force-overrides. + +## Example + +```js +var define = require('define-properties'); +var assert = require('assert'); + +var obj = define({ a: 1, b: 2 }, { + a: 10, + b: 20, + c: 30 +}); +assert(obj.a === 1); +assert(obj.b === 2); +assert(obj.c === 30); +if (define.supportsDescriptors) { + assert.deepEqual(Object.keys(obj), ['a', 'b']); + assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'c'), { + configurable: true, + enumerable: false, + value: 30, + writable: false + }); +} +``` + +Then, with predicates: +```js +var define = require('define-properties'); +var assert = require('assert'); + +var obj = define({ a: 1, b: 2, c: 3 }, { + a: 10, + b: 20, + c: 30 +}, { + a: function () { return false; }, + b: function () { return true; } +}); +assert(obj.a === 1); +assert(obj.b === 20); +assert(obj.c === 3); +if (define.supportsDescriptors) { + assert.deepEqual(Object.keys(obj), ['a', 'c']); + assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'b'), { + configurable: true, + enumerable: false, + value: 20, + writable: false + }); +} +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/define-properties +[npm-version-svg]: http://vb.teelaun.ch/ljharb/define-properties.svg +[travis-svg]: https://travis-ci.org/ljharb/define-properties.svg +[travis-url]: https://travis-ci.org/ljharb/define-properties +[deps-svg]: https://david-dm.org/ljharb/define-properties.svg +[deps-url]: https://david-dm.org/ljharb/define-properties +[dev-deps-svg]: https://david-dm.org/ljharb/define-properties/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/define-properties#info=devDependencies +[testling-svg]: https://ci.testling.com/ljharb/define-properties.png +[testling-url]: https://ci.testling.com/ljharb/define-properties +[npm-badge-png]: https://nodei.co/npm/define-properties.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/define-properties.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/define-properties.svg +[downloads-url]: http://npm-stat.com/charts.html?package=define-properties + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/index.js new file mode 100644 index 0000000..03fb8ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/index.js @@ -0,0 +1,56 @@ +'use strict'; + +var keys = require('object-keys'); +var foreach = require('foreach'); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; + +var toStr = Object.prototype.toString; + +var isFunction = function (fn) { + return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; +}; + +var arePropertyDescriptorsSupported = function () { + var obj = {}; + try { + Object.defineProperty(obj, 'x', { value: obj, enumerable: false }); + /* eslint-disable no-unused-vars */ + for (var _ in obj) { return false; } + /* eslint-enable no-unused-vars */ + return obj.x === obj; + } catch (e) { /* this is IE 8. */ + return false; + } +}; +var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported(); + +var defineProperty = function (object, name, value, predicate) { + if (name in object && (!isFunction(predicate) || !predicate())) { + return; + } + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: value + }); + } else { + object[name] = value; + } +}; + +var defineProperties = function (object, map) { + var predicates = arguments.length > 2 ? arguments[2] : {}; + var props = keys(map); + if (hasSymbols) { + props = props.concat(Object.getOwnPropertySymbols(map)); + } + foreach(props, function (name) { + defineProperty(object, name, map[name], predicates[name]); + }); +}; + +defineProperties.supportsDescriptors = !!supportsDescriptors; + +module.exports = defineProperties; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/.npmignore new file mode 100644 index 0000000..d135df6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/.npmignore @@ -0,0 +1,3 @@ +node_modules +components +build \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/LICENSE new file mode 100644 index 0000000..3032d6e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/LICENSE @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2013 Manuel Stofer + +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/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Makefile new file mode 100644 index 0000000..eae4117 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Makefile @@ -0,0 +1,11 @@ + +build: components + @component build + +components: component.json + @component install --dev + +clean: + rm -fr build components template.js + +.PHONY: clean diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Readme.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Readme.md new file mode 100644 index 0000000..2752b57 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/Readme.md @@ -0,0 +1,30 @@ + +# foreach + +Iterate over the key value pairs of either an array-like object or a dictionary like object. + +[![browser support][1]][2] + +## API + +### foreach(object, function, [context]) + +```js +var each = require('foreach'); + +each([1,2,3], function (value, key, array) { + // value === 1, 2, 3 + // key === 0, 1, 2 + // array === [1, 2, 3] +}); + +each({0:1,1:2,2:3}, function (value, key, object) { + // value === 1, 2, 3 + // key === 0, 1, 2 + // object === {0:1,1:2,2:3} +}); +``` + +[1]: https://ci.testling.com/manuelstofer/foreach.png +[2]: https://ci.testling.com/manuelstofer/foreach + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/component.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/component.json new file mode 100644 index 0000000..0eeecb5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/component.json @@ -0,0 +1,11 @@ +{ + "name": "foreach", + "description": "foreach component + npm package", + "version": "2.0.5", + "keywords": [], + "dependencies": {}, + "scripts": [ + "index.js" + ], + "repo": "manuelstofer/foreach" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/index.js new file mode 100644 index 0000000..a961e4e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/index.js @@ -0,0 +1,22 @@ + +var hasOwn = Object.prototype.hasOwnProperty; +var toString = Object.prototype.toString; + +module.exports = function forEach (obj, fn, ctx) { + if (toString.call(fn) !== '[object Function]') { + throw new TypeError('iterator must be a function'); + } + var l = obj.length; + if (l === +l) { + for (var i = 0; i < l; i++) { + fn.call(ctx, obj[i], i, obj); + } + } else { + for (var k in obj) { + if (hasOwn.call(obj, k)) { + fn.call(ctx, obj[k], k, obj); + } + } + } +}; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/package.json new file mode 100644 index 0000000..7637e01 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/package.json @@ -0,0 +1,84 @@ +{ + "name": "foreach", + "description": "foreach component + npm package", + "version": "2.0.5", + "author": { + "name": "Manuel Stofer", + "email": "manuel@takimata.ch" + }, + "contributors": [ + { + "name": "Manuel Stofer" + }, + { + "name": "Jordan Harband", + "url": "https://github.com/ljharb" + } + ], + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "node test.js", + "coverage": "covert test.js", + "coverage-quiet": "covert --quiet test.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/manuelstofer/foreach" + }, + "keywords": [ + "shim", + "Array.prototype.forEach", + "forEach", + "Array#forEach", + "each" + ], + "dependencies": {}, + "devDependencies": { + "tape": "*", + "covert": "*" + }, + "testling": { + "files": "test.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0", + "chrome/22.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/5.0.5..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "bugs": { + "url": "https://github.com/manuelstofer/foreach/issues" + }, + "homepage": "https://github.com/manuelstofer/foreach", + "_id": "foreach@2.0.5", + "_shasum": "0bee005018aeb260d0a3af3ae658dd0136ec1b99", + "_from": "foreach@>=2.0.5 <3.0.0", + "_npmVersion": "1.4.9", + "_npmUser": { + "name": "manuelstofer", + "email": "manuel@takimata.ch" + }, + "maintainers": [ + { + "name": "manuelstofer", + "email": "manuel@takimata.ch" + } + ], + "dist": { + "shasum": "0bee005018aeb260d0a3af3ae658dd0136ec1b99", + "tarball": "http://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/test.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/test.js new file mode 100644 index 0000000..c6283c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/foreach/test.js @@ -0,0 +1,153 @@ +var test = require('tape'); +var forEach = require('./index.js'); + + +test('second argument: iterator', function (t) { + var arr = []; + t.throws(function () { forEach(arr); }, TypeError, 'undefined is not a function'); + t.throws(function () { forEach(arr, null); }, TypeError, 'null is not a function'); + t.throws(function () { forEach(arr, ''); }, TypeError, 'string is not a function'); + t.throws(function () { forEach(arr, /a/); }, TypeError, 'regex is not a function'); + t.throws(function () { forEach(arr, true); }, TypeError, 'true is not a function'); + t.throws(function () { forEach(arr, false); }, TypeError, 'false is not a function'); + t.throws(function () { forEach(arr, NaN); }, TypeError, 'NaN is not a function'); + t.throws(function () { forEach(arr, 42); }, TypeError, '42 is not a function'); + t.doesNotThrow(function () { forEach(arr, function () {}); }, 'function is a function'); + t.end(); +}); + +test('array', function (t) { + var arr = [1, 2, 3]; + + t.test('iterates over every item', function (st) { + var index = 0; + forEach(arr, function () { index += 1; }); + st.equal(index, arr.length, 'iterates ' + arr.length + ' times'); + st.end(); + }); + + t.test('first iterator argument', function (st) { + var index = 0; + st.plan(arr.length); + forEach(arr, function (item) { + st.equal(arr[index], item, 'item ' + index + ' is passed as first argument'); + index += 1; + }); + st.end(); + }); + + t.test('second iterator argument', function (st) { + var counter = 0; + st.plan(arr.length); + forEach(arr, function (item, index) { + st.equal(counter, index, 'index ' + index + ' is passed as second argument'); + counter += 1; + }); + st.end(); + }); + + t.test('third iterator argument', function (st) { + st.plan(arr.length); + forEach(arr, function (item, index, array) { + st.deepEqual(arr, array, 'array is passed as third argument'); + }); + st.end(); + }); + + t.test('context argument', function (st) { + var context = {}; + st.plan(1); + forEach([1], function () { + st.equal(this, context, '"this" is the passed context'); + }, context); + st.end(); + }); + + t.end(); +}); + +test('object', function (t) { + var obj = { + a: 1, + b: 2, + c: 3 + }; + var keys = ['a', 'b', 'c']; + + var F = function () { + this.a = 1; + this.b = 2; + }; + F.prototype.c = 3; + var fKeys = ['a', 'b']; + + t.test('iterates over every object literal key', function (st) { + var counter = 0; + forEach(obj, function () { counter += 1; }); + st.equal(counter, keys.length, 'iterated ' + counter + ' times'); + st.end(); + }); + + t.test('iterates only over own keys', function (st) { + var counter = 0; + forEach(new F(), function () { counter += 1; }); + st.equal(counter, fKeys.length, 'iterated ' + fKeys.length + ' times'); + st.end(); + }); + + t.test('first iterator argument', function (st) { + var index = 0; + st.plan(keys.length); + forEach(obj, function (item) { + st.equal(obj[keys[index]], item, 'item at key ' + keys[index] + ' is passed as first argument'); + index += 1; + }); + st.end(); + }); + + t.test('second iterator argument', function (st) { + var counter = 0; + st.plan(keys.length); + forEach(obj, function (item, key) { + st.equal(keys[counter], key, 'key ' + key + ' is passed as second argument'); + counter += 1; + }); + st.end(); + }); + + t.test('third iterator argument', function (st) { + st.plan(keys.length); + forEach(obj, function (item, key, object) { + st.deepEqual(obj, object, 'object is passed as third argument'); + }); + st.end(); + }); + + t.test('context argument', function (st) { + var context = {}; + st.plan(1); + forEach({ a: 1 }, function () { + st.equal(this, context, '"this" is the passed context'); + }, context); + st.end(); + }); + + t.end(); +}); + + +test('string', function (t) { + var str = 'str'; + t.test('second iterator argument', function (st) { + var counter = 0; + st.plan(str.length * 2 + 1); + forEach(str, function (item, index) { + st.equal(counter, index, 'index ' + index + ' is passed as second argument'); + st.equal(str.charAt(index), item); + counter += 1; + }); + st.equal(counter, str.length, 'iterates ' + str.length + ' times'); + }); + t.end(); +}); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.editorconfig new file mode 100644 index 0000000..eaa2141 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.eslintrc new file mode 100644 index 0000000..fa45534 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.eslintrc @@ -0,0 +1,193 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "accessor-pairs": [2, { getWithoutSet: false, setWithoutGet: true }], + "array-bracket-spacing": [2, "never", { + "singleValue": false, + "objectsInArrays": false, + "arraysInArrays": false + }], + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [2, 12], + "computed-property-spacing": [2, "never"], + "consistent-return": [2], + "consistent-this": [0, "that"], + "constructor-super": [2], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [2, "expression"], + "generator-star-spacing": [2, { "before": false, "after": true }], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "linebreak-style": [2, "unix"], + "lines-around-comment": [2, { + "beforeBlockComment": false, + "afterBlockComment": false, + "beforeLineComment": false, + "beforeLineComment": false, + "allowBlockStart": true, + "allowBlockEnd": true + }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [2, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [2, 2], + "max-params": [2, 3], + "max-statements": [2, 25], + "new-parens": [2], + "new-cap": [2], + "newline-after-var": [0], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-continue": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-character-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-param-reassign": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2, "always"], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-this-before-super": [2], + "no-throw-literal": [2], + "no-trailing-spaces": [2, { "skipBlankLines": false }], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unexpected-multiline": [2], + "no-unneeded-ternary": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "object-curly-spacing": [2, "always"], + "object-shorthand": [2, "never"], + "one-var": [0], + "operator-assignment": [0, "always"], + "operator-linebreak": [2, "after"], + "padded-blocks": [0], + "prefer-const": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-comment": [2, "always"], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true, "onlyEquality": false }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.jscs.json new file mode 100644 index 0000000..94cc130 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.jscs.json @@ -0,0 +1,104 @@ +{ + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 7 + }, + + "requirePaddingNewLinesAfterUseStrict": true +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.npmignore new file mode 100644 index 0000000..a777a81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.npmignore @@ -0,0 +1,2 @@ +test/* + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.travis.yml new file mode 100644 index 0000000..ebef644 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/.travis.yml @@ -0,0 +1,44 @@ +language: node_js +node_js: + - "iojs-v2.3" + - "iojs-v2.2" + - "iojs-v2.1" + - "iojs-v2.0" + - "iojs-v1.8" + - "iojs-v1.7" + - "iojs-v1.6" + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" = "0.6" ] || npm install -g npm@1.4.28 && npm install -g npm' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v2.2" + - node_js: "iojs-v2.1" + - node_js: "iojs-v2.0" + - node_js: "iojs-v1.7" + - node_js: "iojs-v1.6" + - node_js: "iojs-v1.5" + - node_js: "iojs-v1.4" + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.8" + - node_js: "0.6" + - node_js: "0.4" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/CHANGELOG.md new file mode 100644 index 0000000..e5855f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/CHANGELOG.md @@ -0,0 +1,183 @@ +1.0.6 / 2015-07-09 +================= + * [Fix] Use an object lookup rather than ES5's `indexOf` (#14) + * [Tests] ES3 browsers don't have `Array.isArray` + * [Tests] Fix `no-shadow` rule, as well as an IE 8 bug caused by engine NFE shadowing bugs. + +1.0.5 / 2015-07-03 +================= + * [Fix] Fix a flabbergasting IE 8 bug where `localStorage.constructor.prototype === localStorage` throws + * [Tests] Test up to `io.js` `v2.3` + * [Dev Deps] Update `nsp`, `eslint` + +1.0.4 / 2015-05-23 +================= + * Fix a Safari 5.0 bug with `Object.keys` not working with `arguments` + * Test on latest `node` and `io.js` + * Update `jscs`, `tape`, `eslint`, `nsp`, `is`, `editorconfig-tools`, `covert` + +1.0.3 / 2015-01-06 +================= + * Revert "Make `object-keys` more robust against later environment tampering" to maintain ES3 compliance + +1.0.2 / 2014-12-28 +================= + * Update lots of dev dependencies + * Tweaks to README + * Make `object-keys` more robust against later environment tampering + +1.0.1 / 2014-09-03 +================= + * Update URLs and badges in README + +1.0.0 / 2014-08-26 +================= + * v1.0.0 + +0.6.1 / 2014-08-25 +================= + * v0.6.1 + * Updating dependencies (tape, covert, is) + * Update badges in readme + * Use separate var statements + +0.6.0 / 2014-04-23 +================= + * v0.6.0 + * Updating dependencies (tape, covert) + * Make sure boxed primitives, and arguments objects, work properly in ES3 browsers + * Improve test matrix: test all node versions, but only latest two stables are a failure + * Remove internal foreach shim. + +0.5.1 / 2014-03-09 +================= + * 0.5.1 + * Updating dependencies (tape, covert, is) + * Removing forEach from the module (but keeping it in tests) + +0.5.0 / 2014-01-30 +================= + * 0.5.0 + * Explicitly returning the shim, instead of returning native Object.keys when present + * Adding a changelog. + * Cleaning up IIFE wrapping + * Testing on node 0.4 through 0.11 + +0.4.0 / 2013-08-14 +================== + + * v0.4.0 + * In Chrome 4-10 and Safari 4, typeof (new RegExp) === 'function' + * If it's a string, make sure to use charAt instead of brackets. + * Only use Function#call if necessary. + * Making sure the context tests actually run. + * Better function detection + * Adding the android browser + * Fixing testling files + * Updating tape + * Removing the "is" dependency. + * Making an isArguments shim. + * Adding a local forEach shim and tests. + * Updating paths. + * Moving the shim test. + * v0.3.0 + +0.3.0 / 2013-05-18 +================== + + * README tweak. + * Fixing constructor enum issue. Fixes [#5](https://github.com/ljharb/object-keys/issues/5). + * Adding a test for [#5](https://github.com/ljharb/object-keys/issues/5) + * Updating readme. + * Updating dependencies. + * Giving credit to lodash. + * Make sure that a prototype's constructor property is not enumerable. Fixes [#3](https://github.com/ljharb/object-keys/issues/3). + * Adding additional tests to handle arguments objects, and to skip "prototype" in functions. Fixes [#2](https://github.com/ljharb/object-keys/issues/2). + * Fixing a typo on this test for [#3](https://github.com/ljharb/object-keys/issues/3). + * Adding node 0.10 to travis. + * Adding an IE < 9 test per [#3](https://github.com/ljharb/object-keys/issues/3) + * Adding an iOS 5 mobile Safari test per [#2](https://github.com/ljharb/object-keys/issues/2) + * Moving "indexof" and "is" to be dev dependencies. + * Making sure the shim works with functions. + * Flattening the tests. + +0.2.0 / 2013-05-10 +================== + + * v0.2.0 + * Object.keys should work with arrays. + +0.1.8 / 2013-05-10 +================== + + * v0.1.8 + * Upgrading dependencies. + * Using a simpler check. + * Fixing a bug in hasDontEnumBug browsers. + * Using the newest tape! + * Fixing this error test. + * "undefined" is probably a reserved word in ES3. + * Better test message. + +0.1.7 / 2013-04-17 +================== + + * Upgrading "is" once more. + * The key "null" is breaking some browsers. + +0.1.6 / 2013-04-17 +================== + + * v0.1.6 + * Upgrading "is" + +0.1.5 / 2013-04-14 +================== + + * Bumping version. + * Adding more testling browsers. + * Updating "is" + +0.1.4 / 2013-04-08 +================== + + * Using "is" instead of "is-extended". + +0.1.3 / 2013-04-07 +================== + + * Using "foreach" instead of my own shim. + * Removing "tap"; I'll just wait for "tape" to fix its node 0.10 bug. + +0.1.2 / 2013-04-03 +================== + + * Adding dependency status; moving links to an index at the bottom. + * Upgrading is-extended; version 0.1.2 + * Adding an npm version badge. + +0.1.1 / 2013-04-01 +================== + + * Adding Travis CI. + * Bumping the version. + * Adding indexOf since IE sucks. + * Adding a forEach shim since older browsers don't have Array#forEach. + * Upgrading tape - 0.3.2 uses Array#map + * Using explicit end instead of plan. + * Can't test with Array.isArray in older browsers. + * Using is-extended. + * Fixing testling files. + * JSHint/JSLint-ing. + * Removing an unused object. + * Using strict mode. + +0.1.0 / 2013-03-30 +================== + + * Changing the exports should have meant a higher version bump. + * Oops, fixing the repo URL. + * Adding more tests. + * 0.0.2 + * Merge branch 'export_one_thing'; closes [#1](https://github.com/ljharb/object-keys/issues/1) + * Move shim export to a separate file. diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/LICENSE new file mode 100644 index 0000000..28553fd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2013 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/README.md new file mode 100644 index 0000000..66ac39e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/README.md @@ -0,0 +1,76 @@ +#object-keys [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +[![browser support][testling-svg]][testling-url] + +An Object.keys shim. Invoke its "shim" method to shim Object.keys if it is unavailable. + +Most common usage: +```js +var keys = Object.keys || require('object-keys'); +``` + +## Example + +```js +var keys = require('object-keys'); +var assert = require('assert'); +var obj = { + a: true, + b: true, + c: true +}; + +assert.deepEqual(keys(obj), ['a', 'b', 'c']); +``` + +```js +var keys = require('object-keys'); +var assert = require('assert'); +/* when Object.keys is not present */ +delete Object.keys; +var shimmedKeys = keys.shim(); +assert.equal(shimmedKeys, keys); +assert.deepEqual(Object.keys(obj), keys(obj)); +``` + +```js +var keys = require('object-keys'); +var assert = require('assert'); +/* when Object.keys is present */ +var shimmedKeys = keys.shim(); +assert.equal(shimmedKeys, Object.keys); +assert.deepEqual(Object.keys(obj), keys(obj)); +``` + +## Source +Implementation taken directly from [es5-shim][es5-shim-url], with modifications, including from [lodash][lodash-url]. + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/object-keys +[npm-version-svg]: http://vb.teelaun.ch/ljharb/object-keys.svg +[travis-svg]: https://travis-ci.org/ljharb/object-keys.svg +[travis-url]: https://travis-ci.org/ljharb/object-keys +[deps-svg]: https://david-dm.org/ljharb/object-keys.svg +[deps-url]: https://david-dm.org/ljharb/object-keys +[dev-deps-svg]: https://david-dm.org/ljharb/object-keys/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/object-keys#info=devDependencies +[testling-svg]: https://ci.testling.com/ljharb/object-keys.png +[testling-url]: https://ci.testling.com/ljharb/object-keys +[es5-shim-url]: https://github.com/es-shims/es5-shim/blob/master/es5-shim.js#L542-589 +[lodash-url]: https://github.com/lodash/lodash +[npm-badge-png]: https://nodei.co/npm/object-keys.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/object-keys.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/object-keys.svg +[downloads-url]: http://npm-stat.com/charts.html?package=object-keys + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/index.js new file mode 100644 index 0000000..2c99261 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/index.js @@ -0,0 +1,109 @@ +'use strict'; + +// modified from https://github.com/es-shims/es5-shim +var has = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var slice = Array.prototype.slice; +var isArgs = require('./isArguments'); +var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString'); +var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype'); +var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' +]; +var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; +}; +var blacklistedKeys = { + $window: true, + $console: true, + $parent: true, + $self: true, + $frames: true +}; +var hasAutomationEqualityBug = (function () { + /* global window */ + if (typeof window === 'undefined') { return false; } + for (var k in window) { + if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + equalsConstructorPrototype(window[k]); + } catch (e) { + return true; + } + } + } + return false; +}()); + +var keysShim = function keys(object) { + var isObject = object !== null && typeof object === 'object'; + var isFunction = toStr.call(object) === '[object Function]'; + var isArguments = isArgs(object); + var isString = isObject && toStr.call(object) === '[object String]'; + var theKeys = []; + + if (!isObject && !isFunction && !isArguments) { + throw new TypeError('Object.keys called on a non-object'); + } + + var skipProto = hasProtoEnumBug && isFunction; + if (isString && object.length > 0 && !has.call(object, 0)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)); + } + } + + if (isArguments && object.length > 0) { + for (var j = 0; j < object.length; ++j) { + theKeys.push(String(j)); + } + } else { + for (var name in object) { + if (!(skipProto && name === 'prototype') && has.call(object, name)) { + theKeys.push(String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = hasAutomationEqualityBug || equalsConstructorPrototype(object); + + for (var k = 0; k < dontEnums.length; ++k) { + if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { + theKeys.push(dontEnums[k]); + } + } + } + return theKeys; +}; + +keysShim.shim = function shimObjectKeys() { + if (!Object.keys) { + Object.keys = keysShim; + } else { + var keysWorksWithArguments = (function () { + // Safari 5.0 bug + return (Object.keys(arguments) || '').length === 2; + }(1, 2)); + if (!keysWorksWithArguments) { + var originalKeys = Object.keys; + Object.keys = function keys(object) { + if (isArgs(object)) { + return originalKeys(slice.call(object)); + } else { + return originalKeys(object); + } + }; + } + } + return Object.keys || keysShim; +}; + +module.exports = keysShim; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/isArguments.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/isArguments.js new file mode 100644 index 0000000..f2a2a90 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/isArguments.js @@ -0,0 +1,17 @@ +'use strict'; + +var toStr = Object.prototype.toString; + +module.exports = function isArguments(value) { + var str = toStr.call(value); + var isArgs = str === '[object Arguments]'; + if (!isArgs) { + isArgs = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value.callee) === '[object Function]'; + } + return isArgs; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/package.json new file mode 100644 index 0000000..6bbf914 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/node_modules/object-keys/package.json @@ -0,0 +1,89 @@ +{ + "name": "object-keys", + "version": "1.0.6", + "author": { + "name": "Jordan Harband" + }, + "description": "An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node test/index.js && npm run security", + "coverage": "covert test/*.js", + "coverage-quiet": "covert test/*.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test/*.js *.js", + "eslint": "eslint test/*.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/object-keys.git" + }, + "keywords": [ + "Object.keys", + "keys", + "ES5", + "shim" + ], + "dependencies": {}, + "devDependencies": { + "foreach": "^2.0.5", + "is": "^3.0.1", + "tape": "^4.0.0", + "indexof": "^0.0.1", + "covert": "^1.1.0", + "jscs": "^1.13.1", + "editorconfig-tools": "^0.1.1", + "nsp": "^1.0.3", + "eslint": "^0.24.0" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "3b0fbe74b40b5d78661461339f09a82f45a0a345", + "bugs": { + "url": "https://github.com/ljharb/object-keys/issues" + }, + "homepage": "https://github.com/ljharb/object-keys#readme", + "_id": "object-keys@1.0.6", + "_shasum": "f910c99bb3f57d8ba29b6580e1508eb0ebbfc177", + "_from": "object-keys@>=1.0.4 <2.0.0", + "_npmVersion": "2.11.3", + "_nodeVersion": "2.3.3", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "dist": { + "shasum": "f910c99bb3f57d8ba29b6580e1508eb0ebbfc177", + "tarball": "http://registry.npmjs.org/object-keys/-/object-keys-1.0.6.tgz" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.6.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/package.json new file mode 100644 index 0000000..60a6667 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/define-properties/package.json @@ -0,0 +1,92 @@ +{ + "name": "define-properties", + "version": "1.1.0", + "author": { + "name": "Jordan Harband" + }, + "description": "Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node test/index.js && npm run security", + "coverage": "covert test/*.js", + "coverage-quiet": "covert test/*.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test/*.js *.js", + "eslint": "eslint test/*.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/define-properties.git" + }, + "keywords": [ + "Object.defineProperty", + "Object.defineProperties", + "object", + "property descriptor", + "descriptor", + "define", + "ES5" + ], + "dependencies": { + "foreach": "^2.0.5", + "object-keys": "^1.0.4" + }, + "devDependencies": { + "tape": "^4.0.0", + "covert": "^1.1.0", + "jscs": "^1.13.1", + "editorconfig-tools": "^0.1.1", + "nsp": "^1.0.3", + "eslint": "^0.24.0" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "0855002376afdcbc6c6c5d56cdb207cc69231535", + "bugs": { + "url": "https://github.com/ljharb/define-properties/issues" + }, + "homepage": "https://github.com/ljharb/define-properties#readme", + "_id": "define-properties@1.1.0", + "_shasum": "e445de572ba03584e707e6e7fa7757bcb61e2688", + "_from": "define-properties@>=1.0.1 <2.0.0", + "_npmVersion": "2.11.1", + "_nodeVersion": "2.3.0", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "dist": { + "shasum": "e445de572ba03584e707e6e7fa7757bcb61e2688", + "tarball": "http://registry.npmjs.org/define-properties/-/define-properties-1.1.0.tgz" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.editorconfig new file mode 100644 index 0000000..eaa2141 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.eslintrc new file mode 100644 index 0000000..04d4ac0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.eslintrc @@ -0,0 +1,165 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [0, "declaration"], + "generator-star-spacing": [2, "after"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [0], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-throw-literal": [2], + "no-trailing-spaces": [2], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "one-var": [0], + "operator-assignment": [0, "always"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-parentheses": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.jscs.json new file mode 100644 index 0000000..496777b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.jscs.json @@ -0,0 +1,68 @@ +{ + "additionalRules": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + } +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.travis.yml new file mode 100644 index 0000000..5f8fa67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/.travis.yml @@ -0,0 +1,28 @@ +language: node_js +node_js: + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] && npm install -g npm@~1.3.0 || npm install -g npm' +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.8" + - node_js: "0.6" +sudo: false diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/CHANGELOG.md new file mode 100644 index 0000000..bfe4bef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/CHANGELOG.md @@ -0,0 +1,32 @@ +1.2.1 / 2015-03-20 +================= + * Fix `isFinite` helper. + +1.2.0 / 2015-03-19 +================= + * Use `es-to-primitive` for ToPrimitive methods. + * Test on latest `io.js` versions; allow failures on all but 2 latest `node`/`io.js` versions. + +1.1.2 / 2015-03-20 +================= + * Fix isFinite helper. + +1.1.1 / 2015-03-19 +================= + * Fix isPrimitive check for functions + * Update `eslint`, `editorconfig-tools`, `semver`, `nsp` + +1.1.0 / 2015-02-17 +================= + * Add ES7 export (non-default). + * All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. + * Test on `iojs-v1.2`. + +1.0.1 / 2015-01-30 +================= + * Use `is-callable` instead of an internal function. + * Update `tape`, `jscs`, `nsp`, `eslint` + +1.0.0 / 2015-01-10 +================= + * v1.0.0 diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/LICENSE new file mode 100644 index 0000000..8c271c1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/Makefile new file mode 100644 index 0000000..959bbd4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js */*.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/README.md new file mode 100644 index 0000000..e9c7e90 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/README.md @@ -0,0 +1,44 @@ +#es-abstract [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +[![browser support][testling-svg]][testling-url] + +ECMAScript spec abstract operations. +When different versions of the spec conflict, the default export will be the latest version of the abstract operation. +All abstract operations will also be available under an `es5`/`es6`/`es7` exported property if you require a specific version. + +## Example + +```js +var ES = require('es-abstract'); +var assert = require('assert'); + +assert(ES.isCallable(function () {})); +assert(!ES.isCallable(/a/g)); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/es-abstract +[npm-version-svg]: http://vb.teelaun.ch/ljharb/es-abstract.svg +[travis-svg]: https://travis-ci.org/ljharb/es-abstract.svg +[travis-url]: https://travis-ci.org/ljharb/es-abstract +[deps-svg]: https://david-dm.org/ljharb/es-abstract.svg +[deps-url]: https://david-dm.org/ljharb/es-abstract +[dev-deps-svg]: https://david-dm.org/ljharb/es-abstract/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/es-abstract#info=devDependencies +[testling-svg]: https://ci.testling.com/ljharb/es-abstract.png +[testling-url]: https://ci.testling.com/ljharb/es-abstract +[npm-badge-png]: https://nodei.co/npm/es-abstract.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/es-abstract.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/es-abstract.svg +[downloads-url]: http://npm-stat.com/charts.html?package=es-abstract diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es5.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es5.js new file mode 100644 index 0000000..eeea00a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es5.js @@ -0,0 +1,64 @@ +'use strict'; + +var $isNaN = Number.isNaN || function (a) { return a !== a; }; +var $isFinite = require('./helpers/isFinite'); + +var sign = require('./helpers/sign'); +var mod = require('./helpers/mod'); + +var IsCallable = require('is-callable'); +var toPrimitive = require('es-to-primitive/es5'); + +// https://es5.github.io/#x9 +var ES5 = { + ToPrimitive: toPrimitive, + + ToBoolean: function ToBoolean(value) { + return Boolean(value); + }, + ToNumber: function ToNumber(value) { + return Number(value); + }, + ToInteger: function ToInteger(value) { + var number = this.ToNumber(value); + if ($isNaN(number)) { return 0; } + if (number === 0 || !$isFinite(number)) { return number; } + return sign(number) * Math.floor(Math.abs(number)); + }, + ToInt32: function ToInt32(x) { + return this.ToNumber(x) >> 0; + }, + ToUint32: function ToUint32(x) { + return this.ToNumber(x) >>> 0; + }, + ToUint16: function ToUint16(value) { + var number = this.ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = sign(number) * Math.floor(Math.abs(number)); + return mod(posInt, 0x10000); + }, + ToString: function ToString(value) { + return String(value); + }, + ToObject: function ToObject(value) { + this.CheckObjectCoercible(value); + return Object(value); + }, + CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) { + /* jshint eqnull:true */ + if (value == null) { + throw new TypeError(optMessage || 'Cannot call method on ' + value); + } + }, + IsCallable: IsCallable, + SameValue: function SameValue(x, y) { + if (x === y) { + // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); + } +}; + +module.exports = ES5; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es6.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es6.js new file mode 100644 index 0000000..9ea47f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es6.js @@ -0,0 +1,181 @@ +'use strict'; + +var toStr = Object.prototype.toString; +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; +var symbolToStr = hasSymbols ? Symbol.prototype.toString : toStr; + +var $isNaN = Number.isNaN || function (a) { return a !== a; }; +var $isFinite = require('./helpers/isFinite'); +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; + +var assign = require('./helpers/assign'); +var sign = require('./helpers/sign'); +var mod = require('./helpers/mod'); +var isPrimitive = require('./helpers/isPrimitive'); +var toPrimitive = require('es-to-primitive/es6'); + +var ES5 = require('./es5'); + +// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-operations +var ES6 = assign(assign({}, ES5), { + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args + Call: function Call(F, V) { + var args = arguments.length > 2 ? arguments[2] : []; + if (!this.IsCallable(F)) { + throw new TypeError(F + ' is not a function'); + } + return F.apply(V, args); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive + ToPrimitive: toPrimitive, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toboolean + // ToBoolean: ES5.ToBoolean, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tonumber + ToNumber: function ToNumber(argument) { + if (typeof argument === 'symbol') { + throw new TypeError('Cannot convert a Symbol value to a number'); + } + return Number(argument); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tointeger + // ToInteger: ES5.ToNumber, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint32 + // ToInt32: ES5.ToInt32, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint32 + // ToUint32: ES5.ToUint32, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint16 + ToInt16: function ToInt16(argument) { + var int16bit = this.ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint16 + // ToUint16: ES5.ToUint16, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toint8 + ToInt8: function ToInt8(argument) { + var int8bit = this.ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8 + ToUint8: function ToUint8(argument) { + var number = this.ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = sign(number) * Math.floor(Math.abs(number)); + return mod(posInt, 0x100); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-touint8clamp + ToUint8Clamp: function ToUint8Clamp(argument) { + var number = this.ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = Math.floor(argument); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tostring + ToString: function ToString(argument) { + if (typeof argument === 'symbol') { + throw new TypeError('Cannot convert a Symbol value to a string'); + } + return String(argument); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toobject + ToObject: function ToObject(value) { + this.RequireObjectCoercible(value); + return Object(value); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey + ToPropertyKey: function ToPropertyKey(argument) { + var key = this.ToPrimitive(argument, String); + return typeof key === 'symbol' ? symbolToStr.call(key) : this.ToString(key); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + ToLength: function ToLength(argument) { + var len = this.ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-canonicalnumericindexstring + CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) { + if (toStr.call(argument) !== '[object String]') { + throw new TypeError('must be a string'); + } + if (argument === '-0') { return -0; } + var n = this.ToNumber(argument); + if (this.SameValue(this.ToString(n), argument)) { return n; } + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-requireobjectcoercible + RequireObjectCoercible: ES5.CheckObjectCoercible, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray + IsArray: Array.isArray || function IsArray(argument) { + return toStr.call(argument) === '[object Array]'; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iscallable + // IsCallable: ES5.IsCallable, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor + IsConstructor: function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` + return this.IsCallable(argument); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o + IsExtensible: function IsExtensible(obj) { + if (!Object.preventExtensions) { return true; } + if (isPrimitive(obj)) { + return false; + } + return Object.isExtensible(obj); + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger + IsInteger: function IsInteger(argument) { + if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { + return false; + } + var abs = Math.abs(argument); + return Math.floor(abs) === abs; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ispropertykey + IsPropertyKey: function IsPropertyKey(argument) { + return typeof argument === 'string' || typeof argument === 'symbol'; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isregexp + IsRegExp: function IsRegExp(argument) { + return toStr.call(argument) === '[object RegExp]'; + }, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue + // SameValue: ES5.SameValue, + + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero + SameValueZero: function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); + } +}); + +delete ES6.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible +module.exports = ES6; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es7.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es7.js new file mode 100644 index 0000000..cf86081 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/es7.js @@ -0,0 +1,6 @@ +var ES6 = require('./es6'); +var assign = require('./helpers/assign'); + +var ES7 = assign(ES6, {}); + +module.exports = ES7; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/assign.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/assign.js new file mode 100644 index 0000000..7a4d2a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/assign.js @@ -0,0 +1,9 @@ +var has = Object.prototype.hasOwnProperty; +module.exports = Object.assign || function assign(target, source) { + for (var key in source) { + if (has.call(source, key)) { + target[key] = source[key]; + } + } + return target; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isFinite.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isFinite.js new file mode 100644 index 0000000..4658537 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isFinite.js @@ -0,0 +1,3 @@ +var $isNaN = Number.isNaN || function (a) { return a !== a; }; + +module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isPrimitive.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isPrimitive.js new file mode 100644 index 0000000..3669156 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/isPrimitive.js @@ -0,0 +1,3 @@ +module.exports = function isPrimitive(value) { + return value === null || (typeof value !== 'function' && typeof value !== 'object'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/mod.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/mod.js new file mode 100644 index 0000000..5867fd9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/mod.js @@ -0,0 +1,4 @@ +module.exports = function mod(number, modulo) { + var remain = number % modulo; + return Math.floor(remain >= 0 ? remain : remain + modulo); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/sign.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/sign.js new file mode 100644 index 0000000..2ac0bf1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/helpers/sign.js @@ -0,0 +1,3 @@ +module.exports = function sign(number) { + return number >= 0 ? 1 : -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/index.js new file mode 100644 index 0000000..bf4265b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/index.js @@ -0,0 +1,18 @@ +'use strict'; + +var assign = require('./helpers/assign'); + +var ES5 = require('./es5'); +var ES6 = require('./es6'); +var ES7 = require('./es7'); + +var ES = { + ES5: ES5, + ES6: ES6, + ES7: ES7 +}; +assign(ES, ES5); +delete ES.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible +assign(ES, ES6); + +module.exports = ES; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.eslintrc new file mode 100644 index 0000000..07fbbaa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.eslintrc @@ -0,0 +1,165 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-dangle": [2, "never"], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [0, "declaration"], + "generator-star-spacing": [2, "after"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [2], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-throw-literal": [2], + "no-trailing-spaces": [2], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "one-var": [0], + "operator-assignment": [0, "always"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "semi-spacing": [2, { "before": false, "after": true }], + "sort-vars": [0], + "space-after-keywords": [2, "always"], + "space-before-function-parentheses": [2, { "anonymous": "always", "named": "never" }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.jscs.json new file mode 100644 index 0000000..496777b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.jscs.json @@ -0,0 +1,68 @@ +{ + "additionalRules": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + } +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.npmignore new file mode 100644 index 0000000..59d842b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.npmignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.travis.yml new file mode 100644 index 0000000..095dff5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/.travis.yml @@ -0,0 +1,30 @@ +language: node_js +node_js: + - "iojs-v1.5" + - "iojs-v1.4" + - "iojs-v1.3" + - "iojs-v1.2" + - "iojs-v1.1" + - "iojs-v1.0" + - "0.12" + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] || npm install -g npm@~1.4.6' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "iojs-v1.3" + - node_js: "iojs-v1.2" + - node_js: "iojs-v1.1" + - node_js: "iojs-v1.0" + - node_js: "0.11" + - node_js: "0.8" + - node_js: "0.9" + - node_js: "0.6" + - node_js: "0.4" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/CHANGELOG.md new file mode 100644 index 0000000..8e9f8eb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/CHANGELOG.md @@ -0,0 +1,3 @@ +1.0.0 / 2015-03-19 +================= + * Initial release. diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/LICENSE new file mode 100644 index 0000000..b43df44 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/Makefile new file mode 100644 index 0000000..b9e4fe1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/README.md new file mode 100644 index 0000000..faae393 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/README.md @@ -0,0 +1,53 @@ +# es-to-primitive [![Version Badge][npm-version-svg]][package-url] + +[![Build Status][travis-svg]][travis-url] +[![dependency status][deps-svg]][deps-url] +[![dev dependency status][dev-deps-svg]][dev-deps-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][npm-badge-png]][package-url] + +[![browser support][testling-svg]][testling-url] + +ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES6 versions. +When different versions of the spec conflict, the default export will be the latest version of the abstract operation. +Alternative versions will also be available under an `es5`/`es6`/`es7` exported property if you require a specific version. + +## Example + +```js +var toPrimitive = require('es-to-primitive'); +var assert = require('assert'); + +assert(toPrimitive(function () {}) === String(function () {})); + +var date = new Date(); +assert(toPrimitive(date) === String(date)); + +assert(toPrimitive({ valueOf: function () { return 3; } }) === 3); + +assert(toPrimitive(['a', 'b', 3]) === String(['a', 'b', 3])); + +var sym = Symbol(); +assert(toPrimitive(Object(sym)) === sym); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[package-url]: https://npmjs.org/package/es-to-primitive +[npm-version-svg]: http://vb.teelaun.ch/ljharb/es-to-primitive.svg +[travis-svg]: https://travis-ci.org/ljharb/es-to-primitive.svg +[travis-url]: https://travis-ci.org/ljharb/es-to-primitive +[deps-svg]: https://david-dm.org/ljharb/es-to-primitive.svg +[deps-url]: https://david-dm.org/ljharb/es-to-primitive +[dev-deps-svg]: https://david-dm.org/ljharb/es-to-primitive/dev-status.svg +[dev-deps-url]: https://david-dm.org/ljharb/es-to-primitive#info=devDependencies +[testling-svg]: https://ci.testling.com/ljharb/es-to-primitive.png +[testling-url]: https://ci.testling.com/ljharb/es-to-primitive +[npm-badge-png]: https://nodei.co/npm/es-to-primitive.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/es-to-primitive.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/es-to-primitive.svg +[downloads-url]: http://npm-stat.com/charts.html?package=es-to-primitive diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es5.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es5.js new file mode 100644 index 0000000..d387993 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es5.js @@ -0,0 +1,49 @@ +'use strict'; + +var toStr = Object.prototype.toString; + +var isPrimitive = require('./helpers/isPrimitive'); + +var isCallable = require('is-callable'); + +// https://es5.github.io/#x8.12 +var ES5internalSlots = { + '[[DefaultValue]]': function (O, hint) { + if (!hint) { + hint = toStr.call(O) === '[object Date]' ? String : Number; + } + + if (hint === String || hint === Number) { + var methods = hint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + var value, i; + for (i = 0; i < methods.length; ++i) { + if (isCallable(O[methods[i]])) { + value = O[methods[i]](); + if (isPrimitive(value)) { + return value; + } + } + } + throw new TypeError('No default value'); + } + throw new TypeError('invalid [[DefaultValue]] hint supplied'); + } +}; + +// https://es5.github.io/#x9 +module.exports = function ToPrimitive(input, PreferredType) { + if (isPrimitive(input)) { + return input; + } + if (arguments.length < 2) { + PreferredType = toStr.call(input) === '[object Date]' ? String : Number; + } + if (PreferredType === String) { + return String(input); + } else if (PreferredType === Number) { + return Number(input); + } else { + throw new TypeError('invalid PreferredType supplied'); + } + return ES5internalSlots['[[DefaultValue]]'](input, PreferredType); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es6.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es6.js new file mode 100644 index 0000000..b458199 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/es6.js @@ -0,0 +1,65 @@ +'use strict'; + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + +var isPrimitive = require('./helpers/isPrimitive'); +var isCallable = require('is-callable'); +var isDate = require('is-date-object'); +var isSymbol = require('is-symbol'); + +var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) { + if (O == null) { + throw new TypeError('Cannot call method on ' + O); + } + if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) { + throw new TypeError('hint must be "string" or "number"'); + } + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + var method, result, i; + for (i = 0; i < methodNames.length; ++i) { + method = O[methodNames[i]]; + if (isCallable(method)) { + result = method.call(O); + if (isPrimitive(result)) { + return result; + } + } + } + throw new TypeError('No default value'); +}; + +// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-toprimitive +module.exports = function ToPrimitive(input, PreferredType) { + if (isPrimitive(input)) { + return input; + } + var hint = 'default'; + if (arguments.length > 1) { + if (PreferredType === String) { + hint = 'string'; + } else if (PreferredType === Number) { + hint = 'number'; + } + } + + var exoticToPrim; + if (hasSymbols) { + if (Symbol.toPrimitive) { + throw new TypeError('Symbol.toPrimitive not supported yet'); + // exoticToPrim = this.GetMethod(input, Symbol.toPrimitive); + } else if (isSymbol(input)) { + exoticToPrim = Symbol.prototype.valueOf; + } + } + if (typeof exoticToPrim !== 'undefined') { + var result = exoticToPrim.call(input, hint); + if (isPrimitive(result)) { + return result; + } + throw new TypeError('unable to convert exotic object to primitive'); + } + if (hint === 'default' && (isDate(input) || isSymbol(input))) { + hint = 'string'; + } + return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/helpers/isPrimitive.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/helpers/isPrimitive.js new file mode 100644 index 0000000..3669156 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/helpers/isPrimitive.js @@ -0,0 +1,3 @@ +module.exports = function isPrimitive(value) { + return value === null || (typeof value !== 'function' && typeof value !== 'object'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/index.js new file mode 100644 index 0000000..0035657 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/index.js @@ -0,0 +1,14 @@ +'use strict'; + +var ES5 = require('./es5'); +var ES6 = require('./es6'); + +if (Object.defineProperty) { + Object.defineProperty(ES6, 'ES5', { enumerable: false, value: ES5 }); + Object.defineProperty(ES6, 'ES6', { enumerable: false, value: ES6 }); +} else { + ES6.ES5 = ES5; + ES6.ES6 = ES6; +} + +module.exports = ES6; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.eslintrc new file mode 100644 index 0000000..9f56994 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.eslintrc @@ -0,0 +1,160 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [0, "declaration"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [2], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-comma-dangle": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-keys": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [0, {"max": 2}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-trailing-spaces": [2], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "one-var": [0], + "operator-assignment": [0, "always"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "sort-vars": [0], + "space-after-keywords": [2, "always", { "checkFunctionKeyword": true }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-after-function-name": [2, "never"], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.jscs.json new file mode 100644 index 0000000..496777b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.jscs.json @@ -0,0 +1,68 @@ +{ + "additionalRules": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + } +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.npmignore new file mode 100644 index 0000000..59d842b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.npmignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.travis.yml new file mode 100644 index 0000000..e318c1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/.travis.yml @@ -0,0 +1,18 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] || npm install -g npm@~1.4.6' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.6" + - node_js: "0.4" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/CHANGELOG.md new file mode 100644 index 0000000..d26ecc0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/CHANGELOG.md @@ -0,0 +1,3 @@ +1.0.0 / 2015-01-28 +================= + * Initial release. diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/LICENSE new file mode 100644 index 0000000..b43df44 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/Makefile new file mode 100644 index 0000000..b9e4fe1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/README.md new file mode 100644 index 0000000..321854e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/README.md @@ -0,0 +1,53 @@ +# is-date-object [![Version Badge][2]][1] + +[![Build Status][3]][4] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +[![browser support][9]][10] + +Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag. + +## Example + +```js +var isDate = require('is-date-object'); +var assert = require('assert'); + +assert.notOk(isDate(undefined)); +assert.notOk(isDate(null)); +assert.notOk(isDate(false)); +assert.notOk(isDate(true)); +assert.notOk(isDate(42)); +assert.notOk(isDate('foo')); +assert.notOk(isDate(function () {})); +assert.notOk(isDate([])); +assert.notOk(isDate({})); +assert.notOk(isDate(/a/g)); +assert.notOk(isDate(new RegExp('a', 'g'))); + +assert.ok(isDate(new Date())); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-date-object +[2]: http://vb.teelaun.ch/ljharb/is-date-object.svg +[3]: https://travis-ci.org/ljharb/is-date-object.svg +[4]: https://travis-ci.org/ljharb/is-date-object +[5]: https://david-dm.org/ljharb/is-date-object.svg +[6]: https://david-dm.org/ljharb/is-date-object +[7]: https://david-dm.org/ljharb/is-date-object/dev-status.svg +[8]: https://david-dm.org/ljharb/is-date-object#info=devDependencies +[9]: https://ci.testling.com/ljharb/is-date-object.png +[10]: https://ci.testling.com/ljharb/is-date-object +[11]: https://nodei.co/npm/is-date-object.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/is-date-object.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/is-date-object.svg +[downloads-url]: http://npm-stat.com/charts.html?package=is-date-object diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/index.js new file mode 100644 index 0000000..1f3ee87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var getDay = Date.prototype.getDay; + +module.exports = function isDateObject(value) { + try { + getDay.call(value); + return true; + } catch (e) { + return false; + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/package.json new file mode 100644 index 0000000..ce9f05e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/package.json @@ -0,0 +1,92 @@ +{ + "name": "is-date-object", + "version": "1.0.0", + "author": { + "name": "Jordan Harband" + }, + "description": "Is this value a JS Date object? This module works cross-realm/iframe, and despite ES6 @@toStringTag.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node --harmony --es-staging test.js && npm run security", + "coverage": "covert test.js", + "coverage-quiet": "covert test.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test.js *.js", + "eslint": "eslint test.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/is-date-object.git" + }, + "keywords": [ + "Date", + "ES6", + "toStringTag", + "@@toStringTag", + "Date object" + ], + "dependencies": {}, + "devDependencies": { + "foreach": "~2.0.5", + "is": "~2.2.0", + "tape": "~3.4.0", + "indexof": "~0.0.1", + "covert": "1.0.0", + "jscs": "~1.10.0", + "editorconfig-tools": "~0.0.1", + "nsp": "~1.0.0", + "eslint": "~0.12.0", + "semver": "~4.2.0" + }, + "testling": { + "files": "test.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "8442bb71a894289ac2ff31b4abe65488fb63bb3a", + "bugs": { + "url": "https://github.com/ljharb/is-date-object/issues" + }, + "homepage": "https://github.com/ljharb/is-date-object", + "_id": "is-date-object@1.0.0", + "_shasum": "0510d9e2831904c731b69b54a6fdc41a1b48bc17", + "_from": "is-date-object@>=1.0.0 <2.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "1.0.4", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "dist": { + "shasum": "0510d9e2831904c731b69b54a6fdc41a1b48bc17", + "tarball": "http://registry.npmjs.org/is-date-object/-/is-date-object-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/test.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/test.js new file mode 100644 index 0000000..1268972 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-date-object/test.js @@ -0,0 +1,33 @@ +'use strict'; + +var test = require('tape'); +var isDate = require('./'); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; + +test('not Dates', function (t) { + t.notOk(isDate(), 'undefined is not Date'); + t.notOk(isDate(null), 'null is not Date'); + t.notOk(isDate(false), 'false is not Date'); + t.notOk(isDate(true), 'true is not Date'); + t.notOk(isDate(42), 'number is not Date'); + t.notOk(isDate('foo'), 'string is not Date'); + t.notOk(isDate([]), 'array is not Date'); + t.notOk(isDate({}), 'object is not Date'); + t.notOk(isDate(function () {}), 'function is not Date'); + t.notOk(isDate(/a/g), 'regex literal is not Date'); + t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date'); + t.end(); +}); + +test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) { + var realDate = new Date(); + var fakeDate = { valueOf: function () { return realDate.getTime(); }, toString: function () { return String(realDate); } }; + fakeDate[Symbol.toStringTag] = function () { return 'Date'; }; + t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date'); + t.end(); +}); + +test('Dates', function (t) { + t.ok(isDate(new Date()), 'new Date() is Date'); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.editorconfig new file mode 100644 index 0000000..eaa2141 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = tab; +insert_final_newline = true; +quote_type = auto; +space_after_anonymous_functions = true; +space_after_control_statements = true; +spaces_around_operators = true; +trim_trailing_whitespace = true; +spaces_in_brackets = false; +end_of_line = lf; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.eslintrc new file mode 100644 index 0000000..9f56994 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.eslintrc @@ -0,0 +1,160 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [0, "declaration"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [2], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-comma-dangle": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-keys": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [0, {"max": 2}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-trailing-spaces": [2], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "one-var": [0], + "operator-assignment": [0, "always"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "sort-vars": [0], + "space-after-keywords": [2, "always", { "checkFunctionKeyword": true }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-after-function-name": [2, "never"], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.jscs.json new file mode 100644 index 0000000..496777b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.jscs.json @@ -0,0 +1,68 @@ +{ + "additionalRules": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + } +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.npmignore new file mode 100644 index 0000000..59d842b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.npmignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.nvmrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.nvmrc new file mode 100644 index 0000000..c9c594c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.nvmrc @@ -0,0 +1 @@ +iojs diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.travis.yml new file mode 100644 index 0000000..c80407f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/.travis.yml @@ -0,0 +1,18 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] || npm install -g npm@1.4.6' +matrix: + fast_finish: true + allow_failures: + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.6" + - node_js: "0.4" + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/CHANGELOG.md new file mode 100644 index 0000000..e1a62a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/CHANGELOG.md @@ -0,0 +1,7 @@ +1.0.1 / 2015-01-26 +================= + * Corrected description + +1.0.0 / 2015-01-24 +================= + * Initial release diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/LICENSE new file mode 100644 index 0000000..b43df44 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/Makefile new file mode 100644 index 0000000..b9e4fe1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/README.md new file mode 100644 index 0000000..ad3df64 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/README.md @@ -0,0 +1,46 @@ +#is-symbol [![Version Badge][2]][1] + +[![Build Status][3]][4] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +[![browser support][9]][10] + +Is this an ES6 Symbol value? + +## Example + +```js +var isSymbol = require('is-symbol'); +assert(!isSymbol(function () {})); +assert(!isSymbol(null)); +assert(!isSymbol(function* () { yield 42; return Infinity; }); + +assert(isSymbol(Symbol.iterator)); +assert(isSymbol(Symbol('foo'))); +assert(isSymbol(Symbol.for('foo'))); +assert(isSymbol(Object(Symbol('foo')))); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-symbol +[2]: http://vb.teelaun.ch/ljharb/is-symbol.svg +[3]: https://travis-ci.org/ljharb/is-symbol.svg +[4]: https://travis-ci.org/ljharb/is-symbol +[5]: https://david-dm.org/ljharb/is-symbol.svg +[6]: https://david-dm.org/ljharb/is-symbol +[7]: https://david-dm.org/ljharb/is-symbol/dev-status.svg +[8]: https://david-dm.org/ljharb/is-symbol#info=devDependencies +[9]: https://ci.testling.com/ljharb/is-symbol.png +[10]: https://ci.testling.com/ljharb/is-symbol +[11]: https://nodei.co/npm/is-symbol.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/is-symbol.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/is-symbol.svg +[downloads-url]: http://npm-stat.com/charts.html?package=is-symbol diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/index.js new file mode 100644 index 0000000..a938cbf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/index.js @@ -0,0 +1,27 @@ +'use strict'; + +var toStr = Object.prototype.toString; +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; + +if (hasSymbols) { + var symToStr = Symbol.prototype.toString; + var symStringRegex = /^Symbol\(.*\)$/; + var isSymbolObject = function isSymbolObject(value) { + if (typeof value.valueOf() !== 'symbol') { return false; } + return symStringRegex.test(symToStr.call(value)); + }; + module.exports = function isSymbol(value) { + if (typeof value === 'symbol') { return true; } + if (toStr.call(value) !== '[object Symbol]') { return false; } + try { + return isSymbolObject(value); + } catch (e) { + return false; + } + }; +} else { + module.exports = function isSymbol(value) { + // this environment does not support Symbols. + return false; + }; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/package.json new file mode 100644 index 0000000..0efe762 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/package.json @@ -0,0 +1,82 @@ +{ + "name": "is-symbol", + "version": "1.0.1", + "description": "Determine if a value is an ES6 Symbol or not.", + "main": "index.js", + "scripts": { + "test": "npm run lint && node --es-staging --harmony test/index.js && npm run security", + "coverage": "covert test/index.js", + "coverage:quiet": "covert test/index.js --quiet", + "lint": "jscs *.js */*.js", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/is-symbol.git" + }, + "keywords": [ + "symbol", + "es6", + "is", + "Symbol" + ], + "author": { + "name": "Jordan Harband" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/ljharb/is-symbol/issues" + }, + "dependencies": {}, + "devDependencies": { + "tape": "~3.4.0", + "covert": "1.0.0", + "jscs": "~1.10.0", + "nsp": "~1.0.0", + "semver": "~4.2.0" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "5bbd991ff41a459a941d205de65d533cc6c3cd8c", + "homepage": "https://github.com/ljharb/is-symbol", + "_id": "is-symbol@1.0.1", + "_shasum": "3cc59f00025194b6ab2e38dbae6689256b660572", + "_from": "is-symbol@>=1.0.1 <2.0.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "dist": { + "shasum": "3cc59f00025194b6ab2e38dbae6689256b660572", + "tarball": "http://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/test/index.js new file mode 100644 index 0000000..697a7b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/node_modules/is-symbol/test/index.js @@ -0,0 +1,106 @@ +'use strict'; + +var test = require('tape'); +var isSymbol = require('../index'); + +var forEach = function (arr, func) { + var i; + for (i = 0; i < arr.length; ++i) { + func(arr[i], i, arr); + } +}; + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; +var debug = function (value, msg) { + var output = ''; + if (hasSymbols) { + try { output += String(value); } + catch (e) { output += Symbol.prototype.toString.call(value); } + if (output === '') { + output = JSON.stringify(value); + } + } + var type = Object.prototype.toString.call(value).toLowerCase().slice(8, -1); + output += ' (' + type; + var typeOf = typeof value; + if (type !== typeOf) { + output += ', typeof: ' + typeOf; + } + return output + ') ' + msg; +}; + +test('non-symbol values', function (t) { + var nonSymbols = [ + true, + false, + Object(true), + Object(false), + null, + undefined, + {}, + [], + /a/g, + 'string', + 42, + new Date(), + function () {}, + NaN + ]; + t.plan(nonSymbols.length); + forEach(nonSymbols, function (nonSymbol) { + t.equal(false, isSymbol(nonSymbol), debug(nonSymbol, 'is not a symbol')); + }); + t.end(); +}); + +test('faked symbol values', function (t) { + t.test('real symbol valueOf', { skip: !hasSymbols }, function (st) { + var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; + st.equal(false, isSymbol(fakeSymbol), 'object with valueOf returning a symbol is not a symbol'); + st.end(); + }); + + t.test('faked @@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (st) { + var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; + fakeSymbol[Symbol.toStringTag] = 'Symbol'; + st.equal(false, isSymbol(fakeSymbol), 'object with fake Symbol @@toStringTag and valueOf returning a symbol is not a symbol'); + var notSoFakeSymbol = { valueOf: function () { return 42; } }; + notSoFakeSymbol[Symbol.toStringTag] = 'Symbol'; + st.equal(false, isSymbol(notSoFakeSymbol), 'object with fake Symbol @@toStringTag and valueOf not returning a symbol is not a symbol'); + st.end(); + }); + + var fakeSymbolString = { toString: function () { return 'Symbol(foo)'; } }; + t.equal(false, isSymbol(fakeSymbolString), 'object with toString returning Symbol(foo) is not a symbol'); + + t.end(); +}); + +test('Symbol support', { skip: !hasSymbols }, function (t) { + t.test('well-known Symbols', function (st) { + var wellKnownSymbols = Object.getOwnPropertyNames(Symbol).filter(function filterer(name) { + return name !== 'for' && name !== 'keyFor' && !(name in filterer); + }); + wellKnownSymbols.forEach(function (name) { + var sym = Symbol[name]; + st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); + }); + st.end(); + }); + + t.test('user-created symbols', function (st) { + var symbols = [ + Symbol(), + Symbol('foo'), + Symbol.for('foo'), + Object(Symbol('object')) + ]; + symbols.forEach(function (sym) { + st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); + }); + st.end(); + }); + + t.end(); +}); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/package.json new file mode 100644 index 0000000..33f2991 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/package.json @@ -0,0 +1,102 @@ +{ + "name": "es-to-primitive", + "version": "1.0.0", + "author": { + "name": "Jordan Harband" + }, + "description": "ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES6 versions.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node --harmony --es-staging test && npm run security", + "coverage": "covert test/*.js", + "coverage-quiet": "covert test/*.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test/*.js *.js", + "eslint": "eslint test/*.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/es-to-primitive.git" + }, + "keywords": [ + "primitive", + "abstract", + "ecmascript", + "es5", + "es6", + "toPrimitive", + "coerce", + "type", + "object" + ], + "dependencies": { + "is-callable": "^1.0.4", + "is-date-object": "^1.0.0", + "is-symbol": "^1.0.1" + }, + "devDependencies": { + "tape": "^3.5.0", + "covert": "^1.0.1", + "object-is": "^1.0.1", + "foreach": "^2.0.5", + "jscs": "^1.11.3", + "editorconfig-tools": "^0.1.1", + "nsp": "^1.0.1", + "eslint": "^0.17.0", + "make-arrow-function": "^1.0.0", + "make-generator-function": "^1.1.0", + "replace": "^0.3.0", + "semver": "^4.3.1" + }, + "testling": { + "files": "test.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "cf3f44b793aaa5c340e1da4b49d37fb5f2dd413d", + "bugs": { + "url": "https://github.com/ljharb/es-to-primitive/issues" + }, + "homepage": "https://github.com/ljharb/es-to-primitive", + "_id": "es-to-primitive@1.0.0", + "_shasum": "469bea3a1b3b41f2e2af0a8c9c8c75a1ac8d517f", + "_from": "es-to-primitive@>=1.0.0 <2.0.0", + "_npmVersion": "2.7.2", + "_nodeVersion": "1.5.1", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "dist": { + "shasum": "469bea3a1b3b41f2e2af0a8c9c8c75a1ac8d517f", + "tarball": "http://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.0.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es5.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es5.js new file mode 100644 index 0000000..0c36f60 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es5.js @@ -0,0 +1,74 @@ +var test = require('tape'); +var toPrimitive = require('../es5'); +var is = require('object-is'); +var forEach = require('foreach'); +var debug = require('util').inspect; + +var primitives = [null, undefined, true, false, 0, -0, 42, NaN, Infinity, -Infinity, '', 'abc']; + +test('primitives', function (t) { + forEach(primitives, function (i) { + t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value'); + t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value'); + t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value'); + }); + t.end(); +}); + +test('Arrays', function (t) { + var arrays = [[], ['a', 'b'], [1, 2]]; + forEach(arrays, function (arr) { + t.ok(is(toPrimitive(arr), Number(arr)), 'toPrimitive(' + debug(arr) + ') returns the number version of the array'); + t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.ok(is(toPrimitive(arr, Number), Number(arr)), 'toPrimitive(' + debug(arr) + ') returns the number version of the array'); + }); + t.end(); +}); + +test('Dates', function (t) { + var dates = [new Date(), new Date(0), new Date(NaN)]; + forEach(dates, function (date) { + t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date'); + }); + t.end(); +}); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var coercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return 42; } }; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return function toStrFn() {}; } }; + +test('Objects', function (t) { + t.equal(toPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, String), String(coercibleObject.toString()), 'coercibleObject with hint String coerces to stringified toString'); + t.equal(toPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); + + t.equal(toPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, String), String(coercibleFnObject.toString()), 'coercibleFnObject with hint String coerces to stringified toString'); + t.equal(toPrimitive(coercibleFnObject, Number), coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString'); + + t.ok(is(toPrimitive({}), NaN), '{} with no hint coerces to NaN'); + t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + t.ok(is(toPrimitive({}, Number), NaN), '{} with hint Number coerces to NaN'); + + t.equal(toPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, String), String(toStringOnlyObject.toString()), 'toStringOnlyObject with hint String returns stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, Number), toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString'); + + t.equal(toPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, String), String(valueOfOnlyObject.valueOf()), 'valueOfOnlyObject with hint String returns stringified valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, Number), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf'); + + t.throws(function () { return toPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleObject, String); }, TypeError, 'uncoercibleObject with hint String throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleObject, Number); }, TypeError, 'uncoercibleObject with hint Number throws a TypeError'); + + t.throws(function () { return toPrimitive(uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleFnObject, String); }, TypeError, 'uncoercibleFnObject with hint String throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleFnObject, Number); }, TypeError, 'uncoercibleFnObject with hint Number throws a TypeError'); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es6.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es6.js new file mode 100644 index 0000000..95a0d9f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/es6.js @@ -0,0 +1,92 @@ +var test = require('tape'); +var toPrimitive = require('../es6'); +var is = require('object-is'); +var forEach = require('foreach'); +var debug = require('util').inspect; + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + +var primitives = [null, undefined, true, false, 0, -0, 42, NaN, Infinity, -Infinity, '', 'abc']; + +test('primitives', function (t) { + forEach(primitives, function (i) { + t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value'); + t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value'); + t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value'); + }); + t.end(); +}); + +test('Symbols', { skip: !hasSymbols }, function (t) { + var symbols = [Symbol(), Symbol.iterator, Symbol.for('foo')]; + forEach(symbols, function (sym) { + t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value'); + t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value'); + t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value'); + }); + + var primitiveSym = Symbol('primitiveSym'); + var objectSym = Object(primitiveSym); + t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, String), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(primitiveSym)); + t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym)); + t.end(); +}); + +test('Arrays', function (t) { + var arrays = [[], ['a', 'b'], [1, 2]]; + forEach(arrays, function (arr) { + t.equal(toPrimitive(arr), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + t.equal(toPrimitive(arr, Number), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array'); + }); + t.end(); +}); + +test('Dates', function (t) { + var dates = [new Date(), new Date(0), new Date(NaN)]; + forEach(dates, function (date) { + t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date'); + t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date'); + }); + t.end(); +}); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var coercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return 42; } }; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return function toStrFn() {}; } }; + +test('Objects', function (t) { + t.equal(toPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); + t.equal(toPrimitive(coercibleObject, String), coercibleObject.toString(), 'coercibleObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, Number), coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString'); + t.equal(toPrimitive(coercibleFnObject, String), coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to non-stringified toString'); + + t.equal(toPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString'); + t.equal(toPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString'); + t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + + t.equal(toPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, Number), toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString'); + t.equal(toPrimitive(toStringOnlyObject, String), toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns non-stringified toString'); + + t.equal(toPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, Number), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf'); + t.equal(toPrimitive(valueOfOnlyObject, String), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns non-stringified valueOf'); + + t.throws(function () { return toPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleObject, Number); }, TypeError, 'uncoercibleObject with hint Number throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleObject, String); }, TypeError, 'uncoercibleObject with hint String throws a TypeError'); + + t.throws(function () { return toPrimitive(uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleFnObject, Number); }, TypeError, 'uncoercibleFnObject with hint Number throws a TypeError'); + t.throws(function () { return toPrimitive(uncoercibleFnObject, String); }, TypeError, 'uncoercibleFnObject with hint String throws a TypeError'); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/index.js new file mode 100644 index 0000000..f1de62c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/es-to-primitive/test/index.js @@ -0,0 +1,15 @@ +var toPrimitive = require('../'); +var ES5 = require('../es5'); +var ES6 = require('../es6'); + +var test = require('tape'); + +test('default export', function (t) { + t.equal(toPrimitive, ES6, 'default export is ES6'); + t.equal(toPrimitive.ES5, ES5, 'ES5 property has ES5 method'); + t.equal(toPrimitive.ES6, ES6, 'ES6 property has ES6 method'); + t.end(); +}); + +require('./es5'); +require('./es6'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.eslintrc new file mode 100644 index 0000000..9f56994 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.eslintrc @@ -0,0 +1,160 @@ +{ + "env": { + "browser": false, + "node": true, + "amd": false, + "mocha": false, + "jasmine": false + }, + + "rules": { + "block-scoped-var": [0], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "camelcase": [2], + "comma-spacing": [2], + "comma-style": [2, "last"], + "complexity": [0, 11], + "consistent-return": [2], + "consistent-this": [0, "that"], + "curly": [2, "all"], + "default-case": [2], + "dot-notation": [2, { "allowKeywords": true }], + "eol-last": [2], + "eqeqeq": [2], + "func-names": [0], + "func-style": [0, "declaration"], + "global-strict": [0, "never"], + "guard-for-in": [0], + "handle-callback-err": [0], + "key-spacing": [2, { "beforeColon": false, "afterColon": true }], + "quotes": [2, "single", "avoid-escape"], + "max-depth": [0, 4], + "max-len": [0, 80, 4], + "max-nested-callbacks": [0, 2], + "max-params": [0, 3], + "max-statements": [0, 10], + "new-parens": [2], + "new-cap": [2], + "no-alert": [2], + "no-array-constructor": [2], + "no-bitwise": [0], + "no-caller": [2], + "no-catch-shadow": [2], + "no-comma-dangle": [2], + "no-cond-assign": [2], + "no-console": [2], + "no-constant-condition": [2], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-keys": [2], + "no-else-return": [0], + "no-empty": [2], + "no-empty-class": [2], + "no-empty-label": [2], + "no-eq-null": [0], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [2], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [0], + "no-extra-semi": [2], + "no-extra-strict": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2, "functions"], + "no-invalid-regexp": [2], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [2], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-mixed-requires": [0, false], + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": [2], + "no-multi-str": [2], + "no-multiple-empty-lines": [0, {"max": 2}], + "no-native-reassign": [2], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new": [2], + "no-new-func": [2], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-obj-calls": [2], + "no-octal": [2], + "no-octal-escape": [2], + "no-path-concat": [0], + "no-plusplus": [0], + "no-process-env": [0], + "no-process-exit": [2], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [2], + "no-reserved-keys": [2], + "no-restricted-modules": [0], + "no-return-assign": [2], + "no-script-url": [2], + "no-self-compare": [0], + "no-sequences": [2], + "no-shadow": [2], + "no-shadow-restricted-names": [2], + "no-space-before-semi": [2], + "no-spaced-func": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-trailing-spaces": [2], + "no-undef": [2], + "no-undef-init": [2], + "no-undefined": [0], + "no-underscore-dangle": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [2], + "no-void": [0], + "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], + "no-with": [2], + "no-wrap-func": [2], + "one-var": [0], + "operator-assignment": [0, "always"], + "padded-blocks": [0], + "quote-props": [0], + "radix": [0], + "semi": [2], + "sort-vars": [0], + "space-after-keywords": [2, "always", { "checkFunctionKeyword": true }], + "space-before-blocks": [0, "always"], + "space-in-brackets": [0, "never", { + "singleValue": true, + "arraysInArrays": false, + "arraysInObjects": false, + "objectsInArrays": true, + "objectsInObjects": true, + "propertyName": false + }], + "space-in-parens": [2, "never"], + "space-infix-ops": [2], + "space-return-throw-case": [2], + "space-after-function-name": [2, "never"], + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-line-comment": [0, "always"], + "strict": [0], + "use-isnan": [2], + "valid-jsdoc": [0], + "valid-typeof": [2], + "vars-on-top": [0], + "wrap-iife": [2], + "wrap-regex": [2], + "yoda": [2, "never", { "exceptRange": true }] + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.jscs.json new file mode 100644 index 0000000..496777b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.jscs.json @@ -0,0 +1,68 @@ +{ + "additionalRules": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + } +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.npmignore new file mode 100644 index 0000000..59d842b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.npmignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.travis.yml new file mode 100644 index 0000000..e318c1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/.travis.yml @@ -0,0 +1,18 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.9" + - "0.8" + - "0.6" + - "0.4" +before_install: + - '[ "${TRAVIS_NODE_VERSION}" == "0.6" ] || npm install -g npm@~1.4.6' +sudo: false +matrix: + fast_finish: true + allow_failures: + - node_js: "0.11" + - node_js: "0.9" + - node_js: "0.6" + - node_js: "0.4" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/CHANGELOG.md new file mode 100644 index 0000000..5f03bf9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/CHANGELOG.md @@ -0,0 +1,20 @@ +1.0.4 / 2015-01-30 +================= + * If @@toStringTag is not present, use the old-school Object#toString test. + +1.0.3 / 2015-01-29 +================= + * Add tests to ensure arrow functions are callable. + * Refactor to aid optimization of non-try/catch code. + +1.0.2 / 2015-01-29 +================= + * Fix broken package.json + +1.0.1 / 2015-01-29 +================= + * Add early exit for typeof not "function" + +1.0.0 / 2015-01-29 +================= + * Initial release. diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/LICENSE new file mode 100644 index 0000000..b43df44 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jordan Harband + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/Makefile b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/Makefile new file mode 100644 index 0000000..b9e4fe1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/Makefile @@ -0,0 +1,61 @@ +# Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) + + # The files that need updating when incrementing the version number. +VERSIONED_FILES := *.js *.json README* + + +# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. +# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment +# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. +export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") +UTILS := semver +# Make sure that all required utilities can be located. +UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) + +# Default target (by virtue of being the first non '.'-prefixed in the file). +.PHONY: _no-target-specified +_no-target-specified: + $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) + +# Lists all targets defined in this makefile. +.PHONY: list +list: + @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort + +# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). +.PHONY: test +test: + @npm test + +.PHONY: _ensure-tag +_ensure-tag: +ifndef TAG + $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) +endif + +CHANGELOG_ERROR = $(error No CHANGELOG specified) +.PHONY: _ensure-changelog +_ensure-changelog: + @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) + +# Ensures that the git workspace is clean. +.PHONY: _ensure-clean +_ensure-clean: + @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } + +# Makes a release; invoke with `make TAG= release`. +.PHONY: release +release: _ensure-tag _ensure-changelog _ensure-clean + @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ + new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ + if printf "$$new_ver" | command grep -q '^[0-9]'; then \ + semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ + semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ + else \ + new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ + fi; \ + printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ + replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ + git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ + git tag -a -m "v$$new_ver" "v$$new_ver" diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/README.md b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/README.md new file mode 100644 index 0000000..948538e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/README.md @@ -0,0 +1,59 @@ +# is-callable [![Version Badge][2]][1] + +[![Build Status][3]][4] +[![dependency status][5]][6] +[![dev dependency status][7]][8] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] + +[![npm badge][11]][1] + +[![browser support][9]][10] + +Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag. + +## Example + +```js +var isCallable = require('is-callable'); +var assert = require('assert'); + +assert.notOk(isCallable(undefined)); +assert.notOk(isCallable(null)); +assert.notOk(isCallable(false)); +assert.notOk(isCallable(true)); +assert.notOk(isCallable([])); +assert.notOk(isCallable({})); +assert.notOk(isCallable(/a/g)); +assert.notOk(isCallable(new RegExp('a', 'g'))); +assert.notOk(isCallable(new Date())); +assert.notOk(isCallable(42)); +assert.notOk(isCallable(NaN)); +assert.notOk(isCallable(Infinity)); +assert.notOk(isCallable(new Number(42))); +assert.notOk(isCallable('foo')); +assert.notOk(isCallable(Object('foo'))); + +assert.ok(isCallable(function () {})); +assert.ok(isCallable(function* () {})); +assert.ok(isCallable(x => x * x)); +``` + +## Tests +Simply clone the repo, `npm install`, and run `npm test` + +[1]: https://npmjs.org/package/is-callable +[2]: http://vb.teelaun.ch/ljharb/is-callable.svg +[3]: https://travis-ci.org/ljharb/is-callable.svg +[4]: https://travis-ci.org/ljharb/is-callable +[5]: https://david-dm.org/ljharb/is-callable.svg +[6]: https://david-dm.org/ljharb/is-callable +[7]: https://david-dm.org/ljharb/is-callable/dev-status.svg +[8]: https://david-dm.org/ljharb/is-callable#info=devDependencies +[9]: https://ci.testling.com/ljharb/is-callable.png +[10]: https://ci.testling.com/ljharb/is-callable +[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true +[license-image]: http://img.shields.io/npm/l/is-callable.svg +[license-url]: LICENSE +[downloads-image]: http://img.shields.io/npm/dm/is-callable.svg +[downloads-url]: http://npm-stat.com/charts.html?package=is-callable diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/index.js new file mode 100644 index 0000000..a083cc2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/index.js @@ -0,0 +1,22 @@ +'use strict'; + +var fnToStr = Function.prototype.toString; +var tryFunctionObject = function tryFunctionObject(value) { + try { + fnToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var fnClass = '[object Function]'; +var genClass = '[object GeneratorFunction]'; +var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + +module.exports = function isCallable(value) { + if (typeof value !== 'function') { return false; } + if (hasToStringTag) { return tryFunctionObject(value); } + var strClass = toStr.call(value); + return strClass === fnClass || strClass === genClass; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/package.json new file mode 100644 index 0000000..ebd36f2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/package.json @@ -0,0 +1,99 @@ +{ + "name": "is-callable", + "version": "1.0.4", + "author": { + "name": "Jordan Harband" + }, + "description": "Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node --harmony --es-staging test.js && npm run security", + "coverage": "covert test.js", + "coverage-quiet": "covert test.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test.js *.js", + "eslint": "eslint test.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/is-callable.git" + }, + "keywords": [ + "Function", + "function", + "callable", + "generator", + "generator function", + "arrow", + "arrow function", + "ES6", + "toStringTag", + "@@toStringTag" + ], + "dependencies": {}, + "devDependencies": { + "foreach": "~2.0.5", + "is": "~2.2.0", + "tape": "~3.4.0", + "indexof": "~0.0.1", + "covert": "1.0.0", + "jscs": "~1.10.0", + "editorconfig-tools": "~0.0.1", + "nsp": "~1.0.0", + "eslint": "~0.13.0", + "make-arrow-function": "~1.0.0", + "make-generator-function": "~1.0.0", + "semver": "~4.2.0" + }, + "testling": { + "files": "test.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "3df78871c38ba41060df04bab7d3bd4cea81320a", + "bugs": { + "url": "https://github.com/ljharb/is-callable/issues" + }, + "homepage": "https://github.com/ljharb/is-callable", + "_id": "is-callable@1.0.4", + "_shasum": "63cb2155460fd30501fec1d710bd6612c46c34ad", + "_from": "is-callable@>=1.0.4 <2.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "1.0.4", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "dist": { + "shasum": "63cb2155460fd30501fec1d710bd6612c46c34ad", + "tarball": "http://registry.npmjs.org/is-callable/-/is-callable-1.0.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.0.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/test.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/test.js new file mode 100644 index 0000000..61750a9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/node_modules/is-callable/test.js @@ -0,0 +1,50 @@ +'use strict'; + +var test = require('tape'); +var isCallable = require('./'); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; +var genFn = require('make-generator-function'); +var arrowFn = require('make-arrow-function')(); + +test('not callables', function (t) { + t.notOk(isCallable(), 'undefined is not callable'); + t.notOk(isCallable(null), 'null is not callable'); + t.notOk(isCallable(false), 'false is not callable'); + t.notOk(isCallable(true), 'true is not callable'); + t.notOk(isCallable([]), 'array is not callable'); + t.notOk(isCallable({}), 'object is not callable'); + t.notOk(isCallable(/a/g), 'regex literal is not callable'); + t.notOk(isCallable(new RegExp('a', 'g')), 'regex object is not callable'); + t.notOk(isCallable(new Date()), 'new Date() is not callable'); + t.notOk(isCallable(42), 'number is not callable'); + t.notOk(isCallable(Object(42)), 'number object is not callable'); + t.notOk(isCallable(NaN), 'NaN is not callable'); + t.notOk(isCallable(Infinity), 'Infinity is not callable'); + t.notOk(isCallable('foo'), 'string primitive is not callable'); + t.notOk(isCallable(Object('foo')), 'string object is not callable'); + t.end(); +}); + +test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) { + var fn = function () { return 3; }; + var fakeFunction = { valueOf: function () { return fn; }, toString: function () { return String(fn); } }; + fakeFunction[Symbol.toStringTag] = function () { return 'Function'; }; + t.notOk(isCallable(fakeFunction), 'fake Function with @@toStringTag "Function" is not callable'); + t.end(); +}); + +test('Functions', function (t) { + t.ok(isCallable(function () {}), 'function is callable'); + t.ok(isCallable(isCallable), 'isCallable is callable'); + t.end(); +}); + +test('Generators', { skip: !genFn }, function (t) { + t.ok(isCallable(genFn), 'generator function is callable'); + t.end(); +}); + +test('Arrow functions', { skip: !arrowFn }, function (t) { + t.ok(isCallable(arrowFn), 'arrow function is callable'); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/package.json new file mode 100644 index 0000000..752a90a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/package.json @@ -0,0 +1,99 @@ +{ + "name": "es-abstract", + "version": "1.2.1", + "author": { + "name": "Jordan Harband" + }, + "description": "ECMAScript spec abstract operations.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && node test/index.js && npm run security", + "coverage": "covert test/*.js", + "coverage-quiet": "covert test/*.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test/*.js *.js", + "eslint": "eslint test/*.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/es-abstract.git" + }, + "keywords": [ + "ECMAScript", + "ES", + "abstract", + "operation", + "abstract operation", + "JavaScript", + "ES5", + "ES6", + "ES7" + ], + "dependencies": { + "is-callable": "^1.0.4", + "es-to-primitive": "^1.0.0" + }, + "devDependencies": { + "tape": "^3.5.0", + "covert": "^1.0.1", + "jscs": "^1.11.3", + "editorconfig-tools": "^0.1.1", + "nsp": "^1.0.1", + "eslint": "^0.17.1", + "object-is": "^1.0.1", + "foreach": "^2.0.5", + "semver": "^4.3.1", + "replace": "^0.3.0" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "c163a554e2b9d2034f3c489f3b292987df6a485a", + "bugs": { + "url": "https://github.com/ljharb/es-abstract/issues" + }, + "homepage": "https://github.com/ljharb/es-abstract", + "_id": "es-abstract@1.2.1", + "_shasum": "a7310f95cd83994b8395fff8dd9f36bf0d4e70a2", + "_from": "es-abstract@>=1.2.1 <2.0.0", + "_npmVersion": "2.7.1", + "_nodeVersion": "1.6.1", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "dist": { + "shasum": "a7310f95cd83994b8395fff8dd9f36bf0d4e70a2", + "tarball": "http://registry.npmjs.org/es-abstract/-/es-abstract-1.2.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.2.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es5.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es5.js new file mode 100644 index 0000000..953dc2d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es5.js @@ -0,0 +1,188 @@ +var ES = require('../').ES5; +var test = require('tape'); + +var forEach = require('foreach'); +var is = require('object-is'); + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var coercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var uncoercibleFnObject = { valueOf: function () { return function valueOfFn() {}; }, toString: function () { return function toStrFn() {}; } }; +var objects = [{}, coercibleObject, toStringOnlyObject, valueOfOnlyObject]; +var numbers = [0, -0, Infinity, -Infinity, 42]; +var nonNullPrimitives = [true, false, 'foo', ''].concat(numbers); +var primitives = [undefined, null].concat(nonNullPrimitives); + +test('ToPrimitive', function (t) { + t.test('primitives', function (st) { + forEach(primitives, function (primitive) { + st.ok(is(ES.ToPrimitive(primitive), primitive), primitive + ' is returned correctly'); + }); + st.end(); + }); + + t.test('objects', function (st) { + st.equal(ES.ToPrimitive(coercibleObject), 3, 'coercibleObject coerces to valueOf'); + st.equal(ES.ToPrimitive(coercibleObject, Number), 3, 'coercibleObject with hint Number coerces to valueOf'); + st.equal(ES.ToPrimitive(coercibleObject, String), '42', 'coercibleObject with hint String coerces to stringified toString'); + st.equal(ES.ToPrimitive(coercibleFnObject), 42, 'coercibleFnObject coerces to toString'); + st.equal(ES.ToPrimitive(toStringOnlyObject), 7, 'toStringOnlyObject returns non-stringified toString'); + st.equal(ES.ToPrimitive(valueOfOnlyObject), 4, 'valueOfOnlyObject returns valueOf'); + st.ok(is(ES.ToPrimitive({}), NaN), '{} with no hint coerces to Object#valueOf'); + st.equal(ES.ToPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + st.ok(is(ES.ToPrimitive({}, Number), NaN), '{} with hint Number coerces to NaN'); + st.throws(function () { return ES.ToPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + st.throws(function () { return ES.ToPrimitive(uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError'); + st.end(); + }); + + t.end(); +}); + +test('ToBoolean', function (t) { + t.equal(false, ES.ToBoolean(undefined), 'undefined coerces to false'); + t.equal(false, ES.ToBoolean(null), 'null coerces to false'); + t.equal(false, ES.ToBoolean(false), 'false returns false'); + t.equal(true, ES.ToBoolean(true), 'true returns true'); + forEach([0, -0, NaN], function (falsyNumber) { + t.equal(false, ES.ToBoolean(falsyNumber), 'falsy number ' + falsyNumber + ' coerces to false'); + }); + forEach([Infinity, 42, 1, -Infinity], function (truthyNumber) { + t.equal(true, ES.ToBoolean(truthyNumber), 'truthy number ' + truthyNumber + ' coerces to true'); + }); + t.equal(false, ES.ToBoolean(''), 'empty string coerces to false'); + t.equal(true, ES.ToBoolean('foo'), 'nonempty string coerces to true'); + forEach(objects, function (obj) { + t.equal(true, ES.ToBoolean(obj), 'object coerces to true'); + }); + t.equal(true, ES.ToBoolean(uncoercibleObject), 'uncoercibleObject coerces to true'); + t.end(); +}); + +test('ToNumber', function (t) { + t.ok(is(NaN, ES.ToNumber(undefined)), 'undefined coerces to NaN'); + t.ok(is(ES.ToNumber(null), 0), 'null coerces to +0'); + t.ok(is(ES.ToNumber(false), 0), 'false coerces to +0'); + t.equal(1, ES.ToNumber(true), 'true coerces to 1'); + t.ok(is(NaN, ES.ToNumber(NaN)), 'NaN returns itself'); + forEach([0, -0, 42, Infinity, -Infinity], function (num) { + t.equal(num, ES.ToNumber(num), num + ' returns itself'); + }); + forEach(['foo', '0', '4a', '2.0', 'Infinity', '-Infinity'], function (numString) { + t.ok(is(+numString, ES.ToNumber(numString)), '"' + numString + '" coerces to ' + (+numString)); + }); + forEach(objects, function (object) { + t.ok(is(ES.ToNumber(object), ES.ToNumber(ES.ToPrimitive(object))), 'object ' + object + ' coerces to same as ToPrimitive of object does'); + }); + t.throws(function () { return ES.ToNumber(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInteger', function (t) { + t.ok(is(0, ES.ToInteger(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity, 42], function (num) { + t.ok(is(num, ES.ToInteger(num)), num + ' returns itself'); + t.ok(is(-num, ES.ToInteger(-num)), '-' + num + ' returns itself'); + }); + t.equal(3, ES.ToInteger(Math.PI), 'pi returns 3'); + t.throws(function () { return ES.ToInteger(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInt32', function (t) { + t.ok(is(0, ES.ToInt32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt32(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt32(0x80000000), -0x80000000), '2^31 returns -2^31'); + t.ok(is(ES.ToInt32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToInt32(num), ES.ToInt32(ES.ToUint32(num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToInt32(-num), ES.ToInt32(ES.ToUint32(-num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToUint32', function (t) { + t.ok(is(0, ES.ToUint32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint32(0x100000000 - 1), 0x100000000 - 1), '2^32 - 1 returns 2^32 - 1'); + t.ok(is(ES.ToUint32(0x80000000), 0x80000000), '2^31 returns 2^31'); + t.ok(is(ES.ToUint32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToUint32(num), ES.ToUint32(ES.ToInt32(num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToUint32(-num), ES.ToUint32(ES.ToInt32(-num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToUint16', function (t) { + t.ok(is(0, ES.ToUint16(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint16(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint16(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint16(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint16(0x100000000 - 1), 0x10000 - 1), '2^32 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToUint16(0x80000000 - 1), 0x10000 - 1), '2^31 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToUint16(0x10000 - 1), 0x10000 - 1), '2^16 - 1 returns 2^16 - 1'); + t.end(); +}); + +test('ToString', function (t) { + t.throws(function () { return ES.ToString(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToObject', function (t) { + t.throws(function () { return ES.ToObject(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.ToObject(null); }, TypeError, 'null throws'); + forEach(numbers, function (number) { + var obj = ES.ToObject(number); + t.equal(typeof obj, 'object', 'number ' + number + ' coerces to object'); + t.equal(true, obj instanceof Number, 'object of ' + number + ' is Number object'); + t.ok(is(obj.valueOf(), number), 'object of ' + number + ' coerces to ' + number); + }); + t.end(); +}); + +test('CheckObjectCoercible', function (t) { + t.throws(function () { return ES.CheckObjectCoercible(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.CheckObjectCoercible(null); }, TypeError, 'null throws'); + forEach(objects.concat(nonNullPrimitives), function (value) { + t.doesNotThrow(function () { return ES.CheckObjectCoercible(value); }, '"' + value + '" does not throw'); + }); + t.end(); +}); + +test('IsCallable', function (t) { + t.equal(true, ES.IsCallable(function () {}), 'function is callable'); + var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(primitives); + forEach(nonCallables, function (nonCallable) { + t.equal(false, ES.IsCallable(nonCallable), nonCallable + ' is not callable'); + }); + t.end(); +}); + +test('SameValue', function (t) { + t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN'); + t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); + forEach(objects.concat(primitives), function (val) { + t.equal(val === val, ES.SameValue(val, val), '"' + val + '" is SameValue to itself'); + }); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es6.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es6.js new file mode 100644 index 0000000..9ac1924 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es6.js @@ -0,0 +1,391 @@ +var ES = require('../').ES6; +var test = require('tape'); + +var forEach = require('foreach'); +var is = require('object-is'); + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var objects = [{}, coercibleObject, toStringOnlyObject, valueOfOnlyObject]; +var numbers = [0, -0, Infinity, -Infinity, 42]; +var nonNullPrimitives = [true, false, 'foo', ''].concat(numbers); +var primitives = [undefined, null].concat(nonNullPrimitives); + +test('ToPrimitive', function (t) { + t.test('primitives', function (st) { + forEach(primitives, function (primitive) { + st.ok(is(ES.ToPrimitive(primitive), primitive), primitive + ' is returned correctly'); + }); + st.end(); + }); + + t.test('objects', function (st) { + st.equal(ES.ToPrimitive(coercibleObject), 3, 'coercibleObject with no hint coerces to valueOf'); + st.ok(is(ES.ToPrimitive({}), '[object Object]'), '{} with no hint coerces to Object#toString'); + st.equal(ES.ToPrimitive(coercibleObject, Number), 3, 'coercibleObject with hint Number coerces to valueOf'); + st.ok(is(ES.ToPrimitive({}, Number), '[object Object]'), '{} with hint Number coerces to NaN'); + st.equal(ES.ToPrimitive(coercibleObject, String), 42, 'coercibleObject with hint String coerces to nonstringified toString'); + st.equal(ES.ToPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + st.equal(ES.ToPrimitive(toStringOnlyObject), 7, 'toStringOnlyObject returns non-stringified toString'); + st.equal(ES.ToPrimitive(valueOfOnlyObject), 4, 'valueOfOnlyObject returns valueOf'); + st.throws(function () { return ES.ToPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + st.end(); + }); + + t.end(); +}); + +test('ToBoolean', function (t) { + t.equal(false, ES.ToBoolean(undefined), 'undefined coerces to false'); + t.equal(false, ES.ToBoolean(null), 'null coerces to false'); + t.equal(false, ES.ToBoolean(false), 'false returns false'); + t.equal(true, ES.ToBoolean(true), 'true returns true'); + forEach([0, -0, NaN], function (falsyNumber) { + t.equal(false, ES.ToBoolean(falsyNumber), 'falsy number ' + falsyNumber + ' coerces to false'); + }); + forEach([Infinity, 42, 1, -Infinity], function (truthyNumber) { + t.equal(true, ES.ToBoolean(truthyNumber), 'truthy number ' + truthyNumber + ' coerces to true'); + }); + t.equal(false, ES.ToBoolean(''), 'empty string coerces to false'); + t.equal(true, ES.ToBoolean('foo'), 'nonempty string coerces to true'); + forEach(objects, function (obj) { + t.equal(true, ES.ToBoolean(obj), 'object coerces to true'); + }); + t.equal(true, ES.ToBoolean(uncoercibleObject), 'uncoercibleObject coerces to true'); + t.end(); +}); + +test('ToNumber', function (t) { + t.ok(is(NaN, ES.ToNumber(undefined)), 'undefined coerces to NaN'); + t.ok(is(ES.ToNumber(null), 0), 'null coerces to +0'); + t.ok(is(ES.ToNumber(false), 0), 'false coerces to +0'); + t.equal(1, ES.ToNumber(true), 'true coerces to 1'); + t.ok(is(NaN, ES.ToNumber(NaN)), 'NaN returns itself'); + forEach([0, -0, 42, Infinity, -Infinity], function (num) { + t.equal(num, ES.ToNumber(num), num + ' returns itself'); + }); + forEach(['foo', '0', '4a', '2.0', 'Infinity', '-Infinity'], function (numString) { + t.ok(is(+numString, ES.ToNumber(numString)), '"' + numString + '" coerces to ' + (+numString)); + }); + forEach(objects, function (object) { + t.ok(is(ES.ToNumber(object), ES.ToNumber(ES.ToPrimitive(object))), 'object ' + object + ' coerces to same as ToPrimitive of object does'); + }); + t.throws(function () { return ES.ToNumber(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInteger', function (t) { + t.ok(is(0, ES.ToInteger(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity, 42], function (num) { + t.ok(is(num, ES.ToInteger(num)), num + ' returns itself'); + t.ok(is(-num, ES.ToInteger(-num)), '-' + num + ' returns itself'); + }); + t.equal(3, ES.ToInteger(Math.PI), 'pi returns 3'); + t.throws(function () { return ES.ToInteger(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInt32', function (t) { + t.ok(is(0, ES.ToInt32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt32(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt32(0x80000000), -0x80000000), '2^31 returns -2^31'); + t.ok(is(ES.ToInt32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToInt32(num), ES.ToInt32(ES.ToUint32(num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToInt32(-num), ES.ToInt32(ES.ToUint32(-num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToUint32', function (t) { + t.ok(is(0, ES.ToUint32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint32(0x100000000 - 1), 0x100000000 - 1), '2^32 - 1 returns 2^32 - 1'); + t.ok(is(ES.ToUint32(0x80000000), 0x80000000), '2^31 returns 2^31'); + t.ok(is(ES.ToUint32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToUint32(num), ES.ToUint32(ES.ToInt32(num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToUint32(-num), ES.ToUint32(ES.ToInt32(-num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToInt16', function (t) { + t.ok(is(0, ES.ToInt16(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt16(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt16(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt16(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt16(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt16(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToInt16(0x80000000 - 1), -1), '2^31 - 1 returns -1'); + t.ok(is(ES.ToInt16(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToInt16(0x10000 - 1), -1), '2^16 - 1 returns -1'); + t.end(); +}); + +test('ToUint16', function (t) { + t.ok(is(0, ES.ToUint16(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint16(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint16(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint16(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint16(0x100000000 - 1), 0x10000 - 1), '2^32 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToUint16(0x80000000 - 1), 0x10000 - 1), '2^31 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToUint16(0x10000 - 1), 0x10000 - 1), '2^16 - 1 returns 2^16 - 1'); + t.end(); +}); + +test('ToInt8', function (t) { + t.ok(is(0, ES.ToInt8(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt8(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt8(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt8(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt8(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt8(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToInt8(0x80000000 - 1), -1), '2^31 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToInt8(0x10000 - 1), -1), '2^16 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x100), 0), '2^8 returns +0'); + t.ok(is(ES.ToInt8(0x100 - 1), -1), '2^8 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x10), 0x10), '2^4 returns 2^4'); + t.end(); +}); + +test('ToUint8', function (t) { + t.ok(is(0, ES.ToUint8(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint8(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint8(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint8(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint8(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint8(0x100000000 - 1), 0x100 - 1), '2^32 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToUint8(0x80000000 - 1), 0x100 - 1), '2^31 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToUint8(0x10000 - 1), 0x100 - 1), '2^16 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x100), 0), '2^8 returns +0'); + t.ok(is(ES.ToUint8(0x100 - 1), 0x100 - 1), '2^8 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint8(0x10), 0x10), '2^4 returns 2^4'); + t.ok(is(ES.ToUint8(0x10 - 1), 0x10 - 1), '2^4 - 1 returns 2^4 - 1'); + t.end(); +}); + +test('ToUint8Clamp', function (t) { + t.ok(is(0, ES.ToUint8Clamp(NaN)), 'NaN coerces to +0'); + t.ok(is(0, ES.ToUint8Clamp(0)), '+0 returns +0'); + t.ok(is(0, ES.ToUint8Clamp(-0)), '-0 returns +0'); + t.ok(is(0, ES.ToUint8Clamp(-Infinity)), '-Infinity returns +0'); + t.throws(function () { return ES.ToUint8Clamp(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + forEach([255, 256, 0x100000, Infinity], function (number) { + t.ok(is(255, ES.ToUint8Clamp(number)), number + ' coerces to 255'); + }); + t.equal(1, ES.ToUint8Clamp(1.49), '1.49 coerces to 1'); + t.equal(2, ES.ToUint8Clamp(1.5), '1.5 coerces to 2, because 2 is even'); + t.equal(2, ES.ToUint8Clamp(1.51), '1.51 coerces to 2'); + + t.equal(2, ES.ToUint8Clamp(2.49), '2.49 coerces to 2'); + t.equal(2, ES.ToUint8Clamp(2.5), '2.5 coerces to 2, because 2 is even'); + t.equal(3, ES.ToUint8Clamp(2.51), '2.51 coerces to 3'); + t.end(); +}); + +test('ToString', function (t) { + t.throws(function () { return ES.ToString(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToObject', function (t) { + t.throws(function () { return ES.ToObject(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.ToObject(null); }, TypeError, 'null throws'); + forEach(numbers, function (number) { + var obj = ES.ToObject(number); + t.equal(typeof obj, 'object', 'number ' + number + ' coerces to object'); + t.equal(true, obj instanceof Number, 'object of ' + number + ' is Number object'); + t.ok(is(obj.valueOf(), number), 'object of ' + number + ' coerces to ' + number); + }); + t.end(); +}); + +test('RequireObjectCoercible', function (t) { + t.equal(false, 'CheckObjectCoercible' in ES, 'CheckObjectCoercible -> RequireObjectCoercible in ES6'); + t.throws(function () { return ES.RequireObjectCoercible(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.RequireObjectCoercible(null); }, TypeError, 'null throws'); + forEach(objects.concat(nonNullPrimitives), function (value) { + t.doesNotThrow(function () { return ES.RequireObjectCoercible(value); }, '"' + value + '" does not throw'); + }); + t.end(); +}); + +test('IsCallable', function (t) { + t.equal(true, ES.IsCallable(function () {}), 'function is callable'); + var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(primitives); + forEach(nonCallables, function (nonCallable) { + t.equal(false, ES.IsCallable(nonCallable), nonCallable + ' is not callable'); + }); + t.end(); +}); + +test('SameValue', function (t) { + t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN'); + t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); + forEach(objects.concat(primitives), function (val) { + t.equal(val === val, ES.SameValue(val, val), '"' + val + '" is SameValue to itself'); + }); + t.end(); +}); + +test('SameValueZero', function (t) { + t.equal(true, ES.SameValueZero(NaN, NaN), 'NaN is SameValueZero as NaN'); + t.equal(true, ES.SameValueZero(0, -0), '+0 is SameValueZero as -0'); + forEach(objects.concat(primitives), function (val) { + t.equal(val === val, ES.SameValueZero(val, val), '"' + val + '" is SameValueZero to itself'); + }); + t.end(); +}); + +test('ToPropertyKey', function (t) { + forEach(objects.concat(primitives), function (value) { + t.equal(ES.ToPropertyKey(value), String(value), 'ToPropertyKey(value) === String(value) for non-Symbols'); + }); + if (hasSymbols) { + t.equal(ES.ToPropertyKey(Symbol.iterator), 'Symbol(Symbol.iterator)', 'ToPropertyKey(Symbol.iterator) === "Symbol(Symbol.iterator)"'); + } + t.end(); +}); + +test('ToLength', function (t) { + t.throws(function () { return ES.ToLength(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + t.equal(3, ES.ToLength(coercibleObject), 'coercibleObject coerces to 3'); + t.equal(42, ES.ToLength('42.5'), '"42.5" coerces to 42'); + t.equal(7, ES.ToLength(7.3), '7.3 coerces to 7'); + forEach([-0, -1, -42, -Infinity], function (negative) { + t.ok(is(0, ES.ToLength(negative)), negative + ' coerces to +0'); + }); + t.equal(MAX_SAFE_INTEGER, ES.ToLength(MAX_SAFE_INTEGER + 1), '2^53 coerces to 2^53 - 1'); + t.equal(MAX_SAFE_INTEGER, ES.ToLength(MAX_SAFE_INTEGER + 3), '2^53 + 2 coerces to 2^53 - 1'); + t.end(); +}); + +test('IsArray', function (t) { + t.equal(true, ES.IsArray([]), '[] is array'); + t.equal(false, ES.IsArray({}), '{} is not array'); + t.equal(false, ES.IsArray({ length: 1, 0: true }), 'arraylike object is not array'); + forEach(objects.concat(primitives), function (value) { + t.equal(false, ES.IsArray(value), value + ' is not array'); + }); + t.end(); +}); + +test('IsRegExp', function (t) { + forEach([/a/g, new RegExp('a', 'g')], function (regex) { + t.equal(true, ES.IsRegExp(regex), regex + ' is regex'); + }); + forEach(objects.concat(primitives), function (nonRegex) { + t.equal(false, ES.IsRegExp(nonRegex), nonRegex + ' is not regex'); + }); + t.end(); +}); + +test('IsPropertyKey', function (t) { + forEach(numbers.concat(objects), function (notKey) { + t.equal(false, ES.IsPropertyKey(notKey), notKey + ' is not property key'); + }); + t.equal(true, ES.IsPropertyKey('foo'), 'string is property key'); + if (hasSymbols) { + t.equal(true, ES.IsPropertyKey(Symbol.iterator), 'Symbol.iterator is property key'); + } + t.end(); +}); + +test('IsInteger', function (t) { + for (var i = -100; i < 100; i += 10) { + t.equal(true, ES.IsInteger(i), i + ' is integer'); + t.equal(false, ES.IsInteger(i + 0.2), (i + 0.2) + ' is not integer'); + } + t.equal(true, ES.IsInteger(-0), '-0 is integer'); + var notInts = objects.concat([Infinity, -Infinity, NaN, true, false, null, undefined, [], new Date()]); + if (hasSymbols) { notInts.push(Symbol.iterator); } + forEach(notInts, function (notInt) { + t.equal(false, ES.IsInteger(notInt), ES.ToPropertyKey(notInt) + ' is not integer'); + }); + t.equal(false, ES.IsInteger(uncoercibleObject), 'uncoercibleObject is not integer'); + t.end(); +}); + +test('IsExtensible', function (t) { + forEach(objects, function (object) { + t.equal(true, ES.IsExtensible(object), object + ' object is extensible'); + }); + forEach(primitives, function (primitive) { + t.equal(false, ES.IsExtensible(primitive), primitive + ' is not extensible'); + }); + if (Object.preventExtensions) { + t.equal(false, ES.IsExtensible(Object.preventExtensions({})), 'object with extensions prevented is not extensible'); + } + t.end(); +}); + +test('CanonicalNumericIndexString', function (t) { + forEach(objects.concat(numbers), function (notString) { + t.throws(function () { return ES.CanonicalNumericIndexString(notString); }, TypeError, notString + ' is not a string'); + }); + t.ok(is(-0, ES.CanonicalNumericIndexString('-0')), '"-0" returns -0'); + for (var i = -50; i < 50; i += 10) { + t.equal(i, ES.CanonicalNumericIndexString(String(i)), '"' + i + '" returns ' + i); + t.equal(undefined, ES.CanonicalNumericIndexString(String(i) + 'a'), '"' + i + 'a" returns undefined'); + } + t.end(); +}); + +test('IsConstructor', function (t) { + t.equal(true, ES.IsConstructor(function () {}), 'function is constructor'); + t.equal(false, ES.IsConstructor(/a/g), 'regex is not constructor'); + forEach(objects, function (object) { + t.equal(false, ES.IsConstructor(object), object + ' object is not constructor'); + }); + t.end(); +}); + +test('Call', function (t) { + var receiver = {}; + var notFuncs = objects.concat(primitives).concat([/a/g, new RegExp('a', 'g')]); + t.plan(notFuncs.length + 4); + forEach(notFuncs, function (notFunc) { + t.throws(function () { return ES.Call(notFunc, receiver); }, TypeError, notFunc + ' (' + typeof notFunc + ') is not callable'); + }); + ES.Call(function (a, b) { + t.equal(this, receiver, 'context matches expected'); + t.deepEqual([a, b], [1, 2], 'named args are correct'); + t.equal(arguments.length, 3, 'extra argument was passed'); + t.equal(arguments[2], 3, 'extra argument was correct'); + }, receiver, [1, 2, 3]); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es7.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es7.js new file mode 100644 index 0000000..e1b616c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/es7.js @@ -0,0 +1,391 @@ +var ES = require('../').ES7; +var test = require('tape'); + +var forEach = require('foreach'); +var is = require('object-is'); + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; + +var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; +var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; +var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; +var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; +var objects = [{}, coercibleObject, toStringOnlyObject, valueOfOnlyObject]; +var numbers = [0, -0, Infinity, -Infinity, 42]; +var nonNullPrimitives = [true, false, 'foo', ''].concat(numbers); +var primitives = [undefined, null].concat(nonNullPrimitives); + +test('ToPrimitive', function (t) { + t.test('primitives', function (st) { + forEach(primitives, function (primitive) { + st.ok(is(ES.ToPrimitive(primitive), primitive), primitive + ' is returned correctly'); + }); + st.end(); + }); + + t.test('objects', function (st) { + st.equal(ES.ToPrimitive(coercibleObject), 3, 'coercibleObject with no hint coerces to valueOf'); + st.ok(is(ES.ToPrimitive({}), '[object Object]'), '{} with no hint coerces to Object#toString'); + st.equal(ES.ToPrimitive(coercibleObject, Number), 3, 'coercibleObject with hint Number coerces to valueOf'); + st.ok(is(ES.ToPrimitive({}, Number), '[object Object]'), '{} with hint Number coerces to NaN'); + st.equal(ES.ToPrimitive(coercibleObject, String), 42, 'coercibleObject with hint String coerces to nonstringified toString'); + st.equal(ES.ToPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); + st.equal(ES.ToPrimitive(toStringOnlyObject), 7, 'toStringOnlyObject returns non-stringified toString'); + st.equal(ES.ToPrimitive(valueOfOnlyObject), 4, 'valueOfOnlyObject returns valueOf'); + st.throws(function () { return ES.ToPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + st.end(); + }); + + t.end(); +}); + +test('ToBoolean', function (t) { + t.equal(false, ES.ToBoolean(undefined), 'undefined coerces to false'); + t.equal(false, ES.ToBoolean(null), 'null coerces to false'); + t.equal(false, ES.ToBoolean(false), 'false returns false'); + t.equal(true, ES.ToBoolean(true), 'true returns true'); + forEach([0, -0, NaN], function (falsyNumber) { + t.equal(false, ES.ToBoolean(falsyNumber), 'falsy number ' + falsyNumber + ' coerces to false'); + }); + forEach([Infinity, 42, 1, -Infinity], function (truthyNumber) { + t.equal(true, ES.ToBoolean(truthyNumber), 'truthy number ' + truthyNumber + ' coerces to true'); + }); + t.equal(false, ES.ToBoolean(''), 'empty string coerces to false'); + t.equal(true, ES.ToBoolean('foo'), 'nonempty string coerces to true'); + forEach(objects, function (obj) { + t.equal(true, ES.ToBoolean(obj), 'object coerces to true'); + }); + t.equal(true, ES.ToBoolean(uncoercibleObject), 'uncoercibleObject coerces to true'); + t.end(); +}); + +test('ToNumber', function (t) { + t.ok(is(NaN, ES.ToNumber(undefined)), 'undefined coerces to NaN'); + t.ok(is(ES.ToNumber(null), 0), 'null coerces to +0'); + t.ok(is(ES.ToNumber(false), 0), 'false coerces to +0'); + t.equal(1, ES.ToNumber(true), 'true coerces to 1'); + t.ok(is(NaN, ES.ToNumber(NaN)), 'NaN returns itself'); + forEach([0, -0, 42, Infinity, -Infinity], function (num) { + t.equal(num, ES.ToNumber(num), num + ' returns itself'); + }); + forEach(['foo', '0', '4a', '2.0', 'Infinity', '-Infinity'], function (numString) { + t.ok(is(+numString, ES.ToNumber(numString)), '"' + numString + '" coerces to ' + (+numString)); + }); + forEach(objects, function (object) { + t.ok(is(ES.ToNumber(object), ES.ToNumber(ES.ToPrimitive(object))), 'object ' + object + ' coerces to same as ToPrimitive of object does'); + }); + t.throws(function () { return ES.ToNumber(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInteger', function (t) { + t.ok(is(0, ES.ToInteger(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity, 42], function (num) { + t.ok(is(num, ES.ToInteger(num)), num + ' returns itself'); + t.ok(is(-num, ES.ToInteger(-num)), '-' + num + ' returns itself'); + }); + t.equal(3, ES.ToInteger(Math.PI), 'pi returns 3'); + t.throws(function () { return ES.ToInteger(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToInt32', function (t) { + t.ok(is(0, ES.ToInt32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt32(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt32(0x80000000), -0x80000000), '2^31 returns -2^31'); + t.ok(is(ES.ToInt32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToInt32(num), ES.ToInt32(ES.ToUint32(num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToInt32(-num), ES.ToInt32(ES.ToUint32(-num))), 'ToInt32(x) === ToInt32(ToUint32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToUint32', function (t) { + t.ok(is(0, ES.ToUint32(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint32(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint32(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint32(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint32(0x100000000 - 1), 0x100000000 - 1), '2^32 - 1 returns 2^32 - 1'); + t.ok(is(ES.ToUint32(0x80000000), 0x80000000), '2^31 returns 2^31'); + t.ok(is(ES.ToUint32(0x80000000 - 1), 0x80000000 - 1), '2^31 - 1 returns 2^31 - 1'); + forEach([0, Infinity, NaN, 0x100000000, 0x80000000, 0x10000, 0x42], function (num) { + t.ok(is(ES.ToUint32(num), ES.ToUint32(ES.ToInt32(num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for 0x' + num.toString(16)); + t.ok(is(ES.ToUint32(-num), ES.ToUint32(ES.ToInt32(-num))), 'ToUint32(x) === ToUint32(ToInt32(x)) for -0x' + num.toString(16)); + }); + t.end(); +}); + +test('ToInt16', function (t) { + t.ok(is(0, ES.ToInt16(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt16(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt16(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt16(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt16(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt16(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToInt16(0x80000000 - 1), -1), '2^31 - 1 returns -1'); + t.ok(is(ES.ToInt16(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToInt16(0x10000 - 1), -1), '2^16 - 1 returns -1'); + t.end(); +}); + +test('ToUint16', function (t) { + t.ok(is(0, ES.ToUint16(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint16(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint16(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint16(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint16(0x100000000 - 1), 0x10000 - 1), '2^32 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToUint16(0x80000000 - 1), 0x10000 - 1), '2^31 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint16(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToUint16(0x10000 - 1), 0x10000 - 1), '2^16 - 1 returns 2^16 - 1'); + t.end(); +}); + +test('ToInt8', function (t) { + t.ok(is(0, ES.ToInt8(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToInt8(num)), num + ' returns +0'); + t.ok(is(0, ES.ToInt8(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToInt8(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToInt8(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToInt8(0x100000000 - 1), -1), '2^32 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToInt8(0x80000000 - 1), -1), '2^31 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToInt8(0x10000 - 1), -1), '2^16 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x100), 0), '2^8 returns +0'); + t.ok(is(ES.ToInt8(0x100 - 1), -1), '2^8 - 1 returns -1'); + t.ok(is(ES.ToInt8(0x10), 0x10), '2^4 returns 2^4'); + t.end(); +}); + +test('ToUint8', function (t) { + t.ok(is(0, ES.ToUint8(NaN)), 'NaN coerces to +0'); + forEach([0, Infinity], function (num) { + t.ok(is(0, ES.ToUint8(num)), num + ' returns +0'); + t.ok(is(0, ES.ToUint8(-num)), '-' + num + ' returns +0'); + }); + t.throws(function () { return ES.ToUint8(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.ok(is(ES.ToUint8(0x100000000), 0), '2^32 returns +0'); + t.ok(is(ES.ToUint8(0x100000000 - 1), 0x100 - 1), '2^32 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x80000000), 0), '2^31 returns +0'); + t.ok(is(ES.ToUint8(0x80000000 - 1), 0x100 - 1), '2^31 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x10000), 0), '2^16 returns +0'); + t.ok(is(ES.ToUint8(0x10000 - 1), 0x100 - 1), '2^16 - 1 returns 2^8 - 1'); + t.ok(is(ES.ToUint8(0x100), 0), '2^8 returns +0'); + t.ok(is(ES.ToUint8(0x100 - 1), 0x100 - 1), '2^8 - 1 returns 2^16 - 1'); + t.ok(is(ES.ToUint8(0x10), 0x10), '2^4 returns 2^4'); + t.ok(is(ES.ToUint8(0x10 - 1), 0x10 - 1), '2^4 - 1 returns 2^4 - 1'); + t.end(); +}); + +test('ToUint8Clamp', function (t) { + t.ok(is(0, ES.ToUint8Clamp(NaN)), 'NaN coerces to +0'); + t.ok(is(0, ES.ToUint8Clamp(0)), '+0 returns +0'); + t.ok(is(0, ES.ToUint8Clamp(-0)), '-0 returns +0'); + t.ok(is(0, ES.ToUint8Clamp(-Infinity)), '-Infinity returns +0'); + t.throws(function () { return ES.ToUint8Clamp(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + forEach([255, 256, 0x100000, Infinity], function (number) { + t.ok(is(255, ES.ToUint8Clamp(number)), number + ' coerces to 255'); + }); + t.equal(1, ES.ToUint8Clamp(1.49), '1.49 coerces to 1'); + t.equal(2, ES.ToUint8Clamp(1.5), '1.5 coerces to 2, because 2 is even'); + t.equal(2, ES.ToUint8Clamp(1.51), '1.51 coerces to 2'); + + t.equal(2, ES.ToUint8Clamp(2.49), '2.49 coerces to 2'); + t.equal(2, ES.ToUint8Clamp(2.5), '2.5 coerces to 2, because 2 is even'); + t.equal(3, ES.ToUint8Clamp(2.51), '2.51 coerces to 3'); + t.end(); +}); + +test('ToString', function (t) { + t.throws(function () { return ES.ToString(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); + t.end(); +}); + +test('ToObject', function (t) { + t.throws(function () { return ES.ToObject(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.ToObject(null); }, TypeError, 'null throws'); + forEach(numbers, function (number) { + var obj = ES.ToObject(number); + t.equal(typeof obj, 'object', 'number ' + number + ' coerces to object'); + t.equal(true, obj instanceof Number, 'object of ' + number + ' is Number object'); + t.ok(is(obj.valueOf(), number), 'object of ' + number + ' coerces to ' + number); + }); + t.end(); +}); + +test('RequireObjectCoercible', function (t) { + t.equal(false, 'CheckObjectCoercible' in ES, 'CheckObjectCoercible -> RequireObjectCoercible in ES6'); + t.throws(function () { return ES.RequireObjectCoercible(undefined); }, TypeError, 'undefined throws'); + t.throws(function () { return ES.RequireObjectCoercible(null); }, TypeError, 'null throws'); + forEach(objects.concat(nonNullPrimitives), function (value) { + t.doesNotThrow(function () { return ES.RequireObjectCoercible(value); }, '"' + value + '" does not throw'); + }); + t.end(); +}); + +test('IsCallable', function (t) { + t.equal(true, ES.IsCallable(function () {}), 'function is callable'); + var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(primitives); + forEach(nonCallables, function (nonCallable) { + t.equal(false, ES.IsCallable(nonCallable), nonCallable + ' is not callable'); + }); + t.end(); +}); + +test('SameValue', function (t) { + t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN'); + t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); + forEach(objects.concat(primitives), function (val) { + t.equal(val === val, ES.SameValue(val, val), '"' + val + '" is SameValue to itself'); + }); + t.end(); +}); + +test('SameValueZero', function (t) { + t.equal(true, ES.SameValueZero(NaN, NaN), 'NaN is SameValueZero as NaN'); + t.equal(true, ES.SameValueZero(0, -0), '+0 is SameValueZero as -0'); + forEach(objects.concat(primitives), function (val) { + t.equal(val === val, ES.SameValueZero(val, val), '"' + val + '" is SameValueZero to itself'); + }); + t.end(); +}); + +test('ToPropertyKey', function (t) { + forEach(objects.concat(primitives), function (value) { + t.equal(ES.ToPropertyKey(value), String(value), 'ToPropertyKey(value) === String(value) for non-Symbols'); + }); + if (hasSymbols) { + t.equal(ES.ToPropertyKey(Symbol.iterator), 'Symbol(Symbol.iterator)', 'ToPropertyKey(Symbol.iterator) === "Symbol(Symbol.iterator)"'); + } + t.end(); +}); + +test('ToLength', function (t) { + t.throws(function () { return ES.ToLength(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); + t.equal(3, ES.ToLength(coercibleObject), 'coercibleObject coerces to 3'); + t.equal(42, ES.ToLength('42.5'), '"42.5" coerces to 42'); + t.equal(7, ES.ToLength(7.3), '7.3 coerces to 7'); + forEach([-0, -1, -42, -Infinity], function (negative) { + t.ok(is(0, ES.ToLength(negative)), negative + ' coerces to +0'); + }); + t.equal(MAX_SAFE_INTEGER, ES.ToLength(MAX_SAFE_INTEGER + 1), '2^53 coerces to 2^53 - 1'); + t.equal(MAX_SAFE_INTEGER, ES.ToLength(MAX_SAFE_INTEGER + 3), '2^53 + 2 coerces to 2^53 - 1'); + t.end(); +}); + +test('IsArray', function (t) { + t.equal(true, ES.IsArray([]), '[] is array'); + t.equal(false, ES.IsArray({}), '{} is not array'); + t.equal(false, ES.IsArray({ length: 1, 0: true }), 'arraylike object is not array'); + forEach(objects.concat(primitives), function (value) { + t.equal(false, ES.IsArray(value), value + ' is not array'); + }); + t.end(); +}); + +test('IsRegExp', function (t) { + forEach([/a/g, new RegExp('a', 'g')], function (regex) { + t.equal(true, ES.IsRegExp(regex), regex + ' is regex'); + }); + forEach(objects.concat(primitives), function (nonRegex) { + t.equal(false, ES.IsRegExp(nonRegex), nonRegex + ' is not regex'); + }); + t.end(); +}); + +test('IsPropertyKey', function (t) { + forEach(numbers.concat(objects), function (notKey) { + t.equal(false, ES.IsPropertyKey(notKey), notKey + ' is not property key'); + }); + t.equal(true, ES.IsPropertyKey('foo'), 'string is property key'); + if (hasSymbols) { + t.equal(true, ES.IsPropertyKey(Symbol.iterator), 'Symbol.iterator is property key'); + } + t.end(); +}); + +test('IsInteger', function (t) { + for (var i = -100; i < 100; i += 10) { + t.equal(true, ES.IsInteger(i), i + ' is integer'); + t.equal(false, ES.IsInteger(i + 0.2), (i + 0.2) + ' is not integer'); + } + t.equal(true, ES.IsInteger(-0), '-0 is integer'); + var notInts = objects.concat([Infinity, -Infinity, NaN, true, false, null, undefined, [], new Date()]); + if (hasSymbols) { notInts.push(Symbol.iterator); } + forEach(notInts, function (notInt) { + t.equal(false, ES.IsInteger(notInt), ES.ToPropertyKey(notInt) + ' is not integer'); + }); + t.equal(false, ES.IsInteger(uncoercibleObject), 'uncoercibleObject is not integer'); + t.end(); +}); + +test('IsExtensible', function (t) { + forEach(objects, function (object) { + t.equal(true, ES.IsExtensible(object), object + ' object is extensible'); + }); + forEach(primitives, function (primitive) { + t.equal(false, ES.IsExtensible(primitive), primitive + ' is not extensible'); + }); + if (Object.preventExtensions) { + t.equal(false, ES.IsExtensible(Object.preventExtensions({})), 'object with extensions prevented is not extensible'); + } + t.end(); +}); + +test('CanonicalNumericIndexString', function (t) { + forEach(objects.concat(numbers), function (notString) { + t.throws(function () { return ES.CanonicalNumericIndexString(notString); }, TypeError, notString + ' is not a string'); + }); + t.ok(is(-0, ES.CanonicalNumericIndexString('-0')), '"-0" returns -0'); + for (var i = -50; i < 50; i += 10) { + t.equal(i, ES.CanonicalNumericIndexString(String(i)), '"' + i + '" returns ' + i); + t.equal(undefined, ES.CanonicalNumericIndexString(String(i) + 'a'), '"' + i + 'a" returns undefined'); + } + t.end(); +}); + +test('IsConstructor', function (t) { + t.equal(true, ES.IsConstructor(function () {}), 'function is constructor'); + t.equal(false, ES.IsConstructor(/a/g), 'regex is not constructor'); + forEach(objects, function (object) { + t.equal(false, ES.IsConstructor(object), object + ' object is not constructor'); + }); + t.end(); +}); + +test('Call', function (t) { + var receiver = {}; + var notFuncs = objects.concat(primitives).concat([/a/g, new RegExp('a', 'g')]); + t.plan(notFuncs.length + 4); + forEach(notFuncs, function (notFunc) { + t.throws(function () { return ES.Call(notFunc, receiver); }, TypeError, notFunc + ' (' + typeof notFunc + ') is not callable'); + }); + ES.Call(function (a, b) { + t.equal(this, receiver, 'context matches expected'); + t.deepEqual([a, b], [1, 2], 'named args are correct'); + t.equal(arguments.length, 3, 'extra argument was passed'); + t.equal(arguments[2], 3, 'extra argument was correct'); + }, receiver, [1, 2, 3]); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/index.js new file mode 100644 index 0000000..7dd10e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/node_modules/es-abstract/test/index.js @@ -0,0 +1,21 @@ +var ES = require('../'); +var test = require('tape'); + +var ESkeys = Object.keys(ES).sort(); +var ES6keys = Object.keys(ES.ES6).sort(); + +test('exposed properties', function (t) { + t.deepEqual(ESkeys, ES6keys.concat(['ES7', 'ES6', 'ES5']).sort(), 'main ES object keys match ES6 keys'); + t.end(); +}); + +test('methods match', function (t) { + ES6keys.forEach(function (key) { + t.equal(ES.ES6[key], ES[key], 'method ' + key + ' on main ES object is ES6 method'); + }); + t.end(); +}); + +require('./es5'); +require('./es6'); +require('./es7'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/package.json b/JavaScript/node_modules/johnny-five/node_modules/array-includes/package.json new file mode 100644 index 0000000..19ef1d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/package.json @@ -0,0 +1,103 @@ +{ + "name": "array-includes", + "version": "2.0.0", + "author": { + "name": "Jordan Harband" + }, + "description": "A spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.", + "license": "MIT", + "main": "index.js", + "scripts": { + "test": "npm run lint && npm run test:shimmed && npm run test:module && npm run security", + "test:shimmed": "node test/shimmed.js", + "test:module": "node test/index.js", + "coverage": "covert test/*.js", + "coverage:quiet": "covert test/*.js --quiet", + "lint": "npm run jscs && npm run eslint", + "jscs": "jscs test/*.js *.js", + "eslint": "eslint test/*.js *.js", + "eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", + "security": "nsp package" + }, + "repository": { + "type": "git", + "url": "git://github.com/ljharb/array-includes.git" + }, + "keywords": [ + "Array.prototype.includes", + "includes", + "array", + "ES7", + "shim", + "polyfill", + "contains", + "Array.prototype.contains" + ], + "dependencies": { + "define-properties": "^1.0.1", + "es-abstract": "^1.2.1" + }, + "devDependencies": { + "foreach": "^2.0.5", + "function-bind": "^1.0.2", + "tape": "^4.0.0", + "indexof": "^0.0.1", + "covert": "^1.1.0", + "jscs": "^1.13.1", + "editorconfig-tools": "^0.1.1", + "nsp": "^1.0.1", + "eslint": "^0.21.2", + "semver": "^4.3.4", + "replace": "^0.3.0" + }, + "testling": { + "files": [ + "test/index.js", + "test/shimmed.js" + ], + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "engines": { + "node": ">= 0.4" + }, + "gitHead": "8d994f6e8c42b488382436241af0168e936082ae", + "bugs": { + "url": "https://github.com/ljharb/array-includes/issues" + }, + "homepage": "https://github.com/ljharb/array-includes#readme", + "_id": "array-includes@2.0.0", + "_shasum": "4a95c73514066dc81213d7da45a4d712ccdc2ba6", + "_from": "array-includes@latest", + "_npmVersion": "2.9.0", + "_nodeVersion": "2.0.2", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "dist": { + "shasum": "4a95c73514066dc81213d7da45a4d712ccdc2ba6", + "tarball": "http://registry.npmjs.org/array-includes/-/array-includes-2.0.0.tgz" + }, + "maintainers": [ + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/array-includes/-/array-includes-2.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/index.js new file mode 100644 index 0000000..01b8e10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/index.js @@ -0,0 +1,14 @@ +var includes = require('../'); +var test = require('tape'); + +test('as a function', function (t) { + t.test('bad array/this value', function (st) { + st.throws(function () { return includes(undefined, 'a'); }, TypeError, 'undefined is not an object'); + st.throws(function () { return includes(null, 'a'); }, TypeError, 'null is not an object'); + st.end(); + }); + + require('./tests')(includes, t); + + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/shimmed.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/shimmed.js new file mode 100644 index 0000000..559fac0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/shimmed.js @@ -0,0 +1,40 @@ +var includes = require('../'); +includes.shim(); + +var test = require('tape'); +var defineProperties = require('define-properties'); +var bind = require('function-bind'); +var isEnumerable = Object.prototype.propertyIsEnumerable; +var functionsHaveNames = function f() {}.name === 'f'; + +test('shimmed', function (t) { + t.equal(Array.prototype.includes.length, 1, 'Array#includes has a length of 1'); + t.test('Function name', { skip: !functionsHaveNames }, function (st) { + st.equal(Array.prototype.includes.name, 'includes', 'Array#includes has name "includes"'); + st.end(); + }); + + t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) { + et.equal(false, isEnumerable.call(Array.prototype, 'includes'), 'Array#includes is not enumerable'); + et.end(); + }); + + var supportsStrictMode = (function () { + 'use strict'; + + var fn = function () { return this === null; }; + return fn.call(null); + }()); + + t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) { + 'use strict'; + + st.throws(function () { return includes(undefined, 'a'); }, TypeError, 'undefined is not an object'); + st.throws(function () { return includes(null, 'a'); }, TypeError, 'null is not an object'); + st.end(); + }); + + require('./tests')(bind.call(Function.call, Array.prototype.includes), t); + + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/tests.js b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/tests.js new file mode 100644 index 0000000..add1923 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/array-includes/test/tests.js @@ -0,0 +1,78 @@ +module.exports = function (includes, t) { + var sparseish = { length: 5, 0: 'a', 1: 'b' }; + var overfullarrayish = { length: 2, 0: 'a', 1: 'b', 2: 'c' }; + var thrower = { valueOf: function () { throw new RangeError('whoa'); } }; + var numberish = { valueOf: function () { return 2; } }; + + t.test('simple examples', function (st) { + st.equal(true, includes([1, 2, 3], 1), '[1, 2, 3] includes 1'); + st.equal(false, includes([1, 2, 3], 4), '[1, 2, 3] does not include 4'); + st.equal(true, includes([NaN], NaN), '[NaN] includes NaN'); + st.end(); + }); + + t.test('does not skip holes', function (st) { + st.equal(true, includes(Array(1)), 'Array(1) includes undefined'); + st.end(); + }); + + t.test('exceptions', function (et) { + et.test('fromIndex conversion', function (st) { + st.throws(function () { return includes([0], 0, thrower); }, RangeError, 'fromIndex conversion throws'); + st.end(); + }); + + et.test('ToLength', function (st) { + st.throws(function () { return includes({ length: thrower, 0: true }, true); }, RangeError, 'ToLength conversion throws'); + st.end(); + }); + + et.end(); + }); + + t.test('arraylike', function (st) { + st.equal(true, includes(sparseish, 'a'), 'sparse array-like object includes "a"'); + st.equal(false, includes(sparseish, 'c'), 'sparse array-like object does not include "c"'); + + st.equal(true, includes(overfullarrayish, 'b'), 'sparse array-like object includes "b"'); + st.equal(false, includes(overfullarrayish, 'c'), 'sparse array-like object does not include "c"'); + st.end(); + }); + + t.test('fromIndex', function (ft) { + ft.equal(true, includes([1], 1, NaN), 'NaN fromIndex -> 0 fromIndex'); + + ft.test('number coercion', function (st) { + st.equal(false, includes(['a', 'b', 'c'], 'a', numberish), 'does not find "a" with object fromIndex coercing to 2'); + st.equal(false, includes(['a', 'b', 'c'], 'a', '2'), 'does not find "a" with string fromIndex coercing to 2'); + st.equal(true, includes(['a', 'b', 'c'], 'c', numberish), 'finds "c" with object fromIndex coercing to 2'); + st.equal(true, includes(['a', 'b', 'c'], 'c', '2'), 'finds "c" with string fromIndex coercing to 2'); + st.end(); + }); + + ft.test('fromIndex greater than length', function (st) { + st.equal(false, includes([1], 1, 2), 'array of length 1 is not searched if fromIndex is > 1'); + st.equal(false, includes([1], 1, 1), 'array of length 1 is not searched if fromIndex is >= 1'); + st.equal(false, includes([1], 1, 1.1), 'array of length 1 is not searched if fromIndex is 1.1'); + st.equal(false, includes([1], 1, Infinity), 'array of length 1 is not searched if fromIndex is Infinity'); + st.end(); + }); + + ft.test('negative fromIndex', function (st) { + st.equal(true, includes([1, 3], 1, -4), 'computed length would be negative; fromIndex is thus 0'); + st.equal(true, includes([1, 3], 3, -4), 'computed length would be negative; fromIndex is thus 0'); + st.equal(true, includes([1, 3], 1, -Infinity), 'computed length would be negative; fromIndex is thus 0'); + + st.equal(true, includes([12, 13], 13, -1), 'finds -1st item with -1 fromIndex'); + st.equal(false, includes([12, 13], 12, -1), 'does not find -2nd item with -1 fromIndex'); + st.equal(true, includes([12, 13], 13, -2), 'finds -2nd item with -2 fromIndex'); + + st.equal(true, includes(sparseish, 'b', -4), 'finds -4th item with -4 fromIndex'); + st.equal(false, includes(sparseish, 'a', -4), 'does not find -5th item with -4 fromIndex'); + st.equal(true, includes(sparseish, 'a', -5), 'finds -5th item with -5 fromIndex'); + st.end(); + }); + + ft.end(); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/index.js new file mode 100644 index 0000000..cbe9288 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/index.js @@ -0,0 +1,116 @@ +'use strict'; +var escapeStringRegexp = require('escape-string-regexp'); +var ansiStyles = require('ansi-styles'); +var stripAnsi = require('strip-ansi'); +var hasAnsi = require('has-ansi'); +var supportsColor = require('supports-color'); +var defineProps = Object.defineProperties; +var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM); + +function Chalk(options) { + // detect mode if not set manually + this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled; +} + +// use bright blue on Windows as the normal blue color is illegible +if (isSimpleWindowsTerm) { + ansiStyles.blue.open = '\u001b[94m'; +} + +var styles = (function () { + var ret = {}; + + Object.keys(ansiStyles).forEach(function (key) { + ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); + + ret[key] = { + get: function () { + return build.call(this, this._styles.concat(key)); + } + }; + }); + + return ret; +})(); + +var proto = defineProps(function chalk() {}, styles); + +function build(_styles) { + var builder = function builder() { + return applyStyle.apply(builder, arguments); + }; + + builder._styles = _styles; + builder.enabled = this.enabled; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + /*eslint no-proto: 0 */ + builder.__proto__ = proto; + + return builder; +} + +function applyStyle() { + // support varags, but simply cast to string in case there's only one arg + var args = arguments; + var argsLen = args.length; + var str = argsLen !== 0 && String(arguments[0]); + + if (argsLen > 1) { + // don't slice `arguments`, it prevents v8 optimizations + for (var a = 1; a < argsLen; a++) { + str += ' ' + args[a]; + } + } + + if (!this.enabled || !str) { + return str; + } + + var nestedStyles = this._styles; + var i = nestedStyles.length; + + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, + // see https://github.com/chalk/chalk/issues/58 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. + var originalDim = ansiStyles.dim.open; + if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) { + ansiStyles.dim.open = ''; + } + + while (i--) { + var code = ansiStyles[nestedStyles[i]]; + + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + str = code.open + str.replace(code.closeRe, code.open) + code.close; + } + + // Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue. + ansiStyles.dim.open = originalDim; + + return str; +} + +function init() { + var ret = {}; + + Object.keys(styles).forEach(function (name) { + ret[name] = { + get: function () { + return build.call(this, [name]); + } + }; + }); + + return ret; +} + +defineProps(Chalk.prototype, init()); + +module.exports = new Chalk(); +module.exports.styles = ansiStyles; +module.exports.hasColor = hasAnsi; +module.exports.stripColor = stripAnsi; +module.exports.supportsColor = supportsColor; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/index.js new file mode 100644 index 0000000..7894527 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/index.js @@ -0,0 +1,65 @@ +'use strict'; + +function assembleStyles () { + var styles = { + modifiers: { + reset: [0, 0], + bold: [1, 22], // 21 isn't widely supported and 22 does the same thing + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + colors: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39] + }, + bgColors: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49] + } + }; + + // fix humans + styles.colors.grey = styles.colors.gray; + + Object.keys(styles).forEach(function (groupName) { + var group = styles[groupName]; + + Object.keys(group).forEach(function (styleName) { + var style = group[styleName]; + + styles[styleName] = group[styleName] = { + open: '\u001b[' + style[0] + 'm', + close: '\u001b[' + style[1] + 'm' + }; + }); + + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); + }); + + return styles; +} + +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/package.json new file mode 100644 index 0000000..526281a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/package.json @@ -0,0 +1,79 @@ +{ + "name": "ansi-styles", + "version": "2.1.0", + "description": "ANSI escape codes for styling strings in the terminal", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/chalk/ansi-styles" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "index.js" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "log", + "logging", + "command-line", + "text" + ], + "devDependencies": { + "mocha": "*" + }, + "gitHead": "18421cbe4a2d93359ec2599a894f704be126d066", + "bugs": { + "url": "https://github.com/chalk/ansi-styles/issues" + }, + "homepage": "https://github.com/chalk/ansi-styles", + "_id": "ansi-styles@2.1.0", + "_shasum": "990f747146927b559a932bf92959163d60c0d0e2", + "_from": "ansi-styles@>=2.1.0 <3.0.0", + "_npmVersion": "2.10.1", + "_nodeVersion": "0.12.4", + "_npmUser": { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + }, + "dist": { + "shasum": "990f747146927b559a932bf92959163d60c0d0e2", + "tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/readme.md new file mode 100644 index 0000000..3f933f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/ansi-styles/readme.md @@ -0,0 +1,86 @@ +# ansi-styles [](https://travis-ci.org/chalk/ansi-styles) + +> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal + +You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. + + + + +## Install + +``` +$ npm install --save ansi-styles +``` + + +## Usage + +```js +var ansi = require('ansi-styles'); + +console.log(ansi.green.open + 'Hello world!' + ansi.green.close); +``` + + +## API + +Each style has an `open` and `close` property. + + +## Styles + +### Modifiers + +- `reset` +- `bold` +- `dim` +- `italic` *(not widely supported)* +- `underline` +- `inverse` +- `hidden` +- `strikethrough` *(not widely supported)* + +### Colors + +- `black` +- `red` +- `green` +- `yellow` +- `blue` +- `magenta` +- `cyan` +- `white` +- `gray` + +### Background colors + +- `bgBlack` +- `bgRed` +- `bgGreen` +- `bgYellow` +- `bgBlue` +- `bgMagenta` +- `bgCyan` +- `bgWhite` + + +## Advanced usage + +By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. + +- `ansi.modifiers` +- `ansi.colors` +- `ansi.bgColors` + + +###### Example + +```js +console.log(ansi.colors.green.open); +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/index.js new file mode 100644 index 0000000..ac6572c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/index.js @@ -0,0 +1,11 @@ +'use strict'; + +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; + +module.exports = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + + return str.replace(matchOperatorsRe, '\\$&'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/package.json new file mode 100644 index 0000000..749f5de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/package.json @@ -0,0 +1,70 @@ +{ + "name": "escape-string-regexp", + "version": "1.0.3", + "description": "Escape RegExp special characters", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/escape-string-regexp" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.8.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "index.js" + ], + "keywords": [ + "regex", + "regexp", + "re", + "regular", + "expression", + "escape", + "string", + "str", + "special", + "characters" + ], + "devDependencies": { + "mocha": "*" + }, + "gitHead": "1e446e6b4449b5f1f8868cd31bf8fd25ee37fb4b", + "bugs": { + "url": "https://github.com/sindresorhus/escape-string-regexp/issues" + }, + "homepage": "https://github.com/sindresorhus/escape-string-regexp", + "_id": "escape-string-regexp@1.0.3", + "_shasum": "9e2d8b25bc2555c3336723750e03f099c2735bb5", + "_from": "escape-string-regexp@>=1.0.2 <2.0.0", + "_npmVersion": "2.1.16", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + }, + "dist": { + "shasum": "9e2d8b25bc2555c3336723750e03f099c2735bb5", + "tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/readme.md new file mode 100644 index 0000000..808a963 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/escape-string-regexp/readme.md @@ -0,0 +1,27 @@ +# escape-string-regexp [](https://travis-ci.org/sindresorhus/escape-string-regexp) + +> Escape RegExp special characters + + +## Install + +```sh +$ npm install --save escape-string-regexp +``` + + +## Usage + +```js +var escapeStringRegexp = require('escape-string-regexp'); + +var escapedString = escapeStringRegexp('how much $ for a unicorn?'); +//=> how much \$ for a unicorn\? + +new RegExp(escapedString); +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/index.js new file mode 100644 index 0000000..98fae06 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/index.js @@ -0,0 +1,4 @@ +'use strict'; +var ansiRegex = require('ansi-regex'); +var re = new RegExp(ansiRegex().source); // remove the `g` flag +module.exports = re.test.bind(re); diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/index.js new file mode 100644 index 0000000..4906755 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/index.js @@ -0,0 +1,4 @@ +'use strict'; +module.exports = function () { + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json new file mode 100644 index 0000000..d039d1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json @@ -0,0 +1,85 @@ +{ + "name": "ansi-regex", + "version": "2.0.0", + "description": "Regular expression for matching ANSI escape codes", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/ansi-regex" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha test/test.js", + "view-supported": "node test/viewCodes.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern" + ], + "devDependencies": { + "mocha": "*" + }, + "gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f", + "bugs": { + "url": "https://github.com/sindresorhus/ansi-regex/issues" + }, + "homepage": "https://github.com/sindresorhus/ansi-regex", + "_id": "ansi-regex@2.0.0", + "_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "_from": "ansi-regex@>=2.0.0 <3.0.0", + "_npmVersion": "2.11.2", + "_nodeVersion": "0.12.5", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "dist": { + "shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/readme.md new file mode 100644 index 0000000..1a4894e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/readme.md @@ -0,0 +1,31 @@ +# ansi-regex [](https://travis-ci.org/sindresorhus/ansi-regex) + +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save ansi-regex +``` + + +## Usage + +```js +var ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001b[4mcake\u001b[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001b[4mcake\u001b[0m'.match(ansiRegex()); +//=> ['\u001b[4m', '\u001b[0m'] +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/package.json new file mode 100644 index 0000000..54fe84e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/package.json @@ -0,0 +1,84 @@ +{ + "name": "has-ansi", + "version": "2.0.0", + "description": "Check if a string has ANSI escape codes", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/has-ansi" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "node test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "string", + "tty", + "escape", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern", + "has" + ], + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "devDependencies": { + "ava": "0.0.4" + }, + "gitHead": "0722275e1bef139fcd09137da6e5550c3cd368b9", + "bugs": { + "url": "https://github.com/sindresorhus/has-ansi/issues" + }, + "homepage": "https://github.com/sindresorhus/has-ansi", + "_id": "has-ansi@2.0.0", + "_shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91", + "_from": "has-ansi@>=2.0.0 <3.0.0", + "_npmVersion": "2.11.2", + "_nodeVersion": "0.12.5", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "dist": { + "shasum": "34f5049ce1ecdf2b0649af3ef24e45ed35416d91", + "tarball": "http://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/readme.md new file mode 100644 index 0000000..02bc7c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/has-ansi/readme.md @@ -0,0 +1,36 @@ +# has-ansi [](https://travis-ci.org/sindresorhus/has-ansi) + +> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save has-ansi +``` + + +## Usage + +```js +var hasAnsi = require('has-ansi'); + +hasAnsi('\u001b[4mcake\u001b[0m'); +//=> true + +hasAnsi('cake'); +//=> false +``` + + +## Related + +- [has-ansi-cli](https://github.com/sindresorhus/has-ansi-cli) - CLI for this module +- [strip-ansi](https://github.com/sindresorhus/strip-ansi) - Strip ANSI escape codes +- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes +- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/index.js new file mode 100644 index 0000000..099480f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/index.js @@ -0,0 +1,6 @@ +'use strict'; +var ansiRegex = require('ansi-regex')(); + +module.exports = function (str) { + return typeof str === 'string' ? str.replace(ansiRegex, '') : str; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/index.js new file mode 100644 index 0000000..4906755 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/index.js @@ -0,0 +1,4 @@ +'use strict'; +module.exports = function () { + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json new file mode 100644 index 0000000..d039d1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json @@ -0,0 +1,85 @@ +{ + "name": "ansi-regex", + "version": "2.0.0", + "description": "Regular expression for matching ANSI escape codes", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/ansi-regex" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha test/test.js", + "view-supported": "node test/viewCodes.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern" + ], + "devDependencies": { + "mocha": "*" + }, + "gitHead": "57c3f2941a73079fa8b081e02a522e3d29913e2f", + "bugs": { + "url": "https://github.com/sindresorhus/ansi-regex/issues" + }, + "homepage": "https://github.com/sindresorhus/ansi-regex", + "_id": "ansi-regex@2.0.0", + "_shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "_from": "ansi-regex@>=2.0.0 <3.0.0", + "_npmVersion": "2.11.2", + "_nodeVersion": "0.12.5", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "dist": { + "shasum": "c5061b6e0ef8a81775e50f5d66151bf6bf371107", + "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/readme.md new file mode 100644 index 0000000..1a4894e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/readme.md @@ -0,0 +1,31 @@ +# ansi-regex [](https://travis-ci.org/sindresorhus/ansi-regex) + +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save ansi-regex +``` + + +## Usage + +```js +var ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001b[4mcake\u001b[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001b[4mcake\u001b[0m'.match(ansiRegex()); +//=> ['\u001b[4m', '\u001b[0m'] +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/package.json new file mode 100644 index 0000000..9331056 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/package.json @@ -0,0 +1,84 @@ +{ + "name": "strip-ansi", + "version": "3.0.0", + "description": "Strip ANSI escape codes", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/strip-ansi" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "node test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "strip", + "trim", + "remove", + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "log", + "logging", + "command-line", + "text" + ], + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "devDependencies": { + "ava": "0.0.4" + }, + "gitHead": "3f05b9810e1438f946e2eb84ee854cc00b972e9e", + "bugs": { + "url": "https://github.com/sindresorhus/strip-ansi/issues" + }, + "homepage": "https://github.com/sindresorhus/strip-ansi", + "_id": "strip-ansi@3.0.0", + "_shasum": "7510b665567ca914ccb5d7e072763ac968be3724", + "_from": "strip-ansi@>=3.0.0 <4.0.0", + "_npmVersion": "2.11.2", + "_nodeVersion": "0.12.5", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "dist": { + "shasum": "7510b665567ca914ccb5d7e072763ac968be3724", + "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/readme.md new file mode 100644 index 0000000..7609151 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/strip-ansi/readme.md @@ -0,0 +1,33 @@ +# strip-ansi [](https://travis-ci.org/sindresorhus/strip-ansi) + +> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install --save strip-ansi +``` + + +## Usage + +```js +var stripAnsi = require('strip-ansi'); + +stripAnsi('\u001b[4mcake\u001b[0m'); +//=> 'cake' +``` + + +## Related + +- [strip-ansi-cli](https://github.com/sindresorhus/strip-ansi-cli) - CLI for this module +- [has-ansi](https://github.com/sindresorhus/has-ansi) - Check if a string has ANSI escape codes +- [ansi-regex](https://github.com/sindresorhus/ansi-regex) - Regular expression for matching ANSI escape codes +- [chalk](https://github.com/sindresorhus/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/index.js b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/index.js new file mode 100644 index 0000000..4346e27 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/index.js @@ -0,0 +1,50 @@ +'use strict'; +var argv = process.argv; + +var terminator = argv.indexOf('--'); +var hasFlag = function (flag) { + flag = '--' + flag; + var pos = argv.indexOf(flag); + return pos !== -1 && (terminator !== -1 ? pos < terminator : true); +}; + +module.exports = (function () { + if ('FORCE_COLOR' in process.env) { + return true; + } + + if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false')) { + return false; + } + + if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + return true; + } + + if (process.stdout && !process.stdout.isTTY) { + return false; + } + + if (process.platform === 'win32') { + return true; + } + + if ('COLORTERM' in process.env) { + return true; + } + + if (process.env.TERM === 'dumb') { + return false; + } + + if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { + return true; + } + + return false; +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/license b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/package.json new file mode 100644 index 0000000..281f3e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/package.json @@ -0,0 +1,78 @@ +{ + "name": "supports-color", + "version": "2.0.0", + "description": "Detect whether a terminal supports color", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/chalk/supports-color" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + } + ], + "engines": { + "node": ">=0.8.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "index.js" + ], + "keywords": [ + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "ansi", + "styles", + "tty", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "support", + "supports", + "capability", + "detect" + ], + "devDependencies": { + "mocha": "*", + "require-uncached": "^1.0.2" + }, + "gitHead": "8400d98ade32b2adffd50902c06d9e725a5c6588", + "bugs": { + "url": "https://github.com/chalk/supports-color/issues" + }, + "homepage": "https://github.com/chalk/supports-color", + "_id": "supports-color@2.0.0", + "_shasum": "535d045ce6b6363fa40117084629995e9df324c7", + "_from": "supports-color@>=2.0.0 <3.0.0", + "_npmVersion": "2.11.2", + "_nodeVersion": "0.12.5", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "dist": { + "shasum": "535d045ce6b6363fa40117084629995e9df324c7", + "tarball": "http://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/readme.md new file mode 100644 index 0000000..b4761f1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/node_modules/supports-color/readme.md @@ -0,0 +1,36 @@ +# supports-color [](https://travis-ci.org/chalk/supports-color) + +> Detect whether a terminal supports color + + +## Install + +``` +$ npm install --save supports-color +``` + + +## Usage + +```js +var supportsColor = require('supports-color'); + +if (supportsColor) { + console.log('Terminal supports color'); +} +``` + +It obeys the `--color` and `--no-color` CLI flags. + +For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`. + + +## Related + +- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module +- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/package.json b/JavaScript/node_modules/johnny-five/node_modules/chalk/package.json new file mode 100644 index 0000000..c0b9dcd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/package.json @@ -0,0 +1,95 @@ +{ + "name": "chalk", + "version": "1.1.0", + "description": "Terminal string styling done right. Much color.", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/chalk/chalk" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + }, + { + "name": "unicorn", + "email": "sindresorhus+unicorn@gmail.com" + } + ], + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha", + "bench": "matcha benchmark.js", + "coverage": "nyc npm test && nyc report", + "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls" + }, + "files": [ + "index.js" + ], + "keywords": [ + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "str", + "ansi", + "style", + "styles", + "tty", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "log", + "logging", + "command-line", + "text" + ], + "dependencies": { + "ansi-styles": "^2.1.0", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "devDependencies": { + "coveralls": "^2.11.2", + "matcha": "^0.6.0", + "mocha": "*", + "nyc": "^3.0.0", + "require-uncached": "^1.0.2", + "resolve-from": "^1.0.0", + "semver": "^4.3.3" + }, + "gitHead": "e9bb6e6000b1c5d4508afabfdc85dd70f582f515", + "bugs": { + "url": "https://github.com/chalk/chalk/issues" + }, + "homepage": "https://github.com/chalk/chalk", + "_id": "chalk@1.1.0", + "_shasum": "09b453cec497a75520e4a60ae48214a8700e0921", + "_from": "chalk@latest", + "_npmVersion": "2.10.1", + "_nodeVersion": "0.12.4", + "_npmUser": { + "name": "jbnicolai", + "email": "jappelman@xebia.com" + }, + "dist": { + "shasum": "09b453cec497a75520e4a60ae48214a8700e0921", + "tarball": "http://registry.npmjs.org/chalk/-/chalk-1.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/chalk/readme.md b/JavaScript/node_modules/johnny-five/node_modules/chalk/readme.md new file mode 100644 index 0000000..f757e59 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/chalk/readme.md @@ -0,0 +1,212 @@ + + + + + + + + + +> Terminal string styling done right + +[](https://travis-ci.org/chalk/chalk) +[](https://coveralls.io/r/chalk/chalk?branch=master) +[](https://www.youtube.com/watch?v=9auOCbH5Ns4) + + +[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough. + +**Chalk is a clean and focused alternative.** + + + + +## Why + +- Highly performant +- Doesn't extend `String.prototype` +- Expressive API +- Ability to nest styles +- Clean and focused +- Auto-detects color support +- Actively maintained +- [Used by ~4000 modules](https://www.npmjs.com/browse/depended/chalk) as of May 24, 2015 + + +## Install + +``` +$ npm install --save chalk +``` + + +## Usage + +Chalk comes with an easy to use composable API where you just chain and nest the styles you want. + +```js +var chalk = require('chalk'); + +// style a string +chalk.blue('Hello world!'); + +// combine styled and normal strings +chalk.blue('Hello') + 'World' + chalk.red('!'); + +// compose multiple styles using the chainable API +chalk.blue.bgRed.bold('Hello world!'); + +// pass in multiple arguments +chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'); + +// nest styles +chalk.red('Hello', chalk.underline.bgBlue('world') + '!'); + +// nest styles of the same type even (color, underline, background) +chalk.green( + 'I am a green line ' + + chalk.blue.underline.bold('with a blue substring') + + ' that becomes green again!' +); +``` + +Easily define your own themes. + +```js +var chalk = require('chalk'); +var error = chalk.bold.red; +console.log(error('Error!')); +``` + +Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data). + +```js +var name = 'Sindre'; +console.log(chalk.green('Hello %s'), name); +//=> Hello Sindre +``` + + +## API + +### chalk.` + + + + + + \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/ease-component/index.js b/JavaScript/node_modules/johnny-five/node_modules/ease-component/index.js new file mode 100644 index 0000000..4516199 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/ease-component/index.js @@ -0,0 +1,170 @@ + +// easing functions from "Tween.js" + +exports.linear = function(n){ + return n; +}; + +exports.inQuad = function(n){ + return n * n; +}; + +exports.outQuad = function(n){ + return n * (2 - n); +}; + +exports.inOutQuad = function(n){ + n *= 2; + if (n < 1) return 0.5 * n * n; + return - 0.5 * (--n * (n - 2) - 1); +}; + +exports.inCube = function(n){ + return n * n * n; +}; + +exports.outCube = function(n){ + return --n * n * n + 1; +}; + +exports.inOutCube = function(n){ + n *= 2; + if (n < 1) return 0.5 * n * n * n; + return 0.5 * ((n -= 2 ) * n * n + 2); +}; + +exports.inQuart = function(n){ + return n * n * n * n; +}; + +exports.outQuart = function(n){ + return 1 - (--n * n * n * n); +}; + +exports.inOutQuart = function(n){ + n *= 2; + if (n < 1) return 0.5 * n * n * n * n; + return -0.5 * ((n -= 2) * n * n * n - 2); +}; + +exports.inQuint = function(n){ + return n * n * n * n * n; +} + +exports.outQuint = function(n){ + return --n * n * n * n * n + 1; +} + +exports.inOutQuint = function(n){ + n *= 2; + if (n < 1) return 0.5 * n * n * n * n * n; + return 0.5 * ((n -= 2) * n * n * n * n + 2); +}; + +exports.inSine = function(n){ + return 1 - Math.cos(n * Math.PI / 2 ); +}; + +exports.outSine = function(n){ + return Math.sin(n * Math.PI / 2); +}; + +exports.inOutSine = function(n){ + return .5 * (1 - Math.cos(Math.PI * n)); +}; + +exports.inExpo = function(n){ + return 0 == n ? 0 : Math.pow(1024, n - 1); +}; + +exports.outExpo = function(n){ + return 1 == n ? n : 1 - Math.pow(2, -10 * n); +}; + +exports.inOutExpo = function(n){ + if (0 == n) return 0; + if (1 == n) return 1; + if ((n *= 2) < 1) return .5 * Math.pow(1024, n - 1); + return .5 * (-Math.pow(2, -10 * (n - 1)) + 2); +}; + +exports.inCirc = function(n){ + return 1 - Math.sqrt(1 - n * n); +}; + +exports.outCirc = function(n){ + return Math.sqrt(1 - (--n * n)); +}; + +exports.inOutCirc = function(n){ + n *= 2 + if (n < 1) return -0.5 * (Math.sqrt(1 - n * n) - 1); + return 0.5 * (Math.sqrt(1 - (n -= 2) * n) + 1); +}; + +exports.inBack = function(n){ + var s = 1.70158; + return n * n * (( s + 1 ) * n - s); +}; + +exports.outBack = function(n){ + var s = 1.70158; + return --n * n * ((s + 1) * n + s) + 1; +}; + +exports.inOutBack = function(n){ + var s = 1.70158 * 1.525; + if ( ( n *= 2 ) < 1 ) return 0.5 * ( n * n * ( ( s + 1 ) * n - s ) ); + return 0.5 * ( ( n -= 2 ) * n * ( ( s + 1 ) * n + s ) + 2 ); +}; + +exports.inBounce = function(n){ + return 1 - exports.outBounce(1 - n); +}; + +exports.outBounce = function(n){ + if ( n < ( 1 / 2.75 ) ) { + return 7.5625 * n * n; + } else if ( n < ( 2 / 2.75 ) ) { + return 7.5625 * ( n -= ( 1.5 / 2.75 ) ) * n + 0.75; + } else if ( n < ( 2.5 / 2.75 ) ) { + return 7.5625 * ( n -= ( 2.25 / 2.75 ) ) * n + 0.9375; + } else { + return 7.5625 * ( n -= ( 2.625 / 2.75 ) ) * n + 0.984375; + } +}; + +exports.inOutBounce = function(n){ + if (n < .5) return exports.inBounce(n * 2) * .5; + return exports.outBounce(n * 2 - 1) * .5 + .5; +}; + +// aliases + +exports['in-quad'] = exports.inQuad; +exports['out-quad'] = exports.outQuad; +exports['in-out-quad'] = exports.inOutQuad; +exports['in-cube'] = exports.inCube; +exports['out-cube'] = exports.outCube; +exports['in-out-cube'] = exports.inOutCube; +exports['in-quart'] = exports.inQuart; +exports['out-quart'] = exports.outQuart; +exports['in-out-quart'] = exports.inOutQuart; +exports['in-quint'] = exports.inQuint; +exports['out-quint'] = exports.outQuint; +exports['in-out-quint'] = exports.inOutQuint; +exports['in-sine'] = exports.inSine; +exports['out-sine'] = exports.outSine; +exports['in-out-sine'] = exports.inOutSine; +exports['in-expo'] = exports.inExpo; +exports['out-expo'] = exports.outExpo; +exports['in-out-expo'] = exports.inOutExpo; +exports['in-circ'] = exports.inCirc; +exports['out-circ'] = exports.outCirc; +exports['in-out-circ'] = exports.inOutCirc; +exports['in-back'] = exports.inBack; +exports['out-back'] = exports.outBack; +exports['in-out-back'] = exports.inOutBack; +exports['in-bounce'] = exports.inBounce; +exports['out-bounce'] = exports.outBounce; +exports['in-out-bounce'] = exports.inOutBounce; diff --git a/JavaScript/node_modules/johnny-five/node_modules/ease-component/package.json b/JavaScript/node_modules/johnny-five/node_modules/ease-component/package.json new file mode 100644 index 0000000..b45544b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/ease-component/package.json @@ -0,0 +1,39 @@ +{ + "name": "ease-component", + "description": "Easing functions (for canvas etc)", + "version": "1.0.0", + "keywords": [ + "ease", + "easing", + "tween" + ], + "dependencies": {}, + "component": { + "scripts": { + "ease/index.js": "index.js" + } + }, + "license": "MIT", + "readme": "\n# ease\n\n Easing functions (for canvas etc)\n\n - linear\n - inQuad\n - outQuad\n - inOutQuad\n - inCube\n - outCube\n - inOutCube\n - inQuart\n - outQuart\n - inOutQuart\n - inQuint\n - outQuint\n - inOutQuint\n - inSine\n - outSine\n - inOutSine\n - inExpo\n - outExpo\n - inOutExpo\n - inCirc\n - outCirc\n - inOutCirc\n - inBack\n - outBack\n - inOutBack\n - inBounce\n - outBounce\n - inOutBounce\n\n## Aliases\n\n - in-quad\n - out-quad\n - in-out-quad\n - in-cube\n - out-cube\n - in-out-cube\n - in-quart\n - out-quart\n - in-out-quart\n - in-quint\n - out-quint\n - in-out-quint\n - in-sine\n - out-sine\n - in-out-sine\n - in-expo\n - out-expo\n - in-out-expo\n - in-circ\n - out-circ\n - in-out-circ\n - in-back\n - out-back\n - in-out-back\n - in-bounce\n - out-bounce\n - in-out-bounce\n\n## Example\n\n```js\nvar ease = require('ease');\nvar requestAnimationFrame = require('raf');\nvar canvas = document.querySelector('canvas');\nvar ctx = canvas.getContext('2d');\n\nvar stop = false;\nfunction animate() {\n if (stop) return;\n requestAnimationFrame(animate);\n draw();\n}\n\nvar startx = 20;\nvar x = startx;\nvar destx = 300;\nvar y = 400 / 2;\nvar duration = 1000;\nvar start = Date.now();\nvar end = start + duration;\n\nfunction draw() {\n var now = Date.now();\n if (now - start >= duration) stop = true;\n var p = (now - start) / duration;\n val = ease.inOutBounce(p);\n x = startx + (destx - startx) * val;\n canvas.width = canvas.width;\n ctx.fillStyle = 'red';\n ctx.arc(x, y, 10, 0, Math.PI * 2, false);\n ctx.fill();\n}\n\nanimate();\n\n```\n\n# License\n\n MIT\n", + "readmeFilename": "Readme.md", + "_id": "ease-component@1.0.0", + "dist": { + "shasum": "b375726db0b5b04595b77440396fec7daa5d77c9", + "tarball": "http://registry.npmjs.org/ease-component/-/ease-component-1.0.0.tgz" + }, + "_from": "ease-component@latest", + "_npmVersion": "1.2.14", + "_npmUser": { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "directories": {}, + "_shasum": "b375726db0b5b04595b77440396fec7daa5d77c9", + "_resolved": "https://registry.npmjs.org/ease-component/-/ease-component-1.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jscs.json b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jscs.json new file mode 100644 index 0000000..7b757e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jscs.json @@ -0,0 +1,104 @@ +{ + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": "allButReserved", + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": true, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 10 + }, + + "requirePaddingNewLinesAfterUseStrict": true +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jshintrc new file mode 100644 index 0000000..d8c9896 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.jshintrc @@ -0,0 +1,4 @@ +{ + "es3": true, + "esnext": true +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.npmignore new file mode 100644 index 0000000..d681c02 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/.npmignore @@ -0,0 +1,7 @@ +.DS_Store +node_modules/ +test/ +components +build +.travis.yml +testling.html diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/CHANGELOG.md new file mode 100644 index 0000000..deb29d3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/CHANGELOG.md @@ -0,0 +1,381 @@ +# es6-shim x.x.x (not yet released) + +# es6-shim 0.32.2 (17 Jun 2015) +* [Fix] `Object.assign` with no sources should coerce to an object (#348) +* [Fix] `String#includes` should throw when given a `RegExp` (#349) +* [Fix] `RegExp()` should not throw (#350) +* [Fix] Create `Value.defineByDescriptor`, fix `create` when `Object.create` is unavailable. +* [Compliance] Update `Promise.reject` to match official ECMA-262 spec. +* [Dev Deps] Update `es5-shim` + +# es6-shim 0.32.1 (13 Jun 2015) +* [Fix] Make sure that all `Map`/`Set` shim forms properly add an iterable to the collection instance. +* [Tests] Make sure none of the `Array` ToLength tests throw *any* error (#347) + +# es6-shim 0.32.0 (7 Jun 2015) +* [Spec compliance] Update Promises to match finalized ES6 spec (#345, #344, #239) +* [Fix] Ensure `Map`, `Set`, and `Promise` shims all throw when used without "new". +* [Tests] Fix the pending exceptions test for Safari 5.1 +* [Refactor] Since the String HTML shims will be iterated anyways, no need to defineProperties them twice. +* [Deps] Update `chai`, `es5-shim` + +# es6-shim 0.31.3 (2 Jun 2015) +* [Fix] Properly name more shim functions +* [Fix] Fix an IE bug where the layout engine internally calls the userland `Object.getOwnPropertyNames` +* [Fix] Ensure `Map.prototype[Symbol.iterator] === Map.prototype.entries` +* [Fix] Ensure `Set.prototype[Symbol.iterator] === Set.prototype.values` +* [Tests] `Object.assign` pending exceptions: IE 9 `preventExtensions` doesn't throw, even in strict mode +* [Security] Cache more native methods in case they're overwritten later +* [Tests] IE 11 has native `Map`/`Set`, but it takes an optional *function*, not an optional iterable, in the constructor +* [Tests] Add more "exists" early bailouts, to declutter native test results +* [Docs] Alphabetize shim lists in the README +* [Perf] Add more `Map`/`Set` fast paths for more primitives: boolean, null, undefined +* [Tests] Test up to `io.js` `v2.2` +* [Deps] Update `mocha`, `es5-shim`, `uglify-js`, `jshint` +* [Refactor] Style cleanups + +# es6-shim 0.31.2 (9 May 2015) +* Fix ES5 `Array.prototype` method wrappers to return the correct value. (#341) + +# es6-shim 0.31.1 (7 May 2015) +* `RegExp` should work properly as a wrapper (#340) + +# es6-shim 0.31.0 (1 May 2015) +* All Array.prototype methods should use `ToLength`, not `ToUint32`, on `this.length`. +* Preserve and use original Array.prototype functions (for later shimming) +* Make String#{startsWith, endsWith, includes} tests a bit more granular. +* Fix Map/Set invalid receiver error messages for WebKit +* Update `grunt-saucelabs`, `jscs` + +# es6-shim 0.30.0 (26 Apr 2015) +* `Map` and `Set` methods are not generic, and must only be called on valid `Map` and `Set` objects. +* Use the native `Number#clz` (in Safari 8, eg) inside `Math.clz32` + +# es6-shim 0.29.0 (26 Apr 2015) +* Test on `io.js` `v1.7` and `v1.8` +* Ensure that shallowly wrapped Maps’ and Sets’ prototypes aren't one level too far away. +* Update `chai` and use new matchers +* Avoid reassigning argument variables to avoid deoptimizations +* Ensure that ES3 browsers get both `Object.is` and `Object.assign` +* Improve `Object.assign` to avoid leaking arguments in v8 +* Ensuring `Number.parseInt === parseInt` (failed in FF 37) +* a little more accurate Math.cbrt (#335) +* Test cleanups +* Adding `Symbol.unscopables` tests +* Adding tests to ensure that default iterators on builtins === the appropriate prototype function. + +# es6-shim 0.28.2 (13 Apr 2015) +* `Map` and `Set` should have an arity of 0. + +# es6-shim 0.28.1 (12 Apr 2015) +* Ensure `Object.assign` only includes enumerable Symbols. + +# es6-shim 0.28.0 (12 Apr 2015) +* Ensure `Object.assign` also includes Symbols. +* Make sure to clobber Firefox 37's very slow native Object.assign, that has "pending exception" logic. +* Adding much more granular Set/Map acceptance tests and replacements, to preserve as much of the original implementation as possible. (#326, #328) +* Lots of test additions and cleanup + * Fill in (and fix) missing name, arity, and enumerability tests. + * Using `property` matcher for a more helpful failure message. + * Make sure this test doesn't fail if `Array#values` doesn't exist yet. + * Make this `@@iterator` test not depend on `Array#values`, and properly skip tests if the symbol isn't available. +* Update `Math.fround` with a much smaller implementation (#332) +* Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change. +* Update `es5-shim`, `mocha`, `grunt-contrib-connect`, `chai`, `jshint` +* IE 11 TP has a broken `String.raw` implementation +* Overwriting some imprecise Math functions on IE 11 TP. +* Overwrite `Math.imul` in Safari 8 to report the correct length. +* Fix Math.round for very large numbers +* Don't rely on shims in tests, for better native failure checking. +* Shim `Object.is` in ES3 environments, and add tests. +* Test the native `Object.assign` prior to shimming it. +* Tweak the `travis-ci` config to make a separate "lint only" test run. +* Fix Firefox 4 test failures: ensure RegExp global aliases starting with "$" exist. +* more efficient Math.clz32 (#327) +* Fix Webkit nightly bugs with `Array.from` and `Array.of`. +* Make sure shims that depend on `Number.isNaN` and `Number.isFinite` will always work. +* The latest Webkit nightly has a bug with `String#includes` and a position arg of `Infinity`. +* Webkit r181855 has a noncompliant `String#startsWith` and `String#endsWith` +* Clean up README; add more accurate note about `es5-shim`. +* Updating the `String.raw` code to be more in line with the changes in RC2/Rev 35 of the spec. + +# es6-shim 0.27.1 (5 Mar 2015) +* Revert `Array#slice` changes. (#322) +* Test on `io.js` `v1.4` + +# es6-shim 0.27.0 (26 Feb 2015) +* Overwrite `Array#slice` so that it supports Array subclasses. +* Improve `Map`/`Set` `TypeError` messages when called as a function. (#321) + +# es6-shim 0.26.1 (25 Feb 2015) +* Ensure `Array`/`Array.prototype` functions have the correct name. +* Chrome 40 defines the incorrect name for `Array#values` +* Make sure that `Array.of` works when subclassed. + +# es6-shim 0.26.0 (24 Feb 2015) +* Ensure that remaining Object static methods accept primitives. +* Update `chai` +* Document `String.prototype` HTML methods and `Reflect` methods in README + +# es6-shim 0.25.3 (22 Feb 2015) +* Removing nonexistent arguments from some String.prototype HTML methods +* All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. +* Test on `iojs-v1.3` +* Update `chai` +* Add a LICENSE file + +# es6-shim 0.25.2 (18 Feb 2015) +* If someone (looking at you, chalk) has previously modified String.prototype with a non-function “bold”, don‘t break. (#315) + +# es6-shim 0.25.1 (18 Feb 2015) +* Add Annex B String.prototype HTML methods. +* Overwriting Annex B String.prototype HTML methods in IE 9, which both uppercases the tag names, and fails to escape double quotes. +* Overwriting Annex B String.prototype HTML methods in Safari 4-5, which fails to escape double quotes. +* Ensuring that Date#toString returns “Invalid Date” when the date‘s value is NaN. +* Test on `iojs-v1.2` + +# es6-shim 0.25.0 (16 Feb 2015) +* Ensure Object.getOwnPropertyNames accepts primitives. +* Make sure the replaced `Object.keys` is non-enumerable. +* Clean up lots of tests to make failures easier to read, and false negatives less common + +# es6-shim 0.24.0 (5 Feb 2015) +* Improving accuracy of Math.expm1 values, and ensuring a shim on Linux FF 35, which reports an inaccurate value for Math.expm1(10). +* Fix bug from 7454db144e5aa251d599415cfb296b67aa3cf992 which prevented String#startsWith and String#endsWith from being overwritten in old Firefox. +* Improve tests across a wider list of browsers +* Ensure that individual Reflect methods are added when possible +* Add Reflect (#313) +* Fix node 0.11: it has an imprecise Math.sinh with very small numbers. +* Alter String#repeat RangeError message to align with Firefox’s native implementation. + +# es6-shim 0.23.0 (26 Jan 2015) +* Use Symbol.species when available, else fall back to "@@species" (renamed from "@@create") +* Fix `npm run test-native` +* Correct broken Math implementations: `log1p`, `exmp1`, `tanh`, `acosh`, `cosh`, `sinh`, `round` (#314) +* Update `jscs`, `grunt-saucelabs`, `jshint` + +# es6-shim 0.22.2 (4 Jan 2015) +* Faster travis-ci builds +* Better ES3 support: quoting/avoiding reserved words +* Update `mocha`, `jscs`, `jshint`, `grunt-saucelabs`, `uglify-js` + +# es6-shim 0.22.1 (13 Dec 2014) +* Make RegExp#flags generic, per spec (#310) + +# es6-shim 0.22.0 (12 Dec 2014) +* Add RegExp#flags +* Make `new RegExp` work with both a regex and a flags string +* Remove non-spec `Object.{getPropertyNames,getPropertyDescriptor}` + +# es6-shim 0.21.1 (4 Dec 2014) +* Promise/Promise.prototype methods, and String#{startsWith,endsWith} are now not enumerable +* Array#{keys, values, entries} should all be @@unscopeable in browsers that support that +* Ensure that tampering with Function#{call,apply} won’t break internal methods +* Add Math.clz32, RegExp tests +* Update es6-sham UMD +* Update `chai`, `es5-shim`, `grunt-saucelabs`, `jscs` + +# es6-shim 0.21.0 (21 Nov 2014) +* String#contains → String#includes per 2014-11-19 TC39 meeting +* Use an invalid identifier as the es6-shim iterator key, so it doesn’t show up in the console as easily. + +# es6-shim 0.20.4 (20 Nov 2014) +* Performance improvements: avoid slicing arguments, avoid `Function#call` when possible +* Name `String.{fromCodePoint,raw}` for debugging +* Fix `String.raw` to match spec +* Ensure Chrome’s excess Promise methods are purged +* Ensure `Set#keys === Set#values`, per spec + +# es6-shim 0.20.3 (19 Nov 2014) +* Fix Set#add and Map#set to always return "this" (#302) +* Clarify TypeError messages thrown by Map/Set +* Fix Chrome 38 bug with Array#values + +# es6-shim 0.20.2 (28 Oct 2014) +* Fix AMD (#299) + +# es6-shim 0.20.1 (27 Oct 2014) +* Set#delete and Map#delete should return false unless a deletion occurred. (#298) + +# es6-shim 0.20.0 (26 Oct 2014) +* Use a more reliable UMD +* export the global object rather than undefined + +# es6-shim 0.19.2 (25 Oct 2014) +* Set#delete and Map#delete should return a boolean indicating success. (#298) +* Make style consistent; add jscs + +# es6-shim 0.19.1 (14 Oct 2014) +* Fix Map#set and Set#add to be chainable (#295) +* Update mocha + +# es6-shim 0.19.0 (9 Oct 2014) +* Detect and override noncompliant Map in Firefox 32 (#294) +* Fix Map and Set for engines that don’t preserve numeric key order (#292, #290) +* Detect and override noncompliant Safari 7.1 Promises (#289) +* Fix Array#keys and Array#entries in Safari 7.1 +* General style and whitespace cleanup +* Update dependencies +* Clean up tests for ES3 by removing reserved words + +# es6-shim 0.18.0 (6 Sep 2014) +* Speed up String#trim replacement (#284) +* named Array#find and Array#findIndex for easier debugging +* Replace broken native implementation in Firefox 25-31 for Array#find and Array#findIndex +* Ensure String.fromCodePoint has the correct length in Firefox +* List the license in `package.json` for `npm` +* Array.from: fix spec bug with Array.from([], undefined) throwing +* Array.from: fix Firefox Array.from bug wrt swallowing negative lengths vs throwing + +# es6-shim 0.17.0 (31 Aug 2014) +* Added es6-sham (#281) +* Fixing some flaky tests (#268) +* Tweaking how ArrayIterator is checked in its "next" function +* Cleaning up some of the logic in Array.from + +# es6-shim 0.16.0 (6 Aug 2014) +* Array#find and Array#findIndex: no longer skips holes in sparse arrays, per https://bugs.ecmascript.org/show_bug.cgi?id=3107 + +# es6-shim 0.15.1 (5 Aug 2014) +* Array.from: now correctly throws if provided `undefined` as a mapper function +* Array.from: now correctly works if provided a falsy `thisArg` +* Fix tests so they work properly when Array#(values|keys|entries) are not present +* Add `npm run lint` to run style checks independently +* Add `test/native.html` so browsers can be easily checked for shim-less compliance. + +# es6-shim 0.15.0 (31 Jul 2014) +* Object.assign no longer throws on null or undefined sources, per https://bugs.ecmascript.org/show_bug.cgi?id=3096 + +# es6-shim 0.14.0 (20 Jul 2014) +* Properly recognize Symbol.iterator when it is present (#277) +* Fix Math.clz’s improper handling of values that coerce to NaN (#269) +* Fix incorrect handling of negative end index on Array#fill (#270) +* Removed Object.getOwnPropertyKeys, which shouldn’t be anywhere (#267) +* Fixed arity of Map and Set constructors, per 2014.04.27 draft spec (rev 24) +* Added a full additional suite of ES6 promise tests (thanks to @smikes!) (#265) +* Make Number.isInteger a bit more efficient (#266) +* Added `npm run test-native` to expose how broken implementations are without the shim ;-) +* Added additional tests + +# es6-shim 0.13.0 (11 Jun 2014) +* Adapt to new Array.from changes: mapper function is now called with both value and index (#261, #262) +* More reliably getting the global object in strict mode to fix node-webkit (#258, #259) +* Properly test the global Promise for ignoring non-function callbacks (#258) + +# es6-shim 0.12.0 (4 Jun 2014) +* Fix String#trim implementations that incorrectly trim \u0085 +* Stop relying on ArrayIterator being a public var, fixing Safari 8 + +# es6-shim 0.11.1 (2 Jun 2014) +* Make sure to shim Object.assign in all environments, not just true ES5 +* Now including minified file and source map + +# es6-shim 0.11.0 (11 May 2014) +* Remove `Object.getOwnPropertyDescriptors`, per spec. (#234, #235) +* IE8 fixes. (#163, #236) +* Improve `Promise` scheduling. (#231) +* Add some more standalone shims +* Use an Object.create fallback, for better ES3 compatibility +* Fix Math.expm1 in more browsers (#84) +* Fix es6-shim in Web Workers (#247, #248) +* Correct Object.assign to take multiple sources (#241) + +# es6-shim 0.10.1 (13 Mar 2014) +* Update bower.json, component.json, and .npmignore (#229, #230, #233) +* Minor updates to `Promise` implementation and test suite. +* Workaround lack of "strict mode" in IE9. (#232) + +# es6-shim 0.10.0 (1 March 2014) +* Implement `Promise`, per spec. (#209, #215, #224, #225) +* Make `Map`/`Set` subclassable; support `iterable` argument to + constructor (#218) +* Rename `Number#clz` to `Math.clz32` (#217) +* Bug fixes to `Array#find` and `Array#findIndex` on sparse arrays (#213) +* Re-add `Number.isInteger` (mistakenly removed in 0.9.0) +* Allow use of `arguments` as an iterable +* Minor spec-compliance fixes for `String.raw` +* In ES6, `Object.keys` accepts non-Object types (#220) +* Improved browser compatibility with IE 9/10, Opera 12 (#225) + +# es6-shim 0.9.3 (5 February 2014) +* Per spec, removed `Object.mixin` (#192) +* Per spec, treat -0 and +0 keys as identical in Map/Set (#129, #204) +* Per spec, `ArrayIterator`/`Array#values()` skips sparse indexes now. (#189) +* Added `Array.from`, supporting Map/Set/Array/String iterators (the String iterator iterates over codepoints, not indexes) (#182) +* Bug fixes to Map/Set iteration after concurrent delete. (#183) +* Bug fixes to `Number.clz`: 0 and 0x100000000 are handled correctly now. (#196) +* Added `Math.fround` to truncate to a 32-bit floating point number. (#140) +* Bug fix for `Math.cosh` (#178) +* Work around Firefox bugs in `String#startsWith` and `String#endsWith` (#172) +* Work around Safari bug in `Math.imul` + +# es6-shim 0.9.2 (18 December 2013) +* Negative `String#endsWith` position is now handled properly. +* `TypeError` is now thrown when string methods are called + on `null` / `undefined`. + +# es6-shim 0.9.1 (28 October 2013) +* Added `Array#copyWithin` and `Number.MIN_SAFE_INTEGER` +* Big speed-up of Maps / Sets for string / number keys: + they are O(1) now. +* Changed `Math.hypot` according to spec. +* Other small fixes. + +# es6-shim 0.9.0 (30 August 2013) +* Added Array iteration methods: `Array#keys`, `Array#values`, `Array#entries`, which return an `ArrayIterator` +* Changed `Map` and `Set` constructors to conform to spec when called without `new` +* Added `Math.imul` +* Per spec, removed `Number.toInteger`, `Number.isInteger`, and `Number.MAX_INTEGER`; added `Number.isSafeInteger`, `Number.MAX_SAFE_INTEGER` +* Added extensive additional tests for many methods + +# es6-shim 0.8.0 (8 June 2013) +* Added `Object.setPrototypeOf`, `Set#keys`, `Set#values`, `Map#keys`, `Map#values`, `Map#entries`, `Set#entries`. +* Fixed `String#repeat` according to spec. + +# es6-shim 0.7.0 (2 April 2013) +* Added `Array#find`, `Array#findIndex`, `Object.assign`, `Object.mixin`, + `Math.cbrt`, `String.fromCodePoint`, `String#codePointAt`. +* Removed `Object.isnt`. +* Made Math functions fully conform spec. + +# es6-shim 0.6.0 (15 January 2013) +* Added `Map#keys`, `Map#values`, `Map#size`, `Set#size`, `Set#clear`. + +# es6-shim 0.5.3 (2 September 2012) +* Made `String#startsWith`, `String#endsWith` fully conform spec. + +# es6-shim 0.5.2 (17 June 2012) +* Removed `String#toArray` and `Object.isObject` as per spec updates. + +# es6-shim 0.5.1 (14 June 2012) +* Made Map and Set follow Spidermonkey implementation instead of V8. +`var m = Map(); m.set('key', void 0); m.has('key');` now gives true. + +# es6-shim 0.5.0 (13 June 2012) +* Added Number.MAX_INTEGER, Number.EPSILON, Number.parseInt, +Number.parseFloat, Number.prototype.clz, Object.isObject. + +# es6-shim 0.4.1 (11 May 2012) +* Fixed boundary checking in Number.isInteger. + +# es6-shim 0.4.0 (8 February 2012) +* Added Math.log10, Math.log2, Math.log1p, Math.expm1, Math.cosh, +Math.sinh, Math.tanh, Math.acosh, Math.asinh, Math.atanh, Math.hypot, +Math.trunc. + +# es6-shim 0.3.1 (30 January 2012) +* Added IE8 support. + +# es6-shim 0.3.0 (27 January 2012) +* Added Number.isFinite() and Object.isnt(). + +# es6-shim 0.2.1 (7 January 2012) +* Fixed a bug in String#endsWith(). + +# es6-shim 0.2.0 (25 December 2011) +* Added browser support. +* Added tests. +* Added Math.sign(). + +# es6-shim 0.1.0 (25 December 2011) +* Initial release diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/Gruntfile.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/Gruntfile.js new file mode 100644 index 0000000..3704437 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/Gruntfile.js @@ -0,0 +1,100 @@ +module.exports = function (grunt) { + var browsers = [ + { browserName: "firefox", version: "19", platform: "XP" }, + { browserName: "firefox", platform: "linux" }, + { browserName: "firefox", platform: "OS X 10.10" }, + { browserName: "chrome", platform: "linux" }, + { browserName: "chrome", platform: "OS X 10.9" }, + { browserName: "chrome", platform: "XP" }, + { browserName: "internet explorer", platform: "Windows 8.1", version: "11" }, + { browserName: "internet explorer", platform: "WIN8", version: "10" }, + { browserName: "internet explorer", platform: "VISTA", version: "9" }, + { browserName: 'safari', platform: 'OS X 10.6' }, + { browserName: 'safari', platform: 'OS X 10.8' }, + { browserName: 'safari', platform: 'OS X 10.9' }, + { browserName: 'safari', platform: 'OS X 10.10' }, + { browserName: 'iphone', platform: 'OS X 10.9', version: '7.1' }, + { browserName: 'android', platform: 'Linux', version: '4.4' }, + ]; + var extraBrowsers = [ + { browserName: "firefox", platform: "linux", version: "30" }, + { browserName: "firefox", platform: "linux", version: "25" }, + { browserName: 'iphone', platform: 'OS X 10.8', version: '6.1' }, + { browserName: 'iphone', platform: 'OS X 10.8', version: '5.1' }, + { browserName: 'android', platform: 'Linux', version: '4.2' }, + // XXX haven't investigated these: + //{ browserName: "opera", platform: "Windows 7", version: "12" }, + //{ browserName: "opera", platform: "Windows 2008", version: "12" } + //{ browserName: 'iphone', platform: 'OS X 10.6', version: '4.3' }, + //{ browserName: 'android', platform: 'Linux', version: '4.0' }, + ]; + if (grunt.option('extra')) { + browsers = browsers.concat(extraBrowsers); + } + grunt.initConfig({ + connect: { + server: { + options: { + base: "", + port: 9999, + useAvailablePort: true + } + } + }, + 'saucelabs-mocha': { + all: { + options: { + urls: (function () { + var urls = ["http://localhost:9999/test/"]; + if (grunt.option('extra')) { + urls.push("http://localhost:9999/test-sham/"); + } + return urls; + }()), + //tunnelTimeout: 5, + build: process.env.TRAVIS_BUILD_NUMBER, + tunneled: !process.env.SAUCE_HAS_TUNNEL, + identifier: process.env.TRAVIS_JOB_NUMBER, + sauceConfig: { + 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER + }, + //concurrency: 3, + browsers: browsers, + testname: (function () { + var testname = "mocha"; + if (process.env.TRAVIS_PULL_REQUEST && + process.env.TRAVIS_PULL_REQUEST !== 'false') { + testname += ' (PR '+process.env.TRAVIS_PULL_REQUEST+')'; + } + if (process.env.TRAVIS_BRANCH && + process.env.TRAVIS_BRANCH !== 'false') { + testname += ' (branch '+process.env.TRAVIS_BRANCH+')'; + } + return testname; + })(), + tags: (function () { + var tags = []; + if (process.env.TRAVIS_PULL_REQUEST && + process.env.TRAVIS_PULL_REQUEST !== 'false') { + tags.push('PR-'+process.env.TRAVIS_PULL_REQUEST); + } + if (process.env.TRAVIS_BRANCH && + process.env.TRAVIS_BRANCH !== 'false') { + tags.push(process.env.TRAVIS_BRANCH); + } + return tags; + })() + } + } + }, + watch: {} + }); + // Loading dependencies + for (var key in grunt.file.readJSON("package.json").devDependencies) { + if (key !== "grunt" && key.indexOf("grunt") === 0) { + grunt.loadNpmTasks(key); + } + } + grunt.registerTask("dev", ["connect", "watch"]); + grunt.registerTask("sauce", ["connect", "saucelabs-mocha"]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/LICENSE new file mode 100644 index 0000000..822c479 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/LICENSE @@ -0,0 +1,26 @@ +The project was initially based on [es6-shim by Axel Rauschmayer](https://github.com/rauschma/es6-shim). + +Current maintainers are: [Paul Miller](http://paulmillr.com), [Jordan Harband](https://github.com/ljharb), and [C. Scott Ananian](http://cscott.net). + +The MIT License (MIT) + +Copyright (c) 2013-2015 Paul Miller (http://paulmillr.com) and contributors + +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/node_modules/johnny-five/node_modules/es6-shim/README.md b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/README.md new file mode 100644 index 0000000..e0fa465 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/README.md @@ -0,0 +1,227 @@ +# ES6 Shim +Provides compatibility shims so that legacy JavaScript engines behave as +closely as possible to ECMAScript 6 (Harmony). + +[![Build Status][1]][2] [![dependency status][3]][4] [![dev dependency status][5]][6] + +[](https://ci.testling.com/paulmillr/es6-shim) + +[](https://saucelabs.com/u/es6-shim) + +## Installation +If you want to use it in browser: + +* Just include es6-shim before your scripts. +* Include [es5-shim][es5-shim-url] especially if your browser doesn't support ECMAScript 5 - but every JS engine requires the `es5-shim` to correct broken implementations, so it's strongly recommended to always include it. + +For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended method): + + npm install es6-shim + +Alternative methods: +* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/component/component). +* `bower install es6-shim` if you’re using [Bower](http://bower.io/). + +In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details. + +## Safe shims + +* `Map`, `Set` (requires ES5 property descriptor support) +* `Promise` +* `String`: + * `fromCodePoint()` ([a standalone shim is also available](http://mths.be/fromcodepoint)) + * `raw()` +* `String.prototype`: + * `codePointAt()` ([a standalone shim is also available](http://mths.be/codepointat)) + * `endsWith()` ([a standalone shim is also available](http://mths.be/endswith)) + * `includes()` ([a standalone shim is also available](http://mths.be/includes)) + * `repeat()` ([a standalone shim is also available](http://mths.be/repeat)) + * `startsWith()` ([a standalone shim is also available](http://mths.be/startswith)) +* `RegExp`: + * `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5) +* `RegExp.prototype`: + * `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags)) +* `Number`: + * `EPSILON` + * `MAX_SAFE_INTEGER` + * `MIN_SAFE_INTEGER` + * `isNaN()`([a standalone shim is also available](https://npmjs.org/package/is-nan)) + * `isInteger()` + * `isSafeInteger()` + * `isFinite()` + * `parseInt()` + * `parseFloat()` +* `Array`: + * `from()` ([a standalone shim is also available](https://npmjs.org/package/array.from)) + * `of()` ([a standalone shim is also available](https://npmjs.org/package/array.of)) +* `Array.prototype`: + * `copyWithin()` + * `entries()` + * `fill()` + * `find()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.find)) + * `findIndex()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.findIndex)) + * `keys()` (note: keys/values/entries return an `ArrayIterator` object) + * `values()` +* `Object`: + * `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign)) + * `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is)) + * `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6) + * `setPrototypeOf()` (IE >= 11) +* `Math`: + * `acosh()` + * `asinh()` + * `atanh()` + * `cbrt()` + * `clz32()` + * `cosh()` + * `expm1()` + * `fround()` + * `hypot()` + * `imul()` + * `log10()` + * `log1p()` + * `log2()` + * `sign()` + * `sinh()` + * `tanh()` + * `trunc()` + +Math functions’ accuracy is 1e-11. + +* `Reflect` + * `apply()` + * `construct()` + * `defineProperty()` + * `deleteProperty()` + * `enumerate()` + * `get()` + * `getOwnPropertyDescriptor()` + * `getPrototypeOf()` + * `has()` + * `isExtensible()` + * `ownKeys()` + * `preventExtensions()` + * `set()` + * `setPrototypeOf()` + +* `String.prototype` Annex B HTML methods +These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them: + * `anchor()` + * `big()` + * `blink()` + * `bold()` + * `fixed()` + * `fontcolor()` + * `fontsize()` + * `italics()` + * `link()` + * `small()` + * `strike()` + * `sub()` + * `sup()` + +## Subclassing +The `Map`, `Set`, and `Promise` implementations are subclassable. +You should use the following pattern to create a subclass in ES5 which +will continue to work in ES6: +```javascript +function MyPromise(exec) { + Promise.call(this, exec); + // ... +} +Object.setPrototypeOf(MyPromise, Promise); +MyPromise.prototype = Object.create(Promise.prototype, { + constructor: { value: MyPromise } +}); +``` + +## String.prototype.normalize +Including a proper shim for `String.prototype.normalize` would +increase the size of this library by a factor of more than 4. +So instead we recommend that you install the +[`unorm`](https://github.com/walling/unorm) +package alongside `es6-shim` if you need `String.prototype.normalize`. +See https://github.com/paulmillr/es6-shim/issues/134 for more +discussion. + + +## WeakMap shim +It is not possible to implement WeakMap in pure javascript. +The [es6-collections](https://github.com/WebReflection/es6-collections) +implementation doesn't hold values strongly, which is critical +for the collection. es6-shim decided to not include an incorrect shim. + +WeakMap has a very unusual use-case so you probably won't need it at all +(use simple `Map` instead). + +## Getting started + +```javascript +'abc'.startsWith('a') // true +'abc'.endsWith('a') // false +'john alice'.includes('john') // true +'123'.repeat(2) // '123123' + +Object.is(NaN, NaN) // Fixes ===. 0 isnt -0, NaN is NaN +Object.assign({a: 1}, {b: 2}) // {a: 1, b: 2} + +Number.isNaN('123') // false. isNaN('123') will give true. +Number.isFinite('asd') // false. Global isFinite() will give true. +// Tests if value is a number, finite, +// >= -9007199254740992 && <= 9007199254740992 and floor(value) === value +Number.isInteger(2.4) // false. + +Math.sign(400) // 1, 0 or -1 depending on sign. In this case 1. + +[5, 10, 15, 10].find(function (item) {return item / 2 === 5;}) // 10 +[5, 10, 15, 10].findIndex(function (item) {return item / 2 === 5;}) // 1 + +// Replacement for `{}` key-value storage. +// Keys can be anything. +var map = new Map(); +map.set('John', 25); +map.set('Alice', 400); +map.set(['meh'], 555); +assert(map.get(['meh']) === undefined); // undefined because you need to use exactly the same object. +map.delete('Alice'); +map.keys(); +map.values(); +assert(map.size === 2); + +// Useful for storing unique items. +var set = new Set(); +set.add(1); +set.add(5); +assert(set.has(1) === true); +assert(set.has(4) === false); +set.delete(5); + +// Promises, see +// http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript +// https://github.com/petkaantonov/bluebird/#what-are-promises-and-why-should-i-use-them +Promise.resolve(5).then(function (value) { + if ( ... ) throw new Error("whoops!"); + // do some stuff + return anotherPromise(); +}).catch(function (e) { + // any errors thrown asynchronously end up here +}); +``` + +Other stuff: + +* [HTML version of the latest ECMAScript 6 spec draft][spec-html-url] +* [PDFs of ECMAScript 6 spec drafts][spec-drafts-url] + +## [License][license-url] + +[1]: https://travis-ci.org/paulmillr/es6-shim.svg +[2]: https://travis-ci.org/paulmillr/es6-shim +[3]: https://david-dm.org/paulmillr/es6-shim.svg +[4]: https://david-dm.org/paulmillr/es6-shim +[5]: https://david-dm.org/paulmillr/es6-shim/dev-status.svg +[6]: https://david-dm.org/paulmillr/es6-shim#info=devDependencies +[license-url]: https://github.com/paulmillr/es6-shim/blob/master/LICENSE +[spec-html-url]: https://people.mozilla.org/~jorendorff/es6-draft.html +[spec-drafts-url]: http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts +[es5-shim-url]: https://github.com/es-shims/es5-shim diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/bower.json b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/bower.json new file mode 100644 index 0000000..0cad788 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/bower.json @@ -0,0 +1,29 @@ +{ + "name": "es6-shim", + "version": "0.32.2", + "repo": "paulmillr/es6-shim", + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "main": "es6-shim.js", + "scripts": ["es6-shim.js"], + "dependencies": {}, + "development": {}, + "ignore": [ + "**/.*", + "node_modules", + "components", + "test" + ] +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/component.json b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/component.json new file mode 100644 index 0000000..b4283de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/component.json @@ -0,0 +1,23 @@ +{ + "name": "es6-shim", + "version": "0.32.2", + "repo": "paulmillr/es6-shim", + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "main": "es6-shim.js", + "scripts": ["es6-shim.js"], + "dependencies": {}, + "development": {} +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.js new file mode 100644 index 0000000..559a3f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.js @@ -0,0 +1,121 @@ + /*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-sham: v0.32.2 + * see https://github.com/paulmillr/es6-shim/blob/0.32.2/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/returnExports.js +(function (root, factory) { + /*global define, exports, module */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { + 'use strict'; + + /*jshint evil: true */ + var getGlobal = new Function('return this;'); + /*jshint evil: false */ + + var globals = getGlobal(); + var Object = globals.Object; + + // NOTE: This versions needs object ownership + // beacuse every promoted object needs to be reassigned + // otherwise uncompatible browsers cannot work as expected + // + // NOTE: This might need es5-shim or polyfills upfront + // because it's based on ES5 API. + // (probably just an IE <= 8 problem) + // + // NOTE: nodejs is fine in version 0.8, 0.10, and future versions. + (function () { + if (Object.setPrototypeOf) { return; } + + /*jshint proto: true */ + // @author Andrea Giammarchi - @WebReflection + + var getOwnPropertyNames = Object.getOwnPropertyNames; + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var create = Object.create; + var defineProperty = Object.defineProperty; + var getPrototypeOf = Object.getPrototypeOf; + var objProto = Object.prototype; + + var copyDescriptors = function (target, source) { + // define into target descriptors from source + getOwnPropertyNames(source).forEach(function (key) { + defineProperty( + target, + key, + getOwnPropertyDescriptor(source, key) + ); + }); + return target; + }; + // used as fallback when no promotion is possible + var createAndCopy = function (origin, proto) { + return copyDescriptors(create(proto), origin); + }; + var set, setPrototypeOf; + try { + // this might fail for various reasons + // ignore if Chrome cought it at runtime + set = getOwnPropertyDescriptor(objProto, '__proto__').set; + set.call({}, null); + // setter not poisoned, it can promote + // Firefox, Chrome + setPrototypeOf = function (origin, proto) { + set.call(origin, proto); + return origin; + }; + } catch (e) { + // do one or more feature detections + set = {__proto__: null}; + // if proto does not work, needs to fallback + // some Opera, Rhino, ducktape + if (set instanceof Object) { + setPrototypeOf = createAndCopy; + } else { + // verify if null objects are buggy + set.__proto__ = objProto; + // if null objects are buggy + // nodejs 0.8 to 0.10 + if (set instanceof Object) { + setPrototypeOf = function (origin, proto) { + // use such bug to promote + origin.__proto__ = proto; + return origin; + }; + } else { + // try to use proto or fallback + // Safari, old Firefox, many others + setPrototypeOf = function (origin, proto) { + // if proto is not null + return getPrototypeOf(origin) ? + // use __proto__ to promote + ((origin.__proto__ = proto), origin) : + // otherwise unable to promote: fallback + createAndCopy(origin, proto); + }; + } + } + } + Object.setPrototypeOf = setPrototypeOf; + }()); + +})); diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.map b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.map new file mode 100644 index 0000000..1e11c31 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.map @@ -0,0 +1 @@ +{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","defineProperty","getPrototypeOf","objProto","prototype","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","call","e","__proto__"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAsBF,EAAOE,mBACjC,IAAIC,GAA2BH,EAAOG,wBACtC,IAAIC,GAASJ,EAAOI,MACpB,IAAIC,GAAiBL,EAAOK,cAC5B,IAAIC,GAAiBN,EAAOM,cAC5B,IAAIC,GAAWP,EAAOQ,SAEtB,IAAIC,GAAkB,SAAUC,EAAQC,GAEtCT,EAAoBS,GAAQC,QAAQ,SAAUC,GAC5CR,EACEK,EACAG,EACAV,EAAyBQ,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBL,EAAOY,GAAQD,GAExC,IAAIE,GAAKhB,CACT,KAGEgB,EAAMd,EAAyBI,EAAU,aAAaU,GACtDA,GAAIC,QAAS,KAGbjB,GAAiB,SAAUc,EAAQC,GACjCC,EAAIC,KAAKH,EAAQC,EACjB,OAAOD,IAET,MAAOI,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAejB,GAAQ,CACzBC,EAAiBa,MACZ,CAELG,EAAIG,UAAYb,CAGhB,IAAIU,YAAejB,GAAQ,CACzBC,EAAiB,SAAUc,EAAQC,GAEjCD,EAAOK,UAAYJ,CACnB,OAAOD,QAEJ,CAGLd,EAAiB,SAAUc,EAAQC,GAEjC,MAAOV,GAAeS,IAElBA,EAAOK,UAAYJ,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhChB,EAAOC,eAAiBA"} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.min.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.min.js new file mode 100644 index 0000000..469544a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-sham.min.js @@ -0,0 +1,11 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-sham: v0.32.2 + * see https://github.com/paulmillr/es6-shim/blob/0.32.2/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ +(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var f=r.getPrototypeOf;var i=r.prototype;var c=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var u=function(t,e){return c(n(e),t)};var a,_;try{a=e(i,"__proto__").set;a.call({},null);_=function(t,e){a.call(t,e);return t}}catch(p){a={__proto__:null};if(a instanceof r){_=u}else{a.__proto__=i;if(a instanceof r){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,e){return f(t)?(t.__proto__=e,t):u(t,e)}}}}r.setPrototypeOf=_})()}); +//# sourceMappingURL=es6-sham.map diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.js new file mode 100644 index 0000000..28c7c45 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.js @@ -0,0 +1,3096 @@ + /*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-shim: v0.32.2 + * see https://github.com/paulmillr/es6-shim/blob/0.32.2/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/returnExports.js +(function (root, factory) { + /*global define, module, exports */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { + 'use strict'; + + var _apply = Function.call.bind(Function.apply); + var _call = Function.call.bind(Function.call); + + var not = function notThunker(func) { + return function notThunk() { return !_apply(func, this, arguments); }; + }; + var throwsError = function (func) { + try { + func(); + return false; + } catch (e) { + return true; + } + }; + var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) { + try { + return func(); + } catch (e) { + return false; + } + }; + + var isCallableWithoutNew = not(throwsError); + var arePropertyDescriptorsSupported = function () { + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { Object.defineProperty({}, 'x', {}); }); + }; + var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + + var _forEach = Function.call.bind(Array.prototype.forEach); + var _reduce = Function.call.bind(Array.prototype.reduce); + var _filter = Function.call.bind(Array.prototype.filter); + var _every = Function.call.bind(Array.prototype.every); + + var defineProperty = function (object, name, value, force) { + if (!force && name in object) { return; } + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + + // Define configurable, writable and non-enumerable props + // if they don’t exist. + var defineProperties = function (object, map) { + _forEach(Object.keys(map), function (name) { + var method = map[name]; + defineProperty(object, name, method, false); + }); + }; + + // Simple shim for Object.create on ES3 browsers + // (unlike real shim, no attempt to support `prototype === null`) + var create = Object.create || function (prototype, properties) { + var Prototype = function Prototype() {}; + Prototype.prototype = prototype; + var object = new Prototype(); + if (typeof properties !== 'undefined') { + Object.keys(properties).forEach(function (key) { + Value.defineByDescriptor(object, key, properties[key]); + }); + } + return object; + }; + + var supportsSubclassing = function (C, f) { + if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } + return valueOrFalseIfThrows(function () { + var Sub = function Subclass(arg) { + var o = new C(arg); + Object.setPrototypeOf(o, Subclass.prototype); + return o; + }; + Object.setPrototypeOf(Sub, C); + Sub.prototype = create(C.prototype, { + constructor: { value: Sub } + }); + return f(Sub); + }); + }; + + var startsWithRejectsRegex = function () { + return String.prototype.startsWith && throwsError(function () { + /* throws if spec-compliant */ + '/a/'.startsWith(/a/); + }); + }; + var startsWithHandlesInfinity = (function () { + return String.prototype.startsWith && 'abc'.startsWith('a', Infinity) === false; + }()); + + /*jshint evil: true */ + var getGlobal = new Function('return this;'); + /*jshint evil: false */ + + var globals = getGlobal(); + var globalIsFinite = globals.isFinite; + var hasStrictMode = (function () { return this === null; }.call(null)); + var startsWithIsCompliant = startsWithRejectsRegex() && startsWithHandlesInfinity; + var _indexOf = Function.call.bind(String.prototype.indexOf); + var _toString = Function.call.bind(Object.prototype.toString); + var _concat = Function.call.bind(Array.prototype.concat); + var _strSlice = Function.call.bind(String.prototype.slice); + var _push = Function.call.bind(Array.prototype.push); + var _pushApply = Function.apply.bind(Array.prototype.push); + var _shift = Function.call.bind(Array.prototype.shift); + var _max = Math.max; + var _min = Math.min; + var _floor = Math.floor; + var _abs = Math.abs; + var _log = Math.log; + var _sqrt = Math.sqrt; + var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); + var ArrayIterator; // make our implementation private + var noop = function () {}; + + var Symbol = globals.Symbol || {}; + var symbolSpecies = Symbol.species || '@@species'; + var defaultSpeciesGetter = function () { return this; }; + var addDefaultSpecies = function (C) { + if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) { + Value.getter(C, symbolSpecies, defaultSpeciesGetter); + } + }; + var Type = { + object: function (x) { return x !== null && typeof x === 'object'; }, + string: function (x) { return _toString(x) === '[object String]'; }, + regex: function (x) { return _toString(x) === '[object RegExp]'; }, + symbol: function (x) { + return typeof globals.Symbol === 'function' && typeof x === 'symbol'; + } + }; + + var numberIsNaN = Number.isNaN || function isNaN(value) { + // NaN !== NaN, but they are identical. + // NaNs are the only non-reflexive value, i.e., if x !== x, + // then x is NaN. + // isNaN is broken: it converts its argument to number, so + // isNaN('foo') => true + return value !== value; + }; + var numberIsFinite = Number.isFinite || function isFinite(value) { + return typeof value === 'number' && globalIsFinite(value); + }; + + var Value = { + getter: function (object, name, getter) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + get: getter + }); + }, + proxy: function (originalObject, key, targetObject) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); + Object.defineProperty(targetObject, key, { + configurable: originalDescriptor.configurable, + enumerable: originalDescriptor.enumerable, + get: function getKey() { return originalObject[key]; }, + set: function setKey(value) { originalObject[key] = value; } + }); + }, + redefine: function (object, property, newValue) { + if (supportsDescriptors) { + var descriptor = Object.getOwnPropertyDescriptor(object, property); + descriptor.value = newValue; + Object.defineProperty(object, property, descriptor); + } else { + object[property] = newValue; + } + }, + defineByDescriptor: function (object, property, descriptor) { + if (supportsDescriptors) { + Object.defineProperty(object, property, descriptor); + } else if ('value' in descriptor) { + object[property] = descriptor.value; + } + }, + preserveToString: function (target, source) { + defineProperty(target, 'toString', source.toString.bind(source), true); + } + }; + + var overrideNative = function overrideNative(object, property, replacement) { + var original = object[property]; + defineProperty(object, property, replacement, true); + Value.preserveToString(object[property], original); + }; + + // This is a private name in the es6 spec, equal to '[Symbol.iterator]' + // we're going to use an arbitrary _-prefixed name to make our shims + // work properly with each other, even though we don't have full Iterator + // support. That is, `Array.from(map.keys())` will work, but we don't + // pretend to export a "real" Iterator interface. + var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_'; + // Firefox ships a partial implementation using the name @@iterator. + // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14 + // So use that name if we detect it. + if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; + } + var addIterator = function (prototype, impl) { + var implementation = impl || function iterator() { return this; }; + var o = {}; + o[$iterator$] = implementation; + defineProperties(prototype, o); + if (!prototype[$iterator$] && Type.symbol($iterator$)) { + // implementations are buggy when $iterator$ is a Symbol + prototype[$iterator$] = implementation; + } + }; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isArguments = function isArguments(value) { + var str = _toString(value); + var result = str === '[object Arguments]'; + if (!result) { + result = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + _toString(value.callee) === '[object Function]'; + } + return result; + }; + + var ES = { + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args + Call: function Call(F, V) { + var args = arguments.length > 2 ? arguments[2] : []; + if (!ES.IsCallable(F)) { + throw new TypeError(F + ' is not a function'); + } + return _apply(F, V, args); + }, + + RequireObjectCoercible: function (x, optMessage) { + /* jshint eqnull:true */ + if (x == null) { + throw new TypeError(optMessage || 'Cannot call method on ' + x); + } + }, + + TypeIsObject: function (x) { + /* jshint eqnull:true */ + // this is expensive when it returns false; use this function + // when you expect it to return true in the common case. + return x != null && Object(x) === x; + }, + + ToObject: function (o, optMessage) { + ES.RequireObjectCoercible(o, optMessage); + return Object(o); + }, + + IsCallable: function (x) { + // some versions of IE say that typeof /abc/ === 'function' + return typeof x === 'function' && _toString(x) === '[object Function]'; + }, + + IsConstructor: function (x) { + // We can't tell callables from constructors in ES5 + return ES.IsCallable(x); + }, + + ToInt32: function (x) { + return ES.ToNumber(x) >> 0; + }, + + ToUint32: function (x) { + return ES.ToNumber(x) >>> 0; + }, + + ToNumber: function (value) { + if (_toString(value) === '[object Symbol]') { + throw new TypeError('Cannot convert a Symbol value to a number'); + } + return +value; + }, + + ToInteger: function (value) { + var number = ES.ToNumber(value); + if (numberIsNaN(number)) { return 0; } + if (number === 0 || !numberIsFinite(number)) { return number; } + return (number > 0 ? 1 : -1) * _floor(_abs(number)); + }, + + ToLength: function (value) { + var len = ES.ToInteger(value); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; } + return len; + }, + + SameValue: function (a, b) { + if (a === b) { + // 0 === -0, but they are not identical. + if (a === 0) { return 1 / a === 1 / b; } + return true; + } + return numberIsNaN(a) && numberIsNaN(b); + }, + + SameValueZero: function (a, b) { + // same as SameValue except for SameValueZero(+0, -0) == true + return (a === b) || (numberIsNaN(a) && numberIsNaN(b)); + }, + + IsIterable: function (o) { + return ES.TypeIsObject(o) && (typeof o[$iterator$] !== 'undefined' || isArguments(o)); + }, + + GetIterator: function (o) { + if (isArguments(o)) { + // special case support for `arguments` + return new ArrayIterator(o, 'value'); + } + var itFn = ES.GetMethod(o, $iterator$); + if (!ES.IsCallable(itFn)) { + // Better diagnostics if itFn is null or undefined + throw new TypeError('value is not an iterable'); + } + var it = _call(itFn, o); + if (!ES.TypeIsObject(it)) { + throw new TypeError('bad iterator'); + } + return it; + }, + + GetMethod: function (o, p) { + var func = ES.ToObject(o)[p]; + if (func === void 0 || func === null) { + return void 0; + } + if (!ES.IsCallable(func)) { + throw new TypeError('Method not callable: ' + p); + } + return func; + }, + + IteratorComplete: function (iterResult) { + return !!(iterResult.done); + }, + + IteratorClose: function (iterator, completionIsThrow) { + var returnMethod = ES.GetMethod(iterator, 'return'); + if (returnMethod === void 0) { + return; + } + var innerResult, innerException; + try { + innerResult = _call(returnMethod, iterator); + } catch (e) { + innerException = e; + } + if (completionIsThrow) { + return; + } + if (innerException) { + throw innerException; + } + if (!ES.TypeIsObject(innerResult)) { + throw new TypeError("Iterator's return method returned a non-object."); + } + }, + + IteratorNext: function (it) { + var result = arguments.length > 1 ? it.next(arguments[1]) : it.next(); + if (!ES.TypeIsObject(result)) { + throw new TypeError('bad iterator'); + } + return result; + }, + + IteratorStep: function (it) { + var result = ES.IteratorNext(it); + var done = ES.IteratorComplete(result); + return done ? false : result; + }, + + Construct: function (C, args, newTarget, isES6internal) { + if (newTarget === void 0) { + newTarget = C; + } + if (!isES6internal) { + // Try to use Reflect.construct if available + return Reflect.construct(C, args, newTarget); + } + // OK, we have to fake it. This will only work if the + // C.[[ConstructorKind]] == "base" -- but that's the only + // kind we can make in ES5 code anyway. + + // OrdinaryCreateFromConstructor(newTarget, "%ObjectPrototype%") + var proto = newTarget.prototype; + if (!ES.TypeIsObject(proto)) { + proto = Object.prototype; + } + var obj = create(proto); + // Call the constructor. + var result = ES.Call(C, obj, args); + return ES.TypeIsObject(result) ? result : obj; + }, + + SpeciesConstructor: function (O, defaultConstructor) { + var C = O.constructor; + if (C === void 0) { + return defaultConstructor; + } + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad constructor'); + } + var S = C[symbolSpecies]; + if (S === void 0 || S === null) { + return defaultConstructor; + } + if (!ES.IsConstructor(S)) { + throw new TypeError('Bad @@species'); + } + return S; + }, + + CreateHTML: function (string, tag, attribute, value) { + var S = String(string); + var p1 = '<' + tag; + if (attribute !== '') { + var V = String(value); + var escapedV = V.replace(/"/g, '"'); + p1 += ' ' + attribute + '="' + escapedV + '"'; + } + var p2 = p1 + '>'; + var p3 = p2 + S; + return p3 + '' + tag + '>'; + } + }; + + var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) { + // This is an es5 approximation to es6 construct semantics. in es6, + // 'new Foo' invokes Foo.[[Construct]] which (for almost all objects) + // just sets the internal variable NewTarget (in es6 syntax `new.target`) + // to Foo and then returns Foo(). + + // Many ES6 object then have constructors of the form: + // 1. If NewTarget is undefined, throw a TypeError exception + // 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz) + + // So we're going to emulate those first two steps. + if (!ES.TypeIsObject(o)) { + throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name); + } + var proto = defaultNewTarget.prototype; + if (!ES.TypeIsObject(proto)) { + proto = defaultProto; + } + o = create(proto); + for (var name in slots) { + if (_hasOwnProperty(slots, name)) { + var value = slots[name]; + defineProperty(o, name, value, true); + } + } + return o; + }; + + // Firefox 31 reports this function's length as 0 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 + if (String.fromCodePoint && String.fromCodePoint.length !== 1) { + var originalFromCodePoint = String.fromCodePoint; + overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { return _apply(originalFromCodePoint, this, arguments); }); + } + + var StringShims = { + fromCodePoint: function fromCodePoint(codePoints) { + var result = []; + var next; + for (var i = 0, length = arguments.length; i < length; i++) { + next = Number(arguments[i]); + if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) { + throw new RangeError('Invalid code point ' + next); + } + + if (next < 0x10000) { + _push(result, String.fromCharCode(next)); + } else { + next -= 0x10000; + _push(result, String.fromCharCode((next >> 10) + 0xD800)); + _push(result, String.fromCharCode((next % 0x400) + 0xDC00)); + } + } + return result.join(''); + }, + + raw: function raw(callSite) { + var cooked = ES.ToObject(callSite, 'bad callSite'); + var rawString = ES.ToObject(cooked.raw, 'bad raw value'); + var len = rawString.length; + var literalsegments = ES.ToLength(len); + if (literalsegments <= 0) { + return ''; + } + + var stringElements = []; + var nextIndex = 0; + var nextKey, next, nextSeg, nextSub; + while (nextIndex < literalsegments) { + nextKey = String(nextIndex); + nextSeg = String(rawString[nextKey]); + _push(stringElements, nextSeg); + if (nextIndex + 1 >= literalsegments) { + break; + } + next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : ''; + nextSub = String(next); + _push(stringElements, nextSub); + nextIndex++; + } + return stringElements.join(''); + } + }; + defineProperties(String, StringShims); + if (String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') { + // IE 11 TP has a broken String.raw implementation + overrideNative(String, 'raw', StringShims.raw); + } + + // Fast repeat, uses the `Exponentiation by squaring` algorithm. + // Perf: http://jsperf.com/string-repeat2/2 + var stringRepeat = function repeat(s, times) { + if (times < 1) { return ''; } + if (times % 2) { return repeat(s, times - 1) + s; } + var half = repeat(s, times / 2); + return half + half; + }; + var stringMaxLength = Infinity; + + var StringPrototypeShims = { + repeat: function repeat(times) { + ES.RequireObjectCoercible(this); + var thisStr = String(this); + var numTimes = ES.ToInteger(times); + if (numTimes < 0 || numTimes >= stringMaxLength) { + throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); + } + return stringRepeat(thisStr, numTimes); + }, + + startsWith: function startsWith(searchString) { + ES.RequireObjectCoercible(this); + var thisStr = String(this); + if (Type.regex(searchString)) { + throw new TypeError('Cannot call method "startsWith" with a regex'); + } + var searchStr = String(searchString); + var startArg = arguments.length > 1 ? arguments[1] : void 0; + var start = _max(ES.ToInteger(startArg), 0); + return _strSlice(thisStr, start, start + searchStr.length) === searchStr; + }, + + endsWith: function endsWith(searchString) { + ES.RequireObjectCoercible(this); + var thisStr = String(this); + if (Type.regex(searchString)) { + throw new TypeError('Cannot call method "endsWith" with a regex'); + } + var searchStr = String(searchString); + var thisLen = thisStr.length; + var posArg = arguments.length > 1 ? arguments[1] : void 0; + var pos = typeof posArg === 'undefined' ? thisLen : ES.ToInteger(posArg); + var end = _min(_max(pos, 0), thisLen); + return _strSlice(thisStr, end - searchStr.length, end) === searchStr; + }, + + includes: function includes(searchString) { + if (Type.regex(searchString)) { + throw new TypeError('"includes" does not accept a RegExp'); + } + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + // Somehow this trick makes method 100% compat with the spec. + return _indexOf(this, searchString, position) !== -1; + }, + + codePointAt: function codePointAt(pos) { + ES.RequireObjectCoercible(this); + var thisStr = String(this); + var position = ES.ToInteger(pos); + var length = thisStr.length; + if (position >= 0 && position < length) { + var first = thisStr.charCodeAt(position); + var isEnd = (position + 1 === length); + if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; } + var second = thisStr.charCodeAt(position + 1); + if (second < 0xDC00 || second > 0xDFFF) { return first; } + return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000; + } + } + }; + defineProperties(String.prototype, StringPrototypeShims); + + if ('a'.includes('a', Infinity) !== false) { + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); + } + + var hasStringTrimBug = '\u0085'.trim().length !== 1; + if (hasStringTrimBug) { + delete String.prototype.trim; + // whitespace from: http://es5.github.io/#x15.5.4.20 + // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 + var ws = [ + '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003', + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028', + '\u2029\uFEFF' + ].join(''); + var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); + defineProperties(String.prototype, { + trim: function trim() { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + return String(this).replace(trimRegexp, ''); + } + }); + } + + // see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype-@@iterator + var StringIterator = function (s) { + ES.RequireObjectCoercible(s); + this._s = String(s); + this._i = 0; + }; + StringIterator.prototype.next = function () { + var s = this._s, i = this._i; + if (typeof s === 'undefined' || i >= s.length) { + this._s = void 0; + return { value: void 0, done: true }; + } + var first = s.charCodeAt(i), second, len; + if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) { + len = 1; + } else { + second = s.charCodeAt(i + 1); + len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2; + } + this._i = i + len; + return { value: s.substr(i, len), done: false }; + }; + addIterator(StringIterator.prototype); + addIterator(String.prototype, function () { + return new StringIterator(this); + }); + + if (!startsWithIsCompliant) { + // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); + } + + var ArrayShims = { + from: function from(items) { + var C = this; + var mapFn = arguments.length > 1 ? arguments[1] : void 0; + var mapping, T; + if (mapFn === void 0) { + mapping = false; + } else { + if (!ES.IsCallable(mapFn)) { + throw new TypeError('Array.from: when provided, the second argument must be a function'); + } + T = arguments.length > 2 ? arguments[2] : void 0; + mapping = true; + } + + // Note that that Arrays will use ArrayIterator: + // https://bugs.ecmascript.org/show_bug.cgi?id=2416 + var usingIterator = isArguments(items) || ES.GetMethod(items, $iterator$); + + var length, result, i; + if (usingIterator !== void 0) { + result = ES.IsConstructor(C) ? Object(new C()) : []; + var iterator = ES.GetIterator(items); + var next, nextValue; + + for (i = 0; ; ++i) { + next = ES.IteratorStep(iterator); + if (next === false) { + break; + } + nextValue = next.value; + try { + if (mapping) { + nextValue = T !== undefined ? _call(mapFn, T, nextValue, i) : mapFn(nextValue, i); + } + result[i] = nextValue; + } catch (e) { + ES.IteratorClose(iterator, true); + throw e; + } + } + length = i; + } else { + var arrayLike = ES.ToObject(items); + length = ES.ToLength(arrayLike.length); + result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length); + var value; + for (i = 0; i < length; ++i) { + value = arrayLike[i]; + if (mapping) { + value = T !== undefined ? _call(mapFn, T, value, i) : mapFn(value, i); + } + result[i] = value; + } + } + + result.length = length; + return result; + }, + + of: function of() { + return _call(Array.from, this, arguments); + } + }; + defineProperties(Array, ArrayShims); + addDefaultSpecies(Array); + + // Given an argument x, it will return an IteratorResult object, + // with value set to x and done to false. + // Given no arguments, it will return an iterator completion object. + var iteratorResult = function (x) { + return { value: x, done: arguments.length === 0 }; + }; + + // Our ArrayIterator is private; see + // https://github.com/paulmillr/es6-shim/issues/252 + ArrayIterator = function (array, kind) { + this.i = 0; + this.array = array; + this.kind = kind; + }; + + defineProperties(ArrayIterator.prototype, { + next: function () { + var i = this.i, array = this.array; + if (!(this instanceof ArrayIterator)) { + throw new TypeError('Not an ArrayIterator'); + } + if (typeof array !== 'undefined') { + var len = ES.ToLength(array.length); + for (; i < len; i++) { + var kind = this.kind; + var retval; + if (kind === 'key') { + retval = i; + } else if (kind === 'value') { + retval = array[i]; + } else if (kind === 'entry') { + retval = [i, array[i]]; + } + this.i = i + 1; + return { value: retval, done: false }; + } + } + this.array = void 0; + return { value: void 0, done: true }; + } + }); + addIterator(ArrayIterator.prototype); + + var ObjectIterator = function (object, kind) { + this.object = object; + // Don't generate keys yet. + this.array = null; + this.kind = kind; + }; + + var getAllKeys = function getAllKeys(object) { + var keys = []; + + for (var key in object) { + _push(keys, key); + } + + return keys; + }; + + defineProperties(ObjectIterator.prototype, { + next: function () { + var key, array = this.array; + + if (!(this instanceof ObjectIterator)) { + throw new TypeError('Not an ObjectIterator'); + } + + // Keys not generated + if (array === null) { + array = this.array = getAllKeys(this.object); + } + + // Find next key in the object + while (ES.ToLength(array.length) > 0) { + key = _shift(array); + + // The candidate key isn't defined on object. + // Must have been deleted, or object[[Prototype]] + // has been modified. + if (!(key in this.object)) { + continue; + } + + if (this.kind === 'key') { + return iteratorResult(key); + } else if (this.kind === 'value') { + return iteratorResult(this.object[key]); + } else { + return iteratorResult([key, this.object[key]]); + } + } + + return iteratorResult(); + } + }); + addIterator(ObjectIterator.prototype); + + // note: this is positioned here because it depends on ArrayIterator + var arrayOfSupportsSubclassing = (function () { + // Detects a bug in Webkit nightly r181886 + var Foo = function Foo(len) { this.length = len; }; + Foo.prototype = []; + var fooArr = Array.of.apply(Foo, [1, 2]); + return fooArr instanceof Foo && fooArr.length === 2; + }()); + if (!arrayOfSupportsSubclassing) { + overrideNative(Array, 'of', ArrayShims.of); + } + + var ArrayPrototypeShims = { + copyWithin: function copyWithin(target, start) { + var end = arguments[2]; // copyWithin.length must be 2 + var o = ES.ToObject(this); + var len = ES.ToLength(o.length); + var relativeTarget = ES.ToInteger(target); + var relativeStart = ES.ToInteger(start); + var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len); + var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len); + end = typeof end === 'undefined' ? len : ES.ToInteger(end); + var fin = end < 0 ? _max(len + end, 0) : _min(end, len); + var count = _min(fin - from, len - to); + var direction = 1; + if (from < to && to < (from + count)) { + direction = -1; + from += count - 1; + to += count - 1; + } + while (count > 0) { + if (_hasOwnProperty(o, from)) { + o[to] = o[from]; + } else { + delete o[from]; + } + from += direction; + to += direction; + count -= 1; + } + return o; + }, + + fill: function fill(value) { + var start = arguments.length > 1 ? arguments[1] : void 0; + var end = arguments.length > 2 ? arguments[2] : void 0; + var O = ES.ToObject(this); + var len = ES.ToLength(O.length); + start = ES.ToInteger(typeof start === 'undefined' ? 0 : start); + end = ES.ToInteger(typeof end === 'undefined' ? len : end); + + var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len); + var relativeEnd = end < 0 ? len + end : end; + + for (var i = relativeStart; i < len && i < relativeEnd; ++i) { + O[i] = value; + } + return O; + }, + + find: function find(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#find: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0, value; i < length; i++) { + value = list[i]; + if (thisArg) { + if (_call(predicate, thisArg, value, i, list)) { return value; } + } else if (predicate(value, i, list)) { + return value; + } + } + }, + + findIndex: function findIndex(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#findIndex: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0; i < length; i++) { + if (thisArg) { + if (_call(predicate, thisArg, list[i], i, list)) { return i; } + } else if (predicate(list[i], i, list)) { + return i; + } + } + return -1; + }, + + keys: function keys() { + return new ArrayIterator(this, 'key'); + }, + + values: function values() { + return new ArrayIterator(this, 'value'); + }, + + entries: function entries() { + return new ArrayIterator(this, 'entry'); + } + }; + // Safari 7.1 defines Array#keys and Array#entries natively, + // but the resulting ArrayIterator objects don't have a "next" method. + if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) { + delete Array.prototype.keys; + } + if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) { + delete Array.prototype.entries; + } + + // Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values + if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) { + defineProperties(Array.prototype, { + values: Array.prototype[$iterator$] + }); + if (Type.symbol(Symbol.unscopables)) { + Array.prototype[Symbol.unscopables].values = true; + } + } + // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name + if (Array.prototype.values && Array.prototype.values.name !== 'values') { + var originalArrayPrototypeValues = Array.prototype.values; + overrideNative(Array.prototype, 'values', function values() { return _call(originalArrayPrototypeValues, this); }); + defineProperty(Array.prototype, $iterator$, Array.prototype.values, true); + } + defineProperties(Array.prototype, ArrayPrototypeShims); + + addIterator(Array.prototype, function () { return this.values(); }); + // Chrome defines keys/values/entries on Array, but doesn't give us + // any way to identify its iterator. So add our own shimmed field. + if (Object.getPrototypeOf) { + addIterator(Object.getPrototypeOf([].values())); + } + + // note: this is positioned here because it relies on Array#entries + var arrayFromSwallowsNegativeLengths = (function () { + // Detects a Firefox bug in v32 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 + return valueOrFalseIfThrows(function () { return Array.from({ length: -1 }).length === 0; }); + }()); + var arrayFromHandlesIterables = (function () { + // Detects a bug in Webkit nightly r181886 + var arr = Array.from([0].entries()); + return arr.length === 1 && arr[0][0] === 0 && arr[0][1] === 1; + }()); + if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) { + overrideNative(Array, 'from', ArrayShims.from); + } + + var toLengthsCorrectly = function (method, reversed) { + var obj = { length: -1 }; + obj[reversed ? ((-1 >>> 0) - 1) : 0] = true; + return valueOrFalseIfThrows(function () { + _call(method, obj, function () { + // note: in nonconforming browsers, this will be called + // -1 >>> 0 times, which is 4294967295, so the throw matters. + throw new RangeError('should not reach here'); + }, []); + }); + }; + if (!toLengthsCorrectly(Array.prototype.forEach)) { + var originalForEach = Array.prototype.forEach; + overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) { + return _apply(originalForEach, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.map)) { + var originalMap = Array.prototype.map; + overrideNative(Array.prototype, 'map', function map(callbackFn) { + return _apply(originalMap, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.filter)) { + var originalFilter = Array.prototype.filter; + overrideNative(Array.prototype, 'filter', function filter(callbackFn) { + return _apply(originalFilter, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.some)) { + var originalSome = Array.prototype.some; + overrideNative(Array.prototype, 'some', function some(callbackFn) { + return _apply(originalSome, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.every)) { + var originalEvery = Array.prototype.every; + overrideNative(Array.prototype, 'every', function every(callbackFn) { + return _apply(originalEvery, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.reduce)) { + var originalReduce = Array.prototype.reduce; + overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) { + return _apply(originalReduce, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) { + var originalReduceRight = Array.prototype.reduceRight; + overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) { + return _apply(originalReduceRight, this.length >= 0 ? this : [], arguments); + }, true); + } + + var maxSafeInteger = Math.pow(2, 53) - 1; + defineProperties(Number, { + MAX_SAFE_INTEGER: maxSafeInteger, + MIN_SAFE_INTEGER: -maxSafeInteger, + EPSILON: 2.220446049250313e-16, + + parseInt: globals.parseInt, + parseFloat: globals.parseFloat, + + isFinite: numberIsFinite, + + isInteger: function isInteger(value) { + return numberIsFinite(value) && ES.ToInteger(value) === value; + }, + + isSafeInteger: function isSafeInteger(value) { + return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER; + }, + + isNaN: numberIsNaN + }); + // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40) + defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt); + + // Work around bugs in Array#find and Array#findIndex -- early + // implementations skipped holes in sparse arrays. (Note that the + // implementations of find/findIndex indirectly use shimmed + // methods of Number, so this test has to happen down here.) + /*jshint elision: true */ + if (![, 1].find(function (item, idx) { return idx === 0; })) { + overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); + } + if ([, 1].findIndex(function (item, idx) { return idx === 0; }) !== 0) { + overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); + } + /*jshint elision: false */ + + var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); + var sliceArgs = function sliceArgs() { + // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments + // and https://gist.github.com/WebReflection/4327762cb87a8c634a29 + var initial = Number(this); + var len = arguments.length; + var desiredArgCount = len - initial; + var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount); + for (var i = initial; i < len; ++i) { + args[i - initial] = arguments[i]; + } + return args; + }; + var assignTo = function assignTo(source) { + return function assignToSource(target, key) { + target[key] = source[key]; + return target; + }; + }; + var assignReducer = function (target, source) { + var keys = Object.keys(Object(source)); + var symbols; + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source)); + } + return _reduce(_concat(keys, symbols || []), assignTo(source), target); + }; + + var ObjectShims = { + // 19.1.3.1 + assign: function (target, source) { + var to = ES.ToObject(target, 'Cannot convert undefined or null to object'); + return _reduce(_apply(sliceArgs, 1, arguments), assignReducer, to); + }, + + // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865 + is: function is(a, b) { + return ES.SameValue(a, b); + } + }; + var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + }()); + if (assignHasPendingExceptions) { + overrideNative(Object, 'assign', ObjectShims.assign); + } + defineProperties(Object, ObjectShims); + + if (supportsDescriptors) { + var ES5ObjectShims = { + // 19.1.3.9 + // shim from https://gist.github.com/WebReflection/5593554 + setPrototypeOf: (function (Object, magic) { + var set; + + var checkArgs = function (O, proto) { + if (!ES.TypeIsObject(O)) { + throw new TypeError('cannot set prototype on a non-object'); + } + if (!(proto === null || ES.TypeIsObject(proto))) { + throw new TypeError('can only set prototype to an object or null' + proto); + } + }; + + var setPrototypeOf = function (O, proto) { + checkArgs(O, proto); + _call(set, O, proto); + return O; + }; + + try { + // this works already in Firefox and Safari + set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set; + _call(set, {}, null); + } catch (e) { + if (Object.prototype !== {}[magic]) { + // IE < 11 cannot be shimmed + return; + } + // probably Chrome or some old Mobile stock browser + set = function (proto) { + this[magic] = proto; + }; + // please note that this will **not** work + // in those browsers that do not inherit + // __proto__ by mistake from Object.prototype + // in these cases we should probably throw an error + // or at least be informed about the issue + setPrototypeOf.polyfill = setPrototypeOf( + setPrototypeOf({}, null), + Object.prototype + ) instanceof Object; + // setPrototypeOf.polyfill === true means it works as meant + // setPrototypeOf.polyfill === false means it's not 100% reliable + // setPrototypeOf.polyfill === undefined + // or + // setPrototypeOf.polyfill == null means it's not a polyfill + // which means it works as expected + // we can even delete Object.prototype.__proto__; + } + return setPrototypeOf; + }(Object, '__proto__')) + }; + + defineProperties(Object, ES5ObjectShims); + } + + // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work, + // but Object.create(null) does. + if (Object.setPrototypeOf && Object.getPrototypeOf && + Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null && + Object.getPrototypeOf(Object.create(null)) === null) { + (function () { + var FAKENULL = Object.create(null); + var gpo = Object.getPrototypeOf, spo = Object.setPrototypeOf; + Object.getPrototypeOf = function (o) { + var result = gpo(o); + return result === FAKENULL ? null : result; + }; + Object.setPrototypeOf = function (o, p) { + var proto = p === null ? FAKENULL : p; + return spo(o, proto); + }; + Object.setPrototypeOf.polyfill = false; + }()); + } + + var objectKeysAcceptsPrimitives = !throwsError(function () { Object.keys('foo'); }); + if (!objectKeysAcceptsPrimitives) { + var originalObjectKeys = Object.keys; + overrideNative(Object, 'keys', function keys(value) { + return originalObjectKeys(ES.ToObject(value)); + }); + } + + if (Object.getOwnPropertyNames) { + var objectGOPNAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyNames('foo'); }); + if (!objectGOPNAcceptsPrimitives) { + var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : []; + var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames; + overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { + var val = ES.ToObject(value); + if (_toString(val) === '[object Window]') { + try { + return originalObjectGetOwnPropertyNames(val); + } catch (e) { + // IE bug where layout engine calls userland gOPN for cross-domain `window` objects + return _concat([], cachedWindowNames); + } + } + return originalObjectGetOwnPropertyNames(val); + }); + } + } + if (Object.getOwnPropertyDescriptor) { + var objectGOPDAcceptsPrimitives = !throwsError(function () { Object.getOwnPropertyDescriptor('foo', 'bar'); }); + if (!objectGOPDAcceptsPrimitives) { + var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { + return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property); + }); + } + } + if (Object.seal) { + var objectSealAcceptsPrimitives = !throwsError(function () { Object.seal('foo'); }); + if (!objectSealAcceptsPrimitives) { + var originalObjectSeal = Object.seal; + overrideNative(Object, 'seal', function seal(value) { + if (!Type.object(value)) { return value; } + return originalObjectSeal(value); + }); + } + } + if (Object.isSealed) { + var objectIsSealedAcceptsPrimitives = !throwsError(function () { Object.isSealed('foo'); }); + if (!objectIsSealedAcceptsPrimitives) { + var originalObjectIsSealed = Object.isSealed; + overrideNative(Object, 'isSealed', function isSealed(value) { + if (!Type.object(value)) { return true; } + return originalObjectIsSealed(value); + }); + } + } + if (Object.freeze) { + var objectFreezeAcceptsPrimitives = !throwsError(function () { Object.freeze('foo'); }); + if (!objectFreezeAcceptsPrimitives) { + var originalObjectFreeze = Object.freeze; + overrideNative(Object, 'freeze', function freeze(value) { + if (!Type.object(value)) { return value; } + return originalObjectFreeze(value); + }); + } + } + if (Object.isFrozen) { + var objectIsFrozenAcceptsPrimitives = !throwsError(function () { Object.isFrozen('foo'); }); + if (!objectIsFrozenAcceptsPrimitives) { + var originalObjectIsFrozen = Object.isFrozen; + overrideNative(Object, 'isFrozen', function isFrozen(value) { + if (!Type.object(value)) { return true; } + return originalObjectIsFrozen(value); + }); + } + } + if (Object.preventExtensions) { + var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { Object.preventExtensions('foo'); }); + if (!objectPreventExtensionsAcceptsPrimitives) { + var originalObjectPreventExtensions = Object.preventExtensions; + overrideNative(Object, 'preventExtensions', function preventExtensions(value) { + if (!Type.object(value)) { return value; } + return originalObjectPreventExtensions(value); + }); + } + } + if (Object.isExtensible) { + var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { Object.isExtensible('foo'); }); + if (!objectIsExtensibleAcceptsPrimitives) { + var originalObjectIsExtensible = Object.isExtensible; + overrideNative(Object, 'isExtensible', function isExtensible(value) { + if (!Type.object(value)) { return false; } + return originalObjectIsExtensible(value); + }); + } + } + if (Object.getPrototypeOf) { + var objectGetProtoAcceptsPrimitives = !throwsError(function () { Object.getPrototypeOf('foo'); }); + if (!objectGetProtoAcceptsPrimitives) { + var originalGetProto = Object.getPrototypeOf; + overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) { + return originalGetProto(ES.ToObject(value)); + }); + } + } + + if (!RegExp.prototype.flags && supportsDescriptors) { + var regExpFlagsGetter = function flags() { + if (!ES.TypeIsObject(this)) { + throw new TypeError('Method called on incompatible type: must be an object.'); + } + var result = ''; + if (this.global) { + result += 'g'; + } + if (this.ignoreCase) { + result += 'i'; + } + if (this.multiline) { + result += 'm'; + } + if (this.unicode) { + result += 'u'; + } + if (this.sticky) { + result += 'y'; + } + return result; + }; + + Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter); + } + + var regExpSupportsFlagsWithRegex = valueOrFalseIfThrows(function () { + return String(new RegExp(/a/g, 'i')) === '/a/i'; + }); + + if (!regExpSupportsFlagsWithRegex && supportsDescriptors) { + var OrigRegExp = RegExp; + var RegExpShim = function RegExp(pattern, flags) { + var calledWithNew = this instanceof RegExp; + if (!calledWithNew && (Type.regex(pattern) || (pattern && pattern.constructor === RegExp))) { + return pattern; + } + if (Type.regex(pattern) && Type.string(flags)) { + return new RegExp(pattern.source, flags); + } + return new OrigRegExp(pattern, flags); + }; + Value.preserveToString(RegExpShim, OrigRegExp); + if (Object.setPrototypeOf) { + // sets up proper prototype chain where possible + Object.setPrototypeOf(OrigRegExp, RegExpShim); + } + _forEach(Object.getOwnPropertyNames(OrigRegExp), function (key) { + if (key === '$input') { return; } // Chrome < v39 & Opera < 26 have a nonstandard "$input" property + if (key in noop) { return; } + Value.proxy(OrigRegExp, key, RegExpShim); + }); + RegExpShim.prototype = OrigRegExp.prototype; + Value.redefine(OrigRegExp.prototype, 'constructor', RegExpShim); + /*globals RegExp: true */ + RegExp = RegExpShim; + Value.redefine(globals, 'RegExp', RegExpShim); + /*globals RegExp: false */ + } + + if (supportsDescriptors) { + var regexGlobals = { + input: '$_', + lastMatch: '$&', + lastParen: '$+', + leftContext: '$`', + rightContext: '$\'' + }; + _forEach(Object.keys(regexGlobals), function (prop) { + if (prop in RegExp && !(regexGlobals[prop] in RegExp)) { + Value.getter(RegExp, regexGlobals[prop], function get() { + return RegExp[prop]; + }); + } + }); + } + addDefaultSpecies(RegExp); + + var inverseEpsilon = 1 / Number.EPSILON; + var roundTiesToEven = function roundTiesToEven(n) { + // Even though this reduces down to `return n`, it takes advantage of built-in rounding. + return (n + inverseEpsilon) - inverseEpsilon; + }; + var BINARY_32_EPSILON = Math.pow(2, -23); + var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON); + var BINARY_32_MIN_VALUE = Math.pow(2, -126); + var numberCLZ = Number.prototype.clz; + delete Number.prototype.clz; // Safari 8 has Number#clz + + var MathShims = { + acosh: function acosh(value) { + var x = Number(value); + if (Number.isNaN(x) || value < 1) { return NaN; } + if (x === 1) { return 0; } + if (x === Infinity) { return x; } + return _log(x / Math.E + _sqrt(x + 1) * _sqrt(x - 1) / Math.E) + 1; + }, + + asinh: function asinh(value) { + var x = Number(value); + if (x === 0 || !globalIsFinite(x)) { + return x; + } + return x < 0 ? -Math.asinh(-x) : _log(x + _sqrt(x * x + 1)); + }, + + atanh: function atanh(value) { + var x = Number(value); + if (Number.isNaN(x) || x < -1 || x > 1) { + return NaN; + } + if (x === -1) { return -Infinity; } + if (x === 1) { return Infinity; } + if (x === 0) { return x; } + return 0.5 * _log((1 + x) / (1 - x)); + }, + + cbrt: function cbrt(value) { + var x = Number(value); + if (x === 0) { return x; } + var negate = x < 0, result; + if (negate) { x = -x; } + if (x === Infinity) { + result = Infinity; + } else { + result = Math.exp(_log(x) / 3); + // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods + result = (x / (result * result) + (2 * result)) / 3; + } + return negate ? -result : result; + }, + + clz32: function clz32(value) { + // See https://bugs.ecmascript.org/show_bug.cgi?id=2465 + var x = Number(value); + var number = ES.ToUint32(x); + if (number === 0) { + return 32; + } + return numberCLZ ? _call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * Math.LOG2E); + }, + + cosh: function cosh(value) { + var x = Number(value); + if (x === 0) { return 1; } // +0 or -0 + if (Number.isNaN(x)) { return NaN; } + if (!globalIsFinite(x)) { return Infinity; } + if (x < 0) { x = -x; } + if (x > 21) { return Math.exp(x) / 2; } + return (Math.exp(x) + Math.exp(-x)) / 2; + }, + + expm1: function expm1(value) { + var x = Number(value); + if (x === -Infinity) { return -1; } + if (!globalIsFinite(x) || x === 0) { return x; } + if (_abs(x) > 0.5) { + return Math.exp(x) - 1; + } + // A more precise approximation using Taylor series expansion + // from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986 + var t = x; + var sum = 0; + var n = 1; + while (sum + t !== sum) { + sum += t; + n += 1; + t *= x / n; + } + return sum; + }, + + hypot: function hypot(x, y) { + var result = 0; + var largest = 0; + for (var i = 0; i < arguments.length; ++i) { + var value = _abs(Number(arguments[i])); + if (largest < value) { + result *= (largest / value) * (largest / value); + result += 1; + largest = value; + } else { + result += (value > 0 ? (value / largest) * (value / largest) : value); + } + } + return largest === Infinity ? Infinity : largest * _sqrt(result); + }, + + log2: function log2(value) { + return _log(value) * Math.LOG2E; + }, + + log10: function log10(value) { + return _log(value) * Math.LOG10E; + }, + + log1p: function log1p(value) { + var x = Number(value); + if (x < -1 || Number.isNaN(x)) { return NaN; } + if (x === 0 || x === Infinity) { return x; } + if (x === -1) { return -Infinity; } + + return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1)); + }, + + sign: function sign(value) { + var number = Number(value); + if (number === 0) { return number; } + if (Number.isNaN(number)) { return number; } + return number < 0 ? -1 : 1; + }, + + sinh: function sinh(value) { + var x = Number(value); + if (!globalIsFinite(x) || x === 0) { return x; } + + if (_abs(x) < 1) { + return (Math.expm1(x) - Math.expm1(-x)) / 2; + } + return (Math.exp(x - 1) - Math.exp(-x - 1)) * Math.E / 2; + }, + + tanh: function tanh(value) { + var x = Number(value); + if (Number.isNaN(x) || x === 0) { return x; } + if (x === Infinity) { return 1; } + if (x === -Infinity) { return -1; } + var a = Math.expm1(x); + var b = Math.expm1(-x); + if (a === Infinity) { return 1; } + if (b === Infinity) { return -1; } + return (a - b) / (Math.exp(x) + Math.exp(-x)); + }, + + trunc: function trunc(value) { + var x = Number(value); + return x < 0 ? -_floor(-x) : _floor(x); + }, + + imul: function imul(x, y) { + // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul + var a = ES.ToUint32(x); + var b = ES.ToUint32(y); + var ah = (a >>> 16) & 0xffff; + var al = a & 0xffff; + var bh = (b >>> 16) & 0xffff; + var bl = b & 0xffff; + // the shift by 0 fixes the sign on the high part + // the final |0 converts the unsigned value into a signed value + return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0); + }, + + fround: function fround(x) { + var v = Number(x); + if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) { + return v; + } + var sign = Math.sign(v); + var abs = _abs(v); + if (abs < BINARY_32_MIN_VALUE) { + return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON; + } + // Veltkamp's splitting (?) + var a = (1 + BINARY_32_EPSILON / Number.EPSILON) * abs; + var result = a - (a - abs); + if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) { + return sign * Infinity; + } + return sign * result; + } + }; + defineProperties(Math, MathShims); + // IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0 + defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17); + // IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7) + defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7)); + // Chrome 40 has an imprecise Math.tanh with very small numbers + defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17); + // Chrome 40 loses Math.acosh precision with high numbers + defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity); + // Firefox 38 on Windows + defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - Math.cbrt(1e-300) / 1e-100) / Number.EPSILON > 8); + // node 0.11 has an imprecise Math.sinh with very small numbers + defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17); + // FF 35 on Linux reports 22025.465794806725 for Math.expm1(10) + var expm1OfTen = Math.expm1(10); + defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168); + + var origMathRound = Math.round; + // breaks in e.g. Safari 8, Internet Explorer 11, Opera 12 + var roundHandlesBoundaryConditions = Math.round(0.5 - Number.EPSILON / 4) === 0 && Math.round(-0.5 + Number.EPSILON / 3.99) === 1; + + // When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers. + // This behavior should be governed by "round to nearest, ties to even mode" + // see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-number-type + // These are the boundary cases where it breaks. + var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1; + var largestPositiveNumberWhereRoundBreaks = 2 * inverseEpsilon - 1; + var roundDoesNotIncreaseIntegers = [smallestPositiveNumberWhereRoundBreaks, largestPositiveNumberWhereRoundBreaks].every(function (num) { + return Math.round(num) === num; + }); + defineProperty(Math, 'round', function round(x) { + var floor = _floor(x); + var ceil = floor === -1 ? -0 : floor + 1; + return x - floor < 0.5 ? floor : ceil; + }, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers); + Value.preserveToString(Math.round, origMathRound); + + var origImul = Math.imul; + if (Math.imul(0xffffffff, 5) !== -5) { + // Safari 6.1, at least, reports "0" for this value + Math.imul = MathShims.imul; + Value.preserveToString(Math.imul, origImul); + } + if (Math.imul.length !== 2) { + // Safari 8.0.4 has a length of 1 + // fixed in https://bugs.webkit.org/show_bug.cgi?id=143658 + overrideNative(Math, 'imul', function imul(x, y) { + return _apply(origImul, Math, arguments); + }); + } + + // Promises + // Simplest possible implementation; use a 3rd-party library if you + // want the best possible speed and/or long stack traces. + var PromiseShim = (function () { + + ES.IsPromise = function (promise) { + if (!ES.TypeIsObject(promise)) { + return false; + } + if (typeof promise._promise === 'undefined') { + return false; // uninitialized, or missing our hidden field. + } + return true; + }; + + // "PromiseCapability" in the spec is what most promise implementations + // call a "deferred". + var PromiseCapability = function (C) { + if (!ES.IsConstructor(C)) { + throw new TypeError('Bad promise constructor'); + } + var capability = this; + var resolver = function (resolve, reject) { + if (capability.resolve !== void 0 || capability.reject !== void 0) { + throw new TypeError('Bad Promise implementation!'); + } + capability.resolve = resolve; + capability.reject = reject; + }; + capability.promise = new C(resolver); + if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) { + throw new TypeError('Bad promise constructor'); + } + }; + + // find an appropriate setImmediate-alike + var setTimeout = globals.setTimeout; + var makeZeroTimeout; + /*global window */ + if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) { + makeZeroTimeout = function () { + // from http://dbaron.org/log/20100309-faster-timeouts + var timeouts = []; + var messageName = 'zero-timeout-message'; + var setZeroTimeout = function (fn) { + _push(timeouts, fn); + window.postMessage(messageName, '*'); + }; + var handleMessage = function (event) { + if (event.source === window && event.data === messageName) { + event.stopPropagation(); + if (timeouts.length === 0) { return; } + var fn = _shift(timeouts); + fn(); + } + }; + window.addEventListener('message', handleMessage, true); + return setZeroTimeout; + }; + } + var makePromiseAsap = function () { + // An efficient task-scheduler based on a pre-existing Promise + // implementation, which we can use even if we override the + // global Promise below (in order to workaround bugs) + // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671 + var P = globals.Promise; + return P && P.resolve && function (task) { + return P.resolve().then(task); + }; + }; + /*global process */ + var enqueue = ES.IsCallable(globals.setImmediate) ? + globals.setImmediate.bind(globals) : + typeof process === 'object' && process.nextTick ? process.nextTick : + makePromiseAsap() || + (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() : + function (task) { setTimeout(task, 0); }); // fallback + + // Constants for Promise implementation + var PROMISE_IDENTITY = 1; + var PROMISE_THROWER = 2; + var PROMISE_PENDING = 3; + var PROMISE_FULFILLED = 4; + var PROMISE_REJECTED = 5; + + var promiseReactionJob = function (reaction, argument) { + var promiseCapability = reaction.capabilities; + var handler = reaction.handler; + var handlerResult, handlerException = false, f; + if (handler === PROMISE_IDENTITY) { + handlerResult = argument; + } else if (handler === PROMISE_THROWER) { + handlerResult = argument; + handlerException = true; + } else { + try { + handlerResult = handler(argument); + } catch (e) { + handlerResult = e; + handlerException = true; + } + } + f = handlerException ? promiseCapability.reject : promiseCapability.resolve; + f(handlerResult); + }; + + var triggerPromiseReactions = function (reactions, argument) { + _forEach(reactions, function (reaction) { + enqueue(function () { + promiseReactionJob(reaction, argument); + }); + }); + }; + + var fulfillPromise = function (promise, value) { + var _promise = promise._promise; + var reactions = _promise.fulfillReactions; + _promise.result = value; + _promise.fulfillReactions = void 0; + _promise.rejectReactions = void 0; + _promise.state = PROMISE_FULFILLED; + triggerPromiseReactions(reactions, value); + }; + + var rejectPromise = function (promise, reason) { + var _promise = promise._promise; + var reactions = _promise.rejectReactions; + _promise.result = reason; + _promise.fulfillReactions = void 0; + _promise.rejectReactions = void 0; + _promise.state = PROMISE_REJECTED; + triggerPromiseReactions(reactions, reason); + }; + + var createResolvingFunctions = function (promise) { + var alreadyResolved = false; + var resolve = function (resolution) { + var then; + if (alreadyResolved) { return; } + alreadyResolved = true; + if (resolution === promise) { + return rejectPromise(promise, new TypeError('Self resolution')); + } + if (!ES.TypeIsObject(resolution)) { + return fulfillPromise(promise, resolution); + } + try { + then = resolution.then; + } catch (e) { + return rejectPromise(promise, e); + } + if (!ES.IsCallable(then)) { + return fulfillPromise(promise, resolution); + } + enqueue(function () { + promiseResolveThenableJob(promise, resolution, then); + }); + }; + var reject = function (reason) { + if (alreadyResolved) { return; } + alreadyResolved = true; + return rejectPromise(promise, reason); + }; + return { resolve: resolve, reject: reject }; + }; + + var promiseResolveThenableJob = function (promise, thenable, then) { + var resolvingFunctions = createResolvingFunctions(promise); + var resolve = resolvingFunctions.resolve; + var reject = resolvingFunctions.reject; + try { + _call(then, thenable, resolve, reject); + } catch (e) { + reject(e); + } + }; + + // This is a common step in many Promise methods + var getPromiseSpecies = function (C) { + if (!ES.TypeIsObject(C)) { + throw new TypeError('Promise is not object'); + } + var S = C[symbolSpecies]; + if (S !== void 0 && S !== null) { + return S; + } + return C; + }; + + var Promise = function Promise(resolver) { + if (!(this instanceof Promise)) { + throw new TypeError('Constructor Promise requires "new"'); + } + if (this && this._promise) { + throw new TypeError('Bad construction'); + } + // see https://bugs.ecmascript.org/show_bug.cgi?id=2482 + if (!ES.IsCallable(resolver)) { + throw new TypeError('not a valid resolver'); + } + var promise = emulateES6construct(this, Promise, Promise$prototype, { + _promise: { + result: void 0, + state: PROMISE_PENDING, + fulfillReactions: [], + rejectReactions: [] + } + }); + var resolvingFunctions = createResolvingFunctions(promise); + var reject = resolvingFunctions.reject; + try { + resolver(resolvingFunctions.resolve, reject); + } catch (e) { + reject(e); + } + return promise; + }; + var Promise$prototype = Promise.prototype; + + var _promiseAllResolver = function (index, values, capability, remaining) { + var alreadyCalled = false; + return function (x) { + if (alreadyCalled) { return; } + alreadyCalled = true; + values[index] = x; + if ((--remaining.count) === 0) { + var resolve = capability.resolve; + resolve(values); // call w/ this===undefined + } + }; + }; + + var performPromiseAll = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator; + var values = [], remaining = { count: 1 }, next, nextValue; + for (var index = 0; ; index++) { + try { + next = ES.IteratorStep(it); + if (next === false) { + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + values[index] = void 0; + var nextPromise = C.resolve(nextValue); + var resolveElement = _promiseAllResolver( + index, values, resultCapability, remaining + ); + remaining.count++; + nextPromise.then(resolveElement, resultCapability.reject); + } + if ((--remaining.count) === 0) { + var resolve = resultCapability.resolve; + resolve(values); // call w/ this===undefined + } + return resultCapability.promise; + }; + + var performPromiseRace = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator, next, nextValue, nextPromise; + while (true) { + try { + next = ES.IteratorStep(it); + if (next === false) { + // NOTE: If iterable has no items, resulting promise will never + // resolve; see: + // https://github.com/domenic/promises-unwrapping/issues/75 + // https://bugs.ecmascript.org/show_bug.cgi?id=2515 + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + nextPromise = C.resolve(nextValue); + nextPromise.then(resultCapability.resolve, resultCapability.reject); + } + return resultCapability.promise; + }; + + defineProperties(Promise, { + all: function all(iterable) { + var C = getPromiseSpecies(this); + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseAll(iteratorRecord, C, capability); + } catch (e) { + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + e = ee; + } + } + var reject = capability.reject; + reject(e); + return capability.promise; + } + }, + + race: function race(iterable) { + var C = getPromiseSpecies(this); + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseRace(iteratorRecord, C, capability); + } catch (e) { + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + e = ee; + } + } + var reject = capability.reject; + reject(e); + return capability.promise; + } + }, + + reject: function reject(reason) { + var C = this; + var capability = new PromiseCapability(C); + var rejectFunc = capability.reject; + rejectFunc(reason); // call with this===undefined + return capability.promise; + }, + + resolve: function resolve(v) { + // See https://esdiscuss.org/topic/fixing-promise-resolve for spec + var C = this; + if (ES.IsPromise(v)) { + var constructor = v.constructor; + if (constructor === C) { return v; } + } + var capability = new PromiseCapability(C); + var resolveFunc = capability.resolve; + resolveFunc(v); // call with this===undefined + return capability.promise; + } + }); + + defineProperties(Promise$prototype, { + 'catch': function (onRejected) { + return this.then(void 0, onRejected); + }, + + then: function then(onFulfilled, onRejected) { + var promise = this; + if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); } + var C = ES.SpeciesConstructor(promise, Promise); + var resultCapability = new PromiseCapability(C); + // PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability) + if (!ES.IsCallable(onFulfilled)) { + onFulfilled = PROMISE_IDENTITY; + } + if (!ES.IsCallable(onRejected)) { + onRejected = PROMISE_THROWER; + } + var fulfillReaction = { capabilities: resultCapability, handler: onFulfilled }; + var rejectReaction = { capabilities: resultCapability, handler: onRejected }; + var _promise = promise._promise, value; + switch (_promise.state) { + case PROMISE_PENDING: + _push(_promise.fulfillReactions, fulfillReaction); + _push(_promise.rejectReactions, rejectReaction); + break; + case PROMISE_FULFILLED: + value = _promise.result; + enqueue(function () { + promiseReactionJob(fulfillReaction, value); + }); + break; + case PROMISE_REJECTED: + value = _promise.result; + enqueue(function () { + promiseReactionJob(rejectReaction, value); + }); + break; + default: + throw new TypeError('unexpected'); + } + return resultCapability.promise; + } + }); + + return Promise; + }()); + + // Chrome's native Promise has extra methods that it shouldn't have. Let's remove them. + if (globals.Promise) { + delete globals.Promise.accept; + delete globals.Promise.defer; + delete globals.Promise.prototype.chain; + } + + // export the Promise constructor. + defineProperties(globals, { Promise: PromiseShim }); + // In Chrome 33 (and thereabouts) Promise is defined, but the + // implementation is buggy in a number of ways. Let's check subclassing + // support to see if we have a buggy implementation. + var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) { + return S.resolve(42).then(function () {}) instanceof S; + }); + var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { globals.Promise.reject(42).then(null, 5).then(null, noop); }); + var promiseRequiresObjectContext = throwsError(function () { globals.Promise.call(3, noop); }); + // Promise.resolve() was errata'ed late in the ES6 process. + // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742 + // https://code.google.com/p/v8/issues/detail?id=4161 + // It serves as a proxy for a number of other bugs in early Promise + // implementations. + var promiseResolveBroken = (function (Promise) { + var p = Promise.resolve(5); + p.constructor = {}; + var p2 = Promise.resolve(p); + return (p === p2); // This *should* be false! + })(globals.Promise); + if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks || + !promiseRequiresObjectContext || promiseResolveBroken) { + /*globals Promise: true */ + Promise = PromiseShim; + /*globals Promise: false */ + overrideNative(globals, 'Promise', PromiseShim); + } + addDefaultSpecies(Promise); + + // Map and Set require a true ES5 environment + // Their fast path also requires that the environment preserve + // property insertion order, which is not guaranteed by the spec. + var testOrder = function (a) { + var b = Object.keys(_reduce(a, function (o, k) { + o[k] = true; + return o; + }, {})); + return a.join(':') === b.join(':'); + }; + var preservesInsertionOrder = testOrder(['z', 'a', 'bb']); + // some engines (eg, Chrome) only preserve insertion order for string keys + var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]); + + if (supportsDescriptors) { + + var fastkey = function fastkey(key) { + if (!preservesInsertionOrder) { + return null; + } + var type = typeof key; + if (type === 'undefined' || key === null) { + return '^' + String(key); + } else if (type === 'string') { + return '$' + key; + } else if (type === 'number') { + // note that -0 will get coerced to "0" when used as a property key + if (!preservesNumericInsertionOrder) { + return 'n' + key; + } + return key; + } else if (type === 'boolean') { + return 'b' + key; + } + return null; + }; + + var emptyObject = function emptyObject() { + // accomodate some older not-quite-ES5 browsers + return Object.create ? Object.create(null) : {}; + }; + + var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) { + if (Array.isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (entry) { + map.set(entry[0], entry[1]); + }); + } else if (iterable instanceof MapConstructor) { + _call(MapConstructor.prototype.forEach, iterable, function (value, key) { + map.set(key, value); + }); + } else { + var iter, adder; + if (iterable !== null && typeof iterable !== 'undefined') { + adder = map.set; + if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextItem = next.value; + try { + if (!ES.TypeIsObject(nextItem)) { + throw new TypeError('expected iterable of pairs'); + } + _call(adder, map, nextItem[0], nextItem[1]); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) { + if (Array.isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (value) { + set.add(value); + }); + } else if (iterable instanceof SetConstructor) { + _call(SetConstructor.prototype.forEach, iterable, function (value) { + set.add(value); + }); + } else { + var iter, adder; + if (iterable !== null && typeof iterable !== 'undefined') { + adder = set.add; + if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextValue = next.value; + try { + _call(adder, set, nextValue); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + + var collectionShims = { + Map: (function () { + + var empty = {}; + + var MapEntry = function MapEntry(key, value) { + this.key = key; + this.value = value; + this.next = null; + this.prev = null; + }; + + MapEntry.prototype.isRemoved = function isRemoved() { + return this.key === empty; + }; + + var isMap = function isMap(map) { + return !!map._es6map; + }; + + var requireMapSlot = function requireMapSlot(map, method) { + if (!ES.TypeIsObject(map) || !isMap(map)) { + throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + String(map)); + } + }; + + var MapIterator = function MapIterator(map, kind) { + requireMapSlot(map, '[[MapIterator]]'); + this.head = map._head; + this.i = this.head; + this.kind = kind; + }; + + MapIterator.prototype = { + next: function next() { + var i = this.i, kind = this.kind, head = this.head, result; + if (typeof this.i === 'undefined') { + return { value: void 0, done: true }; + } + while (i.isRemoved() && i !== head) { + // back up off of removed entries + i = i.prev; + } + // advance to next unreturned element. + while (i.next !== head) { + i = i.next; + if (!i.isRemoved()) { + if (kind === 'key') { + result = i.key; + } else if (kind === 'value') { + result = i.value; + } else { + result = [i.key, i.value]; + } + this.i = i; + return { value: result, done: false }; + } + } + // once the iterator is done, it is done forever. + this.i = void 0; + return { value: void 0, done: true }; + } + }; + addIterator(MapIterator.prototype); + + var MapShim = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + if (this && this._es6map) { + throw new TypeError('Bad construction'); + } + var map = emulateES6construct(this, Map, Map$prototype, { + _es6map: true, + _head: null, + _storage: emptyObject(), + _size: 0 + }); + + var head = new MapEntry(null, null); + // circular doubly-linked list. + head.next = head.prev = head; + map._head = head; + + // Optionally initialize map from iterable + if (arguments.length > 0) { + addIterableToMap(Map, map, arguments[0]); + } + return map; + }; + var Map$prototype = MapShim.prototype; + + Value.getter(Map$prototype, 'size', function () { + if (typeof this._size === 'undefined') { + throw new TypeError('size method called on incompatible Map'); + } + return this._size; + }); + + defineProperties(Map$prototype, { + get: function get(key) { + requireMapSlot(this, 'get'); + var fkey = fastkey(key); + if (fkey !== null) { + // fast O(1) path + var entry = this._storage[fkey]; + if (entry) { + return entry.value; + } else { + return; + } + } + var head = this._head, i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return i.value; + } + } + }, + + has: function has(key) { + requireMapSlot(this, 'has'); + var fkey = fastkey(key); + if (fkey !== null) { + // fast O(1) path + return typeof this._storage[fkey] !== 'undefined'; + } + var head = this._head, i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return true; + } + } + return false; + }, + + set: function set(key, value) { + requireMapSlot(this, 'set'); + var head = this._head, i = head, entry; + var fkey = fastkey(key); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] !== 'undefined') { + this._storage[fkey].value = value; + return this; + } else { + entry = this._storage[fkey] = new MapEntry(key, value); + i = head.prev; + // fall through + } + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.value = value; + return this; + } + } + entry = entry || new MapEntry(key, value); + if (ES.SameValue(-0, key)) { + entry.key = +0; // coerce -0 to +0 in entry + } + entry.next = this._head; + entry.prev = this._head.prev; + entry.prev.next = entry; + entry.next.prev = entry; + this._size += 1; + return this; + }, + + 'delete': function (key) { + requireMapSlot(this, 'delete'); + var head = this._head, i = head; + var fkey = fastkey(key); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] === 'undefined') { + return false; + } + i = this._storage[fkey].prev; + delete this._storage[fkey]; + // fall through + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.key = i.value = empty; + i.prev.next = i.next; + i.next.prev = i.prev; + this._size -= 1; + return true; + } + } + return false; + }, + + clear: function clear() { + requireMapSlot(this, 'clear'); + this._size = 0; + this._storage = emptyObject(); + var head = this._head, i = head, p = i.next; + while ((i = p) !== head) { + i.key = i.value = empty; + p = i.next; + i.next = i.prev = head; + } + head.next = head.prev = head; + }, + + keys: function keys() { + requireMapSlot(this, 'keys'); + return new MapIterator(this, 'key'); + }, + + values: function values() { + requireMapSlot(this, 'values'); + return new MapIterator(this, 'value'); + }, + + entries: function entries() { + requireMapSlot(this, 'entries'); + return new MapIterator(this, 'key+value'); + }, + + forEach: function forEach(callback) { + requireMapSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var it = this.entries(); + for (var entry = it.next(); !entry.done; entry = it.next()) { + if (context) { + _call(callback, context, entry.value[1], entry.value[0], this); + } else { + callback(entry.value[1], entry.value[0], this); + } + } + } + }); + addIterator(Map$prototype, Map$prototype.entries); + + return MapShim; + }()), + + Set: (function () { + var isSet = function isSet(set) { + return set._es6set && typeof set._storage !== 'undefined'; + }; + var requireSetSlot = function requireSetSlot(set, method) { + if (!ES.TypeIsObject(set) || !isSet(set)) { + // https://github.com/paulmillr/es6-shim/issues/176 + throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + String(set)); + } + }; + + // Creating a Map is expensive. To speed up the common case of + // Sets containing only string or numeric keys, we use an object + // as backing storage and lazily create a full Map only when + // required. + var SetShim = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + if (this && this._es6set) { + throw new TypeError('Bad construction'); + } + var set = emulateES6construct(this, Set, Set$prototype, { + _es6set: true, + '[[SetData]]': null, + _storage: emptyObject() + }); + if (!set._es6set) { + throw new TypeError('bad set'); + } + + // Optionally initialize Set from iterable + if (arguments.length > 0) { + addIterableToSet(Set, set, arguments[0]); + } + return set; + }; + var Set$prototype = SetShim.prototype; + + // Switch from the object backing storage to a full Map. + var ensureMap = function ensureMap(set) { + if (!set['[[SetData]]']) { + var m = set['[[SetData]]'] = new collectionShims.Map(); + _forEach(Object.keys(set._storage), function (k) { + if (k === '^null') { + k = null; + } else if (k === '^undefined') { + k = void 0; + } else { + var first = k.charAt(0); + if (first === '$') { + k = _strSlice(k, 1); + } else if (first === 'n') { + k = +_strSlice(k, 1); + } else if (first === 'b') { + k = k === 'btrue'; + } else { + k = +k; + } + } + m.set(k, k); + }); + set._storage = null; // free old backing storage + } + }; + + Value.getter(SetShim.prototype, 'size', function () { + requireSetSlot(this, 'size'); + ensureMap(this); + return this['[[SetData]]'].size; + }); + + defineProperties(SetShim.prototype, { + has: function has(key) { + requireSetSlot(this, 'has'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + return !!this._storage[fkey]; + } + ensureMap(this); + return this['[[SetData]]'].has(key); + }, + + add: function add(key) { + requireSetSlot(this, 'add'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + this._storage[fkey] = true; + return this; + } + ensureMap(this); + this['[[SetData]]'].set(key, key); + return this; + }, + + 'delete': function (key) { + requireSetSlot(this, 'delete'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + var hasFKey = _hasOwnProperty(this._storage, fkey); + return (delete this._storage[fkey]) && hasFKey; + } + ensureMap(this); + return this['[[SetData]]']['delete'](key); + }, + + clear: function clear() { + requireSetSlot(this, 'clear'); + if (this._storage) { + this._storage = emptyObject(); + } else { + this['[[SetData]]'].clear(); + } + }, + + values: function values() { + requireSetSlot(this, 'values'); + ensureMap(this); + return this['[[SetData]]'].values(); + }, + + entries: function entries() { + requireSetSlot(this, 'entries'); + ensureMap(this); + return this['[[SetData]]'].entries(); + }, + + forEach: function forEach(callback) { + requireSetSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var entireSet = this; + ensureMap(entireSet); + this['[[SetData]]'].forEach(function (value, key) { + if (context) { + _call(callback, context, key, key, entireSet); + } else { + callback(key, key, entireSet); + } + }); + } + }); + defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true); + addIterator(SetShim.prototype, SetShim.prototype.values); + + return SetShim; + }()) + }; + defineProperties(globals, collectionShims); + + if (globals.Map || globals.Set) { + // Safari 8, for example, doesn't accept an iterable. + var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; }); + if (!mapAcceptsArguments) { + var OrigMapNoArgs = globals.Map; + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMapNoArgs(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + Object.setPrototypeOf(m, globals.Map.prototype); + defineProperty(m, 'constructor', Map, true); + return m; + }; + globals.Map.prototype = create(OrigMapNoArgs.prototype); + Value.preserveToString(globals.Map, OrigMapNoArgs); + } + var testMap = new Map(); + var mapUsesSameValueZero = (function (m) { + m['delete'](0); + m['delete'](-0); + m.set(0, 3); + m.get(-0, 4); + return m.get(0) === 3 && m.get(-0) === 4; + }(testMap)); + var mapSupportsChaining = testMap.set(1, 2) === testMap; + if (!mapUsesSameValueZero || !mapSupportsChaining) { + var origMapSet = Map.prototype.set; + overrideNative(Map.prototype, 'set', function set(k, v) { + _call(origMapSet, this, k === 0 ? 0 : k, v); + return this; + }); + } + if (!mapUsesSameValueZero) { + var origMapGet = Map.prototype.get; + var origMapHas = Map.prototype.has; + defineProperties(Map.prototype, { + get: function get(k) { + return _call(origMapGet, this, k === 0 ? 0 : k); + }, + has: function has(k) { + return _call(origMapHas, this, k === 0 ? 0 : k); + } + }, true); + Value.preserveToString(Map.prototype.get, origMapGet); + Value.preserveToString(Map.prototype.has, origMapHas); + } + var testSet = new Set(); + var setUsesSameValueZero = (function (s) { + s['delete'](0); + s.add(-0); + return !s.has(0); + }(testSet)); + var setSupportsChaining = testSet.add(1) === testSet; + if (!setUsesSameValueZero || !setSupportsChaining) { + var origSetAdd = Set.prototype.add; + Set.prototype.add = function add(v) { + _call(origSetAdd, this, v === 0 ? 0 : v); + return this; + }; + Value.preserveToString(Set.prototype.add, origSetAdd); + } + if (!setUsesSameValueZero) { + var origSetHas = Set.prototype.has; + Set.prototype.has = function has(v) { + return _call(origSetHas, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype.has, origSetHas); + var origSetDel = Set.prototype['delete']; + Set.prototype['delete'] = function SetDelete(v) { + return _call(origSetDel, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype['delete'], origSetDel); + } + var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) { + var m = new M([]); + // Firefox 32 is ok with the instantiating the subclass but will + // throw when the map is used. + m.set(42, 42); + return m instanceof M; + }); + var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible + var mapRequiresNew = (function () { + try { + return !(globals.Map() instanceof globals.Map); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) { + var OrigMap = globals.Map; + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMap(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + Object.setPrototypeOf(m, Map.prototype); + defineProperty(m, 'constructor', Map, true); + return m; + }; + globals.Map.prototype = OrigMap.prototype; + Value.preserveToString(globals.Map, OrigMap); + } + var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) { + var s = new S([]); + s.add(42, 42); + return s instanceof S; + }); + var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible + var setRequiresNew = (function () { + try { + return !(globals.Set() instanceof globals.Set); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) { + var OrigSet = globals.Set; + globals.Set = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + var s = new OrigSet(); + if (arguments.length > 0) { + addIterableToSet(Set, s, arguments[0]); + } + Object.setPrototypeOf(s, Set.prototype); + defineProperty(s, 'constructor', Set, true); + return s; + }; + globals.Set.prototype = OrigSet.prototype; + Value.preserveToString(globals.Set, OrigSet); + } + var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () { + return (new Map()).keys().next().done; + }); + /* + - In Firefox < 23, Map#size is a function. + - In all current Firefox, Set#entries/keys/values & Map#clear do not exist + - https://bugzilla.mozilla.org/show_bug.cgi?id=869996 + - In Firefox 24, Map and Set do not implement forEach + - In Firefox 25 at least, Map and Set are callable without "new" + */ + if ( + typeof globals.Map.prototype.clear !== 'function' || + new globals.Set().size !== 0 || + new globals.Map().size !== 0 || + typeof globals.Map.prototype.keys !== 'function' || + typeof globals.Set.prototype.keys !== 'function' || + typeof globals.Map.prototype.forEach !== 'function' || + typeof globals.Set.prototype.forEach !== 'function' || + isCallableWithoutNew(globals.Map) || + isCallableWithoutNew(globals.Set) || + typeof (new globals.Map().keys().next) !== 'function' || // Safari 8 + mapIterationThrowsStopIterator || // Firefox 25 + !mapSupportsSubclassing + ) { + delete globals.Map; // necessary to overwrite in Safari 8 + delete globals.Set; // necessary to overwrite in Safari 8 + defineProperties(globals, { + Map: collectionShims.Map, + Set: collectionShims.Set + }, true); + } + } + if (globals.Set.prototype.keys !== globals.Set.prototype.values) { + // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 + defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); + } + // Shim incomplete iterator implementations. + addIterator(Object.getPrototypeOf((new globals.Map()).keys())); + addIterator(Object.getPrototypeOf((new globals.Set()).keys())); + } + addDefaultSpecies(Map); + addDefaultSpecies(Set); + + // Reflect + if (!globals.Reflect) { + defineProperty(globals, 'Reflect', {}); + } + var Reflect = globals.Reflect; + + var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) { + if (!ES.TypeIsObject(target)) { + throw new TypeError('target must be an object'); + } + }; + + // Some Reflect methods are basically the same as + // those on the Object global, except that a TypeError is thrown if + // target isn't an object. As well as returning a boolean indicating + // the success of the operation. + defineProperties(globals.Reflect, { + // Apply method in a functional form. + apply: function apply() { + return _apply(ES.Call, null, arguments); + }, + + // New operator in a functional form. + construct: function construct(constructor, args) { + if (!ES.IsConstructor(constructor)) { + throw new TypeError('First argument must be a constructor.'); + } + var newTarget = (arguments.length < 3) ? constructor : arguments[2]; + if (!ES.IsConstructor(newTarget)) { + throw new TypeError('new.target must be a constructor.'); + } + return ES.Construct(constructor, args, newTarget, 'internal'); + }, + + // When deleting a non-existent or configurable property, + // true is returned. + // When attempting to delete a non-configurable property, + // it will return false. + deleteProperty: function deleteProperty(target, key) { + throwUnlessTargetIsObject(target); + if (supportsDescriptors) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (desc && !desc.configurable) { + return false; + } + } + + // Will return true. + return delete target[key]; + }, + + enumerate: function enumerate(target) { + throwUnlessTargetIsObject(target); + return new ObjectIterator(target, 'key'); + }, + + has: function has(target, key) { + throwUnlessTargetIsObject(target); + return key in target; + } + }); + + if (Object.getOwnPropertyNames) { + defineProperties(globals.Reflect, { + // Basically the result of calling the internal [[OwnPropertyKeys]]. + // Concatenating propertyNames and propertySymbols should do the trick. + // This should continue to work together with a Symbol shim + // which overrides Object.getOwnPropertyNames and implements + // Object.getOwnPropertySymbols. + ownKeys: function ownKeys(target) { + throwUnlessTargetIsObject(target); + var keys = Object.getOwnPropertyNames(target); + + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + _pushApply(keys, Object.getOwnPropertySymbols(target)); + } + + return keys; + } + }); + } + + var callAndCatchException = function ConvertExceptionToBoolean(func) { + return !throwsError(func); + }; + + if (Object.preventExtensions) { + defineProperties(globals.Reflect, { + isExtensible: function isExtensible(target) { + throwUnlessTargetIsObject(target); + return Object.isExtensible(target); + }, + preventExtensions: function preventExtensions(target) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + Object.preventExtensions(target); + }); + } + }); + } + + if (supportsDescriptors) { + var internalGet = function get(target, key, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent === null) { + return undefined; + } + + return internalGet(parent, key, receiver); + } + + if ('value' in desc) { + return desc.value; + } + + if (desc.get) { + return _call(desc.get, receiver); + } + + return undefined; + }; + + var internalSet = function set(target, key, value, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent !== null) { + return internalSet(parent, key, value, receiver); + } + + desc = { + value: void 0, + writable: true, + enumerable: true, + configurable: true + }; + } + + if ('value' in desc) { + if (!desc.writable) { + return false; + } + + if (!ES.TypeIsObject(receiver)) { + return false; + } + + var existingDesc = Object.getOwnPropertyDescriptor(receiver, key); + + if (existingDesc) { + return Reflect.defineProperty(receiver, key, { + value: value + }); + } else { + return Reflect.defineProperty(receiver, key, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + } + + if (desc.set) { + _call(desc.set, receiver, value); + return true; + } + + return false; + }; + + defineProperties(globals.Reflect, { + defineProperty: function defineProperty(target, propertyKey, attributes) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + Object.defineProperty(target, propertyKey, attributes); + }); + }, + + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { + throwUnlessTargetIsObject(target); + return Object.getOwnPropertyDescriptor(target, propertyKey); + }, + + // Syntax in a functional form. + get: function get(target, key) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 2 ? arguments[2] : target; + + return internalGet(target, key, receiver); + }, + + set: function set(target, key, value) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 3 ? arguments[3] : target; + + return internalSet(target, key, value, receiver); + } + }); + } + + if (Object.getPrototypeOf) { + var objectDotGetPrototypeOf = Object.getPrototypeOf; + defineProperties(globals.Reflect, { + getPrototypeOf: function getPrototypeOf(target) { + throwUnlessTargetIsObject(target); + return objectDotGetPrototypeOf(target); + } + }); + } + + if (Object.setPrototypeOf) { + var willCreateCircularPrototype = function (object, proto) { + while (proto) { + if (object === proto) { + return true; + } + proto = Reflect.getPrototypeOf(proto); + } + return false; + }; + + defineProperties(globals.Reflect, { + // Sets the prototype of the given object. + // Returns true on success, otherwise false. + setPrototypeOf: function setPrototypeOf(object, proto) { + throwUnlessTargetIsObject(object); + if (proto !== null && !ES.TypeIsObject(proto)) { + throw new TypeError('proto must be an object or null'); + } + + // If they already are the same, we're done. + if (proto === Reflect.getPrototypeOf(object)) { + return true; + } + + // Cannot alter prototype if object not extensible. + if (Reflect.isExtensible && !Reflect.isExtensible(object)) { + return false; + } + + // Ensure that we do not create a circular prototype chain. + if (willCreateCircularPrototype(object, proto)) { + return false; + } + + Object.setPrototypeOf(object, proto); + + return true; + } + }); + } + + if (String(new Date(NaN)) !== 'Invalid Date') { + var dateToString = Date.prototype.toString; + var shimmedDateToString = function toString() { + var valueOf = +this; + if (valueOf !== valueOf) { + return 'Invalid Date'; + } + return _call(dateToString, this); + }; + overrideNative(Date.prototype, 'toString', shimmedDateToString); + } + + // Annex B HTML methods + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-additional-properties-of-the-string.prototype-object + var stringHTMLshims = { + anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); }, + big: function big() { return ES.CreateHTML(this, 'big', '', ''); }, + blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); }, + bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); }, + fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); }, + fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); }, + fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); }, + italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); }, + link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); }, + small: function small() { return ES.CreateHTML(this, 'small', '', ''); }, + strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); }, + sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); }, + sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); } + }; + _forEach(Object.keys(stringHTMLshims), function (key) { + var method = String.prototype[key]; + var shouldOverwrite = false; + if (ES.IsCallable(method)) { + var output = _call(method, '', ' " '); + var quotesCount = _concat([], output.match(/"/g)).length; + shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2; + } else { + shouldOverwrite = true; + } + if (shouldOverwrite) { + defineProperty(String.prototype, key, stringHTMLshims[key], true); + } + }); + + return globals; +})); diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.map b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.map new file mode 100644 index 0000000..a226caa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.map @@ -0,0 +1 @@ +{"version":3,"sources":["es6-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","_apply","Function","call","bind","apply","_call","not","notThunker","func","notThunk","arguments","throwsError","e","valueOrFalseIfThrows","isCallableWithoutNew","arePropertyDescriptorsSupported","Object","defineProperty","supportsDescriptors","_forEach","Array","prototype","forEach","_reduce","reduce","_filter","filter","_every","every","object","name","value","force","configurable","enumerable","writable","defineProperties","map","keys","method","create","properties","Prototype","key","Value","defineByDescriptor","supportsSubclassing","C","f","setPrototypeOf","Sub","Subclass","arg","o","constructor","startsWithRejectsRegex","String","startsWith","startsWithHandlesInfinity","Infinity","getGlobal","globals","globalIsFinite","isFinite","hasStrictMode","startsWithIsCompliant","_indexOf","indexOf","_toString","toString","_concat","concat","_strSlice","slice","_push","push","_pushApply","_shift","shift","_max","Math","max","_min","min","_floor","floor","_abs","abs","_log","log","_sqrt","sqrt","_hasOwnProperty","hasOwnProperty","ArrayIterator","noop","Symbol","symbolSpecies","species","defaultSpeciesGetter","addDefaultSpecies","getter","Type","x","string","regex","symbol","numberIsNaN","Number","isNaN","numberIsFinite","TypeError","get","proxy","originalObject","targetObject","originalDescriptor","getOwnPropertyDescriptor","getKey","set","setKey","redefine","property","newValue","descriptor","preserveToString","target","source","overrideNative","replacement","original","$iterator$","iterator","Set","addIterator","impl","implementation","isArguments","str","result","length","callee","ES","Call","F","V","args","IsCallable","RequireObjectCoercible","optMessage","TypeIsObject","ToObject","IsConstructor","ToInt32","ToNumber","ToUint32","ToInteger","number","ToLength","len","MAX_SAFE_INTEGER","SameValue","a","b","SameValueZero","IsIterable","GetIterator","itFn","GetMethod","it","p","IteratorComplete","iterResult","IteratorClose","completionIsThrow","returnMethod","innerResult","innerException","IteratorNext","next","IteratorStep","done","Construct","newTarget","isES6internal","Reflect","construct","proto","obj","SpeciesConstructor","O","defaultConstructor","S","CreateHTML","tag","attribute","p1","escapedV","replace","p2","p3","emulateES6construct","defaultNewTarget","defaultProto","slots","fromCodePoint","originalFromCodePoint","codePoints","StringShims","i","RangeError","fromCharCode","join","raw","callSite","cooked","rawString","literalsegments","stringElements","nextIndex","nextKey","nextSeg","nextSub",1,"stringRepeat","repeat","s","times","half","stringMaxLength","StringPrototypeShims","thisStr","numTimes","searchString","searchStr","startArg","start","endsWith","thisLen","posArg","pos","end","includes","position","codePointAt","first","charCodeAt","isEnd","second","hasStringTrimBug","trim","ws","trimRegexp","RegExp","StringIterator","_s","_i","substr","ArrayShims","from","items","mapFn","mapping","T","usingIterator","nextValue","undefined","arrayLike","of","iteratorResult","array","kind","retval","ObjectIterator","getAllKeys","arrayOfSupportsSubclassing","Foo","fooArr","ArrayPrototypeShims","copyWithin","relativeTarget","relativeStart","to","fin","count","direction","fill","relativeEnd","find","predicate","list","thisArg","findIndex","values","entries","unscopables","originalArrayPrototypeValues","getPrototypeOf","arrayFromSwallowsNegativeLengths","arrayFromHandlesIterables","arr","toLengthsCorrectly","reversed","originalForEach","callbackFn","originalMap","originalFilter","some","originalSome","originalEvery","originalReduce","reduceRight","originalReduceRight","maxSafeInteger","pow","MIN_SAFE_INTEGER","EPSILON","parseInt","parseFloat","isInteger","isSafeInteger","item","idx","isEnumerableOn","propertyIsEnumerable","sliceArgs","initial","desiredArgCount","assignTo","assignToSource","assignReducer","symbols","getOwnPropertySymbols","ObjectShims","assign","is","assignHasPendingExceptions","preventExtensions","thrower","ES5ObjectShims","magic","checkArgs","polyfill","FAKENULL","gpo","spo","objectKeysAcceptsPrimitives","originalObjectKeys","getOwnPropertyNames","objectGOPNAcceptsPrimitives","cachedWindowNames","window","originalObjectGetOwnPropertyNames","val","objectGOPDAcceptsPrimitives","originalObjectGetOwnPropertyDescriptor","seal","objectSealAcceptsPrimitives","originalObjectSeal","isSealed","objectIsSealedAcceptsPrimitives","originalObjectIsSealed","freeze","objectFreezeAcceptsPrimitives","originalObjectFreeze","isFrozen","objectIsFrozenAcceptsPrimitives","originalObjectIsFrozen","objectPreventExtensionsAcceptsPrimitives","originalObjectPreventExtensions","isExtensible","objectIsExtensibleAcceptsPrimitives","originalObjectIsExtensible","objectGetProtoAcceptsPrimitives","originalGetProto","flags","regExpFlagsGetter","global","ignoreCase","multiline","unicode","sticky","regExpSupportsFlagsWithRegex","OrigRegExp","RegExpShim","pattern","calledWithNew","regexGlobals","input","lastMatch","lastParen","leftContext","rightContext","prop","inverseEpsilon","roundTiesToEven","n","BINARY_32_EPSILON","BINARY_32_MAX_VALUE","BINARY_32_MIN_VALUE","numberCLZ","clz","MathShims","acosh","NaN","E","asinh","atanh","cbrt","negate","exp","clz32","LOG2E","cosh","expm1","t","sum","hypot","y","largest","log2","log10","LOG10E","log1p","sign","sinh","tanh","trunc","imul","ah","al","bh","bl","fround","v","MAX_VALUE","expm1OfTen","origMathRound","round","roundHandlesBoundaryConditions","smallestPositiveNumberWhereRoundBreaks","largestPositiveNumberWhereRoundBreaks","roundDoesNotIncreaseIntegers","num","ceil","origImul","PromiseShim","IsPromise","promise","_promise","PromiseCapability","capability","resolver","resolve","reject","setTimeout","makeZeroTimeout","postMessage","timeouts","messageName","setZeroTimeout","fn","handleMessage","event","data","stopPropagation","addEventListener","makePromiseAsap","P","Promise","task","then","enqueue","setImmediate","process","nextTick","PROMISE_IDENTITY","PROMISE_THROWER","PROMISE_PENDING","PROMISE_FULFILLED","PROMISE_REJECTED","promiseReactionJob","reaction","argument","promiseCapability","capabilities","handler","handlerResult","handlerException","triggerPromiseReactions","reactions","fulfillPromise","fulfillReactions","rejectReactions","state","rejectPromise","reason","createResolvingFunctions","alreadyResolved","resolution","promiseResolveThenableJob","thenable","resolvingFunctions","getPromiseSpecies","Promise$prototype","_promiseAllResolver","index","remaining","alreadyCalled","performPromiseAll","iteratorRecord","resultCapability","nextPromise","resolveElement","performPromiseRace","all","iterable","ee","race","rejectFunc","resolveFunc","catch","onRejected","onFulfilled","fulfillReaction","rejectReaction","accept","defer","chain","promiseSupportsSubclassing","promiseIgnoresNonFunctionThenCallbacks","promiseRequiresObjectContext","promiseResolveBroken","testOrder","k","preservesInsertionOrder","preservesNumericInsertionOrder","fastkey","type","emptyObject","addIterableToMap","MapConstructor","isArray","entry","iter","adder","nextItem","addIterableToSet","SetConstructor","add","collectionShims","Map","empty","MapEntry","prev","isRemoved","isMap","_es6map","requireMapSlot","MapIterator","head","_head","MapShim","Map$prototype","_storage","_size","fkey","has","delete","clear","callback","context","isSet","_es6set","requireSetSlot","SetShim","Set$prototype","[[SetData]]","ensureMap","m","charAt","size","hasFKey","entireSet","mapAcceptsArguments","OrigMapNoArgs","testMap","mapUsesSameValueZero","mapSupportsChaining","origMapSet","origMapGet","origMapHas","testSet","setUsesSameValueZero","setSupportsChaining","origSetAdd","origSetHas","origSetDel","SetDelete","mapSupportsSubclassing","M","mapFailsToSupportSubclassing","mapRequiresNew","OrigMap","setSupportsSubclassing","setFailsToSupportSubclassing","setRequiresNew","OrigSet","mapIterationThrowsStopIterator","throwUnlessTargetIsObject","deleteProperty","desc","enumerate","ownKeys","callAndCatchException","ConvertExceptionToBoolean","internalGet","receiver","parent","internalSet","existingDesc","propertyKey","attributes","objectDotGetPrototypeOf","willCreateCircularPrototype","Date","dateToString","shimmedDateToString","valueOf","stringHTMLshims","anchor","big","blink","bold","fixed","fontcolor","color","fontsize","italics","link","url","small","strike","sub","sup","shouldOverwrite","output","quotesCount","match","toLowerCase"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAEA,IAAIC,GAASC,SAASC,KAAKC,KAAKF,SAASG,MACzC,IAAIC,GAAQJ,SAASC,KAAKC,KAAKF,SAASC,KAExC,IAAII,GAAM,QAASC,IAAWC,GAC5B,MAAO,SAASC,KAAa,OAAQT,EAAOQ,EAAMT,KAAMW,YAE1D,IAAIC,GAAc,SAAUH,GAC1B,IACEA,GACA,OAAO,OACP,MAAOI,GACP,MAAO,OAGX,IAAIC,GAAuB,QAASA,IAAqBL,GACvD,IACE,MAAOA,KACP,MAAOI,GACP,MAAO,QAIX,IAAIE,GAAuBR,EAAIK,EAC/B,IAAII,GAAkC,WAEpC,OAAQJ,EAAY,WAAcK,OAAOC,kBAAmB,UAE9D,IAAIC,KAAwBF,OAAOC,gBAAkBF,GAErD,IAAII,GAAWlB,SAASC,KAAKC,KAAKiB,MAAMC,UAAUC,QAClD,IAAIC,GAAUtB,SAASC,KAAKC,KAAKiB,MAAMC,UAAUG,OACjD,IAAIC,GAAUxB,SAASC,KAAKC,KAAKiB,MAAMC,UAAUK,OACjD,IAAIC,GAAS1B,SAASC,KAAKC,KAAKiB,MAAMC,UAAUO,MAEhD,IAAIX,GAAiB,SAAUY,EAAQC,EAAMC,EAAOC,GAClD,IAAKA,GAASF,IAAQD,GAAQ,CAAE,OAChC,GAAIX,EAAqB,CACvBF,OAAOC,eAAeY,EAAQC,GAC5BG,aAAc,KACdC,WAAY,MACZC,SAAU,KACVJ,MAAOA,QAEJ,CACLF,EAAOC,GAAQC,GAMnB,IAAIK,GAAmB,SAAUP,EAAQQ,GACvClB,EAASH,OAAOsB,KAAKD,GAAM,SAAUP,GACnC,GAAIS,GAASF,EAAIP,EACjBb,GAAeY,EAAQC,EAAMS,EAAQ,SAMzC,IAAIC,GAASxB,OAAOwB,QAAU,SAAUnB,EAAWoB,GACjD,GAAIC,GAAY,QAASA,MACzBA,GAAUrB,UAAYA,CACtB,IAAIQ,GAAS,GAAIa,EACjB,UAAWD,KAAe,YAAa,CACrCzB,OAAOsB,KAAKG,GAAYnB,QAAQ,SAAUqB,GACxCC,EAAMC,mBAAmBhB,EAAQc,EAAKF,EAAWE,MAGrD,MAAOd,GAGT,IAAIiB,GAAsB,SAAUC,EAAGC,GACrC,IAAKhC,OAAOiC,eAAgB,CAAE,MAAO,OACrC,MAAOpC,GAAqB,WAC1B,GAAIqC,GAAM,QAASC,GAASC,GAC1B,GAAIC,GAAI,GAAIN,GAAEK,EACdpC,QAAOiC,eAAeI,EAAGF,EAAS9B,UAClC,OAAOgC,GAETrC,QAAOiC,eAAeC,EAAKH,EAC3BG,GAAI7B,UAAYmB,EAAOO,EAAE1B,WACvBiC,aAAevB,MAAOmB,IAExB,OAAOF,GAAEE,KAIb,IAAIK,GAAyB,WAC3B,MAAOC,QAAOnC,UAAUoC,YAAc9C,EAAY,WAEhD,MAAM8C,WAAW,OAGrB,IAAIC,GAA6B,WAC/B,MAAOF,QAAOnC,UAAUoC,YAAc,MAAMA,WAAW,IAAKE,YAAc,QAI5E,IAAIC,GAAY,GAAI3D,UAAS,eAG7B,IAAI4D,GAAUD,GACd,IAAIE,GAAiBD,EAAQE,QAC7B,IAAIC,GAAiB,WAAc,MAAOjE,QAAS,MAAQG,KAAK,KAChE,IAAI+D,GAAwBV,KAA4BG,CACxD,IAAIQ,GAAWjE,SAASC,KAAKC,KAAKqD,OAAOnC,UAAU8C,QACnD,IAAIC,GAAYnE,SAASC,KAAKC,KAAKa,OAAOK,UAAUgD,SACpD,IAAIC,GAAUrE,SAASC,KAAKC,KAAKiB,MAAMC,UAAUkD,OACjD,IAAIC,GAAYvE,SAASC,KAAKC,KAAKqD,OAAOnC,UAAUoD,MACpD,IAAIC,GAAQzE,SAASC,KAAKC,KAAKiB,MAAMC,UAAUsD,KAC/C,IAAIC,GAAa3E,SAASG,MAAMD,KAAKiB,MAAMC,UAAUsD,KACrD,IAAIE,GAAS5E,SAASC,KAAKC,KAAKiB,MAAMC,UAAUyD,MAChD,IAAIC,GAAOC,KAAKC,GAChB,IAAIC,GAAOF,KAAKG,GAChB,IAAIC,GAASJ,KAAKK,KAClB,IAAIC,GAAON,KAAKO,GAChB,IAAIC,GAAOR,KAAKS,GAChB,IAAIC,GAAQV,KAAKW,IACjB,IAAIC,GAAkB3F,SAASC,KAAKC,KAAKa,OAAOK,UAAUwE,eAC1D,IAAIC,EACJ,IAAIC,GAAO,YAEX,IAAIC,GAASnC,EAAQmC,UACrB,IAAIC,GAAgBD,EAAOE,SAAW,WACtC,IAAIC,GAAuB,WAAc,MAAOpG,MAChD,IAAIqG,GAAoB,SAAUrD,GAChC,GAAI7B,IAAwB0E,EAAgB7C,EAAGkD,GAAgB,CAC7DrD,EAAMyD,OAAOtD,EAAGkD,EAAeE,IAGnC,IAAIG,IACFzE,OAAQ,SAAU0E,GAAK,MAAOA,KAAM,YAAeA,KAAM,UACzDC,OAAQ,SAAUD,GAAK,MAAOnC,GAAUmC,KAAO,mBAC/CE,MAAO,SAAUF,GAAK,MAAOnC,GAAUmC,KAAO,mBAC9CG,OAAQ,SAAUH,GAChB,aAAc1C,GAAQmC,SAAW,kBAAqBO,KAAM,UAIhE,IAAII,GAAcC,OAAOC,OAAS,QAASA,IAAM9E,GAM/C,MAAOA,KAAUA,EAEnB,IAAI+E,GAAiBF,OAAO7C,UAAY,QAASA,IAAShC,GACxD,aAAcA,KAAU,UAAY+B,EAAe/B,GAGrD,IAAIa,IACFyD,OAAQ,SAAUxE,EAAQC,EAAMuE,GAC9B,IAAKnF,EAAqB,CACxB,KAAM,IAAI6F,WAAU,oCAEtB/F,OAAOC,eAAeY,EAAQC,GAC5BG,aAAc,KACdC,WAAY,MACZ8E,IAAKX,KAGTY,MAAO,SAAUC,EAAgBvE,EAAKwE,GACpC,IAAKjG,EAAqB,CACxB,KAAM,IAAI6F,WAAU,oCAEtB,GAAIK,GAAqBpG,OAAOqG,yBAAyBH,EAAgBvE,EACzE3B,QAAOC,eAAekG,EAAcxE,GAClCV,aAAcmF,EAAmBnF,aACjCC,WAAYkF,EAAmBlF,WAC/B8E,IAAK,QAASM,KAAW,MAAOJ,GAAevE,IAC/C4E,IAAK,QAASC,GAAOzF,GAASmF,EAAevE,GAAOZ,MAGxD0F,SAAU,SAAU5F,EAAQ6F,EAAUC,GACpC,GAAIzG,EAAqB,CACvB,GAAI0G,GAAa5G,OAAOqG,yBAAyBxF,EAAQ6F,EACzDE,GAAW7F,MAAQ4F,CACnB3G,QAAOC,eAAeY,EAAQ6F,EAAUE,OACnC,CACL/F,EAAO6F,GAAYC,IAGvB9E,mBAAoB,SAAUhB,EAAQ6F,EAAUE,GAC9C,GAAI1G,EAAqB,CACvBF,OAAOC,eAAeY,EAAQ6F,EAAUE,OACnC,IAAI,SAAWA,GAAY,CAChC/F,EAAO6F,GAAYE,EAAW7F,QAGlC8F,iBAAkB,SAAUC,EAAQC,GAClC9G,EAAe6G,EAAQ,WAAYC,EAAO1D,SAASlE,KAAK4H,GAAS,OAIrE,IAAIC,GAAiB,QAASA,IAAenG,EAAQ6F,EAAUO,GAC7D,GAAIC,GAAWrG,EAAO6F,EACtBzG,GAAeY,EAAQ6F,EAAUO,EAAa,KAC9CrF,GAAMiF,iBAAiBhG,EAAO6F,GAAWQ,GAQ3C,IAAIC,GAAa7B,EAAKI,OAAOV,EAAOoC,UAAYpC,EAAOoC,SAAW,qBAIlE,IAAIvE,EAAQwE,YAAc,GAAIxE,GAAQwE,KAAM,gBAAkB,WAAY,CACxEF,EAAa,aAEf,GAAIG,GAAc,SAAUjH,EAAWkH,GACrC,GAAIC,GAAiBD,GAAQ,QAASH,KAAa,MAAOrI,MAC1D,IAAIsD,KACJA,GAAE8E,GAAcK,CAChBpG,GAAiBf,EAAWgC,EAC5B,KAAKhC,EAAU8G,IAAe7B,EAAKI,OAAOyB,GAAa,CAErD9G,EAAU8G,GAAcK,GAM5B,IAAIC,GAAc,QAASA,IAAY1G,GACrC,GAAI2G,GAAMtE,EAAUrC,EACpB,IAAI4G,GAASD,IAAQ,oBACrB,KAAKC,EAAQ,CACXA,EAASD,IAAQ,kBACf3G,IAAU,YACHA,KAAU,gBACVA,GAAM6G,SAAW,UACxB7G,EAAM6G,QAAU,GAChBxE,EAAUrC,EAAM8G,UAAY,oBAEhC,MAAOF,GAGT,IAAIG,IAEFC,KAAM,QAASA,IAAKC,EAAGC,GACrB,GAAIC,GAAOxI,UAAUkI,OAAS,EAAIlI,UAAU,KAC5C,KAAKoI,EAAGK,WAAWH,GAAI,CACrB,KAAM,IAAIjC,WAAUiC,EAAI,sBAE1B,MAAOhJ,GAAOgJ,EAAGC,EAAGC,IAGtBE,uBAAwB,SAAU7C,EAAG8C,GAEnC,GAAI9C,GAAK,KAAM,CACb,KAAM,IAAIQ,WAAUsC,GAAc,yBAA2B9C,KAIjE+C,aAAc,SAAU/C,GAItB,MAAOA,IAAK,MAAQvF,OAAOuF,KAAOA,GAGpCgD,SAAU,SAAUlG,EAAGgG,GACrBP,EAAGM,uBAAuB/F,EAAGgG,EAC7B,OAAOrI,QAAOqC,IAGhB8F,WAAY,SAAU5C,GAEpB,aAAcA,KAAM,YAAcnC,EAAUmC,KAAO,qBAGrDiD,cAAe,SAAUjD,GAEvB,MAAOuC,GAAGK,WAAW5C,IAGvBkD,QAAS,SAAUlD,GACjB,MAAOuC,GAAGY,SAASnD,IAAM,GAG3BoD,SAAU,SAAUpD,GAClB,MAAOuC,GAAGY,SAASnD,KAAO,GAG5BmD,SAAU,SAAU3H,GAClB,GAAIqC,EAAUrC,KAAW,kBAAmB,CAC1C,KAAM,IAAIgF,WAAU,6CAEtB,OAAQhF,GAGV6H,UAAW,SAAU7H,GACnB,GAAI8H,GAASf,EAAGY,SAAS3H,EACzB,IAAI4E,EAAYkD,GAAS,CAAE,MAAO,GAClC,GAAIA,IAAW,IAAM/C,EAAe+C,GAAS,CAAE,MAAOA,GACtD,OAAQA,EAAS,EAAI,GAAK,GAAKzE,EAAOE,EAAKuE,KAG7CC,SAAU,SAAU/H,GAClB,GAAIgI,GAAMjB,EAAGc,UAAU7H,EACvB,IAAIgI,GAAO,EAAG,CAAE,MAAO,GACvB,GAAIA,EAAMnD,OAAOoD,iBAAkB,CAAE,MAAOpD,QAAOoD,iBACnD,MAAOD,IAGTE,UAAW,SAAUC,EAAGC,GACtB,GAAID,IAAMC,EAAG,CAEX,GAAID,IAAM,EAAG,CAAE,MAAO,GAAIA,IAAM,EAAIC,EACpC,MAAO,MAET,MAAOxD,GAAYuD,IAAMvD,EAAYwD,IAGvCC,cAAe,SAAUF,EAAGC,GAE1B,MAAQD,KAAMC,GAAOxD,EAAYuD,IAAMvD,EAAYwD,IAGrDE,WAAY,SAAUhH,GACpB,MAAOyF,GAAGQ,aAAajG,WAAcA,GAAE8E,KAAgB,aAAeM,EAAYpF,KAGpFiH,YAAa,SAAUjH,GACrB,GAAIoF,EAAYpF,GAAI,CAElB,MAAO,IAAIyC,GAAczC,EAAG,SAE9B,GAAIkH,GAAOzB,EAAG0B,UAAUnH,EAAG8E,EAC3B,KAAKW,EAAGK,WAAWoB,GAAO,CAExB,KAAM,IAAIxD,WAAU,4BAEtB,GAAI0D,GAAKpK,EAAMkK,EAAMlH,EACrB,KAAKyF,EAAGQ,aAAamB,GAAK,CACxB,KAAM,IAAI1D,WAAU,gBAEtB,MAAO0D,IAGTD,UAAW,SAAUnH,EAAGqH,GACtB,GAAIlK,GAAOsI,EAAGS,SAASlG,GAAGqH,EAC1B,IAAIlK,QAAc,IAAKA,IAAS,KAAM,CACpC,WAAY,GAEd,IAAKsI,EAAGK,WAAW3I,GAAO,CACxB,KAAM,IAAIuG,WAAU,wBAA0B2D,GAEhD,MAAOlK,IAGTmK,iBAAkB,SAAUC,GAC1B,QAAUA,EAAe,MAG3BC,cAAe,SAAUzC,EAAU0C,GACjC,GAAIC,GAAejC,EAAG0B,UAAUpC,EAAU,SAC1C,IAAI2C,QAAsB,GAAG,CAC3B,OAEF,GAAIC,GAAaC,CACjB,KACED,EAAc3K,EAAM0K,EAAc3C,GAClC,MAAOxH,GACPqK,EAAiBrK,EAEnB,GAAIkK,EAAmB,CACrB,OAEF,GAAIG,EAAgB,CAClB,KAAMA,GAER,IAAKnC,EAAGQ,aAAa0B,GAAc,CACjC,KAAM,IAAIjE,WAAU,qDAIxBmE,aAAc,SAAUT,GACtB,GAAI9B,GAASjI,UAAUkI,OAAS,EAAI6B,EAAGU,KAAKzK,UAAU,IAAM+J,EAAGU,MAC/D,KAAKrC,EAAGQ,aAAaX,GAAS,CAC5B,KAAM,IAAI5B,WAAU,gBAEtB,MAAO4B,IAGTyC,aAAc,SAAUX,GACtB,GAAI9B,GAASG,EAAGoC,aAAaT,EAC7B,IAAIY,GAAOvC,EAAG6B,iBAAiBhC,EAC/B,OAAO0C,GAAO,MAAQ1C,GAGxB2C,UAAW,SAAUvI,EAAGmG,EAAMqC,EAAWC,GACvC,GAAID,QAAmB,GAAG,CACxBA,EAAYxI,EAEd,IAAKyI,EAAe,CAElB,MAAOC,IAAQC,UAAU3I,EAAGmG,EAAMqC,GAOpC,GAAII,GAAQJ,EAAUlK,SACtB,KAAKyH,EAAGQ,aAAaqC,GAAQ,CAC3BA,EAAQ3K,OAAOK,UAEjB,GAAIuK,GAAMpJ,EAAOmJ,EAEjB,IAAIhD,GAASG,EAAGC,KAAKhG,EAAG6I,EAAK1C,EAC7B,OAAOJ,GAAGQ,aAAaX,GAAUA,EAASiD,GAG5CC,mBAAoB,SAAUC,EAAGC,GAC/B,GAAIhJ,GAAI+I,EAAExI,WACV,IAAIP,QAAW,GAAG,CAChB,MAAOgJ,GAET,IAAKjD,EAAGQ,aAAavG,GAAI,CACvB,KAAM,IAAIgE,WAAU,mBAEtB,GAAIiF,GAAIjJ,EAAEkD,EACV,IAAI+F,QAAW,IAAKA,IAAM,KAAM,CAC9B,MAAOD,GAET,IAAKjD,EAAGU,cAAcwC,GAAI,CACxB,KAAM,IAAIjF,WAAU,iBAEtB,MAAOiF,IAGTC,WAAY,SAAUzF,EAAQ0F,EAAKC,EAAWpK,GAC5C,GAAIiK,GAAIxI,OAAOgD,EACf,IAAI4F,GAAK,IAAMF,CACf,IAAIC,IAAc,GAAI,CACpB,GAAIlD,GAAIzF,OAAOzB,EACf,IAAIsK,GAAWpD,EAAEqD,QAAQ,KAAM,SAC/BF,IAAM,IAAMD,EAAY,KAAOE,EAAW,IAE5C,GAAIE,GAAKH,EAAK,GACd,IAAII,GAAKD,EAAKP,CACd,OAAOQ,GAAK,KAAON,EAAM,KAI7B,IAAIO,GAAsB,SAAUpJ,EAAGqJ,EAAkBC,EAAcC,GAWrE,IAAK9D,EAAGQ,aAAajG,GAAI,CACvB,KAAM,IAAI0D,WAAU,+BAAiC2F,EAAiB5K,MAExE,GAAI6J,GAAQe,EAAiBrL,SAC7B,KAAKyH,EAAGQ,aAAaqC,GAAQ,CAC3BA,EAAQgB,EAEVtJ,EAAIb,EAAOmJ,EACX,KAAK,GAAI7J,KAAQ8K,GAAO,CACtB,GAAIhH,EAAgBgH,EAAO9K,GAAO,CAChC,GAAIC,GAAQ6K,EAAM9K,EAClBb,GAAeoC,EAAGvB,EAAMC,EAAO,OAGnC,MAAOsB,GAKT,IAAIG,OAAOqJ,eAAiBrJ,OAAOqJ,cAAcjE,SAAW,EAAG,CAC7D,GAAIkE,GAAwBtJ,OAAOqJ,aACnC7E,GAAexE,OAAQ,gBAAiB,QAASqJ,IAAcE,GAAc,MAAO/M,GAAO8M,EAAuB/M,KAAMW,aAG1H,GAAIsM,KACFH,cAAe,QAASA,IAAcE,GACpC,GAAIpE,KACJ,IAAIwC,EACJ,KAAK,GAAI8B,GAAI,EAAGrE,EAASlI,UAAUkI,OAAQqE,EAAIrE,EAAQqE,IAAK,CAC1D9B,EAAOvE,OAAOlG,UAAUuM,GACxB,KAAKnE,EAAGmB,UAAUkB,EAAMrC,EAAGc,UAAUuB,KAAUA,EAAO,GAAKA,EAAO,QAAU,CAC1E,KAAM,IAAI+B,YAAW,sBAAwB/B,GAG/C,GAAIA,EAAO,MAAS,CAClBzG,EAAMiE,EAAQnF,OAAO2J,aAAahC,QAC7B,CACLA,GAAQ,KACRzG,GAAMiE,EAAQnF,OAAO2J,cAAchC,GAAQ,IAAM,OACjDzG,GAAMiE,EAAQnF,OAAO2J,aAAchC,EAAO,KAAS,SAGvD,MAAOxC,GAAOyE,KAAK,KAGrBC,IAAK,QAASA,IAAIC,GAChB,GAAIC,GAASzE,EAAGS,SAAS+D,EAAU,eACnC,IAAIE,GAAY1E,EAAGS,SAASgE,EAAOF,IAAK,gBACxC,IAAItD,GAAMyD,EAAU5E,MACpB,IAAI6E,GAAkB3E,EAAGgB,SAASC,EAClC,IAAI0D,GAAmB,EAAG,CACxB,MAAO,GAGT,GAAIC,KACJ,IAAIC,GAAY,CAChB,IAAIC,GAASzC,EAAM0C,EAASC,CAC5B,OAAOH,EAAYF,EAAiB,CAClCG,EAAUpK,OAAOmK,EACjBE,GAAUrK,OAAOgK,EAAUI,GAC3BlJ,GAAMgJ,EAAgBG,EACtB,IAAIF,EAAY,GAAKF,EAAiB,CACpC,MAEFtC,EAAOwC,EAAY,EAAIjN,UAAUkI,OAASlI,UAAUiN,EAAY,GAAK,EACrEG,GAAUtK,OAAO2H,EACjBzG,GAAMgJ,EAAgBI,EACtBH,KAEF,MAAOD,GAAeN,KAAK,KAG/BhL,GAAiBoB,OAAQwJ,GACzB,IAAIxJ,OAAO6J,KAAMA,KAAO,EAAG,IAAKU,EAAG,IAAKnF,OAAQ,OAAW,KAAM,CAE/DZ,EAAexE,OAAQ,MAAOwJ,GAAYK,KAK5C,GAAIW,IAAe,QAASC,IAAOC,EAAGC,GACpC,GAAIA,EAAQ,EAAG,CAAE,MAAO,GACxB,GAAIA,EAAQ,EAAG,CAAE,MAAOF,IAAOC,EAAGC,EAAQ,GAAKD,EAC/C,GAAIE,GAAOH,GAAOC,EAAGC,EAAQ,EAC7B,OAAOC,GAAOA,EAEhB,IAAIC,IAAkB1K,QAEtB,IAAI2K,KACFL,OAAQ,QAASA,IAAOE,GACtBrF,EAAGM,uBAAuBrJ,KAC1B,IAAIwO,GAAU/K,OAAOzD,KACrB,IAAIyO,GAAW1F,EAAGc,UAAUuE,EAC5B,IAAIK,EAAW,GAAKA,GAAYH,GAAiB,CAC/C,KAAM,IAAInB,YAAW,gFAEvB,MAAOc,IAAaO,EAASC,IAG/B/K,WAAY,QAASA,IAAWgL,GAC9B3F,EAAGM,uBAAuBrJ,KAC1B,IAAIwO,GAAU/K,OAAOzD,KACrB,IAAIuG,EAAKG,MAAMgI,GAAe,CAC5B,KAAM,IAAI1H,WAAU,gDAEtB,GAAI2H,GAAYlL,OAAOiL,EACvB,IAAIE,GAAWjO,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EAC1D,IAAIkO,GAAQ7J,EAAK+D,EAAGc,UAAU+E,GAAW,EACzC,OAAOnK,GAAU+J,EAASK,EAAOA,EAAQF,EAAU9F,UAAY8F,GAGjEG,SAAU,QAASA,IAASJ,GAC1B3F,EAAGM,uBAAuBrJ,KAC1B,IAAIwO,GAAU/K,OAAOzD,KACrB,IAAIuG,EAAKG,MAAMgI,GAAe,CAC5B,KAAM,IAAI1H,WAAU,8CAEtB,GAAI2H,GAAYlL,OAAOiL,EACvB,IAAIK,GAAUP,EAAQ3F,MACtB,IAAImG,GAASrO,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EACxD,IAAIsO,SAAaD,KAAW,YAAcD,EAAUhG,EAAGc,UAAUmF,EACjE,IAAIE,GAAM/J,EAAKH,EAAKiK,EAAK,GAAIF,EAC7B,OAAOtK,GAAU+J,EAASU,EAAMP,EAAU9F,OAAQqG,KAASP,GAG7DQ,SAAU,QAASA,IAAST,GAC1B,GAAInI,EAAKG,MAAMgI,GAAe,CAC5B,KAAM,IAAI1H,WAAU,uCAEtB,GAAIoI,EACJ,IAAIzO,UAAUkI,OAAS,EAAG,CACxBuG,EAAWzO,UAAU,GAGvB,MAAOwD,GAASnE,KAAM0O,EAAcU,MAAe,GAGrDC,YAAa,QAASA,IAAYJ,GAChClG,EAAGM,uBAAuBrJ,KAC1B,IAAIwO,GAAU/K,OAAOzD,KACrB,IAAIoP,GAAWrG,EAAGc,UAAUoF,EAC5B,IAAIpG,GAAS2F,EAAQ3F,MACrB,IAAIuG,GAAY,GAAKA,EAAWvG,EAAQ,CACtC,GAAIyG,GAAQd,EAAQe,WAAWH,EAC/B,IAAII,GAASJ,EAAW,IAAMvG,CAC9B,IAAIyG,EAAQ,OAAUA,EAAQ,OAAUE,EAAO,CAAE,MAAOF,GACxD,GAAIG,GAASjB,EAAQe,WAAWH,EAAW,EAC3C,IAAIK,EAAS,OAAUA,EAAS,MAAQ,CAAE,MAAOH,GACjD,OAASA,EAAQ,OAAU,MAASG,EAAS,OAAU,QAI7DpN,GAAiBoB,OAAOnC,UAAWiN,GAEnC,IAAI,IAAIY,SAAS,IAAKvL,YAAc,MAAO,CACzCqE,EAAexE,OAAOnC,UAAW,WAAYiN,GAAqBY,UAGpE,GAAIO,IAAmB,OAASC,OAAO9G,SAAW,CAClD,IAAI6G,GAAkB,OACbjM,QAAOnC,UAAUqO,IAGxB,IAAIC,KACF,oDACA,qEACA,gBACAvC,KAAK,GACP,IAAIwC,IAAa,GAAIC,QAAO,MAAQF,GAAK,SAAWA,GAAK,OAAQ,IACjEvN,GAAiBoB,OAAOnC,WACtBqO,KAAM,QAASA,MACb,SAAW3P,QAAS,aAAeA,OAAS,KAAM,CAChD,KAAM,IAAIgH,WAAU,iBAAmBhH,KAAO,cAEhD,MAAOyD,QAAOzD,MAAMuM,QAAQsD,GAAY,OAM9C,GAAIE,IAAiB,SAAU5B,GAC7BpF,EAAGM,uBAAuB8E,EAC1BnO,MAAKgQ,GAAKvM,OAAO0K,EACjBnO,MAAKiQ,GAAK,EAEZF,IAAezO,UAAU8J,KAAO,WAC9B,GAAI+C,GAAInO,KAAKgQ,GAAI9C,EAAIlN,KAAKiQ,EAC1B,UAAW9B,KAAM,aAAejB,GAAKiB,EAAEtF,OAAQ,CAC7C7I,KAAKgQ,OAAU,EACf,QAAShO,UAAY,GAAGsJ,KAAM,MAEhC,GAAIgE,GAAQnB,EAAEoB,WAAWrC,GAAIuC,EAAQzF,CACrC,IAAIsF,EAAQ,OAAUA,EAAQ,OAAWpC,EAAI,IAAOiB,EAAEtF,OAAQ,CAC5DmB,EAAM,MACD,CACLyF,EAAStB,EAAEoB,WAAWrC,EAAI,EAC1BlD,GAAOyF,EAAS,OAAUA,EAAS,MAAU,EAAI,EAEnDzP,KAAKiQ,GAAK/C,EAAIlD,CACd,QAAShI,MAAOmM,EAAE+B,OAAOhD,EAAGlD,GAAMsB,KAAM,OAE1C/C,GAAYwH,GAAezO,UAC3BiH,GAAY9E,OAAOnC,UAAW,WAC5B,MAAO,IAAIyO,IAAe/P,OAG5B,KAAKkE,EAAuB,CAE1B+D,EAAexE,OAAOnC,UAAW,aAAciN,GAAqB7K,WACpEuE,GAAexE,OAAOnC,UAAW,WAAYiN,GAAqBO,UAGpE,GAAIqB,KACFC,KAAM,QAASA,IAAKC,GAClB,GAAIrN,GAAIhD,IACR,IAAIsQ,GAAQ3P,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EACvD,IAAI4P,GAASC,CACb,IAAIF,QAAe,GAAG,CACpBC,EAAU,UACL,CACL,IAAKxH,EAAGK,WAAWkH,GAAQ,CACzB,KAAM,IAAItJ,WAAU,qEAEtBwJ,EAAI7P,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EAC/C4P,GAAU,KAKZ,GAAIE,GAAgB/H,EAAY2H,IAAUtH,EAAG0B,UAAU4F,EAAOjI,EAE9D,IAAIS,GAAQD,EAAQsE,CACpB,IAAIuD,QAAuB,GAAG,CAC5B7H,EAASG,EAAGU,cAAczG,GAAK/B,OAAO,GAAI+B,MAC1C,IAAIqF,GAAWU,EAAGwB,YAAY8F,EAC9B,IAAIjF,GAAMsF,CAEV,KAAKxD,EAAI,KAAOA,EAAG,CACjB9B,EAAOrC,EAAGsC,aAAahD,EACvB,IAAI+C,IAAS,MAAO,CAClB,MAEFsF,EAAYtF,EAAKpJ,KACjB,KACE,GAAIuO,EAAS,CACXG,EAAYF,IAAMG,UAAYrQ,EAAMgQ,EAAOE,EAAGE,EAAWxD,GAAKoD,EAAMI,EAAWxD,GAEjFtE,EAAOsE,GAAKwD,EACZ,MAAO7P,GACPkI,EAAG+B,cAAczC,EAAU,KAC3B,MAAMxH,IAGVgI,EAASqE,MACJ,CACL,GAAI0D,GAAY7H,EAAGS,SAAS6G,EAC5BxH,GAASE,EAAGgB,SAAS6G,EAAU/H,OAC/BD,GAASG,EAAGU,cAAczG,GAAK/B,OAAO,GAAI+B,GAAE6F,IAAW,GAAIxH,OAAMwH,EACjE,IAAI7G,EACJ,KAAKkL,EAAI,EAAGA,EAAIrE,IAAUqE,EAAG,CAC3BlL,EAAQ4O,EAAU1D,EAClB,IAAIqD,EAAS,CACXvO,EAAQwO,IAAMG,UAAYrQ,EAAMgQ,EAAOE,EAAGxO,EAAOkL,GAAKoD,EAAMtO,EAAOkL,GAErEtE,EAAOsE,GAAKlL,GAIhB4G,EAAOC,OAASA,CAChB,OAAOD,IAGTiI,GAAI,QAASA,MACX,MAAOvQ,GAAMe,MAAM+O,KAAMpQ,KAAMW,YAGnC0B,GAAiBhB,MAAO8O,GACxB9J,GAAkBhF,MAKlB,IAAIyP,IAAiB,SAAUtK,GAC7B,OAASxE,MAAOwE,EAAG8E,KAAM3K,UAAUkI,SAAW,GAKhD9C,GAAgB,SAAUgL,EAAOC,GAC7BhR,KAAKkN,EAAI,CACTlN,MAAK+Q,MAAQA,CACb/Q,MAAKgR,KAAOA,EAGhB3O,GAAiB0D,EAAczE,WAC7B8J,KAAM,WACJ,GAAI8B,GAAIlN,KAAKkN,EAAG6D,EAAQ/Q,KAAK+Q,KAC7B,MAAM/Q,eAAgB+F,IAAgB,CACpC,KAAM,IAAIiB,WAAU,wBAEtB,SAAW+J,KAAU,YAAa,CAChC,GAAI/G,GAAMjB,EAAGgB,SAASgH,EAAMlI,OAC5B,MAAOqE,EAAIlD,EAAKkD,IAAK,CACnB,GAAI8D,GAAOhR,KAAKgR,IAChB,IAAIC,EACJ,IAAID,IAAS,MAAO,CAClBC,EAAS/D,MACJ,IAAI8D,IAAS,QAAS,CAC3BC,EAASF,EAAM7D,OACV,IAAI8D,IAAS,QAAS,CAC3BC,GAAU/D,EAAG6D,EAAM7D,IAErBlN,KAAKkN,EAAIA,EAAI,CACb,QAASlL,MAAOiP,EAAQ3F,KAAM,QAGlCtL,KAAK+Q,UAAa,EAClB,QAAS/O,UAAY,GAAGsJ,KAAM,QAGlC/C,GAAYxC,EAAczE,UAE1B,IAAI4P,IAAiB,SAAUpP,EAAQkP,GACrChR,KAAK8B,OAASA,CAEd9B,MAAK+Q,MAAQ,IACb/Q,MAAKgR,KAAOA,EAGd,IAAIG,IAAa,QAASA,IAAWrP,GACnC,GAAIS,KAEJ,KAAK,GAAIK,KAAOd,GAAQ,CACtB6C,EAAMpC,EAAMK,GAGd,MAAOL,GAGTF,GAAiB6O,GAAe5P,WAC9B8J,KAAM,WACJ,GAAIxI,GAAKmO,EAAQ/Q,KAAK+Q,KAEtB,MAAM/Q,eAAgBkR,KAAiB,CACrC,KAAM,IAAIlK,WAAU,yBAItB,GAAI+J,IAAU,KAAM,CAClBA,EAAQ/Q,KAAK+Q,MAAQI,GAAWnR,KAAK8B,QAIvC,MAAOiH,EAAGgB,SAASgH,EAAMlI,QAAU,EAAG,CACpCjG,EAAMkC,EAAOiM,EAKb,MAAMnO,IAAO5C,MAAK8B,QAAS,CACzB,SAGF,GAAI9B,KAAKgR,OAAS,MAAO,CACvB,MAAOF,IAAelO,OACjB,IAAI5C,KAAKgR,OAAS,QAAS,CAChC,MAAOF,IAAe9Q,KAAK8B,OAAOc,QAC7B,CACL,MAAOkO,KAAgBlO,EAAK5C,KAAK8B,OAAOc,MAI5C,MAAOkO,QAGXvI,GAAY2I,GAAe5P,UAG3B,IAAI8P,IAA8B,WAEhC,GAAIC,GAAM,QAASA,GAAIrH,GAAOhK,KAAK6I,OAASmB,EAC5CqH,GAAI/P,YACJ,IAAIgQ,GAASjQ,MAAMwP,GAAGxQ,MAAMgR,GAAM,EAAG,GACrC,OAAOC,aAAkBD,IAAOC,EAAOzI,SAAW,IAEpD,KAAKuI,GAA4B,CAC/BnJ,EAAe5G,MAAO,KAAM8O,GAAWU,IAGzC,GAAIU,KACFC,WAAY,QAASA,IAAWzJ,EAAQ8G,GACtC,GAAIK,GAAMvO,UAAU,EACpB,IAAI2C,GAAIyF,EAAGS,SAASxJ,KACpB,IAAIgK,GAAMjB,EAAGgB,SAASzG,EAAEuF,OACxB,IAAI4I,GAAiB1I,EAAGc,UAAU9B,EAClC,IAAI2J,GAAgB3I,EAAGc,UAAUgF,EACjC,IAAI8C,GAAKF,EAAiB,EAAIzM,EAAKgF,EAAMyH,EAAgB,GAAKtM,EAAKsM,EAAgBzH,EACnF,IAAIoG,GAAOsB,EAAgB,EAAI1M,EAAKgF,EAAM0H,EAAe,GAAKvM,EAAKuM,EAAe1H,EAClFkF,SAAaA,KAAQ,YAAclF,EAAMjB,EAAGc,UAAUqF,EACtD,IAAI0C,GAAM1C,EAAM,EAAIlK,EAAKgF,EAAMkF,EAAK,GAAK/J,EAAK+J,EAAKlF,EACnD,IAAI6H,GAAQ1M,EAAKyM,EAAMxB,EAAMpG,EAAM2H,EACnC,IAAIG,GAAY,CAChB,IAAI1B,EAAOuB,GAAMA,EAAMvB,EAAOyB,EAAQ,CACpCC,GAAa,CACb1B,IAAQyB,EAAQ,CAChBF,IAAME,EAAQ,EAEhB,MAAOA,EAAQ,EAAG,CAChB,GAAIhM,EAAgBvC,EAAG8M,GAAO,CAC5B9M,EAAEqO,GAAMrO,EAAE8M,OACL,OACE9M,GAAE8M,GAEXA,GAAQ0B,CACRH,IAAMG,CACND,IAAS,EAEX,MAAOvO,IAGTyO,KAAM,QAASA,IAAK/P,GAClB,GAAI6M,GAAQlO,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EACvD,IAAIuO,GAAMvO,UAAUkI,OAAS,EAAIlI,UAAU,OAAU,EACrD,IAAIoL,GAAIhD,EAAGS,SAASxJ,KACpB,IAAIgK,GAAMjB,EAAGgB,SAASgC,EAAElD,OACxBgG,GAAQ9F,EAAGc,gBAAiBgF,KAAU,YAAc,EAAIA,EACxDK,GAAMnG,EAAGc,gBAAiBqF,KAAQ,YAAclF,EAAMkF,EAEtD,IAAIwC,GAAgB7C,EAAQ,EAAI7J,EAAKgF,EAAM6E,EAAO,GAAK1J,EAAK0J,EAAO7E,EACnE,IAAIgI,GAAc9C,EAAM,EAAIlF,EAAMkF,EAAMA,CAExC,KAAK,GAAIhC,GAAIwE,EAAexE,EAAIlD,GAAOkD,EAAI8E,IAAe9E,EAAG,CAC3DnB,EAAEmB,GAAKlL,EAET,MAAO+J,IAGTkG,KAAM,QAASA,IAAKC,GAClB,GAAIC,GAAOpJ,EAAGS,SAASxJ,KACvB,IAAI6I,GAASE,EAAGgB,SAASoI,EAAKtJ,OAC9B,KAAKE,EAAGK,WAAW8I,GAAY,CAC7B,KAAM,IAAIlL,WAAU,4CAEtB,GAAIoL,GAAUzR,UAAUkI,OAAS,EAAIlI,UAAU,GAAK,IACpD,KAAK,GAAIuM,GAAI,EAAGlL,EAAOkL,EAAIrE,EAAQqE,IAAK,CACtClL,EAAQmQ,EAAKjF,EACb,IAAIkF,EAAS,CACX,GAAI9R,EAAM4R,EAAWE,EAASpQ,EAAOkL,EAAGiF,GAAO,CAAE,MAAOnQ,QACnD,IAAIkQ,EAAUlQ,EAAOkL,EAAGiF,GAAO,CACpC,MAAOnQ,MAKbqQ,UAAW,QAASA,IAAUH,GAC5B,GAAIC,GAAOpJ,EAAGS,SAASxJ,KACvB,IAAI6I,GAASE,EAAGgB,SAASoI,EAAKtJ,OAC9B,KAAKE,EAAGK,WAAW8I,GAAY,CAC7B,KAAM,IAAIlL,WAAU,iDAEtB,GAAIoL,GAAUzR,UAAUkI,OAAS,EAAIlI,UAAU,GAAK,IACpD,KAAK,GAAIuM,GAAI,EAAGA,EAAIrE,EAAQqE,IAAK,CAC/B,GAAIkF,EAAS,CACX,GAAI9R,EAAM4R,EAAWE,EAASD,EAAKjF,GAAIA,EAAGiF,GAAO,CAAE,MAAOjF,QACrD,IAAIgF,EAAUC,EAAKjF,GAAIA,EAAGiF,GAAO,CACtC,MAAOjF,IAGX,OAAQ,GAGV3K,KAAM,QAASA,MACb,MAAO,IAAIwD,GAAc/F,KAAM,QAGjCsS,OAAQ,QAASA,MACf,MAAO,IAAIvM,GAAc/F,KAAM,UAGjCuS,QAAS,QAASA,MAChB,MAAO,IAAIxM,GAAc/F,KAAM,UAKnC,IAAIqB,MAAMC,UAAUiB,OAASwG,EAAGK,YAAY,GAAG7G,OAAO6I,MAAO,OACpD/J,OAAMC,UAAUiB,KAEzB,GAAIlB,MAAMC,UAAUiR,UAAYxJ,EAAGK,YAAY,GAAGmJ,UAAUnH,MAAO,OAC1D/J,OAAMC,UAAUiR,QAIzB,GAAIlR,MAAMC,UAAUiB,MAAQlB,MAAMC,UAAUiR,UAAYlR,MAAMC,UAAUgR,QAAUjR,MAAMC,UAAU8G,GAAa,CAC7G/F,EAAiBhB,MAAMC,WACrBgR,OAAQjR,MAAMC,UAAU8G,IAE1B,IAAI7B,EAAKI,OAAOV,EAAOuM,aAAc,CACnCnR,MAAMC,UAAU2E,EAAOuM,aAAaF,OAAS,MAIjD,GAAIjR,MAAMC,UAAUgR,QAAUjR,MAAMC,UAAUgR,OAAOvQ,OAAS,SAAU,CACtE,GAAI0Q,IAA+BpR,MAAMC,UAAUgR,MACnDrK,GAAe5G,MAAMC,UAAW,SAAU,QAASgR,MAAW,MAAOhS,GAAMmS,GAA8BzS,OACzGkB,GAAeG,MAAMC,UAAW8G,EAAY/G,MAAMC,UAAUgR,OAAQ,MAEtEjQ,EAAiBhB,MAAMC,UAAWiQ,GAElChJ,GAAYlH,MAAMC,UAAW,WAAc,MAAOtB,MAAKsS,UAGvD,IAAIrR,OAAOyR,eAAgB,CACzBnK,EAAYtH,OAAOyR,kBAAkBJ,WAIvC,GAAIK,IAAoC,WAGtC,MAAO7R,GAAqB,WAAc,MAAOO,OAAM+O,MAAOvH,QAAS,IAAKA,SAAW,MAEzF,IAAI+J,IAA6B,WAE/B,GAAIC,GAAMxR,MAAM+O,MAAM,GAAGmC,UACzB,OAAOM,GAAIhK,SAAW,GAAKgK,EAAI,GAAG,KAAO,GAAKA,EAAI,GAAG,KAAO,IAE9D,KAAKF,KAAqCC,GAA2B,CACnE3K,EAAe5G,MAAO,OAAQ8O,GAAWC,MAG3C,GAAI0C,IAAqB,SAAUtQ,EAAQuQ,GACzC,GAAIlH,IAAQhD,QAAS,EACrBgD,GAAIkH,IAAc,IAAM,GAAK,EAAK,GAAK,IACvC,OAAOjS,GAAqB,WAC1BR,EAAMkC,EAAQqJ,EAAK,WAGjB,KAAM,IAAIsB,YAAW,gCAI3B,KAAK2F,GAAmBzR,MAAMC,UAAUC,SAAU,CAChD,GAAIyR,IAAkB3R,MAAMC,UAAUC,OACtC0G,GAAe5G,MAAMC,UAAW,UAAW,QAASC,IAAQ0R,GAC1D,MAAOhT,GAAO+S,GAAiBhT,KAAK6I,QAAU,EAAI7I,QAAWW,YAC5D,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAUgB,KAAM,CAC5C,GAAI4Q,IAAc7R,MAAMC,UAAUgB,GAClC2F,GAAe5G,MAAMC,UAAW,MAAO,QAASgB,IAAI2Q,GAClD,MAAOhT,GAAOiT,GAAalT,KAAK6I,QAAU,EAAI7I,QAAWW,YACxD,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAUK,QAAS,CAC/C,GAAIwR,IAAiB9R,MAAMC,UAAUK,MACrCsG,GAAe5G,MAAMC,UAAW,SAAU,QAASK,IAAOsR,GACxD,MAAOhT,GAAOkT,GAAgBnT,KAAK6I,QAAU,EAAI7I,QAAWW,YAC3D,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAU8R,MAAO,CAC7C,GAAIC,IAAehS,MAAMC,UAAU8R,IACnCnL,GAAe5G,MAAMC,UAAW,OAAQ,QAAS8R,IAAKH,GACpD,MAAOhT,GAAOoT,GAAcrT,KAAK6I,QAAU,EAAI7I,QAAWW,YACzD,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAUO,OAAQ,CAC9C,GAAIyR,IAAgBjS,MAAMC,UAAUO,KACpCoG,GAAe5G,MAAMC,UAAW,QAAS,QAASO,IAAMoR,GACtD,MAAOhT,GAAOqT,GAAetT,KAAK6I,QAAU,EAAI7I,QAAWW,YAC1D,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAUG,QAAS,CAC/C,GAAI8R,IAAiBlS,MAAMC,UAAUG,MACrCwG,GAAe5G,MAAMC,UAAW,SAAU,QAASG,IAAOwR,GACxD,MAAOhT,GAAOsT,GAAgBvT,KAAK6I,QAAU,EAAI7I,QAAWW,YAC3D,MAEL,IAAKmS,GAAmBzR,MAAMC,UAAUkS,YAAa,MAAO,CAC1D,GAAIC,IAAsBpS,MAAMC,UAAUkS,WAC1CvL,GAAe5G,MAAMC,UAAW,cAAe,QAASkS,IAAYP,GAClE,MAAOhT,GAAOwT,GAAqBzT,KAAK6I,QAAU,EAAI7I,QAAWW,YAChE,MAGL,GAAI+S,IAAiBzO,KAAK0O,IAAI,EAAG,IAAM,CACvCtR,GAAiBwE,QACfoD,iBAAkByJ,GAClBE,kBAAmBF,GACnBG,QAAS,sBAETC,SAAUhQ,EAAQgQ,SAClBC,WAAYjQ,EAAQiQ,WAEpB/P,SAAU+C,EAEViN,UAAW,QAASA,IAAUhS,GAC5B,MAAO+E,GAAe/E,IAAU+G,EAAGc,UAAU7H,KAAWA,GAG1DiS,cAAe,QAASA,IAAcjS,GACpC,MAAO6E,QAAOmN,UAAUhS,IAAUuD,EAAKvD,IAAU6E,OAAOoD,kBAG1DnD,MAAOF,GAGT1F,GAAe2F,OAAQ,WAAY/C,EAAQgQ,SAAUjN,OAAOiN,WAAahQ,EAAQgQ,SAOjF,MAAM,CAAE,GAAG7B,KAAK,SAAUiC,EAAMC,GAAO,MAAOA,KAAQ,IAAO,CAC3DlM,EAAe5G,MAAMC,UAAW,OAAQiQ,GAAoBU,MAE9D,IAAK,CAAE,GAAGI,UAAU,SAAU6B,EAAMC,GAAO,MAAOA,KAAQ,MAAU,EAAG,CACrElM,EAAe5G,MAAMC,UAAW,YAAaiQ,GAAoBc,WAInE,GAAI+B,IAAiBlU,SAASE,KAAKD,KAAKD,SAASE,KAAMa,OAAOK,UAAU+S,qBACxE,IAAIC,IAAY,QAASA,MAGvB,GAAIC,GAAU1N,OAAO7G,KACrB,IAAIgK,GAAMrJ,UAAUkI,MACpB,IAAI2L,GAAkBxK,EAAMuK,CAC5B,IAAIpL,GAAO,GAAI9H,OAAMmT,EAAkB,EAAI,EAAIA,EAC/C,KAAK,GAAItH,GAAIqH,EAASrH,EAAIlD,IAAOkD,EAAG,CAClC/D,EAAK+D,EAAIqH,GAAW5T,UAAUuM,GAEhC,MAAO/D,GAET,IAAIsL,IAAW,QAASA,IAASzM,GAC/B,MAAO,SAAS0M,GAAe3M,EAAQnF,GACrCmF,EAAOnF,GAAOoF,EAAOpF,EACrB,OAAOmF,IAGX,IAAI4M,IAAgB,SAAU5M,EAAQC,GACpC,GAAIzF,GAAOtB,OAAOsB,KAAKtB,OAAO+G,GAC9B,IAAI4M,EACJ,IAAI7L,EAAGK,WAAWnI,OAAO4T,uBAAwB,CAC/CD,EAAUlT,EAAQT,OAAO4T,sBAAsB5T,OAAO+G,IAAUoM,GAAepM,IAEjF,MAAOxG,GAAQ+C,EAAQhC,EAAMqS,OAAgBH,GAASzM,GAASD,GAGjE,IAAI+M,KAEFC,OAAQ,SAAUhN,EAAQC,GACxB,GAAI2J,GAAK5I,EAAGS,SAASzB,EAAQ,6CAC7B,OAAOvG,GAAQvB,EAAOqU,GAAW,EAAG3T,WAAYgU,GAAehD,IAIjEqD,GAAI,QAASA,IAAG7K,EAAGC,GACjB,MAAOrB,GAAGmB,UAAUC,EAAGC,IAG3B,IAAI6K,IAA6BhU,OAAO8T,QAAU9T,OAAOiU,mBAAsB,WAG7E,GAAIC,GAAUlU,OAAOiU,mBAAoBlH,EAAG,GAC5C,KACE/M,OAAO8T,OAAOI,EAAS,MACvB,MAAOtU,GACP,MAAOsU,GAAQ,KAAO,OAG1B,IAAIF,GAA4B,CAC9BhN,EAAehH,OAAQ,SAAU6T,GAAYC,QAE/C1S,EAAiBpB,OAAQ6T,GAEzB,IAAI3T,EAAqB,CACvB,GAAIiU,KAGFlS,eAAiB,SAAUjC,EAAQoU,GACjC,GAAI7N,EAEJ,IAAI8N,GAAY,SAAUvJ,EAAGH,GAC3B,IAAK7C,EAAGQ,aAAawC,GAAI,CACvB,KAAM,IAAI/E,WAAU,wCAEtB,KAAM4E,IAAU,MAAQ7C,EAAGQ,aAAaqC,IAAS,CAC/C,KAAM,IAAI5E,WAAU,8CAAgD4E,IAIxE,IAAI1I,GAAiB,SAAU6I,EAAGH,GAChC0J,EAAUvJ,EAAGH,EACbtL,GAAMkH,EAAKuE,EAAGH,EACd,OAAOG,GAGT,KAEEvE,EAAMvG,EAAOqG,yBAAyBrG,EAAOK,UAAW+T,GAAO7N,GAC/DlH,GAAMkH,KAAS,MACf,MAAO3G,GACP,GAAII,EAAOK,eAAiB+T,GAAQ,CAElC,OAGF7N,EAAM,SAAUoE,GACd5L,KAAKqV,GAASzJ,EAOhB1I,GAAeqS,SAAWrS,EACxBA,KAAmB,MACnBjC,EAAOK,oBACIL,GASf,MAAOiC,IACPjC,OAAQ,aAGZoB,GAAiBpB,OAAQmU,IAK3B,GAAInU,OAAOiC,gBAAkBjC,OAAOyR,gBAChCzR,OAAOyR,eAAezR,OAAOiC,kBAAmB,SAAW,MAC3DjC,OAAOyR,eAAezR,OAAOwB,OAAO,SAAW,KAAM,EACtD,WACC,GAAI+S,GAAWvU,OAAOwB,OAAO,KAC7B,IAAIgT,GAAMxU,OAAOyR,eAAgBgD,EAAMzU,OAAOiC,cAC9CjC,QAAOyR,eAAiB,SAAUpP,GAChC,GAAIsF,GAAS6M,EAAInS,EACjB,OAAOsF,KAAW4M,EAAW,KAAO5M,EAEtC3H,QAAOiC,eAAiB,SAAUI,EAAGqH,GACnC,GAAIiB,GAAQjB,IAAM,KAAO6K,EAAW7K,CACpC,OAAO+K,GAAIpS,EAAGsI,GAEhB3K,QAAOiC,eAAeqS,SAAW,UAIrC,GAAII,KAA+B/U,EAAY,WAAcK,OAAOsB,KAAK,QACzE,KAAKoT,GAA6B,CAChC,GAAIC,IAAqB3U,OAAOsB,IAChC0F,GAAehH,OAAQ,OAAQ,QAASsB,IAAKP,GAC3C,MAAO4T,IAAmB7M,EAAGS,SAASxH,MAI1C,GAAIf,OAAO4U,oBAAqB,CAC9B,GAAIC,KAA+BlV,EAAY,WAAcK,OAAO4U,oBAAoB,QACxF,KAAKC,GAA6B,CAChC,GAAIC,UAA2BC,UAAW,SAAW/U,OAAO4U,oBAAoBG,UAChF,IAAIC,IAAoChV,OAAO4U,mBAC/C5N,GAAehH,OAAQ,sBAAuB,QAAS4U,IAAoB7T,GACzE,GAAIkU,GAAMnN,EAAGS,SAASxH,EACtB,IAAIqC,EAAU6R,KAAS,kBAAmB,CACxC,IACE,MAAOD,IAAkCC,GACzC,MAAOrV,GAEP,MAAO0D,MAAYwR,KAGvB,MAAOE,IAAkCC,MAI/C,GAAIjV,OAAOqG,yBAA0B,CACnC,GAAI6O,KAA+BvV,EAAY,WAAcK,OAAOqG,yBAAyB,MAAO,QACpG,KAAK6O,GAA6B,CAChC,GAAIC,IAAyCnV,OAAOqG,wBACpDW,GAAehH,OAAQ,2BAA4B,QAASqG,IAAyBtF,EAAO2F,GAC1F,MAAOyO,IAAuCrN,EAAGS,SAASxH,GAAQ2F,MAIxE,GAAI1G,OAAOoV,KAAM,CACf,GAAIC,KAA+B1V,EAAY,WAAcK,OAAOoV,KAAK,QACzE,KAAKC,GAA6B,CAChC,GAAIC,IAAqBtV,OAAOoV,IAChCpO,GAAehH,OAAQ,OAAQ,QAASoV,IAAKrU,GAC3C,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAOA,GAClC,MAAOuU,IAAmBvU,MAIhC,GAAIf,OAAOuV,SAAU,CACnB,GAAIC,KAAmC7V,EAAY,WAAcK,OAAOuV,SAAS,QACjF,KAAKC,GAAiC,CACpC,GAAIC,IAAyBzV,OAAOuV,QACpCvO,GAAehH,OAAQ,WAAY,QAASuV,IAASxU,GACnD,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAO,MAClC,MAAO0U,IAAuB1U,MAIpC,GAAIf,OAAO0V,OAAQ,CACjB,GAAIC,KAAiChW,EAAY,WAAcK,OAAO0V,OAAO,QAC7E,KAAKC,GAA+B,CAClC,GAAIC,IAAuB5V,OAAO0V,MAClC1O,GAAehH,OAAQ,SAAU,QAAS0V,IAAO3U,GAC/C,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAOA,GAClC,MAAO6U,IAAqB7U,MAIlC,GAAIf,OAAO6V,SAAU,CACnB,GAAIC,KAAmCnW,EAAY,WAAcK,OAAO6V,SAAS,QACjF,KAAKC,GAAiC,CACpC,GAAIC,IAAyB/V,OAAO6V,QACpC7O,GAAehH,OAAQ,WAAY,QAAS6V,IAAS9U,GACnD,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAO,MAClC,MAAOgV,IAAuBhV,MAIpC,GAAIf,OAAOiU,kBAAmB,CAC5B,GAAI+B,KAA4CrW,EAAY,WAAcK,OAAOiU,kBAAkB,QACnG,KAAK+B,GAA0C,CAC7C,GAAIC,IAAkCjW,OAAOiU,iBAC7CjN,GAAehH,OAAQ,oBAAqB,QAASiU,IAAkBlT,GACrE,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAOA,GAClC,MAAOkV,IAAgClV,MAI7C,GAAIf,OAAOkW,aAAc,CACvB,GAAIC,KAAuCxW,EAAY,WAAcK,OAAOkW,aAAa,QACzF,KAAKC,GAAqC,CACxC,GAAIC,IAA6BpW,OAAOkW,YACxClP,GAAehH,OAAQ,eAAgB,QAASkW,IAAanV,GAC3D,IAAKuE,EAAKzE,OAAOE,GAAQ,CAAE,MAAO,OAClC,MAAOqV,IAA2BrV,MAIxC,GAAIf,OAAOyR,eAAgB,CACzB,GAAI4E,KAAmC1W,EAAY,WAAcK,OAAOyR,eAAe,QACvF,KAAK4E,GAAiC,CACpC,GAAIC,IAAmBtW,OAAOyR,cAC9BzK,GAAehH,OAAQ,iBAAkB,QAASyR,IAAe1Q,GAC/D,MAAOuV,IAAiBxO,EAAGS,SAASxH,OAK1C,IAAK8N,OAAOxO,UAAUkW,OAASrW,EAAqB,CAClD,GAAIsW,IAAoB,QAASD,MAC/B,IAAKzO,EAAGQ,aAAavJ,MAAO,CAC1B,KAAM,IAAIgH,WAAU,0DAEtB,GAAI4B,GAAS,EACb,IAAI5I,KAAK0X,OAAQ,CACf9O,GAAU,IAEZ,GAAI5I,KAAK2X,WAAY,CACnB/O,GAAU,IAEZ,GAAI5I,KAAK4X,UAAW,CAClBhP,GAAU,IAEZ,GAAI5I,KAAK6X,QAAS,CAChBjP,GAAU,IAEZ,GAAI5I,KAAK8X,OAAQ,CACflP,GAAU,IAEZ,MAAOA,GAGT/F,GAAMyD,OAAOwJ,OAAOxO,UAAW,QAASmW,IAG1C,GAAIM,IAA+BjX,EAAqB,WACtD,MAAO2C,QAAO,GAAIqM,QAAO,KAAM,QAAU,QAG3C,KAAKiI,IAAgC5W,EAAqB,CACxD,GAAI6W,IAAalI,MACjB,IAAImI,IAAa,QAASnI,IAAOoI,EAASV,GACxC,GAAIW,GAAgBnY,eAAgB8P,GACpC,KAAKqI,IAAkB5R,EAAKG,MAAMwR,IAAaA,GAAWA,EAAQ3U,cAAgBuM,IAAU,CAC1F,MAAOoI,GAET,GAAI3R,EAAKG,MAAMwR,IAAY3R,EAAKE,OAAO+Q,GAAQ,CAC7C,MAAO,IAAI1H,IAAOoI,EAAQlQ,OAAQwP,GAEpC,MAAO,IAAIQ,IAAWE,EAASV,GAEjC3U,GAAMiF,iBAAiBmQ,GAAYD,GACnC,IAAI/W,OAAOiC,eAAgB,CAEzBjC,OAAOiC,eAAe8U,GAAYC,IAEpC7W,EAASH,OAAO4U,oBAAoBmC,IAAa,SAAUpV,GACzD,GAAIA,IAAQ,SAAU,CAAE,OACxB,GAAIA,IAAOoD,GAAM,CAAE,OACnBnD,EAAMqE,MAAM8Q,GAAYpV,EAAKqV,KAE/BA,IAAW3W,UAAY0W,GAAW1W,SAClCuB,GAAM6E,SAASsQ,GAAW1W,UAAW,cAAe2W,GAEpDnI,QAASmI,EACTpV,GAAM6E,SAAS5D,EAAS,SAAUmU,IAIpC,GAAI9W,EAAqB,CACvB,GAAIiX,KACFC,MAAO,KACPC,UAAW,KACXC,UAAW,KACXC,YAAa,KACbC,aAAc,KAEhBrX,GAASH,OAAOsB,KAAK6V,IAAe,SAAUM,GAC5C,GAAIA,IAAQ5I,WAAYsI,GAAaM,IAAS5I,SAAS,CACrDjN,EAAMyD,OAAOwJ,OAAQsI,GAAaM,GAAO,QAASzR,KAChD,MAAO6I,QAAO4I,QAKtBrS,EAAkByJ,OAElB,IAAI6I,IAAiB,EAAI9R,OAAOgN,OAChC,IAAI+E,IAAkB,QAASA,IAAgBC,GAE7C,MAAQA,GAAIF,GAAkBA,GAEhC,IAAIG,IAAoB7T,KAAK0O,IAAI,GAAI,GACrC,IAAIoF,IAAsB9T,KAAK0O,IAAI,EAAG,MAAQ,EAAImF,GAClD,IAAIE,IAAsB/T,KAAK0O,IAAI,GAAI,IACvC,IAAIsF,IAAYpS,OAAOvF,UAAU4X,UAC1BrS,QAAOvF,UAAU4X,GAExB,IAAIC,KACFC,MAAO,QAASA,IAAMpX,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAI6E,OAAOC,MAAMN,IAAMxE,EAAQ,EAAG,CAAE,MAAOqX,KAC3C,GAAI7S,IAAM,EAAG,CAAE,MAAO,GACtB,GAAIA,IAAM5C,SAAU,CAAE,MAAO4C,GAC7B,MAAOf,GAAKe,EAAIvB,KAAKqU,EAAI3T,EAAMa,EAAI,GAAKb,EAAMa,EAAI,GAAKvB,KAAKqU,GAAK,GAGnEC,MAAO,QAASA,IAAMvX,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAIwE,IAAM,IAAMzC,EAAeyC,GAAI,CACjC,MAAOA,GAET,MAAOA,GAAI,GAAKvB,KAAKsU,OAAO/S,GAAKf,EAAKe,EAAIb,EAAMa,EAAIA,EAAI,KAG1DgT,MAAO,QAASA,IAAMxX,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAI6E,OAAOC,MAAMN,IAAMA,GAAK,GAAKA,EAAI,EAAG,CACtC,MAAO6S,KAET,GAAI7S,KAAO,EAAG,CAAE,OAAQ5C,SACxB,GAAI4C,IAAM,EAAG,CAAE,MAAO5C,UACtB,GAAI4C,IAAM,EAAG,CAAE,MAAOA,GACtB,MAAO,GAAMf,GAAM,EAAIe,IAAM,EAAIA,KAGnCiT,KAAM,QAASA,IAAKzX,GAClB,GAAIwE,GAAIK,OAAO7E,EACf,IAAIwE,IAAM,EAAG,CAAE,MAAOA,GACtB,GAAIkT,GAASlT,EAAI,EAAGoC,CACpB,IAAI8Q,EAAQ,CAAElT,GAAKA,EACnB,GAAIA,IAAM5C,SAAU,CAClBgF,EAAShF,aACJ,CACLgF,EAAS3D,KAAK0U,IAAIlU,EAAKe,GAAK,EAE5BoC,IAAUpC,GAAKoC,EAASA,GAAW,EAAIA,GAAW,EAEpD,MAAO8Q,IAAU9Q,EAASA,GAG5BgR,MAAO,QAASA,IAAM5X,GAEpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAI8H,GAASf,EAAGa,SAASpD,EACzB,IAAIsD,IAAW,EAAG,CAChB,MAAO,IAET,MAAOmP,IAAY3Y,EAAM2Y,GAAWnP,GAAU,GAAKzE,EAAOI,EAAKqE,EAAS,IAAO7E,KAAK4U,QAGtFC,KAAM,QAASA,IAAK9X,GAClB,GAAIwE,GAAIK,OAAO7E,EACf,IAAIwE,IAAM,EAAG,CAAE,MAAO,GACtB,GAAIK,OAAOC,MAAMN,GAAI,CAAE,MAAO6S,KAC9B,IAAKtV,EAAeyC,GAAI,CAAE,MAAO5C,UACjC,GAAI4C,EAAI,EAAG,CAAEA,GAAKA,EAClB,GAAIA,EAAI,GAAI,CAAE,MAAOvB,MAAK0U,IAAInT,GAAK,EACnC,OAAQvB,KAAK0U,IAAInT,GAAKvB,KAAK0U,KAAKnT,IAAM,GAGxCuT,MAAO,QAASA,IAAM/X,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAIwE,KAAO5C,SAAU,CAAE,OAAQ,EAC/B,IAAKG,EAAeyC,IAAMA,IAAM,EAAG,CAAE,MAAOA,GAC5C,GAAIjB,EAAKiB,GAAK,GAAK,CACjB,MAAOvB,MAAK0U,IAAInT,GAAK,EAIvB,GAAIwT,GAAIxT,CACR,IAAIyT,GAAM,CACV,IAAIpB,GAAI,CACR,OAAOoB,EAAMD,IAAMC,EAAK,CACtBA,GAAOD,CACPnB,IAAK,CACLmB,IAAKxT,EAAIqS,EAEX,MAAOoB,IAGTC,MAAO,QAASA,IAAM1T,EAAG2T,GACvB,GAAIvR,GAAS,CACb,IAAIwR,GAAU,CACd,KAAK,GAAIlN,GAAI,EAAGA,EAAIvM,UAAUkI,SAAUqE,EAAG,CACzC,GAAIlL,GAAQuD,EAAKsB,OAAOlG,UAAUuM,IAClC,IAAIkN,EAAUpY,EAAO,CACnB4G,GAAWwR,EAAUpY,GAAUoY,EAAUpY,EACzC4G,IAAU,CACVwR,GAAUpY,MACL,CACL4G,GAAW5G,EAAQ,EAAKA,EAAQoY,GAAYpY,EAAQoY,GAAWpY,GAGnE,MAAOoY,KAAYxW,SAAWA,SAAWwW,EAAUzU,EAAMiD,IAG3DyR,KAAM,QAASA,IAAKrY,GAClB,MAAOyD,GAAKzD,GAASiD,KAAK4U,OAG5BS,MAAO,QAASA,IAAMtY,GACpB,MAAOyD,GAAKzD,GAASiD,KAAKsV,QAG5BC,MAAO,QAASA,IAAMxY,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,IAAIwE,GAAK,GAAKK,OAAOC,MAAMN,GAAI,CAAE,MAAO6S,KACxC,GAAI7S,IAAM,GAAKA,IAAM5C,SAAU,CAAE,MAAO4C,GACxC,GAAIA,KAAO,EAAG,CAAE,OAAQ5C,SAExB,MAAQ,GAAI4C,EAAK,IAAM,EAAIA,EAAIA,GAAKf,EAAK,EAAIe,IAAO,EAAIA,EAAK,KAG/DiU,KAAM,QAASA,IAAKzY,GAClB,GAAI8H,GAASjD,OAAO7E,EACpB,IAAI8H,IAAW,EAAG,CAAE,MAAOA,GAC3B,GAAIjD,OAAOC,MAAMgD,GAAS,CAAE,MAAOA,GACnC,MAAOA,GAAS,GAAK,EAAI,GAG3B4Q,KAAM,QAASA,IAAK1Y,GAClB,GAAIwE,GAAIK,OAAO7E,EACf,KAAK+B,EAAeyC,IAAMA,IAAM,EAAG,CAAE,MAAOA,GAE5C,GAAIjB,EAAKiB,GAAK,EAAG,CACf,OAAQvB,KAAK8U,MAAMvT,GAAKvB,KAAK8U,OAAOvT,IAAM,EAE5C,OAAQvB,KAAK0U,IAAInT,EAAI,GAAKvB,KAAK0U,KAAKnT,EAAI,IAAMvB,KAAKqU,EAAI,GAGzDqB,KAAM,QAASA,IAAK3Y,GAClB,GAAIwE,GAAIK,OAAO7E,EACf,IAAI6E,OAAOC,MAAMN,IAAMA,IAAM,EAAG,CAAE,MAAOA,GACzC,GAAIA,IAAM5C,SAAU,CAAE,MAAO,GAC7B,GAAI4C,KAAO5C,SAAU,CAAE,OAAQ,EAC/B,GAAIuG,GAAIlF,KAAK8U,MAAMvT,EACnB,IAAI4D,GAAInF,KAAK8U,OAAOvT,EACpB,IAAI2D,IAAMvG,SAAU,CAAE,MAAO,GAC7B,GAAIwG,IAAMxG,SAAU,CAAE,OAAQ,EAC9B,OAAQuG,EAAIC,IAAMnF,KAAK0U,IAAInT,GAAKvB,KAAK0U,KAAKnT,KAG5CoU,MAAO,QAASA,IAAM5Y,GACpB,GAAIwE,GAAIK,OAAO7E,EACf,OAAOwE,GAAI,GAAKnB,GAAQmB,GAAKnB,EAAOmB,IAGtCqU,KAAM,QAASA,IAAKrU,EAAG2T,GAErB,GAAIhQ,GAAIpB,EAAGa,SAASpD,EACpB,IAAI4D,GAAIrB,EAAGa,SAASuQ,EACpB,IAAIW,GAAM3Q,IAAM,GAAM,KACtB,IAAI4Q,GAAK5Q,EAAI,KACb,IAAI6Q,GAAM5Q,IAAM,GAAM,KACtB,IAAI6Q,GAAK7Q,EAAI,KAGb,OAAS2Q,GAAKE,GAASH,EAAKG,EAAKF,EAAKC,GAAO,KAAQ,GAAK,GAG5DE,OAAQ,QAASA,IAAO1U,GACtB,GAAI2U,GAAItU,OAAOL,EACf,IAAI2U,IAAM,GAAKA,IAAMvX,UAAYuX,KAAOvX,UAAYgD,EAAYuU,GAAI,CAClE,MAAOA,GAET,GAAIV,GAAOxV,KAAKwV,KAAKU,EACrB,IAAI3V,GAAMD,EAAK4V,EACf,IAAI3V,EAAMwT,GAAqB,CAC7B,MAAOyB,GAAO7B,GAAgBpT,EAAMwT,GAAsBF,IAAqBE,GAAsBF,GAGvG,GAAI3O,IAAK,EAAI2O,GAAoBjS,OAAOgN,SAAWrO,CACnD,IAAIoD,GAASuB,GAAKA,EAAI3E,EACtB,IAAIoD,EAASmQ,IAAuBnS,EAAYgC,GAAS,CACvD,MAAO6R,GAAO7W,SAEhB,MAAO6W,GAAO7R,GAGlBvG,GAAiB4C,KAAMkU,GAEvBjY,GAAe+D,KAAM,QAASkU,GAAUqB,MAAOvV,KAAKuV,OAAO,UAAY,MAEvEtZ,GAAe+D,KAAM,QAASkU,GAAUI,MAAOtU,KAAKsU,OAAO,QAAUtU,KAAKsU,MAAM,KAEhFrY,GAAe+D,KAAM,OAAQkU,GAAUwB,KAAM1V,KAAK0V,MAAM,UAAY,MAEpEzZ,GAAe+D,KAAM,QAASkU,GAAUC,MAAOnU,KAAKmU,MAAMvS,OAAOuU,aAAexX,SAEhF1C,GAAe+D,KAAM,OAAQkU,GAAUM,KAAMxU,KAAKO,IAAI,EAAIP,KAAKwU,KAAK,QAAU,QAAU5S,OAAOgN,QAAU,EAEzG3S,GAAe+D,KAAM,OAAQkU,GAAUuB,KAAMzV,KAAKyV,MAAM,UAAY,MAEpE,IAAIW,IAAapW,KAAK8U,MAAM,GAC5B7Y,GAAe+D,KAAM,QAASkU,GAAUY,MAAOsB,GAAa,oBAAsBA,GAAa,mBAE/F,IAAIC,IAAgBrW,KAAKsW,KAEzB,IAAIC,IAAiCvW,KAAKsW,MAAM,GAAM1U,OAAOgN,QAAU,KAAO,GAAK5O,KAAKsW,OAAO,GAAM1U,OAAOgN,QAAU,QAAU,CAMhI,IAAI4H,IAAyC9C,GAAiB,CAC9D,IAAI+C,IAAwC,EAAI/C,GAAiB,CACjE,IAAIgD,KAAgCF,GAAwCC,IAAuC7Z,MAAM,SAAU+Z,GACjI,MAAO3W,MAAKsW,MAAMK,KAASA,GAE7B1a,GAAe+D,KAAM,QAAS,QAASsW,IAAM/U,GAC3C,GAAIlB,GAAQD,EAAOmB,EACnB,IAAIqV,GAAOvW,KAAW,GAAK,EAAIA,EAAQ,CACvC,OAAOkB,GAAIlB,EAAQ,GAAMA,EAAQuW,IAC/BL,KAAmCG,GACvC9Y,GAAMiF,iBAAiB7C,KAAKsW,MAAOD,GAEnC,IAAIQ,IAAW7W,KAAK4V,IACpB,IAAI5V,KAAK4V,KAAK,WAAY,MAAQ,EAAG,CAEnC5V,KAAK4V,KAAO1B,GAAU0B,IACtBhY,GAAMiF,iBAAiB7C,KAAK4V,KAAMiB,IAEpC,GAAI7W,KAAK4V,KAAKhS,SAAW,EAAG,CAG1BZ,EAAehD,KAAM,OAAQ,QAAS4V,IAAKrU,EAAG2T,GAC5C,MAAOla,GAAO6b,GAAU7W,KAAMtE,aAOlC,GAAIob,IAAe,WAEjBhT,EAAGiT,UAAY,SAAUC,GACvB,IAAKlT,EAAGQ,aAAa0S,GAAU,CAC7B,MAAO,OAET,SAAWA,GAAQC,WAAa,YAAa,CAC3C,MAAO,OAET,MAAO,MAKT,IAAIC,GAAoB,SAAUnZ,GAChC,IAAK+F,EAAGU,cAAczG,GAAI,CACxB,KAAM,IAAIgE,WAAU,2BAEtB,GAAIoV,GAAapc,IACjB,IAAIqc,GAAW,SAAUC,EAASC,GAChC,GAAIH,EAAWE,cAAiB,IAAKF,EAAWG,aAAgB,GAAG,CACjE,KAAM,IAAIvV,WAAU,+BAEtBoV,EAAWE,QAAUA,CACrBF,GAAWG,OAASA,EAEtBH,GAAWH,QAAU,GAAIjZ,GAAEqZ,EAC3B,MAAMtT,EAAGK,WAAWgT,EAAWE,UAAYvT,EAAGK,WAAWgT,EAAWG,SAAU,CAC5E,KAAM,IAAIvV,WAAU,4BAKxB,IAAIwV,GAAa1Y,EAAQ0Y,UACzB,IAAIC,EAEJ,UAAWzG,UAAW,aAAejN,EAAGK,WAAW4M,OAAO0G,aAAc,CACtED,EAAkB,WAEhB,GAAIE,KACJ,IAAIC,GAAc,sBAClB,IAAIC,GAAiB,SAAUC,GAC7BnY,EAAMgY,EAAUG,EAChB9G,QAAO0G,YAAYE,EAAa,KAElC,IAAIG,GAAgB,SAAUC,GAC5B,GAAIA,EAAMhV,SAAWgO,QAAUgH,EAAMC,OAASL,EAAa,CACzDI,EAAME,iBACN,IAAIP,EAAS9T,SAAW,EAAG,CAAE,OAC7B,GAAIiU,GAAKhY,EAAO6X,EAChBG,MAGJ9G,QAAOmH,iBAAiB,UAAWJ,EAAe,KAClD,OAAOF,IAGX,GAAIO,GAAkB,WAKpB,GAAIC,GAAIvZ,EAAQwZ,OAChB,OAAOD,IAAKA,EAAEf,SAAW,SAAUiB,GACjC,MAAOF,GAAEf,UAAUkB,KAAKD,IAI5B,IAAIE,GAAU1U,EAAGK,WAAWtF,EAAQ4Z,cAClC5Z,EAAQ4Z,aAAatd,KAAK0D,SACnB6Z,WAAY,UAAYA,QAAQC,SAAWD,QAAQC,SAC1DR,MACCrU,EAAGK,WAAWqT,GAAmBA,IAClC,SAAUc,GAAQf,EAAWe,EAAM,IAGrC,IAAIM,GAAmB,CACvB,IAAIC,GAAkB,CACtB,IAAIC,GAAkB,CACtB,IAAIC,GAAoB,CACxB,IAAIC,GAAmB,CAEvB,IAAIC,GAAqB,SAAUC,EAAUC,GAC3C,GAAIC,GAAoBF,EAASG,YACjC,IAAIC,GAAUJ,EAASI,OACvB,IAAIC,GAAeC,EAAmB,MAAOxb,CAC7C,IAAIsb,IAAYV,EAAkB,CAChCW,EAAgBJ,MACX,IAAIG,IAAYT,EAAiB,CACtCU,EAAgBJ,CAChBK,GAAmB,SACd,CACL,IACED,EAAgBD,EAAQH,GACxB,MAAOvd,GACP2d,EAAgB3d,CAChB4d,GAAmB,MAGvBxb,EAAIwb,EAAmBJ,EAAkB9B,OAAS8B,EAAkB/B,OACpErZ,GAAEub,GAGJ,IAAIE,GAA0B,SAAUC,EAAWP,GACjDhd,EAASud,EAAW,SAAUR,GAC5BV,EAAQ,WACNS,EAAmBC,EAAUC,OAKnC,IAAIQ,GAAiB,SAAU3C,EAASja,GACtC,GAAIka,GAAWD,EAAQC,QACvB,IAAIyC,GAAYzC,EAAS2C,gBACzB3C,GAAStT,OAAS5G,CAClBka,GAAS2C,qBAAwB,EACjC3C,GAAS4C,oBAAuB,EAChC5C,GAAS6C,MAAQf,CACjBU,GAAwBC,EAAW3c,GAGrC,IAAIgd,GAAgB,SAAU/C,EAASgD,GACrC,GAAI/C,GAAWD,EAAQC,QACvB,IAAIyC,GAAYzC,EAAS4C,eACzB5C,GAAStT,OAASqW,CAClB/C,GAAS2C,qBAAwB,EACjC3C,GAAS4C,oBAAuB,EAChC5C,GAAS6C,MAAQd,CACjBS,GAAwBC,EAAWM,GAGrC,IAAIC,GAA2B,SAAUjD,GACvC,GAAIkD,GAAkB,KACtB,IAAI7C,GAAU,SAAU8C,GACtB,GAAI5B,EACJ,IAAI2B,EAAiB,CAAE,OACvBA,EAAkB,IAClB,IAAIC,IAAenD,EAAS,CAC1B,MAAO+C,GAAc/C,EAAS,GAAIjV,WAAU,oBAE9C,IAAK+B,EAAGQ,aAAa6V,GAAa,CAChC,MAAOR,GAAe3C,EAASmD,GAEjC,IACE5B,EAAO4B,EAAW5B,KAClB,MAAO3c,GACP,MAAOme,GAAc/C,EAASpb,GAEhC,IAAKkI,EAAGK,WAAWoU,GAAO,CACxB,MAAOoB,GAAe3C,EAASmD,GAEjC3B,EAAQ,WACN4B,EAA0BpD,EAASmD,EAAY5B,KAGnD,IAAIjB,GAAS,SAAU0C,GACrB,GAAIE,EAAiB,CAAE,OACvBA,EAAkB,IAClB,OAAOH,GAAc/C,EAASgD,GAEhC,QAAS3C,QAASA,EAASC,OAAQA,GAGrC,IAAI8C,GAA4B,SAAUpD,EAASqD,EAAU9B,GAC3D,GAAI+B,GAAqBL,EAAyBjD,EAClD,IAAIK,GAAUiD,EAAmBjD,OACjC,IAAIC,GAASgD,EAAmBhD,MAChC,KACEjc,EAAMkd,EAAM8B,EAAUhD,EAASC,GAC/B,MAAO1b,GACP0b,EAAO1b,IAKX,IAAI2e,GAAoB,SAAUxc,GAChC,IAAK+F,EAAGQ,aAAavG,GAAI,CACvB,KAAM,IAAIgE,WAAU,yBAEtB,GAAIiF,GAAIjJ,EAAEkD,EACV,IAAI+F,QAAW,IAAKA,IAAM,KAAM,CAC9B,MAAOA,GAET,MAAOjJ,GAGT,IAAIsa,GAAU,QAASA,GAAQjB,GAC7B,KAAMrc,eAAgBsd,IAAU,CAC9B,KAAM,IAAItW,WAAU,sCAEtB,GAAIhH,MAAQA,KAAKkc,SAAU,CACzB,KAAM,IAAIlV,WAAU,oBAGtB,IAAK+B,EAAGK,WAAWiT,GAAW,CAC5B,KAAM,IAAIrV,WAAU,wBAEtB,GAAIiV,GAAUvP,EAAoB1M,KAAMsd,EAASmC,GAC/CvD,UACEtT,WAAa,GACbmW,MAAOhB,EACPc,oBACAC,qBAGJ,IAAIS,GAAqBL,EAAyBjD,EAClD,IAAIM,GAASgD,EAAmBhD,MAChC,KACEF,EAASkD,EAAmBjD,QAASC,GACrC,MAAO1b,GACP0b,EAAO1b,GAET,MAAOob,GAET,IAAIwD,GAAoBnC,EAAQhc,SAEhC,IAAIoe,GAAsB,SAAUC,EAAOrN,EAAQ8J,EAAYwD,GAC7D,GAAIC,GAAgB,KACpB,OAAO,UAAUrZ,GACf,GAAIqZ,EAAe,CAAE,OACrBA,EAAgB,IAChBvN,GAAOqN,GAASnZ,CAChB,MAAOoZ,EAAU/N,QAAW,EAAG,CAC7B,GAAIyK,GAAUF,EAAWE,OACzBA,GAAQhK,KAKd,IAAIwN,GAAoB,SAAUC,EAAgB/c,EAAGgd,GACnD,GAAItV,GAAKqV,EAAe1X,QACxB,IAAIiK,MAAasN,GAAc/N,MAAO,GAAKzG,EAAMsF,CACjD,KAAK,GAAIiP,GAAQ,GAAKA,IAAS,CAC7B,IACEvU,EAAOrC,EAAGsC,aAAaX,EACvB,IAAIU,IAAS,MAAO,CAClB2U,EAAezU,KAAO,IACtB,OAEFoF,EAAYtF,EAAKpJ,MACjB,MAAOnB,GACPkf,EAAezU,KAAO,IACtB,MAAMzK,GAERyR,EAAOqN,OAAc,EACrB,IAAIM,GAAcjd,EAAEsZ,QAAQ5L,EAC5B,IAAIwP,GAAiBR,EACnBC,EAAOrN,EAAQ0N,EAAkBJ,EAEnCA,GAAU/N,OACVoO,GAAYzC,KAAK0C,EAAgBF,EAAiBzD,QAEpD,KAAOqD,EAAU/N,QAAW,EAAG,CAC7B,GAAIyK,GAAU0D,EAAiB1D,OAC/BA,GAAQhK,GAEV,MAAO0N,GAAiB/D,QAG1B,IAAIkE,GAAqB,SAAUJ,EAAgB/c,EAAGgd,GACpD,GAAItV,GAAKqV,EAAe1X,SAAU+C,EAAMsF,EAAWuP,CACnD,OAAO,KAAM,CACX,IACE7U,EAAOrC,EAAGsC,aAAaX,EACvB,IAAIU,IAAS,MAAO,CAKlB2U,EAAezU,KAAO,IACtB,OAEFoF,EAAYtF,EAAKpJ,MACjB,MAAOnB,GACPkf,EAAezU,KAAO,IACtB,MAAMzK,GAERof,EAAcjd,EAAEsZ,QAAQ5L,EACxBuP,GAAYzC,KAAKwC,EAAiB1D,QAAS0D,EAAiBzD,QAE9D,MAAOyD,GAAiB/D,QAG1B5Z,GAAiBib,GACf8C,IAAK,QAASA,GAAIC,GAChB,GAAIrd,GAAIwc,EAAkBxf,KAC1B,IAAIoc,GAAa,GAAID,GAAkBnZ,EACvC,IAAIqF,GAAU0X,CACd,KACE1X,EAAWU,EAAGwB,YAAY8V,EAC1BN,IAAmB1X,SAAUA,EAAUiD,KAAM,MAC7C,OAAOwU,GAAkBC,EAAgB/c,EAAGoZ,GAC5C,MAAOvb,GACP,GAAIkf,IAAmBA,EAAezU,KAAM,CAC1C,IACEvC,EAAG+B,cAAczC,EAAU,MAC3B,MAAOiY,GACPzf,EAAIyf,GAGR,GAAI/D,GAASH,EAAWG,MACxBA,GAAO1b,EACP,OAAOub,GAAWH,UAItBsE,KAAM,QAASA,GAAKF,GAClB,GAAIrd,GAAIwc,EAAkBxf,KAC1B,IAAIoc,GAAa,GAAID,GAAkBnZ,EACvC,IAAIqF,GAAU0X,CACd,KACE1X,EAAWU,EAAGwB,YAAY8V,EAC1BN,IAAmB1X,SAAUA,EAAUiD,KAAM,MAC7C,OAAO6U,GAAmBJ,EAAgB/c,EAAGoZ,GAC7C,MAAOvb,GACP,GAAIkf,IAAmBA,EAAezU,KAAM,CAC1C,IACEvC,EAAG+B,cAAczC,EAAU,MAC3B,MAAOiY,GACPzf,EAAIyf,GAGR,GAAI/D,GAASH,EAAWG,MACxBA,GAAO1b,EACP,OAAOub,GAAWH,UAItBM,OAAQ,QAASA,GAAO0C,GACtB,GAAIjc,GAAIhD,IACR,IAAIoc,GAAa,GAAID,GAAkBnZ,EACvC,IAAIwd,GAAapE,EAAWG,MAC5BiE,GAAWvB,EACX,OAAO7C,GAAWH,SAGpBK,QAAS,QAASA,GAAQnB,GAExB,GAAInY,GAAIhD,IACR,IAAI+I,EAAGiT,UAAUb,GAAI,CACnB,GAAI5X,GAAc4X,EAAE5X,WACpB,IAAIA,IAAgBP,EAAG,CAAE,MAAOmY,IAElC,GAAIiB,GAAa,GAAID,GAAkBnZ,EACvC,IAAIyd,GAAcrE,EAAWE,OAC7BmE,GAAYtF,EACZ,OAAOiB,GAAWH,UAItB5Z,GAAiBod,GACfiB,QAAS,SAAUC,GACjB,MAAO3gB,MAAKwd,SAAU,GAAGmD,IAG3BnD,KAAM,QAASA,GAAKoD,EAAaD,GAC/B,GAAI1E,GAAUjc,IACd,KAAK+I,EAAGiT,UAAUC,GAAU,CAAE,KAAM,IAAIjV,WAAU,iBAClD,GAAIhE,GAAI+F,EAAG+C,mBAAmBmQ,EAASqB,EACvC,IAAI0C,GAAmB,GAAI7D,GAAkBnZ,EAE7C,KAAK+F,EAAGK,WAAWwX,GAAc,CAC/BA,EAAc/C,EAEhB,IAAK9U,EAAGK,WAAWuX,GAAa,CAC9BA,EAAa7C,EAEf,GAAI+C,IAAoBvC,aAAc0B,EAAkBzB,QAASqC,EACjE,IAAIE,IAAmBxC,aAAc0B,EAAkBzB,QAASoC,EAChE,IAAIzE,GAAWD,EAAQC,SAAUla,CACjC,QAAQka,EAAS6C,OACf,IAAKhB,GACHpZ,EAAMuX,EAAS2C,iBAAkBgC,EACjClc,GAAMuX,EAAS4C,gBAAiBgC,EAChC,MACF,KAAK9C,GACHhc,EAAQka,EAAStT,MACjB6U,GAAQ,WACNS,EAAmB2C,EAAiB7e,IAEtC,MACF,KAAKic,GACHjc,EAAQka,EAAStT,MACjB6U,GAAQ,WACNS,EAAmB4C,EAAgB9e,IAErC,MACF,SACE,KAAM,IAAIgF,WAAU,cAExB,MAAOgZ,GAAiB/D,UAI5B,OAAOqB,KAIT,IAAIxZ,EAAQwZ,QAAS,OACZxZ,GAAQwZ,QAAQyD,aAChBjd,GAAQwZ,QAAQ0D,YAChBld,GAAQwZ,QAAQhc,UAAU2f,MAInC5e,EAAiByB,GAAWwZ,QAASvB,IAIrC,IAAImF,IAA6Bne,EAAoBe,EAAQwZ,QAAS,SAAUrR,GAC9E,MAAOA,GAAEqQ,QAAQ,IAAIkB,KAAK,uBAA2BvR,IAEvD,IAAIkV,KAA0CvgB,EAAY,WAAckD,EAAQwZ,QAAQf,OAAO,IAAIiB,KAAK,KAAM,GAAGA,KAAK,KAAMxX,IAC5H,IAAIob,IAA+BxgB,EAAY,WAAckD,EAAQwZ,QAAQnd,KAAK,EAAG6F,IAMrF,IAAIqb,IAAuB,SAAW/D,GACpC,GAAI3S,GAAI2S,EAAQhB,QAAQ,EACxB3R,GAAEpH,cACF,IAAIiJ,GAAK8Q,EAAQhB,QAAQ3R,EACzB,OAAQA,KAAM6B,GACb1I,EAAQwZ,QACX,KAAK4D,KAA+BC,KAC/BC,IAAgCC,GAAsB,CAEzD/D,QAAUvB,EAEV9T,GAAenE,EAAS,UAAWiY,IAErC1V,EAAkBiX,QAKlB,IAAIgE,IAAY,SAAUnX,GACxB,GAAIC,GAAInJ,OAAOsB,KAAKf,EAAQ2I,EAAG,SAAU7G,EAAGie,GAC1Cje,EAAEie,GAAK,IACP,OAAOje,QAET,OAAO6G,GAAEkD,KAAK,OAASjD,EAAEiD,KAAK,KAEhC,IAAImU,IAA0BF,IAAW,IAAK,IAAK,MAEnD,IAAIG,IAAiCH,IAAW,IAAK,EAAG,IAAK,IAAK,GAElE,IAAIngB,EAAqB,CAEvB,GAAIugB,IAAU,QAASA,IAAQ9e,GAC7B,IAAK4e,GAAyB,CAC5B,MAAO,MAET,GAAIG,SAAc/e,EAClB,IAAI+e,IAAS,aAAe/e,IAAQ,KAAM,CACxC,MAAO,IAAMa,OAAOb,OACf,IAAI+e,IAAS,SAAU,CAC5B,MAAO,IAAM/e,MACR,IAAI+e,IAAS,SAAU,CAE5B,IAAKF,GAAgC,CACnC,MAAO,IAAM7e,EAEf,MAAOA,OACF,IAAI+e,IAAS,UAAW,CAC7B,MAAO,IAAM/e,EAEf,MAAO,MAGT,IAAIgf,IAAc,QAASA,MAEzB,MAAO3gB,QAAOwB,OAASxB,OAAOwB,OAAO,SAGvC,IAAIof,IAAmB,QAASA,IAAiBC,EAAgBxf,EAAK+d,GACpE,GAAIhf,MAAM0gB,QAAQ1B,IAAa9Z,EAAKE,OAAO4Z,GAAW,CACpDjf,EAASif,EAAU,SAAU2B,GAC3B1f,EAAIkF,IAAIwa,EAAM,GAAIA,EAAM,UAErB,IAAI3B,YAAoByB,GAAgB,CAC7CxhB,EAAMwhB,EAAexgB,UAAUC,QAAS8e,EAAU,SAAUre,EAAOY,GACjEN,EAAIkF,IAAI5E,EAAKZ,SAEV,CACL,GAAIigB,GAAMC,CACV,IAAI7B,IAAa,YAAeA,KAAa,YAAa,CACxD6B,EAAQ5f,EAAIkF,GACZ,KAAKuB,EAAGK,WAAW8Y,GAAQ,CAAE,KAAM,IAAIlb,WAAU,WACjDib,EAAOlZ,EAAGwB,YAAY8V,GAExB,SAAW4B,KAAS,YAAa,CAC/B,MAAO,KAAM,CACX,GAAI7W,GAAOrC,EAAGsC,aAAa4W,EAC3B,IAAI7W,IAAS,MAAO,CAAE,MACtB,GAAI+W,GAAW/W,EAAKpJ,KACpB,KACE,IAAK+G,EAAGQ,aAAa4Y,GAAW,CAC9B,KAAM,IAAInb,WAAU,8BAEtB1G,EAAM4hB,EAAO5f,EAAK6f,EAAS,GAAIA,EAAS,IACxC,MAAOthB,GACPkI,EAAG+B,cAAcmX,EAAM,KACvB,MAAMphB,OAMhB,IAAIuhB,IAAmB,QAASA,IAAiBC,EAAgB7a,EAAK6Y,GACpE,GAAIhf,MAAM0gB,QAAQ1B,IAAa9Z,EAAKE,OAAO4Z,GAAW,CACpDjf,EAASif,EAAU,SAAUre,GAC3BwF,EAAI8a,IAAItgB,SAEL,IAAIqe,YAAoBgC,GAAgB,CAC7C/hB,EAAM+hB,EAAe/gB,UAAUC,QAAS8e,EAAU,SAAUre,GAC1DwF,EAAI8a,IAAItgB,SAEL,CACL,GAAIigB,GAAMC,CACV,IAAI7B,IAAa,YAAeA,KAAa,YAAa,CACxD6B,EAAQ1a,EAAI8a,GACZ,KAAKvZ,EAAGK,WAAW8Y,GAAQ,CAAE,KAAM,IAAIlb,WAAU,WACjDib,EAAOlZ,EAAGwB,YAAY8V,GAExB,SAAW4B,KAAS,YAAa,CAC/B,MAAO,KAAM,CACX,GAAI7W,GAAOrC,EAAGsC,aAAa4W,EAC3B,IAAI7W,IAAS,MAAO,CAAE,MACtB,GAAIsF,GAAYtF,EAAKpJ,KACrB,KACE1B,EAAM4hB,EAAO1a,EAAKkJ,GAClB,MAAO7P,GACPkI,EAAG+B,cAAcmX,EAAM,KACvB,MAAMphB,OAOhB,IAAI0hB,KACFC,IAAM,WAEJ,GAAIC,KAEJ,IAAIC,GAAW,QAASA,GAAS9f,EAAKZ,GACpChC,KAAK4C,IAAMA,CACX5C,MAAKgC,MAAQA,CACbhC,MAAKoL,KAAO,IACZpL,MAAK2iB,KAAO,KAGdD,GAASphB,UAAUshB,UAAY,QAASA,KACtC,MAAO5iB,MAAK4C,MAAQ6f;CAGtB,IAAII,GAAQ,QAASA,GAAMvgB,GACzB,QAASA,EAAIwgB,QAGf,IAAIC,GAAiB,QAASA,GAAezgB,EAAKE,GAChD,IAAKuG,EAAGQ,aAAajH,KAASugB,EAAMvgB,GAAM,CACxC,KAAM,IAAI0E,WAAU,wBAA0BxE,EAAS,oCAAsCiB,OAAOnB,KAIxG,IAAI0gB,GAAc,QAASA,GAAY1gB,EAAK0O,GAC1C+R,EAAezgB,EAAK,kBACpBtC,MAAKijB,KAAO3gB,EAAI4gB,KAChBljB,MAAKkN,EAAIlN,KAAKijB,IACdjjB,MAAKgR,KAAOA,EAGdgS,GAAY1hB,WACV8J,KAAM,QAASA,KACb,GAAI8B,GAAIlN,KAAKkN,EAAG8D,EAAOhR,KAAKgR,KAAMiS,EAAOjjB,KAAKijB,KAAMra,CACpD,UAAW5I,MAAKkN,IAAM,YAAa,CACjC,OAASlL,UAAY,GAAGsJ,KAAM,MAEhC,MAAO4B,EAAE0V,aAAe1V,IAAM+V,EAAM,CAElC/V,EAAIA,EAAEyV,KAGR,MAAOzV,EAAE9B,OAAS6X,EAAM,CACtB/V,EAAIA,EAAE9B,IACN,KAAK8B,EAAE0V,YAAa,CAClB,GAAI5R,IAAS,MAAO,CAClBpI,EAASsE,EAAEtK,QACN,IAAIoO,IAAS,QAAS,CAC3BpI,EAASsE,EAAElL,UACN,CACL4G,GAAUsE,EAAEtK,IAAKsK,EAAElL,OAErBhC,KAAKkN,EAAIA,CACT,QAASlL,MAAO4G,EAAQ0C,KAAM,QAIlCtL,KAAKkN,MAAS,EACd,QAASlL,UAAY,GAAGsJ,KAAM,OAGlC/C,GAAYya,EAAY1hB,UAExB,IAAI6hB,GAAU,QAASX,KACrB,KAAMxiB,eAAgBwiB,IAAM,CAC1B,KAAM,IAAIxb,WAAU,kCAEtB,GAAIhH,MAAQA,KAAK8iB,QAAS,CACxB,KAAM,IAAI9b,WAAU,oBAEtB,GAAI1E,GAAMoK,EAAoB1M,KAAMwiB,EAAKY,GACvCN,QAAS,KACTI,MAAO,KACPG,SAAUzB,KACV0B,MAAO,GAGT,IAAIL,GAAO,GAAIP,GAAS,KAAM,KAE9BO,GAAK7X,KAAO6X,EAAKN,KAAOM,CACxB3gB,GAAI4gB,MAAQD,CAGZ,IAAItiB,UAAUkI,OAAS,EAAG,CACxBgZ,GAAiBW,EAAKlgB,EAAK3B,UAAU,IAEvC,MAAO2B,GAET,IAAI8gB,GAAgBD,EAAQ7hB,SAE5BuB,GAAMyD,OAAO8c,EAAe,OAAQ,WAClC,SAAWpjB,MAAKsjB,QAAU,YAAa,CACrC,KAAM,IAAItc,WAAU,0CAEtB,MAAOhH,MAAKsjB,OAGdjhB,GAAiB+gB,GACfnc,IAAK,QAASA,GAAIrE,GAChBmgB,EAAe/iB,KAAM,MACrB,IAAIujB,GAAO7B,GAAQ9e,EACnB,IAAI2gB,IAAS,KAAM,CAEjB,GAAIvB,GAAQhiB,KAAKqjB,SAASE,EAC1B,IAAIvB,EAAO,CACT,MAAOA,GAAMhgB,UACR,CACL,QAGJ,GAAIihB,GAAOjjB,KAAKkjB,MAAOhW,EAAI+V,CAC3B,QAAQ/V,EAAIA,EAAE9B,QAAU6X,EAAM,CAC5B,GAAIla,EAAGsB,cAAc6C,EAAEtK,IAAKA,GAAM,CAChC,MAAOsK,GAAElL,SAKfwhB,IAAK,QAASA,GAAI5gB,GAChBmgB,EAAe/iB,KAAM,MACrB,IAAIujB,GAAO7B,GAAQ9e,EACnB,IAAI2gB,IAAS,KAAM,CAEjB,aAAcvjB,MAAKqjB,SAASE,KAAU,YAExC,GAAIN,GAAOjjB,KAAKkjB,MAAOhW,EAAI+V,CAC3B,QAAQ/V,EAAIA,EAAE9B,QAAU6X,EAAM,CAC5B,GAAIla,EAAGsB,cAAc6C,EAAEtK,IAAKA,GAAM,CAChC,MAAO,OAGX,MAAO,QAGT4E,IAAK,QAASA,GAAI5E,EAAKZ,GACrB+gB,EAAe/iB,KAAM,MACrB,IAAIijB,GAAOjjB,KAAKkjB,MAAOhW,EAAI+V,EAAMjB,CACjC,IAAIuB,GAAO7B,GAAQ9e,EACnB,IAAI2gB,IAAS,KAAM,CAEjB,SAAWvjB,MAAKqjB,SAASE,KAAU,YAAa,CAC9CvjB,KAAKqjB,SAASE,GAAMvhB,MAAQA,CAC5B,OAAOhC,UACF,CACLgiB,EAAQhiB,KAAKqjB,SAASE,GAAQ,GAAIb,GAAS9f,EAAKZ,EAChDkL,GAAI+V,EAAKN,MAIb,OAAQzV,EAAIA,EAAE9B,QAAU6X,EAAM,CAC5B,GAAIla,EAAGsB,cAAc6C,EAAEtK,IAAKA,GAAM,CAChCsK,EAAElL,MAAQA,CACV,OAAOhC,OAGXgiB,EAAQA,GAAS,GAAIU,GAAS9f,EAAKZ,EACnC,IAAI+G,EAAGmB,WAAW,EAAGtH,GAAM,CACzBof,EAAMpf,KAAO,EAEfof,EAAM5W,KAAOpL,KAAKkjB,KAClBlB,GAAMW,KAAO3iB,KAAKkjB,MAAMP,IACxBX,GAAMW,KAAKvX,KAAO4W,CAClBA,GAAM5W,KAAKuX,KAAOX,CAClBhiB,MAAKsjB,OAAS,CACd,OAAOtjB,OAGTyjB,SAAU,SAAU7gB,GAClBmgB,EAAe/iB,KAAM,SACrB,IAAIijB,GAAOjjB,KAAKkjB,MAAOhW,EAAI+V,CAC3B,IAAIM,GAAO7B,GAAQ9e,EACnB,IAAI2gB,IAAS,KAAM,CAEjB,SAAWvjB,MAAKqjB,SAASE,KAAU,YAAa,CAC9C,MAAO,OAETrW,EAAIlN,KAAKqjB,SAASE,GAAMZ,WACjB3iB,MAAKqjB,SAASE,GAGvB,OAAQrW,EAAIA,EAAE9B,QAAU6X,EAAM,CAC5B,GAAIla,EAAGsB,cAAc6C,EAAEtK,IAAKA,GAAM,CAChCsK,EAAEtK,IAAMsK,EAAElL,MAAQygB,CAClBvV,GAAEyV,KAAKvX,KAAO8B,EAAE9B,IAChB8B,GAAE9B,KAAKuX,KAAOzV,EAAEyV,IAChB3iB,MAAKsjB,OAAS,CACd,OAAO,OAGX,MAAO,QAGTI,MAAO,QAASA,KACdX,EAAe/iB,KAAM,QACrBA,MAAKsjB,MAAQ,CACbtjB,MAAKqjB,SAAWzB,IAChB,IAAIqB,GAAOjjB,KAAKkjB,MAAOhW,EAAI+V,EAAMtY,EAAIuC,EAAE9B,IACvC,QAAQ8B,EAAIvC,KAAOsY,EAAM,CACvB/V,EAAEtK,IAAMsK,EAAElL,MAAQygB,CAClB9X,GAAIuC,EAAE9B,IACN8B,GAAE9B,KAAO8B,EAAEyV,KAAOM,EAEpBA,EAAK7X,KAAO6X,EAAKN,KAAOM,GAG1B1gB,KAAM,QAASA,KACbwgB,EAAe/iB,KAAM,OACrB,OAAO,IAAIgjB,GAAYhjB,KAAM,QAG/BsS,OAAQ,QAASA,KACfyQ,EAAe/iB,KAAM,SACrB,OAAO,IAAIgjB,GAAYhjB,KAAM,UAG/BuS,QAAS,QAASA,KAChBwQ,EAAe/iB,KAAM,UACrB,OAAO,IAAIgjB,GAAYhjB,KAAM,cAG/BuB,QAAS,QAASA,GAAQoiB,GACxBZ,EAAe/iB,KAAM,UACrB,IAAI4jB,GAAUjjB,UAAUkI,OAAS,EAAIlI,UAAU,GAAK,IACpD,IAAI+J,GAAK1K,KAAKuS,SACd,KAAK,GAAIyP,GAAQtX,EAAGU,QAAS4W,EAAM1W,KAAM0W,EAAQtX,EAAGU,OAAQ,CAC1D,GAAIwY,EAAS,CACXtjB,EAAMqjB,EAAUC,EAAS5B,EAAMhgB,MAAM,GAAIggB,EAAMhgB,MAAM,GAAIhC,UACpD,CACL2jB,EAAS3B,EAAMhgB,MAAM,GAAIggB,EAAMhgB,MAAM,GAAIhC,UAKjDuI,GAAY6a,EAAeA,EAAc7Q,QAEzC,OAAO4Q,MAGT7a,IAAM,WACJ,GAAIub,GAAQ,QAASA,GAAMrc,GACzB,MAAOA,GAAIsc,eAAkBtc,GAAI6b,WAAa,YAEhD,IAAIU,GAAiB,QAASA,GAAevc,EAAKhF,GAChD,IAAKuG,EAAGQ,aAAa/B,KAASqc,EAAMrc,GAAM,CAExC,KAAM,IAAIR,WAAU,iBAAmBxE,EAAS,oCAAsCiB,OAAO+D,KAQjG,IAAIwc,GAAU,QAAS1b,KACrB,KAAMtI,eAAgBsI,IAAM,CAC1B,KAAM,IAAItB,WAAU,kCAEtB,GAAIhH,MAAQA,KAAK8jB,QAAS,CACxB,KAAM,IAAI9c,WAAU,oBAEtB,GAAIQ,GAAMkF,EAAoB1M,KAAMsI,EAAK2b,GACvCH,QAAS,KACTI,cAAe,KACfb,SAAUzB,MAEZ,KAAKpa,EAAIsc,QAAS,CAChB,KAAM,IAAI9c,WAAU,WAItB,GAAIrG,UAAUkI,OAAS,EAAG,CACxBuZ,GAAiB9Z,EAAKd,EAAK7G,UAAU,IAEvC,MAAO6G,GAET,IAAIyc,GAAgBD,EAAQ1iB,SAG5B,IAAI6iB,GAAY,QAASA,GAAU3c,GACjC,IAAKA,EAAI,eAAgB,CACvB,GAAI4c,GAAI5c,EAAI,eAAiB,GAAI+a,IAAgBC,GACjDphB,GAASH,OAAOsB,KAAKiF,EAAI6b,UAAW,SAAU9B,GAC5C,GAAIA,IAAM,QAAS,CACjBA,EAAI,SACC,IAAIA,IAAM,aAAc,CAC7BA,MAAS,OACJ,CACL,GAAIjS,GAAQiS,EAAE8C,OAAO,EACrB,IAAI/U,IAAU,IAAK,CACjBiS,EAAI9c,EAAU8c,EAAG,OACZ,IAAIjS,IAAU,IAAK,CACxBiS,GAAK9c,EAAU8c,EAAG,OACb,IAAIjS,IAAU,IAAK,CACxBiS,EAAIA,IAAM,YACL,CACLA,GAAKA,GAGT6C,EAAE5c,IAAI+Z,EAAGA,IAEX/Z,GAAI6b,SAAW,MAInBxgB,GAAMyD,OAAO0d,EAAQ1iB,UAAW,OAAQ,WACtCyiB,EAAe/jB,KAAM,OACrBmkB,GAAUnkB,KACV,OAAOA,MAAK,eAAeskB,MAG7BjiB,GAAiB2hB,EAAQ1iB,WACvBkiB,IAAK,QAASA,GAAI5gB,GAChBmhB,EAAe/jB,KAAM,MACrB,IAAIujB,EACJ,IAAIvjB,KAAKqjB,WAAaE,EAAO7B,GAAQ9e,MAAU,KAAM,CACnD,QAAS5C,KAAKqjB,SAASE,GAEzBY,EAAUnkB,KACV,OAAOA,MAAK,eAAewjB,IAAI5gB,IAGjC0f,IAAK,QAASA,GAAI1f,GAChBmhB,EAAe/jB,KAAM,MACrB,IAAIujB,EACJ,IAAIvjB,KAAKqjB,WAAaE,EAAO7B,GAAQ9e,MAAU,KAAM,CACnD5C,KAAKqjB,SAASE,GAAQ,IACtB,OAAOvjB,MAETmkB,EAAUnkB,KACVA,MAAK,eAAewH,IAAI5E,EAAKA,EAC7B,OAAO5C,OAGTyjB,SAAU,SAAU7gB,GAClBmhB,EAAe/jB,KAAM,SACrB,IAAIujB,EACJ,IAAIvjB,KAAKqjB,WAAaE,EAAO7B,GAAQ9e,MAAU,KAAM,CACnD,GAAI2hB,GAAU1e,EAAgB7F,KAAKqjB,SAAUE,EAC7C,cAAevjB,MAAKqjB,SAASE,IAAUgB,EAEzCJ,EAAUnkB,KACV,OAAOA,MAAK,eAAe,UAAU4C,IAGvC8gB,MAAO,QAASA,KACdK,EAAe/jB,KAAM,QACrB,IAAIA,KAAKqjB,SAAU,CACjBrjB,KAAKqjB,SAAWzB,SACX,CACL5hB,KAAK,eAAe0jB,UAIxBpR,OAAQ,QAASA,KACfyR,EAAe/jB,KAAM,SACrBmkB,GAAUnkB,KACV,OAAOA,MAAK,eAAesS,UAG7BC,QAAS,QAASA,KAChBwR,EAAe/jB,KAAM,UACrBmkB,GAAUnkB,KACV,OAAOA,MAAK,eAAeuS,WAG7BhR,QAAS,QAASA,GAAQoiB,GACxBI,EAAe/jB,KAAM,UACrB,IAAI4jB,GAAUjjB,UAAUkI,OAAS,EAAIlI,UAAU,GAAK,IACpD,IAAI6jB,GAAYxkB,IAChBmkB,GAAUK,EACVxkB,MAAK,eAAeuB,QAAQ,SAAUS,EAAOY,GAC3C,GAAIghB,EAAS,CACXtjB,EAAMqjB,EAAUC,EAAShhB,EAAKA,EAAK4hB,OAC9B,CACLb,EAAS/gB,EAAKA,EAAK4hB,QAK3BtjB,GAAe8iB,EAAQ1iB,UAAW,OAAQ0iB,EAAQ1iB,UAAUgR,OAAQ,KACpE/J,GAAYyb,EAAQ1iB,UAAW0iB,EAAQ1iB,UAAUgR,OAEjD,OAAO0R,MAGX3hB,GAAiByB,EAASye,GAE1B,IAAIze,EAAQ0e,KAAO1e,EAAQwE,IAAK,CAE9B,GAAImc,IAAsB3jB,EAAqB,WAAc,MAAO,IAAI0hB,OAAM,EAAG,KAAKvb,IAAI,KAAO,GACjG,KAAKwd,GAAqB,CACxB,GAAIC,IAAgB5gB,EAAQ0e,GAC5B1e,GAAQ0e,IAAM,QAASA,MACrB,KAAMxiB,eAAgBwiB,KAAM,CAC1B,KAAM,IAAIxb,WAAU,kCAEtB,GAAIod,GAAI,GAAIM,GACZ,IAAI/jB,UAAUkI,OAAS,EAAG,CACxBgZ,GAAiBW,GAAK4B,EAAGzjB,UAAU,IAErCM,OAAOiC,eAAekhB,EAAGtgB,EAAQ0e,IAAIlhB,UACrCJ,GAAekjB,EAAG,cAAe5B,GAAK,KACtC,OAAO4B,GAETtgB,GAAQ0e,IAAIlhB,UAAYmB,EAAOiiB,GAAcpjB,UAC7CuB,GAAMiF,iBAAiBhE,EAAQ0e,IAAKkC,IAEtC,GAAIC,IAAU,GAAInC,IAClB,IAAIoC,IAAwB,SAAUR,GACpCA,EAAE,UAAU,EACZA,GAAE,WAAW,EACbA,GAAE5c,IAAI,EAAG,EACT4c,GAAEnd,KAAK,EAAG,EACV,OAAOmd,GAAEnd,IAAI,KAAO,GAAKmd,EAAEnd,KAAK,KAAO,GACvC0d,GACF,IAAIE,IAAsBF,GAAQnd,IAAI,EAAG,KAAOmd,EAChD,KAAKC,KAAyBC,GAAqB,CACjD,GAAIC,IAAatC,IAAIlhB,UAAUkG,GAC/BS,GAAeua,IAAIlhB,UAAW,MAAO,QAASkG,IAAI+Z,EAAGpG,GACnD7a,EAAMwkB,GAAY9kB,KAAMuhB,IAAM,EAAI,EAAIA,EAAGpG,EACzC,OAAOnb,QAGX,IAAK4kB,GAAsB,CACzB,GAAIG,IAAavC,IAAIlhB,UAAU2F,GAC/B,IAAI+d,IAAaxC,IAAIlhB,UAAUkiB,GAC/BnhB,GAAiBmgB,IAAIlhB,WACnB2F,IAAK,QAASA,IAAIsa,GAChB,MAAOjhB,GAAMykB,GAAY/kB,KAAMuhB,IAAM,EAAI,EAAIA,IAE/CiC,IAAK,QAASA,IAAIjC,GAChB,MAAOjhB,GAAM0kB,GAAYhlB,KAAMuhB,IAAM,EAAI,EAAIA,KAE9C,KACH1e,GAAMiF,iBAAiB0a,IAAIlhB,UAAU2F,IAAK8d,GAC1CliB,GAAMiF,iBAAiB0a,IAAIlhB,UAAUkiB,IAAKwB,IAE5C,GAAIC,IAAU,GAAI3c,IAClB,IAAI4c,IAAwB,SAAU/W,GACpCA,EAAE,UAAU,EACZA,GAAEmU,KAAK,EACP,QAAQnU,EAAEqV,IAAI,IACdyB,GACF,IAAIE,IAAsBF,GAAQ3C,IAAI,KAAO2C,EAC7C,KAAKC,KAAyBC,GAAqB,CACjD,GAAIC,IAAa9c,IAAIhH,UAAUghB,GAC/Bha,KAAIhH,UAAUghB,IAAM,QAASA,IAAInH,GAC/B7a,EAAM8kB,GAAYplB,KAAMmb,IAAM,EAAI,EAAIA,EACtC,OAAOnb,MAET6C,GAAMiF,iBAAiBQ,IAAIhH,UAAUghB,IAAK8C,IAE5C,IAAKF,GAAsB,CACzB,GAAIG,IAAa/c,IAAIhH,UAAUkiB,GAC/Blb,KAAIhH,UAAUkiB,IAAM,QAASA,IAAIrI,GAC/B,MAAO7a,GAAM+kB,GAAYrlB,KAAMmb,IAAM,EAAI,EAAIA,GAE/CtY,GAAMiF,iBAAiBQ,IAAIhH,UAAUkiB,IAAK6B,GAC1C,IAAIC,IAAahd,IAAIhH,UAAU,SAC/BgH,KAAIhH,UAAU,UAAY,QAASikB,IAAUpK,GAC3C,MAAO7a,GAAMglB,GAAYtlB,KAAMmb,IAAM,EAAI,EAAIA,GAE/CtY,GAAMiF,iBAAiBQ,IAAIhH,UAAU,UAAWgkB,IAElD,GAAIE,IAAyBziB,EAAoBe,EAAQ0e,IAAK,SAAUiD,GACtE,GAAIrB,GAAI,GAAIqB,MAGZrB,GAAE5c,IAAI,GAAI,GACV,OAAO4c,aAAaqB,IAEtB,IAAIC,IAA+BzkB,OAAOiC,iBAAmBsiB,EAC7D,IAAIG,IAAkB,WACpB,IACE,QAAS7hB,EAAQ0e,eAAiB1e,GAAQ0e,KAC1C,MAAO3hB,GACP,MAAOA,aAAamG,cAGxB,IAAIlD,EAAQ0e,IAAI3Z,SAAW,GAAK6c,KAAiCC,GAAgB,CAC/E,GAAIC,IAAU9hB,EAAQ0e,GACtB1e,GAAQ0e,IAAM,QAASA,MACrB,KAAMxiB,eAAgBwiB,KAAM,CAC1B,KAAM,IAAIxb,WAAU,kCAEtB,GAAIod,GAAI,GAAIwB,GACZ,IAAIjlB,UAAUkI,OAAS,EAAG,CACxBgZ,GAAiBW,GAAK4B,EAAGzjB,UAAU,IAErCM,OAAOiC,eAAekhB,EAAG5B,GAAIlhB,UAC7BJ,GAAekjB,EAAG,cAAe5B,GAAK,KACtC,OAAO4B,GAETtgB,GAAQ0e,IAAIlhB,UAAYskB,GAAQtkB,SAChCuB,GAAMiF,iBAAiBhE,EAAQ0e,IAAKoD,IAEtC,GAAIC,IAAyB9iB,EAAoBe,EAAQwE,IAAK,SAAU2D,GACtE,GAAIkC,GAAI,GAAIlC,MACZkC,GAAEmU,IAAI,GAAI,GACV,OAAOnU,aAAalC,IAEtB,IAAI6Z,IAA+B7kB,OAAOiC,iBAAmB2iB,EAC7D,IAAIE,IAAkB,WACpB,IACE,QAASjiB,EAAQwE,eAAiBxE,GAAQwE,KAC1C,MAAOzH,GACP,MAAOA,aAAamG,cAGxB,IAAIlD,EAAQwE,IAAIO,SAAW,GAAKid,KAAiCC,GAAgB,CAC/E,GAAIC,IAAUliB,EAAQwE,GACtBxE,GAAQwE,IAAM,QAASA,MACrB,KAAMtI,eAAgBsI,KAAM,CAC1B,KAAM,IAAItB,WAAU,kCAEtB,GAAImH,GAAI,GAAI6X,GACZ,IAAIrlB,UAAUkI,OAAS,EAAG,CACxBuZ,GAAiB9Z,GAAK6F,EAAGxN,UAAU,IAErCM,OAAOiC,eAAeiL,EAAG7F,GAAIhH,UAC7BJ,GAAeiN,EAAG,cAAe7F,GAAK,KACtC,OAAO6F,GAETrK,GAAQwE,IAAIhH,UAAY0kB,GAAQ1kB,SAChCuB,GAAMiF,iBAAiBhE,EAAQwE,IAAK0d,IAEtC,GAAIC,KAAkCnlB,EAAqB,WACzD,OAAO,GAAK0hB,MAAOjgB,OAAO6I,OAAOE,MASnC,UACSxH,GAAQ0e,IAAIlhB,UAAUoiB,QAAU,aACvC,GAAI5f,GAAQwE,KAAMgc,OAAS,IAC3B,GAAIxgB,GAAQ0e,KAAM8B,OAAS,SACpBxgB,GAAQ0e,IAAIlhB,UAAUiB,OAAS,kBAC/BuB,GAAQwE,IAAIhH,UAAUiB,OAAS,kBAC/BuB,GAAQ0e,IAAIlhB,UAAUC,UAAY,kBAClCuC,GAAQwE,IAAIhH,UAAUC,UAAY,YACzCR,EAAqB+C,EAAQ0e,MAC7BzhB,EAAqB+C,EAAQwE,aACrB,GAAIxE,GAAQ0e,KAAMjgB,OAAW,OAAM,YAC3C0jB,KACCT,GACD,OACO1hB,GAAQ0e,UACR1e,GAAQwE,GACfjG,GAAiByB,GACf0e,IAAKD,GAAgBC,IACrBla,IAAKia,GAAgBja,KACpB,OAGP,GAAIxE,EAAQwE,IAAIhH,UAAUiB,OAASuB,EAAQwE,IAAIhH,UAAUgR,OAAQ,CAE/DpR,EAAe4C,EAAQwE,IAAIhH,UAAW,OAAQwC,EAAQwE,IAAIhH,UAAUgR,OAAQ,MAG9E/J,EAAYtH,OAAOyR,gBAAe,GAAK5O,GAAQ0e,KAAOjgB,QACtDgG,GAAYtH,OAAOyR,gBAAe,GAAK5O,GAAQwE,KAAO/F,SAExD8D,EAAkBmc,IAClBnc,GAAkBiC,IAGlB,KAAKxE,EAAQ4H,QAAS,CACpBxK,EAAe4C,EAAS,cAE1B,GAAI4H,IAAU5H,EAAQ4H,OAEtB,IAAIwa,IAA4B,QAASA,IAA0Bne,GACjE,IAAKgB,EAAGQ,aAAaxB,GAAS,CAC5B,KAAM,IAAIf,WAAU,6BAQxB3E,GAAiByB,EAAQ4H,SAEvBrL,MAAO,QAASA,MACd,MAAOJ,GAAO8I,EAAGC,KAAM,KAAMrI,YAI/BgL,UAAW,QAASA,IAAUpI,EAAa4F,GACzC,IAAKJ,EAAGU,cAAclG,GAAc,CAClC,KAAM,IAAIyD,WAAU,yCAEtB,GAAIwE,GAAa7K,UAAUkI,OAAS,EAAKtF,EAAc5C,UAAU,EACjE,KAAKoI,EAAGU,cAAc+B,GAAY,CAChC,KAAM,IAAIxE,WAAU,qCAEtB,MAAO+B,GAAGwC,UAAUhI,EAAa4F,EAAMqC,EAAW,aAOpD2a,eAAgB,QAASA,IAAepe,EAAQnF,GAC9CsjB,GAA0Bne,EAC1B,IAAI5G,EAAqB,CACvB,GAAIilB,GAAOnlB,OAAOqG,yBAAyBS,EAAQnF,EAEnD,IAAIwjB,IAASA,EAAKlkB,aAAc,CAC9B,MAAO,QAKX,aAAc6F,GAAOnF,IAGvByjB,UAAW,QAASA,IAAUte,GAC5Bme,GAA0Bne,EAC1B,OAAO,IAAImJ,IAAenJ,EAAQ,QAGpCyb,IAAK,QAASA,IAAIzb,EAAQnF,GACxBsjB,GAA0Bne,EAC1B,OAAOnF,KAAOmF,KAIlB,IAAI9G,OAAO4U,oBAAqB,CAC9BxT,EAAiByB,EAAQ4H,SAMvB4a,QAAS,QAASA,IAAQve,GACxBme,GAA0Bne,EAC1B,IAAIxF,GAAOtB,OAAO4U,oBAAoB9N,EAEtC,IAAIgB,EAAGK,WAAWnI,OAAO4T,uBAAwB,CAC/ChQ,EAAWtC,EAAMtB,OAAO4T,sBAAsB9M,IAGhD,MAAOxF,MAKb,GAAIgkB,IAAwB,QAASC,IAA0B/lB,GAC7D,OAAQG,EAAYH,GAGtB,IAAIQ,OAAOiU,kBAAmB,CAC5B7S,EAAiByB,EAAQ4H,SACvByL,aAAc,QAASA,IAAapP,GAClCme,GAA0Bne,EAC1B,OAAO9G,QAAOkW,aAAapP,IAE7BmN,kBAAmB,QAASA,IAAkBnN,GAC5Cme,GAA0Bne,EAC1B,OAAOwe,IAAsB,WAC3BtlB,OAAOiU,kBAAkBnN,QAMjC,GAAI5G,EAAqB,CACvB,GAAIslB,IAAc,QAASxf,IAAIc,EAAQnF,EAAK8jB,GAC1C,GAAIN,GAAOnlB,OAAOqG,yBAAyBS,EAAQnF,EAEnD,KAAKwjB,EAAM,CACT,GAAIO,GAAS1lB,OAAOyR,eAAe3K,EAEnC,IAAI4e,IAAW,KAAM,CACnB,MAAOhW,WAGT,MAAO8V,IAAYE,EAAQ/jB,EAAK8jB,GAGlC,GAAI,SAAWN,GAAM,CACnB,MAAOA,GAAKpkB,MAGd,GAAIokB,EAAKnf,IAAK,CACZ,MAAO3G,GAAM8lB,EAAKnf,IAAKyf,GAGzB,MAAO/V,WAGT,IAAIiW,IAAc,QAASpf,IAAIO,EAAQnF,EAAKZ,EAAO0kB,GACjD,GAAIN,GAAOnlB,OAAOqG,yBAAyBS,EAAQnF,EAEnD,KAAKwjB,EAAM,CACT,GAAIO,GAAS1lB,OAAOyR,eAAe3K,EAEnC,IAAI4e,IAAW,KAAM,CACnB,MAAOC,IAAYD,EAAQ/jB,EAAKZ,EAAO0kB,GAGzCN,GACEpkB,UAAY,GACZI,SAAU,KACVD,WAAY,KACZD,aAAc,MAIlB,GAAI,SAAWkkB,GAAM,CACnB,IAAKA,EAAKhkB,SAAU,CAClB,MAAO,OAGT,IAAK2G,EAAGQ,aAAamd,GAAW,CAC9B,MAAO,OAGT,GAAIG,GAAe5lB,OAAOqG,yBAAyBof,EAAU9jB,EAE7D,IAAIikB,EAAc,CAChB,MAAOnb,IAAQxK,eAAewlB,EAAU9jB,GACtCZ,MAAOA,QAEJ,CACL,MAAO0J,IAAQxK,eAAewlB,EAAU9jB,GACtCZ,MAAOA,EACPI,SAAU,KACVD,WAAY,KACZD,aAAc,QAKpB,GAAIkkB,EAAK5e,IAAK,CACZlH,EAAM8lB,EAAK5e,IAAKkf,EAAU1kB,EAC1B,OAAO,MAGT,MAAO,OAGTK,GAAiByB,EAAQ4H,SACvBxK,eAAgB,QAASA,IAAe6G,EAAQ+e,EAAaC,GAC3Db,GAA0Bne,EAC1B,OAAOwe,IAAsB,WAC3BtlB,OAAOC,eAAe6G,EAAQ+e,EAAaC,MAI/Czf,yBAA0B,QAASA,IAAyBS,EAAQ+e,GAClEZ,GAA0Bne,EAC1B,OAAO9G,QAAOqG,yBAAyBS,EAAQ+e,IAIjD7f,IAAK,QAASA,IAAIc,EAAQnF,GACxBsjB,GAA0Bne,EAC1B,IAAI2e,GAAW/lB,UAAUkI,OAAS,EAAIlI,UAAU,GAAKoH,CAErD,OAAO0e,IAAY1e,EAAQnF,EAAK8jB,IAGlClf,IAAK,QAASA,IAAIO,EAAQnF,EAAKZ,GAC7BkkB,GAA0Bne,EAC1B,IAAI2e,GAAW/lB,UAAUkI,OAAS,EAAIlI,UAAU,GAAKoH,CAErD,OAAO6e,IAAY7e,EAAQnF,EAAKZ,EAAO0kB,MAK7C,GAAIzlB,OAAOyR,eAAgB,CACzB,GAAIsU,IAA0B/lB,OAAOyR,cACrCrQ,GAAiByB,EAAQ4H,SACvBgH,eAAgB,QAASA,IAAe3K,GACtCme,GAA0Bne,EAC1B,OAAOif,IAAwBjf,MAKrC,GAAI9G,OAAOiC,eAAgB,CACzB,GAAI+jB,IAA8B,SAAUnlB,EAAQ8J,GAClD,MAAOA,EAAO,CACZ,GAAI9J,IAAW8J,EAAO,CACpB,MAAO,MAETA,EAAQF,GAAQgH,eAAe9G,GAEjC,MAAO,OAGTvJ,GAAiByB,EAAQ4H,SAGvBxI,eAAgB,QAASA,IAAepB,EAAQ8J,GAC9Csa,GAA0BpkB,EAC1B,IAAI8J,IAAU,OAAS7C,EAAGQ,aAAaqC,GAAQ,CAC7C,KAAM,IAAI5E,WAAU,mCAItB,GAAI4E,IAAUF,GAAQgH,eAAe5Q,GAAS,CAC5C,MAAO,MAIT,GAAI4J,GAAQyL,eAAiBzL,GAAQyL,aAAarV,GAAS,CACzD,MAAO,OAIT,GAAImlB,GAA4BnlB,EAAQ8J,GAAQ,CAC9C,MAAO,OAGT3K,OAAOiC,eAAepB,EAAQ8J,EAE9B,OAAO,SAKb,GAAInI,OAAO,GAAIyjB,MAAK7N,QAAU,eAAgB,CAC5C,GAAI8N,IAAeD,KAAK5lB,UAAUgD,QAClC,IAAI8iB,IAAsB,QAAS9iB,MACjC,GAAI+iB,IAAWrnB,IACf,IAAIqnB,IAAYA,EAAS,CACvB,MAAO,eAET,MAAO/mB,GAAM6mB,GAAcnnB,MAE7BiI,GAAeif,KAAK5lB,UAAW,WAAY8lB,IAK7C,GAAIE,KACFC,OAAQ,QAASA,IAAOxlB,GAAQ,MAAOgH,GAAGmD,WAAWlM,KAAM,IAAK,OAAQ+B,IACxEylB,IAAK,QAASA,MAAQ,MAAOze,GAAGmD,WAAWlM,KAAM,MAAO,GAAI,KAC5DynB,MAAO,QAASA,MAAU,MAAO1e,GAAGmD,WAAWlM,KAAM,QAAS,GAAI,KAClE0nB,KAAM,QAASA,MAAS,MAAO3e,GAAGmD,WAAWlM,KAAM,IAAK,GAAI,KAC5D2nB,MAAO,QAASA,MAAU,MAAO5e,GAAGmD,WAAWlM,KAAM,KAAM,GAAI,KAC/D4nB,UAAW,QAASA,IAAUC,GAAS,MAAO9e,GAAGmD,WAAWlM,KAAM,OAAQ,QAAS6nB,IACnFC,SAAU,QAASA,IAASxD,GAAQ,MAAOvb,GAAGmD,WAAWlM,KAAM,OAAQ,OAAQskB,IAC/EyD,QAAS,QAASA,MAAY,MAAOhf,GAAGmD,WAAWlM,KAAM,IAAK,GAAI,KAClEgoB,KAAM,QAASA,IAAKC,GAAO,MAAOlf,GAAGmD,WAAWlM,KAAM,IAAK,OAAQioB,IACnEC,MAAO,QAASA,MAAU,MAAOnf,GAAGmD,WAAWlM,KAAM,QAAS,GAAI,KAClEmoB,OAAQ,QAASA,MAAW,MAAOpf,GAAGmD,WAAWlM,KAAM,SAAU,GAAI,KACrEooB,IAAK,QAASA,MAAQ,MAAOrf,GAAGmD,WAAWlM,KAAM,MAAO,GAAI,KAC5DqoB,IAAK,QAASD,MAAQ,MAAOrf,GAAGmD,WAAWlM,KAAM,MAAO,GAAI,KAE9DoB,GAASH,OAAOsB,KAAK+kB,IAAkB,SAAU1kB,GAC/C,GAAIJ,GAASiB,OAAOnC,UAAUsB,EAC9B,IAAI0lB,GAAkB,KACtB,IAAIvf,EAAGK,WAAW5G,GAAS,CACzB,GAAI+lB,GAASjoB,EAAMkC,EAAQ,GAAI,MAC/B,IAAIgmB,GAAcjkB,KAAYgkB,EAAOE,MAAM,OAAO5f,MAClDyf,GAAkBC,IAAWA,EAAOG,eAAiBF,EAAc,MAC9D,CACLF,EAAkB,KAEpB,GAAIA,EAAiB,CACnBpnB,EAAeuC,OAAOnC,UAAWsB,EAAK0kB,GAAgB1kB,GAAM,QAIhE,OAAOkB"} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.min.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.min.js new file mode 100644 index 0000000..3447878 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/es6-shim.min.js @@ -0,0 +1,12 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-shim: v0.32.2 + * see https://github.com/paulmillr/es6-shim/blob/0.32.2/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ +(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=function pr(t){return function r(){return!e(t,this,arguments)}};var n=function(e){try{e();return false}catch(t){return true}};var o=function lr(e){try{return e()}catch(t){return false}};var i=r(n);var a=function(){return!n(function(){Object.defineProperty({},"x",{})})};var u=!!Object.defineProperty&&a();var s=Function.call.bind(Array.prototype.forEach);var f=Function.call.bind(Array.prototype.reduce);var c=Function.call.bind(Array.prototype.filter);var p=Function.call.bind(Array.prototype.every);var l=function(e,t,r,n){if(!n&&t in e){return}if(u){Object.defineProperty(e,t,{configurable:true,enumerable:false,writable:true,value:r})}else{e[t]=r}};var v=function(e,t){s(Object.keys(t),function(r){var n=t[r];l(e,r,n,false)})};var h=Object.create||function(e,t){var r=function o(){};r.prototype=e;var n=new r;if(typeof t!=="undefined"){Object.keys(t).forEach(function(e){$.defineByDescriptor(n,e,t[e])})}return n};var y=function(e,t){if(!Object.setPrototypeOf){return false}return o(function(){var r=function n(t){var r=new e(t);Object.setPrototypeOf(r,n.prototype);return r};Object.setPrototypeOf(r,e);r.prototype=h(e.prototype,{constructor:{value:r}});return t(r)})};var b=function(){return String.prototype.startsWith&&n(function(){"/a/".startsWith(/a/)})};var g=function(){return String.prototype.startsWith&&"abc".startsWith("a",Infinity)===false}();var d=new Function("return this;");var m=d();var w=m.isFinite;var O=function(){return this===null}.call(null);var j=b()&&g;var T=Function.call.bind(String.prototype.indexOf);var S=Function.call.bind(Object.prototype.toString);var I=Function.call.bind(Array.prototype.concat);var E=Function.call.bind(String.prototype.slice);var M=Function.call.bind(Array.prototype.push);var x=Function.apply.bind(Array.prototype.push);var P=Function.call.bind(Array.prototype.shift);var C=Math.max;var N=Math.min;var A=Math.floor;var _=Math.abs;var k=Math.log;var R=Math.sqrt;var F=Function.call.bind(Object.prototype.hasOwnProperty);var L;var D=function(){};var z=m.Symbol||{};var q=z.species||"@@species";var G=function(){return this};var H=function(e){if(u&&!F(e,q)){$.getter(e,q,G)}};var W={object:function(e){return e!==null&&typeof e==="object"},string:function(e){return S(e)==="[object String]"},regex:function(e){return S(e)==="[object RegExp]"},symbol:function(e){return typeof m.Symbol==="function"&&typeof e==="symbol"}};var B=Number.isNaN||function vr(e){return e!==e};var V=Number.isFinite||function hr(e){return typeof e==="number"&&w(e)};var $={getter:function(e,t,r){if(!u){throw new TypeError("getters require true ES5 support")}Object.defineProperty(e,t,{configurable:true,enumerable:false,get:r})},proxy:function(e,t,r){if(!u){throw new TypeError("getters require true ES5 support")}var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,{configurable:n.configurable,enumerable:n.enumerable,get:function o(){return e[t]},set:function i(r){e[t]=r}})},redefine:function(e,t,r){if(u){var n=Object.getOwnPropertyDescriptor(e,t);n.value=r;Object.defineProperty(e,t,n)}else{e[t]=r}},defineByDescriptor:function(e,t,r){if(u){Object.defineProperty(e,t,r)}else if("value"in r){e[t]=r.value}},preserveToString:function(e,t){l(e,"toString",t.toString.bind(t),true)}};var U=function yr(e,t,r){var n=e[t];l(e,t,r,true);$.preserveToString(e[t],n)};var X=W.symbol(z.iterator)?z.iterator:"_es6-shim iterator_";if(m.Set&&typeof(new m.Set)["@@iterator"]==="function"){X="@@iterator"}var Z=function(e,t){var r=t||function o(){return this};var n={};n[X]=r;v(e,n);if(!e[X]&&W.symbol(X)){e[X]=r}};var K=function br(e){var t=S(e);var r=t==="[object Arguments]";if(!r){r=t!=="[object Array]"&&e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&S(e.callee)==="[object Function]"}return r};var J={Call:function gr(t,r){var n=arguments.length>2?arguments[2]:[];if(!J.IsCallable(t)){throw new TypeError(t+" is not a function")}return e(t,r,n)},RequireObjectCoercible:function(e,t){if(e==null){throw new TypeError(t||"Cannot call method on "+e)}},TypeIsObject:function(e){return e!=null&&Object(e)===e},ToObject:function(e,t){J.RequireObjectCoercible(e,t);return Object(e)},IsCallable:function(e){return typeof e==="function"&&S(e)==="[object Function]"},IsConstructor:function(e){return J.IsCallable(e)},ToInt32:function(e){return J.ToNumber(e)>>0},ToUint32:function(e){return J.ToNumber(e)>>>0},ToNumber:function(e){if(S(e)==="[object Symbol]"){throw new TypeError("Cannot convert a Symbol value to a number")}return+e},ToInteger:function(e){var t=J.ToNumber(e);if(B(t)){return 0}if(t===0||!V(t)){return t}return(t>0?1:-1)*A(_(t))},ToLength:function(e){var t=J.ToInteger(e);if(t<=0){return 0}if(t>Number.MAX_SAFE_INTEGER){return Number.MAX_SAFE_INTEGER}return t},SameValue:function(e,t){if(e===t){if(e===0){return 1/e===1/t}return true}return B(e)&&B(t)},SameValueZero:function(e,t){return e===t||B(e)&&B(t)},IsIterable:function(e){return J.TypeIsObject(e)&&(typeof e[X]!=="undefined"||K(e))},GetIterator:function(e){if(K(e)){return new L(e,"value")}var r=J.GetMethod(e,X);if(!J.IsCallable(r)){throw new TypeError("value is not an iterable")}var n=t(r,e);if(!J.TypeIsObject(n)){throw new TypeError("bad iterator")}return n},GetMethod:function(e,t){var r=J.ToObject(e)[t];if(r===void 0||r===null){return void 0}if(!J.IsCallable(r)){throw new TypeError("Method not callable: "+t)}return r},IteratorComplete:function(e){return!!e.done},IteratorClose:function(e,r){var n=J.GetMethod(e,"return");if(n===void 0){return}var o,i;try{o=t(n,e)}catch(a){i=a}if(r){return}if(i){throw i}if(!J.TypeIsObject(o)){throw new TypeError("Iterator's return method returned a non-object.")}},IteratorNext:function(e){var t=arguments.length>1?e.next(arguments[1]):e.next();if(!J.TypeIsObject(t)){throw new TypeError("bad iterator")}return t},IteratorStep:function(e){var t=J.IteratorNext(e);var r=J.IteratorComplete(t);return r?false:t},Construct:function(e,t,r,n){if(r===void 0){r=e}if(!n){return tr.construct(e,t,r)}var o=r.prototype;if(!J.TypeIsObject(o)){o=Object.prototype}var i=h(o);var a=J.Call(e,i,t);return J.TypeIsObject(a)?a:i},SpeciesConstructor:function(e,t){var r=e.constructor;if(r===void 0){return t}if(!J.TypeIsObject(r)){throw new TypeError("Bad constructor")}var n=r[q];if(n===void 0||n===null){return t}if(!J.IsConstructor(n)){throw new TypeError("Bad @@species")}return n},CreateHTML:function(e,t,r,n){var o=String(e);var i="<"+t;if(r!==""){var a=String(n);var u=a.replace(/"/g,""");i+=" "+r+'="'+u+'"'}var s=i+">";var f=s+o;return f+""+t+">"}};var Q=function(e,t,r,n){if(!J.TypeIsObject(e)){throw new TypeError("Constructor requires `new`: "+t.name)}var o=t.prototype;if(!J.TypeIsObject(o)){o=r}e=h(o);for(var i in n){if(F(n,i)){var a=n[i];l(e,i,a,true)}}return e};if(String.fromCodePoint&&String.fromCodePoint.length!==1){var Y=String.fromCodePoint;U(String,"fromCodePoint",function dr(t){return e(Y,this,arguments)})}var ee={fromCodePoint:function mr(e){var t=[];var r;for(var n=0,o=arguments.length;n1114111){throw new RangeError("Invalid code point "+r)}if(r<65536){M(t,String.fromCharCode(r))}else{r-=65536;M(t,String.fromCharCode((r>>10)+55296));M(t,String.fromCharCode(r%1024+56320))}}return t.join("")},raw:function wr(e){var t=J.ToObject(e,"bad callSite");var r=J.ToObject(t.raw,"bad raw value");var n=r.length;var o=J.ToLength(n);if(o<=0){return""}var i=[];var a=0;var u,s,f,c;while(a=o){break}s=a+1=re){throw new RangeError("repeat count must be less than infinity and not overflow maximum string size")}return te(t,r)},startsWith:function Tr(e){J.RequireObjectCoercible(this);var t=String(this);if(W.regex(e)){throw new TypeError('Cannot call method "startsWith" with a regex')}var r=String(e);var n=arguments.length>1?arguments[1]:void 0;var o=C(J.ToInteger(n),0);return E(t,o,o+r.length)===r},endsWith:function Sr(e){J.RequireObjectCoercible(this);var t=String(this);if(W.regex(e)){throw new TypeError('Cannot call method "endsWith" with a regex')}var r=String(e);var n=t.length;var o=arguments.length>1?arguments[1]:void 0;var i=typeof o==="undefined"?n:J.ToInteger(o);var a=N(C(i,0),n);return E(t,a-r.length,a)===r},includes:function Ir(e){if(W.regex(e)){throw new TypeError('"includes" does not accept a RegExp')}var t;if(arguments.length>1){t=arguments[1]}return T(this,e,t)!==-1},codePointAt:function Er(e){J.RequireObjectCoercible(this);var t=String(this);var r=J.ToInteger(e);var n=t.length;if(r>=0&&r56319||i){return o}var a=t.charCodeAt(r+1);if(a<56320||a>57343){return o}return(o-55296)*1024+(a-56320)+65536}}};v(String.prototype,ne);if("a".includes("a",Infinity)!==false){U(String.prototype,"includes",ne.includes)}var oe="\x85".trim().length!==1;if(oe){delete String.prototype.trim;var ie=[" \n\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003","\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028","\u2029\ufeff"].join("");var ae=new RegExp("(^["+ie+"]+)|(["+ie+"]+$)","g");v(String.prototype,{trim:function Mr(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return String(this).replace(ae,"")}})}var ue=function(e){J.RequireObjectCoercible(e);this._s=String(e);this._i=0};ue.prototype.next=function(){var e=this._s,t=this._i;if(typeof e==="undefined"||t>=e.length){this._s=void 0;return{value:void 0,done:true}}var r=e.charCodeAt(t),n,o;if(r<55296||r>56319||t+1===e.length){o=1}else{n=e.charCodeAt(t+1);o=n<56320||n>57343?1:2}this._i=t+o;return{value:e.substr(t,o),done:false}};Z(ue.prototype);Z(String.prototype,function(){return new ue(this)});if(!j){U(String.prototype,"startsWith",ne.startsWith);U(String.prototype,"endsWith",ne.endsWith)}var se={from:function xr(e){var r=this;var n=arguments.length>1?arguments[1]:void 0;var o,i;if(n===void 0){o=false}else{if(!J.IsCallable(n)){throw new TypeError("Array.from: when provided, the second argument must be a function")}i=arguments.length>2?arguments[2]:void 0;o=true}var a=K(e)||J.GetMethod(e,X);var u,s,f;if(a!==void 0){s=J.IsConstructor(r)?Object(new r):[];var c=J.GetIterator(e);var p,l;for(f=0;;++f){p=J.IteratorStep(c);if(p===false){break}l=p.value;try{if(o){l=i!==undefined?t(n,i,l,f):n(l,f)}s[f]=l}catch(v){J.IteratorClose(c,true);throw v}}u=f}else{var h=J.ToObject(e);u=J.ToLength(h.length);s=J.IsConstructor(r)?Object(new r(u)):new Array(u);var y;for(f=0;f0){e=P(t);if(!(e in this.object)){continue}if(this.kind==="key"){return fe(e)}else if(this.kind==="value"){return fe(this.object[e])}else{return fe([e,this.object[e]])}}return fe()}});Z(ce.prototype);var le=function(){var e=function r(e){this.length=e};e.prototype=[];var t=Array.of.apply(e,[1,2]);return t instanceof e&&t.length===2}();if(!le){U(Array,"of",se.of)}var ve={copyWithin:function Nr(e,t){var r=arguments[2];var n=J.ToObject(this);var o=J.ToLength(n.length);var i=J.ToInteger(e);var a=J.ToInteger(t);var u=i<0?C(o+i,0):N(i,o);var s=a<0?C(o+a,0):N(a,o);r=typeof r==="undefined"?o:J.ToInteger(r);var f=r<0?C(o+r,0):N(r,o);var c=N(f-s,o-u);var p=1;if(s0){if(F(n,s)){n[u]=n[s]}else{delete n[s]}s+=p;u+=p;c-=1}return n},fill:function Ar(e){var t=arguments.length>1?arguments[1]:void 0;var r=arguments.length>2?arguments[2]:void 0;var n=J.ToObject(this);var o=J.ToLength(n.length);t=J.ToInteger(typeof t==="undefined"?0:t);r=J.ToInteger(typeof r==="undefined"?o:r);var i=t<0?C(o+t,0):N(t,o);var a=r<0?o+r:r;for(var u=i;u1?arguments[1]:null;for(var i=0,a;i1?arguments[1]:null;for(var i=0;i>>0)-1:0]=true;return o(function(){t(e,n,function(){throw new RangeError("should not reach here")},[])})};if(!ge(Array.prototype.forEach)){var de=Array.prototype.forEach;U(Array.prototype,"forEach",function zr(t){return e(de,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.map)){var me=Array.prototype.map;U(Array.prototype,"map",function qr(t){return e(me,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.filter)){var we=Array.prototype.filter;U(Array.prototype,"filter",function Gr(t){return e(we,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.some)){var Oe=Array.prototype.some;U(Array.prototype,"some",function Hr(t){return e(Oe,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.every)){var je=Array.prototype.every;U(Array.prototype,"every",function Wr(t){return e(je,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.reduce)){var Te=Array.prototype.reduce;U(Array.prototype,"reduce",function Br(t){return e(Te,this.length>=0?this:[],arguments)},true)}if(!ge(Array.prototype.reduceRight,true)){var Se=Array.prototype.reduceRight;U(Array.prototype,"reduceRight",function Vr(t){return e(Se,this.length>=0?this:[],arguments)},true)}var Ie=Math.pow(2,53)-1;v(Number,{MAX_SAFE_INTEGER:Ie,MIN_SAFE_INTEGER:-Ie,EPSILON:2.220446049250313e-16,parseInt:m.parseInt,parseFloat:m.parseFloat,isFinite:V,isInteger:function $r(e){return V(e)&&J.ToInteger(e)===e},isSafeInteger:function Ur(e){return Number.isInteger(e)&&_(e)<=Number.MAX_SAFE_INTEGER},isNaN:B});l(Number,"parseInt",m.parseInt,Number.parseInt!==m.parseInt);if(![,1].find(function(e,t){return t===0})){U(Array.prototype,"find",ve.find)}if([,1].findIndex(function(e,t){return t===0})!==0){U(Array.prototype,"findIndex",ve.findIndex)}var Ee=Function.bind.call(Function.bind,Object.prototype.propertyIsEnumerable);var Me=function Xr(){var e=Number(this);var t=arguments.length;var r=t-e;var n=new Array(r<0?0:r);for(var o=e;o1){return NaN}if(t===-1){return-Infinity}if(t===1){return Infinity}if(t===0){return t}return.5*k((1+t)/(1-t))},cbrt:function hn(e){var t=Number(e);if(t===0){return t}var r=t<0,n;if(r){t=-t}if(t===Infinity){n=Infinity}else{n=Math.exp(k(t)/3);n=(t/(n*n)+2*n)/3}return r?-n:n},clz32:function yn(e){var r=Number(e);var n=J.ToUint32(r);if(n===0){return 32}return ct?t(ct,n):31-A(k(n+.5)*Math.LOG2E)},cosh:function bn(e){var t=Number(e);if(t===0){return 1}if(Number.isNaN(t)){return NaN}if(!w(t)){return Infinity}if(t<0){t=-t}if(t>21){return Math.exp(t)/2}return(Math.exp(t)+Math.exp(-t))/2},expm1:function gn(e){var t=Number(e);if(t===-Infinity){return-1}if(!w(t)||t===0){return t}if(_(t)>.5){return Math.exp(t)-1}var r=t;var n=0;var o=1;while(n+r!==n){n+=r;o+=1;r*=t/o}return n},hypot:function dn(e,t){var r=0;var n=0;for(var o=0;o0?i/n*(i/n):i}}return n===Infinity?Infinity:n*R(r)},log2:function mn(e){return k(e)*Math.LOG2E},log10:function wn(e){return k(e)*Math.LOG10E},log1p:function On(e){var t=Number(e);if(t<-1||Number.isNaN(t)){return NaN}if(t===0||t===Infinity){return t}if(t===-1){return-Infinity}return 1+t-1===0?t:t*(k(1+t)/(1+t-1))},sign:function jn(e){var t=Number(e);if(t===0){return t}if(Number.isNaN(t)){return t}return t<0?-1:1},sinh:function Tn(e){var t=Number(e);if(!w(t)||t===0){return t}if(_(t)<1){return(Math.expm1(t)-Math.expm1(-t))/2}return(Math.exp(t-1)-Math.exp(-t-1))*Math.E/2},tanh:function Sn(e){var t=Number(e);if(Number.isNaN(t)||t===0){return t}if(t===Infinity){return 1}if(t===-Infinity){return-1}var r=Math.expm1(t);var n=Math.expm1(-t);if(r===Infinity){return 1}if(n===Infinity){return-1}return(r-n)/(Math.exp(t)+Math.exp(-t))},trunc:function In(e){var t=Number(e);return t<0?-A(-t):A(t)},imul:function En(e,t){var r=J.ToUint32(e);var n=J.ToUint32(t);var o=r>>>16&65535;var i=r&65535;var a=n>>>16&65535;var u=n&65535;return i*u+(o*u+i*a<<16>>>0)|0},fround:function Mn(e){var t=Number(e);if(t===0||t===Infinity||t===-Infinity||B(t)){return t}var r=Math.sign(t);var n=_(t);if(nst||B(i)){return r*Infinity}return r*i}};v(Math,pt);l(Math,"log1p",pt.log1p,Math.log1p(-1e-17)!==-1e-17);l(Math,"asinh",pt.asinh,Math.asinh(-1e7)!==-Math.asinh(1e7));l(Math,"tanh",pt.tanh,Math.tanh(-2e-17)!==-2e-17);l(Math,"acosh",pt.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);l(Math,"cbrt",pt.cbrt,Math.abs(1-Math.cbrt(1e-300)/1e-100)/Number.EPSILON>8);l(Math,"sinh",pt.sinh,Math.sinh(-2e-17)!==-2e-17);var lt=Math.expm1(10);l(Math,"expm1",pt.expm1,lt>22025.465794806718||lt<22025.465794806718);var vt=Math.round;var ht=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var yt=it+1;var bt=2*it-1;var gt=[yt,bt].every(function(e){return Math.round(e)===e});l(Math,"round",function xn(e){var t=A(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!ht||!gt);$.preserveToString(Math.round,vt);var dt=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=pt.imul;$.preserveToString(Math.imul,dt)}if(Math.imul.length!==2){U(Math,"imul",function Pn(t,r){return e(dt,Math,arguments)})}var mt=function(){J.IsPromise=function(e){if(!J.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var e=function(e){if(!J.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.promise=new e(r);if(!(J.IsCallable(t.resolve)&&J.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var r=m.setTimeout;var n;if(typeof window!=="undefined"&&J.IsCallable(window.postMessage)){n=function(){var e=[];var t="zero-timeout-message";var r=function(r){M(e,r);window.postMessage(t,"*")};var n=function(r){if(r.source===window&&r.data===t){r.stopPropagation();if(e.length===0){return}var n=P(e);n()}};window.addEventListener("message",n,true);return r}}var o=function(){var e=m.Promise;return e&&e.resolve&&function(t){return e.resolve().then(t)}};var i=J.IsCallable(m.setImmediate)?m.setImmediate.bind(m):typeof process==="object"&&process.nextTick?process.nextTick:o()||(J.IsCallable(n)?n():function(e){r(e,0)});var a=1;var u=2;var f=3;var c=4;var p=5;var l=function(e,t){var r=e.capabilities;var n=e.handler;var o,i=false,s;if(n===a){o=t}else if(n===u){o=t;i=true}else{try{o=n(t)}catch(f){o=f;i=true}}s=i?r.reject:r.resolve;s(o)};var h=function(e,t){s(e,function(e){i(function(){l(e,t)})})};var y=function(e,t){var r=e._promise;var n=r.fulfillReactions;r.result=t;r.fulfillReactions=void 0;r.rejectReactions=void 0;r.state=c;h(n,t)};var b=function(e,t){var r=e._promise;var n=r.rejectReactions;r.result=t;r.fulfillReactions=void 0;r.rejectReactions=void 0;r.state=p;h(n,t)};var g=function(e){var t=false;var r=function(r){var n;if(t){return}t=true;if(r===e){return b(e,new TypeError("Self resolution"))}if(!J.TypeIsObject(r)){return y(e,r)}try{n=r.then}catch(o){return b(e,o)}if(!J.IsCallable(n)){return y(e,r)}i(function(){d(e,r,n)})};var n=function(r){if(t){return}t=true;return b(e,r)};return{resolve:r,reject:n}};var d=function(e,r,n){var o=g(e);var i=o.resolve;var a=o.reject;try{t(n,r,i,a)}catch(u){a(u)}};var w=function(e){if(!J.TypeIsObject(e)){throw new TypeError("Promise is not object")}var t=e[q];if(t!==void 0&&t!==null){return t}return e};var O=function E(e){if(!(this instanceof E)){throw new TypeError('Constructor Promise requires "new"')}if(this&&this._promise){throw new TypeError("Bad construction")}if(!J.IsCallable(e)){throw new TypeError("not a valid resolver")}var t=Q(this,E,j,{_promise:{result:void 0,state:f,fulfillReactions:[],rejectReactions:[]}});var r=g(t);var n=r.reject;try{e(r.resolve,n)}catch(o){n(o)}return t};var j=O.prototype;var T=function(e,t,r,n){var o=false;return function(i){if(o){return}o=true;t[e]=i;if(--n.count===0){var a=r.resolve;a(t)}}};var S=function(e,t,r){var n=e.iterator;var o=[],i={count:1},a,u;for(var s=0;;s++){try{a=J.IteratorStep(n);if(a===false){e.done=true;break}u=a.value}catch(f){e.done=true;throw f}o[s]=void 0;var c=t.resolve(u);var p=T(s,o,r,i);i.count++;c.then(p,r.reject)}if(--i.count===0){var l=r.resolve;l(o)}return r.promise};var I=function(e,t,r){var n=e.iterator,o,i,a;while(true){try{o=J.IteratorStep(n);if(o===false){e.done=true;break}i=o.value}catch(u){e.done=true;throw u}a=t.resolve(i);a.then(r.resolve,r.reject)}return r.promise};v(O,{all:function x(t){var r=w(this);var n=new e(r);var o,i;try{o=J.GetIterator(t);i={iterator:o,done:false};return S(i,r,n)}catch(a){if(i&&!i.done){try{J.IteratorClose(o,true)}catch(u){a=u}}var s=n.reject;s(a);return n.promise}},race:function C(t){var r=w(this);var n=new e(r);var o,i;try{o=J.GetIterator(t);i={iterator:o,done:false};return I(i,r,n)}catch(a){if(i&&!i.done){try{J.IteratorClose(o,true)}catch(u){a=u}}var s=n.reject;s(a);return n.promise}},reject:function N(t){var r=this;var n=new e(r);var o=n.reject;o(t);return n.promise},resolve:function A(t){var r=this;if(J.IsPromise(t)){var n=t.constructor;if(n===r){return t}}var o=new e(r);var i=o.resolve;i(t);return o.promise}});v(j,{"catch":function(e){return this.then(void 0,e)},then:function _(t,r){var n=this;if(!J.IsPromise(n)){throw new TypeError("not a promise")}var o=J.SpeciesConstructor(n,O);var s=new e(o);if(!J.IsCallable(t)){t=a}if(!J.IsCallable(r)){r=u}var v={capabilities:s,handler:t};var h={capabilities:s,handler:r};var y=n._promise,b;switch(y.state){case f:M(y.fulfillReactions,v);M(y.rejectReactions,h);break;case c:b=y.result;i(function(){l(v,b)});break;case p:b=y.result;i(function(){l(h,b)});break;default:throw new TypeError("unexpected")}return s.promise}});return O}();if(m.Promise){delete m.Promise.accept;delete m.Promise.defer;delete m.Promise.prototype.chain}v(m,{Promise:mt});var wt=y(m.Promise,function(e){return e.resolve(42).then(function(){})instanceof e});var Ot=!n(function(){m.Promise.reject(42).then(null,5).then(null,D)});var jt=n(function(){m.Promise.call(3,D)});var Tt=function(e){var t=e.resolve(5);t.constructor={};var r=e.resolve(t);return t===r}(m.Promise);if(!wt||!Ot||!jt||Tt){Promise=mt;U(m,"Promise",mt)}H(Promise);var St=function(e){var t=Object.keys(f(e,function(e,t){e[t]=true;return e},{}));return e.join(":")===t.join(":")};var It=St(["z","a","bb"]);var Et=St(["z",1,"a","3",2]);if(u){var Mt=function Cn(e){if(!It){return null}var t=typeof e;if(t==="undefined"||e===null){return"^"+String(e)}else if(t==="string"){return"$"+e}else if(t==="number"){if(!Et){return"n"+e}return e}else if(t==="boolean"){return"b"+e}return null};var xt=function Nn(){return Object.create?Object.create(null):{}};var Pt=function An(e,r,n){if(Array.isArray(n)||W.string(n)){s(n,function(e){r.set(e[0],e[1])})}else if(n instanceof e){t(e.prototype.forEach,n,function(e,t){r.set(t,e)})}else{var o,i;if(n!==null&&typeof n!=="undefined"){i=r.set;if(!J.IsCallable(i)){throw new TypeError("bad map")}o=J.GetIterator(n)}if(typeof o!=="undefined"){while(true){var a=J.IteratorStep(o);if(a===false){break}var u=a.value;try{if(!J.TypeIsObject(u)){throw new TypeError("expected iterable of pairs")}t(i,r,u[0],u[1])}catch(f){J.IteratorClose(o,true);throw f}}}}};var Ct=function _n(e,r,n){if(Array.isArray(n)||W.string(n)){s(n,function(e){r.add(e)})}else if(n instanceof e){t(e.prototype.forEach,n,function(e){r.add(e)})}else{var o,i;if(n!==null&&typeof n!=="undefined"){i=r.add;if(!J.IsCallable(i)){throw new TypeError("bad set")}o=J.GetIterator(n)}if(typeof o!=="undefined"){while(true){var a=J.IteratorStep(o);if(a===false){break}var u=a.value;try{t(i,r,u)}catch(f){J.IteratorClose(o,true);throw f}}}}};var Nt={Map:function(){var e={};var r=function s(e,t){this.key=e;this.value=t;this.next=null;this.prev=null};r.prototype.isRemoved=function f(){return this.key===e; +};var n=function c(e){return!!e._es6map};var o=function p(e,t){if(!J.TypeIsObject(e)||!n(e)){throw new TypeError("Method Map.prototype."+t+" called on incompatible receiver "+String(e))}};var i=function l(e,t){o(e,"[[MapIterator]]");this.head=e._head;this.i=this.head;this.kind=t};i.prototype={next:function h(){var e=this.i,t=this.kind,r=this.head,n;if(typeof this.i==="undefined"){return{value:void 0,done:true}}while(e.isRemoved()&&e!==r){e=e.prev}while(e.next!==r){e=e.next;if(!e.isRemoved()){if(t==="key"){n=e.key}else if(t==="value"){n=e.value}else{n=[e.key,e.value]}this.i=e;return{value:n,done:false}}}this.i=void 0;return{value:void 0,done:true}}};Z(i.prototype);var a=function y(){if(!(this instanceof y)){throw new TypeError('Constructor Map requires "new"')}if(this&&this._es6map){throw new TypeError("Bad construction")}var e=Q(this,y,u,{_es6map:true,_head:null,_storage:xt(),_size:0});var t=new r(null,null);t.next=t.prev=t;e._head=t;if(arguments.length>0){Pt(y,e,arguments[0])}return e};var u=a.prototype;$.getter(u,"size",function(){if(typeof this._size==="undefined"){throw new TypeError("size method called on incompatible Map")}return this._size});v(u,{get:function b(e){o(this,"get");var t=Mt(e);if(t!==null){var r=this._storage[t];if(r){return r.value}else{return}}var n=this._head,i=n;while((i=i.next)!==n){if(J.SameValueZero(i.key,e)){return i.value}}},has:function g(e){o(this,"has");var t=Mt(e);if(t!==null){return typeof this._storage[t]!=="undefined"}var r=this._head,n=r;while((n=n.next)!==r){if(J.SameValueZero(n.key,e)){return true}}return false},set:function d(e,t){o(this,"set");var n=this._head,i=n,a;var u=Mt(e);if(u!==null){if(typeof this._storage[u]!=="undefined"){this._storage[u].value=t;return this}else{a=this._storage[u]=new r(e,t);i=n.prev}}while((i=i.next)!==n){if(J.SameValueZero(i.key,e)){i.value=t;return this}}a=a||new r(e,t);if(J.SameValue(-0,e)){a.key=+0}a.next=this._head;a.prev=this._head.prev;a.prev.next=a;a.next.prev=a;this._size+=1;return this},"delete":function(t){o(this,"delete");var r=this._head,n=r;var i=Mt(t);if(i!==null){if(typeof this._storage[i]==="undefined"){return false}n=this._storage[i].prev;delete this._storage[i]}while((n=n.next)!==r){if(J.SameValueZero(n.key,t)){n.key=n.value=e;n.prev.next=n.next;n.next.prev=n.prev;this._size-=1;return true}}return false},clear:function m(){o(this,"clear");this._size=0;this._storage=xt();var t=this._head,r=t,n=r.next;while((r=n)!==t){r.key=r.value=e;n=r.next;r.next=r.prev=t}t.next=t.prev=t},keys:function w(){o(this,"keys");return new i(this,"key")},values:function O(){o(this,"values");return new i(this,"value")},entries:function j(){o(this,"entries");return new i(this,"key+value")},forEach:function T(e){o(this,"forEach");var r=arguments.length>1?arguments[1]:null;var n=this.entries();for(var i=n.next();!i.done;i=n.next()){if(r){t(e,r,i.value[1],i.value[0],this)}else{e(i.value[1],i.value[0],this)}}}});Z(u,u.entries);return a}(),Set:function(){var e=function a(e){return e._es6set&&typeof e._storage!=="undefined"};var r=function u(t,r){if(!J.TypeIsObject(t)||!e(t)){throw new TypeError("Set.prototype."+r+" called on incompatible receiver "+String(t))}};var n=function f(){if(!(this instanceof f)){throw new TypeError('Constructor Set requires "new"')}if(this&&this._es6set){throw new TypeError("Bad construction")}var e=Q(this,f,o,{_es6set:true,"[[SetData]]":null,_storage:xt()});if(!e._es6set){throw new TypeError("bad set")}if(arguments.length>0){Ct(f,e,arguments[0])}return e};var o=n.prototype;var i=function c(e){if(!e["[[SetData]]"]){var t=e["[[SetData]]"]=new Nt.Map;s(Object.keys(e._storage),function(e){if(e==="^null"){e=null}else if(e==="^undefined"){e=void 0}else{var r=e.charAt(0);if(r==="$"){e=E(e,1)}else if(r==="n"){e=+E(e,1)}else if(r==="b"){e=e==="btrue"}else{e=+e}}t.set(e,e)});e._storage=null}};$.getter(n.prototype,"size",function(){r(this,"size");i(this);return this["[[SetData]]"].size});v(n.prototype,{has:function p(e){r(this,"has");var t;if(this._storage&&(t=Mt(e))!==null){return!!this._storage[t]}i(this);return this["[[SetData]]"].has(e)},add:function h(e){r(this,"add");var t;if(this._storage&&(t=Mt(e))!==null){this._storage[t]=true;return this}i(this);this["[[SetData]]"].set(e,e);return this},"delete":function(e){r(this,"delete");var t;if(this._storage&&(t=Mt(e))!==null){var n=F(this._storage,t);return delete this._storage[t]&&n}i(this);return this["[[SetData]]"]["delete"](e)},clear:function y(){r(this,"clear");if(this._storage){this._storage=xt()}else{this["[[SetData]]"].clear()}},values:function b(){r(this,"values");i(this);return this["[[SetData]]"].values()},entries:function g(){r(this,"entries");i(this);return this["[[SetData]]"].entries()},forEach:function d(e){r(this,"forEach");var n=arguments.length>1?arguments[1]:null;var o=this;i(o);this["[[SetData]]"].forEach(function(r,i){if(n){t(e,n,i,i,o)}else{e(i,i,o)}})}});l(n.prototype,"keys",n.prototype.values,true);Z(n.prototype,n.prototype.values);return n}()};v(m,Nt);if(m.Map||m.Set){var At=o(function(){return new Map([[1,2]]).get(1)===2});if(!At){var _t=m.Map;m.Map=function kn(){if(!(this instanceof kn)){throw new TypeError('Constructor Map requires "new"')}var e=new _t;if(arguments.length>0){Pt(kn,e,arguments[0])}Object.setPrototypeOf(e,m.Map.prototype);l(e,"constructor",kn,true);return e};m.Map.prototype=h(_t.prototype);$.preserveToString(m.Map,_t)}var kt=new Map;var Rt=function(e){e["delete"](0);e["delete"](-0);e.set(0,3);e.get(-0,4);return e.get(0)===3&&e.get(-0)===4}(kt);var Ft=kt.set(1,2)===kt;if(!Rt||!Ft){var Lt=Map.prototype.set;U(Map.prototype,"set",function Rn(e,r){t(Lt,this,e===0?0:e,r);return this})}if(!Rt){var Dt=Map.prototype.get;var zt=Map.prototype.has;v(Map.prototype,{get:function Fn(e){return t(Dt,this,e===0?0:e)},has:function Ln(e){return t(zt,this,e===0?0:e)}},true);$.preserveToString(Map.prototype.get,Dt);$.preserveToString(Map.prototype.has,zt)}var qt=new Set;var Gt=function(e){e["delete"](0);e.add(-0);return!e.has(0)}(qt);var Ht=qt.add(1)===qt;if(!Gt||!Ht){var Wt=Set.prototype.add;Set.prototype.add=function Dn(e){t(Wt,this,e===0?0:e);return this};$.preserveToString(Set.prototype.add,Wt)}if(!Gt){var Bt=Set.prototype.has;Set.prototype.has=function zn(e){return t(Bt,this,e===0?0:e)};$.preserveToString(Set.prototype.has,Bt);var Vt=Set.prototype["delete"];Set.prototype["delete"]=function qn(e){return t(Vt,this,e===0?0:e)};$.preserveToString(Set.prototype["delete"],Vt)}var $t=y(m.Map,function(e){var t=new e([]);t.set(42,42);return t instanceof e});var Ut=Object.setPrototypeOf&&!$t;var Xt=function(){try{return!(m.Map()instanceof m.Map)}catch(e){return e instanceof TypeError}}();if(m.Map.length!==0||Ut||!Xt){var Zt=m.Map;m.Map=function Gn(){if(!(this instanceof Gn)){throw new TypeError('Constructor Map requires "new"')}var e=new Zt;if(arguments.length>0){Pt(Gn,e,arguments[0])}Object.setPrototypeOf(e,Gn.prototype);l(e,"constructor",Gn,true);return e};m.Map.prototype=Zt.prototype;$.preserveToString(m.Map,Zt)}var Kt=y(m.Set,function(e){var t=new e([]);t.add(42,42);return t instanceof e});var Jt=Object.setPrototypeOf&&!Kt;var Qt=function(){try{return!(m.Set()instanceof m.Set)}catch(e){return e instanceof TypeError}}();if(m.Set.length!==0||Jt||!Qt){var Yt=m.Set;m.Set=function Hn(){if(!(this instanceof Hn)){throw new TypeError('Constructor Set requires "new"')}var e=new Yt;if(arguments.length>0){Ct(Hn,e,arguments[0])}Object.setPrototypeOf(e,Hn.prototype);l(e,"constructor",Hn,true);return e};m.Set.prototype=Yt.prototype;$.preserveToString(m.Set,Yt)}var er=!o(function(){return(new Map).keys().next().done});if(typeof m.Map.prototype.clear!=="function"||(new m.Set).size!==0||(new m.Map).size!==0||typeof m.Map.prototype.keys!=="function"||typeof m.Set.prototype.keys!=="function"||typeof m.Map.prototype.forEach!=="function"||typeof m.Set.prototype.forEach!=="function"||i(m.Map)||i(m.Set)||typeof(new m.Map).keys().next!=="function"||er||!$t){delete m.Map;delete m.Set;v(m,{Map:Nt.Map,Set:Nt.Set},true)}}if(m.Set.prototype.keys!==m.Set.prototype.values){l(m.Set.prototype,"keys",m.Set.prototype.values,true)}Z(Object.getPrototypeOf((new m.Map).keys()));Z(Object.getPrototypeOf((new m.Set).keys()))}H(Map);H(Set);if(!m.Reflect){l(m,"Reflect",{})}var tr=m.Reflect;var rr=function Wn(e){if(!J.TypeIsObject(e)){throw new TypeError("target must be an object")}};v(m.Reflect,{apply:function Bn(){return e(J.Call,null,arguments)},construct:function Vn(e,t){if(!J.IsConstructor(e)){throw new TypeError("First argument must be a constructor.")}var r=arguments.length<3?e:arguments[2];if(!J.IsConstructor(r)){throw new TypeError("new.target must be a constructor.")}return J.Construct(e,t,r,"internal")},deleteProperty:function $n(e,t){rr(e);if(u){var r=Object.getOwnPropertyDescriptor(e,t);if(r&&!r.configurable){return false}}return delete e[t]},enumerate:function Un(e){rr(e);return new ce(e,"key")},has:function Xn(e,t){rr(e);return t in e}});if(Object.getOwnPropertyNames){v(m.Reflect,{ownKeys:function Zn(e){rr(e);var t=Object.getOwnPropertyNames(e);if(J.IsCallable(Object.getOwnPropertySymbols)){x(t,Object.getOwnPropertySymbols(e))}return t}})}var nr=function Kn(e){return!n(e)};if(Object.preventExtensions){v(m.Reflect,{isExtensible:function Jn(e){rr(e);return Object.isExtensible(e)},preventExtensions:function Qn(e){rr(e);return nr(function(){Object.preventExtensions(e)})}})}if(u){var or=function Yn(e,r,n){var o=Object.getOwnPropertyDescriptor(e,r);if(!o){var i=Object.getPrototypeOf(e);if(i===null){return undefined}return or(i,r,n)}if("value"in o){return o.value}if(o.get){return t(o.get,n)}return undefined};var ir=function eo(e,r,n,o){var i=Object.getOwnPropertyDescriptor(e,r);if(!i){var a=Object.getPrototypeOf(e);if(a!==null){return ir(a,r,n,o)}i={value:void 0,writable:true,enumerable:true,configurable:true}}if("value"in i){if(!i.writable){return false}if(!J.TypeIsObject(o)){return false}var u=Object.getOwnPropertyDescriptor(o,r);if(u){return tr.defineProperty(o,r,{value:n})}else{return tr.defineProperty(o,r,{value:n,writable:true,enumerable:true,configurable:true})}}if(i.set){t(i.set,o,n);return true}return false};v(m.Reflect,{defineProperty:function to(e,t,r){rr(e);return nr(function(){Object.defineProperty(e,t,r)})},getOwnPropertyDescriptor:function ro(e,t){rr(e);return Object.getOwnPropertyDescriptor(e,t)},get:function no(e,t){rr(e);var r=arguments.length>2?arguments[2]:e;return or(e,t,r)},set:function oo(e,t,r){rr(e);var n=arguments.length>3?arguments[3]:e;return ir(e,t,r,n)}})}if(Object.getPrototypeOf){var ar=Object.getPrototypeOf;v(m.Reflect,{getPrototypeOf:function io(e){rr(e);return ar(e)}})}if(Object.setPrototypeOf){var ur=function(e,t){while(t){if(e===t){return true}t=tr.getPrototypeOf(t)}return false};v(m.Reflect,{setPrototypeOf:function ao(e,t){rr(e);if(t!==null&&!J.TypeIsObject(t)){throw new TypeError("proto must be an object or null")}if(t===tr.getPrototypeOf(e)){return true}if(tr.isExtensible&&!tr.isExtensible(e)){return false}if(ur(e,t)){return false}Object.setPrototypeOf(e,t);return true}})}if(String(new Date(NaN))!=="Invalid Date"){var sr=Date.prototype.toString;var fr=function uo(){var e=+this;if(e!==e){return"Invalid Date"}return t(sr,this)};U(Date.prototype,"toString",fr)}var cr={anchor:function so(e){return J.CreateHTML(this,"a","name",e)},big:function fo(){return J.CreateHTML(this,"big","","")},blink:function co(){return J.CreateHTML(this,"blink","","")},bold:function po(){return J.CreateHTML(this,"b","","")},fixed:function lo(){return J.CreateHTML(this,"tt","","")},fontcolor:function vo(e){return J.CreateHTML(this,"font","color",e)},fontsize:function ho(e){return J.CreateHTML(this,"font","size",e)},italics:function yo(){return J.CreateHTML(this,"i","","")},link:function bo(e){return J.CreateHTML(this,"a","href",e)},small:function go(){return J.CreateHTML(this,"small","","")},strike:function mo(){return J.CreateHTML(this,"strike","","")},sub:function wo(){return J.CreateHTML(this,"sub","","")},sup:function Oo(){return J.CreateHTML(this,"sup","","")}};s(Object.keys(cr),function(e){var r=String.prototype[e];var n=false;if(J.IsCallable(r)){var o=t(r,"",' " ');var i=I([],o.match(/"/g)).length;n=o!==o.toLowerCase()||i>2}else{n=true}if(n){l(String.prototype,e,cr[e],true)}});return m}); +//# sourceMappingURL=es6-shim.map diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/package.json b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/package.json new file mode 100644 index 0000000..35b84f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/package.json @@ -0,0 +1,111 @@ +{ + "name": "es6-shim", + "version": "0.32.2", + "author": { + "name": "Paul Miller", + "url": "http://paulmillr.com" + }, + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "homepage": "https://github.com/paulmillr/es6-shim/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git://github.com/paulmillr/es6-shim.git" + }, + "main": "es6-shim", + "scripts": { + "test": "npm run lint && npm run test-shim && npm run test-sham", + "test-shim": "mocha test/*.js test/*/*.js", + "test-sham": "mocha test-sham/*.js", + "test-native": "npm run jshint-shim && NO_ES6_SHIM=1 mocha test/*.js test/*/*.js", + "lint": "npm run lint-shim && npm run lint-sham", + "lint-shim": "npm run jshint-shim && npm run jscs-shim", + "lint-sham": "npm run jshint-sham && npm run jscs-sham", + "jshint": "npm run jshint-shim && npm run jshint-sham", + "jshint-shim": "jshint es6-shim.js test/*.js test/*/*.js", + "jshint-sham": "jshint es6-sham.js test-sham/*.js", + "jscs": "npm run jscs-shim && npm run jscs-sham", + "jscs-shim": "jscs es6-shim.js test/*.js test/*/*.js", + "jscs-sham": "jscs es6-sham.js test-sham/*.js", + "minify": "npm run minify-shim && npm run minify-sham", + "minify-shim": "uglifyjs es6-shim.js --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js", + "minify-sham": "uglifyjs es6-sham.js --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js", + "sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true", + "sauce": "npm run sauce-connect && grunt sauce" + }, + "testling": { + "html": "testling.html", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/10.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "dependencies": {}, + "devDependencies": { + "chai": "^3.0.0", + "es5-shim": "^4.1.6", + "grunt": "^0.4.5", + "grunt-contrib-connect": "^0.10.1", + "grunt-contrib-watch": "^0.6.1", + "grunt-saucelabs": "^8.6.1", + "jscs": "^1.13.1", + "jshint": "^2.8.0", + "mocha": "^2.2.5", + "promises-aplus-tests": "^2.1.0", + "promises-es6-tests": "^0.5.0", + "uglify-js": "^2.4.23" + }, + "gitHead": "116db26893347198a5e2c080e0ed10a6bc5ed67e", + "bugs": { + "url": "https://github.com/paulmillr/es6-shim/issues" + }, + "_id": "es6-shim@0.32.2", + "_shasum": "db38c519ed6005a479ec9dda5f64ff6c8574ebf2", + "_from": "es6-shim@latest", + "_npmVersion": "2.11.1", + "_nodeVersion": "2.3.0", + "_npmUser": { + "name": "ljharb", + "email": "ljharb@gmail.com" + }, + "dist": { + "shasum": "db38c519ed6005a479ec9dda5f64ff6c8574ebf2", + "tarball": "http://registry.npmjs.org/es6-shim/-/es6-shim-0.32.2.tgz" + }, + "maintainers": [ + { + "name": "paulmillr", + "email": "paul@paulmillr.com" + }, + { + "name": "ljharb", + "email": "ljharb@gmail.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.32.2.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/index.html b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/index.html new file mode 100644 index 0000000..e83204d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/index.html @@ -0,0 +1,22 @@ + + + + + es6-shim tests + + + + + + + + + + + + + + + + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/set-prototype-of.js b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/set-prototype-of.js new file mode 100644 index 0000000..e46bb6a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/es6-shim/test-sham/set-prototype-of.js @@ -0,0 +1,25 @@ +/*global expect */ +describe('Object.setPrototypeOf(o, p)', function () { + 'use strict'; + + it('changes prototype to regular objects', function () { + var obj = {a: 123}; + expect(obj).to.be.an.instanceOf(Object); + // sham requires assignment to work cross browser + obj = Object.setPrototypeOf(obj, null); + expect(obj).not.to.be.an.instanceOf(Object); + expect(obj.a).to.equal(123); + }); + + it('changes prototype to null objects', function () { + var obj = Object.create(null); + obj.a = 456; + expect(obj).not.to.be.an.instanceOf(Object); + expect(obj.a).to.equal(456); + // sham requires assignment to work cross browser + obj = Object.setPrototypeOf(obj, {}); + expect(obj).to.be.an.instanceOf(Object); + expect(obj.a).to.equal(456); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/.npmignore new file mode 100644 index 0000000..28f1ba7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/.npmignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/.travis.yml new file mode 100644 index 0000000..86f9e06 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.12" +compiler: clang +before_script: + - npm install -g grunt-cli diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/changelog b/JavaScript/node_modules/johnny-five/node_modules/firmata/changelog new file mode 100644 index 0000000..a8193a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/changelog @@ -0,0 +1,10 @@ + +# 0.4.1 + +- [v0.4.1](https://github.com/jgautier/firmata/commit/cf1d4de658f273a062455bb6479d33c9197e5ef2) +- [Board: emit a "connect" event when transport opens; set isReady = true](https://github.com/jgautier/firmata/commit/70dcea3184abb4a7a0496404babbeba90d69cc76) +- [Board: module.exports Board class](https://github.com/jgautier/firmata/commit/6c8458b0a430a725f708095cf7b39572d8ffff98) +- [Board: rename sp -> transport](https://github.com/jgautier/firmata/commit/66d084d18141f8543f0c54cb0fb97b4fcc70d82a) +- [I2C: any i2c requests will throw if i2cConfig has not been called.](https://github.com/jgautier/firmata/commit/4fc710fad7ef6cf536cf96db0e163eb981682577) +- [ADXL345 example](https://github.com/jgautier/firmata/commit/fb18f5fdd62eb060a56f759ee6cfc041180f4c26) + diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/adxl345.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/adxl345.js new file mode 100644 index 0000000..3168fd1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/adxl345.js @@ -0,0 +1,58 @@ +var Board = require("../lib/firmata").Board; +var SerialPort = require("serialport"); +var rport = /usb|acm|^com/i; + +SerialPort.list(function(err, ports) { + ports.forEach(function(port) { + if (rport.test(port.comName)) { + console.log("ATTEMPTING: ", port.comName); + + var board = new Board(port.comName); + + var accel = { + ADDRESS: 0x53, + POWER_CTL: 0x2D, + RANGE: 0x31, + ALL_DATA: 0xB2, + }; + + // board.on("string", function(data) { + // console.log("data: ", data); + // }); + + board.on("ready", function() { + console.log("Ready"); + + var sensitivity = 0.00390625; + + // This is required to enable I2C + this.i2cConfig(); + + // Standby mode + this.i2cWrite(accel.ADDRESS, accel.POWER_CTL, 0); + + // Enable measurements + this.i2cWrite(accel.ADDRESS, accel.POWER_CTL, 8); + + // Set range (this is 2G range) + this.i2cWrite(accel.ADDRESS, accel.RANGE, 8); + + // Set the Register to ALL_DATA and request 6 bytes + this.i2cRead(accel.ADDRESS, accel.ALL_DATA, 6, function(data) { + var x = (data[1] << 8) | data[0]; + var y = (data[3] << 8) | data[2]; + var z = (data[5] << 8) | data[4]; + + // Wrap and clamp 16 bits; + var X = (x >> 15 ? ((x ^ 0xFFFF) + 1) * -1 : x) * sensitivity; + var Y = (y >> 15 ? ((y ^ 0xFFFF) + 1) * -1 : y) * sensitivity; + var Z = (z >> 15 ? ((z ^ 0xFFFF) + 1) * -1 : z) * sensitivity; + + console.log("X: ", X); + console.log("Y: ", Y); + console.log("Z: ", Z); + }); + }); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink-ethernet.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink-ethernet.js new file mode 100644 index 0000000..4f9b247 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink-ethernet.js @@ -0,0 +1,45 @@ +/** + * Sample script to blink LED 13 + */ + + +var ledPin = 13; + +var firmata = require("../lib/firmata"); +var EtherPort = require("../../etherport/lib/wtf.js"); + +// var eport = new EtherPort(3030); + +// console.log(eport); + + +// var board = new firmata.Board(new EtherPort(3030), function(err) { + + + +// if (err) { +// console.log(err); +// return; +// } +// console.log("connected"); + +// console.log("Firmware: " + board.firmware.name + "-" + board.firmware.version.major + "." + board.firmware.version.minor); + +// var ledOn = true; +// board.pinMode(ledPin, board.MODES.OUTPUT); + +// setInterval(function() { + +// if (ledOn) { +// console.log("+"); +// board.digitalWrite(ledPin, board.HIGH); +// } else { +// console.log("-"); +// board.digitalWrite(ledPin, board.LOW); +// } + +// ledOn = !ledOn; + +// }, 500); + +// }); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink.js new file mode 100644 index 0000000..c618568 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/blink.js @@ -0,0 +1,37 @@ +/** + * Sample script to blink LED 13 + */ + + +console.log("blink start ..."); + +var ledPin = 13; + +var firmata = require("../lib/firmata"); +var board = new firmata.Board("/dev/cu.usbmodem1411", function(err) { + if (err) { + console.log(err); + return; + } + console.log("connected"); + + console.log("Firmware: " + board.firmware.name + "-" + board.firmware.version.major + "." + board.firmware.version.minor); + + var ledOn = true; + board.pinMode(ledPin, board.MODES.OUTPUT); + + setInterval(function() { + + if (ledOn) { + console.log("+"); + board.digitalWrite(ledPin, board.HIGH); + } else { + console.log("-"); + board.digitalWrite(ledPin, board.LOW); + } + + ledOn = !ledOn; + + }, 500); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/failure.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/failure.js new file mode 100644 index 0000000..31f91e9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/failure.js @@ -0,0 +1,10 @@ +var Board = require("../lib/firmata").Board; +var board = new Board("/dev/XYZ"); + +board.on("ready", function() { + console.log("Ready"); +}); + +board.on("error", function() { + console.log("error"); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/johnny-five-io-plugin.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/johnny-five-io-plugin.js new file mode 100644 index 0000000..d39bf1b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/johnny-five-io-plugin.js @@ -0,0 +1,28 @@ +var SerialPort = require("serialport"); +var five = require("johnny-five"); +var Firmata = require("../"); + +SerialPort.list(function(error, list) { + var device = list.reduce(function(accum, item) { + if (item.manufacturer.indexOf("Arduino") === 0) { + return item; + } + return accum; + }, null); + + + /* + The following demonstrates using Firmata + as an IO Plugin for Johnny-Five + */ + + var board = new five.Board({ + io: new Firmata(device.comName) + }); + + board.on("ready", function() { + var led = new five.Led(13); + led.blink(500); + }); +}); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/k22.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/k22.js new file mode 100644 index 0000000..9dcaf5f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/k22.js @@ -0,0 +1,26 @@ +/** + * Sample script to take readings from a k22 co2 sensor. + * http://www.co2meter.com/collections/co2-sensors/products/k-22-oc-co2-sensor-module + */ +var Board = require("../lib/firmata").Board; +var board = new Board("/dev/tty.usbmodemfa131", function() { + board.sendI2CConfig(); + board.on("string", function(string) { + console.log(string); + }); + setInterval(function() { + board.sendI2CWriteRequest(0x68, [0x22, 0x00, 0x08, 0x2A]); + board.sendI2CReadRequest(0x68, 4, function(data) { + var ppms = 0; + ppms |= data[1] & 0xFF; + ppms = ppms << 8; + ppms |= data[2] & 0xFF; + var checksum = data[0] + data[1] + data[2]; + if (checksum === data[3]) { + console.log("Current PPMs: " + ppms); + } else { + console.log("Checksum failure"); + } + }); + }, 2000); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/multi.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/multi.js new file mode 100644 index 0000000..aefe740 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/multi.js @@ -0,0 +1,27 @@ +var Board = require("../lib/firmata").Board; +var SerialPort = require("serialport"); +var rport = /usb|acm|^com/i; + +SerialPort.list(function(err, ports) { + ports.forEach(function(port) { + if (rport.test(port.comName)) { + console.log("ATTEMPTING: ", port.comName); + var board = new Board(port.comName, function(error) { + console.log(error); + }); + + board.on("ready", function() { + console.log("CONNECTED: ", port.comName); + + var byte = 1; + var pin = 13; + + this.pinMode(pin, this.MODES.OUTPUT); + + setInterval(function() { + this.digitalWrite(pin, (byte ^= 1)); + }.bind(this), 500); + }); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reality-check.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reality-check.js new file mode 100644 index 0000000..cf2e2b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reality-check.js @@ -0,0 +1,32 @@ +var Board = require("../lib/firmata").Board; +var SerialPort = require("serialport"); +var rport = /usb|acm|^com/i; + +SerialPort.list(function(err, ports) { + ports.forEach(function(port) { + if (rport.test(port.comName)) { + console.log("ATTEMPTING: ", port.comName); + + var board = new Board(port.comName); + + board.on("ready", function() { + console.log("Ready"); + + console.log(this.getSamplingInterval()); + + // this.analogRead(0, function(adc) { + // console.log(adc); + // }); + + this.pinMode(14, this.MODES.INPUT); + this.digitalRead(14, function(data) { + console.log(data); + }); + + // this.analogRead(0, function(adc) { + // console.log(adc); + // }); + }); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reporting.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reporting.js new file mode 100644 index 0000000..1730715 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/reporting.js @@ -0,0 +1,40 @@ +var Board = require("../lib/firmata").Board; +var a = 6; +var b = 7; + +var board = new Board("/dev/cu.usbmodem1411"); + +board.on("ready", function() { + console.log("Ready."); + + this.pinMode(a, this.MODES.PWM); + this.pinMode(b, this.MODES.OUTPUT); + + var states = { + 5: 0, + 8: 0 + }; + + Object.keys(states).forEach(function(pin) { + pin = +pin; + this.pinMode(pin, this.MODES.INPUT); + this.digitalRead(pin, function(value) { + console.log("pin: %d value: %d", pin, value); + if (states[pin] !== value) { + states[pin] = value; + this.digitalWrite(b, value); + } + }); + }, this); + + // var analogs = [0, 1, 2, 3, 4, 5]; + var analogs = [3]; + + analogs.forEach(function(pin) { + pin = +pin; + this.pinMode(pin, this.MODES.ANALOG); + this.analogRead(pin, function(value) { + this.analogWrite(a, value >> 2); + }); + }, this); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/serialport-multi.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/serialport-multi.js new file mode 100644 index 0000000..60a4b0d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/serialport-multi.js @@ -0,0 +1,23 @@ +var com = require("serialport"); +var rport = /usb|acm|^com/i; + +com.list(function(err, ports) { + ports.forEach(function(port) { + if (rport.test(port.comName)) { + console.log("ATTEMPTING: ", port.comName); + + var serialPort = new com.SerialPort(port.comName, { + baudRate: 57600, + bufferSize: 1 + }); + + serialPort.on("open",function() { + console.log("Port open"); + }); + + serialPort.on("data", function(data) { + console.log(port.comName, Date.now()); + }); + } + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servo-config.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servo-config.js new file mode 100644 index 0000000..f8cfebb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servo-config.js @@ -0,0 +1,20 @@ +var Board = require("../lib/firmata").Board; +var board = new Board("/dev/tty.usbmodem1421"); + +board.on("ready", function() { + var degrees = 10; + var incrementer = 10; + + // This will map 0-180 to 1000-1500 + board.servoConfig(9, 1000, 1500); + board.servoWrite(9, 0); + + setInterval(function() { + if (degrees >= 180 || degrees === 0) { + incrementer *= -1; + } + degrees += incrementer; + board.servoWrite(9, degrees); + console.log(degrees); + }, 500); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servosweep.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servosweep.js new file mode 100644 index 0000000..f629bde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/servosweep.js @@ -0,0 +1,17 @@ +/** + * Sample script to move a servo back and forth. + */ +var Board = require("../lib/firmata").Board; +var board = new Board("/dev/tty.usbmodemfa131", function() { + var degrees = 10; + var incrementer = 10; + board.pinMode(9, board.MODES.SERVO); + board.servoWrite(9, 0); + setInterval(function() { + if (degrees >= 180 || degrees === 0) { + incrementer *= -1; + } + degrees += incrementer; + board.servoWrite(9, degrees); + }, 500); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/simple.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/simple.js new file mode 100644 index 0000000..52f95f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/simple.js @@ -0,0 +1,20 @@ +var Board = require("../lib/firmata").Board; +var board = new Board("/dev/cu.usbmodem1421"); + +// board.on("ready", function() { +// this.pinMode(this.MODES.ANALOG); +// this.analogRead("A0", function(data) { +// console.log("A0", data); +// }); +// }); + +var pin = 13; +board.on("ready", function() { + var byte = 1; + + this.pinMode(pin, this.MODES.OUTPUT); + + setInterval(function() { + board.digitalWrite(pin, (byte ^= 1)); + }.bind(this), 500); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp-streams.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp-streams.js new file mode 100644 index 0000000..bd982c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp-streams.js @@ -0,0 +1,15 @@ +// var Board = require("../lib/firmata").Board; +// var SerialPort = require("serialport").SerialPort; +// var board = new Board("/dev/cu.usbmodem1411"); + + +var SerialPort = require("serialport").SerialPort; +var options = { + comname: "/dev/cu.usbmodem1411", + baudRate: 57600, + bufferSize: 1 +}; +var sp = new SerialPort(options); + +console.log(sp); +// sp.open(options); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp.js new file mode 100644 index 0000000..7a5bf40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/sp.js @@ -0,0 +1,10 @@ +var SerialPort = require("serialport").SerialPort; + +var sp = new SerialPort("/dev/cu.usbmodem1421", { + baudRate: 57600, + bufferSize: 1 +}); + +sp.on("open", function(data) { + console.log(this === sp); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/ssfirmata.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/ssfirmata.js new file mode 100644 index 0000000..5043486 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/ssfirmata.js @@ -0,0 +1,13 @@ +var firmata = require("../lib/firmata"); +var board = new firmata.Board("/dev/tty.usbmodem1411", function(err) { + + console.log(this); + + board.on("string", function(value) { + console.log(value); + }); + + board.serialConfig(); + + board.serialWrite("#10P1000T100\r\n"); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/untitled b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/untitled new file mode 100644 index 0000000..088bcf9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/examples/untitled @@ -0,0 +1,30 @@ +var d = 13; + +var firmata = require("../lib/firmata"); +var board = new firmata.Board("/dev/cu.usbmodem1411", function(err) { + if (err) { + console.log(err); + return; + } + console.log("connected"); + + console.log("Firmware: " + board.firmware.name + "-" + board.firmware.version.major + "." + board.firmware.version.minor); + + var ledOn = true; + board.pinMode(d, board.MODES.OUTPUT); + + setInterval(function() { + + if (ledOn) { + console.log("+"); + board.digitalWrite(d, board.HIGH); + } else { + console.log("-"); + board.digitalWrite(d, board.LOW); + } + + ledOn = !ledOn; + + }, 500); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/gruntfile.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/gruntfile.js new file mode 100644 index 0000000..d0ceae4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/gruntfile.js @@ -0,0 +1,95 @@ +module.exports = function (grunt) { + grunt.initConfig({ + mochaTest: { + files: [ "test/*.test.js"] + }, + jshint: { + all: [ "gruntfile.js", "lib/*.js", "test/*.js", "examples/*.js"], + options: { + globals: { + it: true, + describe: true, + beforeEach: true, + afterEach: true, + before: true + }, + curly: true, + eqeqeq: true, + immed: true, + latedef: false, + newcap: true, + noarg: true, + sub: true, + undef: true, + boss: true, + eqnull: true, + node: true, + strict: false, + es5: true + } + }, + jscs: { + files: { + src: [ "gruntfile.js", "lib/*.js", "test/*.js", "examples/*.js"] + }, + options: { + config: ".jscsrc", + requireCurlyBraces: [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch", + ], + requireSpaceBeforeBlockStatements: true, + requireParenthesesAroundIIFE: true, + requireSpacesInConditionalExpression: true, + // requireSpaceBeforeKeywords: true, + requireSpaceAfterKeywords: [ + "if", "else", + "switch", "case", + "try", "catch", + "do", "while", "for", + "return", "typeof", "void", + ], + validateQuoteMarks: { + mark: "\"", + escape: true + } + } + }, + jsbeautifier: { + files: [ "gruntfile.js", "lib/*.js", "test/*.js", "examples/*.js"], + options: { + js: { + braceStyle: "collapse", + breakChainedMethods: false, + e4x: false, + evalCode: false, + indentChar: " ", + indentLevel: 0, + indentSize: 2, + indentWithTabs: false, + jslintHappy: false, + keepArrayIndentation: false, + keepFunctionIndentation: false, + maxPreserveNewlines: 10, + preserveNewlines: true, + spaceBeforeConditional: true, + spaceInParen: false, + unescapeStrings: false, + wrapLineLength: 0 + } + } + }, + }); + + grunt.registerTask("default", ["jshint:all", "jscs", "mochaTest"]); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-mocha-test"); + grunt.loadNpmTasks("grunt-jsbeautifier"); + grunt.loadNpmTasks("grunt-jscs"); + +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/encoder7bit.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/encoder7bit.js new file mode 100644 index 0000000..98a5366 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/encoder7bit.js @@ -0,0 +1,47 @@ +/** + * "Inspired" by Encoder7Bit.h/Encoder7Bit.cpp in the + * Firmata source code. + */ +module.exports = { + to7BitArray: function(data) { + var shift = 0; + var previous = 0; + var output = []; + + data.forEach(function(byte) { + if (shift === 0) { + output.push(byte & 0x7f); + shift++; + previous = byte >> 7; + } else { + output.push(((byte << shift) & 0x7f) | previous); + if (shift === 6) { + output.push(byte >> 1); + shift = 0; + } else { + shift++; + previous = byte >> (8 - shift); + } + } + }); + + if (shift > 0) { + output.push(previous); + } + + return output; + }, + from7BitArray: function(encoded) { + var expectedBytes = (encoded.length) * 7 >> 3; + var decoded = []; + + for (var i = 0; i < expectedBytes; i++) { + var j = i << 3; + var pos = parseInt(j / 7, 10); + var shift = j % 7; + decoded[i] = (encoded[pos] >> shift) | ((encoded[pos + 1] << (7 - shift)) & 0xFF); + } + + return decoded; + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/firmata.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/firmata.js new file mode 100644 index 0000000..c582f0b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/firmata.js @@ -0,0 +1,1426 @@ +/** + * Global Environment Dependencies + */ +/* jshint -W079 */ +var Map = require("es6-map"); +var assign = require("object-assign"); + +/** + * @author Julian Gautier + */ +/** + * Module Dependencies + */ +var util = require("util"), + Emitter = require("events").EventEmitter, + chrome = chrome || undefined, + Encoder7Bit = require("./encoder7bit"), + OneWireUtils = require("./onewireutils"), + SerialPort = null, + i2cActive = new Map(); + + +try { + if (process.browser) { + SerialPort = require("browser-serialport").SerialPort; + } else { + SerialPort = require("serialport").SerialPort; + } +} catch (err) { + SerialPort = null; +} + +if (SerialPort == null) { + console.log("It looks like serialport didn't compile properly. This is a common problem and its fix is well documented here https://github.com/voodootikigod/node-serialport#to-install"); + throw "Missing serialport dependency"; +} + +/** + * constants + */ + +var ANALOG_MAPPING_QUERY = 0x69; +var ANALOG_MAPPING_RESPONSE = 0x6A; +var ANALOG_MESSAGE = 0xE0; +var CAPABILITY_QUERY = 0x6B; +var CAPABILITY_RESPONSE = 0x6C; +var DIGITAL_MESSAGE = 0x90; +var END_SYSEX = 0xF7; +var EXTENDED_ANALOG = 0x6F; +var I2C_CONFIG = 0x78; +var I2C_REPLY = 0x77; +var I2C_REQUEST = 0x76; +var ONEWIRE_CONFIG_REQUEST = 0x41; +var ONEWIRE_DATA = 0x73; +var ONEWIRE_DELAY_REQUEST_BIT = 0x10; +var ONEWIRE_READ_REPLY = 0x43; +var ONEWIRE_READ_REQUEST_BIT = 0x08; +var ONEWIRE_RESET_REQUEST_BIT = 0x01; +var ONEWIRE_SEARCH_ALARMS_REPLY = 0x45; +var ONEWIRE_SEARCH_ALARMS_REQUEST = 0x44; +var ONEWIRE_SEARCH_REPLY = 0x42; +var ONEWIRE_SEARCH_REQUEST = 0x40; +var ONEWIRE_WITHDATA_REQUEST_BITS = 0x3C; +var ONEWIRE_WRITE_REQUEST_BIT = 0x20; +var PIN_MODE = 0xF4; +var PIN_STATE_QUERY = 0x6D; +var PIN_STATE_RESPONSE = 0x6E; +var PING_READ = 0x75; +var PULSE_IN = 0x74; +var PULSE_OUT = 0x73; +var QUERY_FIRMWARE = 0x79; +var REPORT_ANALOG = 0xC0; +var REPORT_DIGITAL = 0xD0; +var REPORT_VERSION = 0xF9; +var SAMPLING_INTERVAL = 0x7A; +var SERVO_CONFIG = 0x70; +var START_SYSEX = 0xF0; +var STEPPER = 0x72; +var STRING_DATA = 0x71; +var SYSTEM_RESET = 0xFF; + +var MAX_PIN_COUNT = 128; + +/** + * MIDI_RESPONSE contains functions to be called when we receive a MIDI message from the arduino. + * used as a switch object as seen here http://james.padolsey.com/javascript/how-to-avoid-switch-case-syndrome/ + * @private + */ + +var MIDI_RESPONSE = {}; + +/** + * Handles a REPORT_VERSION response and emits the reportversion event. Also turns on all pins to start reporting + * @private + * @param {Board} board the current arduino board we are working with. + */ + +MIDI_RESPONSE[REPORT_VERSION] = function(board) { + board.version.major = board.currentBuffer[1]; + board.version.minor = board.currentBuffer[2]; + board.emit("reportversion"); +}; + +/** + * Handles a ANALOG_MESSAGE response and emits "analog-read" and "analog-read-"+n events where n is the pin number. + * @private + * @param {Board} board the current arduino board we are working with. + */ + +MIDI_RESPONSE[ANALOG_MESSAGE] = function(board) { + var value = board.currentBuffer[1] | (board.currentBuffer[2] << 7); + var pin = board.currentBuffer[0] & 0x0F; + + if (board.pins[board.analogPins[pin]]) { + board.pins[board.analogPins[pin]].value = value; + } + + board.emit("analog-read-" + pin, value); + board.emit("analog-read", { + pin: pin, + value: value + }); +}; + +/** + * Handles a DIGITAL_MESSAGE response and emits: + * "digital-read" + * "digital-read-"+n + * + * Where n is the pin number. + * + * @private + * @param {Board} board the current arduino board we are working with. + */ + +MIDI_RESPONSE[DIGITAL_MESSAGE] = function(board) { + var port = (board.currentBuffer[0] & 0x0F); + var portValue = board.currentBuffer[1] | (board.currentBuffer[2] << 7); + + for (var i = 0; i < 8; i++) { + var pinNumber = 8 * port + i; + var pin = board.pins[pinNumber]; + if (pin && (pin.mode === board.MODES.INPUT)) { + pin.value = (portValue >> (i & 0x07)) & 0x01; + board.emit("digital-read-" + pinNumber, pin.value); + board.emit("digital-read", { + pin: pinNumber, + value: pin.value + }); + } + } +}; + +/** + * SYSEX_RESPONSE contains functions to be called when we receive a SYSEX message from the arduino. + * used as a switch object as seen here http://james.padolsey.com/javascript/how-to-avoid-switch-case-syndrome/ + * @private + */ + +var SYSEX_RESPONSE = {}; + +/** + * Handles a QUERY_FIRMWARE response and emits the "queryfirmware" event + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[QUERY_FIRMWARE] = function(board) { + var firmwareBuf = []; + board.firmware.version = {}; + board.firmware.version.major = board.currentBuffer[2]; + board.firmware.version.minor = board.currentBuffer[3]; + for (var i = 4, length = board.currentBuffer.length - 2; i < length; i += 2) { + firmwareBuf.push((board.currentBuffer[i] & 0x7F) | ((board.currentBuffer[i + 1] & 0x7F) << 7)); + } + + board.firmware.name = new Buffer(firmwareBuf).toString("utf8", 0, firmwareBuf.length); + board.emit("queryfirmware"); +}; + +/** + * Handles a CAPABILITY_RESPONSE response and emits the "capability-query" event + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[CAPABILITY_RESPONSE] = function(board) { + var supportedModes = 0; + + function pushModes(modesArray, mode) { + if (supportedModes & (1 << board.MODES[mode])) { + modesArray.push(board.MODES[mode]); + } + } + + // Only create pins if none have been previously created on the instance. + if (!board.pins.length) { + for (var i = 2, n = 0; i < board.currentBuffer.length - 1; i++) { + if (board.currentBuffer[i] === 127) { + var modesArray = []; + Object.keys(board.MODES).forEach(pushModes.bind(null, modesArray)); + board.pins.push({ + supportedModes: modesArray, + mode: board.MODES.UNKNOWN, + value: 0, + report: 1 + }); + supportedModes = 0; + n = 0; + continue; + } + if (n === 0) { + supportedModes |= (1 << board.currentBuffer[i]); + } + n ^= 1; + } + } + + board.emit("capability-query"); +}; + +/** + * Handles a PIN_STATE response and emits the 'pin-state-'+n event where n is the pin number. + * + * Note about pin state: For output modes, the state is any value that has been + * previously written to the pin. For input modes, the state is the status of + * the pullup resistor. + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[PIN_STATE_RESPONSE] = function (board) { + var pin = board.currentBuffer[2]; + board.pins[pin].mode = board.currentBuffer[3]; + board.pins[pin].state = board.currentBuffer[4]; + if (board.currentBuffer.length > 6) { + board.pins[pin].state |= (board.currentBuffer[5] << 7); + } + if (board.currentBuffer.length > 7) { + board.pins[pin].state |= (board.currentBuffer[6] << 14); + } + board.emit("pin-state-" + pin); +}; + +/** + * Handles a ANALOG_MAPPING_RESPONSE response and emits the "analog-mapping-query" event. + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[ANALOG_MAPPING_RESPONSE] = function(board) { + var pin = 0; + var currentValue; + for (var i = 2; i < board.currentBuffer.length - 1; i++) { + currentValue = board.currentBuffer[i]; + board.pins[pin].analogChannel = currentValue; + if (currentValue !== 127) { + board.analogPins.push(pin); + } + pin++; + } + board.emit("analog-mapping-query"); +}; + +/** + * Handles a I2C_REPLY response and emits the "I2C-reply-"+n event where n is the slave address of the I2C device. + * The event is passed the buffer of data sent from the I2C Device + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[I2C_REPLY] = function(board) { + var reply = []; + var address = (board.currentBuffer[2] & 0x7F) | ((board.currentBuffer[3] & 0x7F) << 7); + var register = (board.currentBuffer[4] & 0x7F) | ((board.currentBuffer[5] & 0x7F) << 7); + + for (var i = 6, length = board.currentBuffer.length - 1; i < length; i += 2) { + reply.push(board.currentBuffer[i] | (board.currentBuffer[i + 1] << 7)); + } + + board.emit("I2C-reply-" + address + "-" + register, reply); +}; + +SYSEX_RESPONSE[ONEWIRE_DATA] = function(board) { + var subCommand = board.currentBuffer[2]; + + if (!SYSEX_RESPONSE[subCommand]) { + return; + } + + SYSEX_RESPONSE[subCommand](board); +}; + +SYSEX_RESPONSE[ONEWIRE_SEARCH_REPLY] = function(board) { + var pin = board.currentBuffer[3]; + var replyBuffer = board.currentBuffer.slice(4, board.currentBuffer.length - 1); + + board.emit("1-wire-search-reply-" + pin, OneWireUtils.readDevices(replyBuffer)); +}; + +SYSEX_RESPONSE[ONEWIRE_SEARCH_ALARMS_REPLY] = function(board) { + var pin = board.currentBuffer[3]; + var replyBuffer = board.currentBuffer.slice(4, board.currentBuffer.length - 1); + + board.emit("1-wire-search-alarms-reply-" + pin, OneWireUtils.readDevices(replyBuffer)); +}; + +SYSEX_RESPONSE[ONEWIRE_READ_REPLY] = function(board) { + var encoded = board.currentBuffer.slice(4, board.currentBuffer.length - 1); + var decoded = Encoder7Bit.from7BitArray(encoded); + var correlationId = (decoded[1] << 8) | decoded[0]; + + board.emit("1-wire-read-reply-" + correlationId, decoded.slice(2)); +}; + +/** + * Handles a STRING_DATA response and logs the string to the console. + * @private + * @param {Board} board the current arduino board we are working with. + */ + +SYSEX_RESPONSE[STRING_DATA] = function(board) { + var string = new Buffer(board.currentBuffer.slice(2, -1)).toString("utf8").replace(/\0/g, ""); + board.emit("string", string); +}; + +/** + * Response from pingRead + */ + +SYSEX_RESPONSE[PING_READ] = function(board) { + var pin = (board.currentBuffer[2] & 0x7F) | ((board.currentBuffer[3] & 0x7F) << 7); + var durationBuffer = [ + (board.currentBuffer[4] & 0x7F) | ((board.currentBuffer[5] & 0x7F) << 7), (board.currentBuffer[6] & 0x7F) | ((board.currentBuffer[7] & 0x7F) << 7), (board.currentBuffer[8] & 0x7F) | ((board.currentBuffer[9] & 0x7F) << 7), (board.currentBuffer[10] & 0x7F) | ((board.currentBuffer[11] & 0x7F) << 7) + ]; + var duration = ((durationBuffer[0] << 24) + + (durationBuffer[1] << 16) + + (durationBuffer[2] << 8) + + (durationBuffer[3])); + board.emit("ping-read-" + pin, duration); +}; + +/** + * Handles the message from a stepper completing move + * @param {Board} board + */ + +SYSEX_RESPONSE[STEPPER] = function(board) { + var deviceNum = board.currentBuffer[2]; + board.emit("stepper-done-" + deviceNum, true); +}; + + +/** + * @class The Board object represents an arduino board. + * @augments EventEmitter + * @param {String} port This is the serial port the arduino is connected to. + * @param {function} function A function to be called when the arduino is ready to communicate. + * @property MODES All the modes available for pins on this arduino board. + * @property I2C_MODES All the I2C modes available. + * @property HIGH A constant to set a pins value to HIGH when the pin is set to an output. + * @property LOW A constant to set a pins value to LOW when the pin is set to an output. + * @property pins An array of pin object literals. + * @property analogPins An array of analog pins and their corresponding indexes in the pins array. + * @property version An object indicating the major and minor version of the firmware currently running. + * @property firmware An object indicateon the name, major and minor version of the firmware currently running. + * @property currentBuffer An array holding the current bytes received from the arduino. + * @property {SerialPort} sp The serial port object used to communicate with the arduino. + */ +var Board = function(port, options, callback) { + Emitter.call(this); + + if (typeof options === "function" || typeof options === "undefined") { + callback = options; + options = {}; + } + + var board = this; + var defaults = { + reportVersionTimeout: 5000, + samplingInterval: 19, + serialport: { + baudRate: 57600, + bufferSize: 1 + } + }; + + var settings = assign({}, defaults, options); + + this.isReady = false; + + this.MODES = { + INPUT: 0x00, + OUTPUT: 0x01, + ANALOG: 0x02, + PWM: 0x03, + SERVO: 0x04, + SHIFT: 0x05, + I2C: 0x06, + ONEWIRE: 0x07, + STEPPER: 0x08, + IGNORE: 0x7F, + UNKOWN: 0x10 + }; + + this.I2C_MODES = { + WRITE: 0x00, + READ: 1, + CONTINUOUS_READ: 2, + STOP_READING: 3 + }; + + this.STEPPER = { + TYPE: { + DRIVER: 1, + TWO_WIRE: 2, + FOUR_WIRE: 4 + }, + RUNSTATE: { + STOP: 0, + ACCEL: 1, + DECEL: 2, + RUN: 3 + }, + DIRECTION: { + CCW: 0, + CW: 1 + } + }; + + this.HIGH = 1; + this.LOW = 0; + this.pins = []; + this.analogPins = []; + this.version = {}; + this.firmware = {}; + this.currentBuffer = []; + this.versionReceived = false; + this.name = "Firmata"; + this.settings = settings; + + if (typeof port === "object") { + this.transport = port; + } else { + this.transport = new SerialPort(port, settings.serialport); + } + + // For backward compat + this.sp = this.transport; + + this.transport.on("open", function() { + this.emit("connect"); + }.bind(this)); + + this.transport.on("error", function(string) { + if (typeof callback === "function") { + callback(string); + } + }); + + this.transport.on("data", function(data) { + var byt, cmd; + + if (!this.versionReceived && data[0] !== REPORT_VERSION) { + return; + } else { + this.versionReceived = true; + } + + for (var i = 0; i < data.length; i++) { + byt = data[i]; + // we dont want to push 0 as the first byte on our buffer + if (this.currentBuffer.length === 0 && byt === 0) { + continue; + } else { + this.currentBuffer.push(byt); + + // [START_SYSEX, ... END_SYSEX] + if (this.currentBuffer[0] === START_SYSEX && + SYSEX_RESPONSE[this.currentBuffer[1]] && + this.currentBuffer[this.currentBuffer.length - 1] === END_SYSEX) { + + SYSEX_RESPONSE[this.currentBuffer[1]](this); + this.currentBuffer.length = 0; + } else if (this.currentBuffer[0] !== START_SYSEX) { + // Check if data gets out of sync: first byte in buffer + // must be a valid command if not START_SYSEX + // Identify command on first byte + cmd = this.currentBuffer[0] < 240 ? this.currentBuffer[0] & 0xF0 : this.currentBuffer[0]; + + // Check if it is not a valid command + if (cmd !== REPORT_VERSION && cmd !== ANALOG_MESSAGE && cmd !== DIGITAL_MESSAGE) { + // console.log("OUT OF SYNC - CMD: "+cmd); + // Clean buffer + this.currentBuffer.length = 0; + } + } + + // There are 3 bytes in the buffer and the first is not START_SYSEX: + // Might have a MIDI Command + if (this.currentBuffer.length === 3 && this.currentBuffer[0] !== START_SYSEX) { + //commands under 0xF0 we have a multi byte command + if (this.currentBuffer[0] < 240) { + cmd = this.currentBuffer[0] & 0xF0; + } else { + cmd = this.currentBuffer[0]; + } + + if (MIDI_RESPONSE[cmd]) { + MIDI_RESPONSE[cmd](this); + this.currentBuffer.length = 0; + } else { + // A bad serial read must have happened. + // Reseting the buffer will allow recovery. + this.currentBuffer.length = 0; + } + } + } + } + }.bind(this)); + + // if we have not received the version within the alotted + // time specified by the reportVersionTimeout (user or default), + // then send an explicit request for it. + this.reportVersionTimeoutId = setTimeout(function() { + if (this.versionReceived === false) { + this.reportVersion(function() {}); + this.queryFirmware(function() {}); + } + }.bind(this), settings.reportVersionTimeout); + + function ready() { + board.isReady = true; + board.emit("ready"); + if (typeof callback === "function") { + callback(); + } + } + + // Await the reported version. + this.once("reportversion", function() { + clearTimeout(this.reportVersionTimeoutId); + this.versionReceived = true; + this.once("queryfirmware", function() { + + // Only preemptively set the sampling interval if `samplingInterval` + // property was _explicitly_ set as a constructor option. + if (options.samplingInterval !== undefined) { + this.setSamplingInterval(options.samplingInterval); + } + if (settings.skipCapabilities) { + this.analogPins = settings.analogPins || this.analogPins; + this.pins = settings.pins || this.pins; + if (!this.pins.length) { + for (var i = 0; i < (settings.pinCount || MAX_PIN_COUNT); i++) { + var analogChannel = this.analogPins.indexOf(i); + if (analogChannel < 0) { + analogChannel = 127; + } + this.pins.push({supportedModes: [], analogChannel: analogChannel}); + } + } + ready(); + } else { + this.queryCapabilities(function() { + this.queryAnalogMapping(ready); + }); + } + }); + }); + + i2cActive.set(this, false); +}; + +util.inherits(Board, Emitter); + +/** + * Asks the arduino to tell us its version. + * @param {function} callback A function to be called when the arduino has reported its version. + */ + +Board.prototype.reportVersion = function(callback) { + this.once("reportversion", callback); + this.transport.write(new Buffer([REPORT_VERSION])); +}; + +/** + * Asks the arduino to tell us its firmware version. + * @param {function} callback A function to be called when the arduino has reported its firmware version. + */ + +Board.prototype.queryFirmware = function(callback) { + this.once("queryfirmware", callback); + this.transport.write(new Buffer([START_SYSEX, QUERY_FIRMWARE, END_SYSEX])); +}; + +/** + * Asks the arduino to read analog data. Turn on reporting for this pin. + * @param {number} pin The pin to read analog data + * @param {function} callback A function to call when we have the analag data. + */ + +Board.prototype.analogRead = function(pin, callback) { + this.reportAnalogPin(pin, 1); + this.addListener("analog-read-" + pin, callback); +}; + +/** + * Asks the arduino to write an analog message. + * @param {number} pin The pin to write analog data to. + * @param {nubmer} value The data to write to the pin between 0 and 255. + */ + +Board.prototype.analogWrite = function(pin, value) { + var data = []; + + this.pins[pin].value = value; + + if (pin > 15) { + data[0] = START_SYSEX; + data[1] = EXTENDED_ANALOG; + data[2] = pin; + data[3] = value & 0x7F; + data[4] = (value >> 7) & 0x7F; + + if (value > 0x00004000) { + data[data.length] = (value >> 14) & 0x7F; + } + + if (value > 0x00200000) { + data[data.length] = (value >> 21) & 0x7F; + } + + if (value > 0x10000000) { + data[data.length] = (value >> 28) & 0x7F; + } + + data[data.length] = END_SYSEX; + } else { + data.push(ANALOG_MESSAGE | pin, value & 0x7F, (value >> 7) & 0x7F); + } + + this.transport.write(new Buffer(data)); +}; + +Board.prototype.pwmWrite = Board.prototype.analogWrite; + +/** + * Set a pin to SERVO mode with an explicit PWM range. + * + * @param {number} pin The pin the servo is connected to + * @param {number} min A 14-bit signed int. + * @param {number} max A 14-bit signed int. + */ + +Board.prototype.servoConfig = function(pin, min, max) { + // [0] START_SYSEX (0xF0) + // [1] SERVO_CONFIG (0x70) + // [2] pin number (0-127) + // [3] minPulse LSB (0-6) + // [4] minPulse MSB (7-13) + // [5] maxPulse LSB (0-6) + // [6] maxPulse MSB (7-13) + // [7] END_SYSEX (0xF7) + + var data = [ + START_SYSEX, + SERVO_CONFIG, + pin, + min & 0x7F, + (min >> 7) & 0x7F, + max & 0x7F, + (max >> 7) & 0x7F, + END_SYSEX + ]; + + this.pins[pin].mode = this.MODES.SERVO; + this.transport.write(new Buffer(data)); +}; + +/** + * Asks the arduino to move a servo + * @param {number} pin The pin the servo is connected to + * @param {number} value The degrees to move the servo to. + */ + +Board.prototype.servoWrite = function(pin, value) { + // Values less than 544 will be treated as angles in degrees + // (valid values in microseconds are handled as microseconds) + this.analogWrite.apply(this, arguments); +}; + +/** + * Asks the arduino to set the pin to a certain mode. + * @param {number} pin The pin you want to change the mode of. + * @param {number} mode The mode you want to set. Must be one of board.MODES + */ + +Board.prototype.pinMode = function(pin, mode) { + this.pins[pin].mode = mode; + this.transport.write(new Buffer([PIN_MODE, pin, mode])); +}; + +/** + * Asks the arduino to write a value to a digital pin + * @param {number} pin The pin you want to write a value to. + * @param {value} value The value you want to write. Must be board.HIGH or board.LOW + */ + +Board.prototype.digitalWrite = function(pin, value) { + var port = Math.floor(pin / 8); + var portValue = 0; + var pinRecord; + this.pins[pin].value = value; + for (var i = 0; i < 8; i++) { + pinRecord = this.pins[8 * port + i]; + if (pinRecord && pinRecord.value) { + portValue |= (1 << i); + } + } + this.transport.write(new Buffer([DIGITAL_MESSAGE | port, portValue & 0x7F, (portValue >> 7) & 0x7F])); +}; + +/** + * Asks the arduino to read digital data. Turn on reporting for this pin's port. + * + * @param {number} pin The pin to read data from + * @param {function} callback The function to call when data has been received + */ + +Board.prototype.digitalRead = function(pin, callback) { + this.reportDigitalPin(pin, 1); + this.addListener("digital-read-" + pin, callback); +}; + +/** + * Asks the arduino to tell us its capabilities + * @param {function} callback A function to call when we receive the capabilities + */ + +Board.prototype.queryCapabilities = function(callback) { + this.once("capability-query", callback); + this.transport.write(new Buffer([START_SYSEX, CAPABILITY_QUERY, END_SYSEX])); +}; + +/** + * Asks the arduino to tell us its analog pin mapping + * @param {function} callback A function to call when we receive the pin mappings. + */ + +Board.prototype.queryAnalogMapping = function(callback) { + this.once("analog-mapping-query", callback); + this.transport.write(new Buffer([START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX])); +}; + +/** + * Asks the arduino to tell us the current state of a pin + * @param {number} pin The pin we want to the know the state of + * @param {function} callback A function to call when we receive the pin state. + */ + +Board.prototype.queryPinState = function(pin, callback) { + this.once("pin-state-" + pin, callback); + this.transport.write(new Buffer([START_SYSEX, PIN_STATE_QUERY, pin, END_SYSEX])); +}; + +/** + * Sends a string to the arduino + * @param {String} string to send to the device + */ + +Board.prototype.sendString = function(string) { + var bytes = new Buffer(string + "\0", "utf8"); + var data = []; + data.push(START_SYSEX); + data.push(STRING_DATA); + for (var i = 0, length = bytes.length; i < length; i++) { + data.push(bytes[i] & 0x7F); + data.push((bytes[i] >> 7) & 0x7F); + } + data.push(END_SYSEX); + this.transport.write(data); +}; + +function i2cRequest(board, buffer) { + + if (!i2cActive.get(board)) { + throw new Error("I2C is not enabled for this board. To enable, call the i2cConfig() method."); + } + + board.transport.write(buffer); +} + +/** + * Sends a I2C config request to the arduino board with an optional + * value in microseconds to delay an I2C Read. Must be called before + * an I2C Read or Write + * @param {number} delay in microseconds to set for I2C Read + */ + +Board.prototype.sendI2CConfig = function(delay) { + return this.i2cConfig(delay); +}; + +/** + * Enable I2C with an optional read delay. Must be called before + * an I2C Read or Write + * + * Supersedes sendI2CConfig + * + * @param {number} delay in microseconds to set for I2C Read + */ + +Board.prototype.i2cConfig = function(options) { + var delay; + + if (typeof options === "number") { + delay = options; + } else { + if (typeof options === "object" && options !== null) { + delay = options.delay; + } + } + + delay = delay || 0; + + i2cActive.set(this, true); + + i2cRequest(this, + new Buffer([ + START_SYSEX, + I2C_CONFIG, + delay & 0xFF, (delay >> 8) & 0xFF, + END_SYSEX + ]) + ); + + return this; +}; + +/** + * Asks the arduino to send an I2C request to a device + * @param {number} slaveAddress The address of the I2C device + * @param {Array} bytes The bytes to send to the device + */ + +Board.prototype.sendI2CWriteRequest = function(slaveAddress, bytes) { + var data = []; + bytes = bytes || []; + + data.push( + START_SYSEX, + I2C_REQUEST, + slaveAddress, + this.I2C_MODES.WRITE << 3 + ); + + for (var i = 0, length = bytes.length; i < length; i++) { + data.push( + bytes[i] & 0x7F, (bytes[i] >> 7) & 0x7F + ); + } + + data.push(END_SYSEX); + + i2cRequest(this, new Buffer(data)); +}; + +/** + * Write data to a register + * + * @param {number} address The address of the I2C device. + * @param {array} cmdRegOrData An array of bytes + * + * Write a command to a register + * + * @param {number} address The address of the I2C device. + * @param {number} cmdRegOrData The register + * @param {array} inBytes An array of bytes + * + */ +Board.prototype.i2cWrite = function(address, registerOrData, inBytes) { + /** + * registerOrData: + * [... arbitrary bytes] + * + * or + * + * registerOrData, inBytes: + * command [, ...] + * + */ + var bytes; + var data = [ + START_SYSEX, + I2C_REQUEST, + address, + this.I2C_MODES.WRITE << 3 + ]; + + + // If i2cWrite was used for an i2cWriteReg call... + if (arguments.length === 3 && + !Array.isArray(registerOrData) && + !Array.isArray(inBytes)) { + + return this.i2cWriteReg(address, registerOrData, inBytes); + } + + // Fix arguments if called with Firmata.js API + if (arguments.length === 2) { + if (Array.isArray(registerOrData)) { + inBytes = registerOrData.slice(); + registerOrData = inBytes.shift(); + } else { + inBytes = []; + } + } + + bytes = new Buffer([registerOrData].concat(inBytes)); + + for (var i = 0, length = bytes.length; i < length; i++) { + data.push( + bytes[i] & 0x7F, (bytes[i] >> 7) & 0x7F + ); + } + + data.push(END_SYSEX); + + i2cRequest(this, new Buffer(data)); + + return this; +}; + +/** + * Write data to a register + * + * @param {number} address The address of the I2C device. + * @param {number} register The register. + * @param {number} byte The byte value to write. + * + */ + +Board.prototype.i2cWriteReg = function(address, register, byte) { + i2cRequest(this, + new Buffer([ + START_SYSEX, + I2C_REQUEST, + address, + this.I2C_MODES.WRITE << 3, + // register + register & 0x7F, (register >> 7) & 0x7F, + // byte + byte & 0x7F, (byte >> 7) & 0x7F, + END_SYSEX + ]) + ); + + return this; +}; + + +/** + * Asks the arduino to request bytes from an I2C device + * @param {number} slaveAddress The address of the I2C device + * @param {number} numBytes The number of bytes to receive. + * @param {function} callback A function to call when we have received the bytes. + */ + +Board.prototype.sendI2CReadRequest = function(address, numBytes, callback) { + i2cRequest(this, + new Buffer([ + START_SYSEX, + I2C_REQUEST, + address, + this.I2C_MODES.READ << 3, + numBytes & 0x7F, (numBytes >> 7) & 0x7F, + END_SYSEX + ]) + ); + this.once("I2C-reply-" + address + "-0" , callback); +}; + +// TODO: Refactor i2cRead and i2cReadOnce +// to share most operations. + +/** + * Initialize a continuous I2C read. + * + * @param {number} address The address of the I2C device + * @param {number} register Optionally set the register to read from. + * @param {number} numBytes The number of bytes to receive. + * @param {function} callback A function to call when we have received the bytes. + */ + +Board.prototype.i2cRead = function(address, register, bytesToRead, callback) { + + if (arguments.length === 3 && + typeof register === "number" && + typeof bytesToRead === "function") { + callback = bytesToRead; + bytesToRead = register; + register = null; + } + + var event = "I2C-reply-" + address + "-"; + var data = [ + START_SYSEX, + I2C_REQUEST, + address, + this.I2C_MODES.CONTINUOUS_READ << 3, + ]; + + if (register !== null) { + data.push( + register & 0x7F, (register >> 7) & 0x7F + ); + } else { + register = 0; + } + + event += register; + + data.push( + bytesToRead & 0x7F, (bytesToRead >> 7) & 0x7F, + END_SYSEX + ); + + this.on(event, callback); + + i2cRequest(this, new Buffer(data)); + + return this; +}; + +/** + * Perform a single I2C read + * + * Supersedes sendI2CReadRequest + * + * Read bytes from address + * + * @param {number} address The address of the I2C device + * @param {number} register Optionally set the register to read from. + * @param {number} numBytes The number of bytes to receive. + * @param {function} callback A function to call when we have received the bytes. + * + */ + + +Board.prototype.i2cReadOnce = function(address, register, bytesToRead, callback) { + + if (arguments.length === 3 && + typeof register === "number" && + typeof bytesToRead === "function") { + callback = bytesToRead; + bytesToRead = register; + register = null; + } + + var event = "I2C-reply-" + address + "-"; + var data = [ + START_SYSEX, + I2C_REQUEST, + address, + this.I2C_MODES.READ << 3, + ]; + + if (register !== null) { + data.push( + register & 0x7F, (register >> 7) & 0x7F + ); + } else { + register = 0; + } + + event += register; + + data.push( + bytesToRead & 0x7F, (bytesToRead >> 7) & 0x7F, + END_SYSEX + ); + + this.once(event, callback); + + i2cRequest(this, new Buffer(data)); + + return this; +}; + +// CONTINUOUS_READ + +/** + * Configure the passed pin as the controller in a 1-wire bus. + * Pass as enableParasiticPower true if you want the data pin to power the bus. + * @param pin + * @param enableParasiticPower + */ +Board.prototype.sendOneWireConfig = function(pin, enableParasiticPower) { + this.transport.write(new Buffer([START_SYSEX, ONEWIRE_DATA, ONEWIRE_CONFIG_REQUEST, pin, enableParasiticPower ? 0x01 : 0x00, END_SYSEX])); +}; + +/** + * Searches for 1-wire devices on the bus. The passed callback should accept + * and error argument and an array of device identifiers. + * @param pin + * @param callback + */ +Board.prototype.sendOneWireSearch = function(pin, callback) { + this._sendOneWireSearch(ONEWIRE_SEARCH_REQUEST, "1-wire-search-reply-" + pin, pin, callback); +}; + +/** + * Searches for 1-wire devices on the bus in an alarmed state. The passed callback + * should accept and error argument and an array of device identifiers. + * @param pin + * @param callback + */ +Board.prototype.sendOneWireAlarmsSearch = function(pin, callback) { + this._sendOneWireSearch(ONEWIRE_SEARCH_ALARMS_REQUEST, "1-wire-search-alarms-reply-" + pin, pin, callback); +}; + +Board.prototype._sendOneWireSearch = function(type, event, pin, callback) { + this.transport.write(new Buffer([START_SYSEX, ONEWIRE_DATA, type, pin, END_SYSEX])); + + var searchTimeout = setTimeout(function() { + callback(new Error("1-Wire device search timeout - are you running ConfigurableFirmata?")); + }, 5000); + this.once(event, function(devices) { + clearTimeout(searchTimeout); + + callback(null, devices); + }); +}; + +/** + * Reads data from a device on the bus and invokes the passed callback. + * + * N.b. ConfigurableFirmata will issue the 1-wire select command internally. + * @param pin + * @param device + * @param numBytesToRead + * @param callback + */ +Board.prototype.sendOneWireRead = function(pin, device, numBytesToRead, callback) { + var correlationId = Math.floor(Math.random() * 255); + var readTimeout = setTimeout(function() { + callback(new Error("1-Wire device read timeout - are you running ConfigurableFirmata?")); + }, 5000); + this._sendOneWireRequest(pin, ONEWIRE_READ_REQUEST_BIT, device, numBytesToRead, correlationId, null, null, "1-wire-read-reply-" + correlationId, function(data) { + clearTimeout(readTimeout); + + callback(null, data); + }); +}; + +/** + * Resets all devices on the bus. + * @param pin + */ +Board.prototype.sendOneWireReset = function(pin) { + this._sendOneWireRequest(pin, ONEWIRE_RESET_REQUEST_BIT); +}; + +/** + * Writes data to the bus to be received by the passed device. The device + * should be obtained from a previous call to sendOneWireSearch. + * + * N.b. ConfigurableFirmata will issue the 1-wire select command internally. + * @param pin + * @param device + * @param data + */ +Board.prototype.sendOneWireWrite = function(pin, device, data) { + this._sendOneWireRequest(pin, ONEWIRE_WRITE_REQUEST_BIT, device, null, null, null, Array.isArray(data) ? data : [data]); +}; + +/** + * Tells firmata to not do anything for the passed amount of ms. For when you + * need to give a device attached to the bus time to do a calculation. + * @param pin + */ +Board.prototype.sendOneWireDelay = function(pin, delay) { + this._sendOneWireRequest(pin, ONEWIRE_DELAY_REQUEST_BIT, null, null, null, delay); +}; + +/** + * Sends the passed data to the passed device on the bus, reads the specified + * number of bytes and invokes the passed callback. + * + * N.b. ConfigurableFirmata will issue the 1-wire select command internally. + * @param pin + * @param device + * @param data + * @param numBytesToRead + * @param callback + */ +Board.prototype.sendOneWireWriteAndRead = function(pin, device, data, numBytesToRead, callback) { + var correlationId = Math.floor(Math.random() * 255); + var readTimeout = setTimeout(function() { + callback(new Error("1-Wire device read timeout - are you running ConfigurableFirmata?")); + }, 5000); + this._sendOneWireRequest(pin, ONEWIRE_WRITE_REQUEST_BIT | ONEWIRE_READ_REQUEST_BIT, device, numBytesToRead, correlationId, null, Array.isArray(data) ? data : [data], "1-wire-read-reply-" + correlationId, function(data) { + clearTimeout(readTimeout); + + callback(null, data); + }); +}; + +// see http://firmata.org/wiki/Proposals#OneWire_Proposal +Board.prototype._sendOneWireRequest = function(pin, subcommand, device, numBytesToRead, correlationId, delay, dataToWrite, event, callback) { + var bytes = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + + if (device || numBytesToRead || correlationId || delay || dataToWrite) { + subcommand = subcommand | ONEWIRE_WITHDATA_REQUEST_BITS; + } + + if (device) { + bytes.splice.apply(bytes, [0, 8].concat(device)); + } + + if (numBytesToRead) { + bytes[8] = numBytesToRead & 0xFF; + bytes[9] = (numBytesToRead >> 8) & 0xFF; + } + + if (correlationId) { + bytes[10] = correlationId & 0xFF; + bytes[11] = (correlationId >> 8) & 0xFF; + } + + if (delay) { + bytes[12] = delay & 0xFF; + bytes[13] = (delay >> 8) & 0xFF; + bytes[14] = (delay >> 16) & 0xFF; + bytes[15] = (delay >> 24) & 0xFF; + } + + if (dataToWrite) { + dataToWrite.forEach(function(byte) { + bytes.push(byte); + }); + } + + var output = [START_SYSEX, ONEWIRE_DATA, subcommand, pin]; + output = output.concat(Encoder7Bit.to7BitArray(bytes)); + output.push(END_SYSEX); + + this.transport.write(new Buffer(output)); + + if (event && callback) { + this.once(event, callback); + } +}; + +/** + * Set sampling interval in millis. Default is 19 ms + * @param {number} interval The sampling interval in ms > 10 + */ + +Board.prototype.setSamplingInterval = function(interval) { + var safeint = interval < 10 ? 10 : (interval > 65535 ? 65535 : interval); // constrained + this.settings.samplingInterval = safeint; + this.transport.write(new Buffer([START_SYSEX, SAMPLING_INTERVAL, (safeint & 0x7F), ((safeint >> 7) & 0x7F), END_SYSEX])); +}; + +/** + * Get sampling interval in millis. Default is 19 ms + */ + +Board.prototype.getSamplingInterval = function(interval) { + return this.settings.samplingInterval; +}; + +/** + * Set reporting on pin + * @param {number} pin The pin to turn on/off reporting + * @param {number} value Binary value to turn reporting on/off + */ + +Board.prototype.reportAnalogPin = function(pin, value) { + if (value === 0 || value === 1) { + this.pins[this.analogPins[pin]].report = value; + this.transport.write(new Buffer([REPORT_ANALOG | pin, value])); + } +}; + +/** + * Set reporting on pin + * @param {number} pin The pin to turn on/off reporting + * @param {number} value Binary value to turn reporting on/off + */ + +Board.prototype.reportDigitalPin = function(pin, value) { + var port = Math.floor(pin / 8); + if (value === 0 || value === 1) { + this.pins[pin].report = value; + this.transport.write(new Buffer([REPORT_DIGITAL | port, value])); + } +}; + +/** + * + * + */ + +Board.prototype.pingRead = function(opts, callback) { + var pin = opts.pin; + var value = opts.value; + var pulseOut = opts.pulseOut || 0; + var timeout = opts.timeout || 1000000; + var pulseOutArray = [ + ((pulseOut >> 24) & 0xFF), ((pulseOut >> 16) & 0xFF), ((pulseOut >> 8) & 0XFF), ((pulseOut & 0xFF)) + ]; + var timeoutArray = [ + ((timeout >> 24) & 0xFF), ((timeout >> 16) & 0xFF), ((timeout >> 8) & 0XFF), ((timeout & 0xFF)) + ]; + var data = [ + START_SYSEX, + PING_READ, + pin, + value, + pulseOutArray[0] & 0x7F, (pulseOutArray[0] >> 7) & 0x7F, + pulseOutArray[1] & 0x7F, (pulseOutArray[1] >> 7) & 0x7F, + pulseOutArray[2] & 0x7F, (pulseOutArray[2] >> 7) & 0x7F, + pulseOutArray[3] & 0x7F, (pulseOutArray[3] >> 7) & 0x7F, + timeoutArray[0] & 0x7F, (timeoutArray[0] >> 7) & 0x7F, + timeoutArray[1] & 0x7F, (timeoutArray[1] >> 7) & 0x7F, + timeoutArray[2] & 0x7F, (timeoutArray[2] >> 7) & 0x7F, + timeoutArray[3] & 0x7F, (timeoutArray[3] >> 7) & 0x7F, + END_SYSEX + ]; + this.transport.write(new Buffer(data)); + this.once("ping-read-" + pin, callback); +}; + +/** + * Stepper functions to support AdvancedFirmata"s asynchronous control of stepper motors + * https://github.com/soundanalogous/AdvancedFirmata + */ + +/** + * Asks the arduino to configure a stepper motor with the given config to allow asynchronous control of the stepper + * @param {number} deviceNum Device number for the stepper (range 0-5, expects steppers to be setup in order from 0 to 5) + * @param {number} type One of this.STEPPER.TYPE.* + * @param {number} stepsPerRev Number of steps motor takes to make one revolution + * @param {number} dirOrMotor1Pin If using EasyDriver type stepper driver, this is direction pin, otherwise it is motor 1 pin + * @param {number} stepOrMotor2Pin If using EasyDriver type stepper driver, this is step pin, otherwise it is motor 2 pin + * @param {number} [motor3Pin] Only required if type == this.STEPPER.TYPE.FOUR_WIRE + * @param {number} [motor4Pin] Only required if type == this.STEPPER.TYPE.FOUR_WIRE + */ + +Board.prototype.stepperConfig = function(deviceNum, type, stepsPerRev, dirOrMotor1Pin, stepOrMotor2Pin, motor3Pin, motor4Pin) { + var data = [ + START_SYSEX, + STEPPER, + 0x00, // STEPPER_CONFIG from firmware + deviceNum, + type, + stepsPerRev & 0x7F, (stepsPerRev >> 7) & 0x7F, + dirOrMotor1Pin, + stepOrMotor2Pin + ]; + if (type === this.STEPPER.TYPE.FOUR_WIRE) { + data.push(motor3Pin, motor4Pin); + } + data.push(END_SYSEX); + this.transport.write(new Buffer(data)); +}; + +/** + * Asks the arduino to move a stepper a number of steps at a specific speed + * (and optionally with and acceleration and deceleration) + * speed is in units of .01 rad/sec + * accel and decel are in units of .01 rad/sec^2 + * TODO: verify the units of speed, accel, and decel + * @param {number} deviceNum Device number for the stepper (range 0-5) + * @param {number} direction One of this.STEPPER.DIRECTION.* + * @param {number} steps Number of steps to make + * @param {number} speed + * @param {number|function} accel Acceleration or if accel and decel are not used, then it can be the callback + * @param {number} [decel] + * @param {function} [callback] + */ + +Board.prototype.stepperStep = function(deviceNum, direction, steps, speed, accel, decel, callback) { + if (typeof accel === "function") { + callback = accel; + accel = 0; + decel = 0; + } + + var data = [ + START_SYSEX, + STEPPER, + 0x01, // STEPPER_STEP from firmware + deviceNum, + direction, // one of this.STEPPER.DIRECTION.* + steps & 0x7F, (steps >> 7) & 0x7F, (steps >> 14) & 0x7f, + speed & 0x7F, (speed >> 7) & 0x7F + ]; + if (accel > 0 || decel > 0) { + data.push( + accel & 0x7F, (accel >> 7) & 0x7F, + decel & 0x7F, (decel >> 7) & 0x7F + ); + } + data.push(END_SYSEX); + this.transport.write(new Buffer(data)); + this.once("stepper-done-" + deviceNum, callback); +}; + +/** + * Send SYSTEM_RESET to arduino + */ + +Board.prototype.reset = function() { + this.transport.write(new Buffer([SYSTEM_RESET])); +}; + +// For backwards compatibility +Board.Board = Board; +Board.SYSEX_RESPONSE = SYSEX_RESPONSE; +Board.MIDI_RESPONSE = MIDI_RESPONSE; + +module.exports = Board; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/onewireutils.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/onewireutils.js new file mode 100644 index 0000000..727ef07 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/lib/onewireutils.js @@ -0,0 +1,48 @@ +var Encoder7Bit = require("./encoder7bit"); + +var OneWireUtils = { + crc8: function(data) { + var crc = 0; + + for (var i = 0; i < data.length; i++) { + var inbyte = data[i]; + + for (var n = 8; n; n--) { + var mix = (crc ^ inbyte) & 0x01; + crc >>= 1; + + if (mix) { + crc ^= 0x8C; + } + + inbyte >>= 1; + } + } + return crc; + }, + + readDevices: function(data) { + var deviceBytes = Encoder7Bit.from7BitArray(data); + var devices = []; + + for (var i = 0; i < deviceBytes.length; i += 8) { + var device = deviceBytes.slice(i, i + 8); + + if (device.length !== 8) { + continue; + } + + var check = OneWireUtils.crc8(device.slice(0, 7)); + + if (check !== device[7]) { + console.error("ROM invalid!"); + } + + devices.push(device); + } + + return devices; + } +}; + +module.exports = OneWireUtils; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.jshintrc new file mode 100644 index 0000000..468cce0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.jshintrc @@ -0,0 +1,11 @@ +{ + "node": true, + "browser": true, + "debug": true, + "mocha": true, + "undef": true, + "unused": true, + "predef": [ + "chrome" + ] +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.npmignore new file mode 100644 index 0000000..0de689e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/.npmignore @@ -0,0 +1,4 @@ +demo +demoPacked +gulpfile.js +Makefile diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/LICENSE.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/LICENSE.md new file mode 100644 index 0000000..e9c4840 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Glen Arrowsmith + +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. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/README.md new file mode 100644 index 0000000..a4f85a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/README.md @@ -0,0 +1,147 @@ +# browser-serialport + +Robots in the browser. Just like [node-serialport](https://npmjs.org/package/serialport) but for browser apps. + + +## Why not Node.js? + +[Nodebots](http://nodebots.io/) are awesome but HTML5 apps have access to a lot of APIs that make sense for robotics like the [GamepadAPI](http://www.html5rocks.com/en/tutorials/doodles/gamepad/), [WebRTC Video and Data](http://www.webrtc.org/), [Web Speech API](http://www.google.com/intl/en/chrome/demos/speech.html), etc. Also you get a nice GUI and its easier to run. I have also made a fork of [Johnny-Five](https://github.com/garrows/johnny-five) to work with [Browserify](http://browserify.org/) as well by modifying it's dependancy [Firmata](https://github.com/garrows/firmata) to use browser-serialport. + +## Restrictions + +You will not be able to add this to your normal website. + +This library only works in a [Chrome Packaged App](http://developer.chrome.com/apps/about_apps.html) as this is the only way to get access to the [serial ports API](http://developer.chrome.com/apps/serial.html) in the browser. + +If you want help making your first Chrome App, read the ["Create Your First App"](http://developer.chrome.com/apps/first_app.html) tutorial. + +There is currently no Firefox extension support but that might come soon if possible. + + +Known incompatibilities with node-serialport +------------------------------------------- +* Parsers not implemented +* Inconsistent error messages +* Chrome has a slightly different options set: + * __dataBits__: 7, 8 + * __stopBits__: 1, 2 + * __parity__: 'none', 'even', 'mark', 'odd', 'space' + * __flowControl__: 'RTSCTS' + + +## Installation + +``` +npm install browser-serialport +``` + +To Use +------ + +Opening a serial port: + +```js +var SerialPort = require("browser-serialport").SerialPort +var serialPort = new SerialPort("/dev/tty-usbserial1", { + baudrate: 57600 +}); +``` + +When opening a serial port, you can specify (in this order). + +1. Path to Serial Port - required. +1. Options - optional and described below. + +The options object allows you to pass named options to the serial port during initialization. The valid attributes for the options object are the following: + +* baudrate: Baud Rate, defaults to 9600. Should be one of: 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 1200, 600, 300, 200, 150, 134, 110, 75, or 50. Custom rates as allowed by hardware is supported. +* databits: Data Bits, defaults to 8. Must be one of: 8, 7, ~~6~~, or ~~5~~. +* stopbits: Stop Bits, defaults to 1. Must be one of: 1 or 2. +* parity: Parity, defaults to 'none'. Must be one of: 'none', 'even', 'mark', 'odd', 'space' +* buffersize: Size of read buffer, defaults to 255. Must be an integer value. +* parser: The parser engine to use with read data, defaults to rawPacket strategy which just emits the raw buffer as a "data" event. Can be any function that accepts EventEmitter as first parameter and the raw buffer as the second parameter. + +**Note, we have added support for either all lowercase OR camelcase of the options (thanks @jagautier), use whichever style you prefer.** + +open event +---------- + +You MUST wait for the open event to be emitted before reading/writing to the serial port. The open happens asynchronously so installing 'data' listeners and writing +before the open event might result in... nothing at all. + +Assuming you are connected to a serial console, you would for example: + +```js +serialPort.on("open", function () { + console.log('open'); + serialPort.on('data', function(data) { + console.log('data received: ' + data); + }); + serialPort.write("ls\n", function(err, results) { + console.log('err ' + err); + console.log('results ' + results); + }); +}); +``` + +You can also call the open function, in this case instanciate the serialport with an additional flag. + +```js +var SerialPort = require("browser-serialport").SerialPort +var serialPort = new SerialPort("/dev/tty-usbserial1", { + baudrate: 57600 +}, false); // this is the openImmediately flag [default is true] + +serialPort.open(function (error) { + if ( error ) { + console.log('failed to open: '+error); + } else { + console.log('open'); + serialPort.on('data', function(data) { + console.log('data received: ' + data); + }); + serialPort.write("ls\n", function(err, results) { + console.log('err ' + err); + console.log('results ' + results); + }); + } +}); +``` + +List Ports +---------- + +You can also list the ports along with some metadata as well. + +```js +var serialPort = require("browser-serialport"); +serialPort.list(function (err, ports) { + ports.forEach(function(port) { + console.log(port.comName); + console.log(port.pnpId); + console.log(port.manufacturer); + }); +}); +``` + +Parsers +------- + +Browser-serialport doesn't as of 2.0.0 support parsers. + + +You can get updates of new data from the Serial Port as follows: + +```js +serialPort.on("data", function (data) { + sys.puts("here: "+data); +}); +``` + +You can write to the serial port by sending a string or buffer to the write method as follows: + +```js +serialPort.write("OMG IT WORKS\r"); +``` + +Enjoy and do cool things with this code. diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/index.js new file mode 100644 index 0000000..81982c6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/index.js @@ -0,0 +1,419 @@ +'use strict'; + +var EE = require('events').EventEmitter; +var util = require('util'); + +var DATABITS = [7, 8]; +var STOPBITS = [1, 2]; +var PARITY = ['none', 'even', 'mark', 'odd', 'space']; +var FLOWCONTROLS = ['RTSCTS']; + +var _options = { + baudrate: 9600, + parity: 'none', + rtscts: false, + databits: 8, + stopbits: 1, + buffersize: 256 +}; + +function convertOptions(options){ + switch (options.dataBits) { + case 7: + options.dataBits = 'seven'; + break; + case 8: + options.dataBits = 'eight'; + break; + } + + switch (options.stopBits) { + case 1: + options.stopBits = 'one'; + break; + case 2: + options.stopBits = 'two'; + break; + } + + switch (options.parity) { + case 'none': + options.parity = 'no'; + break; + } + + return options; +} + +function SerialPort(path, options, openImmediately, callback) { + + EE.call(this); + + var self = this; + + var args = Array.prototype.slice.call(arguments); + callback = args.pop(); + if (typeof(callback) !== 'function') { + callback = null; + } + + options = (typeof options !== 'function') && options || {}; + + openImmediately = (openImmediately === undefined || openImmediately === null) ? true : openImmediately; + + callback = callback || function (err) { + if (err) { + self.emit('error', err); + } + }; + + var err; + + options.baudRate = options.baudRate || options.baudrate || _options.baudrate; + + options.dataBits = options.dataBits || options.databits || _options.databits; + if (DATABITS.indexOf(options.dataBits) === -1) { + err = new Error('Invalid "databits": ' + options.dataBits); + callback(err); + return; + } + + options.stopBits = options.stopBits || options.stopbits || _options.stopbits; + if (STOPBITS.indexOf(options.stopBits) === -1) { + err = new Error('Invalid "stopbits": ' + options.stopbits); + callback(err); + return; + } + + options.parity = options.parity || _options.parity; + if (PARITY.indexOf(options.parity) === -1) { + err = new Error('Invalid "parity": ' + options.parity); + callback(err); + return; + } + + if (!path) { + err = new Error('Invalid port specified: ' + path); + callback(err); + return; + } + + options.rtscts = _options.rtscts; + + if (options.flowControl || options.flowcontrol) { + var fc = options.flowControl || options.flowcontrol; + + if (typeof fc === 'boolean') { + options.rtscts = true; + } else { + var clean = fc.every(function (flowControl) { + var fcup = flowControl.toUpperCase(); + var idx = FLOWCONTROLS.indexOf(fcup); + if (idx < 0) { + var err = new Error('Invalid "flowControl": ' + fcup + '. Valid options: ' + FLOWCONTROLS.join(', ')); + callback(err); + return false; + } else { + + // "XON", "XOFF", "XANY", "DTRDTS", "RTSCTS" + switch (idx) { + case 0: options.rtscts = true; break; + } + return true; + } + }); + if(!clean){ + return; + } + } + } + + options.bufferSize = options.bufferSize || options.buffersize || _options.buffersize; + + // defaults to chrome.serial if no options.serial passed + // inlined instead of on _options to allow mocking global chrome.serial for optional options test + options.serial = options.serial || (typeof chrome !== 'undefined' && chrome.serial); + + if (!options.serial) { + throw new Error('No access to serial ports. Try loading as a Chrome Application.'); + } + + this.options = convertOptions(options); + + this.options.serial.onReceiveError.addListener(function(info){ + + switch (info.error) { + + case 'disconnected': + case 'device_lost': + case 'system_error': + err = new Error('Disconnected'); + // send notification of disconnect + if (self.options.disconnectedCallback) { + self.options.disconnectedCallback(err); + } else { + self.emit('disconnect', err); + } + self.connectionId = -1; + self.emit('close'); + self.removeAllListeners(); + break; + case 'timeout': + break; + } + + }); + + this.path = path; + + if (openImmediately) { + process.nextTick(function () { + self.open(callback); + }); + } +} + +util.inherits(SerialPort, EE); + +SerialPort.prototype.connectionId = -1; + +SerialPort.prototype.open = function (callback) { + var options = { + bitrate: parseInt(this.options.baudRate, 10), + dataBits: this.options.dataBits, + parityBit: this.options.parity, + stopBits: this.options.stopBits, + ctsFlowControl: this.options.rtscts + }; + + this.options.serial.connect(this.path, options, this.proxy('onOpen', callback)); +}; + +SerialPort.prototype.onOpen = function (callback, openInfo) { + if(chrome.runtime.lastError){ + if(typeof callback === 'function'){ + callback(chrome.runtime.lastError); + }else{ + this.emit('error', chrome.runtime.lastError); + } + return; + } + + this.connectionId = openInfo.connectionId; + + if (this.connectionId === -1) { + this.emit('error', new Error('Could not open port.')); + return; + } + + this.emit('open', openInfo); + + this._reader = this.proxy('onRead'); + + this.options.serial.onReceive.addListener(this._reader); + + if(typeof callback === 'function'){ + callback(chrome.runtime.lastError, openInfo); + } +}; + +SerialPort.prototype.onRead = function (readInfo) { + if (readInfo && this.connectionId === readInfo.connectionId) { + + if (this.options.dataCallback) { + this.options.dataCallback(toBuffer(readInfo.data)); + } else { + this.emit('data', toBuffer(readInfo.data)); + } + + } +}; + +SerialPort.prototype.write = function (buffer, callback) { + if (this.connectionId < 0) { + var err = new Error('Serialport not open.'); + if(typeof callback === 'function'){ + callback(err); + }else{ + this.emit('error', err); + } + return; + } + + if (typeof buffer === 'string') { + buffer = str2ab(buffer); + } + + //Make sure its not a browserify faux Buffer. + if (buffer instanceof ArrayBuffer === false) { + buffer = buffer2ArrayBuffer(buffer); + } + + this.options.serial.send(this.connectionId, buffer, function(info) { + if (typeof callback === 'function') { + callback(chrome.runtime.lastError, info); + } + }); +}; + + +SerialPort.prototype.close = function (callback) { + if (this.connectionId < 0) { + var err = new Error('Serialport not open.'); + if(typeof callback === 'function'){ + callback(err); + }else{ + this.emit('error', err); + } + return; + } + + this.options.serial.disconnect(this.connectionId, this.proxy('onClose', callback)); +}; + +SerialPort.prototype.onClose = function (callback, result) { + this.connectionId = -1; + this.emit('close'); + + this.removeAllListeners(); + if(this._reader){ + this.options.serial.onReceive.removeListener(this._reader); + this._reader = null; + } + + if (typeof callback === 'function') { + callback(chrome.runtime.lastError, result); + } +}; + +SerialPort.prototype.flush = function (callback) { + if (this.connectionId < 0) { + var err = new Error('Serialport not open.'); + if(typeof callback === 'function'){ + callback(err); + }else{ + this.emit('error', err); + } + return; + } + + var self = this; + + this.options.serial.flush(this.connectionId, function(result) { + if (chrome.runtime.lastError) { + if (typeof callback === 'function') { + callback(chrome.runtime.lastError, result); + } else { + self.emit('error', chrome.runtime.lastError); + } + return; + } else { + callback(null, result); + } + }); +}; + +SerialPort.prototype.drain = function (callback) { + if (this.connectionId < 0) { + var err = new Error('Serialport not open.'); + if(typeof callback === 'function'){ + callback(err); + }else{ + this.emit('error', err); + } + return; + } + + if (typeof callback === 'function') { + callback(); + } +}; + + +SerialPort.prototype.proxy = function () { + var self = this; + var proxyArgs = []; + + //arguments isnt actually an array. + for (var i = 0; i < arguments.length; i++) { + proxyArgs[i] = arguments[i]; + } + + var functionName = proxyArgs.splice(0, 1)[0]; + + var func = function() { + var funcArgs = []; + for (var i = 0; i < arguments.length; i++) { + funcArgs[i] = arguments[i]; + } + var allArgs = proxyArgs.concat(funcArgs); + + self[functionName].apply(self, allArgs); + }; + + return func; +}; + +SerialPort.prototype.set = function (options, callback) { + this.options.serial.setControlSignals(this.connectionId, options, function(result){ + callback(chrome.runtime.lastError, result); + }); +}; + +function SerialPortList(callback) { + if (typeof chrome != 'undefined' && chrome.serial) { + chrome.serial.getDevices(function(ports) { + var portObjects = new Array(ports.length); + for (var i = 0; i < ports.length; i++) { + portObjects[i] = { + comName: ports[i].path, + manufacturer: ports[i].displayName, + serialNumber: '', + pnpId: '', + locationId:'', + vendorId: '0x' + (ports[i].vendorId||0).toString(16), + productId: '0x' + (ports[i].productId||0).toString(16) + }; + } + callback(chrome.runtime.lastError, portObjects); + }); + } else { + callback(new Error('No access to serial ports. Try loading as a Chrome Application.'), null); + } +} + +// Convert string to ArrayBuffer +function str2ab(str) { + var buf = new ArrayBuffer(str.length); + var bufView = new Uint8Array(buf); + for (var i = 0; i < str.length; i++) { + bufView[i] = str.charCodeAt(i); + } + return buf; +} + +// Convert buffer to ArrayBuffer +function buffer2ArrayBuffer(buffer) { + var buf = new ArrayBuffer(buffer.length); + var bufView = new Uint8Array(buf); + for (var i = 0; i < buffer.length; i++) { + bufView[i] = buffer[i]; + } + return buf; +} + +function toBuffer(ab) { + var buffer = new Buffer(ab.byteLength); + var view = new Uint8Array(ab); + for (var i = 0; i < buffer.length; ++i) { + buffer[i] = view[i]; + } + return buffer; +} + +module.exports = { + SerialPort: SerialPort, + list: SerialPortList, + buffer2ArrayBuffer: buffer2ArrayBuffer, + used: [] //TODO: Populate this somewhere. +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/package.json new file mode 100644 index 0000000..7c7fa44 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/package.json @@ -0,0 +1,71 @@ +{ + "name": "browser-serialport", + "version": "2.0.2", + "description": "Robots in the browser. Just like node-serialport but for browser/chrome apps.", + "main": "index.js", + "browser": "./index.js", + "dependencies": {}, + "devDependencies": { + "chai": "^1.10.0", + "jshint": "^2.5.11", + "lodash": "^3.6.0", + "mocha": "^2.1.0", + "sinon": "^1.12.2", + "sinon-chai": "^2.6.0" + }, + "scripts": { + "test": "jshint index.js && mocha" + }, + "repository": { + "type": "git", + "url": "git://github.com/garrows/browser-serialport" + }, + "keywords": [ + "serial", + "firmata", + "nodebots", + "chromebots", + "browserbots", + "robot", + "robots" + ], + "author": { + "name": "Glen Arrowsmith @garrows" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/garrows/browser-serialport/issues" + }, + "gitHead": "3d933bfd754531db7307b5e89ee9ac7e44a8cfc1", + "homepage": "https://github.com/garrows/browser-serialport", + "_id": "browser-serialport@2.0.2", + "_shasum": "3b861d6b0cb760d57f4d97b6ba0877e69fd074cb", + "_from": "browser-serialport@*", + "_npmVersion": "2.6.0", + "_nodeVersion": "0.10.36", + "_npmUser": { + "name": "phated", + "email": "blaine@iceddev.com" + }, + "maintainers": [ + { + "name": "garrows", + "email": "glen.arrowsmith@gmail.com" + }, + { + "name": "phated", + "email": "blaine@iceddev.com" + }, + { + "name": "jjrosent", + "email": "jakerosenthal@gmail.com" + } + ], + "dist": { + "shasum": "3b861d6b0cb760d57f4d97b6ba0877e69fd074cb", + "tarball": "http://registry.npmjs.org/browser-serialport/-/browser-serialport-2.0.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/browser-serialport/-/browser-serialport-2.0.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/parsers.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/parsers.js new file mode 100644 index 0000000..d024c7a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/parsers.js @@ -0,0 +1,47 @@ +"use strict"; + +var chai = require('chai'); +var expect = chai.expect; +var sinonChai = require("sinon-chai"); +var sinon = require("sinon"); +chai.use(sinonChai); + +// var parsers = require('../parsers'); + +describe.skip("parsers", function () { + + describe("#raw", function () { + it("emits data exactly as it's written", function () { + var data = new Buffer("BOGUS"); + var spy = sinon.spy(); + parsers.raw({ emit: spy }, data); + expect(spy.getCall(0).args[1]).to.deep.equal(new Buffer("BOGUS")); + }); + }); + + describe("#readline", function () { + it("emits data events split on a delimiter", function () { + var data = new Buffer("I love robots\rEach and Every One\r"); + var spy = sinon.spy(); + var parser = parsers.readline(); + parser({ emit: spy }, data); + expect(spy).to.have.been.calledWith("data", "I love robots"); + expect(spy).to.have.been.calledWith("data", "Each and Every One"); + }); + }); + + describe('#byteLength', function(){ + it("emits data events every 8 bytes", function () { + var data = new Buffer("Robots are so freaking cool!"); + var spy = sinon.spy(); + var parser = parsers.byteLength(8); + parser({ emit: spy }, data); + expect(spy.callCount).to.equal(3); + expect(spy.getCall(0).args[1].length).to.equal(8); + expect(spy.getCall(0).args[1]).to.deep.equal(new Buffer("Robots a")); + expect(spy.getCall(1).args[1]).to.deep.equal(new Buffer("re so fr")); + expect(spy.getCall(2).args[1]).to.deep.equal(new Buffer("eaking c")); + }); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/serialport-basic.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/serialport-basic.js new file mode 100644 index 0000000..e58a127 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/browser-serialport/test/serialport-basic.js @@ -0,0 +1,434 @@ +'use strict'; + +var sinon = require('sinon'); +var chai = require('chai'); +var without = require('lodash/array/without'); +var expect = chai.expect; + +var MockedSerialPort = require('../'); +var SerialPort = MockedSerialPort.SerialPort; + +var options; + +function unset(msg){ + return function(){ + throw new Error(msg); + }; +} + +var serialListeners = []; + +var hardware = { + ports: {}, + createPort: function(path){ + this.ports[path] = true; + }, + reset: function(){ + this.ports = {}; + this.onReceive = unset('onreceive unset'); + this.onReceiveError = unset('onReceiveError unset'); + }, + onReceive: unset('onReceive unset'), + onReceiveError: unset('onReceiveError unset'), + emitData: function(buffer){ + process.nextTick(function(){ + var readInfo = {data: MockedSerialPort.buffer2ArrayBuffer(buffer), connectionId: 1}; + serialListeners.forEach(function(cb){ + cb(readInfo); + }); + }); + }, + disconnect: function(path){ + this.ports[path] = false; + var info = {error: 'disconnected', connectionId: 1}; + this.onReceiveError(info); + }, + timeout: function(path){ + this.ports[path] = false; + var info = {error: 'timeout', connectionId: 1}; + this.onReceiveError(info); + }, + loseDevice: function(path){ + this.ports[path] = false; + var info = {error: 'device_lost', connectionId: 1}; + this.onReceiveError(info); + }, + systemError: function(path){ + this.ports[path] = false; + var info = {error: 'system_error', connectionId: 1}; + this.onReceiveError(info); + } +}; + +describe('SerialPort', function () { + var sandbox; + + beforeEach(function () { + sandbox = sinon.sandbox.create(); + + global.chrome = { runtime: { lastError: null } }; + + serialListeners = []; + + options = { + serial: { + connect: function(path, options, cb){ + if (!hardware.ports[path]) { + global.chrome.runtime.lastError = new Error({message: 'Failed to connect to the port.'}); + } + + chai.assert.ok(options.bitrate, 'baudrate not set'); + chai.assert.ok(options.dataBits, 'databits not set'); + chai.assert.ok(options.parityBit, 'parity not set'); + chai.assert.ok(options.stopBits, 'stopbits not set'); + chai.assert.isBoolean(options.ctsFlowControl, 'flowcontrol not set'); + + cb({ + bitrate: 9600, + bufferSize: 4096, + connectionId: 1, + ctsFlowControl: true, + dataBits: 'eight', + name: '', + parityBit: 'no', + paused: false, + persistent: false, + receiveTimeout: 0, + sendTimeout: 0, + stopBits: 'one' + }); + }, + onReceive: { + addListener: function(cb){ + serialListeners.push(cb); + }, + removeListener: function(cb){ + serialListeners = without(serialListeners, cb); + } + }, + onReceiveError: { + addListener: function(cb){ + hardware.onReceiveError = cb; + } + }, + send: function(connectionId, buffer, cb){ + + }, + disconnect: function(connectionId, cb){ + cb(); + }, + setControlSignals: function(connectionId, options, cb){ + cb(); + } + } + }; + // Create a port for fun and profit + hardware.reset(); + hardware.createPort('/dev/exists'); + }); + + afterEach(function () { + options = null; + + sandbox.restore(); + }); + + describe('Constructor', function () { + it('opens the port immediately', function (done) { + var port = new SerialPort('/dev/exists', options, function (err) { + expect(err).to.not.be.ok; + done(); + }); + }); + + it('emits the open event', function (done) { + var port = new SerialPort('/dev/exists', options); + port.on('open', function(){ + done(); + }); + }); + + it.skip('emits an error on the factory when erroring without a callback', function (done) { + // finish the test on error + MockedSerialPort.once('error', function (err) { + chai.assert.isDefined(err, 'didn\'t get an error'); + done(); + }); + + var port = new SerialPort('/dev/johnJacobJingleheimerSchmidt'); + }); + + it('emits an error on the serialport when explicit error handler present', function (done) { + var port = new SerialPort('/dev/johnJacobJingleheimerSchmidt', options); + + port.once('error', function(err) { + chai.assert.isDefined(err); + done(); + }); + }); + + it('errors with invalid databits', function (done) { + var errorCallback = function (err) { + chai.assert.isDefined(err, 'err is not defined'); + done(); + }; + + var port = new SerialPort('/dev/exists', { databits : 19 }, false, errorCallback); + }); + + it('errors with invalid stopbits', function (done) { + var errorCallback = function (err) { + chai.assert.isDefined(err, 'err is not defined'); + done(); + }; + + var port = new SerialPort('/dev/exists', { stopbits : 19 }, false, errorCallback); + }); + + it('errors with invalid parity', function (done) { + var errorCallback = function (err) { + chai.assert.isDefined(err, 'err is not defined'); + done(); + }; + + var port = new SerialPort('/dev/exists', { parity : 'pumpkins' }, false, errorCallback); + }); + + it('errors with invalid flow control', function (done) { + var errorCallback = function (err) { + chai.assert.isDefined(err, 'err is not defined'); + done(); + }; + + var port = new SerialPort('/dev/exists', { flowcontrol : ['pumpkins'] }, false, errorCallback); + }); + + it('errors with invalid path', function (done) { + var errorCallback = function (err) { + chai.assert.isDefined(err, 'err is not defined'); + done(); + }; + + var port = new SerialPort(null, false, errorCallback); + }); + + it('allows optional options', function (done) { + global.chrome.serial = options.serial; + var cb = function () {}; + var port = new SerialPort('/dev/exists', cb); + // console.log(port); + expect(typeof port.options).to.eq('object'); + delete global.chrome.serial; + done(); + }); + + }); + + describe('Functions', function () { + + it('write errors when serialport not open', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', options, false, cb); + port.write(null, function(err){ + chai.assert.isDefined(err, 'err is not defined'); + done(); + }); + }); + + it('close errors when serialport not open', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', options, false, cb); + port.close(function(err){ + chai.assert.isDefined(err, 'err is not defined'); + done(); + }); + }); + + it('flush errors when serialport not open', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', options, false, cb); + port.flush(function(err){ + chai.assert.isDefined(err, 'err is not defined'); + done(); + }); + }); + + it('set errors when serialport not open', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', options, false, cb); + port.set({}, function(err){ + chai.assert.isDefined(err, 'err is not defined'); + done(); + }); + }); + + it('drain errors when serialport not open', function (done) { + var cb = function () {}; + var port = new SerialPort('/dev/exists', options, false, cb); + port.drain(function(err){ + chai.assert.isDefined(err, 'err is not defined'); + done(); + }); + }); + + }); + + describe('reading data', function () { + + it('emits data events by default', function (done) { + var testData = new Buffer('I am a really short string'); + var port = new SerialPort('/dev/exists', options, function () { + port.once('data', function(recvData) { + expect(recvData).to.eql(testData); + done(); + }); + hardware.emitData(testData); + }); + }); + + it('calls the dataCallback if set', function (done) { + var testData = new Buffer('I am a really short string'); + options.dataCallback = function (recvData) { + expect(recvData).to.eql(testData); + done(); + }; + + var port = new SerialPort('/dev/exists', options, function () { + hardware.emitData(testData); + }); + }); + + }); + + describe('#open', function () { + + it('passes the port to the bindings', function (done) { + var openSpy = sandbox.spy(options.serial, 'connect'); + var port = new SerialPort('/dev/exists', options, false); + port.open(function (err) { + expect(err).to.not.be.ok; + expect(openSpy.calledWith('/dev/exists')); + done(); + }); + }); + + it('calls back an error when opening an invalid port', function (done) { + var port = new SerialPort('/dev/unhappy', options, false); + port.open(function (err) { + expect(err).to.be.ok; + done(); + }); + }); + + it('emits data after being reopened', function (done) { + var data = new Buffer('Howdy!'); + var port = new SerialPort('/dev/exists', options, function () { + port.close(function () { + port.open(function () { + port.once('data', function (res) { + expect(res).to.eql(data); + done(); + }); + hardware.emitData(data); + }); + }); + }); + }); + + it('does not emit data twice if reopened', function (done) { + var data = new Buffer('Howdy!'); + var port = new SerialPort('/dev/exists', options, function () { + port.close(function () { + port.open(function () { + var count = 0; + port.on('data', function (res) { + count++; + }); + hardware.emitData(data); + + setTimeout(function(){ + expect(count).to.equal(1); + done(); + }, 200); + }); + }); + }); + }); + }); + + describe('#send', function () { + + it('errors when writing a closed port', function (done) { + var port = new SerialPort('/dev/exists', options, false); + port.write(new Buffer(''), function(err){ + expect(err).to.be.ok; + done(); + }); + }); + + }); + + describe('close', function () { + it('fires a close event when it\'s closed', function (done) { + var port = new SerialPort('/dev/exists', options, function () { + var closeSpy = sandbox.spy(); + port.on('close', closeSpy); + port.close(); + expect(closeSpy.calledOnce); + done(); + }); + }); + + it('fires a close event after being reopened', function (done) { + var port = new SerialPort('/dev/exists', options, function () { + var closeSpy = sandbox.spy(); + port.on('close', closeSpy); + port.close(); + port.open(); + port.close(); + expect(closeSpy.calledTwice); + done(); + }); + }); + + it('errors when closing an invalid port', function (done) { + var port = new SerialPort('/dev/exists', options, false); + port.close(function(err){ + expect(err).to.be.ok; + done(); + }); + }); + + it('emits a close event', function (done) { + var port = new SerialPort('/dev/exists', options, function () { + port.on('close', function () { + done(); + }); + port.close(); + }); + }); + }); + + describe('disconnect', function () { + it('fires a disconnect event', function (done) { + options.disconnectedCallback = function (err) { + expect(err).to.be.ok; + done(); + }; + var port = new SerialPort('/dev/exists', options, function () { + hardware.disconnect('/dev/exists'); + }); + }); + + it('emits a disconnect event', function (done) { + var port = new SerialPort('/dev/exists', options, function () { + port.on('disconnect', function () { + done(); + }); + hardware.disconnect('/dev/exists'); + }); + }); + }); + +}); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.lint new file mode 100644 index 0000000..e8cb4c7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.lint @@ -0,0 +1,11 @@ +@root + +module + +indent 2 +maxlen 80 +tabs + +ass +nomen +plusplus diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.travis.yml new file mode 100644 index 0000000..9181d78 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-map@medikoo.com + +script: "npm test && npm run lint" diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/CHANGES new file mode 100644 index 0000000..a17e221 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/CHANGES @@ -0,0 +1,16 @@ +v0.1.1 -- 2014.10.07 +* Fix isImplemented so native Maps are detected properly +* Configure lint scripts + +v0.1.0 -- 2014.04.29 +* Assure strictly npm hosted dependencies +* Update to use latest versions of dependencies + +v0.0.1 -- 2014.04.25 +* Provide @@toStringTag symbol, and use other ES 6 symbols +* Fix iterators handling +* Fix isImplemented so it doesn't crash +* Update up to changes in dependencies + +v0.0.0 -- 2013.11.10 +- Initial (dev) version diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/LICENCE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/LICENCE new file mode 100644 index 0000000..aaf3528 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/LICENCE @@ -0,0 +1,19 @@ +Copyright (C) 2013 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/README.md new file mode 100644 index 0000000..1ea3a95 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/README.md @@ -0,0 +1,75 @@ +# es6-map +## Map collection as specified in ECMAScript6 + +### Usage + +If you want to make sure your environment implements `Map`, do: + +```javascript +require('es6-map/implement'); +``` + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Map` on global scope, do: + +```javascript +var Map = require('es6-map'); +``` + +If you strictly want to use polyfill even if native `Map` exists, do: + +```javascript +var Map = require('es6-map/polyfill'); +``` + +### Installation + + $ npm install es6-map + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-objects). Still if you want quick look, follow examples: + +```javascript +var Map = require('es6-map'); + +var x = {}, y = {}, map = new Map([['raz', 'one'], ['dwa', 'two'], [x, y]]); + +map.size; // 3 +map.get('raz'); // 'one' +map.get(x); // y +map.has('raz'); // true +map.has(x); // true +map.has('foo'); // false +map.set('trzy', 'three'); // map +map.size // 4 +map.get('trzy'); // 'three' +map.has('trzy'); // true +map.has('dwa'); // true +map.delete('dwa'); // true +map.size; // 3 + +map.forEach(function (value, key) { + // { 'raz', 'one' }, { x, y }, { 'trzy', 'three' } iterated +}); + +// FF nightly only: +for (value of map) { + // ['raz', 'one'], [x, y], ['trzy', 'three'] iterated +} + +var iterator = map.values(); + +iterator.next(); // { done: false, value: 'one' } +iterator.next(); // { done: false, value: y } +iterator.next(); // { done: false, value: 'three' } +iterator.next(); // { done: true, value: undefined } + +map.clear(); // undefined +map.size; // 0 +``` + +## Tests [](https://travis-ci.org/medikoo/es6-map) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/implement.js new file mode 100644 index 0000000..ff3ebac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Map', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/index.js new file mode 100644 index 0000000..3e27caa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Map : require('./polyfill'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-implemented.js new file mode 100644 index 0000000..cb872fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-implemented.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = function () { + var map, iterator, result; + if (typeof Map !== 'function') return false; + try { + // WebKit doesn't support arguments and crashes + map = new Map([['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]); + } catch (e) { + return false; + } + if (map.size !== 3) return false; + if (typeof map.clear !== 'function') return false; + if (typeof map.delete !== 'function') return false; + if (typeof map.entries !== 'function') return false; + if (typeof map.forEach !== 'function') return false; + if (typeof map.get !== 'function') return false; + if (typeof map.has !== 'function') return false; + if (typeof map.keys !== 'function') return false; + if (typeof map.set !== 'function') return false; + if (typeof map.values !== 'function') return false; + + iterator = map.entries(); + result = iterator.next(); + if (result.done !== false) return false; + if (!result.value) return false; + if (result.value[0] !== 'raz') return false; + if (result.value[1] !== 'one') return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-map.js new file mode 100644 index 0000000..f45526a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-map.js @@ -0,0 +1,12 @@ +'use strict'; + +var toStringTagSymbol = require('es6-symbol').toStringTag + + , toString = Object.prototype.toString + , id = '[object Map]' + , Global = (typeof Map === 'undefined') ? null : Map; + +module.exports = function (x) { + return (x && ((Global && (x instanceof Global)) || + (toString.call(x) === id) || (x[toStringTagSymbol] === 'Map'))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-native-implemented.js new file mode 100644 index 0000000..208c661 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/is-native-implemented.js @@ -0,0 +1,9 @@ +// Exports true if environment provides native `Map` implementation, +// whatever that is. + +'use strict'; + +module.exports = (function () { + if (typeof Map === 'undefined') return false; + return (Object.prototype.toString.call(Map.prototype) === '[object Map]'); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator-kinds.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator-kinds.js new file mode 100644 index 0000000..5367b38 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator-kinds.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('es5-ext/object/primitive-set')('key', + 'value', 'key+value'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator.js new file mode 100644 index 0000000..60f1e8c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/iterator.js @@ -0,0 +1,38 @@ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , Iterator = require('es6-iterator') + , toStringTagSymbol = require('es6-symbol').toStringTag + , kinds = require('./iterator-kinds') + + , defineProperties = Object.defineProperties + , unBind = Iterator.prototype._unBind + , MapIterator; + +MapIterator = module.exports = function (map, kind) { + if (!(this instanceof MapIterator)) return new MapIterator(map, kind); + Iterator.call(this, map.__mapKeysData__, map); + if (!kind || !kinds[kind]) kind = 'key+value'; + defineProperties(this, { + __kind__: d('', kind), + __values__: d('w', map.__mapValuesData__) + }); +}; +if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator); + +MapIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(MapIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__values__[i]; + if (this.__kind__ === 'key') return this.__list__[i]; + return [this.__list__[i], this.__values__[i]]; + }), + _unBind: d(function () { + this.__values__ = null; + unBind.call(this); + }), + toString: d(function () { return '[object Map Iterator]'; }) +}); +Object.defineProperty(MapIterator.prototype, toStringTagSymbol, + d('c', 'Map Iterator')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/primitive-iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/primitive-iterator.js new file mode 100644 index 0000000..b9eada3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/lib/primitive-iterator.js @@ -0,0 +1,57 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , assign = require('es5-ext/object/assign') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , toStringTagSymbol = require('es6-symbol').toStringTag + , d = require('d') + , autoBind = require('d/auto-bind') + , Iterator = require('es6-iterator') + , kinds = require('./iterator-kinds') + + , defineProperties = Object.defineProperties, keys = Object.keys + , unBind = Iterator.prototype._unBind + , PrimitiveMapIterator; + +PrimitiveMapIterator = module.exports = function (map, kind) { + if (!(this instanceof PrimitiveMapIterator)) { + return new PrimitiveMapIterator(map, kind); + } + Iterator.call(this, keys(map.__mapKeysData__), map); + if (!kind || !kinds[kind]) kind = 'key+value'; + defineProperties(this, { + __kind__: d('', kind), + __keysData__: d('w', map.__mapKeysData__), + __valuesData__: d('w', map.__mapValuesData__) + }); +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveMapIterator, Iterator); + +PrimitiveMapIterator.prototype = Object.create(Iterator.prototype, assign({ + constructor: d(PrimitiveMapIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__valuesData__[this.__list__[i]]; + if (this.__kind__ === 'key') return this.__keysData__[this.__list__[i]]; + return [this.__keysData__[this.__list__[i]], + this.__valuesData__[this.__list__[i]]]; + }), + _unBind: d(function () { + this.__keysData__ = null; + this.__valuesData__ = null; + unBind.call(this); + }), + toString: d(function () { return '[object Map Iterator]'; }) +}, autoBind({ + _onAdd: d(function (key) { this.__list__.push(key); }), + _onDelete: d(function (key) { + var index = this.__list__.lastIndexOf(key); + if (index < this.__nextIndex__) return; + this.__list__.splice(index, 1); + }), + _onClear: d(function () { + clear.call(this.__list__); + this.__nextIndex__ = 0; + }) +}))); +Object.defineProperty(PrimitiveMapIterator.prototype, toStringTagSymbol, + d('c', 'Map Iterator')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.lint new file mode 100644 index 0000000..858b753 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.lint @@ -0,0 +1,12 @@ +@root + +es5 +module + +tabs +indent 2 +maxlen 80 + +ass +nomen +plusplus diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.travis.yml new file mode 100644 index 0000000..50008b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+d@medikoo.com diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/CHANGES new file mode 100644 index 0000000..45233f7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/CHANGES @@ -0,0 +1,7 @@ +v0.1.1 -- 2014.04.24 +- Add `autoBind` and `lazy` utilities +- Allow to pass other options to be merged onto created descriptor. + Useful when used with other custom utilties + +v0.1.0 -- 2013.06.20 +Initial (derived from es5-ext project) diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/LICENCE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/LICENCE new file mode 100644 index 0000000..aaf3528 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/LICENCE @@ -0,0 +1,19 @@ +Copyright (C) 2013 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/README.md new file mode 100644 index 0000000..872d493 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/README.md @@ -0,0 +1,108 @@ +# D - Property descriptor factory + +_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._ + +Defining properties with descriptors is very verbose: + +```javascript +var Account = function () {}; +Object.defineProperties(Account.prototype, { + deposit: { value: function () { + /* ... */ + }, configurable: true, enumerable: false, writable: true }, + whithdraw: { value: function () { + /* ... */ + }, configurable: true, enumerable: false, writable: true }, + balance: { get: function () { + /* ... */ + }, configurable: true, enumerable: false } +}); +``` + +D cuts that to: + +```javascript +var d = require('d'); + +var Account = function () {}; +Object.defineProperties(Account.prototype, { + deposit: d(function () { + /* ... */ + }), + whithdraw: d(function () { + /* ... */ + }), + balance: d.gs(function () { + /* ... */ + }) +}); +``` + +By default, created descriptor follow characteristics of native ES5 properties, and defines values as: + +```javascript +{ configurable: true, enumerable: false, writable: true } +``` + +You can overwrite it by preceding _value_ argument with instruction: +```javascript +d('c', value); // { configurable: true, enumerable: false, writable: false } +d('ce', value); // { configurable: true, enumerable: true, writable: false } +d('e', value); // { configurable: false, enumerable: true, writable: false } + +// Same way for get/set: +d.gs('e', value); // { configurable: false, enumerable: true } +``` + +### Other utilities + +#### autoBind(obj, props) _(d/auto-bind)_ + +Define methods which will be automatically bound to its instances + +```javascript +var d = require('d'); +var autoBind = require('d/auto-bind'); + +var Foo = function () { this._count = 0; }; +autoBind(Foo.prototype, { + increment: d(function () { ++this._count; }); +}); + +var foo = new Foo(); + +// Increment foo counter on each domEl click +domEl.addEventListener('click', foo.increment, false); +``` + +#### lazy(obj, props) _(d/lazy)_ + +Define lazy properties, which will be resolved on first access + +```javascript +var d = require('d'); +var lazy = require('d/lazy'); + +var Foo = function () {}; +lazy(Foo.prototype, { + items: d(function () { return []; }) +}); + +var foo = new Foo(); +foo.items.push(1, 2); // foo.items array created +``` + +## Installation +### NPM + +In your project path: + + $ npm install d + +### Browser + +You can easily bundle _D_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake) + +## Tests [](https://travis-ci.org/medikoo/d) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/auto-bind.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/auto-bind.js new file mode 100644 index 0000000..1b00dba --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/auto-bind.js @@ -0,0 +1,31 @@ +'use strict'; + +var copy = require('es5-ext/object/copy') + , map = require('es5-ext/object/map') + , callable = require('es5-ext/object/valid-callable') + , validValue = require('es5-ext/object/valid-value') + + , bind = Function.prototype.bind, defineProperty = Object.defineProperty + , hasOwnProperty = Object.prototype.hasOwnProperty + , define; + +define = function (name, desc, bindTo) { + var value = validValue(desc) && callable(desc.value), dgs; + dgs = copy(desc); + delete dgs.writable; + delete dgs.value; + dgs.get = function () { + if (hasOwnProperty.call(this, name)) return value; + desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]); + defineProperty(this, name, desc); + return this[name]; + }; + return dgs; +}; + +module.exports = function (props/*, bindTo*/) { + var bindTo = arguments[1]; + return map(props, function (desc, name) { + return define(name, desc, bindTo); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/index.js new file mode 100644 index 0000000..076ae46 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/index.js @@ -0,0 +1,63 @@ +'use strict'; + +var assign = require('es5-ext/object/assign') + , normalizeOpts = require('es5-ext/object/normalize-options') + , isCallable = require('es5-ext/object/is-callable') + , contains = require('es5-ext/string/#/contains') + + , d; + +d = module.exports = function (dscr, value/*, options*/) { + var c, e, w, options, desc; + if ((arguments.length < 2) || (typeof dscr !== 'string')) { + options = value; + value = dscr; + dscr = null; + } else { + options = arguments[2]; + } + if (dscr == null) { + c = w = true; + e = false; + } else { + c = contains.call(dscr, 'c'); + e = contains.call(dscr, 'e'); + w = contains.call(dscr, 'w'); + } + + desc = { value: value, configurable: c, enumerable: e, writable: w }; + return !options ? desc : assign(normalizeOpts(options), desc); +}; + +d.gs = function (dscr, get, set/*, options*/) { + var c, e, options, desc; + if (typeof dscr !== 'string') { + options = set; + set = get; + get = dscr; + dscr = null; + } else { + options = arguments[3]; + } + if (get == null) { + get = undefined; + } else if (!isCallable(get)) { + options = get; + get = set = undefined; + } else if (set == null) { + set = undefined; + } else if (!isCallable(set)) { + options = set; + set = undefined; + } + if (dscr == null) { + c = true; + e = false; + } else { + c = contains.call(dscr, 'c'); + e = contains.call(dscr, 'e'); + } + + desc = { get: get, set: set, configurable: c, enumerable: e }; + return !options ? desc : assign(normalizeOpts(options), desc); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/lazy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/lazy.js new file mode 100644 index 0000000..61e4665 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/lazy.js @@ -0,0 +1,111 @@ +'use strict'; + +var map = require('es5-ext/object/map') + , isCallable = require('es5-ext/object/is-callable') + , validValue = require('es5-ext/object/valid-value') + , contains = require('es5-ext/string/#/contains') + + , call = Function.prototype.call + , defineProperty = Object.defineProperty + , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor + , getPrototypeOf = Object.getPrototypeOf + , hasOwnProperty = Object.prototype.hasOwnProperty + , cacheDesc = { configurable: false, enumerable: false, writable: false, + value: null } + , define; + +define = function (name, options) { + var value, dgs, cacheName, desc, writable = false, resolvable + , flat; + options = Object(validValue(options)); + cacheName = options.cacheName; + flat = options.flat; + if (cacheName == null) cacheName = name; + delete options.cacheName; + value = options.value; + resolvable = isCallable(value); + delete options.value; + dgs = { configurable: Boolean(options.configurable), + enumerable: Boolean(options.enumerable) }; + if (name !== cacheName) { + dgs.get = function () { + if (hasOwnProperty.call(this, cacheName)) return this[cacheName]; + cacheDesc.value = resolvable ? call.call(value, this, options) : value; + cacheDesc.writable = writable; + defineProperty(this, cacheName, cacheDesc); + cacheDesc.value = null; + if (desc) defineProperty(this, name, desc); + return this[cacheName]; + }; + } else if (!flat) { + dgs.get = function self() { + var ownDesc; + if (hasOwnProperty.call(this, name)) { + ownDesc = getOwnPropertyDescriptor(this, name); + // It happens in Safari, that getter is still called after property + // was defined with a value, following workarounds that + if (ownDesc.hasOwnProperty('value')) return ownDesc.value; + if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { + return ownDesc.get.call(this); + } + return value; + } + desc.value = resolvable ? call.call(value, this, options) : value; + defineProperty(this, name, desc); + desc.value = null; + return this[name]; + }; + } else { + dgs.get = function self() { + var base = this, ownDesc; + if (hasOwnProperty.call(this, name)) { + // It happens in Safari, that getter is still called after property + // was defined with a value, following workarounds that + ownDesc = getOwnPropertyDescriptor(this, name); + if (ownDesc.hasOwnProperty('value')) return ownDesc.value; + if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { + return ownDesc.get.call(this); + } + } + while (!hasOwnProperty.call(base, name)) base = getPrototypeOf(base); + desc.value = resolvable ? call.call(value, base, options) : value; + defineProperty(base, name, desc); + desc.value = null; + return base[name]; + }; + } + dgs.set = function (value) { + dgs.get.call(this); + this[cacheName] = value; + }; + if (options.desc) { + desc = { + configurable: contains.call(options.desc, 'c'), + enumerable: contains.call(options.desc, 'e') + }; + if (cacheName === name) { + desc.writable = contains.call(options.desc, 'w'); + desc.value = null; + } else { + writable = contains.call(options.desc, 'w'); + desc.get = dgs.get; + desc.set = dgs.set; + } + delete options.desc; + } else if (cacheName === name) { + desc = { + configurable: Boolean(options.configurable), + enumerable: Boolean(options.enumerable), + writable: Boolean(options.writable), + value: null + }; + } + delete options.configurable; + delete options.enumerable; + delete options.writable; + return dgs; +}; + +module.exports = function (props) { + return map(props, function (desc, name) { return define(name, desc); }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/package.json new file mode 100644 index 0000000..03d81db --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/package.json @@ -0,0 +1,59 @@ +{ + "name": "d", + "version": "0.1.1", + "description": "Property descriptor factory", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "scripts": { + "test": "node node_modules/tad/bin/tad" + }, + "repository": { + "type": "git", + "url": "git://github.com/medikoo/d.git" + }, + "keywords": [ + "descriptor", + "es", + "ecmascript", + "ecma", + "property", + "descriptors", + "meta", + "properties" + ], + "dependencies": { + "es5-ext": "~0.10.2" + }, + "devDependencies": { + "tad": "~0.1.21" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/medikoo/d/issues" + }, + "homepage": "https://github.com/medikoo/d", + "_id": "d@0.1.1", + "dist": { + "shasum": "da184c535d18d8ee7ba2aa229b914009fae11309", + "tarball": "http://registry.npmjs.org/d/-/d-0.1.1.tgz" + }, + "_from": "d@>=0.1.1 <0.2.0", + "_npmVersion": "1.4.3", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "directories": {}, + "_shasum": "da184c535d18d8ee7ba2aa229b914009fae11309", + "_resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/auto-bind.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/auto-bind.js new file mode 100644 index 0000000..89edfb8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/auto-bind.js @@ -0,0 +1,12 @@ +'use strict'; + +var d = require('../'); + +module.exports = function (t, a) { + var o = Object.defineProperties({}, t({ + bar: d(function () { return this === o; }), + bar2: d(function () { return this; }) + })); + + a.deep([(o.bar)(), (o.bar2)()], [true, o]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/index.js new file mode 100644 index 0000000..3db0af1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/index.js @@ -0,0 +1,182 @@ +'use strict'; + +var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +module.exports = function (t, a) { + var o, c, cg, cs, ce, ceg, ces, cew, cw, e, eg, es, ew, v, vg, vs, w, df, dfg + , dfs; + + o = Object.create(Object.prototype, { + c: t('c', c = {}), + cgs: t.gs('c', cg = function () {}, cs = function () {}), + ce: t('ce', ce = {}), + cegs: t.gs('ce', ceg = function () {}, ces = function () {}), + cew: t('cew', cew = {}), + cw: t('cw', cw = {}), + e: t('e', e = {}), + egs: t.gs('e', eg = function () {}, es = function () {}), + ew: t('ew', ew = {}), + v: t('', v = {}), + vgs: t.gs('', vg = function () {}, vs = function () {}), + w: t('w', w = {}), + + df: t(df = {}), + dfgs: t.gs(dfg = function () {}, dfs = function () {}) + }); + + return { + c: function (a) { + var d = getOwnPropertyDescriptor(o, 'c'); + a(d.value, c, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, true, "Configurable"); + a(d.enumerable, false, "Enumerable"); + a(d.writable, false, "Writable"); + + d = getOwnPropertyDescriptor(o, 'cgs'); + a(d.value, undefined, "GS Value"); + a(d.get, cg, "GS Get"); + a(d.set, cs, "GS Set"); + a(d.configurable, true, "GS Configurable"); + a(d.enumerable, false, "GS Enumerable"); + a(d.writable, undefined, "GS Writable"); + }, + ce: function (a) { + var d = getOwnPropertyDescriptor(o, 'ce'); + a(d.value, ce, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, true, "Configurable"); + a(d.enumerable, true, "Enumerable"); + a(d.writable, false, "Writable"); + + d = getOwnPropertyDescriptor(o, 'cegs'); + a(d.value, undefined, "GS Value"); + a(d.get, ceg, "GS Get"); + a(d.set, ces, "GS Set"); + a(d.configurable, true, "GS Configurable"); + a(d.enumerable, true, "GS Enumerable"); + a(d.writable, undefined, "GS Writable"); + }, + cew: function (a) { + var d = getOwnPropertyDescriptor(o, 'cew'); + a(d.value, cew, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, true, "Configurable"); + a(d.enumerable, true, "Enumerable"); + a(d.writable, true, "Writable"); + }, + cw: function (a) { + var d = getOwnPropertyDescriptor(o, 'cw'); + a(d.value, cw, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, true, "Configurable"); + a(d.enumerable, false, "Enumerable"); + a(d.writable, true, "Writable"); + }, + e: function (a) { + var d = getOwnPropertyDescriptor(o, 'e'); + a(d.value, e, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, false, "Configurable"); + a(d.enumerable, true, "Enumerable"); + a(d.writable, false, "Writable"); + + d = getOwnPropertyDescriptor(o, 'egs'); + a(d.value, undefined, "GS Value"); + a(d.get, eg, "GS Get"); + a(d.set, es, "GS Set"); + a(d.configurable, false, "GS Configurable"); + a(d.enumerable, true, "GS Enumerable"); + a(d.writable, undefined, "GS Writable"); + }, + ew: function (a) { + var d = getOwnPropertyDescriptor(o, 'ew'); + a(d.value, ew, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, false, "Configurable"); + a(d.enumerable, true, "Enumerable"); + a(d.writable, true, "Writable"); + }, + v: function (a) { + var d = getOwnPropertyDescriptor(o, 'v'); + a(d.value, v, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, false, "Configurable"); + a(d.enumerable, false, "Enumerable"); + a(d.writable, false, "Writable"); + + d = getOwnPropertyDescriptor(o, 'vgs'); + a(d.value, undefined, "GS Value"); + a(d.get, vg, "GS Get"); + a(d.set, vs, "GS Set"); + a(d.configurable, false, "GS Configurable"); + a(d.enumerable, false, "GS Enumerable"); + a(d.writable, undefined, "GS Writable"); + }, + w: function (a) { + var d = getOwnPropertyDescriptor(o, 'w'); + a(d.value, w, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, false, "Configurable"); + a(d.enumerable, false, "Enumerable"); + a(d.writable, true, "Writable"); + }, + d: function (a) { + var d = getOwnPropertyDescriptor(o, 'df'); + a(d.value, df, "Value"); + a(d.get, undefined, "Get"); + a(d.set, undefined, "Set"); + a(d.configurable, true, "Configurable"); + a(d.enumerable, false, "Enumerable"); + a(d.writable, true, "Writable"); + + d = getOwnPropertyDescriptor(o, 'dfgs'); + a(d.value, undefined, "GS Value"); + a(d.get, dfg, "GS Get"); + a(d.set, dfs, "GS Set"); + a(d.configurable, true, "GS Configurable"); + a(d.enumerable, false, "GS Enumerable"); + a(d.writable, undefined, "GS Writable"); + }, + Options: { + v: function (a) { + var x = {}, d = t(x, { foo: true }); + a.deep(d, { configurable: true, enumerable: false, writable: true, + value: x, foo: true }, "No descriptor"); + d = t('c', 'foo', { marko: 'elo' }); + a.deep(d, { configurable: true, enumerable: false, writable: false, + value: 'foo', marko: 'elo' }, "Descriptor"); + }, + gs: function (a) { + var gFn = function () {}, sFn = function () {}, d; + d = t.gs(gFn, sFn, { foo: true }); + a.deep(d, { configurable: true, enumerable: false, get: gFn, set: sFn, + foo: true }, "No descriptor"); + d = t.gs(null, sFn, { foo: true }); + a.deep(d, { configurable: true, enumerable: false, get: undefined, + set: sFn, foo: true }, "No descriptor: Just set"); + d = t.gs(gFn, { foo: true }); + a.deep(d, { configurable: true, enumerable: false, get: gFn, + set: undefined, foo: true }, "No descriptor: Just get"); + + d = t.gs('e', gFn, sFn, { bar: true }); + a.deep(d, { configurable: false, enumerable: true, get: gFn, set: sFn, + bar: true }, "Descriptor"); + d = t.gs('e', null, sFn, { bar: true }); + a.deep(d, { configurable: false, enumerable: true, get: undefined, + set: sFn, bar: true }, "Descriptor: Just set"); + d = t.gs('e', gFn, { bar: true }); + a.deep(d, { configurable: false, enumerable: true, get: gFn, + set: undefined, bar: true }, "Descriptor: Just get"); + } + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/lazy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/lazy.js new file mode 100644 index 0000000..8266deb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/d/test/lazy.js @@ -0,0 +1,77 @@ +'use strict'; + +var d = require('../') + + , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +module.exports = function (t, a) { + var Foo = function () {}, i = 1, o, o2, desc; + Object.defineProperties(Foo.prototype, t({ + bar: d(function () { return ++i; }), + bar2: d(function () { return this.bar + 23; }), + bar3: d(function () { return this.bar2 + 34; }, { desc: 'ew' }), + bar4: d(function () { return this.bar3 + 12; }, { cacheName: '_bar4_' }), + bar5: d(function () { return this.bar4 + 3; }, + { cacheName: '_bar5_', desc: 'e' }) + })); + + desc = getOwnPropertyDescriptor(Foo.prototype, 'bar'); + a(desc.configurable, true, "Configurable: default"); + a(desc.enumerable, false, "Enumerable: default"); + + o = new Foo(); + a.deep([o.bar, o.bar2, o.bar3, o.bar4, o.bar5], [2, 25, 59, 71, 74], + "Values"); + + a.deep(getOwnPropertyDescriptor(o, 'bar3'), { configurable: false, + enumerable: true, writable: true, value: 59 }, "Desc"); + a(o.hasOwnProperty('bar4'), false, "Cache not exposed"); + desc = getOwnPropertyDescriptor(o, 'bar5'); + a.deep(desc, { configurable: false, + enumerable: true, get: desc.get, set: desc.set }, "Cache & Desc: desc"); + + o2 = Object.create(o); + o2.bar = 30; + o2.bar3 = 100; + + a.deep([o2.bar, o2.bar2, o2.bar3, o2.bar4, o2.bar5], [30, 25, 100, 112, 115], + "Extension Values"); + + Foo = function () {}; + Object.defineProperties(Foo.prototype, t({ + test: d('w', function () { return 'raz'; }), + test2: d('', function () { return 'raz'; }, { desc: 'w' }), + test3: d('', function () { return 'raz'; }, + { cacheName: '__test3__', desc: 'w' }), + test4: d('w', 'bar') + })); + + o = new Foo(); + o.test = 'marko'; + a.deep(getOwnPropertyDescriptor(o, 'test'), + { configurable: false, enumerable: false, writable: true, value: 'marko' }, + "Set before get"); + o.test2 = 'marko2'; + a.deep(getOwnPropertyDescriptor(o, 'test2'), + { configurable: false, enumerable: false, writable: true, value: 'marko2' }, + "Set before get: Custom desc"); + o.test3 = 'marko3'; + a.deep(getOwnPropertyDescriptor(o, '__test3__'), + { configurable: false, enumerable: false, writable: true, value: 'marko3' }, + "Set before get: Custom cache name"); + a(o.test4, 'bar', "Resolve by value"); + + a.h1("Flat"); + Object.defineProperties(Foo.prototype, t({ + flat: d(function () { return 'foo'; }, { flat: true }), + flat2: d(function () { return 'bar'; }, { flat: true }) + })); + + a.h2("Instance"); + a(o.flat, 'foo', "Value"); + a(o.hasOwnProperty('flat'), false, "Instance"); + a(Foo.prototype.flat, 'foo', "Prototype"); + + a.h2("Direct"); + a(Foo.prototype.flat2, 'bar'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lint new file mode 100644 index 0000000..d1da610 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lint @@ -0,0 +1,38 @@ +@root + +module + +indent 2 +maxlen 100 +tabs + +ass +continue +forin +nomen +plusplus +vars + +./global.js +./function/_define-length.js +./function/#/copy.js +./object/unserialize.js +./test/function/valid-function.js +evil + +./math/_pack-ieee754.js +./math/_unpack-ieee754.js +./math/clz32/shim.js +./math/imul/shim.js +./number/to-uint32.js +./string/#/at.js +bitwise + +./math/fround/shim.js +predef+ Float32Array + +./object/first-key.js +forin + +./test/reg-exp/#/index.js +predef+ __dirname diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lintignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lintignore new file mode 100644 index 0000000..ed703ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.lintignore @@ -0,0 +1,8 @@ +/string/#/normalize/_data.js +/test/boolean/is-boolean.js +/test/date/is-date.js +/test/number/is-number.js +/test/object/is-copy.js +/test/object/is-object.js +/test/reg-exp/is-reg-exp.js +/test/string/is-string.js diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.npmignore new file mode 100644 index 0000000..eb09b50 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/.lintcache +/npm-debug.log diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.travis.yml new file mode 100644 index 0000000..a183dbc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/.travis.yml @@ -0,0 +1,15 @@ +sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +language: node_js +node_js: + - 0.10 + - 0.12 + - iojs + +before_install: + - mkdir node_modules; ln -s ../ node_modules/es5-ext + +notifications: + email: + - medikoo+es5-ext@medikoo.com + +script: "npm test && npm run lint" diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/CHANGES new file mode 100644 index 0000000..5d0ace5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/CHANGES @@ -0,0 +1,611 @@ +v0.10.7 -- 2015.04.22 +* New utlitities. They're convention differs from v0.10, as they were supposed to land in v1. + Still they're non breaking and start the conventions to be used in v1 + * Object.validateArrayLike + * Object.validateArrayLikeObject + * Object.validateStringifiable + * Object.validateStringifiableValue + * Universal utilities for array-like/iterable objects + * Iterable.is + * Iterable.validate + * Iterable.validateObject + * Iterable.forEach +* Fix camelToHyphen resolution, it must be absolutely reversable by hyphenToCamel +* Fix calculations of large numbers in Math.tanh +* Fix algorithm of Math.sinh +* Fix indexes to not use real symbols +* Fix length of String.fromCodePoint +* Fix tests of Array#copyWithin +* Update Travis CI configuration + +v0.10.6 -- 2015.02.02 +* Fix handling of infinite values in Math.trunc +* Fix handling of getters in Object.normalizeOptions + +v0.10.5 -- 2015.01.20 +* Add Function#toStringTokens +* Add Object.serialize and Object.unserialize +* Add String.randomUniq +* Fix Strin#camelToHyphen issue with tokens that end with digit +* Optimise Number.isInteger logic +* Improve documentation +* Configure lint scripts +* Fix spelling of LICENSE + +v0.10.4 -- 2014.04.30 +* Assure maximum spec compliance of Array.of and Array.from (thanks @mathiasbynens) +* Improve documentations + +v0.10.3 -- 2014.04.29 +Provide accurate iterators handling: +* Array.from improvements: + * Assure right unicode symbols resolution when processing strings in Array.from + * Rely on ES6 symbol shim and use native @@iterator Symbol if provided by environment +* Add methods: + * Array.prototype.entries + * Array.prototype.keys + * Array.prototype.values + * Array.prototype[@@iterator] + * String.prototype[@@iterator] + +Improve documentation + +v0.10.2 -- 2014.04.24 +- Simplify and deprecate `isCallable`. It seems in ES5 based engines there are + no callable objects which are `typeof obj !== 'function'` +- Update Array.from map callback signature (up to latest resolution of TC39) +- Improve documentation + +v0.10.1 -- 2014.04.14 +Bump version for npm +(Workaround for accidental premature publish & unpublish of v0.10.0 a while ago) + +v0.10.0 -- 2014.04.13 +Major update: +- All methods and function specified for ECMAScript 6 are now introduced as + shims accompanied with functions through which (optionally) they can be + implementend on native objects +- Filename convention was changed to shorter and strictly lower case names. e.g. + `lib/String/prototype/starts-with` became `string/#/starts-with` +- Generated functions are guaranteed to have expected length +- Objects with null prototype (created via `Object.create(null)`) are widely + supported (older version have crashed due to implied `obj.hasOwnProperty` and + related invocations) +- Support array subclasses +- When handling lists do not limit its length to Uint32 range +- Use newly introduced `Object.eq` for strict equality in place of `Object.is` +- Iteration of Object have been improved so properties that were hidden or + removed after iteration started are not iterated. + +Additions: +- `Array.isPlainArray` +- `Array.validArray` +- `Array.prototype.concat` (as updated with ES6) +- `Array.prototype.copyWithin` (as introduced with ES6) +- `Array.prototype.fill` (as introduced with ES6) +- `Array.prototype.filter` (as updated with ES6) +- `Array.prototype.findIndex` (as introduced with ES6) +- `Array.prototype.map` (as updated with ES6) +- `Array.prototype.separate` +- `Array.prototype.slice` (as updated with ES6) +- `Array.prototype.splice` (as updated with ES6) +- `Function.prototype.copy` +- `Math.acosh` (as introduced with ES6) +- `Math.atanh` (as introduced with ES6) +- `Math.cbrt` (as introduced with ES6) +- `Math.clz32` (as introduced with ES6) +- `Math.cosh` (as introduced with ES6) +- `Math.expm1` (as introduced with ES6) +- `Math.fround` (as introduced with ES6) +- `Math.hypot` (as introduced with ES6) +- `Math.imul` (as introduced with ES6) +- `Math.log2` (as introduced with ES6) +- `Math.log10` (as introduced with ES6) +- `Math.log1p` (as introduced with ES6) +- `Math.sinh` (as introduced with ES6) +- `Math.tanh` (as introduced with ES6) +- `Math.trunc` (as introduced with ES6) +- `Number.EPSILON` (as introduced with ES6) +- `Number.MIN_SAFE_INTEGER` (as introduced with ES6) +- `Number.MAX_SAFE_INTEGER` (as introduced with ES6) +- `Number.isFinite` (as introduced with ES6) +- `Number.isInteger` (as introduced with ES6) +- `Number.isSafeInteger` (as introduced with ES6) +- `Object.create` (with fix for V8 issue which disallows prototype turn of + objects derived from null +- `Object.eq` - Less restrictive version of `Object.is` based on SameValueZero + algorithm +- `Object.firstKey` +- `Object.keys` (as updated with ES6) +- `Object.mixinPrototypes` +- `Object.primitiveSet` +- `Object.setPrototypeOf` (as introduced with ES6) +- `Object.validObject` +- `RegExp.escape` +- `RegExp.prototype.match` (as introduced with ES6) +- `RegExp.prototype.replace` (as introduced with ES6) +- `RegExp.prototype.search` (as introduced with ES6) +- `RegExp.prototype.split` (as introduced with ES6) +- `RegExp.prototype.sticky` (as introduced with ES6) +- `RegExp.prototype.unicode` (as introduced with ES6) +- `String.fromCodePoint` (as introduced with ES6) +- `String.raw` (as introduced with ES6) +- `String.prototype.at` +- `String.prototype.codePointAt` (as introduced with ES6) +- `String.prototype.normalize` (as introduced with ES6) +- `String.prototype.plainReplaceAll` + +Removals: +- `reserved` set +- `Array.prototype.commonLeft` +- `Function.insert` +- `Function.remove` +- `Function.prototype.silent` +- `Function.prototype.wrap` +- `Object.descriptor` Move to external `d` project. + See: https://github.com/medikoo/d +- `Object.diff` +- `Object.extendDeep` +- `Object.reduce` +- `Object.values` +- `String.prototype.trimCommonLeft` + +Renames: +- `Function.i` into `Function.identity` +- `Function.k` into `Function.constant` +- `Number.toInt` into `Number.toInteger` +- `Number.toUint` into `Number.toPosInteger` +- `Object.extend` into `Object.assign` (as introduced in ES 6) +- `Object.extendProperties` into `Object.mixin`, with improved internal + handling, so it matches temporarily specified `Object.mixin` for ECMAScript 6 +- `Object.isList` into `Object.isArrayLike` +- `Object.mapToArray` into `Object.toArray` (with fixed function length) +- `Object.toPlainObject` into `Object.normalizeOptions` (as this is the real + use case where we use this function) +- `Function.prototype.chain` into `Function.prototype.compose` +- `Function.prototype.match` into `Function.prototype.spread` +- `String.prototype.format` into `String.formatMethod` + +Improvements & Fixes: +- Remove workaround for primitive values handling in object iterators +- `Array.from`: Update so it follows ES 6 spec +- `Array.prototype.compact`: filters just null and undefined values + (not all falsies) +- `Array.prototype.eIndexOf` and `Array.prototype.eLastIndexOf`: fix position + handling, improve internals +- `Array.prototype.find`: return undefined not null, in case of not found + (follow ES 6) +- `Array.prototype.remove` fix function length +- `Error.custom`: simplify, Custom class case is addressed by outer + `error-create` project -> https://github.com/medikoo/error-create +- `Error.isError` true only for Error instances (remove detection of host + Exception objects) +- `Number.prototype.pad`: Normalize negative pad +- `Object.clear`: Handle errors same way as in `Object.assign` +- `Object.compact`: filters just null and undefined values (not all falsies) +- `Object.compare`: Take into account NaN values +- `Object.copy`: Split into `Object.copy` and `Object.copyDeep` +- `Object.isCopy`: Separate into `Object.isCopy` and `Object.isCopyDeep`, where + `isCopyDeep` handles nested plain objects and plain arrays only +- `String.prototype.endsWith`: Adjust up to ES6 specification +- `String.prototype.repeat`: Adjust up to ES6 specification and improve algorithm +- `String.prototype.simpleReplace`: Rename into `String.prototype.plainReplace` +- `String.prototype.startsWith`: Adjust up to ES6 specification +- Update lint rules, and adjust code to that +- Update Travis CI configuration +- Remove Makefile (it's cross-env utility) + +v0.9.2 -- 2013.03.11 +Added: +* Array.prototype.isCopy +* Array.prototype.isUniq +* Error.CustomError +* Function.validFunction +* Object.extendDeep +* Object.descriptor.binder +* Object.safeTraverse +* RegExp.validRegExp +* String.prototype.capitalize +* String.prototype.simpleReplace + +Fixed: +* Fix Array.prototype.diff for sparse arrays +* Accept primitive objects as input values in Object iteration methods and + Object.clear, Object.count, Object.diff, Object.extend, + Object.getPropertyNames, Object.values +* Pass expected arguments to callbacks of Object.filter, Object.mapKeys, + Object.mapToArray, Object.map +* Improve callable callback support in Object.mapToArray + +v0.9.1 -- 2012.09.17 +* Object.reduce - reduce for hash-like collections +* Accapt any callable object as callback in Object.filter, mapKeys and map +* Convention cleanup + +v0.9.0 -- 2012.09.13 +We're getting to real solid API + +Removed: +* Function#memoize - it's grown up to be external package, to be soon published + as 'memoizee' +* String.guid - it doesn't fit es5-ext (extensions) concept, will be provided as + external package +# Function.arguments - obsolete +# Function.context - obsolete +# Function#flip - not readable when used, so it was never used +# Object.clone - obsolete and confusing + +Added: +* String#camelToHyphen - String format convertion + +Renamed: +* String#dashToCamelCase -> String#hyphenToCamel + +Fixes: +* Object.isObject - Quote names in literals that match reserved keywords + (older implementations crashed on that) +* String#repeat - Do not accept negative values (coerce them to 1) + +Improvements: +* Array#remove - Accepts many arguments, we can now remove many values at once +* Object iterators (forEach, map, some) - Compare function invoked with scope + object bound to this +* Function#curry - Algorithm cleanup +* Object.isCopy - Support for all types, not just plain objects +* Object.isPlainObject - Support for cross-frame objects +* Do not memoize any of the functions, it shouldn't be decided internally +* Remove Object.freeze calls in reserved, it's not up to convention +* Improved documentation +* Better linting (hard-core approach using both JSLint mod and JSHint) +* Optional arguments are now documented in funtions signature + +v0.8.2 -- 2012.06.22 +Fix errors in Array's intersection and exclusion methods, related to improper +usage of contains method + +v0.8.1 -- 2012.06.13 +Reorganized internal logic of Function.prototype.memoize. So it's more safe now +and clears cache properly. Additionally preventCache option was provided. + +v0.8.0 -- 2012.05.28 +Again, major overhaul. Probably last experimental stuff was trashed, all API +looks more like standard extensions now. + +Changes: +* Turn all Object.prototype extensions into functions and move them to Object +namespace. We learned that extending Object.prototype is bad idea in any case. +* Rename Function.prototype.curry into Function.prototype.partial. This function + is really doing partial application while currying is slightly different + concept. +* Convert Function.prototype.ncurry to new implementation of + Function.prototype.curry, it now serves real curry concept additionaly it + covers use cases for aritize and hold, which were removed. +* Rename Array's peek to last, and provide support for sparse arrays in it +* Rename Date's monthDaysCount into daysInMonth +* Simplify object iterators, now order of iteration can be configured with just + compareFn argument (no extra byKeys option) +* Rename Object.isDuplicate to Object.isCopy +* Rename Object.isEqual to Object.is which is compatible with future 'is' + keyword +* Function.memoize is now Function.prototype.memoize. Additionally clear cache + functionality is added, and access to original arguments object. +* Rename validation functions: assertNotNull to validValue, assertCallable to + validCallable. validValue was moved to Object namespace. On success they now + return validated value instead of true, it supports better composition. + Additionally created Date.validDate and Error.validError +* All documentation is now held in README.md not in code files. +* Move guid to String namespace. All guids now start with numbers. +* Array.generate: fill argument is now optional +* Object.toArray is now Array.from (as new ES6 specification draft suggests) +* All methods that rely on indexOf or lastIndexOf, now rely on egal (Object.is) + versions of them (eIndexOf, eLastIndexOf) +* Turn all get* functions that returned methods into actuall methods (get* + functionality can still be achieved with help of Function.prototype.partial). + So: Date.getFormat is now Date.prototype.format, + Number.getPad is now Number.prototype.pad, + String.getFormat is now String.prototype.format, + String.getIndent is now String.prototype.indent, + String.getPad is now String.prototype.pad +* Refactored Object.descriptor, it is now just two functions, main one and + main.gs, main is for describing values, and gs for describing getters and + setters. Configuration is passed with first argument as string e.g. 'ce' for + configurable and enumerable. If no configuration string is provided then by + default it returns configurable and writable but not enumerable for value or + configurable but not enumerable for getter/setter +* Function.prototype.silent now returns prepared function (it was + expected to be fixed for 0.7) +* Reserved keywords map (reserved) is now array not hash. +* Object.merge is now Object.extend (while former Object.extend was completely + removed) - 'extend' implies that we change object, not creating new one (as + 'merge' may imply). Similarily Object.mergeProperties was renamed to + Object.extendProperties +* Position argument support in Array.prototype.contains and + String.prototype.contains (so it follows ES6 specification draft) +* endPosition argument support in String.prototype.endsWith and fromPosition + argument support in String.prototype.startsWith (so it follows ES6 + specification draft) +* Better and cleaner String.prototype.indent implementation. No default value + for indent string argument, optional nest value (defaults to 1), remove + nostart argument +* Correct length values for most methods (so they reflect length of similar + methods in standard) +* Length argument is now optional in number and string pad methods. +* Improve arguments validation in general, so it adheres to standard conventions +* Fixed format of package.json + +Removed methods and functions: +* Object.prototype.slice - Object is not ordered collection, so slice doesn't + make sense. +* Function's rcurry, rncurry, s - too cumbersome for JS, not many use cases for + that +* Function.prototype.aritize and Function.prototype.hold - same functionality + can be achieved with new Function.prototype.curry +* Function.prototype.log - provided more generic Function.prototype.wrap for + same use case +* getNextIdGenerator - no use case for that (String.guid should be used if + needed) +* Object.toObject - Can be now acheived with Object(validValue(x)) +* Array.prototype.someValue - no real use case (personally used once and + case was already controversial) +* Date.prototype.duration - moved to external package +* Number.getAutoincrement - No real use case +* Object.prototype.extend, Object.prototype.override, + Object.prototype.plainCreate, Object.prototype.plainExtend - It was probably + too complex, same should be achieved just with Object.create, + Object.descriptor and by saving references to super methods in local scope. +* Object.getCompareBy - Functions should be created individually for each use + case +* Object.get, Object.getSet, Object.set, Object.unset - Not many use cases and + same can be easily achieved with simple inline function +* String.getPrefixWith - Not real use case for something that can be easily + achieved with '+' operator +* Object.isPrimitive - It's just negation of Object.isObject +* Number.prototype.isLess, Number.prototype.isLessOrEqual - they shouldn't be in + Number namespace and should rather be addressed with simple inline functions. +* Number.prototype.subtract - Should rather be addressed with simple inline + function + +New methods and functions: +* Array.prototype.lastIndex - Returns last declared index in array +* String.prototype.last - last for strings +* Function.prototype.wrap - Wrap function with other, it allows to specify + before and after behavior transform return value or prevent original function + from being called. +* Math.sign - Returns sign of a number (already in ES6 specification draft) +* Number.toInt - Converts value to integer (already in ES6 specification draft) +* Number.isNaN - Returns true if value is NaN (already in ES6 specification + draft) +* Number.toUint - Converts value to unsigned integer +* Number.toUint32 - Converts value to 32bit unsigned integer +* Array.prototype.eIndexOf, eLastIndexOf - Egal version (that uses Object.is) of + standard methods (all methods that were using native indexOf or lastIndexOf + now uses eIndexOf and elastIndexOf respectively) +* Array.of - as it's specified for ES6 + +Fixes: +* Fixed binarySearch so it always returns valid list index +* Object.isList - it failed on lists that are callable (e.g. NodeList in Nitro + engine) +* Object.map now supports third argument for callback + +v0.7.1 -- 2012.01.05 +New methods: +* Array.prototype.firstIndex - returns first valid index of array (for + sparse arrays it may not be '0' + +Improvements: +* Array.prototype.first - now returns value for index returned by firstIndex +* Object.prototype.mapToArray - can be called without callback, then array of + key-value pairs is returned + +Fixes +* Array.prototype.forEachRight, object's length read through UInt32 conversion + +v0.7.0 -- 2011.12.27 +Major update. +Stepped back from experimental ideas and introduced more standard approach +taking example from how ES5 methods and functions are designed. One exceptions +is that, we don’t refrain from declaring methods for Object.prototype - it’s up +to developer whether how he decides to use it in his context (as function or as +method). + +In general: +* Removed any method 'functionalization' and functionalize method itself. + es5-ext declares plain methods, which can be configured to work as functions + with call.bind(method) - see documentation. +* Removed separation of Object methods for ES5 (with descriptors) and + ES3 (plain) - we're following ES5 idea on that, some methods are intended just + for enumerable properties and some are for all properties, all are declared + for Object.prototype +* Removed separation of Array generic (collected in List folder) and not generic + methods (collected in Array folder). Now all methods are generic and are in + Array/prototype folder. This separation also meant, that methods in Array are + usually destructive. We don’t do that separation now, there’s generally no use + case for destructive iterators, we should be fine with one version of each + method, (same as ES5 is fine with e.g. one, non destructive 'filter' method) +* Folder structure resembles tree of native ES5 Objects +* All methods are written with ES5 conventions in mind, it means that most + methods are generic and can be run on any object. In more detail: + ** Array.prototype and Object.prototype methods can be run on any object (any + not null or undefined value), + ** Date.prototype methods should be called only on Date instances. + ** Function.prototype methods can be called on any callable objects (not + necessarily functions) + ** Number.prototype & String.prototype methods can be called on any value, in + case of Number it it’ll be degraded to number, in case of string it’ll be + degraded to string. +* Travis CI support (only for Node v0.6 branch, as v0.4 has buggy V8 version) + +Improvements for existing functions and methods: +* Function.memoize (was Function.cache) is now fully generic, can operate on any + type of arguments and it’s NaN safe (all NaN objects are considered equal) +* Method properties passed to Object.prototype.extend or + Object.prototype.override can aside of _super optionally take prototype object + via _proto argument +* Object iterators: forEach, mapToArray and every can now iterate in specified + order +* pluck, invoke and other functions that return reusable functions or methods + have now their results memoized. + +New methods: +* Global: assertNotNull, getNextIdGenerator, guid, isEqual, isPrimitive, + toObject +* Array: generate +* Array.prototype: binarySearch, clear, contains, diff, exclusion, find, first, + forEachRight, group, indexesOf, intersection, remove, someRight, someValue +* Boolean: isBoolean +* Date: isDate +* Function: arguments, context, insert, isArguments, remove +* Function.prototype: not, silent +* Number: getAutoincrement, isNumber +* Number.prototype: isLessOrEqual, isLess, subtract +* Object: assertCallable, descriptor (functions for clean descriptors), + getCompareBy, isCallable, isObject +* Object.prototype: clone (real clone), compact, count, diff, empty, + getPropertyNames, get, keyOf, mapKeys, override, plainCreate, plainExtend, + slice, some, unset +* RegExp: isRegExp +* String: getPrefixWith, isString +* String.prototype: caseInsensitiveCompare, contains, isNumeric + +Renamed methods: +* Date.clone -> Date.prototype.copy +* Date.format -> Date.getFormat +* Date/day/floor -> Date.prototype.floorDay +* Date/month/floor -> Date.prototype.floorMonth +* Date/month/year -> Date.prototype.floorYear +* Function.cache -> Function.memoize +* Function.getApplyArg -> Function.prototype.match +* Function.sequence -> Function.prototype.chain +* List.findSameStartLength -> Array.prototype.commonLeft +* Number.pad -> Number.getPad +* Object/plain/clone -> Object.prototype.copy +* Object/plain/elevate -> Object.prototype.flatten +* Object/plain/same -> Object.prototype.isDuplicate +* Object/plain/setValue -> Object.getSet +* String.format -> String.getFormat +* String.indent -> String.getIndent +* String.pad -> String.getPad +* String.trimLeftStr -> String.prototype.trimCommonLeft +* Object.merge -> Object.prototype.mergeProperties +* Object/plain/pluck -> Object.prototype.get +* Array.clone is now Array.prototype.copy and can be used also on any array-like + objects +* List.isList -> Object.isList +* List.toArray -> Object.prototype.toArray +* String/convert/dashToCamelCase -> String.prototype.dashToCamelCase + +Removed methods: +* Array.compact - removed destructive version (that operated on same array), we + have now non destructive version as Array.prototype.compact. +* Function.applyBind -> use apply.bind directly +* Function.bindBind -> use bind.bind directly +* Function.callBind -> use call.bind directly +* Fuction.clone -> no valid use case +* Function.dscope -> controversial approach, shouldn’t be considered seriously +* Function.functionalize -> It was experimental but standards are standards +* List/sort/length -> It can be easy obtained by Object.getCompareBy(‘length’) +* List.concat -> Concat’s for array-like’s makes no sense, just convert to array + first +* List.every -> Use Array.prototype.every directly +* List.filter -> Use Array.prototype.filter directly +* List.forEach -> User Array.prototype.forEach directly +* List.isListObject -> No valid use case, do: isList(list) && (typeof list === + 'object’) +* List.map -> Use Array.prototype.map directly +* List.reduce -> Use Array.prototype.reduce directly +* List.shiftSame -> Use Array.prototype.commonLeft and do slice +* List.slice -> Use Array.prototype.slice directly +* List.some -> Use Array.prototype.some directly +* Object.bindMethods -> it was version that considered descriptors, we have now + Object.prototype.bindMethods which operates only on enumerable properties +* Object.every -> version that considered all properties, we have now + Object.prototype.every which iterates only enumerables +* Object.invoke -> no use case +* Object.mergeDeep -> no use case +* Object.pluck -> no use case +* Object.same -> it considered descriptors, now there’s only Object.isDuplicate + which compares only enumerable properties +* Object.sameType -> no use case +* Object.toDescriptor and Object.toDescriptors -> replaced by much nicer + Object.descriptor functions +* Object/plain/link -> no use case (it was used internally only by + Object/plain/merge) +* Object/plain/setTrue -> now easily configurable by more universal + Object.getSet(true) +* String.trimRightStr -> Eventually String.prototype.trimCommonRight will be + added + +v0.6.3 -- 2011.12.12 +* Cleared npm warning for misnamed property in package.json + +v0.6.2 -- 2011.08.12 +* Calling String.indent without scope (global scope then) now treated as calling + it with null scope, it allows more direct invocations when using default nest + string: indent().call(str, nest) + +v0.6.1 -- 2011.08.08 +* Added TAD test suite to devDependencies, configured test commands. + Tests can be run with 'make test' or 'npm test' + +v0.6.0 -- 2011.08.07 +New methods: +* Array: clone, compact (in place) +* Date: format, duration, clone, monthDaysCount, day.floor, month.floor, + year.floor +* Function: getApplyArg, , ncurry, rncurry, hold, cache, log +* List: findSameStartLength, shiftSame, peek, isListObject +* Number: pad +* Object: sameType, toString, mapToArray, mergeDeep, toDescriptor, + toDescriptors, invoke +* String: startsWith, endsWith, indent, trimLeftStr, trimRightStr, pad, format + +Fixed: +* Object.extend does now prototypal extend as exptected +* Object.merge now tries to overwrite only configurable properties +* Function.flip + +Improved: +* Faster List.toArray +* Better global retrieval +* Functionalized all Function methods +* Renamed bindApply and bindCall to applyBind and callBind +* Removed Function.inherit (as it's unintuitive curry clone) +* Straightforward logic in Function.k +* Fixed naming of some tests files (letter case issue) +* Renamed Function.saturate into Function.lock +* String.dashToCamelCase digits support +* Strings now considered as List objects +* Improved List.compact +* Concise logic for List.concat +* Test wit TAD in clean ES5 context + +v0.5.1 -- 2011.07.11 +* Function's bindBind, bindCall and bindApply now more versatile + +v0.5.0 -- 2011.07.07 +* Removed Object.is and List.apply +* Renamed Object.plain.is to Object.plain.isPlainObject (keep naming convention + consistent) +* Improved documentation + +v0.4.0 -- 2011.07.05 +* Take most functions on Object to Object.plain to keep them away from object + descriptors +* Object functions with ES5 standard in mind (object descriptors) + +v0.3.0 -- 2011.06.24 +* New functions +* Consistent file naming (dash instead of camelCase) + +v0.2.1 -- 2011.05.28 +* Renamed Functions.K and Function.S to to lowercase versions (use consistent + naming) + +v0.2.0 -- 2011.05.28 +* Renamed Array folder to List (as its generic functions for array-like objects) +* Added Makefile +* Added various functions + +v0.1.0 -- 2011.05.24 +* Initial version diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/LICENSE new file mode 100644 index 0000000..de39071 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2011-2015 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/README.md new file mode 100644 index 0000000..11d8a34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/README.md @@ -0,0 +1,993 @@ +# es5-ext +## ECMAScript 5 extensions +### (with respect to ECMAScript 6 standard) + +Shims for upcoming ES6 standard and other goodies implemented strictly with ECMAScript conventions in mind. + +It's designed to be used in compliant ECMAScript 5 or ECMAScript 6 environments. Older environments are not supported, although most of the features should work with correct ECMAScript 5 shim on board. + +When used in ECMAScript 6 environment, native implementation (if valid) takes precedence over shims. + +### Installation + + $ npm install es5-ext + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +### Usage + +#### ECMAScript 6 features + +You can force ES6 features to be implemented in your environment, e.g. following will assign `from` function to `Array` (only if it's not implemented already). + +```javascript +require('es5-ext/array/from/implement'); +Array.from('foo'); // ['f', 'o', 'o'] +``` + +You can also access shims directly, without fixing native objects. Following will return native `Array.from` if it's available and fallback to shim if it's not. + +```javascript +var aFrom = require('es5-ext/array/from'); +aFrom('foo'); // ['f', 'o', 'o'] +``` + +If you want to use shim unconditionally (even if native implementation exists) do: + +```javascript +var aFrom = require('es5-ext/array/from/shim'); +aFrom('foo'); // ['f', 'o', 'o'] +``` + +##### List of ES6 shims + +It's about properties introduced with ES6 and those that have been updated in new spec. + +- `Array.from` -> `require('es5-ext/array/from')` +- `Array.of` -> `require('es5-ext/array/of')` +- `Array.prototype.concat` -> `require('es5-ext/array/#/concat')` +- `Array.prototype.copyWithin` -> `require('es5-ext/array/#/copy-within')` +- `Array.prototype.entries` -> `require('es5-ext/array/#/entries')` +- `Array.prototype.fill` -> `require('es5-ext/array/#/fill')` +- `Array.prototype.filter` -> `require('es5-ext/array/#/filter')` +- `Array.prototype.find` -> `require('es5-ext/array/#/find')` +- `Array.prototype.findIndex` -> `require('es5-ext/array/#/find-index')` +- `Array.prototype.keys` -> `require('es5-ext/array/#/keys')` +- `Array.prototype.map` -> `require('es5-ext/array/#/map')` +- `Array.prototype.slice` -> `require('es5-ext/array/#/slice')` +- `Array.prototype.splice` -> `require('es5-ext/array/#/splice')` +- `Array.prototype.values` -> `require('es5-ext/array/#/values')` +- `Array.prototype[@@iterator]` -> `require('es5-ext/array/#/@@iterator')` +- `Math.acosh` -> `require('es5-ext/math/acosh')` +- `Math.asinh` -> `require('es5-ext/math/asinh')` +- `Math.atanh` -> `require('es5-ext/math/atanh')` +- `Math.cbrt` -> `require('es5-ext/math/cbrt')` +- `Math.clz32` -> `require('es5-ext/math/clz32')` +- `Math.cosh` -> `require('es5-ext/math/cosh')` +- `Math.exmp1` -> `require('es5-ext/math/expm1')` +- `Math.fround` -> `require('es5-ext/math/fround')` +- `Math.hypot` -> `require('es5-ext/math/hypot')` +- `Math.imul` -> `require('es5-ext/math/imul')` +- `Math.log1p` -> `require('es5-ext/math/log1p')` +- `Math.log2` -> `require('es5-ext/math/log2')` +- `Math.log10` -> `require('es5-ext/math/log10')` +- `Math.sign` -> `require('es5-ext/math/sign')` +- `Math.signh` -> `require('es5-ext/math/signh')` +- `Math.tanh` -> `require('es5-ext/math/tanh')` +- `Math.trunc` -> `require('es5-ext/math/trunc')` +- `Number.EPSILON` -> `require('es5-ext/number/epsilon')` +- `Number.MAX_SAFE_INTEGER` -> `require('es5-ext/number/max-safe-integer')` +- `Number.MIN_SAFE_INTEGER` -> `require('es5-ext/number/min-safe-integer')` +- `Number.isFinite` -> `require('es5-ext/number/is-finite')` +- `Number.isInteger` -> `require('es5-ext/number/is-integer')` +- `Number.isNaN` -> `require('es5-ext/number/is-nan')` +- `Number.isSafeInteger` -> `require('es5-ext/number/is-safe-integer')` +- `Object.assign` -> `require('es5-ext/object/assign')` +- `Object.keys` -> `require('es5-ext/object/keys')` +- `Object.setPrototypeOf` -> `require('es5-ext/object/set-prototype-of')` +- `RegExp.prototype.match` -> `require('es5-ext/reg-exp/#/match')` +- `RegExp.prototype.replace` -> `require('es5-ext/reg-exp/#/replace')` +- `RegExp.prototype.search` -> `require('es5-ext/reg-exp/#/search')` +- `RegExp.prototype.split` -> `require('es5-ext/reg-exp/#/split')` +- `RegExp.prototype.sticky` -> Implement with `require('es5-ext/reg-exp/#/sticky/implement')`, use as function with `require('es5-ext/reg-exp/#/is-sticky')` +- `RegExp.prototype.unicode` -> Implement with `require('es5-ext/reg-exp/#/unicode/implement')`, use as function with `require('es5-ext/reg-exp/#/is-unicode')` +- `String.fromCodePoint` -> `require('es5-ext/string/from-code-point')` +- `String.raw` -> `require('es5-ext/string/raw')` +- `String.prototype.codePointAt` -> `require('es5-ext/string/#/code-point-at')` +- `String.prototype.contains` -> `require('es5-ext/string/#/contains')` +- `String.prototype.endsWith` -> `require('es5-ext/string/#/ends-with')` +- `String.prototype.normalize` -> `require('es5-ext/string/#/normalize')` +- `String.prototype.repeat` -> `require('es5-ext/string/#/repeat')` +- `String.prototype.startsWith` -> `require('es5-ext/string/#/starts-with')` +- `String.prototype[@@iterator]` -> `require('es5-ext/string/#/@@iterator')` + +#### Non ECMAScript standard features + +__es5-ext__ provides also other utils, and implements them as if they were proposed for a standard. It mostly offers methods (not functions) which can directly be assigned to native prototypes: + +```javascript +Object.defineProperty(Function.prototype, 'partial', { value: require('es5-ext/function/#/partial'), + configurable: true, enumerable: false, writable: true }); +Object.defineProperty(Array.prototype, 'flatten', { value: require('es5-ext/array/#/flatten'), + configurable: true, enumerable: false, writable: true }); +Object.defineProperty(String.prototype, 'capitalize', { value: require('es5-ext/string/#/capitalize'), + configurable: true, enumerable: false, writable: true }); +``` + +See [es5-extend](https://github.com/wookieb/es5-extend#es5-extend), a great utility that automatically will extend natives for you. + +__Important:__ Remember to __not__ extend natives in scope of generic reusable packages (e.g. ones you intend to publish to npm). Extending natives is fine __only__ if you're the _owner_ of the global scope, so e.g. in final project you lead development of. + +When you're in situation when native extensions are not good idea, then you should use methods indirectly: + + +```javascript +var flatten = require('es5-ext/array/#/flatten'); + +flatten.call([1, [2, [3, 4]]]); // [1, 2, 3, 4] +``` + +for better convenience you can turn methods into functions: + + +```javascript +var call = Function.prototype.call +var flatten = call.bind(require('es5-ext/array/#/flatten')); + +flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4] +``` + +You can configure custom toolkit (like [underscorejs](http://underscorejs.org/)), and use it throughout your application + +```javascript +var util = {}; +util.partial = call.bind(require('es5-ext/function/#/partial')); +util.flatten = call.bind(require('es5-ext/array/#/flatten')); +util.startsWith = call.bind(require('es5-ext/string/#/starts-with')); + +util.flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4] +``` + +As with native ones most methods are generic and can be run on any type of object. + +## API + +### Global extensions + +#### global _(es5-ext/global)_ + +Object that represents global scope + +### Array Constructor extensions + +#### from(arrayLike[, mapFn[, thisArg]]) _(es5-ext/array/from)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from). +Returns array representation of _iterable_ or _arrayLike_. If _arrayLike_ is an instance of array, its copy is returned. + +#### generate([length[, …fill]]) _(es5-ext/array/generate)_ + +Generate an array of pre-given _length_ built of repeated arguments. + +#### isPlainArray(x) _(es5-ext/array/is-plain-array)_ + +Returns true if object is plain array (not instance of one of the Array's extensions). + +#### of([…items]) _(es5-ext/array/of)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.of). +Create an array from given arguments. + +#### toArray(obj) _(es5-ext/array/to-array)_ + +Returns array representation of `obj`. If `obj` is already an array, `obj` is returned back. + +#### validArray(obj) _(es5-ext/array/valid-array)_ + +Returns `obj` if it's an array, otherwise throws `TypeError` + +### Array Prototype extensions + +#### arr.binarySearch(compareFn) _(es5-ext/array/#/binary-search)_ + +In __sorted__ list search for index of item for which _compareFn_ returns value closest to _0_. +It's variant of binary search algorithm + +#### arr.clear() _(es5-ext/array/#/clear)_ + +Clears the array + +#### arr.compact() _(es5-ext/array/#/compact)_ + +Returns a copy of the context with all non-values (`null` or `undefined`) removed. + +#### arr.concat() _(es5-ext/array/#/concat)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.concat). +ES6's version of `concat`. Supports `isConcatSpreadable` symbol, and returns array of same type as the context. + +#### arr.contains(searchElement[, position]) _(es5-ext/array/#/contains)_ + +Whether list contains the given value. + +#### arr.copyWithin(target, start[, end]) _(es5-ext/array/#/copy-within)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.copywithin). + +#### arr.diff(other) _(es5-ext/array/#/diff)_ + +Returns the array of elements that are present in context list but not present in other list. + +#### arr.eIndexOf(searchElement[, fromIndex]) _(es5-ext/array/#/e-index-of)_ + +_egal_ version of `indexOf` method. [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) logic is used for comparision + +#### arr.eLastIndexOf(searchElement[, fromIndex]) _(es5-ext/array/#/e-last-index-of)_ + +_egal_ version of `lastIndexOf` method. [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) logic is used for comparision + +#### arr.entries() _(es5-ext/array/#/entries)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.entries). +Returns iterator object, which traverses the array. Each value is represented with an array, where first value is an index and second is corresponding to index value. + +#### arr.exclusion([…lists]]) _(es5-ext/array/#/exclusion)_ + +Returns the array of elements that are found only in one of the lists (either context list or list provided in arguments). + +#### arr.fill(value[, start, end]) _(es5-ext/array/#/fill)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.fill). + +#### arr.filter(callback[, thisArg]) _(es5-ext/array/#/filter)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.filter). +ES6's version of `filter`, returns array of same type as the context. + +#### arr.find(predicate[, thisArg]) _(es5-ext/array/#/find)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.find). +Return first element for which given function returns true + +#### arr.findIndex(predicate[, thisArg]) _(es5-ext/array/#/find-index)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.findindex). +Return first index for which given function returns true + +#### arr.first() _(es5-ext/array/#/first)_ + +Returns value for first defined index + +#### arr.firstIndex() _(es5-ext/array/#/first-index)_ + +Returns first declared index of the array + +#### arr.flatten() _(es5-ext/array/#/flatten)_ + +Returns flattened version of the array + +#### arr.forEachRight(cb[, thisArg]) _(es5-ext/array/#/for-each-right)_ + +`forEach` starting from last element + +#### arr.group(cb[, thisArg]) _(es5-ext/array/#/group)_ + +Group list elements by value returned by _cb_ function + +#### arr.indexesOf(searchElement[, fromIndex]) _(es5-ext/array/#/indexes-of)_ + +Returns array of all indexes of given value + +#### arr.intersection([…lists]) _(es5-ext/array/#/intersection)_ + +Computes the array of values that are the intersection of all lists (context list and lists given in arguments) + +#### arr.isCopy(other) _(es5-ext/array/#/is-copy)_ + +Returns true if both context and _other_ lists have same content + +#### arr.isUniq() _(es5-ext/array/#/is-uniq)_ + +Returns true if all values in array are unique + +#### arr.keys() _(es5-ext/array/#/keys)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.keys). +Returns iterator object, which traverses all array indexes. + +#### arr.last() _(es5-ext/array/#/last)_ + +Returns value of last defined index + +#### arr.lastIndex() _(es5-ext/array/#/last)_ + +Returns last defined index of the array + +#### arr.map(callback[, thisArg]) _(es5-ext/array/#/map)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.map). +ES6's version of `map`, returns array of same type as the context. + +#### arr.remove(value[, …valuen]) _(es5-ext/array/#/remove)_ + +Remove values from the array + +#### arr.separate(sep) _(es5-ext/array/#/separate)_ + +Returns array with items separated with `sep` value + +#### arr.slice(callback[, thisArg]) _(es5-ext/array/#/slice)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.slice). +ES6's version of `slice`, returns array of same type as the context. + +#### arr.someRight(cb[, thisArg]) _(es5-ext/array/#/someRight)_ + +`some` starting from last element + +#### arr.splice(callback[, thisArg]) _(es5-ext/array/#/splice)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.splice). +ES6's version of `splice`, returns array of same type as the context. + +#### arr.uniq() _(es5-ext/array/#/uniq)_ + +Returns duplicate-free version of the array + +#### arr.values() _(es5-ext/array/#/values)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.values). +Returns iterator object which traverses all array values. + +#### arr[@@iterator] _(es5-ext/array/#/@@iterator)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype-@@iterator). +Returns iterator object which traverses all array values. + +### Boolean Constructor extensions + +#### isBoolean(x) _(es5-ext/boolean/is-boolean)_ + +Whether value is boolean + +### Date Constructor extensions + +#### isDate(x) _(es5-ext/date/is-date)_ + +Whether value is date instance + +#### validDate(x) _(es5-ext/date/valid-date)_ + +If given object is not date throw TypeError in other case return it. + +### Date Prototype extensions + +#### date.copy(date) _(es5-ext/date/#/copy)_ + +Returns a copy of the date object + +#### date.daysInMonth() _(es5-ext/date/#/days-in-month)_ + +Returns number of days of date's month + +#### date.floorDay() _(es5-ext/date/#/floor-day)_ + +Sets the date time to 00:00:00.000 + +#### date.floorMonth() _(es5-ext/date/#/floor-month)_ + +Sets date day to 1 and date time to 00:00:00.000 + +#### date.floorYear() _(es5-ext/date/#/floor-year)_ + +Sets date month to 0, day to 1 and date time to 00:00:00.000 + +#### date.format(pattern) _(es5-ext/date/#/format)_ + +Formats date up to given string. Supported patterns: + +* `%Y` - Year with century, 1999, 2003 +* `%y` - Year without century, 99, 03 +* `%m` - Month, 01..12 +* `%d` - Day of the month 01..31 +* `%H` - Hour (24-hour clock), 00..23 +* `%M` - Minute, 00..59 +* `%S` - Second, 00..59 +* `%L` - Milliseconds, 000..999 + +### Error Constructor extensions + +#### custom(message/*, code, ext*/) _(es5-ext/error/custom)_ + +Creates custom error object, optinally extended with `code` and other extension properties (provided with `ext` object) + +#### isError(x) _(es5-ext/error/is-error)_ + +Whether value is an error (instance of `Error`). + +#### validError(x) _(es5-ext/error/valid-error)_ + +If given object is not error throw TypeError in other case return it. + +### Error Prototype extensions + +#### err.throw() _(es5-ext/error/#/throw)_ + +Throws error + +### Function Constructor extensions + +Some of the functions were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele + +#### constant(x) _(es5-ext/function/constant)_ + +Returns a constant function that returns pregiven argument + +_k(x)(y) =def x_ + +#### identity(x) _(es5-ext/function/identity)_ + +Identity function. Returns first argument + +_i(x) =def x_ + +#### invoke(name[, …args]) _(es5-ext/function/invoke)_ + +Returns a function that takes an object as an argument, and applies object's +_name_ method to arguments. +_name_ can be name of the method or method itself. + +_invoke(name, …args)(object, …args2) =def object\[name\]\(…args, …args2\)_ + +#### isArguments(x) _(es5-ext/function/is-arguments)_ + +Whether value is arguments object + +#### isFunction(arg) _(es5-ext/function/is-function)_ + +Wether value is instance of function + +#### noop() _(es5-ext/function/noop)_ + +No operation function + +#### pluck(name) _(es5-ext/function/pluck)_ + +Returns a function that takes an object, and returns the value of its _name_ +property + +_pluck(name)(obj) =def obj[name]_ + +#### validFunction(arg) _(es5-ext/function/valid-function)_ + +If given object is not function throw TypeError in other case return it. + +### Function Prototype extensions + +Some of the methods were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele + +#### fn.compose([…fns]) _(es5-ext/function/#/compose)_ + +Applies the functions in reverse argument-list order. + +_f1.compose(f2, f3, f4)(…args) =def f1(f2(f3(f4(…arg))))_ + +#### fn.copy() _(es5-ext/function/#/copy)_ + +Produces copy of given function + +#### fn.curry([n]) _(es5-ext/function/#/curry)_ + +Invoking the function returned by this function only _n_ arguments are passed to the underlying function. If the underlying function is not saturated, the result is a function that passes all its arguments to the underlying function. +If _n_ is not provided then it defaults to context function length + +_f.curry(4)(arg1, arg2)(arg3)(arg4) =def f(arg1, args2, arg3, arg4)_ + +#### fn.lock([…args]) _(es5-ext/function/#/lock)_ + +Returns a function that applies the underlying function to _args_, and ignores its own arguments. + +_f.lock(…args)(…args2) =def f(…args)_ + +_Named after it's counterpart in Google Closure_ + +#### fn.not() _(es5-ext/function/#/not)_ + +Returns a function that returns boolean negation of value returned by underlying function. + +_f.not()(…args) =def !f(…args)_ + +#### fn.partial([…args]) _(es5-ext/function/#/partial)_ + +Returns a function that when called will behave like context function called with initially passed arguments. If more arguments are suplilied, they are appended to initial args. + +_f.partial(…args1)(…args2) =def f(…args1, …args2)_ + +#### fn.spread() _(es5-ext/function/#/spread)_ + +Returns a function that applies underlying function with first list argument + +_f.match()(args) =def f.apply(null, args)_ + +#### fn.toStringTokens() _(es5-ext/function/#/to-string-tokens)_ + +Serializes function into two (arguments and body) string tokens. Result is plain object with `args` and `body` properties. + +### Math extensions + +#### acosh(x) _(es5-ext/math/acosh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.acosh). + +#### asinh(x) _(es5-ext/math/asinh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.asinh). + +#### atanh(x) _(es5-ext/math/atanh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.atanh). + +#### cbrt(x) _(es5-ext/math/cbrt)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.cbrt). + +#### clz32(x) _(es5-ext/math/clz32)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.clz32). + +#### cosh(x) _(es5-ext/math/cosh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.cosh). + +#### expm1(x) _(es5-ext/math/expm1)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.expm1). + +#### fround(x) _(es5-ext/math/fround)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.fround). + +#### hypot([…values]) _(es5-ext/math/hypot)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.hypot). + +#### imul(x, y) _(es5-ext/math/imul)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.imul). + +#### log1p(x) _(es5-ext/math/log1p)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log1p). + +#### log2(x) _(es5-ext/math/log2)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log2). + +#### log10(x) _(es5-ext/math/log10)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log10). + +#### sign(x) _(es5-ext/math/sign)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.sign). + +#### sinh(x) _(es5-ext/math/sinh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.sinh). + +#### tanh(x) _(es5-ext/math/tanh)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.tanh). + +#### trunc(x) _(es5-ext/math/trunc)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.trunc). + +### Number Constructor extensions + +#### EPSILON _(es5-ext/number/epsilon)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.epsilon). + +The difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 x 10-16. + +#### isFinite(x) _(es5-ext/number/is-finite)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite). +Whether value is finite. Differs from global isNaN that it doesn't do type coercion. + +#### isInteger(x) _(es5-ext/number/is-integer)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isinteger). +Whether value is integer. + +#### isNaN(x) _(es5-ext/number/is-nan)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isnan). +Whether value is NaN. Differs from global isNaN that it doesn't do type coercion. + +#### isNumber(x) _(es5-ext/number/is-number)_ + +Whether given value is number + +#### isSafeInteger(x) _(es5-ext/number/is-safe-integer)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.issafeinteger). + +#### MAX_SAFE_INTEGER _(es5-ext/number/max-safe-integer)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.maxsafeinteger). +The value of Number.MAX_SAFE_INTEGER is 9007199254740991. + +#### MIN_SAFE_INTEGER _(es5-ext/number/min-safe-integer)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.minsafeinteger). +The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (253-1). + +#### toInteger(x) _(es5-ext/number/to-integer)_ + +Converts value to integer + +#### toPosInteger(x) _(es5-ext/number/to-pos-integer)_ + +Converts value to positive integer. If provided value is less than 0, then 0 is returned + +#### toUint32(x) _(es5-ext/number/to-uint32)_ + +Converts value to unsigned 32 bit integer. This type is used for array lengths. +See: http://www.2ality.com/2012/02/js-integers.html + +### Number Prototype extensions + +#### num.pad(length[, precision]) _(es5-ext/number/#/pad)_ + +Pad given number with zeros. Returns string + +### Object Constructor extensions + +#### assign(target, source[, …sourcen]) _(es5-ext/object/assign)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign). +Extend _target_ by enumerable own properties of other objects. If properties are already set on target object, they will be overwritten. + +#### clear(obj) _(es5-ext/object/clear)_ + +Remove all enumerable own properties of the object + +#### compact(obj) _(es5-ext/object/compact)_ + +Returns copy of the object with all enumerable properties that have no falsy values + +#### compare(obj1, obj2) _(es5-ext/object/compare)_ + +Universal cross-type compare function. To be used for e.g. array sort. + +#### copy(obj) _(es5-ext/object/copy)_ + +Returns copy of the object with all enumerable properties. + +#### copyDeep(obj) _(es5-ext/object/copy-deep)_ + +Returns deep copy of the object with all enumerable properties. + +#### count(obj) _(es5-ext/object/count)_ + +Counts number of enumerable own properties on object + +#### create(obj[, properties]) _(es5-ext/object/create)_ + +`Object.create` alternative that provides workaround for [V8 issue](http://code.google.com/p/v8/issues/detail?id=2804). + +When `null` is provided as a prototype, it's substituted with specially prepared object that derives from Object.prototype but has all Object.prototype properties shadowed with undefined. + +It's quirky solution that allows us to have plain objects with no truthy properties but with turnable prototype. + +Use only for objects that you plan to switch prototypes of and be aware of limitations of this workaround. + +#### eq(x, y) _(es5-ext/object/eq)_ + +Whether two values are equal, using [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) algorithm. + +#### every(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/every)_ + +Analogous to Array.prototype.every. Returns true if every key-value pair in this object satisfies the provided testing function. +Optionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). + +#### filter(obj, cb[, thisArg]) _(es5-ext/object/filter)_ + +Analogous to Array.prototype.filter. Returns new object with properites for which _cb_ function returned truthy value. + +#### firstKey(obj) _(es5-ext/object/first-key)_ + +Returns first enumerable key of the object, as keys are unordered by specification, it can be any key of an object. + +#### flatten(obj) _(es5-ext/object/flatten)_ + +Returns new object, with flatten properties of input object + +_flatten({ a: { b: 1 }, c: { d: 1 } }) =def { b: 1, d: 1 }_ + +#### forEach(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/for-each)_ + +Analogous to Array.prototype.forEach. Calls a function for each key-value pair found in object +Optionally _compareFn_ can be provided which assures that properties are iterated in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). + +#### getPropertyNames() _(es5-ext/object/get-property-names)_ + +Get all (not just own) property names of the object + +#### is(x, y) _(es5-ext/object/is)_ + +Whether two values are equal, using [_SameValue_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) algorithm. + +#### isArrayLike(x) _(es5-ext/object/is-array-like)_ + +Whether object is array-like object + +#### isCopy(x, y) _(es5-ext/object/is-copy)_ + +Two values are considered a copy of same value when all of their own enumerable properties have same values. + +#### isCopyDeep(x, y) _(es5-ext/object/is-copy-deep)_ + +Deep comparision of objects + +#### isEmpty(obj) _(es5-ext/object/is-empty)_ + +True if object doesn't have any own enumerable property + +#### isObject(arg) _(es5-ext/object/is-object)_ + +Whether value is not primitive + +#### isPlainObject(arg) _(es5-ext/object/is-plain-object)_ + +Whether object is plain object, its protototype should be Object.prototype and it cannot be host object. + +#### keyOf(obj, searchValue) _(es5-ext/object/key-of)_ + +Search object for value + +#### keys(obj) _(es5-ext/object/keys)_ + +[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys). +ES6's version of `keys`, doesn't throw on primitive input + +#### map(obj, cb[, thisArg]) _(es5-ext/object/map)_ + +Analogous to Array.prototype.map. Creates a new object with properties which values are results of calling a provided function on every key-value pair in this object. + +#### mapKeys(obj, cb[, thisArg]) _(es5-ext/object/map-keys)_ + +Create new object with same values, but remapped keys + +#### mixin(target, source) _(es5-ext/object/mixin)_ + +Extend _target_ by all own properties of other objects. Properties found in both objects will be overwritten (unless they're not configurable and cannot be overwritten). +_It was for a moment part of ECMAScript 6 draft._ + +#### mixinPrototypes(target, …source]) _(es5-ext/object/mixin-prototypes)_ + +Extends _target_, with all source and source's prototype properties. +Useful as an alternative for `setPrototypeOf` in environments in which it cannot be shimmed (no `__proto__` support). + +#### normalizeOptions(options) _(es5-ext/object/normalize-options)_ + +Normalizes options object into flat plain object. + +Useful for functions in which we either need to keep options object for future reference or need to modify it for internal use. + +- It never returns input `options` object back (always a copy is created) +- `options` can be undefined in such case empty plain object is returned. +- Copies all enumerable properties found down prototype chain. + +#### primitiveSet([…names]) _(es5-ext/object/primitive-set)_ + +Creates `null` prototype based plain object, and sets on it all property names provided in arguments to true. + +#### safeTraverse(obj[, …names]) _(es5-ext/object/safe-traverse)_ + +Safe navigation of object properties. See http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator + +#### serialize(value) _(es5-ext/object/serialize)_ + +Serialize value into string. Differs from [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) that it serializes also dates, functions and regular expresssions. + +#### setPrototypeOf(object, proto) _(es5-ext/object/set-prototype-of)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof). +If native version is not provided, it depends on existence of `__proto__` functionality, if it's missing, `null` instead of function is exposed. + +#### some(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/some)_ + +Analogous to Array.prototype.some Returns true if any key-value pair satisfies the provided +testing function. +Optionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). + +#### toArray(obj[, cb[, thisArg[, compareFn]]]) _(es5-ext/object/to-array)_ + +Creates an array of results of calling a provided function on every key-value pair in this object. +Optionally _compareFn_ can be provided which assures that results are added in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). + +#### unserialize(str) _(es5-ext/object/unserialize)_ + +Userializes value previously serialized with [serialize](#serializevalue-es5-extobjectserialize) + +#### validCallable(x) _(es5-ext/object/valid-callable)_ + +If given object is not callable throw TypeError in other case return it. + +#### validObject(x) _(es5-ext/object/valid-object)_ + +Throws error if given value is not an object, otherwise it is returned. + +#### validValue(x) _(es5-ext/object/valid-value)_ + +Throws error if given value is `null` or `undefined`, otherwise returns value. + +### RegExp Constructor extensions + +#### escape(str) _(es5-ext/reg-exp/escape)_ + +Escapes string to be used in regular expression + +#### isRegExp(x) _(es5-ext/reg-exp/is-reg-exp)_ + +Whether object is regular expression + +#### validRegExp(x) _(es5-ext/reg-exp/valid-reg-exp)_ + +If object is regular expression it is returned, otherwise TypeError is thrown. + +### RegExp Prototype extensions + +#### re.isSticky(x) _(es5-ext/reg-exp/#/is-sticky)_ + +Whether regular expression has `sticky` flag. + +It's to be used as counterpart to [regExp.sticky](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.sticky) if it's not implemented. + +#### re.isUnicode(x) _(es5-ext/reg-exp/#/is-unicode)_ + +Whether regular expression has `unicode` flag. + +It's to be used as counterpart to [regExp.unicode](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.unicode) if it's not implemented. + +#### re.match(string) _(es5-ext/reg-exp/#/match)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.match). + +#### re.replace(string, replaceValue) _(es5-ext/reg-exp/#/replace)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.replace). + +#### re.search(string) _(es5-ext/reg-exp/#/search)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.search). + +#### re.split(string) _(es5-ext/reg-exp/#/search)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.split). + +#### re.sticky _(es5-ext/reg-exp/#/sticky/implement)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.sticky). +It's a getter, so only `implement` and `is-implemented` modules are provided. + +#### re.unicode _(es5-ext/reg-exp/#/unicode/implement)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.unicode). +It's a getter, so only `implement` and `is-implemented` modules are provided. + +### String Constructor extensions + +#### formatMethod(fMap) _(es5-ext/string/format-method)_ + +Creates format method. It's used e.g. to create `Date.prototype.format` method + +#### fromCodePoint([…codePoints]) _(es5-ext/string/from-code-point)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.fromcodepoint) + +#### isString(x) _(es5-ext/string/is-string)_ + +Whether object is string + +#### randomUniq() _(es5-ext/string/random-uniq)_ + +Returns randomly generated id, with guarantee of local uniqueness (no same id will be returned twice) + +#### raw(callSite[, …substitutions]) _(es5-ext/string/raw)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.raw) + +### String Prototype extensions + +#### str.at(pos) _(es5-ext/string/#/at)_ + +_Proposed for ECMAScript 6/7 standard, but not (yet) in a draft_ + +Returns a string at given position in Unicode-safe manner. +Based on [implementation by Mathias Bynens](https://github.com/mathiasbynens/String.prototype.at). + +#### str.camelToHyphen() _(es5-ext/string/#/camel-to-hyphen)_ + +Convert camelCase string to hyphen separated, e.g. one-two-three -> oneTwoThree. +Useful when converting names from js property convention into filename convention. + +#### str.capitalize() _(es5-ext/string/#/capitalize)_ + +Capitalize first character of a string + +#### str.caseInsensitiveCompare(str) _(es5-ext/string/#/case-insensitive-compare)_ + +Case insensitive compare + +#### str.codePointAt(pos) _(es5-ext/string/#/code-point-at)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.codepointat) + +Based on [implementation by Mathias Bynens](https://github.com/mathiasbynens/String.prototype.codePointAt). + +#### str.contains(searchString[, position]) _(es5-ext/string/#/contains)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.contains) + +Whether string contains given string. + +#### str.endsWith(searchString[, endPosition]) _(es5-ext/string/#/ends-with)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.endswith). +Whether strings ends with given string + +#### str.hyphenToCamel() _(es5-ext/string/#/hyphen-to-camel)_ + +Convert hyphen separated string to camelCase, e.g. one-two-three -> oneTwoThree. +Useful when converting names from filename convention to js property name convention. + +#### str.indent(str[, count]) _(es5-ext/string/#/indent)_ + +Indents each line with provided _str_ (if _count_ given then _str_ is repeated _count_ times). + +#### str.last() _(es5-ext/string/#/last)_ + +Return last character + +#### str.normalize([form]) _(es5-ext/string/#/normalize)_ + +[_Introduced with ECMAScript 6_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize). +Returns the Unicode Normalization Form of a given string. +Based on Matsuza's version. Code used for integrated shim can be found at [github.com/walling/unorm](https://github.com/walling/unorm/blob/master/lib/unorm.js) + +#### str.pad(fill[, length]) _(es5-ext/string/#/pad)_ + +Pad string with _fill_. +If _length_ si given than _fill_ is reapated _length_ times. +If _length_ is negative then pad is applied from right. + +#### str.repeat(n) _(es5-ext/string/#/repeat)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.repeat). +Repeat given string _n_ times + +#### str.plainReplace(search, replace) _(es5-ext/string/#/plain-replace)_ + +Simple `replace` version. Doesn't support regular expressions. Replaces just first occurrence of search string. Doesn't support insert patterns, therefore it is safe to replace text with text obtained programmatically (there's no need for additional _$_ characters escape in such case). + +#### str.plainReplaceAll(search, replace) _(es5-ext/string/#/plain-replace-all)_ + +Simple `replace` version. Doesn't support regular expressions. Replaces all occurrences of search string. Doesn't support insert patterns, therefore it is safe to replace text with text obtained programmatically (there's no need for additional _$_ characters escape in such case). + +#### str.startsWith(searchString[, position]) _(es5-ext/string/#/starts-with)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.startswith). +Whether strings starts with given string + +#### str[@@iterator] _(es5-ext/string/#/@@iterator)_ + +[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype-@@iterator). +Returns iterator object which traverses all string characters (with respect to unicode symbols) + +### Tests [](https://travis-ci.org/medikoo/es5-ext) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/implement.js new file mode 100644 index 0000000..0f714a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, require('es6-symbol').iterator, { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/index.js new file mode 100644 index 0000000..a694626 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Array.prototype[require('es6-symbol').iterator] : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/is-implemented.js new file mode 100644 index 0000000..72eb1f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/is-implemented.js @@ -0,0 +1,16 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function () { + var arr = ['foo', 1], iterator, result; + if (typeof arr[iteratorSymbol] !== 'function') return false; + iterator = arr[iteratorSymbol](); + if (!iterator) return false; + if (typeof iterator.next !== 'function') return false; + result = iterator.next(); + if (!result) return false; + if (result.value !== 'foo') return false; + if (result.done !== false) return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/shim.js new file mode 100644 index 0000000..ff295df --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/@@iterator/shim.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('../values/shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/_compare-by-length.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/_compare-by-length.js new file mode 100644 index 0000000..d8343ce --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/_compare-by-length.js @@ -0,0 +1,9 @@ +// Used internally to sort array of lists by length + +'use strict'; + +var toPosInt = require('../../number/to-pos-integer'); + +module.exports = function (a, b) { + return toPosInt(a.length) - toPosInt(b.length); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/binary-search.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/binary-search.js new file mode 100644 index 0000000..8eb4567 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/binary-search.js @@ -0,0 +1,28 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , callable = require('../../object/valid-callable') + , value = require('../../object/valid-value') + + , floor = Math.floor; + +module.exports = function (compareFn) { + var length, low, high, middle; + + value(this); + callable(compareFn); + + length = toPosInt(this.length); + low = 0; + high = length - 1; + + while (low <= high) { + middle = floor((low + high) / 2); + if (compareFn(this[middle]) < 0) high = middle - 1; + else low = middle + 1; + } + + if (high < 0) return 0; + if (high >= length) return length - 1; + return high; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/clear.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/clear.js new file mode 100644 index 0000000..3587bdf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/clear.js @@ -0,0 +1,12 @@ +// Inspired by Google Closure: +// http://closure-library.googlecode.com/svn/docs/ +// closure_goog_array_array.js.html#goog.array.clear + +'use strict'; + +var value = require('../../object/valid-value'); + +module.exports = function () { + value(this).length = 0; + return this; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/compact.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/compact.js new file mode 100644 index 0000000..d529d5a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/compact.js @@ -0,0 +1,9 @@ +// Inspired by: http://documentcloud.github.com/underscore/#compact + +'use strict'; + +var filter = Array.prototype.filter; + +module.exports = function () { + return filter.call(this, function (val) { return val != null; }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/implement.js new file mode 100644 index 0000000..80c67cb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'concat', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/index.js new file mode 100644 index 0000000..db205ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.concat : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/is-implemented.js new file mode 100644 index 0000000..cab8bc9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +var SubArray = require('../../_sub-array-dummy-safe'); + +module.exports = function () { + return (new SubArray()).concat('foo') instanceof SubArray; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js new file mode 100644 index 0000000..8b28e4a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/concat/shim.js @@ -0,0 +1,39 @@ +'use strict'; + +var isPlainArray = require('../../is-plain-array') + , toPosInt = require('../../../number/to-pos-integer') + , isObject = require('../../../object/is-object') + + , isArray = Array.isArray, concat = Array.prototype.concat + , forEach = Array.prototype.forEach + + , isSpreadable; + +isSpreadable = function (value) { + if (!value) return false; + if (!isObject(value)) return false; + if (value['@@isConcatSpreadable'] !== undefined) { + return Boolean(value['@@isConcatSpreadable']); + } + return isArray(value); +}; + +module.exports = function (item/*, …items*/) { + var result; + if (!this || !isArray(this) || isPlainArray(this)) { + return concat.apply(this, arguments); + } + result = new this.constructor(this.length); + forEach.call(this, function (val, i) { result[i] = val; }); + forEach.call(arguments, function (arg) { + var base; + if (isSpreadable(arg)) { + base = result.length; + result.length += toPosInt(arg.length); + forEach.call(arg, function (val, i) { result[base + i] = val; }); + return; + } + result.push(arg); + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/contains.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/contains.js new file mode 100644 index 0000000..4a2f9f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/contains.js @@ -0,0 +1,7 @@ +'use strict'; + +var indexOf = require('./e-index-of'); + +module.exports = function (searchElement/*, position*/) { + return indexOf.call(this, searchElement, arguments[1]) > -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/implement.js new file mode 100644 index 0000000..eedbad7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'copyWithin', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/index.js new file mode 100644 index 0000000..bb89d0b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.copyWithin : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js new file mode 100644 index 0000000..8f17e06 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var arr = [1, 2, 3, 4, 5]; + if (typeof arr.copyWithin !== 'function') return false; + return String(arr.copyWithin(1, 3)) === '1,4,5,4,5'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/shim.js new file mode 100644 index 0000000..c0bfb8b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/copy-within/shim.js @@ -0,0 +1,39 @@ +// Taken from: https://github.com/paulmillr/es6-shim/ + +'use strict'; + +var toInteger = require('../../../number/to-integer') + , toPosInt = require('../../../number/to-pos-integer') + , validValue = require('../../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty + , max = Math.max, min = Math.min; + +module.exports = function (target, start/*, end*/) { + var o = validValue(this), end = arguments[2], l = toPosInt(o.length) + , to, from, fin, count, direction; + + target = toInteger(target); + start = toInteger(start); + end = (end === undefined) ? l : toInteger(end); + + to = target < 0 ? max(l + target, 0) : min(target, l); + from = start < 0 ? max(l + start, 0) : min(start, l); + fin = end < 0 ? max(l + end, 0) : min(end, l); + count = min(fin - from, l - to); + direction = 1; + + if ((from < to) && (to < (from + count))) { + direction = -1; + from += count - 1; + to += count - 1; + } + while (count > 0) { + if (hasOwnProperty.call(o, from)) o[to] = o[from]; + else delete o[from]; + from += direction; + to += direction; + count -= 1; + } + return o; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/diff.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/diff.js new file mode 100644 index 0000000..a1f9541 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/diff.js @@ -0,0 +1,13 @@ +'use strict'; + +var value = require('../../object/valid-value') + , contains = require('./contains') + + , filter = Array.prototype.filter; + +module.exports = function (other) { + (value(this) && value(other)); + return filter.call(this, function (item) { + return !contains.call(other, item); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-index-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-index-of.js new file mode 100644 index 0000000..80864d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-index-of.js @@ -0,0 +1,29 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , value = require('../../object/valid-value') + + , indexOf = Array.prototype.indexOf + , hasOwnProperty = Object.prototype.hasOwnProperty + , abs = Math.abs, floor = Math.floor; + +module.exports = function (searchElement/*, fromIndex*/) { + var i, l, fromIndex, val; + if (searchElement === searchElement) { //jslint: ignore + return indexOf.apply(this, arguments); + } + + l = toPosInt(value(this).length); + fromIndex = arguments[1]; + if (isNaN(fromIndex)) fromIndex = 0; + else if (fromIndex >= 0) fromIndex = floor(fromIndex); + else fromIndex = toPosInt(this.length) - floor(abs(fromIndex)); + + for (i = fromIndex; i < l; ++i) { + if (hasOwnProperty.call(this, i)) { + val = this[i]; + if (val !== val) return i; //jslint: ignore + } + } + return -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-last-index-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-last-index-of.js new file mode 100644 index 0000000..4fc536b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/e-last-index-of.js @@ -0,0 +1,29 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , value = require('../../object/valid-value') + + , lastIndexOf = Array.prototype.lastIndexOf + , hasOwnProperty = Object.prototype.hasOwnProperty + , abs = Math.abs, floor = Math.floor; + +module.exports = function (searchElement/*, fromIndex*/) { + var i, fromIndex, val; + if (searchElement === searchElement) { //jslint: ignore + return lastIndexOf.apply(this, arguments); + } + + value(this); + fromIndex = arguments[1]; + if (isNaN(fromIndex)) fromIndex = (toPosInt(this.length) - 1); + else if (fromIndex >= 0) fromIndex = floor(fromIndex); + else fromIndex = toPosInt(this.length) - floor(abs(fromIndex)); + + for (i = fromIndex; i >= 0; --i) { + if (hasOwnProperty.call(this, i)) { + val = this[i]; + if (val !== val) return i; //jslint: ignore + } + } + return -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/implement.js new file mode 100644 index 0000000..490de60 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'entries', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/index.js new file mode 100644 index 0000000..292792c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.entries : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/is-implemented.js new file mode 100644 index 0000000..e186c17 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/is-implemented.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function () { + var arr = [1, 'foo'], iterator, result; + if (typeof arr.entries !== 'function') return false; + iterator = arr.entries(); + if (!iterator) return false; + if (typeof iterator.next !== 'function') return false; + result = iterator.next(); + if (!result || !result.value) return false; + if (result.value[0] !== 0) return false; + if (result.value[1] !== 1) return false; + if (result.done !== false) return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/shim.js new file mode 100644 index 0000000..c052b53 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/entries/shim.js @@ -0,0 +1,4 @@ +'use strict'; + +var ArrayIterator = require('es6-iterator/array'); +module.exports = function () { return new ArrayIterator(this, 'key+value'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/exclusion.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/exclusion.js new file mode 100644 index 0000000..f08adc8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/exclusion.js @@ -0,0 +1,27 @@ +'use strict'; + +var value = require('../../object/valid-value') + , aFrom = require('../from') + , toArray = require('../to-array') + , contains = require('./contains') + , byLength = require('./_compare-by-length') + + , filter = Array.prototype.filter, push = Array.prototype.push; + +module.exports = function (/*…lists*/) { + var lists, seen, result; + if (!arguments.length) return aFrom(this); + push.apply(lists = [this], arguments); + lists.forEach(value); + seen = []; + result = []; + lists.sort(byLength).forEach(function (list) { + result = result.filter(function (item) { + return !contains.call(list, item); + }).concat(filter.call(list, function (x) { + return !contains.call(seen, x); + })); + push.apply(seen, toArray(list)); + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/implement.js new file mode 100644 index 0000000..2251191 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'fill', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/index.js new file mode 100644 index 0000000..36c1f66 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.fill : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/is-implemented.js new file mode 100644 index 0000000..b8e5468 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var arr = [1, 2, 3, 4, 5, 6]; + if (typeof arr.fill !== 'function') return false; + return String(arr.fill(-1, -3)) === '1,2,3,-1,-1,-1'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/shim.js new file mode 100644 index 0000000..45823be --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/fill/shim.js @@ -0,0 +1,21 @@ +// Taken from: https://github.com/paulmillr/es6-shim/ + +'use strict'; + +var toInteger = require('../../../number/to-integer') + , toPosInt = require('../../../number/to-pos-integer') + , validValue = require('../../../object/valid-value') + + , max = Math.max, min = Math.min; + +module.exports = function (value/*, start, end*/) { + var o = validValue(this), start = arguments[1], end = arguments[2] + , l = toPosInt(o.length), relativeStart, i; + + start = (start === undefined) ? 0 : toInteger(start); + end = (end === undefined) ? l : toInteger(end); + + relativeStart = start < 0 ? max(l + start, 0) : min(start, l); + for (i = relativeStart; i < l && i < end; ++i) o[i] = value; + return o; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/implement.js new file mode 100644 index 0000000..090c5f1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'filter', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/index.js new file mode 100644 index 0000000..bcf0268 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.filter : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/is-implemented.js new file mode 100644 index 0000000..5577273 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +var SubArray = require('../../_sub-array-dummy-safe') + + , pass = function () { return true; }; + +module.exports = function () { + return (new SubArray()).filter(pass) instanceof SubArray; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/shim.js new file mode 100644 index 0000000..b0116de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/filter/shim.js @@ -0,0 +1,22 @@ +'use strict'; + +var isPlainArray = require('../../is-plain-array') + , callable = require('../../../object/valid-callable') + + , isArray = Array.isArray, filter = Array.prototype.filter + , forEach = Array.prototype.forEach, call = Function.prototype.call; + +module.exports = function (callbackFn/*, thisArg*/) { + var result, thisArg, i; + if (!this || !isArray(this) || isPlainArray(this)) { + return filter.apply(this, arguments); + } + callable(callbackFn); + thisArg = arguments[1]; + result = new this.constructor(); + i = 0; + forEach.call(this, function (val, j, self) { + if (call.call(callbackFn, thisArg, val, j, self)) result[i++] = val; + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/implement.js new file mode 100644 index 0000000..556cb84 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'findIndex', + { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/index.js new file mode 100644 index 0000000..03a987e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.findIndex : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/is-implemented.js new file mode 100644 index 0000000..dbd3c81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +var fn = function (x) { return x > 3; }; + +module.exports = function () { + var arr = [1, 2, 3, 4, 5, 6]; + if (typeof arr.findIndex !== 'function') return false; + return arr.findIndex(fn) === 3; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/shim.js new file mode 100644 index 0000000..957939f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find-index/shim.js @@ -0,0 +1,20 @@ +'use strict'; + +var callable = require('../../../object/valid-callable') + , value = require('../../../object/valid-value') + + , some = Array.prototype.some, apply = Function.prototype.apply; + +module.exports = function (predicate/*, thisArg*/) { + var k, self; + self = Object(value(this)); + callable(predicate); + + return some.call(self, function (value, index) { + if (apply.call(predicate, this, arguments)) { + k = index; + return true; + } + return false; + }, arguments[1]) ? k : -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/implement.js new file mode 100644 index 0000000..0f37104 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'find', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/index.js new file mode 100644 index 0000000..96819d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.find : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/is-implemented.js new file mode 100644 index 0000000..cc7ec77 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +var fn = function (x) { return x > 3; }; + +module.exports = function () { + var arr = [1, 2, 3, 4, 5, 6]; + if (typeof arr.find !== 'function') return false; + return arr.find(fn) === 4; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/shim.js new file mode 100644 index 0000000..c7ee906 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/find/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +var findIndex = require('../find-index/shim'); + +module.exports = function (predicate/*, thisArg*/) { + var index = findIndex.apply(this, arguments); + return (index === -1) ? undefined : this[index]; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first-index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first-index.js new file mode 100644 index 0000000..7a9e4c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first-index.js @@ -0,0 +1,16 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , value = require('../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function () { + var i, l; + if (!(l = toPosInt(value(this).length))) return null; + i = 0; + while (!hasOwnProperty.call(this, i)) { + if (++i === l) return null; + } + return i; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first.js new file mode 100644 index 0000000..11df571 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/first.js @@ -0,0 +1,9 @@ +'use strict'; + +var firstIndex = require('./first-index'); + +module.exports = function () { + var i; + if ((i = firstIndex.call(this)) !== null) return this[i]; + return undefined; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/flatten.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/flatten.js new file mode 100644 index 0000000..c95407d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/flatten.js @@ -0,0 +1,12 @@ +'use strict'; + +var isArray = Array.isArray, forEach = Array.prototype.forEach + , push = Array.prototype.push; + +module.exports = function flatten() { + var r = []; + forEach.call(this, function (x) { + push.apply(r, isArray(x) ? flatten.call(x) : [x]); + }); + return r; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/for-each-right.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/for-each-right.js new file mode 100644 index 0000000..2f0ffae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/for-each-right.js @@ -0,0 +1,20 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , callable = require('../../object/valid-callable') + , value = require('../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var i, self, thisArg; + + self = Object(value(this)); + callable(cb); + thisArg = arguments[1]; + + for (i = toPosInt(self.length); i >= 0; --i) { + if (hasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/group.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/group.js new file mode 100644 index 0000000..fbb178c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/group.js @@ -0,0 +1,23 @@ +// Inspired by Underscore's groupBy: +// http://documentcloud.github.com/underscore/#groupBy + +'use strict'; + +var callable = require('../../object/valid-callable') + , value = require('../../object/valid-value') + + , forEach = Array.prototype.forEach, apply = Function.prototype.apply; + +module.exports = function (cb/*, thisArg*/) { + var r; + + (value(this) && callable(cb)); + + r = {}; + forEach.call(this, function (v) { + var key = apply.call(cb, this, arguments); + if (!r.hasOwnProperty(key)) r[key] = []; + r[key].push(v); + }, arguments[1]); + return r; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/index.js new file mode 100644 index 0000000..97ef65c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/index.js @@ -0,0 +1,40 @@ +'use strict'; + +module.exports = { + '@@iterator': require('./@@iterator'), + binarySearch: require('./binary-search'), + clear: require('./clear'), + compact: require('./compact'), + concat: require('./concat'), + contains: require('./contains'), + copyWithin: require('./copy-within'), + diff: require('./diff'), + eIndexOf: require('./e-index-of'), + eLastIndexOf: require('./e-last-index-of'), + entries: require('./entries'), + exclusion: require('./exclusion'), + fill: require('./fill'), + filter: require('./filter'), + find: require('./find'), + findIndex: require('./find-index'), + first: require('./first'), + firstIndex: require('./first-index'), + flatten: require('./flatten'), + forEachRight: require('./for-each-right'), + keys: require('./keys'), + group: require('./group'), + indexesOf: require('./indexes-of'), + intersection: require('./intersection'), + isCopy: require('./is-copy'), + isUniq: require('./is-uniq'), + last: require('./last'), + lastIndex: require('./last-index'), + map: require('./map'), + remove: require('./remove'), + separate: require('./separate'), + slice: require('./slice'), + someRight: require('./some-right'), + splice: require('./splice'), + uniq: require('./uniq'), + values: require('./values') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/indexes-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/indexes-of.js new file mode 100644 index 0000000..6b89157 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/indexes-of.js @@ -0,0 +1,12 @@ +'use strict'; + +var indexOf = require('./e-index-of'); + +module.exports = function (value/*, fromIndex*/) { + var r = [], i, fromIndex = arguments[1]; + while ((i = indexOf.call(this, value, fromIndex)) !== -1) { + r.push(i); + fromIndex = i + 1; + } + return r; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/intersection.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/intersection.js new file mode 100644 index 0000000..fadcb52 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/intersection.js @@ -0,0 +1,19 @@ +'use strict'; + +var value = require('../../object/valid-value') + , contains = require('./contains') + , byLength = require('./_compare-by-length') + + , filter = Array.prototype.filter, push = Array.prototype.push + , slice = Array.prototype.slice; + +module.exports = function (/*…list*/) { + var lists; + if (!arguments.length) slice.call(this); + push.apply(lists = [this], arguments); + lists.forEach(value); + lists.sort(byLength); + return lists.reduce(function (a, b) { + return filter.call(a, function (x) { return contains.call(b, x); }); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-copy.js new file mode 100644 index 0000000..ac7c79b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-copy.js @@ -0,0 +1,21 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , eq = require('../../object/eq') + , value = require('../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function (other) { + var i, l; + (value(this) && value(other)); + l = toPosInt(this.length); + if (l !== toPosInt(other.length)) return false; + for (i = 0; i < l; ++i) { + if (hasOwnProperty.call(this, i) !== hasOwnProperty.call(other, i)) { + return false; + } + if (!eq(this[i], other[i])) return false; + } + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-uniq.js new file mode 100644 index 0000000..b14f461 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/is-uniq.js @@ -0,0 +1,12 @@ +'use strict'; + +var indexOf = require('./e-index-of') + + , every = Array.prototype.every + , isFirst; + +isFirst = function (value, index) { + return indexOf.call(this, value) === index; +}; + +module.exports = function () { return every.call(this, isFirst, this); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/implement.js new file mode 100644 index 0000000..e18e617 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'keys', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/index.js new file mode 100644 index 0000000..2f89cff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.keys : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/is-implemented.js new file mode 100644 index 0000000..06bd87b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function () { + var arr = [1, 'foo'], iterator, result; + if (typeof arr.keys !== 'function') return false; + iterator = arr.keys(); + if (!iterator) return false; + if (typeof iterator.next !== 'function') return false; + result = iterator.next(); + if (!result) return false; + if (result.value !== 0) return false; + if (result.done !== false) return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/shim.js new file mode 100644 index 0000000..83773f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/keys/shim.js @@ -0,0 +1,4 @@ +'use strict'; + +var ArrayIterator = require('es6-iterator/array'); +module.exports = function () { return new ArrayIterator(this, 'key'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last-index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last-index.js new file mode 100644 index 0000000..a191d6e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last-index.js @@ -0,0 +1,16 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , value = require('../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function () { + var i, l; + if (!(l = toPosInt(value(this).length))) return null; + i = l - 1; + while (!hasOwnProperty.call(this, i)) { + if (--i === -1) return null; + } + return i; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last.js new file mode 100644 index 0000000..bf9d2f2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/last.js @@ -0,0 +1,9 @@ +'use strict'; + +var lastIndex = require('./last-index'); + +module.exports = function () { + var i; + if ((i = lastIndex.call(this)) !== null) return this[i]; + return undefined; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/implement.js new file mode 100644 index 0000000..3aabb87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'map', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/index.js new file mode 100644 index 0000000..66f6660 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? + Array.prototype.map : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/is-implemented.js new file mode 100644 index 0000000..c328b47 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var identity = require('../../../function/identity') + , SubArray = require('../../_sub-array-dummy-safe'); + +module.exports = function () { + return (new SubArray()).map(identity) instanceof SubArray; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/shim.js new file mode 100644 index 0000000..2ee7313 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/map/shim.js @@ -0,0 +1,21 @@ +'use strict'; + +var isPlainArray = require('../../is-plain-array') + , callable = require('../../../object/valid-callable') + + , isArray = Array.isArray, map = Array.prototype.map + , forEach = Array.prototype.forEach, call = Function.prototype.call; + +module.exports = function (callbackFn/*, thisArg*/) { + var result, thisArg; + if (!this || !isArray(this) || isPlainArray(this)) { + return map.apply(this, arguments); + } + callable(callbackFn); + thisArg = arguments[1]; + result = new this.constructor(this.length); + forEach.call(this, function (val, i, self) { + result[i] = call.call(callbackFn, thisArg, val, i, self); + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/remove.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/remove.js new file mode 100644 index 0000000..dcf8433 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/remove.js @@ -0,0 +1,12 @@ +'use strict'; + +var indexOf = require('./e-index-of') + + , forEach = Array.prototype.forEach, splice = Array.prototype.splice; + +module.exports = function (item/*, …item*/) { + forEach.call(arguments, function (item) { + var index = indexOf.call(this, item); + if (index !== -1) splice.call(this, index, 1); + }, this); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/separate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/separate.js new file mode 100644 index 0000000..dc974b8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/separate.js @@ -0,0 +1,10 @@ +'use strict'; + +var forEach = Array.prototype.forEach; + +module.exports = function (sep) { + var result = []; + forEach.call(this, function (val, i) { result.push(val, sep); }); + result.pop(); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/implement.js new file mode 100644 index 0000000..cd488a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'slice', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/index.js new file mode 100644 index 0000000..72200ca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Array.prototype.slice : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/is-implemented.js new file mode 100644 index 0000000..ec1985e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +var SubArray = require('../../_sub-array-dummy-safe'); + +module.exports = function () { + return (new SubArray()).slice() instanceof SubArray; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/shim.js new file mode 100644 index 0000000..2761a1a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/slice/shim.js @@ -0,0 +1,35 @@ +'use strict'; + +var toInteger = require('../../../number/to-integer') + , toPosInt = require('../../../number/to-pos-integer') + , isPlainArray = require('../../is-plain-array') + + , isArray = Array.isArray, slice = Array.prototype.slice + , hasOwnProperty = Object.prototype.hasOwnProperty, max = Math.max; + +module.exports = function (start, end) { + var length, result, i; + if (!this || !isArray(this) || isPlainArray(this)) { + return slice.apply(this, arguments); + } + length = toPosInt(this.length); + start = toInteger(start); + if (start < 0) start = max(length + start, 0); + else if (start > length) start = length; + if (end === undefined) { + end = length; + } else { + end = toInteger(end); + if (end < 0) end = max(length + end, 0); + else if (end > length) end = length; + } + if (start > end) start = end; + result = new this.constructor(end - start); + i = 0; + while (start !== end) { + if (hasOwnProperty.call(this, start)) result[i] = this[start]; + ++i; + ++start; + } + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/some-right.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/some-right.js new file mode 100644 index 0000000..de7460d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/some-right.js @@ -0,0 +1,22 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + , value = require('../../object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var i, self, thisArg; + self = Object(value(this)); + callable(cb); + thisArg = arguments[1]; + + for (i = self.length; i >= 0; --i) { + if (hasOwnProperty.call(self, i) && + call.call(cb, thisArg, self[i], i, self)) { + return true; + } + } + return false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/implement.js new file mode 100644 index 0000000..aab1f8e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'splice', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/index.js new file mode 100644 index 0000000..e8ecf3c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Array.prototype.splice : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/is-implemented.js new file mode 100644 index 0000000..ffddaa8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +var SubArray = require('../../_sub-array-dummy-safe'); + +module.exports = function () { + return (new SubArray()).splice(0) instanceof SubArray; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/shim.js new file mode 100644 index 0000000..a8505a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/splice/shim.js @@ -0,0 +1,14 @@ +'use strict'; + +var isPlainArray = require('../../is-plain-array') + + , isArray = Array.isArray, splice = Array.prototype.splice + , forEach = Array.prototype.forEach; + +module.exports = function (start, deleteCount/*, …items*/) { + var arr = splice.apply(this, arguments), result; + if (!this || !isArray(this) || isPlainArray(this)) return arr; + result = new this.constructor(arr.length); + forEach.call(arr, function (val, i) { result[i] = val; }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/uniq.js new file mode 100644 index 0000000..db01465 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/uniq.js @@ -0,0 +1,13 @@ +'use strict'; + +var indexOf = require('./e-index-of') + + , filter = Array.prototype.filter + + , isFirst; + +isFirst = function (value, index) { + return indexOf.call(this, value) === index; +}; + +module.exports = function () { return filter.call(this, isFirst, this); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/implement.js new file mode 100644 index 0000000..237281f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array.prototype, 'values', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/index.js new file mode 100644 index 0000000..c0832c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Array.prototype.values : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/is-implemented.js new file mode 100644 index 0000000..cc0c629 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function () { + var arr = ['foo', 1], iterator, result; + if (typeof arr.values !== 'function') return false; + iterator = arr.values(); + if (!iterator) return false; + if (typeof iterator.next !== 'function') return false; + result = iterator.next(); + if (!result) return false; + if (result.value !== 'foo') return false; + if (result.done !== false) return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/shim.js new file mode 100644 index 0000000..f6555fd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/#/values/shim.js @@ -0,0 +1,4 @@ +'use strict'; + +var ArrayIterator = require('es6-iterator/array'); +module.exports = function () { return new ArrayIterator(this, 'value'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_is-extensible.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_is-extensible.js new file mode 100644 index 0000000..6123206 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_is-extensible.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = (function () { + var SubArray = require('./_sub-array-dummy'), arr; + + if (!SubArray) return false; + arr = new SubArray(); + if (!Array.isArray(arr)) return false; + if (!(arr instanceof SubArray)) return false; + + arr[34] = 'foo'; + return (arr.length === 35); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy-safe.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy-safe.js new file mode 100644 index 0000000..5baf8a8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy-safe.js @@ -0,0 +1,23 @@ +'use strict'; + +var setPrototypeOf = require('../object/set-prototype-of') + , isExtensible = require('./_is-extensible'); + +module.exports = (function () { + var SubArray; + + if (isExtensible) return require('./_sub-array-dummy'); + + if (!setPrototypeOf) return null; + SubArray = function () { + var arr = Array.apply(this, arguments); + setPrototypeOf(arr, SubArray.prototype); + return arr; + }; + setPrototypeOf(SubArray, Array); + SubArray.prototype = Object.create(Array.prototype, { + constructor: { value: SubArray, enumerable: false, writable: true, + configurable: true } + }); + return SubArray; +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy.js new file mode 100644 index 0000000..a926d1a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/_sub-array-dummy.js @@ -0,0 +1,16 @@ +'use strict'; + +var setPrototypeOf = require('../object/set-prototype-of'); + +module.exports = (function () { + var SubArray; + + if (!setPrototypeOf) return null; + SubArray = function () { Array.apply(this, arguments); }; + setPrototypeOf(SubArray, Array); + SubArray.prototype = Object.create(Array.prototype, { + constructor: { value: SubArray, enumerable: false, writable: true, + configurable: true } + }); + return SubArray; +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/implement.js new file mode 100644 index 0000000..f3411b1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array, 'from', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/index.js new file mode 100644 index 0000000..3b99cda --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Array.from + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/is-implemented.js new file mode 100644 index 0000000..63ff2a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function () { + var from = Array.from, arr, result; + if (typeof from !== 'function') return false; + arr = ['raz', 'dwa']; + result = from(arr); + return Boolean(result && (result !== arr) && (result[1] === 'dwa')); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/shim.js new file mode 100644 index 0000000..a90ba2f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/from/shim.js @@ -0,0 +1,106 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , isArguments = require('../../function/is-arguments') + , isFunction = require('../../function/is-function') + , toPosInt = require('../../number/to-pos-integer') + , callable = require('../../object/valid-callable') + , validValue = require('../../object/valid-value') + , isString = require('../../string/is-string') + + , isArray = Array.isArray, call = Function.prototype.call + , desc = { configurable: true, enumerable: true, writable: true, value: null } + , defineProperty = Object.defineProperty; + +module.exports = function (arrayLike/*, mapFn, thisArg*/) { + var mapFn = arguments[1], thisArg = arguments[2], Constructor, i, j, arr, l, code, iterator + , result, getIterator, value; + + arrayLike = Object(validValue(arrayLike)); + + if (mapFn != null) callable(mapFn); + if (!this || (this === Array) || !isFunction(this)) { + // Result: Plain array + if (!mapFn) { + if (isArguments(arrayLike)) { + // Source: Arguments + l = arrayLike.length; + if (l !== 1) return Array.apply(null, arrayLike); + arr = new Array(1); + arr[0] = arrayLike[0]; + return arr; + } + if (isArray(arrayLike)) { + // Source: Array + arr = new Array(l = arrayLike.length); + for (i = 0; i < l; ++i) arr[i] = arrayLike[i]; + return arr; + } + } + arr = []; + } else { + // Result: Non plain array + Constructor = this; + } + + if (!isArray(arrayLike)) { + if ((getIterator = arrayLike[iteratorSymbol]) !== undefined) { + // Source: Iterator + iterator = callable(getIterator).call(arrayLike); + if (Constructor) arr = new Constructor(); + result = iterator.next(); + i = 0; + while (!result.done) { + value = mapFn ? call.call(mapFn, thisArg, result.value, i) : result.value; + if (!Constructor) { + arr[i] = value; + } else { + desc.value = value; + defineProperty(arr, i, desc); + } + result = iterator.next(); + ++i; + } + l = i; + } else if (isString(arrayLike)) { + // Source: String + l = arrayLike.length; + if (Constructor) arr = new Constructor(); + for (i = 0, j = 0; i < l; ++i) { + value = arrayLike[i]; + if ((i + 1) < l) { + code = value.charCodeAt(0); + if ((code >= 0xD800) && (code <= 0xDBFF)) value += arrayLike[++i]; + } + value = mapFn ? call.call(mapFn, thisArg, value, j) : value; + if (!Constructor) { + arr[j] = value; + } else { + desc.value = value; + defineProperty(arr, j, desc); + } + ++j; + } + l = j; + } + } + if (l === undefined) { + // Source: array or array-like + l = toPosInt(arrayLike.length); + if (Constructor) arr = new Constructor(l); + for (i = 0; i < l; ++i) { + value = mapFn ? call.call(mapFn, thisArg, arrayLike[i], i) : arrayLike[i]; + if (!Constructor) { + arr[i] = value; + } else { + desc.value = value; + defineProperty(arr, i, desc); + } + } + } + if (Constructor) { + desc.value = null; + arr.length = l; + } + return arr; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/generate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/generate.js new file mode 100644 index 0000000..5e06675 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/generate.js @@ -0,0 +1,20 @@ +'use strict'; + +var toPosInt = require('../number/to-pos-integer') + , value = require('../object/valid-value') + + , slice = Array.prototype.slice; + +module.exports = function (length/*, …fill*/) { + var arr, l; + length = toPosInt(value(length)); + if (length === 0) return []; + + arr = (arguments.length < 2) ? [undefined] : + slice.call(arguments, 1, 1 + length); + + while ((l = arr.length) < length) { + arr = arr.concat(arr.slice(0, length - l)); + } + return arr; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/index.js new file mode 100644 index 0000000..7a68678 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/index.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + from: require('./from'), + generate: require('./generate'), + isPlainArray: require('./is-plain-array'), + of: require('./of'), + toArray: require('./to-array'), + validArray: require('./valid-array') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/is-plain-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/is-plain-array.js new file mode 100644 index 0000000..6b37e40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/is-plain-array.js @@ -0,0 +1,11 @@ +'use strict'; + +var isArray = Array.isArray, getPrototypeOf = Object.getPrototypeOf; + +module.exports = function (obj) { + var proto; + if (!obj || !isArray(obj)) return false; + proto = getPrototypeOf(obj); + if (!isArray(proto)) return false; + return !isArray(getPrototypeOf(proto)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/implement.js new file mode 100644 index 0000000..bf2a5a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Array, 'of', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/index.js new file mode 100644 index 0000000..07ee54d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Array.of + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/is-implemented.js new file mode 100644 index 0000000..4390a10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function () { + var of = Array.of, result; + if (typeof of !== 'function') return false; + result = of('foo', 'bar'); + return Boolean(result && (result[1] === 'bar')); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/shim.js new file mode 100644 index 0000000..de72bc9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/of/shim.js @@ -0,0 +1,19 @@ +'use strict'; + +var isFunction = require('../../function/is-function') + + , slice = Array.prototype.slice, defineProperty = Object.defineProperty + , desc = { configurable: true, enumerable: true, writable: true, value: null }; + +module.exports = function (/*…items*/) { + var result, i, l; + if (!this || (this === Array) || !isFunction(this)) return slice.call(arguments); + result = new this(l = arguments.length); + for (i = 0; i < l; ++i) { + desc.value = arguments[i]; + defineProperty(result, i, desc); + } + desc.value = null; + result.length = l; + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/to-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/to-array.js new file mode 100644 index 0000000..ce908dd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/to-array.js @@ -0,0 +1,9 @@ +'use strict'; + +var from = require('./from') + + , isArray = Array.isArray; + +module.exports = function (arrayLike) { + return isArray(arrayLike) ? arrayLike : from(arrayLike); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/valid-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/valid-array.js new file mode 100644 index 0000000..d86a8f5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/array/valid-array.js @@ -0,0 +1,8 @@ +'use strict'; + +var isArray = Array.isArray; + +module.exports = function (value) { + if (isArray(value)) return value; + throw new TypeError(value + " is not an array"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/index.js new file mode 100644 index 0000000..c193b94 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + isBoolean: require('./is-boolean') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/is-boolean.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/is-boolean.js new file mode 100644 index 0000000..5d1a802 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/boolean/is-boolean.js @@ -0,0 +1,10 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(true); + +module.exports = function (x) { + return (typeof x === 'boolean') || ((typeof x === 'object') && + ((x instanceof Boolean) || (toString.call(x) === id))); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/copy.js new file mode 100644 index 0000000..69e2eb0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/copy.js @@ -0,0 +1,5 @@ +'use strict'; + +var getTime = Date.prototype.getTime; + +module.exports = function () { return new Date(getTime.call(this)); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/days-in-month.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/days-in-month.js new file mode 100644 index 0000000..e780efe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/days-in-month.js @@ -0,0 +1,17 @@ +'use strict'; + +var getMonth = Date.prototype.getMonth; + +module.exports = function () { + switch (getMonth.call(this)) { + case 1: + return this.getFullYear() % 4 ? 28 : 29; + case 3: + case 5: + case 8: + case 10: + return 30; + default: + return 31; + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-day.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-day.js new file mode 100644 index 0000000..0c9eb8b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-day.js @@ -0,0 +1,8 @@ +'use strict'; + +var setHours = Date.prototype.setHours; + +module.exports = function () { + setHours.call(this, 0, 0, 0, 0); + return this; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-month.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-month.js new file mode 100644 index 0000000..7328c25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-month.js @@ -0,0 +1,8 @@ +'use strict'; + +var floorDay = require('./floor-day'); + +module.exports = function () { + floorDay.call(this).setDate(1); + return this; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-year.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-year.js new file mode 100644 index 0000000..9c50853 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/floor-year.js @@ -0,0 +1,8 @@ +'use strict'; + +var floorMonth = require('./floor-month'); + +module.exports = function () { + floorMonth.call(this).setMonth(0); + return this; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/format.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/format.js new file mode 100644 index 0000000..15bd95f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/format.js @@ -0,0 +1,21 @@ +'use strict'; + +var pad = require('../../number/#/pad') + , date = require('../valid-date') + + , format; + +format = require('../../string/format-method')({ + Y: function () { return String(this.getFullYear()); }, + y: function () { return String(this.getFullYear()).slice(-2); }, + m: function () { return pad.call(this.getMonth() + 1, 2); }, + d: function () { return pad.call(this.getDate(), 2); }, + H: function () { return pad.call(this.getHours(), 2); }, + M: function () { return pad.call(this.getMinutes(), 2); }, + S: function () { return pad.call(this.getSeconds(), 2); }, + L: function () { return pad.call(this.getMilliseconds(), 3); } +}); + +module.exports = function (pattern) { + return format.call(date(this), pattern); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/index.js new file mode 100644 index 0000000..f71b295 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/#/index.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = { + copy: require('./copy'), + daysInMonth: require('./days-in-month'), + floorDay: require('./floor-day'), + floorMonth: require('./floor-month'), + floorYear: require('./floor-year'), + format: require('./format') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/index.js new file mode 100644 index 0000000..eac33fb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + isDate: require('./is-date'), + validDate: require('./valid-date') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/is-date.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/is-date.js new file mode 100644 index 0000000..6ba236e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/is-date.js @@ -0,0 +1,9 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(new Date()); + +module.exports = function (x) { + return (x && ((x instanceof Date) || (toString.call(x) === id))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/valid-date.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/valid-date.js new file mode 100644 index 0000000..7d1a9b6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/date/valid-date.js @@ -0,0 +1,8 @@ +'use strict'; + +var isDate = require('./is-date'); + +module.exports = function (x) { + if (!isDate(x)) throw new TypeError(x + " is not a Date object"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/index.js new file mode 100644 index 0000000..b984aa9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + throw: require('./throw') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/throw.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/throw.js new file mode 100644 index 0000000..7e15ebd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/#/throw.js @@ -0,0 +1,5 @@ +'use strict'; + +var error = require('../valid-error'); + +module.exports = function () { throw error(this); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/custom.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/custom.js new file mode 100644 index 0000000..bbc2dc2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/custom.js @@ -0,0 +1,20 @@ +'use strict'; + +var assign = require('../object/assign') + + , captureStackTrace = Error.captureStackTrace; + +exports = module.exports = function (message/*, code, ext*/) { + var err = new Error(), code = arguments[1], ext = arguments[2]; + if (ext == null) { + if (code && (typeof code === 'object')) { + ext = code; + code = null; + } + } + if (ext != null) assign(err, ext); + err.message = String(message); + if (code != null) err.code = String(code); + if (captureStackTrace) captureStackTrace(err, exports); + return err; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/index.js new file mode 100644 index 0000000..62984b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/index.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + custom: require('./custom'), + isError: require('./is-error'), + validError: require('./valid-error') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/is-error.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/is-error.js new file mode 100644 index 0000000..422705f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/is-error.js @@ -0,0 +1,9 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(new Error()); + +module.exports = function (x) { + return (x && ((x instanceof Error) || (toString.call(x)) === id)) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/valid-error.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/valid-error.js new file mode 100644 index 0000000..0bef768 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/error/valid-error.js @@ -0,0 +1,8 @@ +'use strict'; + +var isError = require('./is-error'); + +module.exports = function (x) { + if (!isError(x)) throw new TypeError(x + " is not an Error object"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/compose.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/compose.js new file mode 100644 index 0000000..1da5e01 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/compose.js @@ -0,0 +1,20 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + , aFrom = require('../../array/from') + + , apply = Function.prototype.apply, call = Function.prototype.call + , callFn = function (arg, fn) { return call.call(fn, this, arg); }; + +module.exports = function (fn/*, …fnn*/) { + var fns, first; + if (!fn) callable(fn); + fns = [this].concat(aFrom(arguments)); + fns.forEach(callable); + fns = fns.reverse(); + first = fns[0]; + fns = fns.slice(1); + return function (arg) { + return fns.reduce(callFn, apply.call(first, this, arguments)); + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/copy.js new file mode 100644 index 0000000..e1467f7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/copy.js @@ -0,0 +1,15 @@ +'use strict'; + +var mixin = require('../../object/mixin') + , validFunction = require('../valid-function') + + , re = /^\s*function\s*([\0-'\)-\uffff]+)*\s*\(([\0-\(\*-\uffff]*)\)\s*\{/; + +module.exports = function () { + var match = String(validFunction(this)).match(re), fn; + + fn = new Function('fn', 'return function ' + match[1].trim() + '(' + + match[2] + ') { return fn.apply(this, arguments); };')(this); + try { mixin(fn, this); } catch (ignore) {} + return fn; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/curry.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/curry.js new file mode 100644 index 0000000..943d6fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/curry.js @@ -0,0 +1,24 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , callable = require('../../object/valid-callable') + , defineLength = require('../_define-length') + + , slice = Array.prototype.slice, apply = Function.prototype.apply + , curry; + +curry = function self(fn, length, preArgs) { + return defineLength(function () { + var args = preArgs ? + preArgs.concat(slice.call(arguments, 0, length - preArgs.length)) : + slice.call(arguments, 0, length); + return (args.length === length) ? apply.call(fn, this, args) : + self(fn, length, args); + }, preArgs ? (length - preArgs.length) : length); +}; + +module.exports = function (/*length*/) { + var length = arguments[0]; + return curry(callable(this), + isNaN(length) ? toPosInt(this.length) : toPosInt(length)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/index.js new file mode 100644 index 0000000..8d0da00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/index.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = { + compose: require('./compose'), + copy: require('./copy'), + curry: require('./curry'), + lock: require('./lock'), + not: require('./not'), + partial: require('./partial'), + spread: require('./spread'), + toStringTokens: require('./to-string-tokens') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/lock.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/lock.js new file mode 100644 index 0000000..91e1a65 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/lock.js @@ -0,0 +1,12 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + + , apply = Function.prototype.apply; + +module.exports = function (/*…args*/) { + var fn = callable(this) + , args = arguments; + + return function () { return apply.call(fn, this, args); }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/not.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/not.js new file mode 100644 index 0000000..c6dbe97 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/not.js @@ -0,0 +1,14 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + , defineLength = require('../_define-length') + + , apply = Function.prototype.apply; + +module.exports = function () { + var fn = callable(this); + + return defineLength(function () { + return !apply.call(fn, this, arguments); + }, fn.length); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/partial.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/partial.js new file mode 100644 index 0000000..bf31a35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/partial.js @@ -0,0 +1,16 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + , aFrom = require('../../array/from') + , defineLength = require('../_define-length') + + , apply = Function.prototype.apply; + +module.exports = function (/*…args*/) { + var fn = callable(this) + , args = aFrom(arguments); + + return defineLength(function () { + return apply.call(fn, this, args.concat(aFrom(arguments))); + }, fn.length - args.length); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/spread.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/spread.js new file mode 100644 index 0000000..d7c93b7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/spread.js @@ -0,0 +1,10 @@ +'use strict'; + +var callable = require('../../object/valid-callable') + + , apply = Function.prototype.apply; + +module.exports = function () { + var fn = callable(this); + return function (args) { return apply.call(fn, this, args); }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/to-string-tokens.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/to-string-tokens.js new file mode 100644 index 0000000..67afeae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/#/to-string-tokens.js @@ -0,0 +1,11 @@ +'use strict'; + +var validFunction = require('../valid-function') + + , re = new RegExp('^\\s*function[\\0-\'\\)-\\uffff]*' + + '\\(([\\0-\\(\\*-\\uffff]*)\\)\\s*\\{([\\0-\\uffff]*)\\}\\s*$'); + +module.exports = function () { + var data = String(validFunction(this)).match(re); + return { args: data[1], body: data[2] }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/_define-length.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/_define-length.js new file mode 100644 index 0000000..496ea62 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/_define-length.js @@ -0,0 +1,44 @@ +'use strict'; + +var toPosInt = require('../number/to-pos-integer') + + , test = function (a, b) {}, desc, defineProperty + , generate, mixin; + +try { + Object.defineProperty(test, 'length', { configurable: true, writable: false, + enumerable: false, value: 1 }); +} catch (ignore) {} + +if (test.length === 1) { + // ES6 + desc = { configurable: true, writable: false, enumerable: false }; + defineProperty = Object.defineProperty; + module.exports = function (fn, length) { + length = toPosInt(length); + if (fn.length === length) return fn; + desc.value = length; + return defineProperty(fn, 'length', desc); + }; +} else { + mixin = require('../object/mixin'); + generate = (function () { + var cache = []; + return function (l) { + var args, i = 0; + if (cache[l]) return cache[l]; + args = []; + while (l--) args.push('a' + (++i).toString(36)); + return new Function('fn', 'return function (' + args.join(', ') + + ') { return fn.apply(this, arguments); };'); + }; + }()); + module.exports = function (src, length) { + var target; + length = toPosInt(length); + if (src.length === length) return src; + target = generate(length)(src); + try { mixin(target, src); } catch (ignore) {} + return target; + }; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/constant.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/constant.js new file mode 100644 index 0000000..10f1e20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/constant.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (x) { + return function () { return x; }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/identity.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/identity.js new file mode 100644 index 0000000..a9289f0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/identity.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (x) { return x; }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/index.js new file mode 100644 index 0000000..cfad3f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/index.js @@ -0,0 +1,15 @@ +// Export all modules. + +'use strict'; + +module.exports = { + '#': require('./#'), + constant: require('./constant'), + identity: require('./identity'), + invoke: require('./invoke'), + isArguments: require('./is-arguments'), + isFunction: require('./is-function'), + noop: require('./noop'), + pluck: require('./pluck'), + validFunction: require('./valid-function') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/invoke.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/invoke.js new file mode 100644 index 0000000..9195afd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/invoke.js @@ -0,0 +1,15 @@ +'use strict'; + +var isCallable = require('../object/is-callable') + , value = require('../object/valid-value') + + , slice = Array.prototype.slice, apply = Function.prototype.apply; + +module.exports = function (name/*, …args*/) { + var args = slice.call(arguments, 1), isFn = isCallable(name); + return function (obj) { + value(obj); + return apply.call(isFn ? name : obj[name], obj, + args.concat(slice.call(arguments, 1))); + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-arguments.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-arguments.js new file mode 100644 index 0000000..9a29855 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-arguments.js @@ -0,0 +1,7 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call((function () { return arguments; }())); + +module.exports = function (x) { return (toString.call(x) === id); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-function.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-function.js new file mode 100644 index 0000000..ab4399c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/is-function.js @@ -0,0 +1,9 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(require('./noop')); + +module.exports = function (f) { + return (typeof f === "function") && (toString.call(f) === id); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/noop.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/noop.js new file mode 100644 index 0000000..aa43bae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/noop.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function () {}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/pluck.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/pluck.js new file mode 100644 index 0000000..7f70a30 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/pluck.js @@ -0,0 +1,7 @@ +'use strict'; + +var value = require('../object/valid-value'); + +module.exports = function (name) { + return function (o) { return value(o)[name]; }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/valid-function.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/valid-function.js new file mode 100644 index 0000000..05fdee2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/function/valid-function.js @@ -0,0 +1,8 @@ +'use strict'; + +var isFunction = require('./is-function'); + +module.exports = function (x) { + if (!isFunction(x)) throw new TypeError(x + " is not a function"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/global.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/global.js new file mode 100644 index 0000000..872a40e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/global.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = new Function("return this")(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/index.js new file mode 100644 index 0000000..db9a760 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/index.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + global: require('./global'), + + array: require('./array'), + boolean: require('./boolean'), + date: require('./date'), + error: require('./error'), + function: require('./function'), + iterable: require('./iterable'), + math: require('./math'), + number: require('./number'), + object: require('./object'), + regExp: require('./reg-exp'), + string: require('./string') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/for-each.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/for-each.js new file mode 100644 index 0000000..f1e2042 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/for-each.js @@ -0,0 +1,12 @@ +'use strict'; + +var forOf = require('es6-iterator/for-of') + , isIterable = require('es6-iterator/is-iterable') + , iterable = require('./validate') + + , forEach = Array.prototype.forEach; + +module.exports = function (target, cb/*, thisArg*/) { + if (isIterable(iterable(target))) forOf(target, cb, arguments[2]); + else forEach.call(target, cb, arguments[2]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/index.js new file mode 100644 index 0000000..a3e16a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/index.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + forEach: require('./for-each'), + is: require('./is'), + validate: require('./validate'), + validateObject: require('./validate-object') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/is.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/is.js new file mode 100644 index 0000000..bb8bf28 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/is.js @@ -0,0 +1,10 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , isArrayLike = require('../object/is-array-like'); + +module.exports = function (x) { + if (x == null) return false; + if (typeof x[iteratorSymbol] === 'function') return true; + return isArrayLike(x); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate-object.js new file mode 100644 index 0000000..988a6ad --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate-object.js @@ -0,0 +1,9 @@ +'use strict'; + +var isObject = require('../object/is-object') + , is = require('./is'); + +module.exports = function (x) { + if (is(x) && isObject(x)) return x; + throw new TypeError(x + " is not an iterable or array-like object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate.js new file mode 100644 index 0000000..1be6d7f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/iterable/validate.js @@ -0,0 +1,8 @@ +'use strict'; + +var is = require('./is'); + +module.exports = function (x) { + if (is(x)) return x; + throw new TypeError(x + " is not an iterable or array-like"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_pack-ieee754.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_pack-ieee754.js new file mode 100644 index 0000000..eecda56 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_pack-ieee754.js @@ -0,0 +1,82 @@ +// Credit: https://github.com/paulmillr/es6-shim/ + +'use strict'; + +var abs = Math.abs, floor = Math.floor, log = Math.log, min = Math.min + , pow = Math.pow, LN2 = Math.LN2 + , roundToEven; + +roundToEven = function (n) { + var w = floor(n), f = n - w; + if (f < 0.5) return w; + if (f > 0.5) return w + 1; + return w % 2 ? w + 1 : w; +}; + +module.exports = function (v, ebits, fbits) { + var bias = (1 << (ebits - 1)) - 1, s, e, f, i, bits, str, bytes; + + // Compute sign, exponent, fraction + if (isNaN(v)) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; + f = pow(2, fbits - 1); + s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; + f = 0; + s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; + f = 0; + s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } else { + // Normal + e = e + bias; + f = f - pow(2, fbits); + } + } else { + // Subnormal + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + + // Pack sign, exponent, fraction + bits = []; + for (i = fbits; i; i -= 1) { + bits.push(f % 2 ? 1 : 0); + f = floor(f / 2); + } + for (i = ebits; i; i -= 1) { + bits.push(e % 2 ? 1 : 0); + e = floor(e / 2); + } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); + + // Bits to bytes + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_unpack-ieee754.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_unpack-ieee754.js new file mode 100644 index 0000000..c9f26f2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/_unpack-ieee754.js @@ -0,0 +1,33 @@ +// Credit: https://github.com/paulmillr/es6-shim/ + +'use strict'; + +var pow = Math.pow; + +module.exports = function (bytes, ebits, fbits) { + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; + + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); + b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + + // Produce number + if (e === (1 << ebits) - 1) return f !== 0 ? NaN : s * Infinity; + if (e > 0) return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + if (f !== 0) return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + return s < 0 ? -0 : 0; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/implement.js new file mode 100644 index 0000000..f48ad11 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'acosh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/index.js new file mode 100644 index 0000000..00ddea6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.acosh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/is-implemented.js new file mode 100644 index 0000000..363f0d8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var acosh = Math.acosh; + if (typeof acosh !== 'function') return false; + return acosh(2) === 1.3169578969248166; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/shim.js new file mode 100644 index 0000000..89a24b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/acosh/shim.js @@ -0,0 +1,12 @@ +'use strict'; + +var log = Math.log, sqrt = Math.sqrt; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x < 1) return NaN; + if (x === 1) return 0; + if (x === Infinity) return x; + return log(x + sqrt(x * x - 1)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/implement.js new file mode 100644 index 0000000..21f64d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'asinh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/index.js new file mode 100644 index 0000000..d415144 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.asinh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/is-implemented.js new file mode 100644 index 0000000..6c205f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var asinh = Math.asinh; + if (typeof asinh !== 'function') return false; + return asinh(2) === 1.4436354751788103; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/shim.js new file mode 100644 index 0000000..42fbf14 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/asinh/shim.js @@ -0,0 +1,15 @@ +'use strict'; + +var log = Math.log, sqrt = Math.sqrt; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (!isFinite(x)) return x; + if (x < 0) { + x = -x; + return -log(x + sqrt(x * x + 1)); + } + return log(x + sqrt(x * x + 1)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/implement.js new file mode 100644 index 0000000..1a48513 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'atanh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/index.js new file mode 100644 index 0000000..785b3de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.atanh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/is-implemented.js new file mode 100644 index 0000000..dbaf18e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var atanh = Math.atanh; + if (typeof atanh !== 'function') return false; + return atanh(0.5) === 0.5493061443340549; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/shim.js new file mode 100644 index 0000000..531e289 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/atanh/shim.js @@ -0,0 +1,14 @@ +'use strict'; + +var log = Math.log; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x < -1) return NaN; + if (x > 1) return NaN; + if (x === -1) return -Infinity; + if (x === 1) return Infinity; + if (x === 0) return x; + return 0.5 * log((1 + x) / (1 - x)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/implement.js new file mode 100644 index 0000000..3a12dde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'cbrt', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/index.js new file mode 100644 index 0000000..89f966d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.cbrt + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/is-implemented.js new file mode 100644 index 0000000..69809f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var cbrt = Math.cbrt; + if (typeof cbrt !== 'function') return false; + return cbrt(2) === 1.2599210498948732; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/shim.js new file mode 100644 index 0000000..bca1960 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cbrt/shim.js @@ -0,0 +1,12 @@ +'use strict'; + +var pow = Math.pow; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (!isFinite(x)) return x; + if (x < 0) return -pow(-x, 1 / 3); + return pow(x, 1 / 3); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/implement.js new file mode 100644 index 0000000..339df33 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'clz32', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/index.js new file mode 100644 index 0000000..1687b33 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.clz32 + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/is-implemented.js new file mode 100644 index 0000000..ccc8f71 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var clz32 = Math.clz32; + if (typeof clz32 !== 'function') return false; + return clz32(1000) === 22; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/shim.js new file mode 100644 index 0000000..2a582da --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/clz32/shim.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (value) { + value = value >>> 0; + return value ? 32 - value.toString(2).length : 32; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/implement.js new file mode 100644 index 0000000..f90d830 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'cosh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/index.js new file mode 100644 index 0000000..000636a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.cosh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/is-implemented.js new file mode 100644 index 0000000..c796bcb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var cosh = Math.cosh; + if (typeof cosh !== 'function') return false; + return cosh(1) === 1.5430806348152437; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/shim.js new file mode 100644 index 0000000..f9062bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/cosh/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +var exp = Math.exp; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return 1; + if (!isFinite(x)) return Infinity; + return (exp(x) + exp(-x)) / 2; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/implement.js new file mode 100644 index 0000000..fc20c8c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'expm1', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/index.js new file mode 100644 index 0000000..4c1bc77 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.expm1 + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/is-implemented.js new file mode 100644 index 0000000..3b106d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var expm1 = Math.expm1; + if (typeof expm1 !== 'function') return false; + return expm1(1).toFixed(15) === '1.718281828459045'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/shim.js new file mode 100644 index 0000000..9c8c236 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/expm1/shim.js @@ -0,0 +1,16 @@ +// Thanks: https://github.com/monolithed/ECMAScript-6 + +'use strict'; + +var exp = Math.exp; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (x === Infinity) return Infinity; + if (x === -Infinity) return -1; + + if ((x > -1.0e-6) && (x < 1.0e-6)) return x + x * x / 2; + return exp(x) - 1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/implement.js new file mode 100644 index 0000000..c55b26c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'fround', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/index.js new file mode 100644 index 0000000..a077ed0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.fround + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/is-implemented.js new file mode 100644 index 0000000..ffbf094 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var fround = Math.fround; + if (typeof fround !== 'function') return false; + return fround(1.337) === 1.3370000123977661; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/shim.js new file mode 100644 index 0000000..f2c86e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/fround/shim.js @@ -0,0 +1,33 @@ +// Credit: https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js + +'use strict'; + +var toFloat32; + +if (typeof Float32Array !== 'undefined') { + toFloat32 = (function () { + var float32Array = new Float32Array(1); + return function (x) { + float32Array[0] = x; + return float32Array[0]; + }; + }()); +} else { + toFloat32 = (function () { + var pack = require('../_pack-ieee754') + , unpack = require('../_unpack-ieee754'); + + return function (x) { + return unpack(pack(x, 8, 23), 8, 23); + }; + }()); +} + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (!isFinite(x)) return x; + + return toFloat32(x); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/implement.js new file mode 100644 index 0000000..b27fda7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'hypot', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/index.js new file mode 100644 index 0000000..334bc58 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.hypot + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/is-implemented.js new file mode 100644 index 0000000..e75c5d3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var hypot = Math.hypot; + if (typeof hypot !== 'function') return false; + return hypot(3, 4) === 5; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/shim.js new file mode 100644 index 0000000..3d0988b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/hypot/shim.js @@ -0,0 +1,34 @@ +// Thanks for hints: https://github.com/paulmillr/es6-shim + +'use strict'; + +var some = Array.prototype.some, abs = Math.abs, sqrt = Math.sqrt + + , compare = function (a, b) { return b - a; } + , divide = function (x) { return x / this; } + , add = function (sum, number) { return sum + number * number; }; + +module.exports = function (val1, val2/*, …valn*/) { + var result, numbers; + if (!arguments.length) return 0; + some.call(arguments, function (val) { + if (isNaN(val)) { + result = NaN; + return; + } + if (!isFinite(val)) { + result = Infinity; + return true; + } + if (result !== undefined) return; + val = Number(val); + if (val === 0) return; + if (!numbers) numbers = [abs(val)]; + else numbers.push(abs(val)); + }); + if (result !== undefined) return result; + if (!numbers) return 0; + + numbers.sort(compare); + return numbers[0] * sqrt(numbers.map(divide, numbers[0]).reduce(add, 0)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/implement.js new file mode 100644 index 0000000..ed207bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'imul', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/index.js new file mode 100644 index 0000000..41e5d5f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.imul + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/is-implemented.js new file mode 100644 index 0000000..d8495de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var imul = Math.imul; + if (typeof imul !== 'function') return false; + return imul(-1, 8) === -8; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/shim.js new file mode 100644 index 0000000..8fd8a8d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/imul/shim.js @@ -0,0 +1,13 @@ +// Thanks: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference +// /Global_Objects/Math/imul + +'use strict'; + +module.exports = function (x, y) { + var xh = (x >>> 16) & 0xffff, xl = x & 0xffff + , yh = (y >>> 16) & 0xffff, yl = y & 0xffff; + + // the shift by 0 fixes the sign on the high part + // the final |0 converts the unsigned value into a signed value + return ((xl * yl) + (((xh * yl + xl * yh) << 16) >>> 0) | 0); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/index.js new file mode 100644 index 0000000..d112d0b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/index.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = { + acosh: require('./acosh'), + asinh: require('./asinh'), + atanh: require('./atanh'), + cbrt: require('./cbrt'), + clz32: require('./clz32'), + cosh: require('./cosh'), + expm1: require('./expm1'), + fround: require('./fround'), + hypot: require('./hypot'), + imul: require('./imul'), + log10: require('./log10'), + log2: require('./log2'), + log1p: require('./log1p'), + sign: require('./sign'), + sinh: require('./sinh'), + tanh: require('./tanh'), + trunc: require('./trunc') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/implement.js new file mode 100644 index 0000000..dd96edd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'log10', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/index.js new file mode 100644 index 0000000..a9eee51 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.log10 + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/is-implemented.js new file mode 100644 index 0000000..c7f40ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var log10 = Math.log10; + if (typeof log10 !== 'function') return false; + return log10(2) === 0.3010299956639812; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/shim.js new file mode 100644 index 0000000..fc77287 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log10/shim.js @@ -0,0 +1,14 @@ +'use strict'; + +var log = Math.log, LOG10E = Math.LOG10E; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x < 0) return NaN; + if (x === 0) return -Infinity; + if (x === 1) return 0; + if (x === Infinity) return Infinity; + + return log(x) * LOG10E; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/implement.js new file mode 100644 index 0000000..f62f91f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'log1p', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/index.js new file mode 100644 index 0000000..107b114 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.log1p + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/is-implemented.js new file mode 100644 index 0000000..61e9097 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var log1p = Math.log1p; + if (typeof log1p !== 'function') return false; + return log1p(1) === 0.6931471805599453; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/shim.js new file mode 100644 index 0000000..10acebc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log1p/shim.js @@ -0,0 +1,17 @@ +// Thanks: https://github.com/monolithed/ECMAScript-6/blob/master/ES6.js + +'use strict'; + +var log = Math.log; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x < -1) return NaN; + if (x === -1) return -Infinity; + if (x === 0) return x; + if (x === Infinity) return Infinity; + + if (x > -1.0e-8 && x < 1.0e-8) return (x - x * x / 2); + return log(1 + x); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/implement.js new file mode 100644 index 0000000..8483f09 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'log2', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/index.js new file mode 100644 index 0000000..87e9050 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.log2 + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/is-implemented.js new file mode 100644 index 0000000..802322f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var log2 = Math.log2; + if (typeof log2 !== 'function') return false; + return log2(3).toFixed(15) === '1.584962500721156'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/shim.js new file mode 100644 index 0000000..cd80994 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/log2/shim.js @@ -0,0 +1,14 @@ +'use strict'; + +var log = Math.log, LOG2E = Math.LOG2E; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x < 0) return NaN; + if (x === 0) return -Infinity; + if (x === 1) return 0; + if (x === Infinity) return Infinity; + + return log(x) * LOG2E; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/implement.js new file mode 100644 index 0000000..b0db2f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'sign', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/index.js new file mode 100644 index 0000000..b232633 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.sign + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/is-implemented.js new file mode 100644 index 0000000..6d0de47 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var sign = Math.sign; + if (typeof sign !== 'function') return false; + return ((sign(10) === 1) && (sign(-20) === -1)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/shim.js new file mode 100644 index 0000000..4df9c95 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sign/shim.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (value) { + value = Number(value); + if (isNaN(value) || (value === 0)) return value; + return (value > 0) ? 1 : -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/implement.js new file mode 100644 index 0000000..f259a63 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'sinh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/index.js new file mode 100644 index 0000000..e5bea57 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.sinh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/is-implemented.js new file mode 100644 index 0000000..888ec67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var sinh = Math.sinh; + if (typeof sinh !== 'function') return false; + return ((sinh(1) === 1.1752011936438014) && (sinh(Number.MIN_VALUE) === 5e-324)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/shim.js new file mode 100644 index 0000000..5b725be --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/sinh/shim.js @@ -0,0 +1,17 @@ +// Parts of implementation taken from es6-shim project +// See: https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js + +'use strict'; + +var expm1 = require('../expm1') + + , abs = Math.abs, exp = Math.exp, e = Math.E; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (!isFinite(x)) return x; + if (abs(x) < 1) return (expm1(x) - expm1(-x)) / 2; + return (exp(x - 1) - exp(-x - 1)) * e / 2; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/implement.js new file mode 100644 index 0000000..5199a02 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'tanh', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/index.js new file mode 100644 index 0000000..6099c40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.tanh + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/is-implemented.js new file mode 100644 index 0000000..a7d2223 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var tanh = Math.tanh; + if (typeof tanh !== 'function') return false; + return ((tanh(1) === 0.7615941559557649) && (tanh(Number.MAX_VALUE) === 1)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/shim.js new file mode 100644 index 0000000..f6e948f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/tanh/shim.js @@ -0,0 +1,17 @@ +'use strict'; + +var exp = Math.exp; + +module.exports = function (x) { + var a, b; + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (x === Infinity) return 1; + if (x === -Infinity) return -1; + a = exp(x); + if (a === Infinity) return 1; + b = exp(-x); + if (b === Infinity) return -1; + return (a - b) / (a + b); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/implement.js new file mode 100644 index 0000000..3ee80ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Math, 'trunc', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/index.js new file mode 100644 index 0000000..0b0f9b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Math.trunc + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/is-implemented.js new file mode 100644 index 0000000..3e8cde1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var trunc = Math.trunc; + if (typeof trunc !== 'function') return false; + return (trunc(13.67) === 13) && (trunc(-13.67) === -13); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/shim.js new file mode 100644 index 0000000..02e2c2a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/math/trunc/shim.js @@ -0,0 +1,13 @@ +'use strict'; + +var floor = Math.floor; + +module.exports = function (x) { + if (isNaN(x)) return NaN; + x = Number(x); + if (x === 0) return x; + if (x === Infinity) return Infinity; + if (x === -Infinity) return -Infinity; + if (x > 0) return floor(x); + return -floor(-x); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.lint new file mode 100644 index 0000000..1851752 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.lint @@ -0,0 +1,13 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus +newcap +vars diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml new file mode 100644 index 0000000..afd3509 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-symbol@medikoo.com diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/CHANGES new file mode 100644 index 0000000..df8c27e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/CHANGES @@ -0,0 +1,34 @@ +v2.0.1 -- 2015.01.28 +* Fix Symbol.prototype[Symbol.isPrimitive] implementation +* Improve validation within Symbol.prototype.toString and + Symbol.prototype.valueOf + +v2.0.0 -- 2015.01.28 +* Update up to changes in specification: + * Implement `for` and `keyFor` + * Remove `Symbol.create` and `Symbol.isRegExp` + * Add `Symbol.match`, `Symbol.replace`, `Symbol.search`, `Symbol.species` and + `Symbol.split` +* Rename `validSymbol` to `validateSymbol` +* Improve documentation +* Remove dead test modules + +v1.0.0 -- 2015.01.26 +* Fix enumerability for symbol properties set normally (e.g. obj[symbol] = value) +* Introduce initialization via hidden constructor +* Fix isSymbol handling of polyfill values when native Symbol is present +* Fix spelling of LICENSE +* Configure lint scripts + +v0.1.1 -- 2014.10.07 +* Fix isImplemented, so it returns true in case of polyfill +* Improve documentations + +v0.1.0 -- 2014.04.28 +* Assure strictly npm dependencies +* Update to use latest versions of dependencies +* Fix implementation detection so it doesn't crash on `String(symbol)` +* throw on `new Symbol()` (as decided by TC39) + +v0.0.0 -- 2013.11.15 +* Initial (dev) version \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/LICENSE new file mode 100644 index 0000000..04724a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/README.md new file mode 100644 index 0000000..95d6780 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/README.md @@ -0,0 +1,71 @@ +# es6-symbol +## ECMAScript 6 Symbol polyfill + +For more information about symbols see following links +- [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html) +- [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) +- [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor) + +### Limitations + +Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely. + +### Usage + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't (but without implementing `Symbol` on global scope), do: + +```javascript +var Symbol = require('es6-symbol'); +``` + +If you want to make sure your environment implements `Symbol`, do: + +```javascript +require('es6-symbol/implement'); +``` + +If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do: + +```javascript +var Symbol = require('es6-symbol/polyfill'); +``` + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples: + +```javascript +var Symbol = require('es6-symbol'); + +var symbol = Symbol('My custom symbol'); +var x = {}; + +x[symbol] = 'foo'; +console.log(x[symbol]); 'foo' + +// Detect iterable: +var iterator, result; +if (possiblyIterable[Symbol.iterator]) { + iterator = possiblyIterable[Symbol.iterator](); + result = iterator.next(); + while(!result.done) { + console.log(result.value); + result = iterator.next(); + } +} +``` + +### Installation +#### NPM + +In your project path: + + $ npm install es6-symbol + +##### Browser + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +## Tests [](https://travis-ci.org/medikoo/es6-symbol) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/implement.js new file mode 100644 index 0000000..153edac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Symbol', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/index.js new file mode 100644 index 0000000..609f1fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js new file mode 100644 index 0000000..53759f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function () { + var symbol; + if (typeof Symbol !== 'function') return false; + symbol = Symbol('test symbol'); + try { String(symbol); } catch (e) { return false; } + if (typeof Symbol.iterator === 'symbol') return true; + + // Return 'true' for polyfills + if (typeof Symbol.isConcatSpreadable !== 'object') return false; + if (typeof Symbol.iterator !== 'object') return false; + if (typeof Symbol.toPrimitive !== 'object') return false; + if (typeof Symbol.toStringTag !== 'object') return false; + if (typeof Symbol.unscopables !== 'object') return false; + + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js new file mode 100644 index 0000000..a8cb8b8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js @@ -0,0 +1,8 @@ +// Exports true if environment provides native `Symbol` implementation + +'use strict'; + +module.exports = (function () { + if (typeof Symbol !== 'function') return false; + return (typeof Symbol.iterator === 'symbol'); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js new file mode 100644 index 0000000..beeba2c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (x) { + return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/package.json new file mode 100644 index 0000000..0efffea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/package.json @@ -0,0 +1,63 @@ +{ + "name": "es6-symbol", + "version": "2.0.1", + "description": "ECMAScript6 Symbol polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "symbol", + "private", + "property", + "es6", + "ecmascript", + "harmony" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-symbol.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.5" + }, + "devDependencies": { + "tad": "~0.2.1", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "51f6938d7830269fefa38f02eb912f5472b3ccd7", + "bugs": { + "url": "https://github.com/medikoo/es6-symbol/issues" + }, + "homepage": "https://github.com/medikoo/es6-symbol", + "_id": "es6-symbol@2.0.1", + "_shasum": "761b5c67cfd4f1d18afb234f691d678682cb3bf3", + "_from": "es6-symbol@>=2.0.1 <2.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "761b5c67cfd4f1d18afb234f691d678682cb3bf3", + "tarball": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js new file mode 100644 index 0000000..735eb67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js @@ -0,0 +1,77 @@ +'use strict'; + +var d = require('d') + , validateSymbol = require('./validate-symbol') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty, objPrototype = Object.prototype + , Symbol, HiddenSymbol, globalSymbols = create(null); + +var generateName = (function () { + var created = create(null); + return function (desc) { + var postfix = 0, name; + while (created[desc + (postfix || '')]) ++postfix; + desc += (postfix || ''); + created[desc] = true; + name = '@@' + desc; + defineProperty(objPrototype, name, d.gs(null, function (value) { + defineProperty(this, name, d(value)); + })); + return name; + }; +}()); + +HiddenSymbol = function Symbol(description) { + if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); + return Symbol(description); +}; +module.exports = Symbol = function Symbol(description) { + var symbol; + if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); + symbol = create(HiddenSymbol.prototype); + description = (description === undefined ? '' : String(description)); + return defineProperties(symbol, { + __description__: d('', description), + __name__: d('', generateName(description)) + }); +}; +defineProperties(Symbol, { + for: d(function (key) { + if (globalSymbols[key]) return globalSymbols[key]; + return (globalSymbols[key] = Symbol(String(key))); + }), + keyFor: d(function (s) { + var key; + validateSymbol(s); + for (key in globalSymbols) if (globalSymbols[key] === s) return key; + }), + hasInstance: d('', Symbol('hasInstance')), + isConcatSpreadable: d('', Symbol('isConcatSpreadable')), + iterator: d('', Symbol('iterator')), + match: d('', Symbol('match')), + replace: d('', Symbol('replace')), + search: d('', Symbol('search')), + species: d('', Symbol('species')), + split: d('', Symbol('split')), + toPrimitive: d('', Symbol('toPrimitive')), + toStringTag: d('', Symbol('toStringTag')), + unscopables: d('', Symbol('unscopables')) +}); +defineProperties(HiddenSymbol.prototype, { + constructor: d(Symbol), + toString: d('', function () { return this.__name__; }) +}); + +defineProperties(Symbol.prototype, { + toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), + valueOf: d(function () { return validateSymbol(this); }) +}); +defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', + function () { return validateSymbol(this); })); +defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol')); + +defineProperty(HiddenSymbol.prototype, Symbol.toPrimitive, + d('c', Symbol.prototype[Symbol.toPrimitive])); +defineProperty(HiddenSymbol.prototype, Symbol.toStringTag, + d('c', Symbol.prototype[Symbol.toStringTag])); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js new file mode 100644 index 0000000..eb35c30 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Symbol, 'function'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/index.js new file mode 100644 index 0000000..62b3296 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var d = require('d') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js new file mode 100644 index 0000000..bb0d645 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Symbol; + global.Symbol = polyfill; + a(t(), true); + if (cache === undefined) delete global.Symbol; + else global.Symbol = cache; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js new file mode 100644 index 0000000..df8ba03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js new file mode 100644 index 0000000..ac24b9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js @@ -0,0 +1,16 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Symbol !== 'undefined') { + a(t(Symbol()), true, "Native"); + } + a(t(SymbolPoly()), true, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js new file mode 100644 index 0000000..83fb5e9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js @@ -0,0 +1,27 @@ +'use strict'; + +var d = require('d') + , isSymbol = require('../is-symbol') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); + a(x instanceof T, false); + + a(isSymbol(symbol), true, "Symbol"); + a(isSymbol(T.iterator), true, "iterator"); + a(isSymbol(T.toStringTag), true, "toStringTag"); + + x = {}; + x[symbol] = 'foo'; + a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, + value: 'foo', writable: true }); + symbol = T.for('marko'); + a(isSymbol(symbol), true); + a(T.for('marko'), symbol); + a(T.keyFor(symbol), 'marko'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js new file mode 100644 index 0000000..2c8f84c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js @@ -0,0 +1,19 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + var symbol; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Symbol !== 'undefined') { + symbol = Symbol(); + a(t(symbol), symbol, "Native"); + } + symbol = SymbolPoly(); + a(t(symbol), symbol, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js new file mode 100644 index 0000000..4275004 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSymbol = require('./is-symbol'); + +module.exports = function (value) { + if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/index.js new file mode 100644 index 0000000..3248117 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + pad: require('./pad') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/pad.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/pad.js new file mode 100644 index 0000000..4478f6a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/#/pad.js @@ -0,0 +1,15 @@ +'use strict'; + +var pad = require('../../string/#/pad') + , toPosInt = require('../to-pos-integer') + + , toFixed = Number.prototype.toFixed; + +module.exports = function (length/*, precision*/) { + var precision; + length = toPosInt(length); + precision = toPosInt(arguments[1]); + + return pad.call(precision ? toFixed.call(this, precision) : this, + '0', length + (precision ? (1 + precision) : 0)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/implement.js new file mode 100644 index 0000000..f0a670a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'EPSILON', { value: require('./'), + configurable: false, enumerable: false, writable: false }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/index.js new file mode 100644 index 0000000..4e4b621 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = 2.220446049250313e-16; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/is-implemented.js new file mode 100644 index 0000000..141f5d2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/epsilon/is-implemented.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return (typeof Number.EPSILON === 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/index.js new file mode 100644 index 0000000..35daf78 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/index.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + EPSILON: require('./epsilon'), + isFinite: require('./is-finite'), + isInteger: require('./is-integer'), + isNaN: require('./is-nan'), + isNumber: require('./is-number'), + isSafeInteger: require('./is-safe-integer'), + MAX_SAFE_INTEGER: require('./max-safe-integer'), + MIN_SAFE_INTEGER: require('./min-safe-integer'), + toInteger: require('./to-integer'), + toPosInteger: require('./to-pos-integer'), + toUint32: require('./to-uint32') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/implement.js new file mode 100644 index 0000000..51d7cac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'isFinite', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/index.js new file mode 100644 index 0000000..15d5f40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Number.isFinite + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/is-implemented.js new file mode 100644 index 0000000..556e396 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var isFinite = Number.isFinite; + if (typeof isFinite !== 'function') return false; + return !isFinite('23') && isFinite(34) && !isFinite(Infinity); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/shim.js new file mode 100644 index 0000000..e3aee55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-finite/shim.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (value) { + return (typeof value === 'number') && isFinite(value); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/implement.js new file mode 100644 index 0000000..fe53f28 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'isInteger', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/index.js new file mode 100644 index 0000000..55e039a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Number.isInteger + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/is-implemented.js new file mode 100644 index 0000000..a0e573b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var isInteger = Number.isInteger; + if (typeof isInteger !== 'function') return false; + return !isInteger('23') && isInteger(34) && !isInteger(32.34); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/shim.js new file mode 100644 index 0000000..5402939 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-integer/shim.js @@ -0,0 +1,8 @@ +// Credit: http://www.2ality.com/2014/05/is-integer.html + +'use strict'; + +module.exports = function (value) { + if (typeof value !== 'number') return false; + return (value % 1 === 0); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/implement.js new file mode 100644 index 0000000..e1c5dee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'isNaN', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/index.js new file mode 100644 index 0000000..3b2c4ca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Number.isNaN + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/is-implemented.js new file mode 100644 index 0000000..4cf2766 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var isNaN = Number.isNaN; + if (typeof isNaN !== 'function') return false; + return !isNaN({}) && isNaN(NaN) && !isNaN(34); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/shim.js new file mode 100644 index 0000000..070d96c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-nan/shim.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (value) { return (value !== value); } //jslint: ignore diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-number.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-number.js new file mode 100644 index 0000000..19a99e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-number.js @@ -0,0 +1,11 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(1); + +module.exports = function (x) { + return ((typeof x === 'number') || + ((x instanceof Number) || + ((typeof x === 'object') && (toString.call(x) === id)))); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/implement.js new file mode 100644 index 0000000..51cef96 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'isSafeInteger', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/index.js new file mode 100644 index 0000000..49adeaa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Number.isSafeInteger + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/is-implemented.js new file mode 100644 index 0000000..510b60e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function () { + var isSafeInteger = Number.isSafeInteger; + if (typeof isSafeInteger !== 'function') return false; + return !isSafeInteger('23') && isSafeInteger(34232322323) && + !isSafeInteger(9007199254740992); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/shim.js new file mode 100644 index 0000000..692acdd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/is-safe-integer/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +var isInteger = require('../is-integer/shim') + , maxValue = require('../max-safe-integer') + + , abs = Math.abs; + +module.exports = function (value) { + if (!isInteger(value)) return false; + return abs(value) <= maxValue; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/implement.js new file mode 100644 index 0000000..4e0bb57 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'MAX_SAFE_INTEGER', { value: require('./'), + configurable: false, enumerable: false, writable: false }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/index.js new file mode 100644 index 0000000..ed5d6a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = Math.pow(2, 53) - 1; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/is-implemented.js new file mode 100644 index 0000000..7bd08a9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/max-safe-integer/is-implemented.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return (typeof Number.MAX_SAFE_INTEGER === 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/implement.js new file mode 100644 index 0000000..e3f110e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Number, 'MIN_SAFE_INTEGER', { value: require('./'), + configurable: false, enumerable: false, writable: false }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/index.js new file mode 100644 index 0000000..1c6cc27 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = -(Math.pow(2, 53) - 1); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/is-implemented.js new file mode 100644 index 0000000..efc9875 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/min-safe-integer/is-implemented.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return (typeof Number.MIN_SAFE_INTEGER === 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-integer.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-integer.js new file mode 100644 index 0000000..60e798c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-integer.js @@ -0,0 +1,12 @@ +'use strict'; + +var sign = require('../math/sign') + + , abs = Math.abs, floor = Math.floor; + +module.exports = function (value) { + if (isNaN(value)) return 0; + value = Number(value); + if ((value === 0) || !isFinite(value)) return value; + return sign(value) * floor(abs(value)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-pos-integer.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-pos-integer.js new file mode 100644 index 0000000..605a302 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-pos-integer.js @@ -0,0 +1,7 @@ +'use strict'; + +var toInteger = require('./to-integer') + + , max = Math.max; + +module.exports = function (value) { return max(0, toInteger(value)); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-uint32.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-uint32.js new file mode 100644 index 0000000..6263e85 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/number/to-uint32.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (value) { return value >>> 0; }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/_iterate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/_iterate.js new file mode 100644 index 0000000..bf2c55d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/_iterate.js @@ -0,0 +1,29 @@ +// Internal method, used by iteration functions. +// Calls a function for each key-value pair found in object +// Optionally takes compareFn to iterate object in specific order + +'use strict'; + +var isCallable = require('./is-callable') + , callable = require('./valid-callable') + , value = require('./valid-value') + + , call = Function.prototype.call, keys = Object.keys + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; + +module.exports = function (method, defVal) { + return function (obj, cb/*, thisArg, compareFn*/) { + var list, thisArg = arguments[2], compareFn = arguments[3]; + obj = Object(value(obj)); + callable(cb); + + list = keys(obj); + if (compareFn) { + list.sort(isCallable(compareFn) ? compareFn.bind(obj) : undefined); + } + return list[method](function (key, index) { + if (!propertyIsEnumerable.call(obj, key)) return defVal; + return call.call(cb, thisArg, obj[key], key, obj, index); + }); + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/implement.js new file mode 100644 index 0000000..3bcc68e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Object, 'assign', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/index.js new file mode 100644 index 0000000..ab0f9f2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.assign + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/is-implemented.js new file mode 100644 index 0000000..579ad2d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function () { + var assign = Object.assign, obj; + if (typeof assign !== 'function') return false; + obj = { foo: 'raz' }; + assign(obj, { bar: 'dwa' }, { trzy: 'trzy' }); + return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/shim.js new file mode 100644 index 0000000..74da11a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/assign/shim.js @@ -0,0 +1,22 @@ +'use strict'; + +var keys = require('../keys') + , value = require('../valid-value') + + , max = Math.max; + +module.exports = function (dest, src/*, …srcn*/) { + var error, i, l = max(arguments.length, 2), assign; + dest = Object(value(dest)); + assign = function (key) { + try { dest[key] = src[key]; } catch (e) { + if (!error) error = e; + } + }; + for (i = 1; i < l; ++i) { + src = arguments[i]; + keys(src).forEach(assign); + } + if (error !== undefined) throw error; + return dest; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/clear.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/clear.js new file mode 100644 index 0000000..85e4637 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/clear.js @@ -0,0 +1,16 @@ +'use strict'; + +var keys = require('./keys'); + +module.exports = function (obj) { + var error; + keys(obj).forEach(function (key) { + try { + delete this[key]; + } catch (e) { + if (!error) error = e; + } + }, obj); + if (error !== undefined) throw error; + return obj; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compact.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compact.js new file mode 100644 index 0000000..d021da4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compact.js @@ -0,0 +1,7 @@ +'use strict'; + +var filter = require('./filter'); + +module.exports = function (obj) { + return filter(obj, function (val) { return val != null; }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compare.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compare.js new file mode 100644 index 0000000..2ab11f1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/compare.js @@ -0,0 +1,42 @@ +'use strict'; + +var strCompare = require('../string/#/case-insensitive-compare') + , isObject = require('./is-object') + + , resolve, typeMap; + +typeMap = { + undefined: 0, + object: 1, + boolean: 2, + string: 3, + number: 4 +}; + +resolve = function (a) { + if (isObject(a)) { + if (typeof a.valueOf !== 'function') return NaN; + a = a.valueOf(); + if (isObject(a)) { + if (typeof a.toString !== 'function') return NaN; + a = a.toString(); + if (typeof a !== 'string') return NaN; + } + } + return a; +}; + +module.exports = function (a, b) { + if (a === b) return 0; // Same + + a = resolve(a); + b = resolve(b); + if (a == b) return typeMap[typeof a] - typeMap[typeof b]; //jslint: ignore + if (a == null) return -1; + if (b == null) return 1; + if ((typeof a === 'string') || (typeof b === 'string')) { + return strCompare.call(a, b); + } + if ((a !== a) && (b !== b)) return 0; //jslint: ignore + return Number(a) - Number(b); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy-deep.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy-deep.js new file mode 100644 index 0000000..548e3ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy-deep.js @@ -0,0 +1,30 @@ +'use strict'; + +var isPlainObject = require('./is-plain-object') + , value = require('./valid-value') + + , keys = Object.keys + , copy; + +copy = function (source) { + var target = {}; + this[0].push(source); + this[1].push(target); + keys(source).forEach(function (key) { + var index; + if (!isPlainObject(source[key])) { + target[key] = source[key]; + return; + } + index = this[0].indexOf(source[key]); + if (index === -1) target[key] = copy.call(this, source[key]); + else target[key] = this[1][index]; + }, this); + return target; +}; + +module.exports = function (source) { + var obj = Object(value(source)); + if (obj !== source) return obj; + return copy.call([[], []], obj); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy.js new file mode 100644 index 0000000..4d71772 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/copy.js @@ -0,0 +1,10 @@ +'use strict'; + +var assign = require('./assign') + , value = require('./valid-value'); + +module.exports = function (obj) { + var copy = Object(value(obj)); + if (copy !== obj) return copy; + return assign({}, obj); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/count.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/count.js new file mode 100644 index 0000000..29cfbb5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/count.js @@ -0,0 +1,5 @@ +'use strict'; + +var keys = require('./keys'); + +module.exports = function (obj) { return keys(obj).length; }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/create.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/create.js new file mode 100644 index 0000000..f813b46 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/create.js @@ -0,0 +1,36 @@ +// Workaround for http://code.google.com/p/v8/issues/detail?id=2804 + +'use strict'; + +var create = Object.create, shim; + +if (!require('./set-prototype-of/is-implemented')()) { + shim = require('./set-prototype-of/shim'); +} + +module.exports = (function () { + var nullObject, props, desc; + if (!shim) return create; + if (shim.level !== 1) return create; + + nullObject = {}; + props = {}; + desc = { configurable: false, enumerable: false, writable: true, + value: undefined }; + Object.getOwnPropertyNames(Object.prototype).forEach(function (name) { + if (name === '__proto__') { + props[name] = { configurable: true, enumerable: false, writable: true, + value: undefined }; + return; + } + props[name] = desc; + }); + Object.defineProperties(nullObject, props); + + Object.defineProperty(shim, 'nullPolyfill', { configurable: false, + enumerable: false, writable: false, value: nullObject }); + + return function (prototype, props) { + return create((prototype === null) ? nullObject : prototype, props); + }; +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/eq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/eq.js new file mode 100644 index 0000000..037937e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/eq.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (x, y) { + return ((x === y) || ((x !== x) && (y !== y))); //jslint: ignore +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/every.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/every.js new file mode 100644 index 0000000..1303db2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/every.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./_iterate')('every', true); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/filter.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/filter.js new file mode 100644 index 0000000..e5edb49 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/filter.js @@ -0,0 +1,15 @@ +'use strict'; + +var callable = require('./valid-callable') + , forEach = require('./for-each') + + , call = Function.prototype.call; + +module.exports = function (obj, cb/*, thisArg*/) { + var o = {}, thisArg = arguments[2]; + callable(cb); + forEach(obj, function (value, key, obj, index) { + if (call.call(cb, thisArg, value, key, obj, index)) o[key] = obj[key]; + }); + return o; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/first-key.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/first-key.js new file mode 100644 index 0000000..7df10b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/first-key.js @@ -0,0 +1,14 @@ +'use strict'; + +var value = require('./valid-value') + + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; + +module.exports = function (obj) { + var i; + value(obj); + for (i in obj) { + if (propertyIsEnumerable.call(obj, i)) return i; + } + return null; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/flatten.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/flatten.js new file mode 100644 index 0000000..e8b4044 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/flatten.js @@ -0,0 +1,17 @@ +'use strict'; + +var isPlainObject = require('./is-plain-object') + , forEach = require('./for-each') + + , process; + +process = function self(value, key) { + if (isPlainObject(value)) forEach(value, self, this); + else this[key] = value; +}; + +module.exports = function (obj) { + var flattened = {}; + forEach(obj, process, flattened); + return flattened; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/for-each.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/for-each.js new file mode 100644 index 0000000..6674f8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/for-each.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./_iterate')('forEach'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/get-property-names.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/get-property-names.js new file mode 100644 index 0000000..54a01e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/get-property-names.js @@ -0,0 +1,18 @@ +'use strict'; + +var uniq = require('../array/#/uniq') + , value = require('./valid-value') + + , push = Array.prototype.push + , getOwnPropertyNames = Object.getOwnPropertyNames + , getPrototypeOf = Object.getPrototypeOf; + +module.exports = function (obj) { + var keys; + obj = Object(value(obj)); + keys = getOwnPropertyNames(obj); + while ((obj = getPrototypeOf(obj))) { + push.apply(keys, getOwnPropertyNames(obj)); + } + return uniq.call(keys); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/index.js new file mode 100644 index 0000000..4bdf403 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/index.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = { + assign: require('./assign'), + clear: require('./clear'), + compact: require('./compact'), + compare: require('./compare'), + copy: require('./copy'), + copyDeep: require('./copy-deep'), + count: require('./count'), + create: require('./create'), + eq: require('./eq'), + every: require('./every'), + filter: require('./filter'), + firstKey: require('./first-key'), + flatten: require('./flatten'), + forEach: require('./for-each'), + getPropertyNames: require('./get-property-names'), + is: require('./is'), + isArrayLike: require('./is-array-like'), + isCallable: require('./is-callable'), + isCopy: require('./is-copy'), + isCopyDeep: require('./is-copy-deep'), + isEmpty: require('./is-empty'), + isObject: require('./is-object'), + isPlainObject: require('./is-plain-object'), + keyOf: require('./key-of'), + keys: require('./keys'), + map: require('./map'), + mapKeys: require('./map-keys'), + normalizeOptions: require('./normalize-options'), + mixin: require('./mixin'), + mixinPrototypes: require('./mixin-prototypes'), + primitiveSet: require('./primitive-set'), + safeTraverse: require('./safe-traverse'), + serialize: require('./serialize'), + setPrototypeOf: require('./set-prototype-of'), + some: require('./some'), + toArray: require('./to-array'), + unserialize: require('./unserialize'), + validateArrayLike: require('./validate-array-like'), + validateArrayLikeObject: require('./validate-array-like-object'), + validCallable: require('./valid-callable'), + validObject: require('./valid-object'), + validateStringifiable: require('./validate-stringifiable'), + validateStringifiableValue: require('./validate-stringifiable-value'), + validValue: require('./valid-value') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-array-like.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-array-like.js new file mode 100644 index 0000000..b8beed2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-array-like.js @@ -0,0 +1,14 @@ +'use strict'; + +var isFunction = require('../function/is-function') + , isObject = require('./is-object'); + +module.exports = function (x) { + return ((x != null) && (typeof x.length === 'number') && + + // Just checking ((typeof x === 'object') && (typeof x !== 'function')) + // won't work right for some cases, e.g.: + // type of instance of NodeList in Safari is a 'function' + + ((isObject(x) && !isFunction(x)) || (typeof x === "string"))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-callable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-callable.js new file mode 100644 index 0000000..5d5d4b3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-callable.js @@ -0,0 +1,5 @@ +// Deprecated + +'use strict'; + +module.exports = function (obj) { return typeof obj === 'function'; }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy-deep.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy-deep.js new file mode 100644 index 0000000..c4b2b42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy-deep.js @@ -0,0 +1,58 @@ +'use strict'; + +var eq = require('./eq') + , isPlainObject = require('./is-plain-object') + , value = require('./valid-value') + + , isArray = Array.isArray, keys = Object.keys + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable + + , eqArr, eqVal, eqObj; + +eqArr = function (a, b, recMap) { + var i, l = a.length; + if (l !== b.length) return false; + for (i = 0; i < l; ++i) { + if (a.hasOwnProperty(i) !== b.hasOwnProperty(i)) return false; + if (!eqVal(a[i], b[i], recMap)) return false; + } + return true; +}; + +eqObj = function (a, b, recMap) { + var k1 = keys(a), k2 = keys(b); + if (k1.length !== k2.length) return false; + return k1.every(function (key) { + if (!propertyIsEnumerable.call(b, key)) return false; + return eqVal(a[key], b[key], recMap); + }); +}; + +eqVal = function (a, b, recMap) { + var i, eqX, c1, c2; + if (eq(a, b)) return true; + if (isPlainObject(a)) { + if (!isPlainObject(b)) return false; + eqX = eqObj; + } else if (isArray(a) && isArray(b)) { + eqX = eqArr; + } else { + return false; + } + c1 = recMap[0]; + c2 = recMap[1]; + i = c1.indexOf(a); + if (i !== -1) { + if (c2[i].indexOf(b) !== -1) return true; + } else { + i = c1.push(a) - 1; + c2[i] = []; + } + c2[i].push(b); + return eqX(a, b, recMap); +}; + +module.exports = function (a, b) { + if (eq(value(a), value(b))) return true; + return eqVal(Object(a), Object(b), [[], []]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy.js new file mode 100644 index 0000000..4fe639d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-copy.js @@ -0,0 +1,24 @@ +'use strict'; + +var eq = require('./eq') + , value = require('./valid-value') + + , keys = Object.keys + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; + +module.exports = function (a, b) { + var k1, k2; + + if (eq(value(a), value(b))) return true; + + a = Object(a); + b = Object(b); + + k1 = keys(a); + k2 = keys(b); + if (k1.length !== k2.length) return false; + return k1.every(function (key) { + if (!propertyIsEnumerable.call(b, key)) return false; + return eq(a[key], b[key]); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-empty.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-empty.js new file mode 100644 index 0000000..7b51a87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-empty.js @@ -0,0 +1,14 @@ +'use strict'; + +var value = require('./valid-value') + + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; + +module.exports = function (obj) { + var i; + value(obj); + for (i in obj) { //jslint: ignore + if (propertyIsEnumerable.call(obj, i)) return false; + } + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-object.js new file mode 100644 index 0000000..a86facf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-object.js @@ -0,0 +1,7 @@ +'use strict'; + +var map = { function: true, object: true }; + +module.exports = function (x) { + return ((x != null) && map[typeof x]) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-plain-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-plain-object.js new file mode 100644 index 0000000..9a28231 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is-plain-object.js @@ -0,0 +1,20 @@ +'use strict'; + +var getPrototypeOf = Object.getPrototypeOf, prototype = Object.prototype + , toString = prototype.toString + + , id = Object().toString(); + +module.exports = function (value) { + var proto, constructor; + if (!value || (typeof value !== 'object') || (toString.call(value) !== id)) { + return false; + } + proto = getPrototypeOf(value); + if (proto === null) { + constructor = value.constructor; + if (typeof constructor !== 'function') return true; + return (constructor.prototype !== value); + } + return (proto === prototype) || (getPrototypeOf(proto) === null); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is.js new file mode 100644 index 0000000..5778b50 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/is.js @@ -0,0 +1,10 @@ +// Implementation credits go to: +// http://wiki.ecmascript.org/doku.php?id=harmony:egal + +'use strict'; + +module.exports = function (x, y) { + return (x === y) ? + ((x !== 0) || ((1 / x) === (1 / y))) : + ((x !== x) && (y !== y)); //jslint: ignore +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/key-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/key-of.js new file mode 100644 index 0000000..8c44c8d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/key-of.js @@ -0,0 +1,15 @@ +'use strict'; + +var eq = require('./eq') + , some = require('./some'); + +module.exports = function (obj, searchValue) { + var r; + return some(obj, function (value, name) { + if (eq(value, searchValue)) { + r = name; + return true; + } + return false; + }) ? r : null; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/implement.js new file mode 100644 index 0000000..c6872bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(Object, 'keys', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/index.js new file mode 100644 index 0000000..5ef0522 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.keys + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/is-implemented.js new file mode 100644 index 0000000..40c32c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function () { + try { + Object.keys('primitive'); + return true; + } catch (e) { return false; } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/shim.js new file mode 100644 index 0000000..034b6b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/keys/shim.js @@ -0,0 +1,7 @@ +'use strict'; + +var keys = Object.keys; + +module.exports = function (object) { + return keys(object == null ? object : Object(object)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map-keys.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map-keys.js new file mode 100644 index 0000000..26f0eca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map-keys.js @@ -0,0 +1,15 @@ +'use strict'; + +var callable = require('./valid-callable') + , forEach = require('./for-each') + + , call = Function.prototype.call; + +module.exports = function (obj, cb/*, thisArg*/) { + var o = {}, thisArg = arguments[2]; + callable(cb); + forEach(obj, function (value, key, obj, index) { + o[call.call(cb, thisArg, key, value, this, index)] = value; + }, obj); + return o; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map.js new file mode 100644 index 0000000..6b39d3c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/map.js @@ -0,0 +1,15 @@ +'use strict'; + +var callable = require('./valid-callable') + , forEach = require('./for-each') + + , call = Function.prototype.call; + +module.exports = function (obj, cb/*, thisArg*/) { + var o = {}, thisArg = arguments[2]; + callable(cb); + forEach(obj, function (value, key, obj, index) { + o[key] = call.call(cb, thisArg, value, key, obj, index); + }); + return o; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin-prototypes.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin-prototypes.js new file mode 100644 index 0000000..1ef5756 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin-prototypes.js @@ -0,0 +1,34 @@ +'use strict'; + +var value = require('./valid-value') + , mixin = require('./mixin') + + , defineProperty = Object.defineProperty + , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor + , getOwnPropertyNames = Object.getOwnPropertyNames + , getPrototypeOf = Object.getPrototypeOf + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function (target, source) { + var error, end, define; + target = Object(value(target)); + source = Object(value(source)); + end = getPrototypeOf(target); + if (source === end) return target; + try { + mixin(target, source); + } catch (e) { error = e; } + source = getPrototypeOf(source); + define = function (name) { + if (hasOwnProperty.call(target, name)) return; + try { + defineProperty(target, name, getOwnPropertyDescriptor(source, name)); + } catch (e) { error = e; } + }; + while (source && (source !== end)) { + getOwnPropertyNames(source).forEach(define); + source = getPrototypeOf(source); + } + if (error) throw error; + return target; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin.js new file mode 100644 index 0000000..80b5df5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/mixin.js @@ -0,0 +1,19 @@ +'use strict'; + +var value = require('./valid-value') + + , defineProperty = Object.defineProperty + , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor + , getOwnPropertyNames = Object.getOwnPropertyNames; + +module.exports = function (target, source) { + var error; + target = Object(value(target)); + getOwnPropertyNames(Object(value(source))).forEach(function (name) { + try { + defineProperty(target, name, getOwnPropertyDescriptor(source, name)); + } catch (e) { error = e; } + }); + if (error !== undefined) throw error; + return target; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/normalize-options.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/normalize-options.js new file mode 100644 index 0000000..cf8ed8d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/normalize-options.js @@ -0,0 +1,17 @@ +'use strict'; + +var forEach = Array.prototype.forEach, create = Object.create; + +var process = function (src, obj) { + var key; + for (key in src) obj[key] = src[key]; +}; + +module.exports = function (options/*, …options*/) { + var result = create(null); + forEach.call(arguments, function (options) { + if (options == null) return; + process(Object(options), result); + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/primitive-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/primitive-set.js new file mode 100644 index 0000000..ada1095 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/primitive-set.js @@ -0,0 +1,9 @@ +'use strict'; + +var forEach = Array.prototype.forEach, create = Object.create; + +module.exports = function (arg/*, …args*/) { + var set = create(null); + forEach.call(arguments, function (name) { set[name] = true; }); + return set; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/safe-traverse.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/safe-traverse.js new file mode 100644 index 0000000..7e1b5f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/safe-traverse.js @@ -0,0 +1,15 @@ +'use strict'; + +var value = require('./valid-value'); + +module.exports = function (obj/*, …names*/) { + var length, current = 1; + value(obj); + length = arguments.length - 1; + if (!length) return obj; + while (current < length) { + obj = obj[arguments[current++]]; + if (obj == null) return undefined; + } + return obj[arguments[current]]; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/serialize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/serialize.js new file mode 100644 index 0000000..8113b68 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/serialize.js @@ -0,0 +1,36 @@ +'use strict'; + +var toArray = require('./to-array') + , isDate = require('../date/is-date') + , isRegExp = require('../reg-exp/is-reg-exp') + + , isArray = Array.isArray, stringify = JSON.stringify + , keyValueToString = function (value, key) { return stringify(key) + ':' + exports(value); }; + +var sparseMap = function (arr) { + var i, l = arr.length, result = new Array(l); + for (i = 0; i < l; ++i) { + if (!arr.hasOwnProperty(i)) continue; + result[i] = exports(arr[i]); + } + return result; +}; + +module.exports = exports = function (obj) { + if (obj == null) return String(obj); + switch (typeof obj) { + case 'string': + return stringify(obj); + case 'number': + case 'boolean': + case 'function': + return String(obj); + case 'object': + if (isArray(obj)) return '[' + sparseMap(obj) + ']'; + if (isRegExp(obj)) return String(obj); + if (isDate(obj)) return 'new Date(' + obj.valueOf() + ')'; + return '{' + toArray(obj, keyValueToString) + '}'; + default: + throw new TypeError("Serialization of " + String(obj) + "is unsupported"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/implement.js new file mode 100644 index 0000000..000e6bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/implement.js @@ -0,0 +1,8 @@ +'use strict'; + +var shim; + +if (!require('./is-implemented')() && (shim = require('./shim'))) { + Object.defineProperty(Object, 'setPrototypeOf', + { value: shim, configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/index.js new file mode 100644 index 0000000..ccc4099 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.setPrototypeOf + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/is-implemented.js new file mode 100644 index 0000000..98d0c84 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/is-implemented.js @@ -0,0 +1,11 @@ +'use strict'; + +var create = Object.create, getPrototypeOf = Object.getPrototypeOf + , x = {}; + +module.exports = function (/*customCreate*/) { + var setPrototypeOf = Object.setPrototypeOf + , customCreate = arguments[0] || create; + if (typeof setPrototypeOf !== 'function') return false; + return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/shim.js new file mode 100644 index 0000000..4ec9446 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/set-prototype-of/shim.js @@ -0,0 +1,73 @@ +// Big thanks to @WebReflection for sorting this out +// https://gist.github.com/WebReflection/5593554 + +'use strict'; + +var isObject = require('../is-object') + , value = require('../valid-value') + + , isPrototypeOf = Object.prototype.isPrototypeOf + , defineProperty = Object.defineProperty + , nullDesc = { configurable: true, enumerable: false, writable: true, + value: undefined } + , validate; + +validate = function (obj, prototype) { + value(obj); + if ((prototype === null) || isObject(prototype)) return obj; + throw new TypeError('Prototype must be null or an object'); +}; + +module.exports = (function (status) { + var fn, set; + if (!status) return null; + if (status.level === 2) { + if (status.set) { + set = status.set; + fn = function (obj, prototype) { + set.call(validate(obj, prototype), prototype); + return obj; + }; + } else { + fn = function (obj, prototype) { + validate(obj, prototype).__proto__ = prototype; + return obj; + }; + } + } else { + fn = function self(obj, prototype) { + var isNullBase; + validate(obj, prototype); + isNullBase = isPrototypeOf.call(self.nullPolyfill, obj); + if (isNullBase) delete self.nullPolyfill.__proto__; + if (prototype === null) prototype = self.nullPolyfill; + obj.__proto__ = prototype; + if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc); + return obj; + }; + } + return Object.defineProperty(fn, 'level', { configurable: false, + enumerable: false, writable: false, value: status.level }); +}((function () { + var x = Object.create(null), y = {}, set + , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__'); + + if (desc) { + try { + set = desc.set; // Opera crashes at this point + set.call(x, y); + } catch (ignore) { } + if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 }; + } + + x.__proto__ = y; + if (Object.getPrototypeOf(x) === y) return { level: 2 }; + + x = {}; + x.__proto__ = y; + if (Object.getPrototypeOf(x) === y) return { level: 1 }; + + return false; +}()))); + +require('../create'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/some.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/some.js new file mode 100644 index 0000000..cde5dde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/some.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./_iterate')('some', false); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/to-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/to-array.js new file mode 100644 index 0000000..a954abb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/to-array.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('./valid-callable') + , forEach = require('./for-each') + + , call = Function.prototype.call + + , defaultCb = function (value, key) { return [key, value]; }; + +module.exports = function (obj/*, cb, thisArg, compareFn*/) { + var a = [], cb = arguments[1], thisArg = arguments[2]; + cb = (cb == null) ? defaultCb : callable(cb); + + forEach(obj, function (value, key, obj, index) { + a.push(call.call(cb, thisArg, value, key, this, index)); + }, obj, arguments[3]); + return a; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/unserialize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/unserialize.js new file mode 100644 index 0000000..ce68e40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/unserialize.js @@ -0,0 +1,7 @@ +'use strict'; + +var value = require('./valid-value'); + +module.exports = exports = function (code) { + return (new Function('return ' + value(code)))(); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-callable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-callable.js new file mode 100644 index 0000000..c977527 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-callable.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (fn) { + if (typeof fn !== 'function') throw new TypeError(fn + " is not a function"); + return fn; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-object.js new file mode 100644 index 0000000..f82bd51 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-object.js @@ -0,0 +1,8 @@ +'use strict'; + +var isObject = require('./is-object'); + +module.exports = function (value) { + if (!isObject(value)) throw new TypeError(value + " is not an Object"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-value.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-value.js new file mode 100644 index 0000000..36c8ec3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/valid-value.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (value) { + if (value == null) throw new TypeError("Cannot use null or undefined"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like-object.js new file mode 100644 index 0000000..89e12c5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like-object.js @@ -0,0 +1,9 @@ +'use strict'; + +var isArrayLike = require('./is-array-like') + , isObject = require('./is-object'); + +module.exports = function (obj) { + if (isObject(obj) && isArrayLike(obj)) return obj; + throw new TypeError(obj + " is not array-like object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like.js new file mode 100644 index 0000000..6a35b54 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-array-like.js @@ -0,0 +1,8 @@ +'use strict'; + +var isArrayLike = require('./is-array-like'); + +module.exports = function (obj) { + if (isArrayLike(obj)) return obj; + throw new TypeError(obj + " is not array-like value"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable-value.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable-value.js new file mode 100644 index 0000000..9df3b66 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable-value.js @@ -0,0 +1,6 @@ +'use strict'; + +var value = require('./valid-value') + , stringifiable = require('./validate-stringifiable'); + +module.exports = function (x) { return stringifiable(value(x)); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable.js new file mode 100644 index 0000000..eba7ce7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/object/validate-stringifiable.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (stringifiable) { + try { + return String(stringifiable); + } catch (e) { + throw new TypeError("Passed argument cannot be stringifed"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/package.json new file mode 100644 index 0000000..0020748 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/package.json @@ -0,0 +1,74 @@ +{ + "name": "es5-ext", + "version": "0.10.7", + "description": "ECMAScript 5 extensions and ES6 shims", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "ecmascript", + "ecmascript5", + "ecmascript6", + "es5", + "es6", + "extensions", + "ext", + "addons", + "extras", + "harmony", + "javascript", + "polyfill", + "shim", + "util", + "utils", + "utilities" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es5-ext.git" + }, + "dependencies": { + "es6-iterator": "~0.1.3", + "es6-symbol": "~2.0.1" + }, + "devDependencies": { + "tad": "~0.2.2", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "5b63ee02f50dfbc70dc1f62bc66b8718af443f83", + "bugs": { + "url": "https://github.com/medikoo/es5-ext/issues" + }, + "homepage": "https://github.com/medikoo/es5-ext", + "_id": "es5-ext@0.10.7", + "_shasum": "dfaea50721301042e2d89c1719d43493fa821656", + "_from": "es5-ext@>=0.10.4 <0.11.0", + "_npmVersion": "2.7.4", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "dfaea50721301042e2d89c1719d43493fa821656", + "tarball": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.7.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.7.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/index.js new file mode 100644 index 0000000..f7e7a58 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/index.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = { + isSticky: require('./is-sticky'), + isUnicode: require('./is-unicode'), + match: require('./match'), + replace: require('./replace'), + search: require('./search'), + split: require('./split') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-sticky.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-sticky.js new file mode 100644 index 0000000..830a481 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-sticky.js @@ -0,0 +1,9 @@ +'use strict'; + +var validRegExp = require('../valid-reg-exp') + + , re = /\/[a-xz]*y[a-xz]*$/; + +module.exports = function () { + return Boolean(String(validRegExp(this)).match(re)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-unicode.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-unicode.js new file mode 100644 index 0000000..b005f6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/is-unicode.js @@ -0,0 +1,9 @@ +'use strict'; + +var validRegExp = require('../valid-reg-exp') + + , re = /\/[a-xz]*u[a-xz]*$/; + +module.exports = function () { + return Boolean(String(validRegExp(this)).match(re)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/implement.js new file mode 100644 index 0000000..921c936 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'match', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/index.js new file mode 100644 index 0000000..0534ac3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? RegExp.prototype.match + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/is-implemented.js new file mode 100644 index 0000000..b7e9964 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var re = /foo/; + +module.exports = function () { + if (typeof re.match !== 'function') return false; + return re.match('barfoobar') && !re.match('elo'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/shim.js new file mode 100644 index 0000000..4f99cf4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/match/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +var validRegExp = require('../../valid-reg-exp'); + +module.exports = function (string) { + validRegExp(this); + return String(string).match(this); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/implement.js new file mode 100644 index 0000000..ad580de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'replace', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/index.js new file mode 100644 index 0000000..5658177 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? RegExp.prototype.replace + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js new file mode 100644 index 0000000..1b42d25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var re = /foo/; + +module.exports = function () { + if (typeof re.replace !== 'function') return false; + return re.replace('foobar', 'mar') === 'marbar'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/shim.js new file mode 100644 index 0000000..c3e6aeb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/replace/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +var validRegExp = require('../../valid-reg-exp'); + +module.exports = function (string, replaceValue) { + validRegExp(this); + return String(string).replace(this, replaceValue); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/implement.js new file mode 100644 index 0000000..3804f4e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'search', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/index.js new file mode 100644 index 0000000..67995d4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? RegExp.prototype.search + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/is-implemented.js new file mode 100644 index 0000000..efba889 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var re = /foo/; + +module.exports = function () { + if (typeof re.search !== 'function') return false; + return re.search('barfoo') === 3; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/shim.js new file mode 100644 index 0000000..6d9dcae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/search/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +var validRegExp = require('../../valid-reg-exp'); + +module.exports = function (string) { + validRegExp(this); + return String(string).search(this); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/implement.js new file mode 100644 index 0000000..50facb6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'split', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/index.js new file mode 100644 index 0000000..f101f5a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? RegExp.prototype.split + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/is-implemented.js new file mode 100644 index 0000000..7244c99 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var re = /\|/; + +module.exports = function () { + if (typeof re.split !== 'function') return false; + return re.split('bar|foo')[1] === 'foo'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/shim.js new file mode 100644 index 0000000..76154e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/split/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +var validRegExp = require('../../valid-reg-exp'); + +module.exports = function (string) { + validRegExp(this); + return String(string).split(this); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/implement.js new file mode 100644 index 0000000..7e8af1d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/implement.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSticky = require('../is-sticky'); + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'sticky', { configurable: true, + enumerable: false, get: isSticky }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js new file mode 100644 index 0000000..379c4a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return RegExp.prototype.sticky === false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/implement.js new file mode 100644 index 0000000..5a82a4d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/implement.js @@ -0,0 +1,8 @@ +'use strict'; + +var isUnicode = require('../is-unicode'); + +if (!require('./is-implemented')()) { + Object.defineProperty(RegExp.prototype, 'unicode', { configurable: true, + enumerable: false, get: isUnicode }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js new file mode 100644 index 0000000..a8b15b3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return RegExp.prototype.unicode === false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/escape.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/escape.js new file mode 100644 index 0000000..a2363fc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/escape.js @@ -0,0 +1,9 @@ +// Thanks to Andrew Clover: +// http://stackoverflow.com/questions/3561493 +// /is-there-a-regexp-escape-function-in-javascript + +'use strict'; + +var re = /[\-\/\\\^$*+?.()|\[\]{}]/g; + +module.exports = function (str) { return String(str).replace(re, '\\$&'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/index.js new file mode 100644 index 0000000..75ea313 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/index.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + escape: require('./escape'), + isRegExp: require('./is-reg-exp'), + validRegExp: require('./valid-reg-exp') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/is-reg-exp.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/is-reg-exp.js new file mode 100644 index 0000000..6eb1297 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/is-reg-exp.js @@ -0,0 +1,9 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(/a/); + +module.exports = function (x) { + return (x && (x instanceof RegExp || (toString.call(x) === id))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/valid-reg-exp.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/valid-reg-exp.js new file mode 100644 index 0000000..d3a7764 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/reg-exp/valid-reg-exp.js @@ -0,0 +1,8 @@ +'use strict'; + +var isRegExp = require('./is-reg-exp'); + +module.exports = function (x) { + if (!isRegExp(x)) throw new TypeError(x + " is not a RegExp object"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/implement.js new file mode 100644 index 0000000..4494d7b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, require('es6-symbol').iterator, + { value: require('./shim'), configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/index.js new file mode 100644 index 0000000..22f15e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype[require('es6-symbol').iterator] : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/is-implemented.js new file mode 100644 index 0000000..f5c462d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/is-implemented.js @@ -0,0 +1,16 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function () { + var str = '🙈f', iterator, result; + if (typeof str[iteratorSymbol] !== 'function') return false; + iterator = str[iteratorSymbol](); + if (!iterator) return false; + if (typeof iterator.next !== 'function') return false; + result = iterator.next(); + if (!result) return false; + if (result.value !== '🙈') return false; + if (result.done !== false) return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/shim.js new file mode 100644 index 0000000..0be3029 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/@@iterator/shim.js @@ -0,0 +1,6 @@ +'use strict'; + +var StringIterator = require('es6-iterator/string') + , value = require('../../../object/valid-value'); + +module.exports = function () { return new StringIterator(value(this)); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/at.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/at.js new file mode 100644 index 0000000..77bd251 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/at.js @@ -0,0 +1,33 @@ +// Based on: https://github.com/mathiasbynens/String.prototype.at +// Thanks @mathiasbynens ! + +'use strict'; + +var toInteger = require('../../number/to-integer') + , validValue = require('../../object/valid-value'); + +module.exports = function (pos) { + var str = String(validValue(this)), size = str.length + , cuFirst, cuSecond, nextPos, len; + pos = toInteger(pos); + + // Account for out-of-bounds indices + // The odd lower bound is because the ToInteger operation is + // going to round `n` to `0` for `-1 < n <= 0`. + if (pos <= -1 || pos >= size) return ''; + + // Second half of `ToInteger` + pos = pos | 0; + // Get the first code unit and code unit value + cuFirst = str.charCodeAt(pos); + nextPos = pos + 1; + len = 1; + if ( // check if it’s the start of a surrogate pair + (cuFirst >= 0xD800) && (cuFirst <= 0xDBFF) && // high surrogate + (size > nextPos) // there is a next code unit + ) { + cuSecond = str.charCodeAt(nextPos); + if (cuSecond >= 0xDC00 && cuSecond <= 0xDFFF) len = 2; // low surrogate + } + return str.slice(pos, pos + len); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/camel-to-hyphen.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/camel-to-hyphen.js new file mode 100644 index 0000000..1cb8d12 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/camel-to-hyphen.js @@ -0,0 +1,10 @@ +'use strict'; + +var replace = String.prototype.replace + , re = /([A-Z])/g; + +module.exports = function () { + var str = replace.call(this, re, "-$1").toLowerCase(); + if (str[0] === '-') str = str.slice(1); + return str; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/capitalize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/capitalize.js new file mode 100644 index 0000000..ed76827 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/capitalize.js @@ -0,0 +1,8 @@ +'use strict'; + +var value = require('../../object/valid-value'); + +module.exports = function () { + var str = String(value(this)); + return str.charAt(0).toUpperCase() + str.slice(1); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/case-insensitive-compare.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/case-insensitive-compare.js new file mode 100644 index 0000000..599cb83 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/case-insensitive-compare.js @@ -0,0 +1,7 @@ +'use strict'; + +var toLowerCase = String.prototype.toLowerCase; + +module.exports = function (other) { + return toLowerCase.call(this).localeCompare(toLowerCase.call(String(other))); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/implement.js new file mode 100644 index 0000000..1e7a37b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'codePointAt', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/index.js new file mode 100644 index 0000000..7e91d83 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.codePointAt + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/is-implemented.js new file mode 100644 index 0000000..b271589 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var str = 'abc\uD834\uDF06def'; + +module.exports = function () { + if (typeof str.codePointAt !== 'function') return false; + return str.codePointAt(3) === 0x1D306; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/shim.js new file mode 100644 index 0000000..1c9038b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/code-point-at/shim.js @@ -0,0 +1,26 @@ +// Based on: https://github.com/mathiasbynens/String.prototype.codePointAt +// Thanks @mathiasbynens ! + +'use strict'; + +var toInteger = require('../../../number/to-integer') + , validValue = require('../../../object/valid-value'); + +module.exports = function (pos) { + var str = String(validValue(this)), l = str.length, first, second; + pos = toInteger(pos); + + // Account for out-of-bounds indices: + if (pos < 0 || pos >= l) return undefined; + + // Get the first code unit + first = str.charCodeAt(pos); + if ((first >= 0xD800) && (first <= 0xDBFF) && (l > pos + 1)) { + second = str.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/implement.js new file mode 100644 index 0000000..6b7a3c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'contains', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/index.js new file mode 100644 index 0000000..abb3e37 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.contains + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/is-implemented.js new file mode 100644 index 0000000..6f7d4b7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var str = 'razdwatrzy'; + +module.exports = function () { + if (typeof str.contains !== 'function') return false; + return ((str.contains('dwa') === true) && (str.contains('foo') === false)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/shim.js new file mode 100644 index 0000000..89e39e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/contains/shim.js @@ -0,0 +1,7 @@ +'use strict'; + +var indexOf = String.prototype.indexOf; + +module.exports = function (searchString/*, position*/) { + return indexOf.call(this, searchString, arguments[1]) > -1; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/implement.js new file mode 100644 index 0000000..0b09025 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'endsWith', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/index.js new file mode 100644 index 0000000..d2d9484 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.endsWith + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/is-implemented.js new file mode 100644 index 0000000..f3bb008 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var str = 'razdwatrzy'; + +module.exports = function () { + if (typeof str.endsWith !== 'function') return false; + return ((str.endsWith('trzy') === true) && (str.endsWith('raz') === false)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/shim.js new file mode 100644 index 0000000..26cbdb1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/ends-with/shim.js @@ -0,0 +1,16 @@ +'use strict'; + +var toInteger = require('../../../number/to-integer') + , value = require('../../../object/valid-value') + + , min = Math.min, max = Math.max; + +module.exports = function (searchString/*, endPosition*/) { + var self, start, endPos; + self = String(value(this)); + searchString = String(searchString); + endPos = arguments[1]; + start = ((endPos == null) ? self.length : + min(max(toInteger(endPos), 0), self.length)) - searchString.length; + return (start < 0) ? false : (self.indexOf(searchString, start) === start); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/hyphen-to-camel.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/hyphen-to-camel.js new file mode 100644 index 0000000..8928b02 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/hyphen-to-camel.js @@ -0,0 +1,8 @@ +'use strict'; + +var replace = String.prototype.replace + + , re = /-([a-z0-9])/g + , toUpperCase = function (m, a) { return a.toUpperCase(); }; + +module.exports = function () { return replace.call(this, re, toUpperCase); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/indent.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/indent.js new file mode 100644 index 0000000..223bd82 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/indent.js @@ -0,0 +1,12 @@ +'use strict'; + +var repeat = require('./repeat') + + , replace = String.prototype.replace + , re = /(\r\n|[\n\r\u2028\u2029])([\u0000-\u0009\u000b-\uffff]+)/g; + +module.exports = function (indent/*, count*/) { + var count = arguments[1]; + indent = repeat.call(String(indent), (count == null) ? 1 : count); + return indent + replace.call(this, re, '$1' + indent + '$2'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/index.js new file mode 100644 index 0000000..d45d747 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/index.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = { + '@@iterator': require('./@@iterator'), + at: require('./at'), + camelToHyphen: require('./camel-to-hyphen'), + capitalize: require('./capitalize'), + caseInsensitiveCompare: require('./case-insensitive-compare'), + codePointAt: require('./code-point-at'), + contains: require('./contains'), + hyphenToCamel: require('./hyphen-to-camel'), + endsWith: require('./ends-with'), + indent: require('./indent'), + last: require('./last'), + normalize: require('./normalize'), + pad: require('./pad'), + plainReplace: require('./plain-replace'), + plainReplaceAll: require('./plain-replace-all'), + repeat: require('./repeat'), + startsWith: require('./starts-with') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/last.js new file mode 100644 index 0000000..d5cf46e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/last.js @@ -0,0 +1,8 @@ +'use strict'; + +var value = require('../../object/valid-value'); + +module.exports = function () { + var self = String(value(this)), l = self.length; + return l ? self[l - 1] : null; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/_data.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/_data.js new file mode 100644 index 0000000..e4e00a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/_data.js @@ -0,0 +1,69 @@ +'use strict'; + +module.exports = { 0:{60:[,,{824:8814}],61:[,,{824:8800}],62:[,,{824:8815}],65:[,,{768:192,769:193,770:194,771:195,772:256,774:258,775:550,776:196,777:7842,778:197,780:461,783:512,785:514,803:7840,805:7680,808:260}],66:[,,{775:7682,803:7684,817:7686}],67:[,,{769:262,770:264,775:266,780:268,807:199}],68:[,,{775:7690,780:270,803:7692,807:7696,813:7698,817:7694}],69:[,,{768:200,769:201,770:202,771:7868,772:274,774:276,775:278,776:203,777:7866,780:282,783:516,785:518,803:7864,807:552,808:280,813:7704,816:7706}],70:[,,{775:7710}],71:[,,{769:500,770:284,772:7712,774:286,775:288,780:486,807:290}],72:[,,{770:292,775:7714,776:7718,780:542,803:7716,807:7720,814:7722}],73:[,,{768:204,769:205,770:206,771:296,772:298,774:300,775:304,776:207,777:7880,780:463,783:520,785:522,803:7882,808:302,816:7724}],74:[,,{770:308}],75:[,,{769:7728,780:488,803:7730,807:310,817:7732}],76:[,,{769:313,780:317,803:7734,807:315,813:7740,817:7738}],77:[,,{769:7742,775:7744,803:7746}],78:[,,{768:504,769:323,771:209,775:7748,780:327,803:7750,807:325,813:7754,817:7752}],79:[,,{768:210,769:211,770:212,771:213,772:332,774:334,775:558,776:214,777:7886,779:336,780:465,783:524,785:526,795:416,803:7884,808:490}],80:[,,{769:7764,775:7766}],82:[,,{769:340,775:7768,780:344,783:528,785:530,803:7770,807:342,817:7774}],83:[,,{769:346,770:348,775:7776,780:352,803:7778,806:536,807:350}],84:[,,{775:7786,780:356,803:7788,806:538,807:354,813:7792,817:7790}],85:[,,{768:217,769:218,770:219,771:360,772:362,774:364,776:220,777:7910,778:366,779:368,780:467,783:532,785:534,795:431,803:7908,804:7794,808:370,813:7798,816:7796}],86:[,,{771:7804,803:7806}],87:[,,{768:7808,769:7810,770:372,775:7814,776:7812,803:7816}],88:[,,{775:7818,776:7820}],89:[,,{768:7922,769:221,770:374,771:7928,772:562,775:7822,776:376,777:7926,803:7924}],90:[,,{769:377,770:7824,775:379,780:381,803:7826,817:7828}],97:[,,{768:224,769:225,770:226,771:227,772:257,774:259,775:551,776:228,777:7843,778:229,780:462,783:513,785:515,803:7841,805:7681,808:261}],98:[,,{775:7683,803:7685,817:7687}],99:[,,{769:263,770:265,775:267,780:269,807:231}],100:[,,{775:7691,780:271,803:7693,807:7697,813:7699,817:7695}],101:[,,{768:232,769:233,770:234,771:7869,772:275,774:277,775:279,776:235,777:7867,780:283,783:517,785:519,803:7865,807:553,808:281,813:7705,816:7707}],102:[,,{775:7711}],103:[,,{769:501,770:285,772:7713,774:287,775:289,780:487,807:291}],104:[,,{770:293,775:7715,776:7719,780:543,803:7717,807:7721,814:7723,817:7830}],105:[,,{768:236,769:237,770:238,771:297,772:299,774:301,776:239,777:7881,780:464,783:521,785:523,803:7883,808:303,816:7725}],106:[,,{770:309,780:496}],107:[,,{769:7729,780:489,803:7731,807:311,817:7733}],108:[,,{769:314,780:318,803:7735,807:316,813:7741,817:7739}],109:[,,{769:7743,775:7745,803:7747}],110:[,,{768:505,769:324,771:241,775:7749,780:328,803:7751,807:326,813:7755,817:7753}],111:[,,{768:242,769:243,770:244,771:245,772:333,774:335,775:559,776:246,777:7887,779:337,780:466,783:525,785:527,795:417,803:7885,808:491}],112:[,,{769:7765,775:7767}],114:[,,{769:341,775:7769,780:345,783:529,785:531,803:7771,807:343,817:7775}],115:[,,{769:347,770:349,775:7777,780:353,803:7779,806:537,807:351}],116:[,,{775:7787,776:7831,780:357,803:7789,806:539,807:355,813:7793,817:7791}],117:[,,{768:249,769:250,770:251,771:361,772:363,774:365,776:252,777:7911,778:367,779:369,780:468,783:533,785:535,795:432,803:7909,804:7795,808:371,813:7799,816:7797}],118:[,,{771:7805,803:7807}],119:[,,{768:7809,769:7811,770:373,775:7815,776:7813,778:7832,803:7817}],120:[,,{775:7819,776:7821}],121:[,,{768:7923,769:253,770:375,771:7929,772:563,775:7823,776:255,777:7927,778:7833,803:7925}],122:[,,{769:378,770:7825,775:380,780:382,803:7827,817:7829}],160:[[32],256],168:[[32,776],256,{768:8173,769:901,834:8129}],170:[[97],256],175:[[32,772],256],178:[[50],256],179:[[51],256],180:[[32,769],256],181:[[956],256],184:[[32,807],256],185:[[49],256],186:[[111],256],188:[[49,8260,52],256],189:[[49,8260,50],256],190:[[51,8260,52],256],192:[[65,768]],193:[[65,769]],194:[[65,770],,{768:7846,769:7844,771:7850,777:7848}],195:[[65,771]],196:[[65,776],,{772:478}],197:[[65,778],,{769:506}],198:[,,{769:508,772:482}],199:[[67,807],,{769:7688}],200:[[69,768]],201:[[69,769]],202:[[69,770],,{768:7872,769:7870,771:7876,777:7874}],203:[[69,776]],204:[[73,768]],205:[[73,769]],206:[[73,770]],207:[[73,776],,{769:7726}],209:[[78,771]],210:[[79,768]],211:[[79,769]],212:[[79,770],,{768:7890,769:7888,771:7894,777:7892}],213:[[79,771],,{769:7756,772:556,776:7758}],214:[[79,776],,{772:554}],216:[,,{769:510}],217:[[85,768]],218:[[85,769]],219:[[85,770]],220:[[85,776],,{768:475,769:471,772:469,780:473}],221:[[89,769]],224:[[97,768]],225:[[97,769]],226:[[97,770],,{768:7847,769:7845,771:7851,777:7849}],227:[[97,771]],228:[[97,776],,{772:479}],229:[[97,778],,{769:507}],230:[,,{769:509,772:483}],231:[[99,807],,{769:7689}],232:[[101,768]],233:[[101,769]],234:[[101,770],,{768:7873,769:7871,771:7877,777:7875}],235:[[101,776]],236:[[105,768]],237:[[105,769]],238:[[105,770]],239:[[105,776],,{769:7727}],241:[[110,771]],242:[[111,768]],243:[[111,769]],244:[[111,770],,{768:7891,769:7889,771:7895,777:7893}],245:[[111,771],,{769:7757,772:557,776:7759}],246:[[111,776],,{772:555}],248:[,,{769:511}],249:[[117,768]],250:[[117,769]],251:[[117,770]],252:[[117,776],,{768:476,769:472,772:470,780:474}],253:[[121,769]],255:[[121,776]]}, + 256:{256:[[65,772]],257:[[97,772]],258:[[65,774],,{768:7856,769:7854,771:7860,777:7858}],259:[[97,774],,{768:7857,769:7855,771:7861,777:7859}],260:[[65,808]],261:[[97,808]],262:[[67,769]],263:[[99,769]],264:[[67,770]],265:[[99,770]],266:[[67,775]],267:[[99,775]],268:[[67,780]],269:[[99,780]],270:[[68,780]],271:[[100,780]],274:[[69,772],,{768:7700,769:7702}],275:[[101,772],,{768:7701,769:7703}],276:[[69,774]],277:[[101,774]],278:[[69,775]],279:[[101,775]],280:[[69,808]],281:[[101,808]],282:[[69,780]],283:[[101,780]],284:[[71,770]],285:[[103,770]],286:[[71,774]],287:[[103,774]],288:[[71,775]],289:[[103,775]],290:[[71,807]],291:[[103,807]],292:[[72,770]],293:[[104,770]],296:[[73,771]],297:[[105,771]],298:[[73,772]],299:[[105,772]],300:[[73,774]],301:[[105,774]],302:[[73,808]],303:[[105,808]],304:[[73,775]],306:[[73,74],256],307:[[105,106],256],308:[[74,770]],309:[[106,770]],310:[[75,807]],311:[[107,807]],313:[[76,769]],314:[[108,769]],315:[[76,807]],316:[[108,807]],317:[[76,780]],318:[[108,780]],319:[[76,183],256],320:[[108,183],256],323:[[78,769]],324:[[110,769]],325:[[78,807]],326:[[110,807]],327:[[78,780]],328:[[110,780]],329:[[700,110],256],332:[[79,772],,{768:7760,769:7762}],333:[[111,772],,{768:7761,769:7763}],334:[[79,774]],335:[[111,774]],336:[[79,779]],337:[[111,779]],340:[[82,769]],341:[[114,769]],342:[[82,807]],343:[[114,807]],344:[[82,780]],345:[[114,780]],346:[[83,769],,{775:7780}],347:[[115,769],,{775:7781}],348:[[83,770]],349:[[115,770]],350:[[83,807]],351:[[115,807]],352:[[83,780],,{775:7782}],353:[[115,780],,{775:7783}],354:[[84,807]],355:[[116,807]],356:[[84,780]],357:[[116,780]],360:[[85,771],,{769:7800}],361:[[117,771],,{769:7801}],362:[[85,772],,{776:7802}],363:[[117,772],,{776:7803}],364:[[85,774]],365:[[117,774]],366:[[85,778]],367:[[117,778]],368:[[85,779]],369:[[117,779]],370:[[85,808]],371:[[117,808]],372:[[87,770]],373:[[119,770]],374:[[89,770]],375:[[121,770]],376:[[89,776]],377:[[90,769]],378:[[122,769]],379:[[90,775]],380:[[122,775]],381:[[90,780]],382:[[122,780]],383:[[115],256,{775:7835}],416:[[79,795],,{768:7900,769:7898,771:7904,777:7902,803:7906}],417:[[111,795],,{768:7901,769:7899,771:7905,777:7903,803:7907}],431:[[85,795],,{768:7914,769:7912,771:7918,777:7916,803:7920}],432:[[117,795],,{768:7915,769:7913,771:7919,777:7917,803:7921}],439:[,,{780:494}],452:[[68,381],256],453:[[68,382],256],454:[[100,382],256],455:[[76,74],256],456:[[76,106],256],457:[[108,106],256],458:[[78,74],256],459:[[78,106],256],460:[[110,106],256],461:[[65,780]],462:[[97,780]],463:[[73,780]],464:[[105,780]],465:[[79,780]],466:[[111,780]],467:[[85,780]],468:[[117,780]],469:[[220,772]],470:[[252,772]],471:[[220,769]],472:[[252,769]],473:[[220,780]],474:[[252,780]],475:[[220,768]],476:[[252,768]],478:[[196,772]],479:[[228,772]],480:[[550,772]],481:[[551,772]],482:[[198,772]],483:[[230,772]],486:[[71,780]],487:[[103,780]],488:[[75,780]],489:[[107,780]],490:[[79,808],,{772:492}],491:[[111,808],,{772:493}],492:[[490,772]],493:[[491,772]],494:[[439,780]],495:[[658,780]],496:[[106,780]],497:[[68,90],256],498:[[68,122],256],499:[[100,122],256],500:[[71,769]],501:[[103,769]],504:[[78,768]],505:[[110,768]],506:[[197,769]],507:[[229,769]],508:[[198,769]],509:[[230,769]],510:[[216,769]],511:[[248,769]],66045:[,220]}, + 512:{512:[[65,783]],513:[[97,783]],514:[[65,785]],515:[[97,785]],516:[[69,783]],517:[[101,783]],518:[[69,785]],519:[[101,785]],520:[[73,783]],521:[[105,783]],522:[[73,785]],523:[[105,785]],524:[[79,783]],525:[[111,783]],526:[[79,785]],527:[[111,785]],528:[[82,783]],529:[[114,783]],530:[[82,785]],531:[[114,785]],532:[[85,783]],533:[[117,783]],534:[[85,785]],535:[[117,785]],536:[[83,806]],537:[[115,806]],538:[[84,806]],539:[[116,806]],542:[[72,780]],543:[[104,780]],550:[[65,775],,{772:480}],551:[[97,775],,{772:481}],552:[[69,807],,{774:7708}],553:[[101,807],,{774:7709}],554:[[214,772]],555:[[246,772]],556:[[213,772]],557:[[245,772]],558:[[79,775],,{772:560}],559:[[111,775],,{772:561}],560:[[558,772]],561:[[559,772]],562:[[89,772]],563:[[121,772]],658:[,,{780:495}],688:[[104],256],689:[[614],256],690:[[106],256],691:[[114],256],692:[[633],256],693:[[635],256],694:[[641],256],695:[[119],256],696:[[121],256],728:[[32,774],256],729:[[32,775],256],730:[[32,778],256],731:[[32,808],256],732:[[32,771],256],733:[[32,779],256],736:[[611],256],737:[[108],256],738:[[115],256],739:[[120],256],740:[[661],256]}, + 768:{768:[,230],769:[,230],770:[,230],771:[,230],772:[,230],773:[,230],774:[,230],775:[,230],776:[,230,{769:836}],777:[,230],778:[,230],779:[,230],780:[,230],781:[,230],782:[,230],783:[,230],784:[,230],785:[,230],786:[,230],787:[,230],788:[,230],789:[,232],790:[,220],791:[,220],792:[,220],793:[,220],794:[,232],795:[,216],796:[,220],797:[,220],798:[,220],799:[,220],800:[,220],801:[,202],802:[,202],803:[,220],804:[,220],805:[,220],806:[,220],807:[,202],808:[,202],809:[,220],810:[,220],811:[,220],812:[,220],813:[,220],814:[,220],815:[,220],816:[,220],817:[,220],818:[,220],819:[,220],820:[,1],821:[,1],822:[,1],823:[,1],824:[,1],825:[,220],826:[,220],827:[,220],828:[,220],829:[,230],830:[,230],831:[,230],832:[[768],230],833:[[769],230],834:[,230],835:[[787],230],836:[[776,769],230],837:[,240],838:[,230],839:[,220],840:[,220],841:[,220],842:[,230],843:[,230],844:[,230],845:[,220],846:[,220],848:[,230],849:[,230],850:[,230],851:[,220],852:[,220],853:[,220],854:[,220],855:[,230],856:[,232],857:[,220],858:[,220],859:[,230],860:[,233],861:[,234],862:[,234],863:[,233],864:[,234],865:[,234],866:[,233],867:[,230],868:[,230],869:[,230],870:[,230],871:[,230],872:[,230],873:[,230],874:[,230],875:[,230],876:[,230],877:[,230],878:[,230],879:[,230],884:[[697]],890:[[32,837],256],894:[[59]],900:[[32,769],256],901:[[168,769]],902:[[913,769]],903:[[183]],904:[[917,769]],905:[[919,769]],906:[[921,769]],908:[[927,769]],910:[[933,769]],911:[[937,769]],912:[[970,769]],913:[,,{768:8122,769:902,772:8121,774:8120,787:7944,788:7945,837:8124}],917:[,,{768:8136,769:904,787:7960,788:7961}],919:[,,{768:8138,769:905,787:7976,788:7977,837:8140}],921:[,,{768:8154,769:906,772:8153,774:8152,776:938,787:7992,788:7993}],927:[,,{768:8184,769:908,787:8008,788:8009}],929:[,,{788:8172}],933:[,,{768:8170,769:910,772:8169,774:8168,776:939,788:8025}],937:[,,{768:8186,769:911,787:8040,788:8041,837:8188}],938:[[921,776]],939:[[933,776]],940:[[945,769],,{837:8116}],941:[[949,769]],942:[[951,769],,{837:8132}],943:[[953,769]],944:[[971,769]],945:[,,{768:8048,769:940,772:8113,774:8112,787:7936,788:7937,834:8118,837:8115}],949:[,,{768:8050,769:941,787:7952,788:7953}],951:[,,{768:8052,769:942,787:7968,788:7969,834:8134,837:8131}],953:[,,{768:8054,769:943,772:8145,774:8144,776:970,787:7984,788:7985,834:8150}],959:[,,{768:8056,769:972,787:8000,788:8001}],961:[,,{787:8164,788:8165}],965:[,,{768:8058,769:973,772:8161,774:8160,776:971,787:8016,788:8017,834:8166}],969:[,,{768:8060,769:974,787:8032,788:8033,834:8182,837:8179}],970:[[953,776],,{768:8146,769:912,834:8151}],971:[[965,776],,{768:8162,769:944,834:8167}],972:[[959,769]],973:[[965,769]],974:[[969,769],,{837:8180}],976:[[946],256],977:[[952],256],978:[[933],256,{769:979,776:980}],979:[[978,769]],980:[[978,776]],981:[[966],256],982:[[960],256],1008:[[954],256],1009:[[961],256],1010:[[962],256],1012:[[920],256],1013:[[949],256],1017:[[931],256]}, + 1024:{1024:[[1045,768]],1025:[[1045,776]],1027:[[1043,769]],1030:[,,{776:1031}],1031:[[1030,776]],1036:[[1050,769]],1037:[[1048,768]],1038:[[1059,774]],1040:[,,{774:1232,776:1234}],1043:[,,{769:1027}],1045:[,,{768:1024,774:1238,776:1025}],1046:[,,{774:1217,776:1244}],1047:[,,{776:1246}],1048:[,,{768:1037,772:1250,774:1049,776:1252}],1049:[[1048,774]],1050:[,,{769:1036}],1054:[,,{776:1254}],1059:[,,{772:1262,774:1038,776:1264,779:1266}],1063:[,,{776:1268}],1067:[,,{776:1272}],1069:[,,{776:1260}],1072:[,,{774:1233,776:1235}],1075:[,,{769:1107}],1077:[,,{768:1104,774:1239,776:1105}],1078:[,,{774:1218,776:1245}],1079:[,,{776:1247}],1080:[,,{768:1117,772:1251,774:1081,776:1253}],1081:[[1080,774]],1082:[,,{769:1116}],1086:[,,{776:1255}],1091:[,,{772:1263,774:1118,776:1265,779:1267}],1095:[,,{776:1269}],1099:[,,{776:1273}],1101:[,,{776:1261}],1104:[[1077,768]],1105:[[1077,776]],1107:[[1075,769]],1110:[,,{776:1111}],1111:[[1110,776]],1116:[[1082,769]],1117:[[1080,768]],1118:[[1091,774]],1140:[,,{783:1142}],1141:[,,{783:1143}],1142:[[1140,783]],1143:[[1141,783]],1155:[,230],1156:[,230],1157:[,230],1158:[,230],1159:[,230],1217:[[1046,774]],1218:[[1078,774]],1232:[[1040,774]],1233:[[1072,774]],1234:[[1040,776]],1235:[[1072,776]],1238:[[1045,774]],1239:[[1077,774]],1240:[,,{776:1242}],1241:[,,{776:1243}],1242:[[1240,776]],1243:[[1241,776]],1244:[[1046,776]],1245:[[1078,776]],1246:[[1047,776]],1247:[[1079,776]],1250:[[1048,772]],1251:[[1080,772]],1252:[[1048,776]],1253:[[1080,776]],1254:[[1054,776]],1255:[[1086,776]],1256:[,,{776:1258}],1257:[,,{776:1259}],1258:[[1256,776]],1259:[[1257,776]],1260:[[1069,776]],1261:[[1101,776]],1262:[[1059,772]],1263:[[1091,772]],1264:[[1059,776]],1265:[[1091,776]],1266:[[1059,779]],1267:[[1091,779]],1268:[[1063,776]],1269:[[1095,776]],1272:[[1067,776]],1273:[[1099,776]]}, + 1280:{1415:[[1381,1410],256],1425:[,220],1426:[,230],1427:[,230],1428:[,230],1429:[,230],1430:[,220],1431:[,230],1432:[,230],1433:[,230],1434:[,222],1435:[,220],1436:[,230],1437:[,230],1438:[,230],1439:[,230],1440:[,230],1441:[,230],1442:[,220],1443:[,220],1444:[,220],1445:[,220],1446:[,220],1447:[,220],1448:[,230],1449:[,230],1450:[,220],1451:[,230],1452:[,230],1453:[,222],1454:[,228],1455:[,230],1456:[,10],1457:[,11],1458:[,12],1459:[,13],1460:[,14],1461:[,15],1462:[,16],1463:[,17],1464:[,18],1465:[,19],1466:[,19],1467:[,20],1468:[,21],1469:[,22],1471:[,23],1473:[,24],1474:[,25],1476:[,230],1477:[,220],1479:[,18]}, + 1536:{1552:[,230],1553:[,230],1554:[,230],1555:[,230],1556:[,230],1557:[,230],1558:[,230],1559:[,230],1560:[,30],1561:[,31],1562:[,32],1570:[[1575,1619]],1571:[[1575,1620]],1572:[[1608,1620]],1573:[[1575,1621]],1574:[[1610,1620]],1575:[,,{1619:1570,1620:1571,1621:1573}],1608:[,,{1620:1572}],1610:[,,{1620:1574}],1611:[,27],1612:[,28],1613:[,29],1614:[,30],1615:[,31],1616:[,32],1617:[,33],1618:[,34],1619:[,230],1620:[,230],1621:[,220],1622:[,220],1623:[,230],1624:[,230],1625:[,230],1626:[,230],1627:[,230],1628:[,220],1629:[,230],1630:[,230],1631:[,220],1648:[,35],1653:[[1575,1652],256],1654:[[1608,1652],256],1655:[[1735,1652],256],1656:[[1610,1652],256],1728:[[1749,1620]],1729:[,,{1620:1730}],1730:[[1729,1620]],1746:[,,{1620:1747}],1747:[[1746,1620]],1749:[,,{1620:1728}],1750:[,230],1751:[,230],1752:[,230],1753:[,230],1754:[,230],1755:[,230],1756:[,230],1759:[,230],1760:[,230],1761:[,230],1762:[,230],1763:[,220],1764:[,230],1767:[,230],1768:[,230],1770:[,220],1771:[,230],1772:[,230],1773:[,220]}, + 1792:{1809:[,36],1840:[,230],1841:[,220],1842:[,230],1843:[,230],1844:[,220],1845:[,230],1846:[,230],1847:[,220],1848:[,220],1849:[,220],1850:[,230],1851:[,220],1852:[,220],1853:[,230],1854:[,220],1855:[,230],1856:[,230],1857:[,230],1858:[,220],1859:[,230],1860:[,220],1861:[,230],1862:[,220],1863:[,230],1864:[,220],1865:[,230],1866:[,230],2027:[,230],2028:[,230],2029:[,230],2030:[,230],2031:[,230],2032:[,230],2033:[,230],2034:[,220],2035:[,230]}, + 2048:{2070:[,230],2071:[,230],2072:[,230],2073:[,230],2075:[,230],2076:[,230],2077:[,230],2078:[,230],2079:[,230],2080:[,230],2081:[,230],2082:[,230],2083:[,230],2085:[,230],2086:[,230],2087:[,230],2089:[,230],2090:[,230],2091:[,230],2092:[,230],2093:[,230],2137:[,220],2138:[,220],2139:[,220],2276:[,230],2277:[,230],2278:[,220],2279:[,230],2280:[,230],2281:[,220],2282:[,230],2283:[,230],2284:[,230],2285:[,220],2286:[,220],2287:[,220],2288:[,27],2289:[,28],2290:[,29],2291:[,230],2292:[,230],2293:[,230],2294:[,220],2295:[,230],2296:[,230],2297:[,220],2298:[,220],2299:[,230],2300:[,230],2301:[,230],2302:[,230]}, + 2304:{2344:[,,{2364:2345}],2345:[[2344,2364]],2352:[,,{2364:2353}],2353:[[2352,2364]],2355:[,,{2364:2356}],2356:[[2355,2364]],2364:[,7],2381:[,9],2385:[,230],2386:[,220],2387:[,230],2388:[,230],2392:[[2325,2364],512],2393:[[2326,2364],512],2394:[[2327,2364],512],2395:[[2332,2364],512],2396:[[2337,2364],512],2397:[[2338,2364],512],2398:[[2347,2364],512],2399:[[2351,2364],512],2492:[,7],2503:[,,{2494:2507,2519:2508}],2507:[[2503,2494]],2508:[[2503,2519]],2509:[,9],2524:[[2465,2492],512],2525:[[2466,2492],512],2527:[[2479,2492],512]}, + 2560:{2611:[[2610,2620],512],2614:[[2616,2620],512],2620:[,7],2637:[,9],2649:[[2582,2620],512],2650:[[2583,2620],512],2651:[[2588,2620],512],2654:[[2603,2620],512],2748:[,7],2765:[,9],68109:[,220],68111:[,230],68152:[,230],68153:[,1],68154:[,220],68159:[,9]}, + 2816:{2876:[,7],2887:[,,{2878:2891,2902:2888,2903:2892}],2888:[[2887,2902]],2891:[[2887,2878]],2892:[[2887,2903]],2893:[,9],2908:[[2849,2876],512],2909:[[2850,2876],512],2962:[,,{3031:2964}],2964:[[2962,3031]],3014:[,,{3006:3018,3031:3020}],3015:[,,{3006:3019}],3018:[[3014,3006]],3019:[[3015,3006]],3020:[[3014,3031]],3021:[,9]}, + 3072:{3142:[,,{3158:3144}],3144:[[3142,3158]],3149:[,9],3157:[,84],3158:[,91],3260:[,7],3263:[,,{3285:3264}],3264:[[3263,3285]],3270:[,,{3266:3274,3285:3271,3286:3272}],3271:[[3270,3285]],3272:[[3270,3286]],3274:[[3270,3266],,{3285:3275}],3275:[[3274,3285]],3277:[,9]}, + 3328:{3398:[,,{3390:3402,3415:3404}],3399:[,,{3390:3403}],3402:[[3398,3390]],3403:[[3399,3390]],3404:[[3398,3415]],3405:[,9],3530:[,9],3545:[,,{3530:3546,3535:3548,3551:3550}],3546:[[3545,3530]],3548:[[3545,3535],,{3530:3549}],3549:[[3548,3530]],3550:[[3545,3551]]}, + 3584:{3635:[[3661,3634],256],3640:[,103],3641:[,103],3642:[,9],3656:[,107],3657:[,107],3658:[,107],3659:[,107],3763:[[3789,3762],256],3768:[,118],3769:[,118],3784:[,122],3785:[,122],3786:[,122],3787:[,122],3804:[[3755,3737],256],3805:[[3755,3745],256]}, + 3840:{3852:[[3851],256],3864:[,220],3865:[,220],3893:[,220],3895:[,220],3897:[,216],3907:[[3906,4023],512],3917:[[3916,4023],512],3922:[[3921,4023],512],3927:[[3926,4023],512],3932:[[3931,4023],512],3945:[[3904,4021],512],3953:[,129],3954:[,130],3955:[[3953,3954],512],3956:[,132],3957:[[3953,3956],512],3958:[[4018,3968],512],3959:[[4018,3969],256],3960:[[4019,3968],512],3961:[[4019,3969],256],3962:[,130],3963:[,130],3964:[,130],3965:[,130],3968:[,130],3969:[[3953,3968],512],3970:[,230],3971:[,230],3972:[,9],3974:[,230],3975:[,230],3987:[[3986,4023],512],3997:[[3996,4023],512],4002:[[4001,4023],512],4007:[[4006,4023],512],4012:[[4011,4023],512],4025:[[3984,4021],512],4038:[,220]}, + 4096:{4133:[,,{4142:4134}],4134:[[4133,4142]],4151:[,7],4153:[,9],4154:[,9],4237:[,220],4348:[[4316],256],69702:[,9],69785:[,,{69818:69786}],69786:[[69785,69818]],69787:[,,{69818:69788}],69788:[[69787,69818]],69797:[,,{69818:69803}],69803:[[69797,69818]],69817:[,9],69818:[,7]}, + 4352:{69888:[,230],69889:[,230],69890:[,230],69934:[[69937,69927]],69935:[[69938,69927]],69937:[,,{69927:69934}],69938:[,,{69927:69935}],69939:[,9],69940:[,9],70080:[,9]}, + 4864:{4957:[,230],4958:[,230],4959:[,230]}, + 5632:{71350:[,9],71351:[,7]}, + 5888:{5908:[,9],5940:[,9],6098:[,9],6109:[,230]}, + 6144:{6313:[,228]}, + 6400:{6457:[,222],6458:[,230],6459:[,220]}, + 6656:{6679:[,230],6680:[,220],6752:[,9],6773:[,230],6774:[,230],6775:[,230],6776:[,230],6777:[,230],6778:[,230],6779:[,230],6780:[,230],6783:[,220]}, + 6912:{6917:[,,{6965:6918}],6918:[[6917,6965]],6919:[,,{6965:6920}],6920:[[6919,6965]],6921:[,,{6965:6922}],6922:[[6921,6965]],6923:[,,{6965:6924}],6924:[[6923,6965]],6925:[,,{6965:6926}],6926:[[6925,6965]],6929:[,,{6965:6930}],6930:[[6929,6965]],6964:[,7],6970:[,,{6965:6971}],6971:[[6970,6965]],6972:[,,{6965:6973}],6973:[[6972,6965]],6974:[,,{6965:6976}],6975:[,,{6965:6977}],6976:[[6974,6965]],6977:[[6975,6965]],6978:[,,{6965:6979}],6979:[[6978,6965]],6980:[,9],7019:[,230],7020:[,220],7021:[,230],7022:[,230],7023:[,230],7024:[,230],7025:[,230],7026:[,230],7027:[,230],7082:[,9],7083:[,9],7142:[,7],7154:[,9],7155:[,9]}, + 7168:{7223:[,7],7376:[,230],7377:[,230],7378:[,230],7380:[,1],7381:[,220],7382:[,220],7383:[,220],7384:[,220],7385:[,220],7386:[,230],7387:[,230],7388:[,220],7389:[,220],7390:[,220],7391:[,220],7392:[,230],7394:[,1],7395:[,1],7396:[,1],7397:[,1],7398:[,1],7399:[,1],7400:[,1],7405:[,220],7412:[,230]}, + 7424:{7468:[[65],256],7469:[[198],256],7470:[[66],256],7472:[[68],256],7473:[[69],256],7474:[[398],256],7475:[[71],256],7476:[[72],256],7477:[[73],256],7478:[[74],256],7479:[[75],256],7480:[[76],256],7481:[[77],256],7482:[[78],256],7484:[[79],256],7485:[[546],256],7486:[[80],256],7487:[[82],256],7488:[[84],256],7489:[[85],256],7490:[[87],256],7491:[[97],256],7492:[[592],256],7493:[[593],256],7494:[[7426],256],7495:[[98],256],7496:[[100],256],7497:[[101],256],7498:[[601],256],7499:[[603],256],7500:[[604],256],7501:[[103],256],7503:[[107],256],7504:[[109],256],7505:[[331],256],7506:[[111],256],7507:[[596],256],7508:[[7446],256],7509:[[7447],256],7510:[[112],256],7511:[[116],256],7512:[[117],256],7513:[[7453],256],7514:[[623],256],7515:[[118],256],7516:[[7461],256],7517:[[946],256],7518:[[947],256],7519:[[948],256],7520:[[966],256],7521:[[967],256],7522:[[105],256],7523:[[114],256],7524:[[117],256],7525:[[118],256],7526:[[946],256],7527:[[947],256],7528:[[961],256],7529:[[966],256],7530:[[967],256],7544:[[1085],256],7579:[[594],256],7580:[[99],256],7581:[[597],256],7582:[[240],256],7583:[[604],256],7584:[[102],256],7585:[[607],256],7586:[[609],256],7587:[[613],256],7588:[[616],256],7589:[[617],256],7590:[[618],256],7591:[[7547],256],7592:[[669],256],7593:[[621],256],7594:[[7557],256],7595:[[671],256],7596:[[625],256],7597:[[624],256],7598:[[626],256],7599:[[627],256],7600:[[628],256],7601:[[629],256],7602:[[632],256],7603:[[642],256],7604:[[643],256],7605:[[427],256],7606:[[649],256],7607:[[650],256],7608:[[7452],256],7609:[[651],256],7610:[[652],256],7611:[[122],256],7612:[[656],256],7613:[[657],256],7614:[[658],256],7615:[[952],256],7616:[,230],7617:[,230],7618:[,220],7619:[,230],7620:[,230],7621:[,230],7622:[,230],7623:[,230],7624:[,230],7625:[,230],7626:[,220],7627:[,230],7628:[,230],7629:[,234],7630:[,214],7631:[,220],7632:[,202],7633:[,230],7634:[,230],7635:[,230],7636:[,230],7637:[,230],7638:[,230],7639:[,230],7640:[,230],7641:[,230],7642:[,230],7643:[,230],7644:[,230],7645:[,230],7646:[,230],7647:[,230],7648:[,230],7649:[,230],7650:[,230],7651:[,230],7652:[,230],7653:[,230],7654:[,230],7676:[,233],7677:[,220],7678:[,230],7679:[,220]}, + 7680:{7680:[[65,805]],7681:[[97,805]],7682:[[66,775]],7683:[[98,775]],7684:[[66,803]],7685:[[98,803]],7686:[[66,817]],7687:[[98,817]],7688:[[199,769]],7689:[[231,769]],7690:[[68,775]],7691:[[100,775]],7692:[[68,803]],7693:[[100,803]],7694:[[68,817]],7695:[[100,817]],7696:[[68,807]],7697:[[100,807]],7698:[[68,813]],7699:[[100,813]],7700:[[274,768]],7701:[[275,768]],7702:[[274,769]],7703:[[275,769]],7704:[[69,813]],7705:[[101,813]],7706:[[69,816]],7707:[[101,816]],7708:[[552,774]],7709:[[553,774]],7710:[[70,775]],7711:[[102,775]],7712:[[71,772]],7713:[[103,772]],7714:[[72,775]],7715:[[104,775]],7716:[[72,803]],7717:[[104,803]],7718:[[72,776]],7719:[[104,776]],7720:[[72,807]],7721:[[104,807]],7722:[[72,814]],7723:[[104,814]],7724:[[73,816]],7725:[[105,816]],7726:[[207,769]],7727:[[239,769]],7728:[[75,769]],7729:[[107,769]],7730:[[75,803]],7731:[[107,803]],7732:[[75,817]],7733:[[107,817]],7734:[[76,803],,{772:7736}],7735:[[108,803],,{772:7737}],7736:[[7734,772]],7737:[[7735,772]],7738:[[76,817]],7739:[[108,817]],7740:[[76,813]],7741:[[108,813]],7742:[[77,769]],7743:[[109,769]],7744:[[77,775]],7745:[[109,775]],7746:[[77,803]],7747:[[109,803]],7748:[[78,775]],7749:[[110,775]],7750:[[78,803]],7751:[[110,803]],7752:[[78,817]],7753:[[110,817]],7754:[[78,813]],7755:[[110,813]],7756:[[213,769]],7757:[[245,769]],7758:[[213,776]],7759:[[245,776]],7760:[[332,768]],7761:[[333,768]],7762:[[332,769]],7763:[[333,769]],7764:[[80,769]],7765:[[112,769]],7766:[[80,775]],7767:[[112,775]],7768:[[82,775]],7769:[[114,775]],7770:[[82,803],,{772:7772}],7771:[[114,803],,{772:7773}],7772:[[7770,772]],7773:[[7771,772]],7774:[[82,817]],7775:[[114,817]],7776:[[83,775]],7777:[[115,775]],7778:[[83,803],,{775:7784}],7779:[[115,803],,{775:7785}],7780:[[346,775]],7781:[[347,775]],7782:[[352,775]],7783:[[353,775]],7784:[[7778,775]],7785:[[7779,775]],7786:[[84,775]],7787:[[116,775]],7788:[[84,803]],7789:[[116,803]],7790:[[84,817]],7791:[[116,817]],7792:[[84,813]],7793:[[116,813]],7794:[[85,804]],7795:[[117,804]],7796:[[85,816]],7797:[[117,816]],7798:[[85,813]],7799:[[117,813]],7800:[[360,769]],7801:[[361,769]],7802:[[362,776]],7803:[[363,776]],7804:[[86,771]],7805:[[118,771]],7806:[[86,803]],7807:[[118,803]],7808:[[87,768]],7809:[[119,768]],7810:[[87,769]],7811:[[119,769]],7812:[[87,776]],7813:[[119,776]],7814:[[87,775]],7815:[[119,775]],7816:[[87,803]],7817:[[119,803]],7818:[[88,775]],7819:[[120,775]],7820:[[88,776]],7821:[[120,776]],7822:[[89,775]],7823:[[121,775]],7824:[[90,770]],7825:[[122,770]],7826:[[90,803]],7827:[[122,803]],7828:[[90,817]],7829:[[122,817]],7830:[[104,817]],7831:[[116,776]],7832:[[119,778]],7833:[[121,778]],7834:[[97,702],256],7835:[[383,775]],7840:[[65,803],,{770:7852,774:7862}],7841:[[97,803],,{770:7853,774:7863}],7842:[[65,777]],7843:[[97,777]],7844:[[194,769]],7845:[[226,769]],7846:[[194,768]],7847:[[226,768]],7848:[[194,777]],7849:[[226,777]],7850:[[194,771]],7851:[[226,771]],7852:[[7840,770]],7853:[[7841,770]],7854:[[258,769]],7855:[[259,769]],7856:[[258,768]],7857:[[259,768]],7858:[[258,777]],7859:[[259,777]],7860:[[258,771]],7861:[[259,771]],7862:[[7840,774]],7863:[[7841,774]],7864:[[69,803],,{770:7878}],7865:[[101,803],,{770:7879}],7866:[[69,777]],7867:[[101,777]],7868:[[69,771]],7869:[[101,771]],7870:[[202,769]],7871:[[234,769]],7872:[[202,768]],7873:[[234,768]],7874:[[202,777]],7875:[[234,777]],7876:[[202,771]],7877:[[234,771]],7878:[[7864,770]],7879:[[7865,770]],7880:[[73,777]],7881:[[105,777]],7882:[[73,803]],7883:[[105,803]],7884:[[79,803],,{770:7896}],7885:[[111,803],,{770:7897}],7886:[[79,777]],7887:[[111,777]],7888:[[212,769]],7889:[[244,769]],7890:[[212,768]],7891:[[244,768]],7892:[[212,777]],7893:[[244,777]],7894:[[212,771]],7895:[[244,771]],7896:[[7884,770]],7897:[[7885,770]],7898:[[416,769]],7899:[[417,769]],7900:[[416,768]],7901:[[417,768]],7902:[[416,777]],7903:[[417,777]],7904:[[416,771]],7905:[[417,771]],7906:[[416,803]],7907:[[417,803]],7908:[[85,803]],7909:[[117,803]],7910:[[85,777]],7911:[[117,777]],7912:[[431,769]],7913:[[432,769]],7914:[[431,768]],7915:[[432,768]],7916:[[431,777]],7917:[[432,777]],7918:[[431,771]],7919:[[432,771]],7920:[[431,803]],7921:[[432,803]],7922:[[89,768]],7923:[[121,768]],7924:[[89,803]],7925:[[121,803]],7926:[[89,777]],7927:[[121,777]],7928:[[89,771]],7929:[[121,771]]}, + 7936:{7936:[[945,787],,{768:7938,769:7940,834:7942,837:8064}],7937:[[945,788],,{768:7939,769:7941,834:7943,837:8065}],7938:[[7936,768],,{837:8066}],7939:[[7937,768],,{837:8067}],7940:[[7936,769],,{837:8068}],7941:[[7937,769],,{837:8069}],7942:[[7936,834],,{837:8070}],7943:[[7937,834],,{837:8071}],7944:[[913,787],,{768:7946,769:7948,834:7950,837:8072}],7945:[[913,788],,{768:7947,769:7949,834:7951,837:8073}],7946:[[7944,768],,{837:8074}],7947:[[7945,768],,{837:8075}],7948:[[7944,769],,{837:8076}],7949:[[7945,769],,{837:8077}],7950:[[7944,834],,{837:8078}],7951:[[7945,834],,{837:8079}],7952:[[949,787],,{768:7954,769:7956}],7953:[[949,788],,{768:7955,769:7957}],7954:[[7952,768]],7955:[[7953,768]],7956:[[7952,769]],7957:[[7953,769]],7960:[[917,787],,{768:7962,769:7964}],7961:[[917,788],,{768:7963,769:7965}],7962:[[7960,768]],7963:[[7961,768]],7964:[[7960,769]],7965:[[7961,769]],7968:[[951,787],,{768:7970,769:7972,834:7974,837:8080}],7969:[[951,788],,{768:7971,769:7973,834:7975,837:8081}],7970:[[7968,768],,{837:8082}],7971:[[7969,768],,{837:8083}],7972:[[7968,769],,{837:8084}],7973:[[7969,769],,{837:8085}],7974:[[7968,834],,{837:8086}],7975:[[7969,834],,{837:8087}],7976:[[919,787],,{768:7978,769:7980,834:7982,837:8088}],7977:[[919,788],,{768:7979,769:7981,834:7983,837:8089}],7978:[[7976,768],,{837:8090}],7979:[[7977,768],,{837:8091}],7980:[[7976,769],,{837:8092}],7981:[[7977,769],,{837:8093}],7982:[[7976,834],,{837:8094}],7983:[[7977,834],,{837:8095}],7984:[[953,787],,{768:7986,769:7988,834:7990}],7985:[[953,788],,{768:7987,769:7989,834:7991}],7986:[[7984,768]],7987:[[7985,768]],7988:[[7984,769]],7989:[[7985,769]],7990:[[7984,834]],7991:[[7985,834]],7992:[[921,787],,{768:7994,769:7996,834:7998}],7993:[[921,788],,{768:7995,769:7997,834:7999}],7994:[[7992,768]],7995:[[7993,768]],7996:[[7992,769]],7997:[[7993,769]],7998:[[7992,834]],7999:[[7993,834]],8000:[[959,787],,{768:8002,769:8004}],8001:[[959,788],,{768:8003,769:8005}],8002:[[8000,768]],8003:[[8001,768]],8004:[[8000,769]],8005:[[8001,769]],8008:[[927,787],,{768:8010,769:8012}],8009:[[927,788],,{768:8011,769:8013}],8010:[[8008,768]],8011:[[8009,768]],8012:[[8008,769]],8013:[[8009,769]],8016:[[965,787],,{768:8018,769:8020,834:8022}],8017:[[965,788],,{768:8019,769:8021,834:8023}],8018:[[8016,768]],8019:[[8017,768]],8020:[[8016,769]],8021:[[8017,769]],8022:[[8016,834]],8023:[[8017,834]],8025:[[933,788],,{768:8027,769:8029,834:8031}],8027:[[8025,768]],8029:[[8025,769]],8031:[[8025,834]],8032:[[969,787],,{768:8034,769:8036,834:8038,837:8096}],8033:[[969,788],,{768:8035,769:8037,834:8039,837:8097}],8034:[[8032,768],,{837:8098}],8035:[[8033,768],,{837:8099}],8036:[[8032,769],,{837:8100}],8037:[[8033,769],,{837:8101}],8038:[[8032,834],,{837:8102}],8039:[[8033,834],,{837:8103}],8040:[[937,787],,{768:8042,769:8044,834:8046,837:8104}],8041:[[937,788],,{768:8043,769:8045,834:8047,837:8105}],8042:[[8040,768],,{837:8106}],8043:[[8041,768],,{837:8107}],8044:[[8040,769],,{837:8108}],8045:[[8041,769],,{837:8109}],8046:[[8040,834],,{837:8110}],8047:[[8041,834],,{837:8111}],8048:[[945,768],,{837:8114}],8049:[[940]],8050:[[949,768]],8051:[[941]],8052:[[951,768],,{837:8130}],8053:[[942]],8054:[[953,768]],8055:[[943]],8056:[[959,768]],8057:[[972]],8058:[[965,768]],8059:[[973]],8060:[[969,768],,{837:8178}],8061:[[974]],8064:[[7936,837]],8065:[[7937,837]],8066:[[7938,837]],8067:[[7939,837]],8068:[[7940,837]],8069:[[7941,837]],8070:[[7942,837]],8071:[[7943,837]],8072:[[7944,837]],8073:[[7945,837]],8074:[[7946,837]],8075:[[7947,837]],8076:[[7948,837]],8077:[[7949,837]],8078:[[7950,837]],8079:[[7951,837]],8080:[[7968,837]],8081:[[7969,837]],8082:[[7970,837]],8083:[[7971,837]],8084:[[7972,837]],8085:[[7973,837]],8086:[[7974,837]],8087:[[7975,837]],8088:[[7976,837]],8089:[[7977,837]],8090:[[7978,837]],8091:[[7979,837]],8092:[[7980,837]],8093:[[7981,837]],8094:[[7982,837]],8095:[[7983,837]],8096:[[8032,837]],8097:[[8033,837]],8098:[[8034,837]],8099:[[8035,837]],8100:[[8036,837]],8101:[[8037,837]],8102:[[8038,837]],8103:[[8039,837]],8104:[[8040,837]],8105:[[8041,837]],8106:[[8042,837]],8107:[[8043,837]],8108:[[8044,837]],8109:[[8045,837]],8110:[[8046,837]],8111:[[8047,837]],8112:[[945,774]],8113:[[945,772]],8114:[[8048,837]],8115:[[945,837]],8116:[[940,837]],8118:[[945,834],,{837:8119}],8119:[[8118,837]],8120:[[913,774]],8121:[[913,772]],8122:[[913,768]],8123:[[902]],8124:[[913,837]],8125:[[32,787],256],8126:[[953]],8127:[[32,787],256,{768:8141,769:8142,834:8143}],8128:[[32,834],256],8129:[[168,834]],8130:[[8052,837]],8131:[[951,837]],8132:[[942,837]],8134:[[951,834],,{837:8135}],8135:[[8134,837]],8136:[[917,768]],8137:[[904]],8138:[[919,768]],8139:[[905]],8140:[[919,837]],8141:[[8127,768]],8142:[[8127,769]],8143:[[8127,834]],8144:[[953,774]],8145:[[953,772]],8146:[[970,768]],8147:[[912]],8150:[[953,834]],8151:[[970,834]],8152:[[921,774]],8153:[[921,772]],8154:[[921,768]],8155:[[906]],8157:[[8190,768]],8158:[[8190,769]],8159:[[8190,834]],8160:[[965,774]],8161:[[965,772]],8162:[[971,768]],8163:[[944]],8164:[[961,787]],8165:[[961,788]],8166:[[965,834]],8167:[[971,834]],8168:[[933,774]],8169:[[933,772]],8170:[[933,768]],8171:[[910]],8172:[[929,788]],8173:[[168,768]],8174:[[901]],8175:[[96]],8178:[[8060,837]],8179:[[969,837]],8180:[[974,837]],8182:[[969,834],,{837:8183}],8183:[[8182,837]],8184:[[927,768]],8185:[[908]],8186:[[937,768]],8187:[[911]],8188:[[937,837]],8189:[[180]],8190:[[32,788],256,{768:8157,769:8158,834:8159}]}, + 8192:{8192:[[8194]],8193:[[8195]],8194:[[32],256],8195:[[32],256],8196:[[32],256],8197:[[32],256],8198:[[32],256],8199:[[32],256],8200:[[32],256],8201:[[32],256],8202:[[32],256],8209:[[8208],256],8215:[[32,819],256],8228:[[46],256],8229:[[46,46],256],8230:[[46,46,46],256],8239:[[32],256],8243:[[8242,8242],256],8244:[[8242,8242,8242],256],8246:[[8245,8245],256],8247:[[8245,8245,8245],256],8252:[[33,33],256],8254:[[32,773],256],8263:[[63,63],256],8264:[[63,33],256],8265:[[33,63],256],8279:[[8242,8242,8242,8242],256],8287:[[32],256],8304:[[48],256],8305:[[105],256],8308:[[52],256],8309:[[53],256],8310:[[54],256],8311:[[55],256],8312:[[56],256],8313:[[57],256],8314:[[43],256],8315:[[8722],256],8316:[[61],256],8317:[[40],256],8318:[[41],256],8319:[[110],256],8320:[[48],256],8321:[[49],256],8322:[[50],256],8323:[[51],256],8324:[[52],256],8325:[[53],256],8326:[[54],256],8327:[[55],256],8328:[[56],256],8329:[[57],256],8330:[[43],256],8331:[[8722],256],8332:[[61],256],8333:[[40],256],8334:[[41],256],8336:[[97],256],8337:[[101],256],8338:[[111],256],8339:[[120],256],8340:[[601],256],8341:[[104],256],8342:[[107],256],8343:[[108],256],8344:[[109],256],8345:[[110],256],8346:[[112],256],8347:[[115],256],8348:[[116],256],8360:[[82,115],256],8400:[,230],8401:[,230],8402:[,1],8403:[,1],8404:[,230],8405:[,230],8406:[,230],8407:[,230],8408:[,1],8409:[,1],8410:[,1],8411:[,230],8412:[,230],8417:[,230],8421:[,1],8422:[,1],8423:[,230],8424:[,220],8425:[,230],8426:[,1],8427:[,1],8428:[,220],8429:[,220],8430:[,220],8431:[,220],8432:[,230]}, + 8448:{8448:[[97,47,99],256],8449:[[97,47,115],256],8450:[[67],256],8451:[[176,67],256],8453:[[99,47,111],256],8454:[[99,47,117],256],8455:[[400],256],8457:[[176,70],256],8458:[[103],256],8459:[[72],256],8460:[[72],256],8461:[[72],256],8462:[[104],256],8463:[[295],256],8464:[[73],256],8465:[[73],256],8466:[[76],256],8467:[[108],256],8469:[[78],256],8470:[[78,111],256],8473:[[80],256],8474:[[81],256],8475:[[82],256],8476:[[82],256],8477:[[82],256],8480:[[83,77],256],8481:[[84,69,76],256],8482:[[84,77],256],8484:[[90],256],8486:[[937]],8488:[[90],256],8490:[[75]],8491:[[197]],8492:[[66],256],8493:[[67],256],8495:[[101],256],8496:[[69],256],8497:[[70],256],8499:[[77],256],8500:[[111],256],8501:[[1488],256],8502:[[1489],256],8503:[[1490],256],8504:[[1491],256],8505:[[105],256],8507:[[70,65,88],256],8508:[[960],256],8509:[[947],256],8510:[[915],256],8511:[[928],256],8512:[[8721],256],8517:[[68],256],8518:[[100],256],8519:[[101],256],8520:[[105],256],8521:[[106],256],8528:[[49,8260,55],256],8529:[[49,8260,57],256],8530:[[49,8260,49,48],256],8531:[[49,8260,51],256],8532:[[50,8260,51],256],8533:[[49,8260,53],256],8534:[[50,8260,53],256],8535:[[51,8260,53],256],8536:[[52,8260,53],256],8537:[[49,8260,54],256],8538:[[53,8260,54],256],8539:[[49,8260,56],256],8540:[[51,8260,56],256],8541:[[53,8260,56],256],8542:[[55,8260,56],256],8543:[[49,8260],256],8544:[[73],256],8545:[[73,73],256],8546:[[73,73,73],256],8547:[[73,86],256],8548:[[86],256],8549:[[86,73],256],8550:[[86,73,73],256],8551:[[86,73,73,73],256],8552:[[73,88],256],8553:[[88],256],8554:[[88,73],256],8555:[[88,73,73],256],8556:[[76],256],8557:[[67],256],8558:[[68],256],8559:[[77],256],8560:[[105],256],8561:[[105,105],256],8562:[[105,105,105],256],8563:[[105,118],256],8564:[[118],256],8565:[[118,105],256],8566:[[118,105,105],256],8567:[[118,105,105,105],256],8568:[[105,120],256],8569:[[120],256],8570:[[120,105],256],8571:[[120,105,105],256],8572:[[108],256],8573:[[99],256],8574:[[100],256],8575:[[109],256],8585:[[48,8260,51],256],8592:[,,{824:8602}],8594:[,,{824:8603}],8596:[,,{824:8622}],8602:[[8592,824]],8603:[[8594,824]],8622:[[8596,824]],8653:[[8656,824]],8654:[[8660,824]],8655:[[8658,824]],8656:[,,{824:8653}],8658:[,,{824:8655}],8660:[,,{824:8654}]}, + 8704:{8707:[,,{824:8708}],8708:[[8707,824]],8712:[,,{824:8713}],8713:[[8712,824]],8715:[,,{824:8716}],8716:[[8715,824]],8739:[,,{824:8740}],8740:[[8739,824]],8741:[,,{824:8742}],8742:[[8741,824]],8748:[[8747,8747],256],8749:[[8747,8747,8747],256],8751:[[8750,8750],256],8752:[[8750,8750,8750],256],8764:[,,{824:8769}],8769:[[8764,824]],8771:[,,{824:8772}],8772:[[8771,824]],8773:[,,{824:8775}],8775:[[8773,824]],8776:[,,{824:8777}],8777:[[8776,824]],8781:[,,{824:8813}],8800:[[61,824]],8801:[,,{824:8802}],8802:[[8801,824]],8804:[,,{824:8816}],8805:[,,{824:8817}],8813:[[8781,824]],8814:[[60,824]],8815:[[62,824]],8816:[[8804,824]],8817:[[8805,824]],8818:[,,{824:8820}],8819:[,,{824:8821}],8820:[[8818,824]],8821:[[8819,824]],8822:[,,{824:8824}],8823:[,,{824:8825}],8824:[[8822,824]],8825:[[8823,824]],8826:[,,{824:8832}],8827:[,,{824:8833}],8828:[,,{824:8928}],8829:[,,{824:8929}],8832:[[8826,824]],8833:[[8827,824]],8834:[,,{824:8836}],8835:[,,{824:8837}],8836:[[8834,824]],8837:[[8835,824]],8838:[,,{824:8840}],8839:[,,{824:8841}],8840:[[8838,824]],8841:[[8839,824]],8849:[,,{824:8930}],8850:[,,{824:8931}],8866:[,,{824:8876}],8872:[,,{824:8877}],8873:[,,{824:8878}],8875:[,,{824:8879}],8876:[[8866,824]],8877:[[8872,824]],8878:[[8873,824]],8879:[[8875,824]],8882:[,,{824:8938}],8883:[,,{824:8939}],8884:[,,{824:8940}],8885:[,,{824:8941}],8928:[[8828,824]],8929:[[8829,824]],8930:[[8849,824]],8931:[[8850,824]],8938:[[8882,824]],8939:[[8883,824]],8940:[[8884,824]],8941:[[8885,824]]}, + 8960:{9001:[[12296]],9002:[[12297]]}, + 9216:{9312:[[49],256],9313:[[50],256],9314:[[51],256],9315:[[52],256],9316:[[53],256],9317:[[54],256],9318:[[55],256],9319:[[56],256],9320:[[57],256],9321:[[49,48],256],9322:[[49,49],256],9323:[[49,50],256],9324:[[49,51],256],9325:[[49,52],256],9326:[[49,53],256],9327:[[49,54],256],9328:[[49,55],256],9329:[[49,56],256],9330:[[49,57],256],9331:[[50,48],256],9332:[[40,49,41],256],9333:[[40,50,41],256],9334:[[40,51,41],256],9335:[[40,52,41],256],9336:[[40,53,41],256],9337:[[40,54,41],256],9338:[[40,55,41],256],9339:[[40,56,41],256],9340:[[40,57,41],256],9341:[[40,49,48,41],256],9342:[[40,49,49,41],256],9343:[[40,49,50,41],256],9344:[[40,49,51,41],256],9345:[[40,49,52,41],256],9346:[[40,49,53,41],256],9347:[[40,49,54,41],256],9348:[[40,49,55,41],256],9349:[[40,49,56,41],256],9350:[[40,49,57,41],256],9351:[[40,50,48,41],256],9352:[[49,46],256],9353:[[50,46],256],9354:[[51,46],256],9355:[[52,46],256],9356:[[53,46],256],9357:[[54,46],256],9358:[[55,46],256],9359:[[56,46],256],9360:[[57,46],256],9361:[[49,48,46],256],9362:[[49,49,46],256],9363:[[49,50,46],256],9364:[[49,51,46],256],9365:[[49,52,46],256],9366:[[49,53,46],256],9367:[[49,54,46],256],9368:[[49,55,46],256],9369:[[49,56,46],256],9370:[[49,57,46],256],9371:[[50,48,46],256],9372:[[40,97,41],256],9373:[[40,98,41],256],9374:[[40,99,41],256],9375:[[40,100,41],256],9376:[[40,101,41],256],9377:[[40,102,41],256],9378:[[40,103,41],256],9379:[[40,104,41],256],9380:[[40,105,41],256],9381:[[40,106,41],256],9382:[[40,107,41],256],9383:[[40,108,41],256],9384:[[40,109,41],256],9385:[[40,110,41],256],9386:[[40,111,41],256],9387:[[40,112,41],256],9388:[[40,113,41],256],9389:[[40,114,41],256],9390:[[40,115,41],256],9391:[[40,116,41],256],9392:[[40,117,41],256],9393:[[40,118,41],256],9394:[[40,119,41],256],9395:[[40,120,41],256],9396:[[40,121,41],256],9397:[[40,122,41],256],9398:[[65],256],9399:[[66],256],9400:[[67],256],9401:[[68],256],9402:[[69],256],9403:[[70],256],9404:[[71],256],9405:[[72],256],9406:[[73],256],9407:[[74],256],9408:[[75],256],9409:[[76],256],9410:[[77],256],9411:[[78],256],9412:[[79],256],9413:[[80],256],9414:[[81],256],9415:[[82],256],9416:[[83],256],9417:[[84],256],9418:[[85],256],9419:[[86],256],9420:[[87],256],9421:[[88],256],9422:[[89],256],9423:[[90],256],9424:[[97],256],9425:[[98],256],9426:[[99],256],9427:[[100],256],9428:[[101],256],9429:[[102],256],9430:[[103],256],9431:[[104],256],9432:[[105],256],9433:[[106],256],9434:[[107],256],9435:[[108],256],9436:[[109],256],9437:[[110],256],9438:[[111],256],9439:[[112],256],9440:[[113],256],9441:[[114],256],9442:[[115],256],9443:[[116],256],9444:[[117],256],9445:[[118],256],9446:[[119],256],9447:[[120],256],9448:[[121],256],9449:[[122],256],9450:[[48],256]}, + 10752:{10764:[[8747,8747,8747,8747],256],10868:[[58,58,61],256],10869:[[61,61],256],10870:[[61,61,61],256],10972:[[10973,824],512]}, + 11264:{11388:[[106],256],11389:[[86],256],11503:[,230],11504:[,230],11505:[,230]}, + 11520:{11631:[[11617],256],11647:[,9],11744:[,230],11745:[,230],11746:[,230],11747:[,230],11748:[,230],11749:[,230],11750:[,230],11751:[,230],11752:[,230],11753:[,230],11754:[,230],11755:[,230],11756:[,230],11757:[,230],11758:[,230],11759:[,230],11760:[,230],11761:[,230],11762:[,230],11763:[,230],11764:[,230],11765:[,230],11766:[,230],11767:[,230],11768:[,230],11769:[,230],11770:[,230],11771:[,230],11772:[,230],11773:[,230],11774:[,230],11775:[,230]}, + 11776:{11935:[[27597],256],12019:[[40863],256]}, + 12032:{12032:[[19968],256],12033:[[20008],256],12034:[[20022],256],12035:[[20031],256],12036:[[20057],256],12037:[[20101],256],12038:[[20108],256],12039:[[20128],256],12040:[[20154],256],12041:[[20799],256],12042:[[20837],256],12043:[[20843],256],12044:[[20866],256],12045:[[20886],256],12046:[[20907],256],12047:[[20960],256],12048:[[20981],256],12049:[[20992],256],12050:[[21147],256],12051:[[21241],256],12052:[[21269],256],12053:[[21274],256],12054:[[21304],256],12055:[[21313],256],12056:[[21340],256],12057:[[21353],256],12058:[[21378],256],12059:[[21430],256],12060:[[21448],256],12061:[[21475],256],12062:[[22231],256],12063:[[22303],256],12064:[[22763],256],12065:[[22786],256],12066:[[22794],256],12067:[[22805],256],12068:[[22823],256],12069:[[22899],256],12070:[[23376],256],12071:[[23424],256],12072:[[23544],256],12073:[[23567],256],12074:[[23586],256],12075:[[23608],256],12076:[[23662],256],12077:[[23665],256],12078:[[24027],256],12079:[[24037],256],12080:[[24049],256],12081:[[24062],256],12082:[[24178],256],12083:[[24186],256],12084:[[24191],256],12085:[[24308],256],12086:[[24318],256],12087:[[24331],256],12088:[[24339],256],12089:[[24400],256],12090:[[24417],256],12091:[[24435],256],12092:[[24515],256],12093:[[25096],256],12094:[[25142],256],12095:[[25163],256],12096:[[25903],256],12097:[[25908],256],12098:[[25991],256],12099:[[26007],256],12100:[[26020],256],12101:[[26041],256],12102:[[26080],256],12103:[[26085],256],12104:[[26352],256],12105:[[26376],256],12106:[[26408],256],12107:[[27424],256],12108:[[27490],256],12109:[[27513],256],12110:[[27571],256],12111:[[27595],256],12112:[[27604],256],12113:[[27611],256],12114:[[27663],256],12115:[[27668],256],12116:[[27700],256],12117:[[28779],256],12118:[[29226],256],12119:[[29238],256],12120:[[29243],256],12121:[[29247],256],12122:[[29255],256],12123:[[29273],256],12124:[[29275],256],12125:[[29356],256],12126:[[29572],256],12127:[[29577],256],12128:[[29916],256],12129:[[29926],256],12130:[[29976],256],12131:[[29983],256],12132:[[29992],256],12133:[[30000],256],12134:[[30091],256],12135:[[30098],256],12136:[[30326],256],12137:[[30333],256],12138:[[30382],256],12139:[[30399],256],12140:[[30446],256],12141:[[30683],256],12142:[[30690],256],12143:[[30707],256],12144:[[31034],256],12145:[[31160],256],12146:[[31166],256],12147:[[31348],256],12148:[[31435],256],12149:[[31481],256],12150:[[31859],256],12151:[[31992],256],12152:[[32566],256],12153:[[32593],256],12154:[[32650],256],12155:[[32701],256],12156:[[32769],256],12157:[[32780],256],12158:[[32786],256],12159:[[32819],256],12160:[[32895],256],12161:[[32905],256],12162:[[33251],256],12163:[[33258],256],12164:[[33267],256],12165:[[33276],256],12166:[[33292],256],12167:[[33307],256],12168:[[33311],256],12169:[[33390],256],12170:[[33394],256],12171:[[33400],256],12172:[[34381],256],12173:[[34411],256],12174:[[34880],256],12175:[[34892],256],12176:[[34915],256],12177:[[35198],256],12178:[[35211],256],12179:[[35282],256],12180:[[35328],256],12181:[[35895],256],12182:[[35910],256],12183:[[35925],256],12184:[[35960],256],12185:[[35997],256],12186:[[36196],256],12187:[[36208],256],12188:[[36275],256],12189:[[36523],256],12190:[[36554],256],12191:[[36763],256],12192:[[36784],256],12193:[[36789],256],12194:[[37009],256],12195:[[37193],256],12196:[[37318],256],12197:[[37324],256],12198:[[37329],256],12199:[[38263],256],12200:[[38272],256],12201:[[38428],256],12202:[[38582],256],12203:[[38585],256],12204:[[38632],256],12205:[[38737],256],12206:[[38750],256],12207:[[38754],256],12208:[[38761],256],12209:[[38859],256],12210:[[38893],256],12211:[[38899],256],12212:[[38913],256],12213:[[39080],256],12214:[[39131],256],12215:[[39135],256],12216:[[39318],256],12217:[[39321],256],12218:[[39340],256],12219:[[39592],256],12220:[[39640],256],12221:[[39647],256],12222:[[39717],256],12223:[[39727],256],12224:[[39730],256],12225:[[39740],256],12226:[[39770],256],12227:[[40165],256],12228:[[40565],256],12229:[[40575],256],12230:[[40613],256],12231:[[40635],256],12232:[[40643],256],12233:[[40653],256],12234:[[40657],256],12235:[[40697],256],12236:[[40701],256],12237:[[40718],256],12238:[[40723],256],12239:[[40736],256],12240:[[40763],256],12241:[[40778],256],12242:[[40786],256],12243:[[40845],256],12244:[[40860],256],12245:[[40864],256]}, + 12288:{12288:[[32],256],12330:[,218],12331:[,228],12332:[,232],12333:[,222],12334:[,224],12335:[,224],12342:[[12306],256],12344:[[21313],256],12345:[[21316],256],12346:[[21317],256],12358:[,,{12441:12436}],12363:[,,{12441:12364}],12364:[[12363,12441]],12365:[,,{12441:12366}],12366:[[12365,12441]],12367:[,,{12441:12368}],12368:[[12367,12441]],12369:[,,{12441:12370}],12370:[[12369,12441]],12371:[,,{12441:12372}],12372:[[12371,12441]],12373:[,,{12441:12374}],12374:[[12373,12441]],12375:[,,{12441:12376}],12376:[[12375,12441]],12377:[,,{12441:12378}],12378:[[12377,12441]],12379:[,,{12441:12380}],12380:[[12379,12441]],12381:[,,{12441:12382}],12382:[[12381,12441]],12383:[,,{12441:12384}],12384:[[12383,12441]],12385:[,,{12441:12386}],12386:[[12385,12441]],12388:[,,{12441:12389}],12389:[[12388,12441]],12390:[,,{12441:12391}],12391:[[12390,12441]],12392:[,,{12441:12393}],12393:[[12392,12441]],12399:[,,{12441:12400,12442:12401}],12400:[[12399,12441]],12401:[[12399,12442]],12402:[,,{12441:12403,12442:12404}],12403:[[12402,12441]],12404:[[12402,12442]],12405:[,,{12441:12406,12442:12407}],12406:[[12405,12441]],12407:[[12405,12442]],12408:[,,{12441:12409,12442:12410}],12409:[[12408,12441]],12410:[[12408,12442]],12411:[,,{12441:12412,12442:12413}],12412:[[12411,12441]],12413:[[12411,12442]],12436:[[12358,12441]],12441:[,8],12442:[,8],12443:[[32,12441],256],12444:[[32,12442],256],12445:[,,{12441:12446}],12446:[[12445,12441]],12447:[[12424,12426],256],12454:[,,{12441:12532}],12459:[,,{12441:12460}],12460:[[12459,12441]],12461:[,,{12441:12462}],12462:[[12461,12441]],12463:[,,{12441:12464}],12464:[[12463,12441]],12465:[,,{12441:12466}],12466:[[12465,12441]],12467:[,,{12441:12468}],12468:[[12467,12441]],12469:[,,{12441:12470}],12470:[[12469,12441]],12471:[,,{12441:12472}],12472:[[12471,12441]],12473:[,,{12441:12474}],12474:[[12473,12441]],12475:[,,{12441:12476}],12476:[[12475,12441]],12477:[,,{12441:12478}],12478:[[12477,12441]],12479:[,,{12441:12480}],12480:[[12479,12441]],12481:[,,{12441:12482}],12482:[[12481,12441]],12484:[,,{12441:12485}],12485:[[12484,12441]],12486:[,,{12441:12487}],12487:[[12486,12441]],12488:[,,{12441:12489}],12489:[[12488,12441]],12495:[,,{12441:12496,12442:12497}],12496:[[12495,12441]],12497:[[12495,12442]],12498:[,,{12441:12499,12442:12500}],12499:[[12498,12441]],12500:[[12498,12442]],12501:[,,{12441:12502,12442:12503}],12502:[[12501,12441]],12503:[[12501,12442]],12504:[,,{12441:12505,12442:12506}],12505:[[12504,12441]],12506:[[12504,12442]],12507:[,,{12441:12508,12442:12509}],12508:[[12507,12441]],12509:[[12507,12442]],12527:[,,{12441:12535}],12528:[,,{12441:12536}],12529:[,,{12441:12537}],12530:[,,{12441:12538}],12532:[[12454,12441]],12535:[[12527,12441]],12536:[[12528,12441]],12537:[[12529,12441]],12538:[[12530,12441]],12541:[,,{12441:12542}],12542:[[12541,12441]],12543:[[12467,12488],256]}, + 12544:{12593:[[4352],256],12594:[[4353],256],12595:[[4522],256],12596:[[4354],256],12597:[[4524],256],12598:[[4525],256],12599:[[4355],256],12600:[[4356],256],12601:[[4357],256],12602:[[4528],256],12603:[[4529],256],12604:[[4530],256],12605:[[4531],256],12606:[[4532],256],12607:[[4533],256],12608:[[4378],256],12609:[[4358],256],12610:[[4359],256],12611:[[4360],256],12612:[[4385],256],12613:[[4361],256],12614:[[4362],256],12615:[[4363],256],12616:[[4364],256],12617:[[4365],256],12618:[[4366],256],12619:[[4367],256],12620:[[4368],256],12621:[[4369],256],12622:[[4370],256],12623:[[4449],256],12624:[[4450],256],12625:[[4451],256],12626:[[4452],256],12627:[[4453],256],12628:[[4454],256],12629:[[4455],256],12630:[[4456],256],12631:[[4457],256],12632:[[4458],256],12633:[[4459],256],12634:[[4460],256],12635:[[4461],256],12636:[[4462],256],12637:[[4463],256],12638:[[4464],256],12639:[[4465],256],12640:[[4466],256],12641:[[4467],256],12642:[[4468],256],12643:[[4469],256],12644:[[4448],256],12645:[[4372],256],12646:[[4373],256],12647:[[4551],256],12648:[[4552],256],12649:[[4556],256],12650:[[4558],256],12651:[[4563],256],12652:[[4567],256],12653:[[4569],256],12654:[[4380],256],12655:[[4573],256],12656:[[4575],256],12657:[[4381],256],12658:[[4382],256],12659:[[4384],256],12660:[[4386],256],12661:[[4387],256],12662:[[4391],256],12663:[[4393],256],12664:[[4395],256],12665:[[4396],256],12666:[[4397],256],12667:[[4398],256],12668:[[4399],256],12669:[[4402],256],12670:[[4406],256],12671:[[4416],256],12672:[[4423],256],12673:[[4428],256],12674:[[4593],256],12675:[[4594],256],12676:[[4439],256],12677:[[4440],256],12678:[[4441],256],12679:[[4484],256],12680:[[4485],256],12681:[[4488],256],12682:[[4497],256],12683:[[4498],256],12684:[[4500],256],12685:[[4510],256],12686:[[4513],256],12690:[[19968],256],12691:[[20108],256],12692:[[19977],256],12693:[[22235],256],12694:[[19978],256],12695:[[20013],256],12696:[[19979],256],12697:[[30002],256],12698:[[20057],256],12699:[[19993],256],12700:[[19969],256],12701:[[22825],256],12702:[[22320],256],12703:[[20154],256]}, + 12800:{12800:[[40,4352,41],256],12801:[[40,4354,41],256],12802:[[40,4355,41],256],12803:[[40,4357,41],256],12804:[[40,4358,41],256],12805:[[40,4359,41],256],12806:[[40,4361,41],256],12807:[[40,4363,41],256],12808:[[40,4364,41],256],12809:[[40,4366,41],256],12810:[[40,4367,41],256],12811:[[40,4368,41],256],12812:[[40,4369,41],256],12813:[[40,4370,41],256],12814:[[40,4352,4449,41],256],12815:[[40,4354,4449,41],256],12816:[[40,4355,4449,41],256],12817:[[40,4357,4449,41],256],12818:[[40,4358,4449,41],256],12819:[[40,4359,4449,41],256],12820:[[40,4361,4449,41],256],12821:[[40,4363,4449,41],256],12822:[[40,4364,4449,41],256],12823:[[40,4366,4449,41],256],12824:[[40,4367,4449,41],256],12825:[[40,4368,4449,41],256],12826:[[40,4369,4449,41],256],12827:[[40,4370,4449,41],256],12828:[[40,4364,4462,41],256],12829:[[40,4363,4457,4364,4453,4523,41],256],12830:[[40,4363,4457,4370,4462,41],256],12832:[[40,19968,41],256],12833:[[40,20108,41],256],12834:[[40,19977,41],256],12835:[[40,22235,41],256],12836:[[40,20116,41],256],12837:[[40,20845,41],256],12838:[[40,19971,41],256],12839:[[40,20843,41],256],12840:[[40,20061,41],256],12841:[[40,21313,41],256],12842:[[40,26376,41],256],12843:[[40,28779,41],256],12844:[[40,27700,41],256],12845:[[40,26408,41],256],12846:[[40,37329,41],256],12847:[[40,22303,41],256],12848:[[40,26085,41],256],12849:[[40,26666,41],256],12850:[[40,26377,41],256],12851:[[40,31038,41],256],12852:[[40,21517,41],256],12853:[[40,29305,41],256],12854:[[40,36001,41],256],12855:[[40,31069,41],256],12856:[[40,21172,41],256],12857:[[40,20195,41],256],12858:[[40,21628,41],256],12859:[[40,23398,41],256],12860:[[40,30435,41],256],12861:[[40,20225,41],256],12862:[[40,36039,41],256],12863:[[40,21332,41],256],12864:[[40,31085,41],256],12865:[[40,20241,41],256],12866:[[40,33258,41],256],12867:[[40,33267,41],256],12868:[[21839],256],12869:[[24188],256],12870:[[25991],256],12871:[[31631],256],12880:[[80,84,69],256],12881:[[50,49],256],12882:[[50,50],256],12883:[[50,51],256],12884:[[50,52],256],12885:[[50,53],256],12886:[[50,54],256],12887:[[50,55],256],12888:[[50,56],256],12889:[[50,57],256],12890:[[51,48],256],12891:[[51,49],256],12892:[[51,50],256],12893:[[51,51],256],12894:[[51,52],256],12895:[[51,53],256],12896:[[4352],256],12897:[[4354],256],12898:[[4355],256],12899:[[4357],256],12900:[[4358],256],12901:[[4359],256],12902:[[4361],256],12903:[[4363],256],12904:[[4364],256],12905:[[4366],256],12906:[[4367],256],12907:[[4368],256],12908:[[4369],256],12909:[[4370],256],12910:[[4352,4449],256],12911:[[4354,4449],256],12912:[[4355,4449],256],12913:[[4357,4449],256],12914:[[4358,4449],256],12915:[[4359,4449],256],12916:[[4361,4449],256],12917:[[4363,4449],256],12918:[[4364,4449],256],12919:[[4366,4449],256],12920:[[4367,4449],256],12921:[[4368,4449],256],12922:[[4369,4449],256],12923:[[4370,4449],256],12924:[[4366,4449,4535,4352,4457],256],12925:[[4364,4462,4363,4468],256],12926:[[4363,4462],256],12928:[[19968],256],12929:[[20108],256],12930:[[19977],256],12931:[[22235],256],12932:[[20116],256],12933:[[20845],256],12934:[[19971],256],12935:[[20843],256],12936:[[20061],256],12937:[[21313],256],12938:[[26376],256],12939:[[28779],256],12940:[[27700],256],12941:[[26408],256],12942:[[37329],256],12943:[[22303],256],12944:[[26085],256],12945:[[26666],256],12946:[[26377],256],12947:[[31038],256],12948:[[21517],256],12949:[[29305],256],12950:[[36001],256],12951:[[31069],256],12952:[[21172],256],12953:[[31192],256],12954:[[30007],256],12955:[[22899],256],12956:[[36969],256],12957:[[20778],256],12958:[[21360],256],12959:[[27880],256],12960:[[38917],256],12961:[[20241],256],12962:[[20889],256],12963:[[27491],256],12964:[[19978],256],12965:[[20013],256],12966:[[19979],256],12967:[[24038],256],12968:[[21491],256],12969:[[21307],256],12970:[[23447],256],12971:[[23398],256],12972:[[30435],256],12973:[[20225],256],12974:[[36039],256],12975:[[21332],256],12976:[[22812],256],12977:[[51,54],256],12978:[[51,55],256],12979:[[51,56],256],12980:[[51,57],256],12981:[[52,48],256],12982:[[52,49],256],12983:[[52,50],256],12984:[[52,51],256],12985:[[52,52],256],12986:[[52,53],256],12987:[[52,54],256],12988:[[52,55],256],12989:[[52,56],256],12990:[[52,57],256],12991:[[53,48],256],12992:[[49,26376],256],12993:[[50,26376],256],12994:[[51,26376],256],12995:[[52,26376],256],12996:[[53,26376],256],12997:[[54,26376],256],12998:[[55,26376],256],12999:[[56,26376],256],13000:[[57,26376],256],13001:[[49,48,26376],256],13002:[[49,49,26376],256],13003:[[49,50,26376],256],13004:[[72,103],256],13005:[[101,114,103],256],13006:[[101,86],256],13007:[[76,84,68],256],13008:[[12450],256],13009:[[12452],256],13010:[[12454],256],13011:[[12456],256],13012:[[12458],256],13013:[[12459],256],13014:[[12461],256],13015:[[12463],256],13016:[[12465],256],13017:[[12467],256],13018:[[12469],256],13019:[[12471],256],13020:[[12473],256],13021:[[12475],256],13022:[[12477],256],13023:[[12479],256],13024:[[12481],256],13025:[[12484],256],13026:[[12486],256],13027:[[12488],256],13028:[[12490],256],13029:[[12491],256],13030:[[12492],256],13031:[[12493],256],13032:[[12494],256],13033:[[12495],256],13034:[[12498],256],13035:[[12501],256],13036:[[12504],256],13037:[[12507],256],13038:[[12510],256],13039:[[12511],256],13040:[[12512],256],13041:[[12513],256],13042:[[12514],256],13043:[[12516],256],13044:[[12518],256],13045:[[12520],256],13046:[[12521],256],13047:[[12522],256],13048:[[12523],256],13049:[[12524],256],13050:[[12525],256],13051:[[12527],256],13052:[[12528],256],13053:[[12529],256],13054:[[12530],256]}, + 13056:{13056:[[12450,12497,12540,12488],256],13057:[[12450,12523,12501,12449],256],13058:[[12450,12531,12506,12450],256],13059:[[12450,12540,12523],256],13060:[[12452,12491,12531,12464],256],13061:[[12452,12531,12481],256],13062:[[12454,12457,12531],256],13063:[[12456,12473,12463,12540,12489],256],13064:[[12456,12540,12459,12540],256],13065:[[12458,12531,12473],256],13066:[[12458,12540,12512],256],13067:[[12459,12452,12522],256],13068:[[12459,12521,12483,12488],256],13069:[[12459,12525,12522,12540],256],13070:[[12460,12525,12531],256],13071:[[12460,12531,12510],256],13072:[[12462,12460],256],13073:[[12462,12491,12540],256],13074:[[12461,12517,12522,12540],256],13075:[[12462,12523,12480,12540],256],13076:[[12461,12525],256],13077:[[12461,12525,12464,12521,12512],256],13078:[[12461,12525,12513,12540,12488,12523],256],13079:[[12461,12525,12527,12483,12488],256],13080:[[12464,12521,12512],256],13081:[[12464,12521,12512,12488,12531],256],13082:[[12463,12523,12476,12452,12525],256],13083:[[12463,12525,12540,12493],256],13084:[[12465,12540,12473],256],13085:[[12467,12523,12490],256],13086:[[12467,12540,12509],256],13087:[[12469,12452,12463,12523],256],13088:[[12469,12531,12481,12540,12512],256],13089:[[12471,12522,12531,12464],256],13090:[[12475,12531,12481],256],13091:[[12475,12531,12488],256],13092:[[12480,12540,12473],256],13093:[[12487,12471],256],13094:[[12489,12523],256],13095:[[12488,12531],256],13096:[[12490,12494],256],13097:[[12494,12483,12488],256],13098:[[12495,12452,12484],256],13099:[[12497,12540,12475,12531,12488],256],13100:[[12497,12540,12484],256],13101:[[12496,12540,12524,12523],256],13102:[[12500,12450,12473,12488,12523],256],13103:[[12500,12463,12523],256],13104:[[12500,12467],256],13105:[[12499,12523],256],13106:[[12501,12449,12521,12483,12489],256],13107:[[12501,12451,12540,12488],256],13108:[[12502,12483,12471,12455,12523],256],13109:[[12501,12521,12531],256],13110:[[12504,12463,12479,12540,12523],256],13111:[[12506,12477],256],13112:[[12506,12491,12498],256],13113:[[12504,12523,12484],256],13114:[[12506,12531,12473],256],13115:[[12506,12540,12472],256],13116:[[12505,12540,12479],256],13117:[[12509,12452,12531,12488],256],13118:[[12508,12523,12488],256],13119:[[12507,12531],256],13120:[[12509,12531,12489],256],13121:[[12507,12540,12523],256],13122:[[12507,12540,12531],256],13123:[[12510,12452,12463,12525],256],13124:[[12510,12452,12523],256],13125:[[12510,12483,12495],256],13126:[[12510,12523,12463],256],13127:[[12510,12531,12471,12519,12531],256],13128:[[12511,12463,12525,12531],256],13129:[[12511,12522],256],13130:[[12511,12522,12496,12540,12523],256],13131:[[12513,12460],256],13132:[[12513,12460,12488,12531],256],13133:[[12513,12540,12488,12523],256],13134:[[12516,12540,12489],256],13135:[[12516,12540,12523],256],13136:[[12518,12450,12531],256],13137:[[12522,12483,12488,12523],256],13138:[[12522,12521],256],13139:[[12523,12500,12540],256],13140:[[12523,12540,12502,12523],256],13141:[[12524,12512],256],13142:[[12524,12531,12488,12466,12531],256],13143:[[12527,12483,12488],256],13144:[[48,28857],256],13145:[[49,28857],256],13146:[[50,28857],256],13147:[[51,28857],256],13148:[[52,28857],256],13149:[[53,28857],256],13150:[[54,28857],256],13151:[[55,28857],256],13152:[[56,28857],256],13153:[[57,28857],256],13154:[[49,48,28857],256],13155:[[49,49,28857],256],13156:[[49,50,28857],256],13157:[[49,51,28857],256],13158:[[49,52,28857],256],13159:[[49,53,28857],256],13160:[[49,54,28857],256],13161:[[49,55,28857],256],13162:[[49,56,28857],256],13163:[[49,57,28857],256],13164:[[50,48,28857],256],13165:[[50,49,28857],256],13166:[[50,50,28857],256],13167:[[50,51,28857],256],13168:[[50,52,28857],256],13169:[[104,80,97],256],13170:[[100,97],256],13171:[[65,85],256],13172:[[98,97,114],256],13173:[[111,86],256],13174:[[112,99],256],13175:[[100,109],256],13176:[[100,109,178],256],13177:[[100,109,179],256],13178:[[73,85],256],13179:[[24179,25104],256],13180:[[26157,21644],256],13181:[[22823,27491],256],13182:[[26126,27835],256],13183:[[26666,24335,20250,31038],256],13184:[[112,65],256],13185:[[110,65],256],13186:[[956,65],256],13187:[[109,65],256],13188:[[107,65],256],13189:[[75,66],256],13190:[[77,66],256],13191:[[71,66],256],13192:[[99,97,108],256],13193:[[107,99,97,108],256],13194:[[112,70],256],13195:[[110,70],256],13196:[[956,70],256],13197:[[956,103],256],13198:[[109,103],256],13199:[[107,103],256],13200:[[72,122],256],13201:[[107,72,122],256],13202:[[77,72,122],256],13203:[[71,72,122],256],13204:[[84,72,122],256],13205:[[956,8467],256],13206:[[109,8467],256],13207:[[100,8467],256],13208:[[107,8467],256],13209:[[102,109],256],13210:[[110,109],256],13211:[[956,109],256],13212:[[109,109],256],13213:[[99,109],256],13214:[[107,109],256],13215:[[109,109,178],256],13216:[[99,109,178],256],13217:[[109,178],256],13218:[[107,109,178],256],13219:[[109,109,179],256],13220:[[99,109,179],256],13221:[[109,179],256],13222:[[107,109,179],256],13223:[[109,8725,115],256],13224:[[109,8725,115,178],256],13225:[[80,97],256],13226:[[107,80,97],256],13227:[[77,80,97],256],13228:[[71,80,97],256],13229:[[114,97,100],256],13230:[[114,97,100,8725,115],256],13231:[[114,97,100,8725,115,178],256],13232:[[112,115],256],13233:[[110,115],256],13234:[[956,115],256],13235:[[109,115],256],13236:[[112,86],256],13237:[[110,86],256],13238:[[956,86],256],13239:[[109,86],256],13240:[[107,86],256],13241:[[77,86],256],13242:[[112,87],256],13243:[[110,87],256],13244:[[956,87],256],13245:[[109,87],256],13246:[[107,87],256],13247:[[77,87],256],13248:[[107,937],256],13249:[[77,937],256],13250:[[97,46,109,46],256],13251:[[66,113],256],13252:[[99,99],256],13253:[[99,100],256],13254:[[67,8725,107,103],256],13255:[[67,111,46],256],13256:[[100,66],256],13257:[[71,121],256],13258:[[104,97],256],13259:[[72,80],256],13260:[[105,110],256],13261:[[75,75],256],13262:[[75,77],256],13263:[[107,116],256],13264:[[108,109],256],13265:[[108,110],256],13266:[[108,111,103],256],13267:[[108,120],256],13268:[[109,98],256],13269:[[109,105,108],256],13270:[[109,111,108],256],13271:[[80,72],256],13272:[[112,46,109,46],256],13273:[[80,80,77],256],13274:[[80,82],256],13275:[[115,114],256],13276:[[83,118],256],13277:[[87,98],256],13278:[[86,8725,109],256],13279:[[65,8725,109],256],13280:[[49,26085],256],13281:[[50,26085],256],13282:[[51,26085],256],13283:[[52,26085],256],13284:[[53,26085],256],13285:[[54,26085],256],13286:[[55,26085],256],13287:[[56,26085],256],13288:[[57,26085],256],13289:[[49,48,26085],256],13290:[[49,49,26085],256],13291:[[49,50,26085],256],13292:[[49,51,26085],256],13293:[[49,52,26085],256],13294:[[49,53,26085],256],13295:[[49,54,26085],256],13296:[[49,55,26085],256],13297:[[49,56,26085],256],13298:[[49,57,26085],256],13299:[[50,48,26085],256],13300:[[50,49,26085],256],13301:[[50,50,26085],256],13302:[[50,51,26085],256],13303:[[50,52,26085],256],13304:[[50,53,26085],256],13305:[[50,54,26085],256],13306:[[50,55,26085],256],13307:[[50,56,26085],256],13308:[[50,57,26085],256],13309:[[51,48,26085],256],13310:[[51,49,26085],256],13311:[[103,97,108],256]}, + 42496:{42607:[,230],42612:[,230],42613:[,230],42614:[,230],42615:[,230],42616:[,230],42617:[,230],42618:[,230],42619:[,230],42620:[,230],42621:[,230],42655:[,230],42736:[,230],42737:[,230]}, + 42752:{42864:[[42863],256],43000:[[294],256],43001:[[339],256]}, + 43008:{43014:[,9],43204:[,9],43232:[,230],43233:[,230],43234:[,230],43235:[,230],43236:[,230],43237:[,230],43238:[,230],43239:[,230],43240:[,230],43241:[,230],43242:[,230],43243:[,230],43244:[,230],43245:[,230],43246:[,230],43247:[,230],43248:[,230],43249:[,230]}, + 43264:{43307:[,220],43308:[,220],43309:[,220],43347:[,9],43443:[,7],43456:[,9]}, + 43520:{43696:[,230],43698:[,230],43699:[,230],43700:[,220],43703:[,230],43704:[,230],43710:[,230],43711:[,230],43713:[,230],43766:[,9]}, + 43776:{44013:[,9]}, + 53504:{119134:[[119127,119141],512],119135:[[119128,119141],512],119136:[[119135,119150],512],119137:[[119135,119151],512],119138:[[119135,119152],512],119139:[[119135,119153],512],119140:[[119135,119154],512],119141:[,216],119142:[,216],119143:[,1],119144:[,1],119145:[,1],119149:[,226],119150:[,216],119151:[,216],119152:[,216],119153:[,216],119154:[,216],119163:[,220],119164:[,220],119165:[,220],119166:[,220],119167:[,220],119168:[,220],119169:[,220],119170:[,220],119173:[,230],119174:[,230],119175:[,230],119176:[,230],119177:[,230],119178:[,220],119179:[,220],119210:[,230],119211:[,230],119212:[,230],119213:[,230],119227:[[119225,119141],512],119228:[[119226,119141],512],119229:[[119227,119150],512],119230:[[119228,119150],512],119231:[[119227,119151],512],119232:[[119228,119151],512]}, + 53760:{119362:[,230],119363:[,230],119364:[,230]}, + 54272:{119808:[[65],256],119809:[[66],256],119810:[[67],256],119811:[[68],256],119812:[[69],256],119813:[[70],256],119814:[[71],256],119815:[[72],256],119816:[[73],256],119817:[[74],256],119818:[[75],256],119819:[[76],256],119820:[[77],256],119821:[[78],256],119822:[[79],256],119823:[[80],256],119824:[[81],256],119825:[[82],256],119826:[[83],256],119827:[[84],256],119828:[[85],256],119829:[[86],256],119830:[[87],256],119831:[[88],256],119832:[[89],256],119833:[[90],256],119834:[[97],256],119835:[[98],256],119836:[[99],256],119837:[[100],256],119838:[[101],256],119839:[[102],256],119840:[[103],256],119841:[[104],256],119842:[[105],256],119843:[[106],256],119844:[[107],256],119845:[[108],256],119846:[[109],256],119847:[[110],256],119848:[[111],256],119849:[[112],256],119850:[[113],256],119851:[[114],256],119852:[[115],256],119853:[[116],256],119854:[[117],256],119855:[[118],256],119856:[[119],256],119857:[[120],256],119858:[[121],256],119859:[[122],256],119860:[[65],256],119861:[[66],256],119862:[[67],256],119863:[[68],256],119864:[[69],256],119865:[[70],256],119866:[[71],256],119867:[[72],256],119868:[[73],256],119869:[[74],256],119870:[[75],256],119871:[[76],256],119872:[[77],256],119873:[[78],256],119874:[[79],256],119875:[[80],256],119876:[[81],256],119877:[[82],256],119878:[[83],256],119879:[[84],256],119880:[[85],256],119881:[[86],256],119882:[[87],256],119883:[[88],256],119884:[[89],256],119885:[[90],256],119886:[[97],256],119887:[[98],256],119888:[[99],256],119889:[[100],256],119890:[[101],256],119891:[[102],256],119892:[[103],256],119894:[[105],256],119895:[[106],256],119896:[[107],256],119897:[[108],256],119898:[[109],256],119899:[[110],256],119900:[[111],256],119901:[[112],256],119902:[[113],256],119903:[[114],256],119904:[[115],256],119905:[[116],256],119906:[[117],256],119907:[[118],256],119908:[[119],256],119909:[[120],256],119910:[[121],256],119911:[[122],256],119912:[[65],256],119913:[[66],256],119914:[[67],256],119915:[[68],256],119916:[[69],256],119917:[[70],256],119918:[[71],256],119919:[[72],256],119920:[[73],256],119921:[[74],256],119922:[[75],256],119923:[[76],256],119924:[[77],256],119925:[[78],256],119926:[[79],256],119927:[[80],256],119928:[[81],256],119929:[[82],256],119930:[[83],256],119931:[[84],256],119932:[[85],256],119933:[[86],256],119934:[[87],256],119935:[[88],256],119936:[[89],256],119937:[[90],256],119938:[[97],256],119939:[[98],256],119940:[[99],256],119941:[[100],256],119942:[[101],256],119943:[[102],256],119944:[[103],256],119945:[[104],256],119946:[[105],256],119947:[[106],256],119948:[[107],256],119949:[[108],256],119950:[[109],256],119951:[[110],256],119952:[[111],256],119953:[[112],256],119954:[[113],256],119955:[[114],256],119956:[[115],256],119957:[[116],256],119958:[[117],256],119959:[[118],256],119960:[[119],256],119961:[[120],256],119962:[[121],256],119963:[[122],256],119964:[[65],256],119966:[[67],256],119967:[[68],256],119970:[[71],256],119973:[[74],256],119974:[[75],256],119977:[[78],256],119978:[[79],256],119979:[[80],256],119980:[[81],256],119982:[[83],256],119983:[[84],256],119984:[[85],256],119985:[[86],256],119986:[[87],256],119987:[[88],256],119988:[[89],256],119989:[[90],256],119990:[[97],256],119991:[[98],256],119992:[[99],256],119993:[[100],256],119995:[[102],256],119997:[[104],256],119998:[[105],256],119999:[[106],256],120000:[[107],256],120001:[[108],256],120002:[[109],256],120003:[[110],256],120005:[[112],256],120006:[[113],256],120007:[[114],256],120008:[[115],256],120009:[[116],256],120010:[[117],256],120011:[[118],256],120012:[[119],256],120013:[[120],256],120014:[[121],256],120015:[[122],256],120016:[[65],256],120017:[[66],256],120018:[[67],256],120019:[[68],256],120020:[[69],256],120021:[[70],256],120022:[[71],256],120023:[[72],256],120024:[[73],256],120025:[[74],256],120026:[[75],256],120027:[[76],256],120028:[[77],256],120029:[[78],256],120030:[[79],256],120031:[[80],256],120032:[[81],256],120033:[[82],256],120034:[[83],256],120035:[[84],256],120036:[[85],256],120037:[[86],256],120038:[[87],256],120039:[[88],256],120040:[[89],256],120041:[[90],256],120042:[[97],256],120043:[[98],256],120044:[[99],256],120045:[[100],256],120046:[[101],256],120047:[[102],256],120048:[[103],256],120049:[[104],256],120050:[[105],256],120051:[[106],256],120052:[[107],256],120053:[[108],256],120054:[[109],256],120055:[[110],256],120056:[[111],256],120057:[[112],256],120058:[[113],256],120059:[[114],256],120060:[[115],256],120061:[[116],256],120062:[[117],256],120063:[[118],256]}, + 54528:{120064:[[119],256],120065:[[120],256],120066:[[121],256],120067:[[122],256],120068:[[65],256],120069:[[66],256],120071:[[68],256],120072:[[69],256],120073:[[70],256],120074:[[71],256],120077:[[74],256],120078:[[75],256],120079:[[76],256],120080:[[77],256],120081:[[78],256],120082:[[79],256],120083:[[80],256],120084:[[81],256],120086:[[83],256],120087:[[84],256],120088:[[85],256],120089:[[86],256],120090:[[87],256],120091:[[88],256],120092:[[89],256],120094:[[97],256],120095:[[98],256],120096:[[99],256],120097:[[100],256],120098:[[101],256],120099:[[102],256],120100:[[103],256],120101:[[104],256],120102:[[105],256],120103:[[106],256],120104:[[107],256],120105:[[108],256],120106:[[109],256],120107:[[110],256],120108:[[111],256],120109:[[112],256],120110:[[113],256],120111:[[114],256],120112:[[115],256],120113:[[116],256],120114:[[117],256],120115:[[118],256],120116:[[119],256],120117:[[120],256],120118:[[121],256],120119:[[122],256],120120:[[65],256],120121:[[66],256],120123:[[68],256],120124:[[69],256],120125:[[70],256],120126:[[71],256],120128:[[73],256],120129:[[74],256],120130:[[75],256],120131:[[76],256],120132:[[77],256],120134:[[79],256],120138:[[83],256],120139:[[84],256],120140:[[85],256],120141:[[86],256],120142:[[87],256],120143:[[88],256],120144:[[89],256],120146:[[97],256],120147:[[98],256],120148:[[99],256],120149:[[100],256],120150:[[101],256],120151:[[102],256],120152:[[103],256],120153:[[104],256],120154:[[105],256],120155:[[106],256],120156:[[107],256],120157:[[108],256],120158:[[109],256],120159:[[110],256],120160:[[111],256],120161:[[112],256],120162:[[113],256],120163:[[114],256],120164:[[115],256],120165:[[116],256],120166:[[117],256],120167:[[118],256],120168:[[119],256],120169:[[120],256],120170:[[121],256],120171:[[122],256],120172:[[65],256],120173:[[66],256],120174:[[67],256],120175:[[68],256],120176:[[69],256],120177:[[70],256],120178:[[71],256],120179:[[72],256],120180:[[73],256],120181:[[74],256],120182:[[75],256],120183:[[76],256],120184:[[77],256],120185:[[78],256],120186:[[79],256],120187:[[80],256],120188:[[81],256],120189:[[82],256],120190:[[83],256],120191:[[84],256],120192:[[85],256],120193:[[86],256],120194:[[87],256],120195:[[88],256],120196:[[89],256],120197:[[90],256],120198:[[97],256],120199:[[98],256],120200:[[99],256],120201:[[100],256],120202:[[101],256],120203:[[102],256],120204:[[103],256],120205:[[104],256],120206:[[105],256],120207:[[106],256],120208:[[107],256],120209:[[108],256],120210:[[109],256],120211:[[110],256],120212:[[111],256],120213:[[112],256],120214:[[113],256],120215:[[114],256],120216:[[115],256],120217:[[116],256],120218:[[117],256],120219:[[118],256],120220:[[119],256],120221:[[120],256],120222:[[121],256],120223:[[122],256],120224:[[65],256],120225:[[66],256],120226:[[67],256],120227:[[68],256],120228:[[69],256],120229:[[70],256],120230:[[71],256],120231:[[72],256],120232:[[73],256],120233:[[74],256],120234:[[75],256],120235:[[76],256],120236:[[77],256],120237:[[78],256],120238:[[79],256],120239:[[80],256],120240:[[81],256],120241:[[82],256],120242:[[83],256],120243:[[84],256],120244:[[85],256],120245:[[86],256],120246:[[87],256],120247:[[88],256],120248:[[89],256],120249:[[90],256],120250:[[97],256],120251:[[98],256],120252:[[99],256],120253:[[100],256],120254:[[101],256],120255:[[102],256],120256:[[103],256],120257:[[104],256],120258:[[105],256],120259:[[106],256],120260:[[107],256],120261:[[108],256],120262:[[109],256],120263:[[110],256],120264:[[111],256],120265:[[112],256],120266:[[113],256],120267:[[114],256],120268:[[115],256],120269:[[116],256],120270:[[117],256],120271:[[118],256],120272:[[119],256],120273:[[120],256],120274:[[121],256],120275:[[122],256],120276:[[65],256],120277:[[66],256],120278:[[67],256],120279:[[68],256],120280:[[69],256],120281:[[70],256],120282:[[71],256],120283:[[72],256],120284:[[73],256],120285:[[74],256],120286:[[75],256],120287:[[76],256],120288:[[77],256],120289:[[78],256],120290:[[79],256],120291:[[80],256],120292:[[81],256],120293:[[82],256],120294:[[83],256],120295:[[84],256],120296:[[85],256],120297:[[86],256],120298:[[87],256],120299:[[88],256],120300:[[89],256],120301:[[90],256],120302:[[97],256],120303:[[98],256],120304:[[99],256],120305:[[100],256],120306:[[101],256],120307:[[102],256],120308:[[103],256],120309:[[104],256],120310:[[105],256],120311:[[106],256],120312:[[107],256],120313:[[108],256],120314:[[109],256],120315:[[110],256],120316:[[111],256],120317:[[112],256],120318:[[113],256],120319:[[114],256]}, + 54784:{120320:[[115],256],120321:[[116],256],120322:[[117],256],120323:[[118],256],120324:[[119],256],120325:[[120],256],120326:[[121],256],120327:[[122],256],120328:[[65],256],120329:[[66],256],120330:[[67],256],120331:[[68],256],120332:[[69],256],120333:[[70],256],120334:[[71],256],120335:[[72],256],120336:[[73],256],120337:[[74],256],120338:[[75],256],120339:[[76],256],120340:[[77],256],120341:[[78],256],120342:[[79],256],120343:[[80],256],120344:[[81],256],120345:[[82],256],120346:[[83],256],120347:[[84],256],120348:[[85],256],120349:[[86],256],120350:[[87],256],120351:[[88],256],120352:[[89],256],120353:[[90],256],120354:[[97],256],120355:[[98],256],120356:[[99],256],120357:[[100],256],120358:[[101],256],120359:[[102],256],120360:[[103],256],120361:[[104],256],120362:[[105],256],120363:[[106],256],120364:[[107],256],120365:[[108],256],120366:[[109],256],120367:[[110],256],120368:[[111],256],120369:[[112],256],120370:[[113],256],120371:[[114],256],120372:[[115],256],120373:[[116],256],120374:[[117],256],120375:[[118],256],120376:[[119],256],120377:[[120],256],120378:[[121],256],120379:[[122],256],120380:[[65],256],120381:[[66],256],120382:[[67],256],120383:[[68],256],120384:[[69],256],120385:[[70],256],120386:[[71],256],120387:[[72],256],120388:[[73],256],120389:[[74],256],120390:[[75],256],120391:[[76],256],120392:[[77],256],120393:[[78],256],120394:[[79],256],120395:[[80],256],120396:[[81],256],120397:[[82],256],120398:[[83],256],120399:[[84],256],120400:[[85],256],120401:[[86],256],120402:[[87],256],120403:[[88],256],120404:[[89],256],120405:[[90],256],120406:[[97],256],120407:[[98],256],120408:[[99],256],120409:[[100],256],120410:[[101],256],120411:[[102],256],120412:[[103],256],120413:[[104],256],120414:[[105],256],120415:[[106],256],120416:[[107],256],120417:[[108],256],120418:[[109],256],120419:[[110],256],120420:[[111],256],120421:[[112],256],120422:[[113],256],120423:[[114],256],120424:[[115],256],120425:[[116],256],120426:[[117],256],120427:[[118],256],120428:[[119],256],120429:[[120],256],120430:[[121],256],120431:[[122],256],120432:[[65],256],120433:[[66],256],120434:[[67],256],120435:[[68],256],120436:[[69],256],120437:[[70],256],120438:[[71],256],120439:[[72],256],120440:[[73],256],120441:[[74],256],120442:[[75],256],120443:[[76],256],120444:[[77],256],120445:[[78],256],120446:[[79],256],120447:[[80],256],120448:[[81],256],120449:[[82],256],120450:[[83],256],120451:[[84],256],120452:[[85],256],120453:[[86],256],120454:[[87],256],120455:[[88],256],120456:[[89],256],120457:[[90],256],120458:[[97],256],120459:[[98],256],120460:[[99],256],120461:[[100],256],120462:[[101],256],120463:[[102],256],120464:[[103],256],120465:[[104],256],120466:[[105],256],120467:[[106],256],120468:[[107],256],120469:[[108],256],120470:[[109],256],120471:[[110],256],120472:[[111],256],120473:[[112],256],120474:[[113],256],120475:[[114],256],120476:[[115],256],120477:[[116],256],120478:[[117],256],120479:[[118],256],120480:[[119],256],120481:[[120],256],120482:[[121],256],120483:[[122],256],120484:[[305],256],120485:[[567],256],120488:[[913],256],120489:[[914],256],120490:[[915],256],120491:[[916],256],120492:[[917],256],120493:[[918],256],120494:[[919],256],120495:[[920],256],120496:[[921],256],120497:[[922],256],120498:[[923],256],120499:[[924],256],120500:[[925],256],120501:[[926],256],120502:[[927],256],120503:[[928],256],120504:[[929],256],120505:[[1012],256],120506:[[931],256],120507:[[932],256],120508:[[933],256],120509:[[934],256],120510:[[935],256],120511:[[936],256],120512:[[937],256],120513:[[8711],256],120514:[[945],256],120515:[[946],256],120516:[[947],256],120517:[[948],256],120518:[[949],256],120519:[[950],256],120520:[[951],256],120521:[[952],256],120522:[[953],256],120523:[[954],256],120524:[[955],256],120525:[[956],256],120526:[[957],256],120527:[[958],256],120528:[[959],256],120529:[[960],256],120530:[[961],256],120531:[[962],256],120532:[[963],256],120533:[[964],256],120534:[[965],256],120535:[[966],256],120536:[[967],256],120537:[[968],256],120538:[[969],256],120539:[[8706],256],120540:[[1013],256],120541:[[977],256],120542:[[1008],256],120543:[[981],256],120544:[[1009],256],120545:[[982],256],120546:[[913],256],120547:[[914],256],120548:[[915],256],120549:[[916],256],120550:[[917],256],120551:[[918],256],120552:[[919],256],120553:[[920],256],120554:[[921],256],120555:[[922],256],120556:[[923],256],120557:[[924],256],120558:[[925],256],120559:[[926],256],120560:[[927],256],120561:[[928],256],120562:[[929],256],120563:[[1012],256],120564:[[931],256],120565:[[932],256],120566:[[933],256],120567:[[934],256],120568:[[935],256],120569:[[936],256],120570:[[937],256],120571:[[8711],256],120572:[[945],256],120573:[[946],256],120574:[[947],256],120575:[[948],256]}, + 55040:{120576:[[949],256],120577:[[950],256],120578:[[951],256],120579:[[952],256],120580:[[953],256],120581:[[954],256],120582:[[955],256],120583:[[956],256],120584:[[957],256],120585:[[958],256],120586:[[959],256],120587:[[960],256],120588:[[961],256],120589:[[962],256],120590:[[963],256],120591:[[964],256],120592:[[965],256],120593:[[966],256],120594:[[967],256],120595:[[968],256],120596:[[969],256],120597:[[8706],256],120598:[[1013],256],120599:[[977],256],120600:[[1008],256],120601:[[981],256],120602:[[1009],256],120603:[[982],256],120604:[[913],256],120605:[[914],256],120606:[[915],256],120607:[[916],256],120608:[[917],256],120609:[[918],256],120610:[[919],256],120611:[[920],256],120612:[[921],256],120613:[[922],256],120614:[[923],256],120615:[[924],256],120616:[[925],256],120617:[[926],256],120618:[[927],256],120619:[[928],256],120620:[[929],256],120621:[[1012],256],120622:[[931],256],120623:[[932],256],120624:[[933],256],120625:[[934],256],120626:[[935],256],120627:[[936],256],120628:[[937],256],120629:[[8711],256],120630:[[945],256],120631:[[946],256],120632:[[947],256],120633:[[948],256],120634:[[949],256],120635:[[950],256],120636:[[951],256],120637:[[952],256],120638:[[953],256],120639:[[954],256],120640:[[955],256],120641:[[956],256],120642:[[957],256],120643:[[958],256],120644:[[959],256],120645:[[960],256],120646:[[961],256],120647:[[962],256],120648:[[963],256],120649:[[964],256],120650:[[965],256],120651:[[966],256],120652:[[967],256],120653:[[968],256],120654:[[969],256],120655:[[8706],256],120656:[[1013],256],120657:[[977],256],120658:[[1008],256],120659:[[981],256],120660:[[1009],256],120661:[[982],256],120662:[[913],256],120663:[[914],256],120664:[[915],256],120665:[[916],256],120666:[[917],256],120667:[[918],256],120668:[[919],256],120669:[[920],256],120670:[[921],256],120671:[[922],256],120672:[[923],256],120673:[[924],256],120674:[[925],256],120675:[[926],256],120676:[[927],256],120677:[[928],256],120678:[[929],256],120679:[[1012],256],120680:[[931],256],120681:[[932],256],120682:[[933],256],120683:[[934],256],120684:[[935],256],120685:[[936],256],120686:[[937],256],120687:[[8711],256],120688:[[945],256],120689:[[946],256],120690:[[947],256],120691:[[948],256],120692:[[949],256],120693:[[950],256],120694:[[951],256],120695:[[952],256],120696:[[953],256],120697:[[954],256],120698:[[955],256],120699:[[956],256],120700:[[957],256],120701:[[958],256],120702:[[959],256],120703:[[960],256],120704:[[961],256],120705:[[962],256],120706:[[963],256],120707:[[964],256],120708:[[965],256],120709:[[966],256],120710:[[967],256],120711:[[968],256],120712:[[969],256],120713:[[8706],256],120714:[[1013],256],120715:[[977],256],120716:[[1008],256],120717:[[981],256],120718:[[1009],256],120719:[[982],256],120720:[[913],256],120721:[[914],256],120722:[[915],256],120723:[[916],256],120724:[[917],256],120725:[[918],256],120726:[[919],256],120727:[[920],256],120728:[[921],256],120729:[[922],256],120730:[[923],256],120731:[[924],256],120732:[[925],256],120733:[[926],256],120734:[[927],256],120735:[[928],256],120736:[[929],256],120737:[[1012],256],120738:[[931],256],120739:[[932],256],120740:[[933],256],120741:[[934],256],120742:[[935],256],120743:[[936],256],120744:[[937],256],120745:[[8711],256],120746:[[945],256],120747:[[946],256],120748:[[947],256],120749:[[948],256],120750:[[949],256],120751:[[950],256],120752:[[951],256],120753:[[952],256],120754:[[953],256],120755:[[954],256],120756:[[955],256],120757:[[956],256],120758:[[957],256],120759:[[958],256],120760:[[959],256],120761:[[960],256],120762:[[961],256],120763:[[962],256],120764:[[963],256],120765:[[964],256],120766:[[965],256],120767:[[966],256],120768:[[967],256],120769:[[968],256],120770:[[969],256],120771:[[8706],256],120772:[[1013],256],120773:[[977],256],120774:[[1008],256],120775:[[981],256],120776:[[1009],256],120777:[[982],256],120778:[[988],256],120779:[[989],256],120782:[[48],256],120783:[[49],256],120784:[[50],256],120785:[[51],256],120786:[[52],256],120787:[[53],256],120788:[[54],256],120789:[[55],256],120790:[[56],256],120791:[[57],256],120792:[[48],256],120793:[[49],256],120794:[[50],256],120795:[[51],256],120796:[[52],256],120797:[[53],256],120798:[[54],256],120799:[[55],256],120800:[[56],256],120801:[[57],256],120802:[[48],256],120803:[[49],256],120804:[[50],256],120805:[[51],256],120806:[[52],256],120807:[[53],256],120808:[[54],256],120809:[[55],256],120810:[[56],256],120811:[[57],256],120812:[[48],256],120813:[[49],256],120814:[[50],256],120815:[[51],256],120816:[[52],256],120817:[[53],256],120818:[[54],256],120819:[[55],256],120820:[[56],256],120821:[[57],256],120822:[[48],256],120823:[[49],256],120824:[[50],256],120825:[[51],256],120826:[[52],256],120827:[[53],256],120828:[[54],256],120829:[[55],256],120830:[[56],256],120831:[[57],256]}, + 60928:{126464:[[1575],256],126465:[[1576],256],126466:[[1580],256],126467:[[1583],256],126469:[[1608],256],126470:[[1586],256],126471:[[1581],256],126472:[[1591],256],126473:[[1610],256],126474:[[1603],256],126475:[[1604],256],126476:[[1605],256],126477:[[1606],256],126478:[[1587],256],126479:[[1593],256],126480:[[1601],256],126481:[[1589],256],126482:[[1602],256],126483:[[1585],256],126484:[[1588],256],126485:[[1578],256],126486:[[1579],256],126487:[[1582],256],126488:[[1584],256],126489:[[1590],256],126490:[[1592],256],126491:[[1594],256],126492:[[1646],256],126493:[[1722],256],126494:[[1697],256],126495:[[1647],256],126497:[[1576],256],126498:[[1580],256],126500:[[1607],256],126503:[[1581],256],126505:[[1610],256],126506:[[1603],256],126507:[[1604],256],126508:[[1605],256],126509:[[1606],256],126510:[[1587],256],126511:[[1593],256],126512:[[1601],256],126513:[[1589],256],126514:[[1602],256],126516:[[1588],256],126517:[[1578],256],126518:[[1579],256],126519:[[1582],256],126521:[[1590],256],126523:[[1594],256],126530:[[1580],256],126535:[[1581],256],126537:[[1610],256],126539:[[1604],256],126541:[[1606],256],126542:[[1587],256],126543:[[1593],256],126545:[[1589],256],126546:[[1602],256],126548:[[1588],256],126551:[[1582],256],126553:[[1590],256],126555:[[1594],256],126557:[[1722],256],126559:[[1647],256],126561:[[1576],256],126562:[[1580],256],126564:[[1607],256],126567:[[1581],256],126568:[[1591],256],126569:[[1610],256],126570:[[1603],256],126572:[[1605],256],126573:[[1606],256],126574:[[1587],256],126575:[[1593],256],126576:[[1601],256],126577:[[1589],256],126578:[[1602],256],126580:[[1588],256],126581:[[1578],256],126582:[[1579],256],126583:[[1582],256],126585:[[1590],256],126586:[[1592],256],126587:[[1594],256],126588:[[1646],256],126590:[[1697],256],126592:[[1575],256],126593:[[1576],256],126594:[[1580],256],126595:[[1583],256],126596:[[1607],256],126597:[[1608],256],126598:[[1586],256],126599:[[1581],256],126600:[[1591],256],126601:[[1610],256],126603:[[1604],256],126604:[[1605],256],126605:[[1606],256],126606:[[1587],256],126607:[[1593],256],126608:[[1601],256],126609:[[1589],256],126610:[[1602],256],126611:[[1585],256],126612:[[1588],256],126613:[[1578],256],126614:[[1579],256],126615:[[1582],256],126616:[[1584],256],126617:[[1590],256],126618:[[1592],256],126619:[[1594],256],126625:[[1576],256],126626:[[1580],256],126627:[[1583],256],126629:[[1608],256],126630:[[1586],256],126631:[[1581],256],126632:[[1591],256],126633:[[1610],256],126635:[[1604],256],126636:[[1605],256],126637:[[1606],256],126638:[[1587],256],126639:[[1593],256],126640:[[1601],256],126641:[[1589],256],126642:[[1602],256],126643:[[1585],256],126644:[[1588],256],126645:[[1578],256],126646:[[1579],256],126647:[[1582],256],126648:[[1584],256],126649:[[1590],256],126650:[[1592],256],126651:[[1594],256]}, + 61696:{127232:[[48,46],256],127233:[[48,44],256],127234:[[49,44],256],127235:[[50,44],256],127236:[[51,44],256],127237:[[52,44],256],127238:[[53,44],256],127239:[[54,44],256],127240:[[55,44],256],127241:[[56,44],256],127242:[[57,44],256],127248:[[40,65,41],256],127249:[[40,66,41],256],127250:[[40,67,41],256],127251:[[40,68,41],256],127252:[[40,69,41],256],127253:[[40,70,41],256],127254:[[40,71,41],256],127255:[[40,72,41],256],127256:[[40,73,41],256],127257:[[40,74,41],256],127258:[[40,75,41],256],127259:[[40,76,41],256],127260:[[40,77,41],256],127261:[[40,78,41],256],127262:[[40,79,41],256],127263:[[40,80,41],256],127264:[[40,81,41],256],127265:[[40,82,41],256],127266:[[40,83,41],256],127267:[[40,84,41],256],127268:[[40,85,41],256],127269:[[40,86,41],256],127270:[[40,87,41],256],127271:[[40,88,41],256],127272:[[40,89,41],256],127273:[[40,90,41],256],127274:[[12308,83,12309],256],127275:[[67],256],127276:[[82],256],127277:[[67,68],256],127278:[[87,90],256],127280:[[65],256],127281:[[66],256],127282:[[67],256],127283:[[68],256],127284:[[69],256],127285:[[70],256],127286:[[71],256],127287:[[72],256],127288:[[73],256],127289:[[74],256],127290:[[75],256],127291:[[76],256],127292:[[77],256],127293:[[78],256],127294:[[79],256],127295:[[80],256],127296:[[81],256],127297:[[82],256],127298:[[83],256],127299:[[84],256],127300:[[85],256],127301:[[86],256],127302:[[87],256],127303:[[88],256],127304:[[89],256],127305:[[90],256],127306:[[72,86],256],127307:[[77,86],256],127308:[[83,68],256],127309:[[83,83],256],127310:[[80,80,86],256],127311:[[87,67],256],127338:[[77,67],256],127339:[[77,68],256],127376:[[68,74],256]}, + 61952:{127488:[[12411,12363],256],127489:[[12467,12467],256],127490:[[12469],256],127504:[[25163],256],127505:[[23383],256],127506:[[21452],256],127507:[[12487],256],127508:[[20108],256],127509:[[22810],256],127510:[[35299],256],127511:[[22825],256],127512:[[20132],256],127513:[[26144],256],127514:[[28961],256],127515:[[26009],256],127516:[[21069],256],127517:[[24460],256],127518:[[20877],256],127519:[[26032],256],127520:[[21021],256],127521:[[32066],256],127522:[[29983],256],127523:[[36009],256],127524:[[22768],256],127525:[[21561],256],127526:[[28436],256],127527:[[25237],256],127528:[[25429],256],127529:[[19968],256],127530:[[19977],256],127531:[[36938],256],127532:[[24038],256],127533:[[20013],256],127534:[[21491],256],127535:[[25351],256],127536:[[36208],256],127537:[[25171],256],127538:[[31105],256],127539:[[31354],256],127540:[[21512],256],127541:[[28288],256],127542:[[26377],256],127543:[[26376],256],127544:[[30003],256],127545:[[21106],256],127546:[[21942],256],127552:[[12308,26412,12309],256],127553:[[12308,19977,12309],256],127554:[[12308,20108,12309],256],127555:[[12308,23433,12309],256],127556:[[12308,28857,12309],256],127557:[[12308,25171,12309],256],127558:[[12308,30423,12309],256],127559:[[12308,21213,12309],256],127560:[[12308,25943,12309],256],127568:[[24471],256],127569:[[21487],256]}, + 63488:{194560:[[20029]],194561:[[20024]],194562:[[20033]],194563:[[131362]],194564:[[20320]],194565:[[20398]],194566:[[20411]],194567:[[20482]],194568:[[20602]],194569:[[20633]],194570:[[20711]],194571:[[20687]],194572:[[13470]],194573:[[132666]],194574:[[20813]],194575:[[20820]],194576:[[20836]],194577:[[20855]],194578:[[132380]],194579:[[13497]],194580:[[20839]],194581:[[20877]],194582:[[132427]],194583:[[20887]],194584:[[20900]],194585:[[20172]],194586:[[20908]],194587:[[20917]],194588:[[168415]],194589:[[20981]],194590:[[20995]],194591:[[13535]],194592:[[21051]],194593:[[21062]],194594:[[21106]],194595:[[21111]],194596:[[13589]],194597:[[21191]],194598:[[21193]],194599:[[21220]],194600:[[21242]],194601:[[21253]],194602:[[21254]],194603:[[21271]],194604:[[21321]],194605:[[21329]],194606:[[21338]],194607:[[21363]],194608:[[21373]],194609:[[21375]],194610:[[21375]],194611:[[21375]],194612:[[133676]],194613:[[28784]],194614:[[21450]],194615:[[21471]],194616:[[133987]],194617:[[21483]],194618:[[21489]],194619:[[21510]],194620:[[21662]],194621:[[21560]],194622:[[21576]],194623:[[21608]],194624:[[21666]],194625:[[21750]],194626:[[21776]],194627:[[21843]],194628:[[21859]],194629:[[21892]],194630:[[21892]],194631:[[21913]],194632:[[21931]],194633:[[21939]],194634:[[21954]],194635:[[22294]],194636:[[22022]],194637:[[22295]],194638:[[22097]],194639:[[22132]],194640:[[20999]],194641:[[22766]],194642:[[22478]],194643:[[22516]],194644:[[22541]],194645:[[22411]],194646:[[22578]],194647:[[22577]],194648:[[22700]],194649:[[136420]],194650:[[22770]],194651:[[22775]],194652:[[22790]],194653:[[22810]],194654:[[22818]],194655:[[22882]],194656:[[136872]],194657:[[136938]],194658:[[23020]],194659:[[23067]],194660:[[23079]],194661:[[23000]],194662:[[23142]],194663:[[14062]],194664:[[14076]],194665:[[23304]],194666:[[23358]],194667:[[23358]],194668:[[137672]],194669:[[23491]],194670:[[23512]],194671:[[23527]],194672:[[23539]],194673:[[138008]],194674:[[23551]],194675:[[23558]],194676:[[24403]],194677:[[23586]],194678:[[14209]],194679:[[23648]],194680:[[23662]],194681:[[23744]],194682:[[23693]],194683:[[138724]],194684:[[23875]],194685:[[138726]],194686:[[23918]],194687:[[23915]],194688:[[23932]],194689:[[24033]],194690:[[24034]],194691:[[14383]],194692:[[24061]],194693:[[24104]],194694:[[24125]],194695:[[24169]],194696:[[14434]],194697:[[139651]],194698:[[14460]],194699:[[24240]],194700:[[24243]],194701:[[24246]],194702:[[24266]],194703:[[172946]],194704:[[24318]],194705:[[140081]],194706:[[140081]],194707:[[33281]],194708:[[24354]],194709:[[24354]],194710:[[14535]],194711:[[144056]],194712:[[156122]],194713:[[24418]],194714:[[24427]],194715:[[14563]],194716:[[24474]],194717:[[24525]],194718:[[24535]],194719:[[24569]],194720:[[24705]],194721:[[14650]],194722:[[14620]],194723:[[24724]],194724:[[141012]],194725:[[24775]],194726:[[24904]],194727:[[24908]],194728:[[24910]],194729:[[24908]],194730:[[24954]],194731:[[24974]],194732:[[25010]],194733:[[24996]],194734:[[25007]],194735:[[25054]],194736:[[25074]],194737:[[25078]],194738:[[25104]],194739:[[25115]],194740:[[25181]],194741:[[25265]],194742:[[25300]],194743:[[25424]],194744:[[142092]],194745:[[25405]],194746:[[25340]],194747:[[25448]],194748:[[25475]],194749:[[25572]],194750:[[142321]],194751:[[25634]],194752:[[25541]],194753:[[25513]],194754:[[14894]],194755:[[25705]],194756:[[25726]],194757:[[25757]],194758:[[25719]],194759:[[14956]],194760:[[25935]],194761:[[25964]],194762:[[143370]],194763:[[26083]],194764:[[26360]],194765:[[26185]],194766:[[15129]],194767:[[26257]],194768:[[15112]],194769:[[15076]],194770:[[20882]],194771:[[20885]],194772:[[26368]],194773:[[26268]],194774:[[32941]],194775:[[17369]],194776:[[26391]],194777:[[26395]],194778:[[26401]],194779:[[26462]],194780:[[26451]],194781:[[144323]],194782:[[15177]],194783:[[26618]],194784:[[26501]],194785:[[26706]],194786:[[26757]],194787:[[144493]],194788:[[26766]],194789:[[26655]],194790:[[26900]],194791:[[15261]],194792:[[26946]],194793:[[27043]],194794:[[27114]],194795:[[27304]],194796:[[145059]],194797:[[27355]],194798:[[15384]],194799:[[27425]],194800:[[145575]],194801:[[27476]],194802:[[15438]],194803:[[27506]],194804:[[27551]],194805:[[27578]],194806:[[27579]],194807:[[146061]],194808:[[138507]],194809:[[146170]],194810:[[27726]],194811:[[146620]],194812:[[27839]],194813:[[27853]],194814:[[27751]],194815:[[27926]]}, + 63744:{63744:[[35912]],63745:[[26356]],63746:[[36554]],63747:[[36040]],63748:[[28369]],63749:[[20018]],63750:[[21477]],63751:[[40860]],63752:[[40860]],63753:[[22865]],63754:[[37329]],63755:[[21895]],63756:[[22856]],63757:[[25078]],63758:[[30313]],63759:[[32645]],63760:[[34367]],63761:[[34746]],63762:[[35064]],63763:[[37007]],63764:[[27138]],63765:[[27931]],63766:[[28889]],63767:[[29662]],63768:[[33853]],63769:[[37226]],63770:[[39409]],63771:[[20098]],63772:[[21365]],63773:[[27396]],63774:[[29211]],63775:[[34349]],63776:[[40478]],63777:[[23888]],63778:[[28651]],63779:[[34253]],63780:[[35172]],63781:[[25289]],63782:[[33240]],63783:[[34847]],63784:[[24266]],63785:[[26391]],63786:[[28010]],63787:[[29436]],63788:[[37070]],63789:[[20358]],63790:[[20919]],63791:[[21214]],63792:[[25796]],63793:[[27347]],63794:[[29200]],63795:[[30439]],63796:[[32769]],63797:[[34310]],63798:[[34396]],63799:[[36335]],63800:[[38706]],63801:[[39791]],63802:[[40442]],63803:[[30860]],63804:[[31103]],63805:[[32160]],63806:[[33737]],63807:[[37636]],63808:[[40575]],63809:[[35542]],63810:[[22751]],63811:[[24324]],63812:[[31840]],63813:[[32894]],63814:[[29282]],63815:[[30922]],63816:[[36034]],63817:[[38647]],63818:[[22744]],63819:[[23650]],63820:[[27155]],63821:[[28122]],63822:[[28431]],63823:[[32047]],63824:[[32311]],63825:[[38475]],63826:[[21202]],63827:[[32907]],63828:[[20956]],63829:[[20940]],63830:[[31260]],63831:[[32190]],63832:[[33777]],63833:[[38517]],63834:[[35712]],63835:[[25295]],63836:[[27138]],63837:[[35582]],63838:[[20025]],63839:[[23527]],63840:[[24594]],63841:[[29575]],63842:[[30064]],63843:[[21271]],63844:[[30971]],63845:[[20415]],63846:[[24489]],63847:[[19981]],63848:[[27852]],63849:[[25976]],63850:[[32034]],63851:[[21443]],63852:[[22622]],63853:[[30465]],63854:[[33865]],63855:[[35498]],63856:[[27578]],63857:[[36784]],63858:[[27784]],63859:[[25342]],63860:[[33509]],63861:[[25504]],63862:[[30053]],63863:[[20142]],63864:[[20841]],63865:[[20937]],63866:[[26753]],63867:[[31975]],63868:[[33391]],63869:[[35538]],63870:[[37327]],63871:[[21237]],63872:[[21570]],63873:[[22899]],63874:[[24300]],63875:[[26053]],63876:[[28670]],63877:[[31018]],63878:[[38317]],63879:[[39530]],63880:[[40599]],63881:[[40654]],63882:[[21147]],63883:[[26310]],63884:[[27511]],63885:[[36706]],63886:[[24180]],63887:[[24976]],63888:[[25088]],63889:[[25754]],63890:[[28451]],63891:[[29001]],63892:[[29833]],63893:[[31178]],63894:[[32244]],63895:[[32879]],63896:[[36646]],63897:[[34030]],63898:[[36899]],63899:[[37706]],63900:[[21015]],63901:[[21155]],63902:[[21693]],63903:[[28872]],63904:[[35010]],63905:[[35498]],63906:[[24265]],63907:[[24565]],63908:[[25467]],63909:[[27566]],63910:[[31806]],63911:[[29557]],63912:[[20196]],63913:[[22265]],63914:[[23527]],63915:[[23994]],63916:[[24604]],63917:[[29618]],63918:[[29801]],63919:[[32666]],63920:[[32838]],63921:[[37428]],63922:[[38646]],63923:[[38728]],63924:[[38936]],63925:[[20363]],63926:[[31150]],63927:[[37300]],63928:[[38584]],63929:[[24801]],63930:[[20102]],63931:[[20698]],63932:[[23534]],63933:[[23615]],63934:[[26009]],63935:[[27138]],63936:[[29134]],63937:[[30274]],63938:[[34044]],63939:[[36988]],63940:[[40845]],63941:[[26248]],63942:[[38446]],63943:[[21129]],63944:[[26491]],63945:[[26611]],63946:[[27969]],63947:[[28316]],63948:[[29705]],63949:[[30041]],63950:[[30827]],63951:[[32016]],63952:[[39006]],63953:[[20845]],63954:[[25134]],63955:[[38520]],63956:[[20523]],63957:[[23833]],63958:[[28138]],63959:[[36650]],63960:[[24459]],63961:[[24900]],63962:[[26647]],63963:[[29575]],63964:[[38534]],63965:[[21033]],63966:[[21519]],63967:[[23653]],63968:[[26131]],63969:[[26446]],63970:[[26792]],63971:[[27877]],63972:[[29702]],63973:[[30178]],63974:[[32633]],63975:[[35023]],63976:[[35041]],63977:[[37324]],63978:[[38626]],63979:[[21311]],63980:[[28346]],63981:[[21533]],63982:[[29136]],63983:[[29848]],63984:[[34298]],63985:[[38563]],63986:[[40023]],63987:[[40607]],63988:[[26519]],63989:[[28107]],63990:[[33256]],63991:[[31435]],63992:[[31520]],63993:[[31890]],63994:[[29376]],63995:[[28825]],63996:[[35672]],63997:[[20160]],63998:[[33590]],63999:[[21050]],194816:[[27966]],194817:[[28023]],194818:[[27969]],194819:[[28009]],194820:[[28024]],194821:[[28037]],194822:[[146718]],194823:[[27956]],194824:[[28207]],194825:[[28270]],194826:[[15667]],194827:[[28363]],194828:[[28359]],194829:[[147153]],194830:[[28153]],194831:[[28526]],194832:[[147294]],194833:[[147342]],194834:[[28614]],194835:[[28729]],194836:[[28702]],194837:[[28699]],194838:[[15766]],194839:[[28746]],194840:[[28797]],194841:[[28791]],194842:[[28845]],194843:[[132389]],194844:[[28997]],194845:[[148067]],194846:[[29084]],194847:[[148395]],194848:[[29224]],194849:[[29237]],194850:[[29264]],194851:[[149000]],194852:[[29312]],194853:[[29333]],194854:[[149301]],194855:[[149524]],194856:[[29562]],194857:[[29579]],194858:[[16044]],194859:[[29605]],194860:[[16056]],194861:[[16056]],194862:[[29767]],194863:[[29788]],194864:[[29809]],194865:[[29829]],194866:[[29898]],194867:[[16155]],194868:[[29988]],194869:[[150582]],194870:[[30014]],194871:[[150674]],194872:[[30064]],194873:[[139679]],194874:[[30224]],194875:[[151457]],194876:[[151480]],194877:[[151620]],194878:[[16380]],194879:[[16392]],194880:[[30452]],194881:[[151795]],194882:[[151794]],194883:[[151833]],194884:[[151859]],194885:[[30494]],194886:[[30495]],194887:[[30495]],194888:[[30538]],194889:[[16441]],194890:[[30603]],194891:[[16454]],194892:[[16534]],194893:[[152605]],194894:[[30798]],194895:[[30860]],194896:[[30924]],194897:[[16611]],194898:[[153126]],194899:[[31062]],194900:[[153242]],194901:[[153285]],194902:[[31119]],194903:[[31211]],194904:[[16687]],194905:[[31296]],194906:[[31306]],194907:[[31311]],194908:[[153980]],194909:[[154279]],194910:[[154279]],194911:[[31470]],194912:[[16898]],194913:[[154539]],194914:[[31686]],194915:[[31689]],194916:[[16935]],194917:[[154752]],194918:[[31954]],194919:[[17056]],194920:[[31976]],194921:[[31971]],194922:[[32000]],194923:[[155526]],194924:[[32099]],194925:[[17153]],194926:[[32199]],194927:[[32258]],194928:[[32325]],194929:[[17204]],194930:[[156200]],194931:[[156231]],194932:[[17241]],194933:[[156377]],194934:[[32634]],194935:[[156478]],194936:[[32661]],194937:[[32762]],194938:[[32773]],194939:[[156890]],194940:[[156963]],194941:[[32864]],194942:[[157096]],194943:[[32880]],194944:[[144223]],194945:[[17365]],194946:[[32946]],194947:[[33027]],194948:[[17419]],194949:[[33086]],194950:[[23221]],194951:[[157607]],194952:[[157621]],194953:[[144275]],194954:[[144284]],194955:[[33281]],194956:[[33284]],194957:[[36766]],194958:[[17515]],194959:[[33425]],194960:[[33419]],194961:[[33437]],194962:[[21171]],194963:[[33457]],194964:[[33459]],194965:[[33469]],194966:[[33510]],194967:[[158524]],194968:[[33509]],194969:[[33565]],194970:[[33635]],194971:[[33709]],194972:[[33571]],194973:[[33725]],194974:[[33767]],194975:[[33879]],194976:[[33619]],194977:[[33738]],194978:[[33740]],194979:[[33756]],194980:[[158774]],194981:[[159083]],194982:[[158933]],194983:[[17707]],194984:[[34033]],194985:[[34035]],194986:[[34070]],194987:[[160714]],194988:[[34148]],194989:[[159532]],194990:[[17757]],194991:[[17761]],194992:[[159665]],194993:[[159954]],194994:[[17771]],194995:[[34384]],194996:[[34396]],194997:[[34407]],194998:[[34409]],194999:[[34473]],195000:[[34440]],195001:[[34574]],195002:[[34530]],195003:[[34681]],195004:[[34600]],195005:[[34667]],195006:[[34694]],195007:[[17879]],195008:[[34785]],195009:[[34817]],195010:[[17913]],195011:[[34912]],195012:[[34915]],195013:[[161383]],195014:[[35031]],195015:[[35038]],195016:[[17973]],195017:[[35066]],195018:[[13499]],195019:[[161966]],195020:[[162150]],195021:[[18110]],195022:[[18119]],195023:[[35488]],195024:[[35565]],195025:[[35722]],195026:[[35925]],195027:[[162984]],195028:[[36011]],195029:[[36033]],195030:[[36123]],195031:[[36215]],195032:[[163631]],195033:[[133124]],195034:[[36299]],195035:[[36284]],195036:[[36336]],195037:[[133342]],195038:[[36564]],195039:[[36664]],195040:[[165330]],195041:[[165357]],195042:[[37012]],195043:[[37105]],195044:[[37137]],195045:[[165678]],195046:[[37147]],195047:[[37432]],195048:[[37591]],195049:[[37592]],195050:[[37500]],195051:[[37881]],195052:[[37909]],195053:[[166906]],195054:[[38283]],195055:[[18837]],195056:[[38327]],195057:[[167287]],195058:[[18918]],195059:[[38595]],195060:[[23986]],195061:[[38691]],195062:[[168261]],195063:[[168474]],195064:[[19054]],195065:[[19062]],195066:[[38880]],195067:[[168970]],195068:[[19122]],195069:[[169110]],195070:[[38923]],195071:[[38923]]}, + 64000:{64000:[[20999]],64001:[[24230]],64002:[[25299]],64003:[[31958]],64004:[[23429]],64005:[[27934]],64006:[[26292]],64007:[[36667]],64008:[[34892]],64009:[[38477]],64010:[[35211]],64011:[[24275]],64012:[[20800]],64013:[[21952]],64016:[[22618]],64018:[[26228]],64021:[[20958]],64022:[[29482]],64023:[[30410]],64024:[[31036]],64025:[[31070]],64026:[[31077]],64027:[[31119]],64028:[[38742]],64029:[[31934]],64030:[[32701]],64032:[[34322]],64034:[[35576]],64037:[[36920]],64038:[[37117]],64042:[[39151]],64043:[[39164]],64044:[[39208]],64045:[[40372]],64046:[[37086]],64047:[[38583]],64048:[[20398]],64049:[[20711]],64050:[[20813]],64051:[[21193]],64052:[[21220]],64053:[[21329]],64054:[[21917]],64055:[[22022]],64056:[[22120]],64057:[[22592]],64058:[[22696]],64059:[[23652]],64060:[[23662]],64061:[[24724]],64062:[[24936]],64063:[[24974]],64064:[[25074]],64065:[[25935]],64066:[[26082]],64067:[[26257]],64068:[[26757]],64069:[[28023]],64070:[[28186]],64071:[[28450]],64072:[[29038]],64073:[[29227]],64074:[[29730]],64075:[[30865]],64076:[[31038]],64077:[[31049]],64078:[[31048]],64079:[[31056]],64080:[[31062]],64081:[[31069]],64082:[[31117]],64083:[[31118]],64084:[[31296]],64085:[[31361]],64086:[[31680]],64087:[[32244]],64088:[[32265]],64089:[[32321]],64090:[[32626]],64091:[[32773]],64092:[[33261]],64093:[[33401]],64094:[[33401]],64095:[[33879]],64096:[[35088]],64097:[[35222]],64098:[[35585]],64099:[[35641]],64100:[[36051]],64101:[[36104]],64102:[[36790]],64103:[[36920]],64104:[[38627]],64105:[[38911]],64106:[[38971]],64107:[[24693]],64108:[[148206]],64109:[[33304]],64112:[[20006]],64113:[[20917]],64114:[[20840]],64115:[[20352]],64116:[[20805]],64117:[[20864]],64118:[[21191]],64119:[[21242]],64120:[[21917]],64121:[[21845]],64122:[[21913]],64123:[[21986]],64124:[[22618]],64125:[[22707]],64126:[[22852]],64127:[[22868]],64128:[[23138]],64129:[[23336]],64130:[[24274]],64131:[[24281]],64132:[[24425]],64133:[[24493]],64134:[[24792]],64135:[[24910]],64136:[[24840]],64137:[[24974]],64138:[[24928]],64139:[[25074]],64140:[[25140]],64141:[[25540]],64142:[[25628]],64143:[[25682]],64144:[[25942]],64145:[[26228]],64146:[[26391]],64147:[[26395]],64148:[[26454]],64149:[[27513]],64150:[[27578]],64151:[[27969]],64152:[[28379]],64153:[[28363]],64154:[[28450]],64155:[[28702]],64156:[[29038]],64157:[[30631]],64158:[[29237]],64159:[[29359]],64160:[[29482]],64161:[[29809]],64162:[[29958]],64163:[[30011]],64164:[[30237]],64165:[[30239]],64166:[[30410]],64167:[[30427]],64168:[[30452]],64169:[[30538]],64170:[[30528]],64171:[[30924]],64172:[[31409]],64173:[[31680]],64174:[[31867]],64175:[[32091]],64176:[[32244]],64177:[[32574]],64178:[[32773]],64179:[[33618]],64180:[[33775]],64181:[[34681]],64182:[[35137]],64183:[[35206]],64184:[[35222]],64185:[[35519]],64186:[[35576]],64187:[[35531]],64188:[[35585]],64189:[[35582]],64190:[[35565]],64191:[[35641]],64192:[[35722]],64193:[[36104]],64194:[[36664]],64195:[[36978]],64196:[[37273]],64197:[[37494]],64198:[[38524]],64199:[[38627]],64200:[[38742]],64201:[[38875]],64202:[[38911]],64203:[[38923]],64204:[[38971]],64205:[[39698]],64206:[[40860]],64207:[[141386]],64208:[[141380]],64209:[[144341]],64210:[[15261]],64211:[[16408]],64212:[[16441]],64213:[[152137]],64214:[[154832]],64215:[[163539]],64216:[[40771]],64217:[[40846]],195072:[[38953]],195073:[[169398]],195074:[[39138]],195075:[[19251]],195076:[[39209]],195077:[[39335]],195078:[[39362]],195079:[[39422]],195080:[[19406]],195081:[[170800]],195082:[[39698]],195083:[[40000]],195084:[[40189]],195085:[[19662]],195086:[[19693]],195087:[[40295]],195088:[[172238]],195089:[[19704]],195090:[[172293]],195091:[[172558]],195092:[[172689]],195093:[[40635]],195094:[[19798]],195095:[[40697]],195096:[[40702]],195097:[[40709]],195098:[[40719]],195099:[[40726]],195100:[[40763]],195101:[[173568]]}, + 64256:{64256:[[102,102],256],64257:[[102,105],256],64258:[[102,108],256],64259:[[102,102,105],256],64260:[[102,102,108],256],64261:[[383,116],256],64262:[[115,116],256],64275:[[1396,1398],256],64276:[[1396,1381],256],64277:[[1396,1387],256],64278:[[1406,1398],256],64279:[[1396,1389],256],64285:[[1497,1460],512],64286:[,26],64287:[[1522,1463],512],64288:[[1506],256],64289:[[1488],256],64290:[[1491],256],64291:[[1492],256],64292:[[1499],256],64293:[[1500],256],64294:[[1501],256],64295:[[1512],256],64296:[[1514],256],64297:[[43],256],64298:[[1513,1473],512],64299:[[1513,1474],512],64300:[[64329,1473],512],64301:[[64329,1474],512],64302:[[1488,1463],512],64303:[[1488,1464],512],64304:[[1488,1468],512],64305:[[1489,1468],512],64306:[[1490,1468],512],64307:[[1491,1468],512],64308:[[1492,1468],512],64309:[[1493,1468],512],64310:[[1494,1468],512],64312:[[1496,1468],512],64313:[[1497,1468],512],64314:[[1498,1468],512],64315:[[1499,1468],512],64316:[[1500,1468],512],64318:[[1502,1468],512],64320:[[1504,1468],512],64321:[[1505,1468],512],64323:[[1507,1468],512],64324:[[1508,1468],512],64326:[[1510,1468],512],64327:[[1511,1468],512],64328:[[1512,1468],512],64329:[[1513,1468],512],64330:[[1514,1468],512],64331:[[1493,1465],512],64332:[[1489,1471],512],64333:[[1499,1471],512],64334:[[1508,1471],512],64335:[[1488,1500],256],64336:[[1649],256],64337:[[1649],256],64338:[[1659],256],64339:[[1659],256],64340:[[1659],256],64341:[[1659],256],64342:[[1662],256],64343:[[1662],256],64344:[[1662],256],64345:[[1662],256],64346:[[1664],256],64347:[[1664],256],64348:[[1664],256],64349:[[1664],256],64350:[[1658],256],64351:[[1658],256],64352:[[1658],256],64353:[[1658],256],64354:[[1663],256],64355:[[1663],256],64356:[[1663],256],64357:[[1663],256],64358:[[1657],256],64359:[[1657],256],64360:[[1657],256],64361:[[1657],256],64362:[[1700],256],64363:[[1700],256],64364:[[1700],256],64365:[[1700],256],64366:[[1702],256],64367:[[1702],256],64368:[[1702],256],64369:[[1702],256],64370:[[1668],256],64371:[[1668],256],64372:[[1668],256],64373:[[1668],256],64374:[[1667],256],64375:[[1667],256],64376:[[1667],256],64377:[[1667],256],64378:[[1670],256],64379:[[1670],256],64380:[[1670],256],64381:[[1670],256],64382:[[1671],256],64383:[[1671],256],64384:[[1671],256],64385:[[1671],256],64386:[[1677],256],64387:[[1677],256],64388:[[1676],256],64389:[[1676],256],64390:[[1678],256],64391:[[1678],256],64392:[[1672],256],64393:[[1672],256],64394:[[1688],256],64395:[[1688],256],64396:[[1681],256],64397:[[1681],256],64398:[[1705],256],64399:[[1705],256],64400:[[1705],256],64401:[[1705],256],64402:[[1711],256],64403:[[1711],256],64404:[[1711],256],64405:[[1711],256],64406:[[1715],256],64407:[[1715],256],64408:[[1715],256],64409:[[1715],256],64410:[[1713],256],64411:[[1713],256],64412:[[1713],256],64413:[[1713],256],64414:[[1722],256],64415:[[1722],256],64416:[[1723],256],64417:[[1723],256],64418:[[1723],256],64419:[[1723],256],64420:[[1728],256],64421:[[1728],256],64422:[[1729],256],64423:[[1729],256],64424:[[1729],256],64425:[[1729],256],64426:[[1726],256],64427:[[1726],256],64428:[[1726],256],64429:[[1726],256],64430:[[1746],256],64431:[[1746],256],64432:[[1747],256],64433:[[1747],256],64467:[[1709],256],64468:[[1709],256],64469:[[1709],256],64470:[[1709],256],64471:[[1735],256],64472:[[1735],256],64473:[[1734],256],64474:[[1734],256],64475:[[1736],256],64476:[[1736],256],64477:[[1655],256],64478:[[1739],256],64479:[[1739],256],64480:[[1733],256],64481:[[1733],256],64482:[[1737],256],64483:[[1737],256],64484:[[1744],256],64485:[[1744],256],64486:[[1744],256],64487:[[1744],256],64488:[[1609],256],64489:[[1609],256],64490:[[1574,1575],256],64491:[[1574,1575],256],64492:[[1574,1749],256],64493:[[1574,1749],256],64494:[[1574,1608],256],64495:[[1574,1608],256],64496:[[1574,1735],256],64497:[[1574,1735],256],64498:[[1574,1734],256],64499:[[1574,1734],256],64500:[[1574,1736],256],64501:[[1574,1736],256],64502:[[1574,1744],256],64503:[[1574,1744],256],64504:[[1574,1744],256],64505:[[1574,1609],256],64506:[[1574,1609],256],64507:[[1574,1609],256],64508:[[1740],256],64509:[[1740],256],64510:[[1740],256],64511:[[1740],256]}, + 64512:{64512:[[1574,1580],256],64513:[[1574,1581],256],64514:[[1574,1605],256],64515:[[1574,1609],256],64516:[[1574,1610],256],64517:[[1576,1580],256],64518:[[1576,1581],256],64519:[[1576,1582],256],64520:[[1576,1605],256],64521:[[1576,1609],256],64522:[[1576,1610],256],64523:[[1578,1580],256],64524:[[1578,1581],256],64525:[[1578,1582],256],64526:[[1578,1605],256],64527:[[1578,1609],256],64528:[[1578,1610],256],64529:[[1579,1580],256],64530:[[1579,1605],256],64531:[[1579,1609],256],64532:[[1579,1610],256],64533:[[1580,1581],256],64534:[[1580,1605],256],64535:[[1581,1580],256],64536:[[1581,1605],256],64537:[[1582,1580],256],64538:[[1582,1581],256],64539:[[1582,1605],256],64540:[[1587,1580],256],64541:[[1587,1581],256],64542:[[1587,1582],256],64543:[[1587,1605],256],64544:[[1589,1581],256],64545:[[1589,1605],256],64546:[[1590,1580],256],64547:[[1590,1581],256],64548:[[1590,1582],256],64549:[[1590,1605],256],64550:[[1591,1581],256],64551:[[1591,1605],256],64552:[[1592,1605],256],64553:[[1593,1580],256],64554:[[1593,1605],256],64555:[[1594,1580],256],64556:[[1594,1605],256],64557:[[1601,1580],256],64558:[[1601,1581],256],64559:[[1601,1582],256],64560:[[1601,1605],256],64561:[[1601,1609],256],64562:[[1601,1610],256],64563:[[1602,1581],256],64564:[[1602,1605],256],64565:[[1602,1609],256],64566:[[1602,1610],256],64567:[[1603,1575],256],64568:[[1603,1580],256],64569:[[1603,1581],256],64570:[[1603,1582],256],64571:[[1603,1604],256],64572:[[1603,1605],256],64573:[[1603,1609],256],64574:[[1603,1610],256],64575:[[1604,1580],256],64576:[[1604,1581],256],64577:[[1604,1582],256],64578:[[1604,1605],256],64579:[[1604,1609],256],64580:[[1604,1610],256],64581:[[1605,1580],256],64582:[[1605,1581],256],64583:[[1605,1582],256],64584:[[1605,1605],256],64585:[[1605,1609],256],64586:[[1605,1610],256],64587:[[1606,1580],256],64588:[[1606,1581],256],64589:[[1606,1582],256],64590:[[1606,1605],256],64591:[[1606,1609],256],64592:[[1606,1610],256],64593:[[1607,1580],256],64594:[[1607,1605],256],64595:[[1607,1609],256],64596:[[1607,1610],256],64597:[[1610,1580],256],64598:[[1610,1581],256],64599:[[1610,1582],256],64600:[[1610,1605],256],64601:[[1610,1609],256],64602:[[1610,1610],256],64603:[[1584,1648],256],64604:[[1585,1648],256],64605:[[1609,1648],256],64606:[[32,1612,1617],256],64607:[[32,1613,1617],256],64608:[[32,1614,1617],256],64609:[[32,1615,1617],256],64610:[[32,1616,1617],256],64611:[[32,1617,1648],256],64612:[[1574,1585],256],64613:[[1574,1586],256],64614:[[1574,1605],256],64615:[[1574,1606],256],64616:[[1574,1609],256],64617:[[1574,1610],256],64618:[[1576,1585],256],64619:[[1576,1586],256],64620:[[1576,1605],256],64621:[[1576,1606],256],64622:[[1576,1609],256],64623:[[1576,1610],256],64624:[[1578,1585],256],64625:[[1578,1586],256],64626:[[1578,1605],256],64627:[[1578,1606],256],64628:[[1578,1609],256],64629:[[1578,1610],256],64630:[[1579,1585],256],64631:[[1579,1586],256],64632:[[1579,1605],256],64633:[[1579,1606],256],64634:[[1579,1609],256],64635:[[1579,1610],256],64636:[[1601,1609],256],64637:[[1601,1610],256],64638:[[1602,1609],256],64639:[[1602,1610],256],64640:[[1603,1575],256],64641:[[1603,1604],256],64642:[[1603,1605],256],64643:[[1603,1609],256],64644:[[1603,1610],256],64645:[[1604,1605],256],64646:[[1604,1609],256],64647:[[1604,1610],256],64648:[[1605,1575],256],64649:[[1605,1605],256],64650:[[1606,1585],256],64651:[[1606,1586],256],64652:[[1606,1605],256],64653:[[1606,1606],256],64654:[[1606,1609],256],64655:[[1606,1610],256],64656:[[1609,1648],256],64657:[[1610,1585],256],64658:[[1610,1586],256],64659:[[1610,1605],256],64660:[[1610,1606],256],64661:[[1610,1609],256],64662:[[1610,1610],256],64663:[[1574,1580],256],64664:[[1574,1581],256],64665:[[1574,1582],256],64666:[[1574,1605],256],64667:[[1574,1607],256],64668:[[1576,1580],256],64669:[[1576,1581],256],64670:[[1576,1582],256],64671:[[1576,1605],256],64672:[[1576,1607],256],64673:[[1578,1580],256],64674:[[1578,1581],256],64675:[[1578,1582],256],64676:[[1578,1605],256],64677:[[1578,1607],256],64678:[[1579,1605],256],64679:[[1580,1581],256],64680:[[1580,1605],256],64681:[[1581,1580],256],64682:[[1581,1605],256],64683:[[1582,1580],256],64684:[[1582,1605],256],64685:[[1587,1580],256],64686:[[1587,1581],256],64687:[[1587,1582],256],64688:[[1587,1605],256],64689:[[1589,1581],256],64690:[[1589,1582],256],64691:[[1589,1605],256],64692:[[1590,1580],256],64693:[[1590,1581],256],64694:[[1590,1582],256],64695:[[1590,1605],256],64696:[[1591,1581],256],64697:[[1592,1605],256],64698:[[1593,1580],256],64699:[[1593,1605],256],64700:[[1594,1580],256],64701:[[1594,1605],256],64702:[[1601,1580],256],64703:[[1601,1581],256],64704:[[1601,1582],256],64705:[[1601,1605],256],64706:[[1602,1581],256],64707:[[1602,1605],256],64708:[[1603,1580],256],64709:[[1603,1581],256],64710:[[1603,1582],256],64711:[[1603,1604],256],64712:[[1603,1605],256],64713:[[1604,1580],256],64714:[[1604,1581],256],64715:[[1604,1582],256],64716:[[1604,1605],256],64717:[[1604,1607],256],64718:[[1605,1580],256],64719:[[1605,1581],256],64720:[[1605,1582],256],64721:[[1605,1605],256],64722:[[1606,1580],256],64723:[[1606,1581],256],64724:[[1606,1582],256],64725:[[1606,1605],256],64726:[[1606,1607],256],64727:[[1607,1580],256],64728:[[1607,1605],256],64729:[[1607,1648],256],64730:[[1610,1580],256],64731:[[1610,1581],256],64732:[[1610,1582],256],64733:[[1610,1605],256],64734:[[1610,1607],256],64735:[[1574,1605],256],64736:[[1574,1607],256],64737:[[1576,1605],256],64738:[[1576,1607],256],64739:[[1578,1605],256],64740:[[1578,1607],256],64741:[[1579,1605],256],64742:[[1579,1607],256],64743:[[1587,1605],256],64744:[[1587,1607],256],64745:[[1588,1605],256],64746:[[1588,1607],256],64747:[[1603,1604],256],64748:[[1603,1605],256],64749:[[1604,1605],256],64750:[[1606,1605],256],64751:[[1606,1607],256],64752:[[1610,1605],256],64753:[[1610,1607],256],64754:[[1600,1614,1617],256],64755:[[1600,1615,1617],256],64756:[[1600,1616,1617],256],64757:[[1591,1609],256],64758:[[1591,1610],256],64759:[[1593,1609],256],64760:[[1593,1610],256],64761:[[1594,1609],256],64762:[[1594,1610],256],64763:[[1587,1609],256],64764:[[1587,1610],256],64765:[[1588,1609],256],64766:[[1588,1610],256],64767:[[1581,1609],256]}, + 64768:{64768:[[1581,1610],256],64769:[[1580,1609],256],64770:[[1580,1610],256],64771:[[1582,1609],256],64772:[[1582,1610],256],64773:[[1589,1609],256],64774:[[1589,1610],256],64775:[[1590,1609],256],64776:[[1590,1610],256],64777:[[1588,1580],256],64778:[[1588,1581],256],64779:[[1588,1582],256],64780:[[1588,1605],256],64781:[[1588,1585],256],64782:[[1587,1585],256],64783:[[1589,1585],256],64784:[[1590,1585],256],64785:[[1591,1609],256],64786:[[1591,1610],256],64787:[[1593,1609],256],64788:[[1593,1610],256],64789:[[1594,1609],256],64790:[[1594,1610],256],64791:[[1587,1609],256],64792:[[1587,1610],256],64793:[[1588,1609],256],64794:[[1588,1610],256],64795:[[1581,1609],256],64796:[[1581,1610],256],64797:[[1580,1609],256],64798:[[1580,1610],256],64799:[[1582,1609],256],64800:[[1582,1610],256],64801:[[1589,1609],256],64802:[[1589,1610],256],64803:[[1590,1609],256],64804:[[1590,1610],256],64805:[[1588,1580],256],64806:[[1588,1581],256],64807:[[1588,1582],256],64808:[[1588,1605],256],64809:[[1588,1585],256],64810:[[1587,1585],256],64811:[[1589,1585],256],64812:[[1590,1585],256],64813:[[1588,1580],256],64814:[[1588,1581],256],64815:[[1588,1582],256],64816:[[1588,1605],256],64817:[[1587,1607],256],64818:[[1588,1607],256],64819:[[1591,1605],256],64820:[[1587,1580],256],64821:[[1587,1581],256],64822:[[1587,1582],256],64823:[[1588,1580],256],64824:[[1588,1581],256],64825:[[1588,1582],256],64826:[[1591,1605],256],64827:[[1592,1605],256],64828:[[1575,1611],256],64829:[[1575,1611],256],64848:[[1578,1580,1605],256],64849:[[1578,1581,1580],256],64850:[[1578,1581,1580],256],64851:[[1578,1581,1605],256],64852:[[1578,1582,1605],256],64853:[[1578,1605,1580],256],64854:[[1578,1605,1581],256],64855:[[1578,1605,1582],256],64856:[[1580,1605,1581],256],64857:[[1580,1605,1581],256],64858:[[1581,1605,1610],256],64859:[[1581,1605,1609],256],64860:[[1587,1581,1580],256],64861:[[1587,1580,1581],256],64862:[[1587,1580,1609],256],64863:[[1587,1605,1581],256],64864:[[1587,1605,1581],256],64865:[[1587,1605,1580],256],64866:[[1587,1605,1605],256],64867:[[1587,1605,1605],256],64868:[[1589,1581,1581],256],64869:[[1589,1581,1581],256],64870:[[1589,1605,1605],256],64871:[[1588,1581,1605],256],64872:[[1588,1581,1605],256],64873:[[1588,1580,1610],256],64874:[[1588,1605,1582],256],64875:[[1588,1605,1582],256],64876:[[1588,1605,1605],256],64877:[[1588,1605,1605],256],64878:[[1590,1581,1609],256],64879:[[1590,1582,1605],256],64880:[[1590,1582,1605],256],64881:[[1591,1605,1581],256],64882:[[1591,1605,1581],256],64883:[[1591,1605,1605],256],64884:[[1591,1605,1610],256],64885:[[1593,1580,1605],256],64886:[[1593,1605,1605],256],64887:[[1593,1605,1605],256],64888:[[1593,1605,1609],256],64889:[[1594,1605,1605],256],64890:[[1594,1605,1610],256],64891:[[1594,1605,1609],256],64892:[[1601,1582,1605],256],64893:[[1601,1582,1605],256],64894:[[1602,1605,1581],256],64895:[[1602,1605,1605],256],64896:[[1604,1581,1605],256],64897:[[1604,1581,1610],256],64898:[[1604,1581,1609],256],64899:[[1604,1580,1580],256],64900:[[1604,1580,1580],256],64901:[[1604,1582,1605],256],64902:[[1604,1582,1605],256],64903:[[1604,1605,1581],256],64904:[[1604,1605,1581],256],64905:[[1605,1581,1580],256],64906:[[1605,1581,1605],256],64907:[[1605,1581,1610],256],64908:[[1605,1580,1581],256],64909:[[1605,1580,1605],256],64910:[[1605,1582,1580],256],64911:[[1605,1582,1605],256],64914:[[1605,1580,1582],256],64915:[[1607,1605,1580],256],64916:[[1607,1605,1605],256],64917:[[1606,1581,1605],256],64918:[[1606,1581,1609],256],64919:[[1606,1580,1605],256],64920:[[1606,1580,1605],256],64921:[[1606,1580,1609],256],64922:[[1606,1605,1610],256],64923:[[1606,1605,1609],256],64924:[[1610,1605,1605],256],64925:[[1610,1605,1605],256],64926:[[1576,1582,1610],256],64927:[[1578,1580,1610],256],64928:[[1578,1580,1609],256],64929:[[1578,1582,1610],256],64930:[[1578,1582,1609],256],64931:[[1578,1605,1610],256],64932:[[1578,1605,1609],256],64933:[[1580,1605,1610],256],64934:[[1580,1581,1609],256],64935:[[1580,1605,1609],256],64936:[[1587,1582,1609],256],64937:[[1589,1581,1610],256],64938:[[1588,1581,1610],256],64939:[[1590,1581,1610],256],64940:[[1604,1580,1610],256],64941:[[1604,1605,1610],256],64942:[[1610,1581,1610],256],64943:[[1610,1580,1610],256],64944:[[1610,1605,1610],256],64945:[[1605,1605,1610],256],64946:[[1602,1605,1610],256],64947:[[1606,1581,1610],256],64948:[[1602,1605,1581],256],64949:[[1604,1581,1605],256],64950:[[1593,1605,1610],256],64951:[[1603,1605,1610],256],64952:[[1606,1580,1581],256],64953:[[1605,1582,1610],256],64954:[[1604,1580,1605],256],64955:[[1603,1605,1605],256],64956:[[1604,1580,1605],256],64957:[[1606,1580,1581],256],64958:[[1580,1581,1610],256],64959:[[1581,1580,1610],256],64960:[[1605,1580,1610],256],64961:[[1601,1605,1610],256],64962:[[1576,1581,1610],256],64963:[[1603,1605,1605],256],64964:[[1593,1580,1605],256],64965:[[1589,1605,1605],256],64966:[[1587,1582,1610],256],64967:[[1606,1580,1610],256],65008:[[1589,1604,1746],256],65009:[[1602,1604,1746],256],65010:[[1575,1604,1604,1607],256],65011:[[1575,1603,1576,1585],256],65012:[[1605,1581,1605,1583],256],65013:[[1589,1604,1593,1605],256],65014:[[1585,1587,1608,1604],256],65015:[[1593,1604,1610,1607],256],65016:[[1608,1587,1604,1605],256],65017:[[1589,1604,1609],256],65018:[[1589,1604,1609,32,1575,1604,1604,1607,32,1593,1604,1610,1607,32,1608,1587,1604,1605],256],65019:[[1580,1604,32,1580,1604,1575,1604,1607],256],65020:[[1585,1740,1575,1604],256]}, + 65024:{65040:[[44],256],65041:[[12289],256],65042:[[12290],256],65043:[[58],256],65044:[[59],256],65045:[[33],256],65046:[[63],256],65047:[[12310],256],65048:[[12311],256],65049:[[8230],256],65056:[,230],65057:[,230],65058:[,230],65059:[,230],65060:[,230],65061:[,230],65062:[,230],65072:[[8229],256],65073:[[8212],256],65074:[[8211],256],65075:[[95],256],65076:[[95],256],65077:[[40],256],65078:[[41],256],65079:[[123],256],65080:[[125],256],65081:[[12308],256],65082:[[12309],256],65083:[[12304],256],65084:[[12305],256],65085:[[12298],256],65086:[[12299],256],65087:[[12296],256],65088:[[12297],256],65089:[[12300],256],65090:[[12301],256],65091:[[12302],256],65092:[[12303],256],65095:[[91],256],65096:[[93],256],65097:[[8254],256],65098:[[8254],256],65099:[[8254],256],65100:[[8254],256],65101:[[95],256],65102:[[95],256],65103:[[95],256],65104:[[44],256],65105:[[12289],256],65106:[[46],256],65108:[[59],256],65109:[[58],256],65110:[[63],256],65111:[[33],256],65112:[[8212],256],65113:[[40],256],65114:[[41],256],65115:[[123],256],65116:[[125],256],65117:[[12308],256],65118:[[12309],256],65119:[[35],256],65120:[[38],256],65121:[[42],256],65122:[[43],256],65123:[[45],256],65124:[[60],256],65125:[[62],256],65126:[[61],256],65128:[[92],256],65129:[[36],256],65130:[[37],256],65131:[[64],256],65136:[[32,1611],256],65137:[[1600,1611],256],65138:[[32,1612],256],65140:[[32,1613],256],65142:[[32,1614],256],65143:[[1600,1614],256],65144:[[32,1615],256],65145:[[1600,1615],256],65146:[[32,1616],256],65147:[[1600,1616],256],65148:[[32,1617],256],65149:[[1600,1617],256],65150:[[32,1618],256],65151:[[1600,1618],256],65152:[[1569],256],65153:[[1570],256],65154:[[1570],256],65155:[[1571],256],65156:[[1571],256],65157:[[1572],256],65158:[[1572],256],65159:[[1573],256],65160:[[1573],256],65161:[[1574],256],65162:[[1574],256],65163:[[1574],256],65164:[[1574],256],65165:[[1575],256],65166:[[1575],256],65167:[[1576],256],65168:[[1576],256],65169:[[1576],256],65170:[[1576],256],65171:[[1577],256],65172:[[1577],256],65173:[[1578],256],65174:[[1578],256],65175:[[1578],256],65176:[[1578],256],65177:[[1579],256],65178:[[1579],256],65179:[[1579],256],65180:[[1579],256],65181:[[1580],256],65182:[[1580],256],65183:[[1580],256],65184:[[1580],256],65185:[[1581],256],65186:[[1581],256],65187:[[1581],256],65188:[[1581],256],65189:[[1582],256],65190:[[1582],256],65191:[[1582],256],65192:[[1582],256],65193:[[1583],256],65194:[[1583],256],65195:[[1584],256],65196:[[1584],256],65197:[[1585],256],65198:[[1585],256],65199:[[1586],256],65200:[[1586],256],65201:[[1587],256],65202:[[1587],256],65203:[[1587],256],65204:[[1587],256],65205:[[1588],256],65206:[[1588],256],65207:[[1588],256],65208:[[1588],256],65209:[[1589],256],65210:[[1589],256],65211:[[1589],256],65212:[[1589],256],65213:[[1590],256],65214:[[1590],256],65215:[[1590],256],65216:[[1590],256],65217:[[1591],256],65218:[[1591],256],65219:[[1591],256],65220:[[1591],256],65221:[[1592],256],65222:[[1592],256],65223:[[1592],256],65224:[[1592],256],65225:[[1593],256],65226:[[1593],256],65227:[[1593],256],65228:[[1593],256],65229:[[1594],256],65230:[[1594],256],65231:[[1594],256],65232:[[1594],256],65233:[[1601],256],65234:[[1601],256],65235:[[1601],256],65236:[[1601],256],65237:[[1602],256],65238:[[1602],256],65239:[[1602],256],65240:[[1602],256],65241:[[1603],256],65242:[[1603],256],65243:[[1603],256],65244:[[1603],256],65245:[[1604],256],65246:[[1604],256],65247:[[1604],256],65248:[[1604],256],65249:[[1605],256],65250:[[1605],256],65251:[[1605],256],65252:[[1605],256],65253:[[1606],256],65254:[[1606],256],65255:[[1606],256],65256:[[1606],256],65257:[[1607],256],65258:[[1607],256],65259:[[1607],256],65260:[[1607],256],65261:[[1608],256],65262:[[1608],256],65263:[[1609],256],65264:[[1609],256],65265:[[1610],256],65266:[[1610],256],65267:[[1610],256],65268:[[1610],256],65269:[[1604,1570],256],65270:[[1604,1570],256],65271:[[1604,1571],256],65272:[[1604,1571],256],65273:[[1604,1573],256],65274:[[1604,1573],256],65275:[[1604,1575],256],65276:[[1604,1575],256]}, + 65280:{65281:[[33],256],65282:[[34],256],65283:[[35],256],65284:[[36],256],65285:[[37],256],65286:[[38],256],65287:[[39],256],65288:[[40],256],65289:[[41],256],65290:[[42],256],65291:[[43],256],65292:[[44],256],65293:[[45],256],65294:[[46],256],65295:[[47],256],65296:[[48],256],65297:[[49],256],65298:[[50],256],65299:[[51],256],65300:[[52],256],65301:[[53],256],65302:[[54],256],65303:[[55],256],65304:[[56],256],65305:[[57],256],65306:[[58],256],65307:[[59],256],65308:[[60],256],65309:[[61],256],65310:[[62],256],65311:[[63],256],65312:[[64],256],65313:[[65],256],65314:[[66],256],65315:[[67],256],65316:[[68],256],65317:[[69],256],65318:[[70],256],65319:[[71],256],65320:[[72],256],65321:[[73],256],65322:[[74],256],65323:[[75],256],65324:[[76],256],65325:[[77],256],65326:[[78],256],65327:[[79],256],65328:[[80],256],65329:[[81],256],65330:[[82],256],65331:[[83],256],65332:[[84],256],65333:[[85],256],65334:[[86],256],65335:[[87],256],65336:[[88],256],65337:[[89],256],65338:[[90],256],65339:[[91],256],65340:[[92],256],65341:[[93],256],65342:[[94],256],65343:[[95],256],65344:[[96],256],65345:[[97],256],65346:[[98],256],65347:[[99],256],65348:[[100],256],65349:[[101],256],65350:[[102],256],65351:[[103],256],65352:[[104],256],65353:[[105],256],65354:[[106],256],65355:[[107],256],65356:[[108],256],65357:[[109],256],65358:[[110],256],65359:[[111],256],65360:[[112],256],65361:[[113],256],65362:[[114],256],65363:[[115],256],65364:[[116],256],65365:[[117],256],65366:[[118],256],65367:[[119],256],65368:[[120],256],65369:[[121],256],65370:[[122],256],65371:[[123],256],65372:[[124],256],65373:[[125],256],65374:[[126],256],65375:[[10629],256],65376:[[10630],256],65377:[[12290],256],65378:[[12300],256],65379:[[12301],256],65380:[[12289],256],65381:[[12539],256],65382:[[12530],256],65383:[[12449],256],65384:[[12451],256],65385:[[12453],256],65386:[[12455],256],65387:[[12457],256],65388:[[12515],256],65389:[[12517],256],65390:[[12519],256],65391:[[12483],256],65392:[[12540],256],65393:[[12450],256],65394:[[12452],256],65395:[[12454],256],65396:[[12456],256],65397:[[12458],256],65398:[[12459],256],65399:[[12461],256],65400:[[12463],256],65401:[[12465],256],65402:[[12467],256],65403:[[12469],256],65404:[[12471],256],65405:[[12473],256],65406:[[12475],256],65407:[[12477],256],65408:[[12479],256],65409:[[12481],256],65410:[[12484],256],65411:[[12486],256],65412:[[12488],256],65413:[[12490],256],65414:[[12491],256],65415:[[12492],256],65416:[[12493],256],65417:[[12494],256],65418:[[12495],256],65419:[[12498],256],65420:[[12501],256],65421:[[12504],256],65422:[[12507],256],65423:[[12510],256],65424:[[12511],256],65425:[[12512],256],65426:[[12513],256],65427:[[12514],256],65428:[[12516],256],65429:[[12518],256],65430:[[12520],256],65431:[[12521],256],65432:[[12522],256],65433:[[12523],256],65434:[[12524],256],65435:[[12525],256],65436:[[12527],256],65437:[[12531],256],65438:[[12441],256],65439:[[12442],256],65440:[[12644],256],65441:[[12593],256],65442:[[12594],256],65443:[[12595],256],65444:[[12596],256],65445:[[12597],256],65446:[[12598],256],65447:[[12599],256],65448:[[12600],256],65449:[[12601],256],65450:[[12602],256],65451:[[12603],256],65452:[[12604],256],65453:[[12605],256],65454:[[12606],256],65455:[[12607],256],65456:[[12608],256],65457:[[12609],256],65458:[[12610],256],65459:[[12611],256],65460:[[12612],256],65461:[[12613],256],65462:[[12614],256],65463:[[12615],256],65464:[[12616],256],65465:[[12617],256],65466:[[12618],256],65467:[[12619],256],65468:[[12620],256],65469:[[12621],256],65470:[[12622],256],65474:[[12623],256],65475:[[12624],256],65476:[[12625],256],65477:[[12626],256],65478:[[12627],256],65479:[[12628],256],65482:[[12629],256],65483:[[12630],256],65484:[[12631],256],65485:[[12632],256],65486:[[12633],256],65487:[[12634],256],65490:[[12635],256],65491:[[12636],256],65492:[[12637],256],65493:[[12638],256],65494:[[12639],256],65495:[[12640],256],65498:[[12641],256],65499:[[12642],256],65500:[[12643],256],65504:[[162],256],65505:[[163],256],65506:[[172],256],65507:[[175],256],65508:[[166],256],65509:[[165],256],65510:[[8361],256],65512:[[9474],256],65513:[[8592],256],65514:[[8593],256],65515:[[8594],256],65516:[[8595],256],65517:[[9632],256],65518:[[9675],256]} +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/implement.js new file mode 100644 index 0000000..cfc710e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'normalize', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/index.js new file mode 100644 index 0000000..619b096 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.normalize + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/is-implemented.js new file mode 100644 index 0000000..67c8d8d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var str = 'æøåäüö'; + +module.exports = function () { + if (typeof str.normalize !== 'function') return false; + return str.normalize('NFKD') === 'æøåäüö'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/shim.js new file mode 100644 index 0000000..a379989 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/normalize/shim.js @@ -0,0 +1,289 @@ +// Taken from: https://github.com/walling/unorm/blob/master/lib/unorm.js + +/* + * UnicodeNormalizer 1.0.0 + * Copyright (c) 2008 Matsuza + * Dual licensed under the MIT (MIT-LICENSE.txt) and + * GPL (GPL-LICENSE.txt) licenses. + * $Date: 2008-06-05 16:44:17 +0200 (Thu, 05 Jun 2008) $ + * $Rev: 13309 $ +*/ + +'use strict'; + +var primitiveSet = require('../../../object/primitive-set') + , validValue = require('../../../object/valid-value') + , data = require('./_data') + + , floor = Math.floor + , forms = primitiveSet('NFC', 'NFD', 'NFKC', 'NFKD') + + , DEFAULT_FEATURE = [null, 0, {}], CACHE_THRESHOLD = 10, SBase = 0xAC00 + , LBase = 0x1100, VBase = 0x1161, TBase = 0x11A7, LCount = 19, VCount = 21 + , TCount = 28, NCount = VCount * TCount, SCount = LCount * NCount + , UChar, cache = {}, cacheCounter = [], i, fromCache, fromData, fromCpOnly + , fromRuleBasedJamo, fromCpFilter, strategies, UCharIterator + , RecursDecompIterator, DecompIterator, CompIterator, createIterator + , normalize; + +UChar = function (cp, feature) { + this.codepoint = cp; + this.feature = feature; +}; + +// Strategies +for (i = 0; i <= 0xFF; ++i) cacheCounter[i] = 0; + +fromCache = function (next, cp, needFeature) { + var ret = cache[cp]; + if (!ret) { + ret = next(cp, needFeature); + if (!!ret.feature && ++cacheCounter[(cp >> 8) & 0xFF] > CACHE_THRESHOLD) { + cache[cp] = ret; + } + } + return ret; +}; + +fromData = function (next, cp, needFeature) { + var hash = cp & 0xFF00, dunit = UChar.udata[hash] || {}, f = dunit[cp]; + return f ? new UChar(cp, f) : new UChar(cp, DEFAULT_FEATURE); +}; +fromCpOnly = function (next, cp, needFeature) { + return !!needFeature ? next(cp, needFeature) : new UChar(cp, null); +}; + +fromRuleBasedJamo = function (next, cp, needFeature) { + var c, base, i, arr, SIndex, TIndex, feature, j; + if (cp < LBase || (LBase + LCount <= cp && cp < SBase) || + (SBase + SCount < cp)) { + return next(cp, needFeature); + } + if (LBase <= cp && cp < LBase + LCount) { + c = {}; + base = (cp - LBase) * VCount; + for (i = 0; i < VCount; ++i) { + c[VBase + i] = SBase + TCount * (i + base); + } + arr = new Array(3); + arr[2] = c; + return new UChar(cp, arr); + } + + SIndex = cp - SBase; + TIndex = SIndex % TCount; + feature = []; + if (TIndex !== 0) { + feature[0] = [SBase + SIndex - TIndex, TBase + TIndex]; + } else { + feature[0] = [LBase + floor(SIndex / NCount), VBase + + floor((SIndex % NCount) / TCount)]; + feature[2] = {}; + for (j = 1; j < TCount; ++j) { + feature[2][TBase + j] = cp + j; + } + } + return new UChar(cp, feature); +}; + +fromCpFilter = function (next, cp, needFeature) { + return (cp < 60) || ((13311 < cp) && (cp < 42607)) + ? new UChar(cp, DEFAULT_FEATURE) : next(cp, needFeature); +}; + +strategies = [fromCpFilter, fromCache, fromCpOnly, fromRuleBasedJamo, fromData]; + +UChar.fromCharCode = strategies.reduceRight(function (next, strategy) { + return function (cp, needFeature) { return strategy(next, cp, needFeature); }; +}, null); + +UChar.isHighSurrogate = function (cp) { return cp >= 0xD800 && cp <= 0xDBFF; }; +UChar.isLowSurrogate = function (cp) { return cp >= 0xDC00 && cp <= 0xDFFF; }; + +UChar.prototype.prepFeature = function () { + if (!this.feature) { + this.feature = UChar.fromCharCode(this.codepoint, true).feature; + } +}; + +UChar.prototype.toString = function () { + var x; + if (this.codepoint < 0x10000) return String.fromCharCode(this.codepoint); + x = this.codepoint - 0x10000; + return String.fromCharCode(floor(x / 0x400) + 0xD800, x % 0x400 + 0xDC00); +}; + +UChar.prototype.getDecomp = function () { + this.prepFeature(); + return this.feature[0] || null; +}; + +UChar.prototype.isCompatibility = function () { + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 8)); +}; +UChar.prototype.isExclude = function () { + this.prepFeature(); + return !!this.feature[1] && (this.feature[1] & (1 << 9)); +}; +UChar.prototype.getCanonicalClass = function () { + this.prepFeature(); + return !!this.feature[1] ? (this.feature[1] & 0xff) : 0; +}; +UChar.prototype.getComposite = function (following) { + var cp; + this.prepFeature(); + if (!this.feature[2]) return null; + cp = this.feature[2][following.codepoint]; + return cp ? UChar.fromCharCode(cp) : null; +}; + +UCharIterator = function (str) { + this.str = str; + this.cursor = 0; +}; +UCharIterator.prototype.next = function () { + if (!!this.str && this.cursor < this.str.length) { + var cp = this.str.charCodeAt(this.cursor++), d; + if (UChar.isHighSurrogate(cp) && this.cursor < this.str.length && + UChar.isLowSurrogate((d = this.str.charCodeAt(this.cursor)))) { + cp = (cp - 0xD800) * 0x400 + (d - 0xDC00) + 0x10000; + ++this.cursor; + } + return UChar.fromCharCode(cp); + } + this.str = null; + return null; +}; + +RecursDecompIterator = function (it, cano) { + this.it = it; + this.canonical = cano; + this.resBuf = []; +}; + +RecursDecompIterator.prototype.next = function () { + var recursiveDecomp, uchar; + recursiveDecomp = function (cano, uchar) { + var decomp = uchar.getDecomp(), ret, i, a, j; + if (!!decomp && !(cano && uchar.isCompatibility())) { + ret = []; + for (i = 0; i < decomp.length; ++i) { + a = recursiveDecomp(cano, UChar.fromCharCode(decomp[i])); + //ret.concat(a); //<-why does not this work? + //following block is a workaround. + for (j = 0; j < a.length; ++j) ret.push(a[j]); + } + return ret; + } + return [uchar]; + }; + if (this.resBuf.length === 0) { + uchar = this.it.next(); + if (!uchar) return null; + this.resBuf = recursiveDecomp(this.canonical, uchar); + } + return this.resBuf.shift(); +}; + +DecompIterator = function (it) { + this.it = it; + this.resBuf = []; +}; + +DecompIterator.prototype.next = function () { + var cc, uchar, inspt, uchar2, cc2; + if (this.resBuf.length === 0) { + do { + uchar = this.it.next(); + if (!uchar) break; + cc = uchar.getCanonicalClass(); + inspt = this.resBuf.length; + if (cc !== 0) { + for (inspt; inspt > 0; --inspt) { + uchar2 = this.resBuf[inspt - 1]; + cc2 = uchar2.getCanonicalClass(); + if (cc2 <= cc) break; + } + } + this.resBuf.splice(inspt, 0, uchar); + } while (cc !== 0); + } + return this.resBuf.shift(); +}; + +CompIterator = function (it) { + this.it = it; + this.procBuf = []; + this.resBuf = []; + this.lastClass = null; +}; + +CompIterator.prototype.next = function () { + var uchar, starter, composite, cc; + while (this.resBuf.length === 0) { + uchar = this.it.next(); + if (!uchar) { + this.resBuf = this.procBuf; + this.procBuf = []; + break; + } + if (this.procBuf.length === 0) { + this.lastClass = uchar.getCanonicalClass(); + this.procBuf.push(uchar); + } else { + starter = this.procBuf[0]; + composite = starter.getComposite(uchar); + cc = uchar.getCanonicalClass(); + if (!!composite && (this.lastClass < cc || this.lastClass === 0)) { + this.procBuf[0] = composite; + } else { + if (cc === 0) { + this.resBuf = this.procBuf; + this.procBuf = []; + } + this.lastClass = cc; + this.procBuf.push(uchar); + } + } + } + return this.resBuf.shift(); +}; + +createIterator = function (mode, str) { + switch (mode) { + case "NFD": + return new DecompIterator( + new RecursDecompIterator(new UCharIterator(str), true) + ); + case "NFKD": + return new DecompIterator( + new RecursDecompIterator(new UCharIterator(str), false) + ); + case "NFC": + return new CompIterator(new DecompIterator( + new RecursDecompIterator(new UCharIterator(str), true) + )); + case "NFKC": + return new CompIterator(new DecompIterator( + new RecursDecompIterator(new UCharIterator(str), false) + )); + } + throw mode + " is invalid"; +}; +normalize = function (mode, str) { + var it = createIterator(mode, str), ret = "", uchar; + while (!!(uchar = it.next())) ret += uchar.toString(); + return ret; +}; + +/* Unicode data */ +UChar.udata = data; + +module.exports = function (/*form*/) { + var str = String(validValue(this)), form = arguments[0]; + if (form === undefined) form = 'NFC'; + else form = String(form); + if (!forms[form]) throw new RangeError('Invalid normalization form: ' + form); + return normalize(form, str); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/pad.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/pad.js new file mode 100644 index 0000000..f227f23 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/pad.js @@ -0,0 +1,18 @@ +'use strict'; + +var toInteger = require('../../number/to-integer') + , value = require('../../object/valid-value') + , repeat = require('./repeat') + + , abs = Math.abs, max = Math.max; + +module.exports = function (fill/*, length*/) { + var self = String(value(this)) + , sLength = self.length + , length = arguments[1]; + + length = isNaN(length) ? 1 : toInteger(length); + fill = repeat.call(String(fill), abs(length)); + if (length >= 0) return fill.slice(0, max(0, length - sLength)) + self; + return self + (((sLength + length) >= 0) ? '' : fill.slice(length + sLength)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace-all.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace-all.js new file mode 100644 index 0000000..678b1cb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace-all.js @@ -0,0 +1,16 @@ +'use strict'; + +var value = require('../../object/valid-value'); + +module.exports = function (search, replace) { + var index, pos = 0, str = String(value(this)), sl, rl; + search = String(search); + replace = String(replace); + sl = search.length; + rl = replace.length; + while ((index = str.indexOf(search, pos)) !== -1) { + str = str.slice(0, index) + replace + str.slice(index + sl); + pos = index + rl; + } + return str; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace.js new file mode 100644 index 0000000..24ce16d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/plain-replace.js @@ -0,0 +1,10 @@ +'use strict'; + +var indexOf = String.prototype.indexOf, slice = String.prototype.slice; + +module.exports = function (search, replace) { + var index = indexOf.call(this, search); + if (index === -1) return String(this); + return slice.call(this, 0, index) + replace + + slice.call(this, index + String(search).length); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/implement.js new file mode 100644 index 0000000..4c39b9f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'repeat', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/index.js new file mode 100644 index 0000000..15a800e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.repeat + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/is-implemented.js new file mode 100644 index 0000000..f7b8750 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/is-implemented.js @@ -0,0 +1,8 @@ +'use strict'; + +var str = 'foo'; + +module.exports = function () { + if (typeof str.repeat !== 'function') return false; + return (str.repeat(2) === 'foofoo'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js new file mode 100644 index 0000000..0a3928b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js @@ -0,0 +1,22 @@ +// Thanks: http://www.2ality.com/2014/01/efficient-string-repeat.html + +'use strict'; + +var value = require('../../../object/valid-value') + , toInteger = require('../../../number/to-integer'); + +module.exports = function (count) { + var str = String(value(this)), result; + count = toInteger(count); + if (count < 0) throw new RangeError("Count must be >= 0"); + if (!isFinite(count)) throw new RangeError("Count must be < ∞"); + result = ''; + if (!count) return result; + while (true) { + if (count & 1) result += str; + count >>>= 1; + if (count <= 0) break; + str += str; + } + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/implement.js new file mode 100644 index 0000000..d4f1eaf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String.prototype, 'startsWith', + { value: require('./shim'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/index.js new file mode 100644 index 0000000..ec66a7c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.startsWith + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/is-implemented.js new file mode 100644 index 0000000..a0556f1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +var str = 'razdwatrzy'; + +module.exports = function () { + if (typeof str.startsWith !== 'function') return false; + return ((str.startsWith('trzy') === false) && + (str.startsWith('raz') === true)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/shim.js new file mode 100644 index 0000000..aa5aaf4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/#/starts-with/shim.js @@ -0,0 +1,12 @@ +'use strict'; + +var value = require('../../../object/valid-value') + , toInteger = require('../../../number/to-integer') + + , max = Math.max, min = Math.min; + +module.exports = function (searchString/*, position*/) { + var start, self = String(value(this)); + start = min(max(toInteger(arguments[1]), 0), self.length); + return (self.indexOf(searchString, start) === start); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/format-method.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/format-method.js new file mode 100644 index 0000000..f1de1e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/format-method.js @@ -0,0 +1,24 @@ +'use strict'; + +var isCallable = require('../object/is-callable') + , value = require('../object/valid-value') + + , call = Function.prototype.call; + +module.exports = function (fmap) { + fmap = Object(value(fmap)); + return function (pattern) { + var context = value(this); + pattern = String(pattern); + return pattern.replace(/%([a-zA-Z]+)|\\([\u0000-\uffff])/g, + function (match, token, escape) { + var t, r; + if (escape) return escape; + t = token; + while (t && !(r = fmap[t])) t = t.slice(0, -1); + if (!r) return match; + if (isCallable(r)) r = call.call(r, context); + return r + token.slice(t.length); + }); + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/implement.js new file mode 100644 index 0000000..b062331 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String, 'fromCodePoint', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/index.js new file mode 100644 index 0000000..3f3110b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.fromCodePoint + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/is-implemented.js new file mode 100644 index 0000000..840a20e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/is-implemented.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function () { + var fromCodePoint = String.fromCodePoint; + if (typeof fromCodePoint !== 'function') return false; + return fromCodePoint(0x1D306, 0x61, 0x1D307) === '\ud834\udf06a\ud834\udf07'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/shim.js new file mode 100644 index 0000000..41fd737 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/from-code-point/shim.js @@ -0,0 +1,30 @@ +// Based on: +// http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/ +// and: +// https://github.com/mathiasbynens/String.fromCodePoint/blob/master +// /fromcodepoint.js + +'use strict'; + +var floor = Math.floor, fromCharCode = String.fromCharCode; + +module.exports = function (codePoint/*, …codePoints*/) { + var chars = [], l = arguments.length, i, c, result = ''; + for (i = 0; i < l; ++i) { + c = Number(arguments[i]); + if (!isFinite(c) || c < 0 || c > 0x10FFFF || floor(c) !== c) { + throw new RangeError("Invalid code point " + c); + } + + if (c < 0x10000) { + chars.push(c); + } else { + c -= 0x10000; + chars.push((c >> 10) + 0xD800, (c % 0x400) + 0xDC00); + } + if (i + 1 !== l && chars.length <= 0x4000) continue; + result += fromCharCode.apply(null, chars); + chars.length = 0; + } + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/index.js new file mode 100644 index 0000000..dbbcdf6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/index.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = { + '#': require('./#'), + formatMethod: require('./format-method'), + fromCodePoint: require('./from-code-point'), + isString: require('./is-string'), + randomUniq: require('./random-uniq'), + raw: require('./raw') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/is-string.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/is-string.js new file mode 100644 index 0000000..719aeec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/is-string.js @@ -0,0 +1,10 @@ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(''); + +module.exports = function (x) { + return (typeof x === 'string') || (x && (typeof x === 'object') && + ((x instanceof String) || (toString.call(x) === id))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/random-uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/random-uniq.js new file mode 100644 index 0000000..54ae6f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/random-uniq.js @@ -0,0 +1,11 @@ +'use strict'; + +var generated = Object.create(null) + + , random = Math.random; + +module.exports = function () { + var str; + do { str = random().toString(36).slice(2); } while (generated[str]); + return str; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/implement.js new file mode 100644 index 0000000..c417e65 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(String, 'raw', { value: require('./shim'), + configurable: true, enumerable: false, writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/index.js new file mode 100644 index 0000000..504a5de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.raw + : require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/is-implemented.js new file mode 100644 index 0000000..d7204c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/is-implemented.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function () { + var raw = String.raw, test; + if (typeof raw !== 'function') return false; + test = ['foo\nbar', 'marko\n']; + test.raw = ['foo\\nbar', 'marko\\n']; + return raw(test, 'INSE\nRT') === 'foo\\nbarINSE\nRTmarko\\n'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/shim.js new file mode 100644 index 0000000..7096efb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/string/raw/shim.js @@ -0,0 +1,15 @@ +'use strict'; + +var toPosInt = require('../../number/to-pos-integer') + , validValue = require('../../object/valid-value') + + , reduce = Array.prototype.reduce; + +module.exports = function (callSite/*, …substitutions*/) { + var args, rawValue = Object(validValue(Object(validValue(callSite)).raw)); + if (!toPosInt(rawValue.length)) return ''; + args = arguments; + return reduce.call(rawValue, function (a, b, i) { + return a + String(args[i]) + b; + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/__tad.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/__tad.js new file mode 100644 index 0000000..8845778 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/__tad.js @@ -0,0 +1,3 @@ +'use strict'; + +exports.context = null; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/implement.js new file mode 100644 index 0000000..f060539 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/@@iterator/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/shim.js new file mode 100644 index 0000000..e590d8f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/@@iterator/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.__generic = function (t, a) { + var iterator = t.call(this); + a.deep(iterator.next(), { value: '1', done: false }); + a.deep(iterator.next(), { value: '2', done: false }); + a.deep(iterator.next(), { value: '3', done: false }); + a.deep(iterator.next(), { value: undefined, done: true }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/_compare-by-length.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/_compare-by-length.js new file mode 100644 index 0000000..e40c305 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/_compare-by-length.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + var x = [4, 5, 6], y = { length: 8 }, w = {}, z = { length: 1 }; + + a.deep([x, y, w, z].sort(t), [w, z, x, y]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/binary-search.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/binary-search.js new file mode 100644 index 0000000..cf33173 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/binary-search.js @@ -0,0 +1,15 @@ +'use strict'; + +var compare = function (value) { return this - value; }; + +module.exports = function (t, a) { + var arr; + arr = [2, 5, 5, 8, 34, 67, 98, 345, 678]; + + // highest, equal match + a(t.call(arr, compare.bind(1)), 0, "All higher"); + a(t.call(arr, compare.bind(679)), arr.length - 1, "All lower"); + a(t.call(arr, compare.bind(4)), 0, "Mid"); + a(t.call(arr, compare.bind(5)), 2, "Match"); + a(t.call(arr, compare.bind(6)), 2, "Above"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/clear.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/clear.js new file mode 100644 index 0000000..a5b1c97 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/clear.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + var x = [1, 2, {}, 4]; + a(t.call(x), x, "Returns same array"); + a.deep(x, [], "Empties array"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/compact.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/compact.js new file mode 100644 index 0000000..6390eb2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/compact.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + a(t.call(this).length, 3); + }, + "": function (t, a) { + var o, x, y, z; + o = {}; + x = [0, 1, "", null, o, false, undefined, true]; + y = x.slice(0); + + a.not(z = t.call(x), x, "Returns different object"); + a.deep(x, y, "Origin not changed"); + a.deep(z, [0, 1, "", o, false, true], "Result"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/implement.js new file mode 100644 index 0000000..3bdbe86 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/concat/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/shim.js new file mode 100644 index 0000000..c30eb7e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/concat/shim.js @@ -0,0 +1,26 @@ +'use strict'; + +var SubArray = require('../../../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr = [1, 3, 45], x = {}, subArr, subArr2, result; + + a.deep(t.call(arr, '2d', x, ['ere', 'fe', x], false, null), + [1, 3, 45, '2d', x, 'ere', 'fe', x, false, null], "Plain array"); + + subArr = new SubArray('lol', 'miszko'); + subArr2 = new SubArray('elo', 'fol'); + + result = t.call(subArr, 'df', arr, 'fef', subArr2, null); + a(result instanceof SubArray, true, "Instance of subclass"); + a.deep(result, ['lol', 'miszko', 'df', 1, 3, 45, 'fef', 'elo', 'fol', null], + "Spreable by default"); + + SubArray.prototype['@@isConcatSpreadable'] = false; + + result = t.call(subArr, 'df', arr, 'fef', subArr2, null); + a.deep(result, ['lol', 'miszko', 'df', 1, 3, 45, 'fef', subArr2, null], + "Non spreadable"); + + delete SubArray.prototype['@@isConcatSpreadable']; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/contains.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/contains.js new file mode 100644 index 0000000..21404a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/contains.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + a(t.call(this, this[1]), true, "Contains"); + a(t.call(this, {}), false, "Does Not contain"); + }, + "": function (t, a) { + var o, x = {}, y = {}; + + o = [1, 'raz', x]; + + a(t.call(o, 1), true, "First"); + a(t.call(o, '1'), false, "Type coercion"); + a(t.call(o, 'raz'), true, "Primitive"); + a(t.call(o, 'foo'), false, "Primitive not found"); + a(t.call(o, x), true, "Object found"); + a(t.call(o, y), false, "Object not found"); + a(t.call(o, 1, 1), false, "Position"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/implement.js new file mode 100644 index 0000000..3607047 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/copy-within/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/shim.js new file mode 100644 index 0000000..93c85ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/copy-within/shim.js @@ -0,0 +1,29 @@ +'use strict'; + +module.exports = function (t, a) { + var args, x; + + a.h1("2 args"); + x = [1, 2, 3, 4, 5]; + t.call(x, 0, 3); + a.deep(x, [4, 5, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 1, 3), [1, 4, 5, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 1, 2), [1, 3, 4, 5, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 2, 2), [1, 2, 3, 4, 5]); + + a.h1("3 args"); + a.deep(t.call([1, 2, 3, 4, 5], 0, 3, 4), [4, 2, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 1, 3, 4), [1, 4, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 1, 2, 4), [1, 3, 4, 4, 5]); + + a.h1("Negative args"); + a.deep(t.call([1, 2, 3, 4, 5], 0, -2), [4, 5, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], 0, -2, -1), [4, 2, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], -4, -3, -2), [1, 3, 3, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], -4, -3, -1), [1, 3, 4, 4, 5]); + a.deep(t.call([1, 2, 3, 4, 5], -4, -3), [1, 3, 4, 5, 5]); + + a.h1("Array-likes"); + args = { 0: 1, 1: 2, 2: 3, length: 3 }; + a.deep(t.call(args, -2, 0), { '0': 1, '1': 1, '2': 2, length: 3 }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/diff.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/diff.js new file mode 100644 index 0000000..bcfa3a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/diff.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + a.deep(t.call(this, this), []); + }, + "": function (t, a) { + var x = {}, y = {}; + + a.deep(t.call([1, 'raz', x, 2, 'trzy', y], [x, 2, 'trzy']), [1, 'raz', y], + "Scope longer"); + a.deep(t.call([1, 'raz', x], [x, 2, 'trzy', 1, y]), ['raz'], + "Arg longer"); + a.deep(t.call([1, 'raz', x], []), [1, 'raz', x], "Empty arg"); + a.deep(t.call([], [1, y, 'sdfs']), [], "Empty scope"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-index-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-index-of.js new file mode 100644 index 0000000..4cf6c63 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-index-of.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}; + a(t.call([3, 'raz', {}, x, {}], x), 3, "Regular"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN), 2, "NaN"); + a(t.call([3, 'raz', 0, {}, -0], -0), 2, "-0"); + a(t.call([3, 'raz', -0, {}, 0], +0), 2, "+0"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN, 3), 4, "fromIndex"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN, -1), 4, "fromIndex negative #1"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN, -2), 4, "fromIndex negative #2"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN, -3), 2, "fromIndex negative #3"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-last-index-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-last-index-of.js new file mode 100644 index 0000000..ed4f700 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/e-last-index-of.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}; + a(t.call([3, 'raz', {}, x, {}, x], x), 5, "Regular"); + a(t.call([3, 'raz', NaN, {}, x], NaN), 2, "NaN"); + a(t.call([3, 'raz', 0, {}, -0], -0), 4, "-0"); + a(t.call([3, 'raz', -0, {}, 0], +0), 4, "+0"); + a(t.call([3, 'raz', NaN, {}, NaN], NaN, 3), 2, "fromIndex"); + a(t.call([3, 'raz', NaN, 2, NaN], NaN, -1), 4, "Negative fromIndex #1"); + a(t.call([3, 'raz', NaN, 2, NaN], NaN, -2), 2, "Negative fromIndex #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/implement.js new file mode 100644 index 0000000..733209a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/entries/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/shim.js new file mode 100644 index 0000000..bf40d31 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/entries/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.__generic = function (t, a) { + var iterator = t.call(this); + a.deep(iterator.next(), { value: [0, '1'], done: false }); + a.deep(iterator.next(), { value: [1, '2'], done: false }); + a.deep(iterator.next(), { value: [2, '3'], done: false }); + a.deep(iterator.next(), { value: undefined, done: true }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/exclusion.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/exclusion.js new file mode 100644 index 0000000..07b32d8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/exclusion.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + var x = {}; + a.deep(t.call(this, this, [this[0], this[2], x]), [x]); + }, + "": function (t, a) { + var x = {}, y = {}; + + a.deep(t.call([x, y]), [x, y], "No arguments"); + a.deep(t.call([x, 1], [], []), [x, 1], "Empty arguments"); + a.deep(t.call([1, 'raz', x], [2, 'raz', y], [2, 'raz', x]), [1, y]); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/implement.js new file mode 100644 index 0000000..2a01d28 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/fill/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/shim.js new file mode 100644 index 0000000..d67300f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/fill/shim.js @@ -0,0 +1,18 @@ +// Taken from https://github.com/paulmillr/es6-shim/blob/master/test/array.js + +'use strict'; + +module.exports = function (t, a) { + var x; + + x = [1, 2, 3, 4, 5, 6]; + a(t.call(x, -1), x, "Returns self object"); + a.deep(x, [-1, -1, -1, -1, -1, -1], "Value"); + + a.deep(t.call([1, 2, 3, 4, 5, 6], -1, 3), [1, 2, 3, -1, -1, -1], + "Positive start"); + a.deep(t.call([1, 2, 3, 4, 5, 6], -1, -3), [1, 2, 3, -1, -1, -1], + "Negative start"); + a.deep(t.call([1, 2, 3, 4, 5, 6], -1, 9), [1, 2, 3, 4, 5, 6], + "Large start"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/implement.js new file mode 100644 index 0000000..6d6b87c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/filter/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/shim.js new file mode 100644 index 0000000..e8b5c39 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/filter/shim.js @@ -0,0 +1,17 @@ +'use strict'; + +var SubArray = require('../../../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr, x = {}, subArr, result; + + arr = ['foo', undefined, 0, '2d', false, x, null]; + + a.deep(t.call(arr, Boolean), ['foo', '2d', x], "Plain array"); + + subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); + + result = t.call(subArr, Boolean); + a(result instanceof SubArray, true, "Instance of subclass"); + a.deep(result, ['foo', '2d', x], "Result of subclass"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/implement.js new file mode 100644 index 0000000..8d85e61 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/find-index/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/shim.js new file mode 100644 index 0000000..b5fee46 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find-index/shim.js @@ -0,0 +1,17 @@ +'use strict'; + +exports.__generic = function (t, a) { + var count = 0, o = {}, self = Object(this); + a(t.call(self, function (value, i, scope) { + a(value, this[i], "Value"); + a(i, count++, "Index"); + a(scope, this, "Scope"); + }, self), -1, "Falsy result"); + a(count, 3); + + count = -1; + a(t.call(this, function () { + return ++count ? o : null; + }, this), 1, "Truthy result"); + a(count, 1); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/implement.js new file mode 100644 index 0000000..29fac41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/find/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/shim.js new file mode 100644 index 0000000..ad2e645 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/find/shim.js @@ -0,0 +1,17 @@ +'use strict'; + +exports.__generic = function (t, a) { + var count = 0, o = {}, self = Object(this); + a(t.call(self, function (value, i, scope) { + a(value, this[i], "Value"); + a(i, count++, "Index"); + a(scope, this, "Scope"); + }, self), undefined, "Falsy result"); + a(count, 3); + + count = -1; + a(t.call(this, function () { + return ++count ? o : null; + }, this), this[1], "Truthy result"); + a(count, 1); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first-index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first-index.js new file mode 100644 index 0000000..4aebad6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first-index.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a(t.call([]), null, "Empty"); + a(t.call([null]), 0, "One value"); + a(t.call([1, 2, 3]), 0, "Many values"); + a(t.call(new Array(1000)), null, "Sparse empty"); + x = []; + x[883] = undefined; + x[890] = null; + a(t.call(x), 883, "Manual sparse, distant value"); + x = new Array(1000); + x[657] = undefined; + x[700] = null; + a(t.call(x), 657, "Sparse, distant value"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first.js new file mode 100644 index 0000000..87fde03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/first.js @@ -0,0 +1,13 @@ +'use strict'; + +exports.__generic = function (t, a) { + a(t.call(this), this[0]); +}; +exports[''] = function (t, a) { + var x; + a(t.call([]), undefined, "Empty"); + a(t.call(new Array(234), undefined, "Sparse empty")); + x = new Array(2342); + x[434] = {}; + a(t.call(x), x[434], "Sparse"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/flatten.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/flatten.js new file mode 100644 index 0000000..65f1214 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/flatten.js @@ -0,0 +1,12 @@ +'use strict'; + +var o = [1, 2, [3, 4, [5, 6], 7, 8], 9, 10]; + +module.exports = { + __generic: function (t, a) { + a(t.call(this).length, 3); + }, + "Nested Arrays": function (t, a) { + a(t.call(o).length, 10); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/for-each-right.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/for-each-right.js new file mode 100644 index 0000000..2d24569 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/for-each-right.js @@ -0,0 +1,36 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + var count = 0, first, last, x, icount = this.length; + t.call(this, function (item, index, col) { + ++count; + if (!first) { + first = item; + } + last = item; + x = col; + a(index, --icount, "Index"); + }); + a(count, this.length, "Iterated"); + a(first, this[this.length - 1], "First is last"); + a(last, this[0], "Last is first"); + a.deep(x, Object(this), "Collection as third argument"); //jslint: skip + }, + "": function (t, a) { + var x = {}, y, count; + t.call([1], function () { y = this; }, x); + a(y, x, "Scope"); + y = 0; + t.call([3, 4, 4], function (a, i) { y += i; }); + a(y, 3, "Indexes"); + + x = [1, 3]; + x[5] = 'x'; + y = 0; + count = 0; + t.call(x, function (a, i) { ++count; y += i; }); + a(y, 6, "Misssing Indexes"); + a(count, 3, "Misssing Indexes, count"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/group.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/group.js new file mode 100644 index 0000000..32dc8c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/group.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + var count = 0, self; + + self = Object(this); + a.deep(t.call(self, function (v, i, scope) { + a(v, this[i], "Value"); + a(i, count++, "Index"); + a(scope, this, "Scope"); + return i; + }, self), { 0: [this[0]], 1: [this[1]], 2: [this[2]] }); + }, + "": function (t, a) { + var r; + r = t.call([2, 3, 3, 4, 5, 6, 7, 7, 23, 45, 34, 56], + function (v) { + return v % 2 ? 'odd' : 'even'; + }); + a.deep(r.odd, [3, 3, 5, 7, 7, 23, 45]); + a.deep(r.even, [2, 4, 6, 34, 56]); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/indexes-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/indexes-of.js new file mode 100644 index 0000000..3364170 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/indexes-of.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + a.deep(t.call(this, this[1]), [1]); + }, + "": function (t, a) { + var x = {}; + a.deep(t.call([1, 3, 5, 3, 5], 6), [], "No result"); + a.deep(t.call([1, 3, 5, 1, 3, 5, 1], 1), [0, 3, 6], "Some results"); + a.deep(t.call([], x), [], "Empty array"); + a.deep(t.call([x, 3, {}, x, 3, 5, x], x), [0, 3, 6], "Search for object"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/intersection.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/intersection.js new file mode 100644 index 0000000..b72b2fb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/intersection.js @@ -0,0 +1,24 @@ +'use strict'; + +var toArray = require('../../../array/to-array'); + +module.exports = { + __generic: function (t, a) { + a.deep(t.call(this, this, this), toArray(this)); + }, + "": function (t, a) { + var x = {}, y = {}, p, r; + a.deep(t.call([], [2, 3, 4]), [], "Empty #1"); + a.deep(t.call([2, 3, 4], []), [], "Empty #2"); + a.deep(t.call([2, 3, x], [y, 5, 7]), [], "Different"); + p = t.call([3, 5, 'raz', {}, 'dwa', x], [1, 3, 'raz', 'dwa', 'trzy', x, {}], + [3, 'raz', x, 65]); + r = [3, 'raz', x]; + p.sort(); + r.sort(); + a.deep(p, r, "Same parts"); + a.deep(t.call(r, r), r, "Same"); + a.deep(t.call([1, 2, x, 4, 5, y, 7], [7, y, 5, 4, x, 2, 1]), + [1, 2, x, 4, 5, y, 7], "Long reverse same"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-copy.js new file mode 100644 index 0000000..e7f80e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-copy.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}; + a(t.call([], []), true, "Empty"); + a(t.call([], {}), true, "Empty lists"); + a(t.call([1, x, 'raz'], [1, x, 'raz']), true, "Same"); + a(t.call([1, x, 'raz'], { 0: 1, 1: x, 2: 'raz', length: 3 }), true, + "Same lists"); + a(t.call([1, x, 'raz'], [x, 1, 'raz']), false, "Diff order"); + a(t.call([1, x], [1, x, 'raz']), false, "Diff length #1"); + a(t.call([1, x, 'raz'], [1, x]), false, "Diff length #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-uniq.js new file mode 100644 index 0000000..7349ba3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/is-uniq.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}; + a(t.call([]), true, "Empty"); + a(t.call({}), true, "Empty lists"); + a(t.call([1, x, 'raz']), true, "Uniq"); + a(t.call([1, x, 1, 'raz']), false, "Not Uniq: primitive"); + a(t.call([1, x, '1', 'raz']), true, "Uniq: primitive"); + a(t.call([1, x, 1, {}, 'raz']), false, "Not Uniq: Obj"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/implement.js new file mode 100644 index 0000000..b0c1aa0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/keys/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/shim.js new file mode 100644 index 0000000..a43c04c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/keys/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.__generic = function (t, a) { + var iterator = t.call(this); + a.deep(iterator.next(), { value: 0, done: false }); + a.deep(iterator.next(), { value: 1, done: false }); + a.deep(iterator.next(), { value: 2, done: false }); + a.deep(iterator.next(), { value: undefined, done: true }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last-index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last-index.js new file mode 100644 index 0000000..a1cac10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last-index.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a(t.call([]), null, "Empty"); + a(t.call([null]), 0, "One value"); + a(t.call([1, 2, 3]), 2, "Many values"); + a(t.call(new Array(1000)), null, "Sparse empty"); + x = []; + x[883] = null; + x[890] = undefined; + a(t.call(x), 890, "Manual sparse, distant value"); + x = new Array(1000); + x[657] = null; + x[700] = undefined; + a(t.call(x), 700, "Sparse, distant value"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last.js new file mode 100644 index 0000000..8d051bc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/last.js @@ -0,0 +1,15 @@ +'use strict'; + +exports.__generic = function (t, a) { + a(t.call(this), this[this.length - 1]); +}; + +exports[''] = function (t, a) { + var x; + a(t.call([]), undefined, "Empty"); + a(t.call(new Array(234), undefined, "Sparse empty")); + x = new Array(2342); + x[434] = {}; + x[450] = {}; + a(t.call(x), x[450], "Sparse"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/implement.js new file mode 100644 index 0000000..cdcbc8d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/map/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/shim.js new file mode 100644 index 0000000..bbfefe8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/map/shim.js @@ -0,0 +1,19 @@ +'use strict'; + +var SubArray = require('../../../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr, x = {}, subArr, result; + + arr = ['foo', undefined, 0, '2d', false, x, null]; + + a.deep(t.call(arr, Boolean), [true, false, false, true, false, true, false], + "Plain array"); + + subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); + + result = t.call(subArr, Boolean); + a(result instanceof SubArray, true, "Instance of subclass"); + a.deep(result, [true, false, false, true, false, true, false], + "Result of subclass"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/remove.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/remove.js new file mode 100644 index 0000000..3ebdca2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/remove.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function (t, a) { + var y = {}, z = {}, x = [9, z, 5, y, 'foo']; + t.call(x, y); + a.deep(x, [9, z, 5, 'foo']); + t.call(x, {}); + a.deep(x, [9, z, 5, 'foo'], "Not existing"); + t.call(x, 5); + a.deep(x, [9, z, 'foo'], "Primitive"); + x = [9, z, 5, y, 'foo']; + t.call(x, z, 5, 'foo'); + a.deep(x, [9, y], "More than one argument"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/separate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/separate.js new file mode 100644 index 0000000..42918b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/separate.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var x = [], y = {}, z = {}; + a.deep(t.call(x, y), [], "Empty"); + a.not(t.call(x), x, "Returns copy"); + a.deep(t.call([1], y), [1], "One"); + a.deep(t.call([1, 'raz'], y), [1, y, 'raz'], "One"); + a.deep(t.call([1, 'raz', x], y), [1, y, 'raz', y, x], "More"); + x = new Array(1000); + x[23] = 2; + x[3453] = 'raz'; + x[500] = z; + a.deep(t.call(x, y), [2, y, z, y, 'raz'], "Sparse"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/implement.js new file mode 100644 index 0000000..855ae2f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/slice/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/shim.js new file mode 100644 index 0000000..f674f34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/slice/shim.js @@ -0,0 +1,17 @@ +'use strict'; + +var SubArray = require('../../../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr, x = {}, subArr, result; + + arr = ['foo', undefined, 0, '2d', false, x, null]; + + a.deep(t.call(arr, 2, 4), [0, '2d'], "Plain array: result"); + + subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); + + result = t.call(subArr, 2, 4); + a(result instanceof SubArray, true, "Instance of subclass"); + a.deep(result, [0, '2d'], "Subclass: result"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/some-right.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/some-right.js new file mode 100644 index 0000000..900771a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/some-right.js @@ -0,0 +1,43 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + var count = 0, first, last, x, icount = this.length; + t.call(this, function (item, index, col) { + ++count; + if (!first) { + first = item; + } + last = item; + x = col; + a(index, --icount, "Index"); + }); + a(count, this.length, "Iterated"); + a(first, this[this.length - 1], "First is last"); + a(last, this[0], "Last is first"); + a.deep(x, Object(this), "Collection as third argument"); //jslint: skip + }, + "": function (t, a) { + var x = {}, y, count; + t.call([1], function () { y = this; }, x); + a(y, x, "Scope"); + y = 0; + t.call([3, 4, 4], function (a, i) { y += i; }); + a(y, 3, "Indexes"); + + x = [1, 3]; + x[5] = 'x'; + y = 0; + count = 0; + a(t.call(x, function (a, i) { ++count; y += i; }), false, "Return"); + a(y, 6, "Misssing Indexes"); + a(count, 3, "Misssing Indexes, count"); + + count = 0; + a(t.call([-2, -3, -4, 2, -5], function (item) { + ++count; + return item > 0; + }), true, "Return"); + a(count, 2, "Break after true is returned"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/implement.js new file mode 100644 index 0000000..0d9f461 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/splice/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/shim.js new file mode 100644 index 0000000..2c751e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/splice/shim.js @@ -0,0 +1,19 @@ +'use strict'; + +var SubArray = require('../../../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr, x = {}, subArr, result; + + arr = ['foo', undefined, 0, '2d', false, x, null]; + + a.deep(t.call(arr, 2, 2, 'bar'), [0, '2d'], "Plain array: result"); + a.deep(arr, ["foo", undefined, "bar", false, x, null], "Plain array: change"); + + subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); + + result = t.call(subArr, 2, 2, 'bar'); + a(result instanceof SubArray, true, "Instance of subclass"); + a.deep(result, [0, '2d'], "Subclass: result"); + a.deep(subArr, ["foo", undefined, "bar", false, x, null], "Subclass: change"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/uniq.js new file mode 100644 index 0000000..2f7e6c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/uniq.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + __generic: function (t, a) { + a(t.call(this).length, 3); + }, + "": function (t, a) { + var o, x = {}, y = {}, z = {}, w; + o = [1, 2, x, 3, 1, 'raz', '1', y, x, 'trzy', z, 'raz']; + + a.not(w = t.call(o), o, "Returns different object"); + a.deep(w, [1, 2, x, 3, 'raz', '1', y, 'trzy', z], "Result"); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/implement.js new file mode 100644 index 0000000..9f40138 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../array/#/values/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/shim.js new file mode 100644 index 0000000..e590d8f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/#/values/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.__generic = function (t, a) { + var iterator = t.call(this); + a.deep(iterator.next(), { value: '1', done: false }); + a.deep(iterator.next(), { value: '2', done: false }); + a.deep(iterator.next(), { value: '3', done: false }); + a.deep(iterator.next(), { value: undefined, done: true }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/__scopes.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/__scopes.js new file mode 100644 index 0000000..fc240d3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/__scopes.js @@ -0,0 +1,9 @@ +'use strict'; + +exports.Array = ['1', '2', '3']; + +exports.Arguments = (function () { + return arguments; +}('1', '2', '3')); + +exports.String = "123"; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_is-extensible.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_is-extensible.js new file mode 100644 index 0000000..d387126 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_is-extensible.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(typeof t, 'boolean'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js new file mode 100644 index 0000000..29d8699 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js @@ -0,0 +1,7 @@ +'use strict'; + +var isArray = Array.isArray; + +module.exports = function (t, a) { + t((t === null) || isArray(t.prototype), true); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy.js new file mode 100644 index 0000000..29d8699 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/_sub-array-dummy.js @@ -0,0 +1,7 @@ +'use strict'; + +var isArray = Array.isArray; + +module.exports = function (t, a) { + t((t === null) || isArray(t.prototype), true); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/implement.js new file mode 100644 index 0000000..e0db846 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../array/from/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/shim.js new file mode 100644 index 0000000..310302a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/from/shim.js @@ -0,0 +1,60 @@ +// Some tests taken from: https://github.com/mathiasbynens/Array.from/blob/master/tests/tests.js + +'use strict'; + +module.exports = function (t, a) { + var o = [1, 2, 3], MyType; + a.not(t(o), o, "Array"); + a.deep(t(o), o, "Array: same content"); + a.deep(t('12r3v'), ['1', '2', 'r', '3', 'v'], "String"); + a.deep(t((function () { return arguments; }(3, o, 'raz'))), + [3, o, 'raz'], "Arguments"); + a.deep(t((function () { return arguments; }(3))), [3], + "Arguments with one numeric value"); + + a.deep(t({ 0: 'raz', 1: 'dwa', length: 2 }), ['raz', 'dwa'], "Other"); + + a.deep(t(o, function (val) { return (val + 2) * 10; }, 10), [30, 40, 50], + "Mapping"); + + a.throws(function () { t(); }, TypeError, "Undefined"); + a.deep(t(3), [], "Primitive"); + + a(t.length, 1, "Length"); + a.deep(t({ length: 0 }), [], "No values Array-like"); + a.deep(t({ length: -1 }), [], "Invalid length Array-like"); + a.deep(t({ length: -Infinity }), [], "Invalid length Array-like #2"); + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.deep(t(false), [], "Boolean"); + a.deep(t(-Infinity), [], "Inifity"); + a.deep(t(-0), [], "-0"); + a.deep(t(+0), [], "+0"); + a.deep(t(1), [], "1"); + a.deep(t(+Infinity), [], "+Infinity"); + a.deep(t({}), [], "Plain object"); + a.deep(t({ length: 1 }), [undefined], "Sparse array-like"); + a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return x + x; }), ['aa', 'bb'], + "Map"); + a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return String(this); }, undefined), + ['undefined', 'undefined'], "Map context"); + a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return String(this); }, 'x'), + ['x', 'x'], "Map primitive context"); + a.throws(function () { t({}, 'foo', 'x'); }, TypeError, "Non callable for map"); + + a.deep(t.call(null, { length: 1, '0': 'a' }), ['a'], "Null context"); + + a(t({ __proto__: { '0': 'abc', length: 1 } })[0], 'abc', "Values on prototype"); + + a.throws(function () { t.call(function () { return Object.freeze({}); }, {}); }, + TypeError, "Contructor producing freezed objects"); + + // Ensure no setters are called for the indexes + // Ensure no setters are called for the indexes + MyType = function () {}; + Object.defineProperty(MyType.prototype, '0', { + set: function (x) { throw new Error('Setter called: ' + x); } + }); + a.deep(t.call(MyType, { '0': 'abc', length: 1 }), { '0': 'abc', length: 1 }, + "Defined not set"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/generate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/generate.js new file mode 100644 index 0000000..d72e056 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/generate.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}, y = {}; + a.deep(t(3), [undefined, undefined, undefined], "Just length"); + a.deep(t(0, 'x'), [], "No repeat"); + a.deep(t(1, x, y), [x], "Arguments length larger than repeat number"); + a.deep(t(3, x), [x, x, x], "Single argument"); + a.deep(t(5, x, y), [x, y, x, y, x], "Many arguments"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/is-plain-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/is-plain-array.js new file mode 100644 index 0000000..871a08a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/is-plain-array.js @@ -0,0 +1,18 @@ +'use strict'; + +var SubArray = require('../../array/_sub-array-dummy-safe'); + +module.exports = function (t, a) { + var arr = [1, 2, 3]; + a(t(arr), true, "Array"); + a(t(null), false, "Null"); + a(t(), false, "Undefined"); + a(t('234'), false, "String"); + a(t(23), false, "Number"); + a(t({}), false, "Plain object"); + a(t({ length: 1, 0: 'raz' }), false, "Array-like"); + a(t(Object.create(arr)), false, "Array extension"); + if (!SubArray) return; + a(t(new SubArray(23)), false, "Subclass instance"); + a(t(Array.prototype), false, "Array.prototype"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/implement.js new file mode 100644 index 0000000..30d53be --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../array/of/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/shim.js new file mode 100644 index 0000000..e697442 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/of/shim.js @@ -0,0 +1,68 @@ +// Most tests taken from https://github.com/mathiasbynens/Array.of/blob/master/tests/tests.js +// Thanks @mathiasbynens + +'use strict'; + +var defineProperty = Object.defineProperty; + +module.exports = function (t, a) { + var x = {}, testObject, MyType; + + a.deep(t(), [], "No arguments"); + a.deep(t(3), [3], "One numeric argument"); + a.deep(t(3, 'raz', null, x, undefined), [3, 'raz', null, x, undefined], + "Many arguments"); + + a(t.length, 0, "Length"); + + a.deep(t('abc'), ['abc'], "String"); + a.deep(t(undefined), [undefined], "Undefined"); + a.deep(t(null), [null], "Null"); + a.deep(t(false), [false], "Boolean"); + a.deep(t(-Infinity), [-Infinity], "Infinity"); + a.deep(t(-0), [-0], "-0"); + a.deep(t(+0), [+0], "+0"); + a.deep(t(1), [1], "1"); + a.deep(t(1, 2, 3), [1, 2, 3], "Numeric args"); + a.deep(t(+Infinity), [+Infinity], "+Infinity"); + a.deep(t({ '0': 'a', '1': 'b', '2': 'c', length: 3 }), + [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array like"); + a.deep(t(undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity), + [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy arguments"); + + a.h1("Null context"); + a.deep(t.call(null, 'abc'), ['abc'], "String"); + a.deep(t.call(null, undefined), [undefined], "Undefined"); + a.deep(t.call(null, null), [null], "Null"); + a.deep(t.call(null, false), [false], "Boolean"); + a.deep(t.call(null, -Infinity), [-Infinity], "-Infinity"); + a.deep(t.call(null, -0), [-0], "-0"); + a.deep(t.call(null, +0), [+0], "+0"); + a.deep(t.call(null, 1), [1], "1"); + a.deep(t.call(null, 1, 2, 3), [1, 2, 3], "Numeric"); + a.deep(t.call(null, +Infinity), [+Infinity], "+Infinity"); + a.deep(t.call(null, { '0': 'a', '1': 'b', '2': 'c', length: 3 }), + [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array-like"); + a.deep(t.call(null, undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity), + [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy"); + + a.h1("Other constructor context"); + a.deep(t.call(Object, 1, 2, 3), { '0': 1, '1': 2, '2': 3, length: 3 }, "Many arguments"); + + testObject = Object(3); + testObject[0] = 1; + testObject[1] = 2; + testObject[2] = 3; + testObject.length = 3; + a.deep(t.call(Object, 1, 2, 3), testObject, "Test object"); + a(t.call(Object).length, 0, "No arguments"); + a.throws(function () { t.call(function () { return Object.freeze({}); }); }, TypeError, + "Frozen instance"); + + // Ensure no setters are called for the indexes + MyType = function () {}; + defineProperty(MyType.prototype, '0', { + set: function (x) { throw new Error('Setter called: ' + x); } + }); + a.deep(t.call(MyType, 'abc'), { '0': 'abc', length: 1 }, "Define, not set"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/to-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/to-array.js new file mode 100644 index 0000000..4985b5e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/to-array.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + var o = [1, 2, 3]; + a(t(o), o, "Array"); + a.deep(t('12r3v'), ['1', '2', 'r', '3', 'v'], "String"); + a.deep(t((function () { return arguments; }(3, o, 'raz'))), + [3, o, 'raz'], "Arguments"); + a.deep(t((function () { return arguments; }(3))), [3], + "Arguments with one numeric value"); + + a.deep(t({ 0: 'raz', 1: 'dwa', length: 2 }), ['raz', 'dwa'], "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/valid-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/valid-array.js new file mode 100644 index 0000000..3732192 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/array/valid-array.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(0); }, TypeError, "Number"); + a.throws(function () { t(true); }, TypeError, "Boolean"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t(function () {}); }, TypeError, "Function"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); + a(t(x = []), x, "Array"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/boolean/is-boolean.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/boolean/is-boolean.js new file mode 100644 index 0000000..4e6b3cb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/boolean/is-boolean.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + a(t('arar'), false, "String"); + a(t(12), false, "Number"); + a(t(false), true, "Boolean"); + a(t(new Boolean(false)), true, "Boolean object"); + a(t(new Date()), false, "Date"); + a(t(new String('raz')), false, "String object"); + a(t({}), false, "Plain object"); + a(t(/a/), false, "Regular expression"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/copy.js new file mode 100644 index 0000000..767c5e1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/copy.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var o = new Date(), o2; + + o2 = t.call(o); + a.not(o, o2, "Different objects"); + a.ok(o2 instanceof Date, "Instance of Date"); + a(o.getTime(), o2.getTime(), "Same time"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/days-in-month.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/days-in-month.js new file mode 100644 index 0000000..9ddba55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/days-in-month.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(new Date(2001, 0, 1)), 31, "January"); + a(t.call(new Date(2001, 1, 1)), 28, "February"); + a(t.call(new Date(2000, 1, 1)), 29, "February (leap)"); + a(t.call(new Date(2001, 2, 1)), 31, "March"); + a(t.call(new Date(2001, 3, 1)), 30, "April"); + a(t.call(new Date(2001, 4, 1)), 31, "May"); + a(t.call(new Date(2001, 5, 1)), 30, "June"); + a(t.call(new Date(2001, 6, 1)), 31, "July"); + a(t.call(new Date(2001, 7, 1)), 31, "August"); + a(t.call(new Date(2001, 8, 1)), 30, "September"); + a(t.call(new Date(2001, 9, 1)), 31, "October"); + a(t.call(new Date(2001, 10, 1)), 30, "November"); + a(t.call(new Date(2001, 11, 1)), 31, "December"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-day.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-day.js new file mode 100644 index 0000000..d4f4a90 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-day.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(new Date(2000, 0, 1, 13, 32, 34, 234)).valueOf(), + new Date(2000, 0, 1).valueOf()); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-month.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-month.js new file mode 100644 index 0000000..b4a81be --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-month.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(new Date(2000, 0, 15, 13, 32, 34, 234)).valueOf(), + new Date(2000, 0, 1).valueOf()); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-year.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-year.js new file mode 100644 index 0000000..aae117e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/floor-year.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(new Date(2000, 5, 13, 13, 32, 34, 234)).valueOf(), + new Date(2000, 0, 1).valueOf()); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/format.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/format.js new file mode 100644 index 0000000..e68e4bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/#/format.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + var dt = new Date(2011, 2, 3, 3, 5, 5, 32); + a(t.call(dt, ' %Y.%y.%m.%d.%H.%M.%S.%L '), ' 2011.11.03.03.03.05.05.032 '); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/is-date.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/is-date.js new file mode 100644 index 0000000..109093d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/is-date.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t('arar'), false, "String"); + a(t(12), false, "Number"); + a(t(true), false, "Boolean"); + a(t(new Date()), true, "Date"); + a(t(new String('raz')), false, "String object"); + a(t({}), false, "Plain object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/valid-date.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/valid-date.js new file mode 100644 index 0000000..98787e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/date/valid-date.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var d = new Date(); + a(t(d), d, "Date"); + a.throws(function () { + t({}); + }, "Object"); + a.throws(function () { + t({ valueOf: function () { return 20; } }); + }, "Number object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/#/throw.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/#/throw.js new file mode 100644 index 0000000..1213cfc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/#/throw.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var e = new Error(); + try { + t.call(e); + } catch (e2) { + a(e2, e); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/custom.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/custom.js new file mode 100644 index 0000000..d4ff500 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/custom.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var T = t, err = new T('My Error', 'MY_ERROR', { errno: 123 }); + a(err instanceof Error, true, "Instance of error"); + a(err.constructor, Error, "Constructor"); + a(err.name, 'Error', "Name"); + a(String(err), 'Error: My Error', "String representation"); + a(err.code, 'MY_ERROR', "Code"); + a(err.errno, 123, "Errno"); + a(typeof err.stack, 'string', "Stack trace"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/is-error.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/is-error.js new file mode 100644 index 0000000..f8b5e20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/is-error.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(), false, "Undefined"); + a(t(1), false, "Primitive"); + a(t({}), false, "Objectt"); + a(t({ toString: function () { return '[object Error]'; } }), false, + "Fake error"); + a(t(new Error()), true, "Error"); + a(t(new EvalError()), true, "EvalError"); + a(t(new RangeError()), true, "RangeError"); + a(t(new ReferenceError()), true, "ReferenceError"); + a(t(new SyntaxError()), true, "SyntaxError"); + a(t(new TypeError()), true, "TypeError"); + a(t(new URIError()), true, "URIError"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/valid-error.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/valid-error.js new file mode 100644 index 0000000..e04cdb3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/error/valid-error.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + var e = new Error(); + a(t(e), e, "Error"); + a.throws(function () { + t({}); + }, "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/compose.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/compose.js new file mode 100644 index 0000000..83de5e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/compose.js @@ -0,0 +1,9 @@ +'use strict'; + +var f = function (a, b) { return ['a', arguments.length, a, b]; } + , g = function (a) { return ['b', arguments.length].concat(a); } + , h = function (a) { return ['c', arguments.length].concat(a); }; + +module.exports = function (t, a) { + a.deep(t.call(h, g, f)(1, 2), ['c', 1, 'b', 1, 'a', 2, 1, 2]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/copy.js new file mode 100644 index 0000000..7a22e2f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/copy.js @@ -0,0 +1,19 @@ +'use strict'; + +module.exports = function (t, a) { + var foo = 'raz', bar = 'dwa' + , fn = function marko(a, b) { return this + a + b + foo + bar; } + , result, o = {}; + + fn.prototype = o; + + fn.foo = 'raz'; + + result = t.call(fn); + + a(result.length, fn.length, "Length"); + a(result.name, fn.name, "Length"); + a(result.call('marko', 'el', 'fe'), 'markoelferazdwa', "Body"); + a(result.prototype, fn.prototype, "Prototype"); + a(result.foo, fn.foo, "Custom property"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/curry.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/curry.js new file mode 100644 index 0000000..18fb038 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/curry.js @@ -0,0 +1,18 @@ +'use strict'; + +var toArray = require('../../../array/to-array') + + , f = function () { return toArray(arguments); }; + +module.exports = function (t, a) { + var x, y = {}, z; + a.deep(t.call(f, 0, 1, 2)(3), [], "0 arguments"); + x = t.call(f, 5, {}); + a(x.length, 5, "Length #1"); + z = x(1, 2); + a(z.length, 3, "Length #2"); + z = z(3, 4); + a(z.length, 1, "Length #1"); + a.deep(z(5, 6), [1, 2, 3, 4, 5], "Many arguments"); + a.deep(x(8, 3)(y, 45)('raz', 6), [8, 3, y, 45, 'raz'], "Many arguments #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/lock.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/lock.js new file mode 100644 index 0000000..44a12d7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/lock.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(function () { + return arguments.length; + })(1, 2, 3), 0); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/not.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/not.js new file mode 100644 index 0000000..c0f5e9d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/not.js @@ -0,0 +1,11 @@ +'use strict'; + +var identity = require('../../../function/identity') + , noop = require('../../../function/noop'); + +module.exports = function (t, a) { + a(t.call(identity)(''), true, "Falsy"); + a(t.call(noop)(), true, "Undefined"); + a(t.call(identity)({}), false, "Any object"); + a(t.call(identity)(true), false, "True"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/partial.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/partial.js new file mode 100644 index 0000000..bd00ce7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/partial.js @@ -0,0 +1,9 @@ +'use strict'; + +var toArray = require('../../../array/to-array') + + , f = function () { return toArray(arguments); }; + +module.exports = function (t, a) { + a.deep(t.call(f, 1)(2, 3), [1, 2, 3]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/spread.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/spread.js new file mode 100644 index 0000000..b82dfec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/spread.js @@ -0,0 +1,8 @@ +'use strict'; + +var f = function (a, b) { return this[a] + this[b]; } + , o = { a: 3, b: 4 }; + +module.exports = function (t, a) { + a(t.call(f).call(o, ['a', 'b']), 7); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/to-string-tokens.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/to-string-tokens.js new file mode 100644 index 0000000..4c54d30 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/#/to-string-tokens.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t.call(function (a, b) { return this[a] + this[b]; }), + { args: 'a, b', body: ' return this[a] + this[b]; ' }); + a.deep(t.call(function () {}), + { args: '', body: '' }); + a.deep(t.call(function (raz) {}), + { args: 'raz', body: '' }); + a.deep(t.call(function () { Object(); }), + { args: '', body: ' Object(); ' }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/_define-length.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/_define-length.js new file mode 100644 index 0000000..8f037e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/_define-length.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var foo = 'raz', bar = 'dwa' + , fn = function (a, b) { return this + a + b + foo + bar; } + , result; + + result = t(fn, 3); + a(result.call('marko', 'el', 'fe'), 'markoelferazdwa', "Content"); + a(result.length, 3, "Length"); + a(result.prototype, fn.prototype, "Prototype"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/constant.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/constant.js new file mode 100644 index 0000000..fda52aa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/constant.js @@ -0,0 +1,7 @@ +'use strict'; + +var o = {}; + +module.exports = function (t, a) { + a(t(o)(), o); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/identity.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/identity.js new file mode 100644 index 0000000..8013e2e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/identity.js @@ -0,0 +1,7 @@ +'use strict'; + +var o = {}; + +module.exports = function (t, a) { + a(t(o), o); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/invoke.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/invoke.js new file mode 100644 index 0000000..fcce4aa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/invoke.js @@ -0,0 +1,9 @@ +'use strict'; + +var constant = require('../../function/constant') + + , o = { b: constant('c') }; + +module.exports = function (t, a) { + a(t('b')(o), 'c'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-arguments.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-arguments.js new file mode 100644 index 0000000..f8de881 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-arguments.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + var args, dummy; + args = (function () { return arguments; }()); + dummy = { '0': 1, '1': 2 }; + Object.defineProperty(dummy, 'length', { value: 2 }); + a(t(args), true, "Arguments"); + a(t(dummy), false, "Dummy"); + a(t([]), false, "Array"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-function.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-function.js new file mode 100644 index 0000000..83acc42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/is-function.js @@ -0,0 +1,8 @@ +'use strict'; + +var o = { call: Function.prototype.call, apply: Function.prototype.apply }; + +module.exports = function (t, a) { + a(t(function () {}), true, "Function is function"); + a(t(o), false, "Plain object is not function"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/noop.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/noop.js new file mode 100644 index 0000000..4305c6f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/noop.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(typeof t(1, 2, 3), 'undefined'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/pluck.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/pluck.js new file mode 100644 index 0000000..5bf9583 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/pluck.js @@ -0,0 +1,7 @@ +'use strict'; + +var o = { foo: 'bar' }; + +module.exports = function (t, a) { + a(t('foo')(o), o.foo); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/valid-function.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/valid-function.js new file mode 100644 index 0000000..59b1623 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/function/valid-function.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function (t, a) { + var f = function () {}; + a(t(f), f, "Function"); + f = new Function(); + a(t(f), f, "Function"); + a.throws(function () { + t({}); + }, "Object"); + a.throws(function () { + t(/re/); + }, "RegExp"); + a.throws(function () { + t({ call: function () { return 20; } }); + }, "Plain object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/global.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/global.js new file mode 100644 index 0000000..1f452ae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/global.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a.ok(t && typeof t === 'object'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/for-each.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/for-each.js new file mode 100644 index 0000000..0fed8ad --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/for-each.js @@ -0,0 +1,40 @@ +'use strict'; + +var ArrayIterator = require('es6-iterator/array') + + , slice = Array.prototype.slice; + +module.exports = function (t, a) { + var i = 0, x = ['raz', 'dwa', 'trzy'], y = {}; + t(x, function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Array " + i + "#"); + a(this, y, "Array: context: " + (i++) + "#"); + }, y); + i = 0; + t((function () { return arguments; }('raz', 'dwa', 'trzy')), function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Arguments" + i + "#"); + a(this, y, "Arguments: context: " + (i++) + "#"); + }, y); + i = 0; + t({ 0: 'raz', 1: 'dwa', 2: 'trzy', length: 3 }, function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Array-like" + i + "#"); + a(this, y, "Array-like: context: " + (i++) + "#"); + }, y); + i = 0; + t(x = 'foo', function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); + a(this, y, "Regular String: context: " + (i++) + "#"); + }, y); + i = 0; + x = ['r', '💩', 'z']; + t('r💩z', function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); + a(this, y, "Unicode String: context: " + (i++) + "#"); + }, y); + i = 0; + t(new ArrayIterator(x), function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Iterator " + i + "#"); + a(this, y, "Iterator: context: " + (i++) + "#"); + }, y); + +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/is.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/is.js new file mode 100644 index 0000000..c0d2a43 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/is.js @@ -0,0 +1,20 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (t, a) { + var x; + a(t([]), true, "Array"); + a(t(""), true, "String"); + a(t((function () { return arguments; }())), true, "Arguments"); + a(t({ length: 0 }), true, "List object"); + a(t(function () {}), false, "Function"); + a(t({}), false, "Plain object"); + a(t(/raz/), false, "Regexp"); + a(t(), false, "No argument"); + a(t(null), false, "Null"); + a(t(undefined), false, "Undefined"); + x = {}; + x[iteratorSymbol] = function () {}; + a(t(x), true, "Iterable"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate-object.js new file mode 100644 index 0000000..da12529 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate-object.js @@ -0,0 +1,20 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(0); }, TypeError, "0"); + a.throws(function () { t(false); }, TypeError, "false"); + a.throws(function () { t(''); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Plain Object"); + a.throws(function () { t(function () {}); }, TypeError, "Function"); + a(t(x = new String('raz')), x, "String object"); //jslint: ignore + + a(t(x = { length: 1 }), x, "Array like"); + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "null"); + x = {}; + x[iteratorSymbol] = function () {}; + a(t(x), x, "Iterable"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate.js new file mode 100644 index 0000000..bcc2ad3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/iterable/validate.js @@ -0,0 +1,20 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(0); }, TypeError, "0"); + a.throws(function () { t(false); }, TypeError, "false"); + a(t(''), '', "''"); + a.throws(function () { t({}); }, TypeError, "Plain Object"); + a.throws(function () { t(function () {}); }, TypeError, "Function"); + a(t(x = new String('raz')), x, "String object"); //jslint: ignore + + a(t(x = { length: 1 }), x, "Array like"); + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "null"); + x = {}; + x[iteratorSymbol] = function () {}; + a(t(x), x, "Iterable"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_pack-ieee754.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_pack-ieee754.js new file mode 100644 index 0000000..9041431 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_pack-ieee754.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t(1.337, 8, 23), [63, 171, 34, 209]); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_unpack-ieee754.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_unpack-ieee754.js new file mode 100644 index 0000000..ca30b82 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/_unpack-ieee754.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t([63, 171, 34, 209], 8, 23), 1.3370000123977661); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/implement.js new file mode 100644 index 0000000..01fb6d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/acosh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/shim.js new file mode 100644 index 0000000..3d710c7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/acosh/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(-1), NaN, "Negative"); + a(t(0), NaN, "Zero"); + a(t(0.5), NaN, "Below 1"); + a(t(1), 0, "1"); + a(t(2), 1.3169578969248166, "Other"); + a(t(Infinity), Infinity, "Infinity"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/implement.js new file mode 100644 index 0000000..d1fcece --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/asinh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/shim.js new file mode 100644 index 0000000..d9fbe49 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/asinh/shim.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -Infinity, "-Infinity"); + a(t(-2), -1.4436354751788103, "Negative"); + a(t(2), 1.4436354751788103, "Positive"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/implement.js new file mode 100644 index 0000000..cba8fad --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/atanh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/shim.js new file mode 100644 index 0000000..a857b49 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/atanh/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(-2), NaN, "Less than -1"); + a(t(2), NaN, "Greater than 1"); + a(t(-1), -Infinity, "-1"); + a(t(1), Infinity, "1"); + a(t(0), 0, "Zero"); + a(t(0.5), 0.5493061443340549, "Ohter"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/implement.js new file mode 100644 index 0000000..374d4b3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/cbrt/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/shim.js new file mode 100644 index 0000000..43ab68b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cbrt/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -Infinity, "-Infinity"); + a(t(-1), -1, "-1"); + a(t(1), 1, "1"); + a(t(2), 1.2599210498948732, "Ohter"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/implement.js new file mode 100644 index 0000000..44f8815 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/clz32/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/shim.js new file mode 100644 index 0000000..a769b39 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/clz32/shim.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(1), 31, "1"); + a(t(1000), 22, "1000"); + a(t(), 32, "No arguments"); + a(t(Infinity), 32, "Infinity"); + a(t(-Infinity), 32, "-Infinity"); + a(t("foo"), 32, "String"); + a(t(true), 31, "Boolean"); + a(t(3.5), 30, "Float"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/implement.js new file mode 100644 index 0000000..f3c712b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/cosh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/shim.js new file mode 100644 index 0000000..419c123 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/cosh/shim.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 1, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), Infinity, "-Infinity"); + a(t(1), 1.5430806348152437, "1"); + a(t(Number.MAX_VALUE), Infinity); + a(t(-Number.MAX_VALUE), Infinity); + a(t(Number.MIN_VALUE), 1); + a(t(-Number.MIN_VALUE), 1); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/implement.js new file mode 100644 index 0000000..c212967 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/expm1/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/shim.js new file mode 100644 index 0000000..15f0e79 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/expm1/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -1, "-Infinity"); + a(t(1).toFixed(15), '1.718281828459045', "1"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/implement.js new file mode 100644 index 0000000..c909af7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/fround/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/shim.js new file mode 100644 index 0000000..4ef6d4e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/fround/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -Infinity, "-Infinity"); + a(t(1.337), 1.3370000123977661, "1"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/implement.js new file mode 100644 index 0000000..9946646 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/hypot/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/shim.js new file mode 100644 index 0000000..91d950a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/hypot/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(), 0, "No arguments"); + a(t(0, -0, 0), 0, "Zeros"); + a(t(4, NaN, Infinity), Infinity, "Infinity"); + a(t(4, NaN, -Infinity), Infinity, "Infinity"); + a(t(4, NaN, 34), NaN, "NaN"); + a(t(3, 4), 5, "#1"); + a(t(3, 4, 5), 7.0710678118654755, "#2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/implement.js new file mode 100644 index 0000000..7b2a2a6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/imul/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/shim.js new file mode 100644 index 0000000..a2ca7fe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/imul/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(), 0, "No arguments"); + a(t(0, 0), 0, "Zeros"); + a(t(2, 4), 8, "#1"); + a(t(-1, 8), -8, "#2"); + a(t(0xfffffffe, 5), -10, "#3"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/implement.js new file mode 100644 index 0000000..4b3b4a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/log10/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/shim.js new file mode 100644 index 0000000..5fa0d5b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log10/shim.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(-0.5), NaN, "Less than 0"); + a(t(0), -Infinity, "0"); + a(t(1), 0, "1"); + a(t(Infinity), Infinity, "Infinity"); + a(t(2), 0.3010299956639812, "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/implement.js new file mode 100644 index 0000000..5d269bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/log1p/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/shim.js new file mode 100644 index 0000000..d495ce0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log1p/shim.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(-1.5), NaN, "Less than -1"); + a(t(-1), -Infinity, "-1"); + a(t(0), 0, "0"); + a(t(Infinity), Infinity, "Infinity"); + a(t(1), 0.6931471805599453, "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/implement.js new file mode 100644 index 0000000..92b501a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/log2/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/shim.js new file mode 100644 index 0000000..faa9c32 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/log2/shim.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(-0.5), NaN, "Less than 0"); + a(t(0), -Infinity, "0"); + a(t(1), 0, "1"); + a(t(Infinity), Infinity, "Infinity"); + a(t(3).toFixed(15), '1.584962500721156', "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/implement.js new file mode 100644 index 0000000..5875c42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/sign/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/shim.js new file mode 100644 index 0000000..b6b89c1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sign/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +var is = require('../../../object/is'); + +module.exports = function (t, a) { + a(is(t(0), +0), true, "+0"); + a(is(t(-0), -0), true, "-0"); + a(t({}), NaN, true, "NaN"); + a(t(-234234234), -1, "Negative"); + a(t(234234234), 1, "Positive"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/implement.js new file mode 100644 index 0000000..e52089e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/sinh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/shim.js new file mode 100644 index 0000000..4f63b59 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/sinh/shim.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -Infinity, "-Infinity"); + a(t(1), 1.1752011936438014, "1"); + a(t(Number.MAX_VALUE), Infinity); + a(t(-Number.MAX_VALUE), -Infinity); + a(t(Number.MIN_VALUE), 5e-324); + a(t(-Number.MIN_VALUE), -5e-324); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/implement.js new file mode 100644 index 0000000..a96bf19 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/tanh/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/shim.js new file mode 100644 index 0000000..2c67aaf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/tanh/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), 1, "Infinity"); + a(t(-Infinity), -1, "-Infinity"); + a(t(1), 0.7615941559557649, "1"); + a(t(Number.MAX_VALUE), 1); + a(t(-Number.MAX_VALUE), -1); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/implement.js new file mode 100644 index 0000000..1830e61 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../math/trunc/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/shim.js new file mode 100644 index 0000000..9e5eed7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/math/trunc/shim.js @@ -0,0 +1,16 @@ +'use strict'; + +var is = require('../../../object/is'); + +module.exports = function (t, a) { + a(t({}), NaN, "NaN"); + a(t(0), 0, "Zero"); + a(t(Infinity), Infinity, "Infinity"); + a(t(-Infinity), -Infinity, "-Infinity"); + a(is(t(0.234), 0), true, "0"); + a(is(t(-0.234), -0), true, "-0"); + a(t(13.7), 13, "Positive #1"); + a(t(12.3), 12, "Positive #2"); + a(t(-12.3), -12, "Negative #1"); + a(t(-14.7), -14, "Negative #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/#/pad.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/#/pad.js new file mode 100644 index 0000000..e020823 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/#/pad.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(78, 4), '0078'); + a(t.call(65.12323, 4, 3), '0065.123', "Precision"); + a(t.call(65, 4, 3), '0065.000', "Precision integer"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/implement.js new file mode 100644 index 0000000..574da75 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/epsilon/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/index.js new file mode 100644 index 0000000..c892fd4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(typeof t, 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/epsilon/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/implement.js new file mode 100644 index 0000000..b35345f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/is-finite/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/shim.js new file mode 100644 index 0000000..5205d1c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-finite/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(2), true, "Number"); + a(t('23'), false, "Not numeric"); + a(t(NaN), false, "NaN"); + a(t(Infinity), false, "Infinity"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/implement.js new file mode 100644 index 0000000..127149c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/is-integer/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/shim.js new file mode 100644 index 0000000..3f3985c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-integer/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(2), true, "Number"); + a(t(2.34), false, "Float"); + a(t('23'), false, "Not numeric"); + a(t(NaN), false, "NaN"); + a(t(Infinity), false, "Infinity"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/implement.js new file mode 100644 index 0000000..2f01d6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/is-nan/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/shim.js new file mode 100644 index 0000000..425723e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-nan/shim.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(2), false, "Number"); + a(t({}), false, "Not numeric"); + a(t(NaN), true, "NaN"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-number.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-number.js new file mode 100644 index 0000000..2751334 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-number.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(0), true, "Zero"); + a(t(NaN), true, "NaN"); + a(t(Infinity), true, "Infinity"); + a(t(12), true, "Number"); + a(t(false), false, "Boolean"); + a(t(new Date()), false, "Date"); + a(t(new Number(2)), true, "Number object"); + a(t('asdfaf'), false, "String"); + a(t(''), false, "Empty String"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/implement.js new file mode 100644 index 0000000..33667e2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/is-safe-integer/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/shim.js new file mode 100644 index 0000000..77e0667 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/is-safe-integer/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(2), true, "Number"); + a(t(2.34), false, "Float"); + a(t(Math.pow(2, 53)), false, "Too large"); + a(t(Math.pow(2, 53) - 1), true, "Maximum"); + a(t('23'), false, "Not numeric"); + a(t(NaN), false, "NaN"); + a(t(Infinity), false, "Infinity"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/implement.js new file mode 100644 index 0000000..bef00ca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/max-safe-integer/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/index.js new file mode 100644 index 0000000..c892fd4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(typeof t, 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/implement.js new file mode 100644 index 0000000..fa44024 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../number/min-safe-integer/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/index.js new file mode 100644 index 0000000..c892fd4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(typeof t, 'number'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-integer.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-integer.js new file mode 100644 index 0000000..ff326ba --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-integer.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), 0, "NaN"); + a(t(20), 20, "Positive integer"); + a(t('-20'), -20, "String negative integer"); + a(t(Infinity), Infinity, "Infinity"); + a(t(15.343), 15, "Float"); + a(t(-15.343), -15, "Negative float"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-pos-integer.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-pos-integer.js new file mode 100644 index 0000000..2f3b4e6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-pos-integer.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), 0, "NaN"); + a(t(20), 20, "Positive integer"); + a(t(-20), 0, "Negative integer"); + a(t(Infinity), Infinity, "Infinity"); + a(t(15.343), 15, "Float"); + a(t(-15.343), 0, "Negative float"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-uint32.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-uint32.js new file mode 100644 index 0000000..00d05bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/number/to-uint32.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), 0, "Not numeric"); + a(t(-4), 4294967292, "Negative"); + a(t(133432), 133432, "Positive"); + a(t(8589934592), 0, "Greater than maximum"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/_iterate.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/_iterate.js new file mode 100644 index 0000000..179afed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/_iterate.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = function (t, a) { + var o = { raz: 1, dwa: 2, trzy: 3 } + , o2 = {}, o3 = {}, arr, i = -1; + + t = t('forEach'); + t(o, function (value, name, self, index) { + o2[name] = value; + a(index, ++i, "Index"); + a(self, o, "Self"); + a(this, o3, "Scope"); + }, o3); + a.deep(o2, o); + + arr = []; + o2 = {}; + i = -1; + t(o, function (value, name, self, index) { + arr.push(value); + o2[name] = value; + a(index, ++i, "Index"); + a(self, o, "Self"); + a(this, o3, "Scope"); + }, o3, function (a, b) { + return o[b] - o[a]; + }); + a.deep(o2, o, "Sort by Values: Content"); + a.deep(arr, [3, 2, 1], "Sort by Values: Order"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/implement.js new file mode 100644 index 0000000..4006559 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../object/assign/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/shim.js new file mode 100644 index 0000000..9afe5f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/assign/shim.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + var o1 = { a: 1, b: 2 } + , o2 = { b: 3, c: 4 }; + + a(t(o1, o2), o1, "Returns self"); + a.deep(o1, { a: 1, b: 3, c: 4 }, "Single: content"); + + a.deep(t({}, o1, o2), { a: 1, b: 3, c: 4 }, "Multi argument"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/clear.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/clear.js new file mode 100644 index 0000000..bfc08cc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/clear.js @@ -0,0 +1,13 @@ +'use strict'; + +var isEmpty = require('../../object/is-empty'); + +module.exports = function (t, a) { + var x = {}; + a(t(x), x, "Empty: Returns same object"); + a(isEmpty(x), true, "Empty: Not changed"); + x.foo = 'raz'; + x.bar = 'dwa'; + a(t(x), x, "Same object"); + a(isEmpty(x), true, "Emptied"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compact.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compact.js new file mode 100644 index 0000000..9c9064c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compact.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}, y = {}, z; + z = t(x); + a.not(z, x, "Returns different object"); + a.deep(z, {}, "Empty on empty"); + + x = { foo: 'bar', a: 0, b: false, c: '', d: '0', e: null, bar: y, + elo: undefined }; + z = t(x); + a.deep(z, { foo: 'bar', a: 0, b: false, c: '', d: '0', bar: y }, + "Cleared null values"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compare.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compare.js new file mode 100644 index 0000000..cb94241 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/compare.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + var d = new Date(); + + a.ok(t(12, 3) > 0, "Numbers"); + a.ok(t(2, 13) < 0, "Numbers #2"); + a.ok(t("aaa", "aa") > 0, "Strings"); + a.ok(t("aa", "ab") < 0, "Strings #2"); + a(t("aa", "aa"), 0, "Strings same"); + a(t(d, new Date(d.getTime())), 0, "Same date"); + a.ok(t(d, new Date(d.getTime() + 1)) < 0, "Different date"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy-deep.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy-deep.js new file mode 100644 index 0000000..a4023bc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy-deep.js @@ -0,0 +1,24 @@ +'use strict'; + +var stringify = JSON.stringify; + +module.exports = function (t, a) { + var o = { 1: 'raz', 2: 'dwa', 3: 'trzy' } + , no = t(o); + + a.not(no, o, "Return different object"); + a(stringify(no), stringify(o), "Match properties and values"); + + o = { foo: 'bar', raz: { dwa: 'dwa', + trzy: { cztery: 'pięć', 'sześć': 'siedem' }, osiem: {}, + 'dziewięć': function () { } }, 'dziesięć': 10 }; + o.raz.rec = o; + + no = t(o); + a.not(o.raz, no.raz, "Deep"); + a.not(o.raz.trzy, no.raz.trzy, "Deep #2"); + a(stringify(o.raz.trzy), stringify(no.raz.trzy), "Deep content"); + a(no.raz.rec, no, "Recursive"); + a.not(o.raz.osiem, no.raz.osiem, "Empty object"); + a(o.raz['dziewięć'], no.raz['dziewięć'], "Function"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy.js new file mode 100644 index 0000000..2f222ef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/copy.js @@ -0,0 +1,19 @@ +'use strict'; + +var stringify = JSON.stringify; + +module.exports = function (t, a) { + var o = { 1: 'raz', 2: 'dwa', 3: 'trzy' } + , no = t(o); + + a.not(no, o, "Return different object"); + a(stringify(no), stringify(o), "Match properties and values"); + + o = { foo: 'bar', raz: { dwa: 'dwa', + trzy: { cztery: 'pięć', 'sześć': 'siedem' }, osiem: {}, + 'dziewięć': function () { } }, 'dziesięć': 10 }; + o.raz.rec = o; + + no = t(o); + a(o.raz, no.raz, "Shallow"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/count.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/count.js new file mode 100644 index 0000000..494f4f1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/count.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), 0, "Empty"); + a(t({ raz: 1, dwa: null, trzy: undefined, cztery: 0 }), 4, + "Some properties"); + a(t(Object.defineProperties({}, { + raz: { value: 'raz' }, + dwa: { value: 'dwa', enumerable: true } + })), 1, "Some properties hidden"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/create.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/create.js new file mode 100644 index 0000000..8b7be21 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/create.js @@ -0,0 +1,22 @@ +'use strict'; + +var setPrototypeOf = require('../../object/set-prototype-of') + + , getPrototypeOf = Object.getPrototypeOf; + +module.exports = function (t, a) { + var x = {}, obj; + + a(getPrototypeOf(t(x)), x, "Normal object"); + a(getPrototypeOf(t(null)), + (setPrototypeOf && setPrototypeOf.nullPolyfill) || null, "Null"); + + a.h1("Properties"); + a.h2("Normal object"); + a(getPrototypeOf(obj = t(x, { foo: { value: 'bar' } })), x, "Prototype"); + a(obj.foo, 'bar', "Property"); + a.h2("Null"); + a(getPrototypeOf(obj = t(null, { foo: { value: 'bar2' } })), + (setPrototypeOf && setPrototypeOf.nullPolyfill) || null, "Prototype"); + a(obj.foo, 'bar2', "Property"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/eq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/eq.js new file mode 100644 index 0000000..02b3f00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/eq.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var o = {}; + a(t(o, {}), false, "Different objects"); + a(t(o, o), true, "Same objects"); + a(t('1', '1'), true, "Same primitive"); + a(t('1', 1), false, "Different primitive types"); + a(t(NaN, NaN), true, "NaN"); + a(t(0, 0), true, "0,0"); + a(t(0, -0), true, "0,-0"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/every.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/every.js new file mode 100644 index 0000000..07d5bbb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/every.js @@ -0,0 +1,21 @@ +'use strict'; + +var o = { 1: 1, 2: 2, 3: 3 }; + +module.exports = function (t, a) { + var o2 = {}; + t(o, function (value, name) { + o2[name] = value; + return true; + }); + a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); + + a(t(o, function () { + return true; + }), true, "Succeeds"); + + a(t(o, function () { + return false; + }), false, "Fails"); + +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/filter.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/filter.js new file mode 100644 index 0000000..7307da8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/filter.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t({ 1: 1, 2: 2, 3: 3, 4: 4 }, + function (value) { return Boolean(value % 2); }), { 1: 1, 3: 3 }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/first-key.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/first-key.js new file mode 100644 index 0000000..8169cd2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/first-key.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}, y = Object.create(null); + a(t(x), null, "Normal: Empty"); + a(t(y), null, "Null extension: Empty"); + x.foo = 'raz'; + x.bar = 343; + a(['foo', 'bar'].indexOf(t(x)) !== -1, true, "Normal"); + y.elo = 'foo'; + y.mar = 'wew'; + a(['elo', 'mar'].indexOf(t(y)) !== -1, true, "Null extension"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/flatten.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/flatten.js new file mode 100644 index 0000000..ca342ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/flatten.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t({ a: { aa: 1, ab: 2 }, b: { ba: 3, bb: 4 } }), + { aa: 1, ab: 2, ba: 3, bb: 4 }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/for-each.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/for-each.js new file mode 100644 index 0000000..8690d1e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/for-each.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var o = { raz: 1, dwa: 2, trzy: 3 } + , o2 = {}; + a(t(o, function (value, name) { + o2[name] = value; + }), undefined, "Return"); + a.deep(o2, o); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/get-property-names.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/get-property-names.js new file mode 100644 index 0000000..b91c3dd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/get-property-names.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function (t, a) { + var o = { first: 1, second: 4 }, r1, r2; + o = Object.create(o, { + third: { value: null } + }); + o.first = 2; + o = Object.create(o); + o.fourth = 3; + + r1 = t(o); + r1.sort(); + r2 = ['first', 'second', 'third', 'fourth'] + .concat(Object.getOwnPropertyNames(Object.prototype)); + r2.sort(); + a.deep(r1, r2); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-array-like.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-array-like.js new file mode 100644 index 0000000..6295973 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-array-like.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function (t, a) { + a(t([]), true, "Array"); + a(t(""), true, "String"); + a(t((function () { return arguments; }())), true, "Arguments"); + a(t({ length: 0 }), true, "List object"); + a(t(function () {}), false, "Function"); + a(t({}), false, "Plain object"); + a(t(/raz/), false, "Regexp"); + a(t(), false, "No argument"); + a(t(null), false, "Null"); + a(t(undefined), false, "Undefined"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-callable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-callable.js new file mode 100644 index 0000000..625e221 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-callable.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(function () {}), true, "Function"); + a(t({}), false, "Object"); + a(t(), false, "Undefined"); + a(t(null), false, "Null"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy-deep.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy-deep.js new file mode 100644 index 0000000..4f14cbb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy-deep.js @@ -0,0 +1,46 @@ +'use strict'; + +module.exports = function (t, a) { + var x, y; + + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 3 }), true, "Same"); + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 4 }), false, + "Different property value"); + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2 }), false, + "Property only in source"); + a(t({ 1: 1, 2: 2 }, { 1: 1, 2: 2, 3: 4 }), false, + "Property only in target"); + + a(t("raz", "dwa"), false, "String: diff"); + a(t("raz", "raz"), true, "String: same"); + a(t("32", 32), false, "String & Number"); + + a(t([1, 'raz', true], [1, 'raz', true]), true, "Array: same"); + a(t([1, 'raz', undefined], [1, 'raz']), false, "Array: diff"); + a(t(['foo'], ['one']), false, "Array: One value comparision"); + + x = { foo: { bar: { mar: {} } } }; + y = { foo: { bar: { mar: {} } } }; + a(t(x, y), true, "Deep"); + + a(t({ foo: { bar: { mar: 'foo' } } }, { foo: { bar: { mar: {} } } }), + false, "Deep: false"); + + x = { foo: { bar: { mar: {} } } }; + x.rec = { foo: x }; + + y = { foo: { bar: { mar: {} } } }; + y.rec = { foo: x }; + + a(t(x, y), true, "Object: Infinite Recursion: Same #1"); + + x.rec.foo = y; + a(t(x, y), true, "Object: Infinite Recursion: Same #2"); + + x.rec.foo = x; + y.rec.foo = y; + a(t(x, y), true, "Object: Infinite Recursion: Same #3"); + + y.foo.bar.mar = 'raz'; + a(t(x, y), false, "Object: Infinite Recursion: Diff"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy.js new file mode 100644 index 0000000..394e2ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-copy.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 3 }), true, "Same"); + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 4 }), false, + "Different property value"); + a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2 }), false, + "Property only in source"); + a(t({ 1: 1, 2: 2 }, { 1: 1, 2: 2, 3: 4 }), false, + "Property only in target"); + + a(t("raz", "dwa"), false, "String: diff"); + a(t("raz", "raz"), true, "String: same"); + a(t("32", 32), false, "String & Number"); + + a(t([1, 'raz', true], [1, 'raz', true]), true, "Array: same"); + a(t([1, 'raz', undefined], [1, 'raz']), false, "Array: diff"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-empty.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-empty.js new file mode 100644 index 0000000..b560c2c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-empty.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), true, "Empty"); + a(t({ 1: 1 }), false, "Not empty"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-object.js new file mode 100644 index 0000000..72c8aa6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-object.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function (t, a) { + a(t('arar'), false, "String"); + a(t(12), false, "Number"); + a(t(true), false, "Boolean"); + a(t(null), false, "Null"); + a(t(new Date()), true, "Date"); + a(t(new String('raz')), true, "String object"); + a(t({}), true, "Plain object"); + a(t(/a/), true, "Regular expression"); + a(t(function () {}), true, "Function"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-plain-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-plain-object.js new file mode 100644 index 0000000..e988829 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is-plain-object.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function (t, a) { + a(t({}), true, "Empty {} is plain object"); + a(t({ a: true }), true, "{} with property is plain object"); + a(t({ prototype: 1, constructor: 2, __proto__: 3 }), true, + "{} with any property keys is plain object"); + a(t(null), false, "Null is not plain object"); + a(t('string'), false, "Primitive is not plain object"); + a(t(function () {}), false, "Function is not plain object"); + a(t(Object.create({})), false, + "Object whose prototype is not Object.prototype is not plain object"); + a(t(Object.create(Object.prototype)), true, + "Object whose prototype is Object.prototype is plain object"); + a(t(Object.create(null)), true, + "Object whose prototype is null is plain object"); + a(t(Object.prototype), false, "Object.prototype"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is.js new file mode 100644 index 0000000..4f8948c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/is.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var o = {}; + a(t(o, {}), false, "Different objects"); + a(t(o, o), true, "Same objects"); + a(t('1', '1'), true, "Same primitive"); + a(t('1', 1), false, "Different primitive types"); + a(t(NaN, NaN), true, "NaN"); + a(t(0, 0), true, "0,0"); + a(t(0, -0), false, "0,-0"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/key-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/key-of.js new file mode 100644 index 0000000..a9225a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/key-of.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + var x = {}, y = {} + , o = { foo: 'bar', raz: x, trzy: 'cztery', five: '6' }; + + a(t(o, 'bar'), 'foo', "First property"); + a(t(o, 6), null, "Primitive that's not there"); + a(t(o, x), 'raz', "Object"); + a(t(o, y), null, "Object that's not there"); + a(t(o, '6'), 'five', "Last property"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/implement.js new file mode 100644 index 0000000..179e1e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../object/keys/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/shim.js new file mode 100644 index 0000000..ed29eeb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/keys/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t({ foo: 'bar' }), ['foo'], "Object"); + a.deep(t('raz'), ['0', '1', '2'], "Primitive"); + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Undefined"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map-keys.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map-keys.js new file mode 100644 index 0000000..be84825 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map-keys.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t({ 1: 1, 2: 2, 3: 3 }, function (key, value) { + return 'x' + (key + value); + }), { x11: 1, x22: 2, x33: 3 }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map.js new file mode 100644 index 0000000..f9cc09c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/map.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + var obj = { 1: 1, 2: 2, 3: 3 }; + a.deep(t(obj, function (value, key, context) { + a(context, obj, "Context argument"); + return (value + 1) + key; + }), { 1: '21', 2: '32', 3: '43' }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin-prototypes.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin-prototypes.js new file mode 100644 index 0000000..d1c727a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin-prototypes.js @@ -0,0 +1,67 @@ +'use strict'; + +module.exports = function (t, a) { + var o, o1, o2, x, y = {}, z = {}; + o = { inherited: true, visible: 23 }; + o1 = Object.create(o); + o1.visible = z; + o1.nonremovable = 'raz'; + Object.defineProperty(o1, 'hidden', { value: 'hidden' }); + + o2 = Object.defineProperties({}, { nonremovable: { value: y } }); + o2.other = 'other'; + + try { t(o2, o1); } catch (ignore) {} + + a(o2.visible, z, "Enumerable"); + a(o1.hidden, 'hidden', "Not Enumerable"); + a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); + a(o2.propertyIsEnumerable('hidden'), false, + "Not enumerable is not enumerable"); + + a(o2.inherited, true, "Extend deep"); + + a(o2.nonremovable, y, "Do not overwrite non configurable"); + a(o2.other, 'other', "Own kept"); + + x = {}; + t(x, o2); + try { t(x, o1); } catch (ignore) {} + + a(x.visible, z, "Enumerable"); + a(x.hidden, 'hidden', "Not Enumerable"); + a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); + a(x.propertyIsEnumerable('hidden'), false, + "Not enumerable is not enumerable"); + + a(x.inherited, true, "Extend deep"); + + a(x.nonremovable, y, "Ignored non configurable"); + a(x.other, 'other', "Other"); + + x.visible = 3; + a(x.visible, 3, "Writable is writable"); + + x = {}; + t(x, o1); + a.throws(function () { + x.hidden = 3; + }, "Not writable is not writable"); + + x = {}; + t(x, o1); + delete x.visible; + a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable"); + + x = {}; + t(x, o1); + a.throws(function () { + delete x.hidden; + }, "Not configurable is not configurable"); + + x = Object.defineProperty({}, 'foo', + { configurable: false, writable: true, enumerable: false, value: 'bar' }); + + try { t(x, { foo: 'lorem' }); } catch (ignore) {} + a(x.foo, 'bar', "Writable, not enumerable"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin.js new file mode 100644 index 0000000..866005b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/mixin.js @@ -0,0 +1,69 @@ +'use strict'; + +module.exports = function (t, a) { + var o, o1, o2, x, y = {}, z = {}; + o = { inherited: true }; + o1 = Object.create(o); + o1.visible = z; + o1.nonremovable = 'raz'; + Object.defineProperty(o1, 'hidden', { value: 'hidden' }); + + o2 = Object.defineProperties({}, { nonremovable: { value: y } }); + o2.other = 'other'; + + try { t(o2, o1); } catch (ignore) {} + + a(o2.visible, z, "Enumerable"); + a(o1.hidden, 'hidden', "Not Enumerable"); + a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); + a(o2.propertyIsEnumerable('hidden'), false, + "Not enumerable is not enumerable"); + + a(o2.hasOwnProperty('inherited'), false, "Extend only own"); + a(o2.inherited, undefined, "Extend ony own: value"); + + a(o2.nonremovable, y, "Do not overwrite non configurable"); + a(o2.other, 'other', "Own kept"); + + x = {}; + t(x, o2); + try { t(x, o1); } catch (ignore) {} + + a(x.visible, z, "Enumerable"); + a(x.hidden, 'hidden', "Not Enumerable"); + a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); + a(x.propertyIsEnumerable('hidden'), false, + "Not enumerable is not enumerable"); + + a(x.hasOwnProperty('inherited'), false, "Extend only own"); + a(x.inherited, undefined, "Extend ony own: value"); + + a(x.nonremovable, y, "Ignored non configurable"); + a(x.other, 'other', "Other"); + + x.visible = 3; + a(x.visible, 3, "Writable is writable"); + + x = {}; + t(x, o1); + a.throws(function () { + x.hidden = 3; + }, "Not writable is not writable"); + + x = {}; + t(x, o1); + delete x.visible; + a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable"); + + x = {}; + t(x, o1); + a.throws(function () { + delete x.hidden; + }, "Not configurable is not configurable"); + + x = Object.defineProperty({}, 'foo', + { configurable: false, writable: true, enumerable: false, value: 'bar' }); + + try { t(x, { foo: 'lorem' }); } catch (ignore) {} + a(x.foo, 'bar', "Writable, not enumerable"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/normalize-options.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/normalize-options.js new file mode 100644 index 0000000..0d2d4da --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/normalize-options.js @@ -0,0 +1,32 @@ +'use strict'; + +var create = Object.create, defineProperty = Object.defineProperty; + +module.exports = function (t, a) { + var x = { foo: 'raz', bar: 'dwa' }, y; + y = t(x); + a.not(y, x, "Returns copy"); + a.deep(y, x, "Plain"); + + x = { raz: 'one', dwa: 'two' }; + defineProperty(x, 'get', { + configurable: true, + enumerable: true, + get: function () { return this.dwa; } + }); + x = create(x); + x.trzy = 'three'; + x.cztery = 'four'; + x = create(x); + x.dwa = 'two!'; + x.trzy = 'three!'; + x.piec = 'five'; + x.szesc = 'six'; + + a.deep(t(x), { raz: 'one', dwa: 'two!', trzy: 'three!', cztery: 'four', + piec: 'five', szesc: 'six', get: 'two!' }, "Deep object"); + + a.deep(t({ marko: 'raz', raz: 'foo' }, x, { szesc: 'elo', siedem: 'bibg' }), + { marko: 'raz', raz: 'one', dwa: 'two!', trzy: 'three!', cztery: 'four', + piec: 'five', szesc: 'elo', siedem: 'bibg', get: 'two!' }, "Multiple options"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/primitive-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/primitive-set.js new file mode 100644 index 0000000..839857e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/primitive-set.js @@ -0,0 +1,15 @@ +'use strict'; + +var getPropertyNames = require('../../object/get-property-names') + , isPlainObject = require('../../object/is-plain-object'); + +module.exports = function (t, a) { + var x = t(); + a(isPlainObject(x), true, "Plain object"); + a.deep(getPropertyNames(x), [], "No properties"); + x.foo = 'bar'; + a.deep(getPropertyNames(x), ['foo'], "Extensible"); + + a.deep(t('raz', 'dwa', 3), { raz: true, dwa: true, 3: true }, + "Arguments handling"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/safe-traverse.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/safe-traverse.js new file mode 100644 index 0000000..d30cdef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/safe-traverse.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var obj = { foo: { bar: { lorem: 12 } } }; + a(t(obj), obj, "No props"); + a(t(obj, 'foo'), obj.foo, "One"); + a(t(obj, 'raz'), undefined, "One: Fail"); + a(t(obj, 'foo', 'bar'), obj.foo.bar, "Two"); + a(t(obj, 'dsd', 'raz'), undefined, "Two: Fail #1"); + a(t(obj, 'foo', 'raz'), undefined, "Two: Fail #2"); + a(t(obj, 'foo', 'bar', 'lorem'), obj.foo.bar.lorem, "Three"); + a(t(obj, 'dsd', 'raz', 'fef'), undefined, "Three: Fail #1"); + a(t(obj, 'foo', 'raz', 'asdf'), undefined, "Three: Fail #2"); + a(t(obj, 'foo', 'bar', 'asd'), undefined, "Three: Fail #3"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/serialize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/serialize.js new file mode 100644 index 0000000..43eed6a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/serialize.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = function (t, a) { + var fn = function (raz, dwa) { return raz + dwa; }; + a(t(), 'undefined', "Undefined"); + a(t(null), 'null', "Null"); + a(t(null), 'null', "Null"); + a(t('raz'), '"raz"', "String"); + a(t('raz"ddwa\ntrzy'), '"raz\\"ddwa\\ntrzy"', "String with escape"); + a(t(false), 'false', "Booelean"); + a(t(fn), String(fn), "Function"); + + a(t(/raz-dwa/g), '/raz-dwa/g', "RegExp"); + a(t(new Date(1234567)), 'new Date(1234567)', "Date"); + a(t([]), '[]', "Empty array"); + a(t([undefined, false, null, 'raz"ddwa\ntrzy', fn, /raz/g, new Date(1234567), ['foo']]), + '[undefined,false,null,"raz\\"ddwa\\ntrzy",' + String(fn) + + ',/raz/g,new Date(1234567),["foo"]]', "Rich Array"); + a(t({}), '{}', "Empty object"); + a(t({ raz: undefined, dwa: false, trzy: null, cztery: 'raz"ddwa\ntrzy', piec: fn, szesc: /raz/g, + siedem: new Date(1234567), osiem: ['foo', 32], dziewiec: { foo: 'bar', dwa: 343 } }), + '{"raz":undefined,"dwa":false,"trzy":null,"cztery":"raz\\"ddwa\\ntrzy","piec":' + String(fn) + + ',"szesc":/raz/g,"siedem":new Date(1234567),"osiem":["foo",32],' + + '"dziewiec":{"foo":"bar","dwa":343}}', "Rich object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/implement.js new file mode 100644 index 0000000..30b2ac4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +var create = require('../../../object/create') + , isImplemented = require('../../../object/set-prototype-of/is-implemented'); + +module.exports = function (a) { a(isImplemented(create), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/index.js new file mode 100644 index 0000000..aec2605 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/index.js @@ -0,0 +1,23 @@ +'use strict'; + +var create = require('../../../object/create') + + , getPrototypeOf = Object.getPrototypeOf; + +module.exports = function (t, a) { + var x = {}, y = {}; + + if (t === null) return; + a(t(x, y), x, "Return self object"); + a(getPrototypeOf(x), y, "Object"); + a.throws(function () { t(x); }, TypeError, "Undefined"); + a.throws(function () { t('foo'); }, TypeError, "Primitive"); + a(getPrototypeOf(t(x, null)), t.nullPolyfill || null, "Null"); + x = create(null); + a.h1("Change null prototype"); + a(t(x, y), x, "Result"); + a(getPrototypeOf(x), y, "Prototype"); + a.h1("Set null prototype"); + a(t(y, null), y, "Result"); + a(getPrototypeOf(y), t.nullPolyfill || null, "Prototype"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/shim.js new file mode 100644 index 0000000..aec2605 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/set-prototype-of/shim.js @@ -0,0 +1,23 @@ +'use strict'; + +var create = require('../../../object/create') + + , getPrototypeOf = Object.getPrototypeOf; + +module.exports = function (t, a) { + var x = {}, y = {}; + + if (t === null) return; + a(t(x, y), x, "Return self object"); + a(getPrototypeOf(x), y, "Object"); + a.throws(function () { t(x); }, TypeError, "Undefined"); + a.throws(function () { t('foo'); }, TypeError, "Primitive"); + a(getPrototypeOf(t(x, null)), t.nullPolyfill || null, "Null"); + x = create(null); + a.h1("Change null prototype"); + a(t(x, y), x, "Result"); + a(getPrototypeOf(x), y, "Prototype"); + a.h1("Set null prototype"); + a(t(y, null), y, "Result"); + a(getPrototypeOf(y), t.nullPolyfill || null, "Prototype"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/some.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/some.js new file mode 100644 index 0000000..490431e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/some.js @@ -0,0 +1,23 @@ +'use strict'; + +var o = { 1: 1, 2: 2, 3: 3 }; + +module.exports = function (t, a) { + var o2 = {}, i = 0; + t(o, function (value, name) { + o2[name] = value; + return false; + }); + a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); + + a(t(o, function () { + ++i; + return true; + }), true, "Succeeds"); + a(i, 1, "Stops iteration after condition is met"); + + a(t(o, function () { + return false; + }), false, "Fails"); + +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/to-array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/to-array.js new file mode 100644 index 0000000..1f4beef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/to-array.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var o = { 1: 1, 2: 2, 3: 3 }, o1 = {} + , o2 = t(o, function (value, name, self) { + a(self, o, "Self"); + a(this, o1, "Scope"); + return value + Number(name); + }, o1); + a.deep(o2, [2, 4, 6]); + + t(o).sort().forEach(function (item) { + a.deep(item, [item[0], o[item[0]]], "Default"); + }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/unserialize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/unserialize.js new file mode 100644 index 0000000..405eef1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/unserialize.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = function (t, a) { + var fn = function (raz, dwa) { return raz + dwa; }; + a(t('undefined'), undefined, "Undefined"); + a(t('null'), null, "Null"); + a(t('"raz"'), 'raz', "String"); + a(t('"raz\\"ddwa\\ntrzy"'), 'raz"ddwa\ntrzy', "String with escape"); + a(t('false'), false, "Booelean"); + a(String(t(String(fn))), String(fn), "Function"); + + a.deep(t('/raz-dwa/g'), /raz-dwa/g, "RegExp"); + a.deep(t('new Date(1234567)'), new Date(1234567), "Date"); + a.deep(t('[]'), [], "Empty array"); + a.deep(t('[undefined,false,null,"raz\\"ddwa\\ntrzy",/raz/g,new Date(1234567),["foo"]]'), + [undefined, false, null, 'raz"ddwa\ntrzy', /raz/g, new Date(1234567), ['foo']], "Rich Array"); + a.deep(t('{}'), {}, "Empty object"); + a.deep(t('{"raz":undefined,"dwa":false,"trzy":null,"cztery":"raz\\"ddwa\\ntrzy",' + + '"szesc":/raz/g,"siedem":new Date(1234567),"osiem":["foo",32],' + + '"dziewiec":{"foo":"bar","dwa":343}}'), + { raz: undefined, dwa: false, trzy: null, cztery: 'raz"ddwa\ntrzy', szesc: /raz/g, + siedem: new Date(1234567), osiem: ['foo', 32], dziewiec: { foo: 'bar', dwa: 343 } }, + "Rich object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-callable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-callable.js new file mode 100644 index 0000000..b40540b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-callable.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + var f = function () {}; + a(t(f), f, "Function"); + a.throws(function () { + t({}); + }, "Not Function"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-object.js new file mode 100644 index 0000000..eaa8e7b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-object.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(0); }, TypeError, "0"); + a.throws(function () { t(false); }, TypeError, "false"); + a.throws(function () { t(''); }, TypeError, "''"); + a(t(x = {}), x, "Object"); + a(t(x = function () {}), x, "Function"); + a(t(x = new String('raz')), x, "String object"); //jslint: ignore + a(t(x = new Date()), x, "Date"); + + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "null"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-value.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-value.js new file mode 100644 index 0000000..f1eeafa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/valid-value.js @@ -0,0 +1,19 @@ +'use strict'; + +var numIsNaN = require('../../number/is-nan'); + +module.exports = function (t, a) { + var x; + a(t(0), 0, "0"); + a(t(false), false, "false"); + a(t(''), '', "''"); + a(numIsNaN(t(NaN)), true, "NaN"); + a(t(x = {}), x, "{}"); + + a.throws(function () { + t(); + }, "Undefined"); + a.throws(function () { + t(null); + }, "null"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like-object.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like-object.js new file mode 100644 index 0000000..2f3e31b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like-object.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(0); }, TypeError, "0"); + a.throws(function () { t(false); }, TypeError, "false"); + a.throws(function () { t(''); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Plain Object"); + a.throws(function () { t(function () {}); }, TypeError, "Function"); + a(t(x = new String('raz')), x, "String object"); //jslint: ignore + + a(t(x = { length: 1 }), x, "Array like"); + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "null"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like.js new file mode 100644 index 0000000..53bd112 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-array-like.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(0); }, TypeError, "0"); + a.throws(function () { t(false); }, TypeError, "false"); + a(t(''), '', "''"); + a.throws(function () { t({}); }, TypeError, "Plain Object"); + a.throws(function () { t(function () {}); }, TypeError, "Function"); + a(t(x = new String('raz')), x, "String object"); //jslint: ignore + + a(t(x = { length: 1 }), x, "Array like"); + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "null"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable-value.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable-value.js new file mode 100644 index 0000000..ae9bd17 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable-value.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a(t(0), "0"); + a(t(false), "false"); + a(t(''), ""); + a(t({}), String({}), "Object"); + a(t(x = function () {}), String(x), "Function"); + a(t(x = new String('raz')), String(x), "String object"); //jslint: ignore + a(t(x = new Date()), String(x), "Date"); + + a.throws(function () { t(Object.create(null)); }, TypeError, "Null prototype object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable.js new file mode 100644 index 0000000..4a46bb5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/object/validate-stringifiable.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = function (t, a) { + var x; + a(t(), 'undefined', "Undefined"); + a(t(null), 'null', "Null"); + a(t(0), "0"); + a(t(false), "false"); + a(t(''), ""); + a(t({}), String({}), "Object"); + a(t(x = function () {}), String(x), "Function"); + a(t(x = new String('raz')), String(x), "String object"); //jslint: ignore + a(t(x = new Date()), String(x), "Date"); + + a.throws(function () { t(Object.create(null)); }, TypeError, "Null prototype object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/index.js new file mode 100644 index 0000000..ca2bd65 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var indexTest = require('tad/lib/utils/index-test') + + , path = require('path').resolve(__dirname, '../../../reg-exp/#'); + +module.exports = function (t, a, d) { + indexTest(indexTest.readDir(path).aside(function (data) { + delete data.sticky; + delete data.unicode; + }))(t, a, d); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-sticky.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-sticky.js new file mode 100644 index 0000000..e154ac2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-sticky.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var re; + a(t.call(/raz/), false, "Normal"); + a(t.call(/raz/g), false, "Global"); + try { re = new RegExp('raz', 'y'); } catch (ignore) {} + if (!re) return; + a(t.call(re), true, "Sticky"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-unicode.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-unicode.js new file mode 100644 index 0000000..2ffb9e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/is-unicode.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function (t, a) { + var re; + a(t.call(/raz/), false, "Normal"); + a(t.call(/raz/g), false, "Global"); + try { re = new RegExp('raz', 'u'); } catch (ignore) {} + if (!re) return; + a(t.call(re), true, "Unicode"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/implement.js new file mode 100644 index 0000000..89825a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/match/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/shim.js new file mode 100644 index 0000000..5249139 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/match/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + var result = ['foo']; + result.index = 0; + result.input = 'foobar'; + a.deep(t.call(/foo/, 'foobar'), result); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/implement.js new file mode 100644 index 0000000..c32b23a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/replace/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/shim.js new file mode 100644 index 0000000..2b378fd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/replace/shim.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(/foo/, 'foobar', 'mar'), 'marbar'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/implement.js new file mode 100644 index 0000000..ff1b808 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/search/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/shim.js new file mode 100644 index 0000000..596bcdb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/search/shim.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(/foo/, 'barfoo'), 3); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/implement.js new file mode 100644 index 0000000..1cee441 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/split/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/shim.js new file mode 100644 index 0000000..6a95cd0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/split/shim.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t.call(/\|/, 'bar|foo'), ['bar', 'foo']); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js new file mode 100644 index 0000000..d94e7b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/sticky/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js new file mode 100644 index 0000000..9b1aa0f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../reg-exp/#/unicode/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/escape.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/escape.js new file mode 100644 index 0000000..5b00f67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/escape.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + var str = "(?:^te|er)s{2}t\\[raz]+$"; + a(RegExp('^' + t(str) + '$').test(str), true); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/is-reg-exp.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/is-reg-exp.js new file mode 100644 index 0000000..785ca28 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/is-reg-exp.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = function (t, a) { + a(t('arar'), false, "String"); + a(t(12), false, "Number"); + a(t(true), false, "Boolean"); + a(t(new Date()), false, "Date"); + a(t(new String('raz')), false, "String object"); + a(t({}), false, "Plain object"); + a(t(/a/), true, "Regular expression"); + a(t(new RegExp('a')), true, "Regular expression via constructor"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js new file mode 100644 index 0000000..cd12cf1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function (t, a) { + var r = /raz/; + a(t(r), r, "Direct"); + r = new RegExp('foo'); + a(t(r), r, "Constructor"); + a.throws(function () { + t({}); + }, "Object"); + a.throws(function () { + t(function () {}); + }, "Function"); + a.throws(function () { + t({ exec: function () { return 20; } }); + }, "Plain object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/implement.js new file mode 100644 index 0000000..09bf336 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/@@iterator/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/shim.js new file mode 100644 index 0000000..3b0e0b7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/@@iterator/shim.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + var it = t.call('r💩z'); + a.deep(it.next(), { done: false, value: 'r' }, "#1"); + a.deep(it.next(), { done: false, value: '💩' }, "#2"); + a.deep(it.next(), { done: false, value: 'z' }, "#3"); + a.deep(it.next(), { done: true, value: undefined }, "End"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/at.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/at.js new file mode 100644 index 0000000..2447a9f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/at.js @@ -0,0 +1,97 @@ +// See tests at https://github.com/mathiasbynens/String.prototype.at + +'use strict'; + +module.exports = function (t, a) { + a(t.length, 1, "Length"); + + a.h1("BMP"); + a(t.call('abc\uD834\uDF06def', -Infinity), '', "-Infinity"); + a(t.call('abc\uD834\uDF06def', -1), '', "-1"); + a(t.call('abc\uD834\uDF06def', -0), 'a', "-0"); + a(t.call('abc\uD834\uDF06def', +0), 'a', "+0"); + a(t.call('abc\uD834\uDF06def', 1), 'b', "1"); + a(t.call('abc\uD834\uDF06def', 3), '\uD834\uDF06', "3"); + a(t.call('abc\uD834\uDF06def', 4), '\uDF06', "4"); + a(t.call('abc\uD834\uDF06def', 5), 'd', "5"); + a(t.call('abc\uD834\uDF06def', 42), '', "42"); + a(t.call('abc\uD834\uDF06def', +Infinity), '', "+Infinity"); + a(t.call('abc\uD834\uDF06def', null), 'a', "null"); + a(t.call('abc\uD834\uDF06def', undefined), 'a', "undefined"); + a(t.call('abc\uD834\uDF06def'), 'a', "No argument"); + a(t.call('abc\uD834\uDF06def', false), 'a', "false"); + a(t.call('abc\uD834\uDF06def', NaN), 'a', "NaN"); + a(t.call('abc\uD834\uDF06def', ''), 'a', "Empty string"); + a(t.call('abc\uD834\uDF06def', '_'), 'a', "_"); + a(t.call('abc\uD834\uDF06def', '1'), 'b', "'1'"); + a(t.call('abc\uD834\uDF06def', []), 'a', "[]"); + a(t.call('abc\uD834\uDF06def', {}), 'a', "{}"); + a(t.call('abc\uD834\uDF06def', -0.9), 'a', "-0.9"); + a(t.call('abc\uD834\uDF06def', 1.9), 'b', "1.9"); + a(t.call('abc\uD834\uDF06def', 7.9), 'f', "7.9"); + a(t.call('abc\uD834\uDF06def', Math.pow(2, 32)), '', "Big number"); + + a.h1("Astral symbol"); + a(t.call('\uD834\uDF06def', -Infinity), '', "-Infinity"); + a(t.call('\uD834\uDF06def', -1), '', "-1"); + a(t.call('\uD834\uDF06def', -0), '\uD834\uDF06', "-0"); + a(t.call('\uD834\uDF06def', +0), '\uD834\uDF06', "+0"); + a(t.call('\uD834\uDF06def', 1), '\uDF06', "1"); + a(t.call('\uD834\uDF06def', 2), 'd', "2"); + a(t.call('\uD834\uDF06def', 3), 'e', "3"); + a(t.call('\uD834\uDF06def', 4), 'f', "4"); + a(t.call('\uD834\uDF06def', 42), '', "42"); + a(t.call('\uD834\uDF06def', +Infinity), '', "+Infinity"); + a(t.call('\uD834\uDF06def', null), '\uD834\uDF06', "null"); + a(t.call('\uD834\uDF06def', undefined), '\uD834\uDF06', "undefined"); + a(t.call('\uD834\uDF06def'), '\uD834\uDF06', "No arguments"); + a(t.call('\uD834\uDF06def', false), '\uD834\uDF06', "false"); + a(t.call('\uD834\uDF06def', NaN), '\uD834\uDF06', "NaN"); + a(t.call('\uD834\uDF06def', ''), '\uD834\uDF06', "Empty string"); + a(t.call('\uD834\uDF06def', '_'), '\uD834\uDF06', "_"); + a(t.call('\uD834\uDF06def', '1'), '\uDF06', "'1'"); + + a.h1("Lone high surrogates"); + a(t.call('\uD834abc', -Infinity), '', "-Infinity"); + a(t.call('\uD834abc', -1), '', "-1"); + a(t.call('\uD834abc', -0), '\uD834', "-0"); + a(t.call('\uD834abc', +0), '\uD834', "+0"); + a(t.call('\uD834abc', 1), 'a', "1"); + a(t.call('\uD834abc', 42), '', "42"); + a(t.call('\uD834abc', +Infinity), '', "Infinity"); + a(t.call('\uD834abc', null), '\uD834', "null"); + a(t.call('\uD834abc', undefined), '\uD834', "undefined"); + a(t.call('\uD834abc'), '\uD834', "No arguments"); + a(t.call('\uD834abc', false), '\uD834', "false"); + a(t.call('\uD834abc', NaN), '\uD834', "NaN"); + a(t.call('\uD834abc', ''), '\uD834', "Empty string"); + a(t.call('\uD834abc', '_'), '\uD834', "_"); + a(t.call('\uD834abc', '1'), 'a', "'a'"); + + a.h1("Lone low surrogates"); + a(t.call('\uDF06abc', -Infinity), '', "-Infinity"); + a(t.call('\uDF06abc', -1), '', "-1"); + a(t.call('\uDF06abc', -0), '\uDF06', "-0"); + a(t.call('\uDF06abc', +0), '\uDF06', "+0"); + a(t.call('\uDF06abc', 1), 'a', "1"); + a(t.call('\uDF06abc', 42), '', "42"); + a(t.call('\uDF06abc', +Infinity), '', "+Infinity"); + a(t.call('\uDF06abc', null), '\uDF06', "null"); + a(t.call('\uDF06abc', undefined), '\uDF06', "undefined"); + a(t.call('\uDF06abc'), '\uDF06', "No arguments"); + a(t.call('\uDF06abc', false), '\uDF06', "false"); + a(t.call('\uDF06abc', NaN), '\uDF06', "NaN"); + a(t.call('\uDF06abc', ''), '\uDF06', "Empty string"); + a(t.call('\uDF06abc', '_'), '\uDF06', "_"); + a(t.call('\uDF06abc', '1'), 'a', "'1'"); + + a.h1("Context"); + a.throws(function () { t.call(undefined); }, TypeError, "Undefined"); + a.throws(function () { t.call(undefined, 4); }, TypeError, + "Undefined + argument"); + a.throws(function () { t.call(null); }, TypeError, "Null"); + a.throws(function () { t.call(null, 4); }, TypeError, "Null + argument"); + a(t.call(42, 0), '4', "Number #1"); + a(t.call(42, 1), '2', "Number #2"); + a(t.call({ toString: function () { return 'abc'; } }, 2), 'c', "Object"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/camel-to-hyphen.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/camel-to-hyphen.js new file mode 100644 index 0000000..8b47a81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/camel-to-hyphen.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('razDwaTRzy4yFoo45My'), 'raz-dwa-t-rzy4y-foo45-my'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/capitalize.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/capitalize.js new file mode 100644 index 0000000..fa11ff8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/capitalize.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('raz'), 'Raz', "Word"); + a(t.call('BLA'), 'BLA', "Uppercase"); + a(t.call(''), '', "Empty"); + a(t.call('a'), 'A', "One letter"); + a(t.call('this is a test'), 'This is a test', "Sentence"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/case-insensitive-compare.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/case-insensitive-compare.js new file mode 100644 index 0000000..01a90c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/case-insensitive-compare.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call("AA", "aa"), 0, "Same"); + a.ok(t.call("Amber", "zebra") < 0, "Less"); + a.ok(t.call("Zebra", "amber") > 0, "Greater"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/implement.js new file mode 100644 index 0000000..5e33cd7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/implement.js @@ -0,0 +1,6 @@ +'use strict'; + +var isImplemented = + require('../../../../string/#/code-point-at/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/shim.js new file mode 100644 index 0000000..0df4751 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/code-point-at/shim.js @@ -0,0 +1,81 @@ +// Taken from: https://github.com/mathiasbynens/String.prototype.codePointAt +// /blob/master/tests/tests.js + +'use strict'; + +module.exports = function (t, a) { + a(t.length, 1, "Length"); + + // String that starts with a BMP symbol + a(t.call('abc\uD834\uDF06def', ''), 0x61); + a(t.call('abc\uD834\uDF06def', '_'), 0x61); + a(t.call('abc\uD834\uDF06def'), 0x61); + a(t.call('abc\uD834\uDF06def', -Infinity), undefined); + a(t.call('abc\uD834\uDF06def', -1), undefined); + a(t.call('abc\uD834\uDF06def', -0), 0x61); + a(t.call('abc\uD834\uDF06def', 0), 0x61); + a(t.call('abc\uD834\uDF06def', 3), 0x1D306); + a(t.call('abc\uD834\uDF06def', 4), 0xDF06); + a(t.call('abc\uD834\uDF06def', 5), 0x64); + a(t.call('abc\uD834\uDF06def', 42), undefined); + a(t.call('abc\uD834\uDF06def', Infinity), undefined); + a(t.call('abc\uD834\uDF06def', Infinity), undefined); + a(t.call('abc\uD834\uDF06def', NaN), 0x61); + a(t.call('abc\uD834\uDF06def', false), 0x61); + a(t.call('abc\uD834\uDF06def', null), 0x61); + a(t.call('abc\uD834\uDF06def', undefined), 0x61); + + // String that starts with an astral symbol + a(t.call('\uD834\uDF06def', ''), 0x1D306); + a(t.call('\uD834\uDF06def', '1'), 0xDF06); + a(t.call('\uD834\uDF06def', '_'), 0x1D306); + a(t.call('\uD834\uDF06def'), 0x1D306); + a(t.call('\uD834\uDF06def', -1), undefined); + a(t.call('\uD834\uDF06def', -0), 0x1D306); + a(t.call('\uD834\uDF06def', 0), 0x1D306); + a(t.call('\uD834\uDF06def', 1), 0xDF06); + a(t.call('\uD834\uDF06def', 42), undefined); + a(t.call('\uD834\uDF06def', false), 0x1D306); + a(t.call('\uD834\uDF06def', null), 0x1D306); + a(t.call('\uD834\uDF06def', undefined), 0x1D306); + + // Lone high surrogates + a(t.call('\uD834abc', ''), 0xD834); + a(t.call('\uD834abc', '_'), 0xD834); + a(t.call('\uD834abc'), 0xD834); + a(t.call('\uD834abc', -1), undefined); + a(t.call('\uD834abc', -0), 0xD834); + a(t.call('\uD834abc', 0), 0xD834); + a(t.call('\uD834abc', false), 0xD834); + a(t.call('\uD834abc', NaN), 0xD834); + a(t.call('\uD834abc', null), 0xD834); + a(t.call('\uD834abc', undefined), 0xD834); + + // Lone low surrogates + a(t.call('\uDF06abc', ''), 0xDF06); + a(t.call('\uDF06abc', '_'), 0xDF06); + a(t.call('\uDF06abc'), 0xDF06); + a(t.call('\uDF06abc', -1), undefined); + a(t.call('\uDF06abc', -0), 0xDF06); + a(t.call('\uDF06abc', 0), 0xDF06); + a(t.call('\uDF06abc', false), 0xDF06); + a(t.call('\uDF06abc', NaN), 0xDF06); + a(t.call('\uDF06abc', null), 0xDF06); + a(t.call('\uDF06abc', undefined), 0xDF06); + + a.throws(function () { t.call(undefined); }, TypeError); + a.throws(function () { t.call(undefined, 4); }, TypeError); + a.throws(function () { t.call(null); }, TypeError); + a.throws(function () { t.call(null, 4); }, TypeError); + a(t.call(42, 0), 0x34); + a(t.call(42, 1), 0x32); + a(t.call({ toString: function () { return 'abc'; } }, 2), 0x63); + + a.throws(function () { t.apply(undefined); }, TypeError); + a.throws(function () { t.apply(undefined, [4]); }, TypeError); + a.throws(function () { t.apply(null); }, TypeError); + a.throws(function () { t.apply(null, [4]); }, TypeError); + a(t.apply(42, [0]), 0x34); + a(t.apply(42, [1]), 0x32); + a(t.apply({ toString: function () { return 'abc'; } }, [2]), 0x63); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/implement.js new file mode 100644 index 0000000..220f50d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/contains/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/shim.js new file mode 100644 index 0000000..a0ea4db --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/contains/shim.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('raz', ''), true, "Empty"); + a(t.call('', ''), true, "Both Empty"); + a(t.call('raz', 'raz'), true, "Same"); + a(t.call('razdwa', 'raz'), true, "Starts with"); + a(t.call('razdwa', 'dwa'), true, "Ends with"); + a(t.call('razdwa', 'zdw'), true, "In middle"); + a(t.call('', 'raz'), false, "Something in empty"); + a(t.call('az', 'raz'), false, "Longer"); + a(t.call('azasdfasdf', 'azff'), false, "Not found"); + a(t.call('razdwa', 'raz', 1), false, "Position"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/implement.js new file mode 100644 index 0000000..93bd2dd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/ends-with/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/shim.js new file mode 100644 index 0000000..e4b93c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/ends-with/shim.js @@ -0,0 +1,16 @@ +// In some parts copied from: +// http://closure-library.googlecode.com/svn/trunk/closure/goog/ +// string/string_test.html + +'use strict'; + +module.exports = function (t, a) { + a(t.call('abc', ''), true, "Empty needle"); + a(t.call('abcd', 'cd'), true, "Ends with needle"); + a(t.call('abcd', 'abcd'), true, "Needle equals haystack"); + a(t.call('abcd', 'ab'), false, "Doesn't end with needle"); + a(t.call('abc', 'defg'), false, "Length trick"); + a(t.call('razdwa', 'zd', 3), false, "Position: false"); + a(t.call('razdwa', 'zd', 4), true, "Position: true"); + a(t.call('razdwa', 'zd', 5), false, "Position: false #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/hyphen-to-camel.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/hyphen-to-camel.js new file mode 100644 index 0000000..bd7ded4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/hyphen-to-camel.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('raz-dwa-t-rzy-4y-rtr4-tiu-45-pa'), 'razDwaTRzy4yRtr4Tiu45Pa'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/indent.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/indent.js new file mode 100644 index 0000000..eb92b36 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/indent.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('ra\nzz', ''), 'ra\nzz', "Empty"); + a(t.call('ra\nzz', '\t', 3), '\t\t\tra\n\t\t\tzz', "String repeat"); + a(t.call('ra\nzz\nsss\nfff\n', '\t'), '\tra\n\tzz\n\tsss\n\tfff\n', + "Multi-line"); + a(t.call('ra\n\nzz\n', '\t'), '\tra\n\n\tzz\n', "Don't touch empty lines"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/last.js new file mode 100644 index 0000000..ad36a21 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/last.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call(''), null, "Null"); + a(t.call('abcdef'), 'f', "String"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/_data.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/_data.js new file mode 100644 index 0000000..c741add --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/_data.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t[0], 'object'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/implement.js new file mode 100644 index 0000000..4886c9b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/normalize/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/shim.js new file mode 100644 index 0000000..28e27f5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/normalize/shim.js @@ -0,0 +1,13 @@ +// Taken from: https://github.com/walling/unorm/blob/master/test/es6-shim.js + +'use strict'; + +var str = 'äiti'; + +module.exports = function (t, a) { + a(t.call(str), "\u00e4iti"); + a(t.call(str, "NFC"), "\u00e4iti"); + a(t.call(str, "NFD"), "a\u0308iti"); + a(t.call(str, "NFKC"), "\u00e4iti"); + a(t.call(str, "NFKD"), "a\u0308iti"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/pad.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/pad.js new file mode 100644 index 0000000..28c3fca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/pad.js @@ -0,0 +1,24 @@ +'use strict'; + +var partial = require('../../../function/#/partial'); + +module.exports = { + Left: function (t, a) { + t = partial.call(t, 'x', 5); + + a(t.call('yy'), 'xxxyy'); + a(t.call(''), 'xxxxx', "Empty string"); + + a(t.call('yyyyy'), 'yyyyy', 'Equal length'); + a(t.call('yyyyyyy'), 'yyyyyyy', 'Longer'); + }, + Right: function (t, a) { + t = partial.call(t, 'x', -5); + + a(t.call('yy'), 'yyxxx'); + a(t.call(''), 'xxxxx', "Empty string"); + + a(t.call('yyyyy'), 'yyyyy', 'Equal length'); + a(t.call('yyyyyyy'), 'yyyyyyy', 'Longer'); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace-all.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace-all.js new file mode 100644 index 0000000..a425c87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace-all.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('razdwatrzy', 'dwa', 'olera'), 'razoleratrzy', "Basic"); + a(t.call('razdwatrzy', 'dwa', 'ole$&a'), 'razole$&atrzy', "Inserts"); + a(t.call('razdwa', 'ola', 'sdfs'), 'razdwa', "No replace"); + + a(t.call('$raz$$dwa$trzy$', '$', '&&'), '&&raz&&&&dwa&&trzy&&', "Multi"); + a(t.call('$raz$$dwa$$$$trzy$', '$$', '&'), '$raz&dwa&&trzy$', + "Multi many chars"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace.js new file mode 100644 index 0000000..54522ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/plain-replace.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('razdwatrzy', 'dwa', 'olera'), 'razoleratrzy', "Basic"); + a(t.call('razdwatrzy', 'dwa', 'ole$&a'), 'razole$&atrzy', "Inserts"); + a(t.call('razdwa', 'ola', 'sdfs'), 'razdwa', "No replace"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/implement.js new file mode 100644 index 0000000..7ff65a8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/repeat/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/shim.js new file mode 100644 index 0000000..7e0d077 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/repeat/shim.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function (t, a) { + a(t.call('a', 0), '', "Empty"); + a(t.call('a', 1), 'a', "1"); + a(t.call('\t', 5), '\t\t\t\t\t', "Whitespace"); + a(t.call('raz', 3), 'razrazraz', "Many chars"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/implement.js new file mode 100644 index 0000000..fc8490f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../../string/#/starts-with/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/shim.js new file mode 100644 index 0000000..e0e123b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/#/starts-with/shim.js @@ -0,0 +1,14 @@ +// Inspired and in some parts copied from: +// http://closure-library.googlecode.com/svn/trunk/closure/goog +// /string/string_test.html + +'use strict'; + +module.exports = function (t, a) { + a(t.call('abc', ''), true, "Empty needle"); + a(t.call('abcd', 'ab'), true, "Starts with needle"); + a(t.call('abcd', 'abcd'), true, "Needle equals haystack"); + a(t.call('abcd', 'bcde', 1), false, "Needle larger than haystack"); + a(!t.call('abcd', 'cd'), true, "Doesn't start with needle"); + a(t.call('abcd', 'bc', 1), true, "Position"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/format-method.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/format-method.js new file mode 100644 index 0000000..bb5561e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/format-method.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function (t, a) { + t = t({ a: 'A', aa: 'B', ab: 'C', b: 'D', + c: function () { return ++this.a; } }); + a(t.call({ a: 0 }, ' %a%aab%abb%b\\%aa%ab%c%c '), ' ABbCbD%aaC12 '); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/implement.js new file mode 100644 index 0000000..0aceb97 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../string/from-code-point/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/shim.js new file mode 100644 index 0000000..88cda3d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/from-code-point/shim.js @@ -0,0 +1,47 @@ +// Taken from: https://github.com/mathiasbynens/String.fromCodePoint/blob/master +// /tests/tests.js + +'use strict'; + +var pow = Math.pow; + +module.exports = function (t, a) { + var counter, result; + + a(t.length, 1, "Length"); + a(String.propertyIsEnumerable('fromCodePoint'), false, "Not enumerable"); + + a(t(''), '\0', "Empty string"); + a(t(), '', "No arguments"); + a(t(-0), '\0', "-0"); + a(t(0), '\0', "0"); + a(t(0x1D306), '\uD834\uDF06', "Unicode"); + a(t(0x1D306, 0x61, 0x1D307), '\uD834\uDF06a\uD834\uDF07', "Complex unicode"); + a(t(0x61, 0x62, 0x1D307), 'ab\uD834\uDF07', "Complex"); + a(t(false), '\0', "false"); + a(t(null), '\0', "null"); + + a.throws(function () { t('_'); }, RangeError, "_"); + a.throws(function () { t(Infinity); }, RangeError, "Infinity"); + a.throws(function () { t(-Infinity); }, RangeError, "-Infinity"); + a.throws(function () { t(-1); }, RangeError, "-1"); + a.throws(function () { t(0x10FFFF + 1); }, RangeError, "Range error #1"); + a.throws(function () { t(3.14); }, RangeError, "Range error #2"); + a.throws(function () { t(3e-2); }, RangeError, "Range error #3"); + a.throws(function () { t(-Infinity); }, RangeError, "Range error #4"); + a.throws(function () { t(+Infinity); }, RangeError, "Range error #5"); + a.throws(function () { t(NaN); }, RangeError, "Range error #6"); + a.throws(function () { t(undefined); }, RangeError, "Range error #7"); + a.throws(function () { t({}); }, RangeError, "Range error #8"); + a.throws(function () { t(/re/); }, RangeError, "Range error #9"); + + counter = pow(2, 15) * 3 / 2; + result = []; + while (--counter >= 0) result.push(0); // one code unit per symbol + t.apply(null, result); // must not throw + + counter = pow(2, 15) * 3 / 2; + result = []; + while (--counter >= 0) result.push(0xFFFF + 1); // two code units per symbol + t.apply(null, result); // must not throw +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/is-string.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/is-string.js new file mode 100644 index 0000000..32f5958 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/is-string.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function (t, a) { + a(t(null), false, "Null"); + a(t(''), true, "Empty string"); + a(t(12), false, "Number"); + a(t(false), false, "Boolean"); + a(t(new Date()), false, "Date"); + a(t(new String('raz')), true, "String object"); + a(t('asdfaf'), true, "String"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/random-uniq.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/random-uniq.js new file mode 100644 index 0000000..6791ac2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/random-uniq.js @@ -0,0 +1,14 @@ +'use strict'; + +var isValidFormat = RegExp.prototype.test.bind(/^[a-z0-9]+$/); + +module.exports = function (t, a) { + a(typeof t(), 'string'); + a.ok(t().length > 7); + a.not(t(), t()); + a.ok(isValidFormat(t())); + a.ok(isValidFormat(t())); + a.ok(isValidFormat(t())); + a.ok(isValidFormat(t())); + a.ok(isValidFormat(t())); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/implement.js new file mode 100644 index 0000000..59416de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/implement.js @@ -0,0 +1,5 @@ +'use strict'; + +var isImplemented = require('../../../string/raw/is-implemented'); + +module.exports = function (a) { a(isImplemented(), true); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/index.js new file mode 100644 index 0000000..2e0bfa3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./shim'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/is-implemented.js new file mode 100644 index 0000000..1a88328 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/is-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/shim.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/shim.js new file mode 100644 index 0000000..025ed78 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es5-ext/test/string/raw/shim.js @@ -0,0 +1,15 @@ +// Partially taken from: +// https://github.com/paulmillr/es6-shim/blob/master/test/string.js + +'use strict'; + +module.exports = function (t, a) { + var callSite = []; + + callSite.raw = ["The total is ", " ($", " with tax)"]; + a(t(callSite, '{total}', '{total * 1.01}'), + 'The total is {total} (${total * 1.01} with tax)'); + + callSite.raw = []; + a(t(callSite, '{total}', '{total * 1.01}'), ''); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/#/chain.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/#/chain.js new file mode 100644 index 0000000..6dc1543 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/#/chain.js @@ -0,0 +1,40 @@ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , Iterator = require('../') + , validIterable = require('../valid-iterable') + + , push = Array.prototype.push + , defineProperties = Object.defineProperties + , IteratorChain; + +IteratorChain = function (iterators) { + defineProperties(this, { + __iterators__: d('', iterators), + __current__: d('w', iterators.shift()) + }); +}; +if (setPrototypeOf) setPrototypeOf(IteratorChain, Iterator); + +IteratorChain.prototype = Object.create(Iterator.prototype, { + constructor: d(IteratorChain), + next: d(function () { + var result; + if (!this.__current__) return { done: true, value: undefined }; + result = this.__current__.next(); + while (result.done) { + this.__current__ = this.__iterators__.shift(); + if (!this.__current__) return { done: true, value: undefined }; + result = this.__current__.next(); + } + return result; + }) +}); + +module.exports = function () { + var iterators = [this]; + push.apply(iterators, arguments); + iterators.forEach(validIterable); + return new IteratorChain(iterators); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.lint new file mode 100644 index 0000000..cf54d81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.lint @@ -0,0 +1,11 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.travis.yml new file mode 100644 index 0000000..02c277c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-iterator@medikoo.com + +script: "npm test && npm run lint" diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/CHANGES new file mode 100644 index 0000000..a2d1ec7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/CHANGES @@ -0,0 +1,28 @@ +v0.1.3 -- 2015.02.02 +* Update dependencies +* Fix spelling of LICENSE + +v0.1.2 -- 2014.11.19 +* Optimise internal `_next` to not verify internal's list length at all times + (#2 thanks @RReverser) +* Fix documentation examples +* Configure lint scripts + +v0.1.1 -- 2014.04.29 +* Fix es6-symbol dependency version + +v0.1.0 -- 2014.04.29 +* Assure strictly npm hosted dependencies +* Remove sparse arrays dedicated handling (as per spec) +* Add: isIterable, validIterable and chain (method) +* Remove toArray, it's addressed by Array.from (polyfil can be found in es5-ext/array/from) +* Add break possiblity to 'forOf' via 'doBreak' function argument +* Provide dedicated iterator for array-likes (ArrayIterator) and for strings (StringIterator) +* Provide @@toStringTag symbol +* When available rely on @@iterator symbol +* Remove 32bit integer maximum list length restriction +* Improve Iterator internals +* Update to use latest version of dependencies + +v0.0.0 -- 2013.10.12 +Initial (dev version) \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/LICENSE new file mode 100644 index 0000000..04724a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/README.md new file mode 100644 index 0000000..288373d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/README.md @@ -0,0 +1,148 @@ +# es6-iterator +## ECMAScript 6 Iterator interface + +### Installation + + $ npm install es6-iterator + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +## API + +### Constructors + +#### Iterator(list) _(es6-iterator)_ + +Abstract Iterator interface. Meant for extensions and not to be used on its own. + +Accepts any _list_ object (technically object with numeric _length_ property). + +_Mind it doesn't iterate strings properly, for that use dedicated [StringIterator](#string-iterator)_ + +```javascript +var Iterator = require('es6-iterator') +var iterator = new Iterator([1, 2, 3]); + +iterator.next(); // { value: 1, done: false } +iterator.next(); // { value: 2, done: false } +iterator.next(); // { value: 3, done: false } +iterator.next(); // { value: undefined, done: true } +``` + + +#### ArrayIterator(arrayLike[, kind]) _(es6-iterator/array)_ + +Dedicated for arrays and array-likes. Supports three iteration kinds: +* __value__ _(default)_ - Iterates values +* __key__ - Iterates indexes +* __key+value__ - Iterates keys and indexes, each iteration value is in _[key, value]_ form. + + +```javascript +var ArrayIterator = require('es6-iterator/array') +var iterator = new ArrayIterator([1, 2, 3], 'key+value'); + +iterator.next(); // { value: [0, 1], done: false } +iterator.next(); // { value: [1, 2], done: false } +iterator.next(); // { value: [2, 3], done: false } +iterator.next(); // { value: undefined, done: true } +``` + +May also be used for _arguments_ objects: + +```javascript +(function () { + var iterator = new ArrayIterator(arguments); + + iterator.next(); // { value: 1, done: false } + iterator.next(); // { value: 2, done: false } + iterator.next(); // { value: 3, done: false } + iterator.next(); // { value: undefined, done: true } +}(1, 2, 3)); +``` + +#### StringIterator(str) _(es6-iterator/string)_ + +Assures proper iteration over unicode symbols. +See: http://mathiasbynens.be/notes/javascript-unicode + +```javascript +var StringIterator = require('es6-iterator/string'); +var iterator = new StringIterator('f🙈o🙉o🙊'); + +iterator.next(); // { value: 'f', done: false } +iterator.next(); // { value: '🙈', done: false } +iterator.next(); // { value: 'o', done: false } +iterator.next(); // { value: '🙉', done: false } +iterator.next(); // { value: 'o', done: false } +iterator.next(); // { value: '🙊', done: false } +iterator.next(); // { value: undefined, done: true } +``` + +### Function utilities + +#### forOf(iterable, callback[, thisArg]) _(es6-iterator/for-of)_ + +Polyfill for ECMAScript 6 [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) statement. + +``` +var forOf = require('es6-iterator/for-of'); +var result = []; + +forOf('🙈🙉🙊', function (monkey) { result.push(monkey); }); +console.log(result); // ['🙈', '🙉', '🙊']; +``` + +Optionally you can break iteration at any point: + +```javascript +var result = []; + +forOf([1,2,3,4]', function (val, doBreak) { + result.push(monkey); + if (val >= 3) doBreak(); +}); +console.log(result); // [1, 2, 3]; +``` + +#### get(obj) _(es6-iterator/get)_ + +Return iterator for any iterable object. + +```javascript +var getIterator = require('es6-iterator/get'); +var iterator = get([1,2,3]); + +iterator.next(); // { value: 1, done: false } +iterator.next(); // { value: 2, done: false } +iterator.next(); // { value: 3, done: false } +iterator.next(); // { value: undefined, done: true } +``` + +#### isIterable(obj) _(es6-iterator/is-iterable)_ + +Whether _obj_ is iterable + +```javascript +var isIterable = require('es6-iterator/is-iterable'); + +isIterable(null); // false +isIterable(true); // false +isIterable('str'); // true +isIterable(['a', 'r', 'r']); // true +isIterable(new ArrayIterator([])); // true +``` + +#### validIterable(obj) _(es6-iterator/valid-iterable)_ + +If _obj_ is an iterable it is returned. Otherwise _TypeError_ is thrown. + +### Method extensions + +#### iterator.chain(iterator1[, …iteratorn]) _(es6-iterator/#/chain)_ + +Chain multiple iterators into one. + +### Tests [](https://travis-ci.org/medikoo/es6-iterator) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/array.js new file mode 100644 index 0000000..885ad0a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/array.js @@ -0,0 +1,30 @@ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , Iterator = require('./') + + , defineProperty = Object.defineProperty + , ArrayIterator; + +ArrayIterator = module.exports = function (arr, kind) { + if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind); + Iterator.call(this, arr); + if (!kind) kind = 'value'; + else if (contains.call(kind, 'key+value')) kind = 'key+value'; + else if (contains.call(kind, 'key')) kind = 'key'; + else kind = 'value'; + defineProperty(this, '__kind__', d('', kind)); +}; +if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator); + +ArrayIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(ArrayIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__list__[i]; + if (this.__kind__ === 'key+value') return [i, this.__list__[i]]; + return i; + }), + toString: d(function () { return '[object Array Iterator]'; }) +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/for-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/for-of.js new file mode 100644 index 0000000..111f552 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/for-of.js @@ -0,0 +1,44 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , isString = require('es5-ext/string/is-string') + , get = require('./get') + + , isArray = Array.isArray, call = Function.prototype.call; + +module.exports = function (iterable, cb/*, thisArg*/) { + var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code; + if (isArray(iterable)) mode = 'array'; + else if (isString(iterable)) mode = 'string'; + else iterable = get(iterable); + + callable(cb); + doBreak = function () { broken = true; }; + if (mode === 'array') { + iterable.some(function (value) { + call.call(cb, thisArg, value, doBreak); + if (broken) return true; + }); + return; + } + if (mode === 'string') { + l = iterable.length; + for (i = 0; i < l; ++i) { + char = iterable[i]; + if ((i + 1) < l) { + code = char.charCodeAt(0); + if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i]; + } + call.call(cb, thisArg, char, doBreak); + if (broken) break; + } + return; + } + result = iterable.next(); + + while (!result.done) { + call.call(cb, thisArg, result.value, doBreak); + if (broken) return; + result = iterable.next(); + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/get.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/get.js new file mode 100644 index 0000000..38230fd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/get.js @@ -0,0 +1,13 @@ +'use strict'; + +var isString = require('es5-ext/string/is-string') + , ArrayIterator = require('./array') + , StringIterator = require('./string') + , iterable = require('./valid-iterable') + , iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (obj) { + if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol](); + if (isString(obj)) return new StringIterator(obj); + return new ArrayIterator(obj); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/index.js new file mode 100644 index 0000000..10fd089 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/index.js @@ -0,0 +1,90 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , assign = require('es5-ext/object/assign') + , callable = require('es5-ext/object/valid-callable') + , value = require('es5-ext/object/valid-value') + , d = require('d') + , autoBind = require('d/auto-bind') + , Symbol = require('es6-symbol') + + , defineProperty = Object.defineProperty + , defineProperties = Object.defineProperties + , Iterator; + +module.exports = Iterator = function (list, context) { + if (!(this instanceof Iterator)) return new Iterator(list, context); + defineProperties(this, { + __list__: d('w', value(list)), + __context__: d('w', context), + __nextIndex__: d('w', 0) + }); + if (!context) return; + callable(context.on); + context.on('_add', this._onAdd); + context.on('_delete', this._onDelete); + context.on('_clear', this._onClear); +}; + +defineProperties(Iterator.prototype, assign({ + constructor: d(Iterator), + _next: d(function () { + var i; + if (!this.__list__) return; + if (this.__redo__) { + i = this.__redo__.shift(); + if (i !== undefined) return i; + } + if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++; + this._unBind(); + }), + next: d(function () { return this._createResult(this._next()); }), + _createResult: d(function (i) { + if (i === undefined) return { done: true, value: undefined }; + return { done: false, value: this._resolve(i) }; + }), + _resolve: d(function (i) { return this.__list__[i]; }), + _unBind: d(function () { + this.__list__ = null; + delete this.__redo__; + if (!this.__context__) return; + this.__context__.off('_add', this._onAdd); + this.__context__.off('_delete', this._onDelete); + this.__context__.off('_clear', this._onClear); + this.__context__ = null; + }), + toString: d(function () { return '[object Iterator]'; }) +}, autoBind({ + _onAdd: d(function (index) { + if (index >= this.__nextIndex__) return; + ++this.__nextIndex__; + if (!this.__redo__) { + defineProperty(this, '__redo__', d('c', [index])); + return; + } + this.__redo__.forEach(function (redo, i) { + if (redo >= index) this.__redo__[i] = ++redo; + }, this); + this.__redo__.push(index); + }), + _onDelete: d(function (index) { + var i; + if (index >= this.__nextIndex__) return; + --this.__nextIndex__; + if (!this.__redo__) return; + i = this.__redo__.indexOf(index); + if (i !== -1) this.__redo__.splice(i, 1); + this.__redo__.forEach(function (redo, i) { + if (redo > index) this.__redo__[i] = --redo; + }, this); + }), + _onClear: d(function () { + if (this.__redo__) clear.call(this.__redo__); + this.__nextIndex__ = 0; + }) +}))); + +defineProperty(Iterator.prototype, Symbol.iterator, d(function () { + return this; +})); +defineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/is-iterable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/is-iterable.js new file mode 100644 index 0000000..bbcf104 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/is-iterable.js @@ -0,0 +1,13 @@ +'use strict'; + +var isString = require('es5-ext/string/is-string') + , iteratorSymbol = require('es6-symbol').iterator + + , isArray = Array.isArray; + +module.exports = function (value) { + if (value == null) return false; + if (isArray(value)) return true; + if (isString(value)) return true; + return (typeof value[iteratorSymbol] === 'function'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.lint new file mode 100644 index 0000000..1851752 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.lint @@ -0,0 +1,13 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus +newcap +vars diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.travis.yml new file mode 100644 index 0000000..afd3509 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-symbol@medikoo.com diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/CHANGES new file mode 100644 index 0000000..df8c27e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/CHANGES @@ -0,0 +1,34 @@ +v2.0.1 -- 2015.01.28 +* Fix Symbol.prototype[Symbol.isPrimitive] implementation +* Improve validation within Symbol.prototype.toString and + Symbol.prototype.valueOf + +v2.0.0 -- 2015.01.28 +* Update up to changes in specification: + * Implement `for` and `keyFor` + * Remove `Symbol.create` and `Symbol.isRegExp` + * Add `Symbol.match`, `Symbol.replace`, `Symbol.search`, `Symbol.species` and + `Symbol.split` +* Rename `validSymbol` to `validateSymbol` +* Improve documentation +* Remove dead test modules + +v1.0.0 -- 2015.01.26 +* Fix enumerability for symbol properties set normally (e.g. obj[symbol] = value) +* Introduce initialization via hidden constructor +* Fix isSymbol handling of polyfill values when native Symbol is present +* Fix spelling of LICENSE +* Configure lint scripts + +v0.1.1 -- 2014.10.07 +* Fix isImplemented, so it returns true in case of polyfill +* Improve documentations + +v0.1.0 -- 2014.04.28 +* Assure strictly npm dependencies +* Update to use latest versions of dependencies +* Fix implementation detection so it doesn't crash on `String(symbol)` +* throw on `new Symbol()` (as decided by TC39) + +v0.0.0 -- 2013.11.15 +* Initial (dev) version \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/LICENSE new file mode 100644 index 0000000..04724a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/README.md new file mode 100644 index 0000000..95d6780 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/README.md @@ -0,0 +1,71 @@ +# es6-symbol +## ECMAScript 6 Symbol polyfill + +For more information about symbols see following links +- [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html) +- [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) +- [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor) + +### Limitations + +Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely. + +### Usage + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't (but without implementing `Symbol` on global scope), do: + +```javascript +var Symbol = require('es6-symbol'); +``` + +If you want to make sure your environment implements `Symbol`, do: + +```javascript +require('es6-symbol/implement'); +``` + +If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do: + +```javascript +var Symbol = require('es6-symbol/polyfill'); +``` + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples: + +```javascript +var Symbol = require('es6-symbol'); + +var symbol = Symbol('My custom symbol'); +var x = {}; + +x[symbol] = 'foo'; +console.log(x[symbol]); 'foo' + +// Detect iterable: +var iterator, result; +if (possiblyIterable[Symbol.iterator]) { + iterator = possiblyIterable[Symbol.iterator](); + result = iterator.next(); + while(!result.done) { + console.log(result.value); + result = iterator.next(); + } +} +``` + +### Installation +#### NPM + +In your project path: + + $ npm install es6-symbol + +##### Browser + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +## Tests [](https://travis-ci.org/medikoo/es6-symbol) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/implement.js new file mode 100644 index 0000000..153edac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Symbol', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/index.js new file mode 100644 index 0000000..609f1fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-implemented.js new file mode 100644 index 0000000..53759f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-implemented.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function () { + var symbol; + if (typeof Symbol !== 'function') return false; + symbol = Symbol('test symbol'); + try { String(symbol); } catch (e) { return false; } + if (typeof Symbol.iterator === 'symbol') return true; + + // Return 'true' for polyfills + if (typeof Symbol.isConcatSpreadable !== 'object') return false; + if (typeof Symbol.iterator !== 'object') return false; + if (typeof Symbol.toPrimitive !== 'object') return false; + if (typeof Symbol.toStringTag !== 'object') return false; + if (typeof Symbol.unscopables !== 'object') return false; + + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-native-implemented.js new file mode 100644 index 0000000..a8cb8b8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-native-implemented.js @@ -0,0 +1,8 @@ +// Exports true if environment provides native `Symbol` implementation + +'use strict'; + +module.exports = (function () { + if (typeof Symbol !== 'function') return false; + return (typeof Symbol.iterator === 'symbol'); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-symbol.js new file mode 100644 index 0000000..beeba2c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/is-symbol.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (x) { + return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/package.json new file mode 100644 index 0000000..0efffea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/package.json @@ -0,0 +1,63 @@ +{ + "name": "es6-symbol", + "version": "2.0.1", + "description": "ECMAScript6 Symbol polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "symbol", + "private", + "property", + "es6", + "ecmascript", + "harmony" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-symbol.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.5" + }, + "devDependencies": { + "tad": "~0.2.1", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "51f6938d7830269fefa38f02eb912f5472b3ccd7", + "bugs": { + "url": "https://github.com/medikoo/es6-symbol/issues" + }, + "homepage": "https://github.com/medikoo/es6-symbol", + "_id": "es6-symbol@2.0.1", + "_shasum": "761b5c67cfd4f1d18afb234f691d678682cb3bf3", + "_from": "es6-symbol@>=2.0.1 <2.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "761b5c67cfd4f1d18afb234f691d678682cb3bf3", + "tarball": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/polyfill.js new file mode 100644 index 0000000..735eb67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/polyfill.js @@ -0,0 +1,77 @@ +'use strict'; + +var d = require('d') + , validateSymbol = require('./validate-symbol') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty, objPrototype = Object.prototype + , Symbol, HiddenSymbol, globalSymbols = create(null); + +var generateName = (function () { + var created = create(null); + return function (desc) { + var postfix = 0, name; + while (created[desc + (postfix || '')]) ++postfix; + desc += (postfix || ''); + created[desc] = true; + name = '@@' + desc; + defineProperty(objPrototype, name, d.gs(null, function (value) { + defineProperty(this, name, d(value)); + })); + return name; + }; +}()); + +HiddenSymbol = function Symbol(description) { + if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); + return Symbol(description); +}; +module.exports = Symbol = function Symbol(description) { + var symbol; + if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); + symbol = create(HiddenSymbol.prototype); + description = (description === undefined ? '' : String(description)); + return defineProperties(symbol, { + __description__: d('', description), + __name__: d('', generateName(description)) + }); +}; +defineProperties(Symbol, { + for: d(function (key) { + if (globalSymbols[key]) return globalSymbols[key]; + return (globalSymbols[key] = Symbol(String(key))); + }), + keyFor: d(function (s) { + var key; + validateSymbol(s); + for (key in globalSymbols) if (globalSymbols[key] === s) return key; + }), + hasInstance: d('', Symbol('hasInstance')), + isConcatSpreadable: d('', Symbol('isConcatSpreadable')), + iterator: d('', Symbol('iterator')), + match: d('', Symbol('match')), + replace: d('', Symbol('replace')), + search: d('', Symbol('search')), + species: d('', Symbol('species')), + split: d('', Symbol('split')), + toPrimitive: d('', Symbol('toPrimitive')), + toStringTag: d('', Symbol('toStringTag')), + unscopables: d('', Symbol('unscopables')) +}); +defineProperties(HiddenSymbol.prototype, { + constructor: d(Symbol), + toString: d('', function () { return this.__name__; }) +}); + +defineProperties(Symbol.prototype, { + toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), + valueOf: d(function () { return validateSymbol(this); }) +}); +defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', + function () { return validateSymbol(this); })); +defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol')); + +defineProperty(HiddenSymbol.prototype, Symbol.toPrimitive, + d('c', Symbol.prototype[Symbol.toPrimitive])); +defineProperty(HiddenSymbol.prototype, Symbol.toStringTag, + d('c', Symbol.prototype[Symbol.toStringTag])); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/implement.js new file mode 100644 index 0000000..eb35c30 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Symbol, 'function'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/index.js new file mode 100644 index 0000000..62b3296 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var d = require('d') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-implemented.js new file mode 100644 index 0000000..bb0d645 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Symbol; + global.Symbol = polyfill; + a(t(), true); + if (cache === undefined) delete global.Symbol; + else global.Symbol = cache; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-native-implemented.js new file mode 100644 index 0000000..df8ba03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-symbol.js new file mode 100644 index 0000000..ac24b9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/is-symbol.js @@ -0,0 +1,16 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Symbol !== 'undefined') { + a(t(Symbol()), true, "Native"); + } + a(t(SymbolPoly()), true, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/polyfill.js new file mode 100644 index 0000000..83fb5e9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/polyfill.js @@ -0,0 +1,27 @@ +'use strict'; + +var d = require('d') + , isSymbol = require('../is-symbol') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); + a(x instanceof T, false); + + a(isSymbol(symbol), true, "Symbol"); + a(isSymbol(T.iterator), true, "iterator"); + a(isSymbol(T.toStringTag), true, "toStringTag"); + + x = {}; + x[symbol] = 'foo'; + a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, + value: 'foo', writable: true }); + symbol = T.for('marko'); + a(isSymbol(symbol), true); + a(T.for('marko'), symbol); + a(T.keyFor(symbol), 'marko'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/validate-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/validate-symbol.js new file mode 100644 index 0000000..2c8f84c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/test/validate-symbol.js @@ -0,0 +1,19 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + var symbol; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Symbol !== 'undefined') { + symbol = Symbol(); + a(t(symbol), symbol, "Native"); + } + symbol = SymbolPoly(); + a(t(symbol), symbol, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/validate-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/validate-symbol.js new file mode 100644 index 0000000..4275004 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/node_modules/es6-symbol/validate-symbol.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSymbol = require('./is-symbol'); + +module.exports = function (value) { + if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/package.json new file mode 100644 index 0000000..593d080 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/package.json @@ -0,0 +1,66 @@ +{ + "name": "es6-iterator", + "version": "0.1.3", + "description": "Iterator abstraction based on ES6 specification", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "iterator", + "array", + "list", + "set", + "map", + "generator" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-iterator.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.5", + "es6-symbol": "~2.0.1" + }, + "devDependencies": { + "event-emitter": "~0.3.3", + "tad": "~0.2.1", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "2addc362c6f139e4941cf4726eeb59e5960c5cef", + "bugs": { + "url": "https://github.com/medikoo/es6-iterator/issues" + }, + "homepage": "https://github.com/medikoo/es6-iterator", + "_id": "es6-iterator@0.1.3", + "_shasum": "d6f58b8c4fc413c249b4baa19768f8e4d7c8944e", + "_from": "es6-iterator@>=0.1.1 <0.2.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.11.16", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "d6f58b8c4fc413c249b4baa19768f8e4d7c8944e", + "tarball": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/string.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/string.js new file mode 100644 index 0000000..cdb39ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/string.js @@ -0,0 +1,37 @@ +// Thanks @mathiasbynens +// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols + +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , Iterator = require('./') + + , defineProperty = Object.defineProperty + , StringIterator; + +StringIterator = module.exports = function (str) { + if (!(this instanceof StringIterator)) return new StringIterator(str); + str = String(str); + Iterator.call(this, str); + defineProperty(this, '__length__', d('', str.length)); + +}; +if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator); + +StringIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(StringIterator), + _next: d(function () { + if (!this.__list__) return; + if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++; + this._unBind(); + }), + _resolve: d(function (i) { + var char = this.__list__[i], code; + if (this.__nextIndex__ === this.__length__) return char; + code = char.charCodeAt(0); + if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++]; + return char; + }), + toString: d(function () { return '[object String Iterator]'; }) +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/#/chain.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/#/chain.js new file mode 100644 index 0000000..a414c66 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/#/chain.js @@ -0,0 +1,23 @@ +'use strict'; + +var Iterator = require('../../'); + +module.exports = function (t, a) { + var i1 = new Iterator(['raz', 'dwa', 'trzy']) + , i2 = new Iterator(['cztery', 'pięć', 'sześć']) + , i3 = new Iterator(['siedem', 'osiem', 'dziewięć']) + + , iterator = t.call(i1, i2, i3); + + a.deep(iterator.next(), { done: false, value: 'raz' }, "#1"); + a.deep(iterator.next(), { done: false, value: 'dwa' }, "#2"); + a.deep(iterator.next(), { done: false, value: 'trzy' }, "#3"); + a.deep(iterator.next(), { done: false, value: 'cztery' }, "#4"); + a.deep(iterator.next(), { done: false, value: 'pięć' }, "#5"); + a.deep(iterator.next(), { done: false, value: 'sześć' }, "#6"); + a.deep(iterator.next(), { done: false, value: 'siedem' }, "#7"); + a.deep(iterator.next(), { done: false, value: 'osiem' }, "#8"); + a.deep(iterator.next(), { done: false, value: 'dziewięć' }, "#9"); + a.deep(iterator.next(), { done: true, value: undefined }, "Done #1"); + a.deep(iterator.next(), { done: true, value: undefined }, "Done #2"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/array.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/array.js new file mode 100644 index 0000000..ae7c219 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/array.js @@ -0,0 +1,67 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (T) { + return { + Values: function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; + + it = new T(x); + a(it[iteratorSymbol](), it, "@@iterator"); + a.deep(it.next(), { done: false, value: 'raz' }, "#1"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); + x.splice(1, 0, 'elo'); + a.deep(it.next(), { done: false, value: 'dwa' }, "Insert"); + a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); + a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); + x.pop(); + a.deep(it.next(), { done: false, value: 'pięć' }, "#5"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Keys & Values": function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; + + it = new T(x, 'key+value'); + a(it[iteratorSymbol](), it, "@@iterator"); + a.deep(it.next(), { done: false, value: [0, 'raz'] }, "#1"); + a.deep(it.next(), { done: false, value: [1, 'dwa'] }, "#2"); + x.splice(1, 0, 'elo'); + a.deep(it.next(), { done: false, value: [2, 'dwa'] }, "Insert"); + a.deep(it.next(), { done: false, value: [3, 'trzy'] }, "#3"); + a.deep(it.next(), { done: false, value: [4, 'cztery'] }, "#4"); + x.pop(); + a.deep(it.next(), { done: false, value: [5, 'pięć'] }, "#5"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + Keys: function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; + + it = new T(x, 'key'); + a(it[iteratorSymbol](), it, "@@iterator"); + a.deep(it.next(), { done: false, value: 0 }, "#1"); + a.deep(it.next(), { done: false, value: 1 }, "#2"); + x.splice(1, 0, 'elo'); + a.deep(it.next(), { done: false, value: 2 }, "Insert"); + a.deep(it.next(), { done: false, value: 3 }, "#3"); + a.deep(it.next(), { done: false, value: 4 }, "#4"); + x.pop(); + a.deep(it.next(), { done: false, value: 5 }, "#5"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + Sparse: function (a) { + var x = new Array(6), it; + + x[2] = 'raz'; + x[4] = 'dwa'; + it = new T(x); + a.deep(it.next(), { done: false, value: undefined }, "#1"); + a.deep(it.next(), { done: false, value: undefined }, "#2"); + a.deep(it.next(), { done: false, value: 'raz' }, "#3"); + a.deep(it.next(), { done: false, value: undefined }, "#4"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#5"); + a.deep(it.next(), { done: false, value: undefined }, "#6"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/for-of.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/for-of.js new file mode 100644 index 0000000..502e7b7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/for-of.js @@ -0,0 +1,35 @@ +'use strict'; + +var ArrayIterator = require('../array') + + , slice = Array.prototype.slice; + +module.exports = function (t, a) { + var i = 0, x = ['raz', 'dwa', 'trzy'], y = {}, called = 0; + t(x, function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Array " + i + "#"); + a(this, y, "Array: context: " + (i++) + "#"); + }, y); + i = 0; + t(x = 'foo', function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); + a(this, y, "Regular String: context: " + (i++) + "#"); + }, y); + i = 0; + x = ['r', '💩', 'z']; + t('r💩z', function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); + a(this, y, "Unicode String: context: " + (i++) + "#"); + }, y); + i = 0; + t(new ArrayIterator(x), function () { + a.deep(slice.call(arguments, 0, 1), [x[i]], "Iterator " + i + "#"); + a(this, y, "Iterator: context: " + (i++) + "#"); + }, y); + + t(x = ['raz', 'dwa', 'trzy'], function (value, doBreak) { + ++called; + return doBreak(); + }); + a(called, 1, "Break"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/get.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/get.js new file mode 100644 index 0000000..7309590 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/get.js @@ -0,0 +1,16 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , Iterator = require('../'); + +module.exports = function (t, a) { + var iterator; + a.throws(function () { t(); }, TypeError, "Null"); + a.throws(function () { t({}); }, TypeError, "Plain object"); + a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); + iterator = {}; + iterator[iteratorSymbol] = function () { return new Iterator([]); }; + a(t(iterator) instanceof Iterator, true, "Iterator"); + a(String(t([])), '[object Array Iterator]', " Array"); + a(String(t('foo')), '[object String Iterator]', "String"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/index.js new file mode 100644 index 0000000..ea3621a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/index.js @@ -0,0 +1,99 @@ +'use strict'; + +var ee = require('event-emitter') + , iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (T) { + return { + "": function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it, y, z; + + it = new T(x); + a(it[iteratorSymbol](), it, "@@iterator"); + y = it.next(); + a.deep(y, { done: false, value: 'raz' }, "#1"); + z = it.next(); + a.not(y, z, "Recreate result"); + a.deep(z, { done: false, value: 'dwa' }, "#2"); + a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); + a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); + a.deep(it.next(), { done: false, value: 'pięć' }, "#5"); + a.deep(y = it.next(), { done: true, value: undefined }, "End"); + a.not(y, it.next(), "Recreate result on dead"); + }, + Emited: function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], y, it; + + y = ee(); + it = new T(x, y); + a.deep(it.next(), { done: false, value: 'raz' }, "#1"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); + y.emit('_add', x.push('sześć') - 1); + a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); + x.splice(1, 0, 'półtora'); + y.emit('_add', 1); + a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); + x.splice(5, 1); + y.emit('_delete', 5); + a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); + a.deep(it.next(), { done: false, value: 'sześć' }, "#5"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited #2": function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; + + y = ee(); + it = new T(x, y); + a.deep(it.next(), { done: false, value: 'raz' }, "#1"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); + x.splice(1, 0, 'półtora'); + y.emit('_add', 1); + x.splice(1, 0, '1.25'); + y.emit('_add', 1); + x.splice(0, 1); + y.emit('_delete', 0); + a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); + a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2"); + a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); + a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); + x.splice(5, 1); + y.emit('_delete', 5); + a.deep(it.next(), { done: false, value: 'sześć' }, "#5"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #1": function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; + + y = ee(); + it = new T(x, y); + a.deep(it.next(), { done: false, value: 'raz' }, "#1"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); + x.length = 0; + y.emit('_clear'); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #2": function (a) { + var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; + + y = ee(); + it = new T(x, y); + a.deep(it.next(), { done: false, value: 'raz' }, "#1"); + a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); + x.length = 0; + y.emit('_clear'); + x.push('foo'); + x.push('bar'); + a.deep(it.next(), { done: false, value: 'foo' }, "#3"); + a.deep(it.next(), { done: false, value: 'bar' }, "#4"); + x.splice(1, 0, 'półtora'); + y.emit('_add', 1); + x.splice(1, 0, '1.25'); + y.emit('_add', 1); + x.splice(0, 1); + y.emit('_delete', 0); + a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); + a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/is-iterable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/is-iterable.js new file mode 100644 index 0000000..7c5c59b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/is-iterable.js @@ -0,0 +1,18 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , Iterator = require('../'); + +module.exports = function (t, a) { + var iterator; + a(t(), false, "Undefined"); + a(t(123), false, "Number"); + a(t({}), false, "Plain object"); + a(t({ length: 0 }), false, "Array-like"); + iterator = {}; + iterator[iteratorSymbol] = function () { return new Iterator([]); }; + a(t(iterator), true, "Iterator"); + a(t([]), true, "Array"); + a(t('foo'), true, "String"); + a(t(''), true, "Empty string"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/string.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/string.js new file mode 100644 index 0000000..d11855f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/string.js @@ -0,0 +1,23 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (T, a) { + var it = new T('foobar'); + + a(it[iteratorSymbol](), it, "@@iterator"); + a.deep(it.next(), { done: false, value: 'f' }, "#1"); + a.deep(it.next(), { done: false, value: 'o' }, "#2"); + a.deep(it.next(), { done: false, value: 'o' }, "#3"); + a.deep(it.next(), { done: false, value: 'b' }, "#4"); + a.deep(it.next(), { done: false, value: 'a' }, "#5"); + a.deep(it.next(), { done: false, value: 'r' }, "#6"); + a.deep(it.next(), { done: true, value: undefined }, "End"); + + a.h1("Outside of BMP"); + it = new T('r💩z'); + a.deep(it.next(), { done: false, value: 'r' }, "#1"); + a.deep(it.next(), { done: false, value: '💩' }, "#2"); + a.deep(it.next(), { done: false, value: 'z' }, "#3"); + a.deep(it.next(), { done: true, value: undefined }, "End"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/valid-iterable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/valid-iterable.js new file mode 100644 index 0000000..7760b01 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/test/valid-iterable.js @@ -0,0 +1,16 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , Iterator = require('../'); + +module.exports = function (t, a) { + var obj; + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t({}); }, TypeError, "Plain object"); + a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); + obj = {}; + obj[iteratorSymbol] = function () { return new Iterator([]); }; + a(t(obj), obj, "Iterator"); + obj = []; + a(t(obj), obj, 'Array'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/valid-iterable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/valid-iterable.js new file mode 100644 index 0000000..d330997 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-iterator/valid-iterable.js @@ -0,0 +1,8 @@ +'use strict'; + +var isIterable = require('./is-iterable'); + +module.exports = function (value) { + if (!isIterable(value)) throw new TypeError(value + " is not iterable"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.lint new file mode 100644 index 0000000..cf54d81 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.lint @@ -0,0 +1,11 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.travis.yml new file mode 100644 index 0000000..4c4accb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-set@medikoo.com + +script: "npm test && npm run lint" diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/CHANGES new file mode 100644 index 0000000..79603bf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/CHANGES @@ -0,0 +1,18 @@ +v0.1.1 -- 2014.10.07 +* Fix isImplemented so it validates native Set properly +* Add getFirst and getLast extensions +* Configure linter scripts + +v0.1.0 -- 2014.04.29 +* Assure strictly npm hosted dependencies +* Introduce faster 'primitive' alternative (doesn't guarantee order of iteration) +* Add isNativeImplemented, and some, every and copy method extensions +* If native Set is provided polyfill extends it +* Optimize forEach iteration +* Remove comparator support (as it was removed from spec) +* Provide @@toStringTag symbol, ad @@iterator symbols on iterators +* Update to use latest dependencies versions +* Improve interals + +v0.0.0 -- 2013.10.12 +Initial (dev) version diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/LICENCE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/LICENCE new file mode 100644 index 0000000..aaf3528 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/LICENCE @@ -0,0 +1,19 @@ +Copyright (C) 2013 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/README.md new file mode 100644 index 0000000..95e9d35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/README.md @@ -0,0 +1,71 @@ +# es6-set +## Set collection as specified in ECMAScript6 + +### Usage + +If you want to make sure your environment implements `Set`, do: + +```javascript +require('es6-set/implement'); +``` + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Set` on global scope, do: + +```javascript +var Set = require('es6-set'); +``` + +If you strictly want to use polyfill even if native `Set` exists, do: + +```javascript +var Set = require('es6-set/polyfill'); +``` + +### Installation + + $ npm install es6-set + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-objects). Still if you want quick look, follow examples: + +```javascript +var Set = require('es6-set'); + +var set = new Set(['raz', 'dwa', {}]); + +set.size; // 3 +set.has('raz'); // true +set.has('foo'); // false +set.add('foo'); // set +set.size // 4 +set.has('foo'); // true +set.has('dwa'); // true +set.delete('dwa'); // true +set.size; // 3 + +set.forEach(function (value) { + // 'raz', {}, 'foo' iterated +}); + +// FF nightly only: +for (value of set) { + // 'raz', {}, 'foo' iterated +} + +var iterator = set.values(); + +iterator.next(); // { done: false, value: 'raz' } +iterator.next(); // { done: false, value: {} } +iterator.next(); // { done: false, value: 'foo' } +iterator.next(); // { done: true, value: undefined } + +set.clear(); // undefined +set.size; // 0 +``` + +## Tests [](https://travis-ci.org/medikoo/es6-set) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/copy.js new file mode 100644 index 0000000..a8fd5c2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/copy.js @@ -0,0 +1,5 @@ +'use strict'; + +var Set = require('../'); + +module.exports = function () { return new Set(this); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/every.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/every.js new file mode 100644 index 0000000..ea64ebc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/every.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , forOf = require('es6-iterator/for-of') + + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var thisArg = arguments[1], result = true; + callable(cb); + forOf(this, function (value, doBreak) { + if (!call.call(cb, thisArg, value)) { + result = false; + doBreak(); + } + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-first.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-first.js new file mode 100644 index 0000000..b5d89fc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-first.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function () { + return this.values().next().value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-last.js new file mode 100644 index 0000000..d22ce73 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/get-last.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function () { + var value, iterator = this.values(), item; + while (true) { + item = iterator.next(); + if (item.done) break; + value = item.value; + } + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/some.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/some.js new file mode 100644 index 0000000..400a5a0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/ext/some.js @@ -0,0 +1,18 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , forOf = require('es6-iterator/for-of') + + , call = Function.prototype.call; + +module.exports = function (cb/*, thisArg*/) { + var thisArg = arguments[1], result = false; + callable(cb); + forOf(this, function (value, doBreak) { + if (call.call(cb, thisArg, value)) { + result = true; + doBreak(); + } + }); + return result; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/implement.js new file mode 100644 index 0000000..f03362e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Set', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/index.js new file mode 100644 index 0000000..daa7886 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Set : require('./polyfill'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-implemented.js new file mode 100644 index 0000000..d8b0cd7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-implemented.js @@ -0,0 +1,22 @@ +'use strict'; + +module.exports = function () { + var set, iterator, result; + if (typeof Set !== 'function') return false; + set = new Set(['raz', 'dwa', 'trzy']); + if (set.size !== 3) return false; + if (typeof set.add !== 'function') return false; + if (typeof set.clear !== 'function') return false; + if (typeof set.delete !== 'function') return false; + if (typeof set.entries !== 'function') return false; + if (typeof set.forEach !== 'function') return false; + if (typeof set.has !== 'function') return false; + if (typeof set.keys !== 'function') return false; + if (typeof set.values !== 'function') return false; + + iterator = set.values(); + result = iterator.next(); + if (result.done !== false) return false; + if (result.value !== 'raz') return false; + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-native-implemented.js new file mode 100644 index 0000000..e8b0160 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-native-implemented.js @@ -0,0 +1,9 @@ +// Exports true if environment provides native `Set` implementation, +// whatever that is. + +'use strict'; + +module.exports = (function () { + if (typeof Set === 'undefined') return false; + return (Object.prototype.toString.call(Set.prototype) === '[object Set]'); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-set.js new file mode 100644 index 0000000..19e4792 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/is-set.js @@ -0,0 +1,12 @@ +'use strict'; + +var toString = Object.prototype.toString + , toStringTagSymbol = require('es6-symbol').toStringTag + + , id = '[object Set]' + , Global = (typeof Set === 'undefined') ? null : Set; + +module.exports = function (x) { + return (x && ((Global && (x instanceof Global)) || + (toString.call(x) === id) || (x[toStringTagSymbol] === 'Set'))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/iterator.js new file mode 100644 index 0000000..4a7dac7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/iterator.js @@ -0,0 +1,31 @@ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , Iterator = require('es6-iterator') + , toStringTagSymbol = require('es6-symbol').toStringTag + + , defineProperty = Object.defineProperty + , SetIterator; + +SetIterator = module.exports = function (set, kind) { + if (!(this instanceof SetIterator)) return new SetIterator(set, kind); + Iterator.call(this, set.__setData__, set); + if (!kind) kind = 'value'; + else if (contains.call(kind, 'key+value')) kind = 'key+value'; + else kind = 'value'; + defineProperty(this, '__kind__', d('', kind)); +}; +if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator); + +SetIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(SetIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__list__[i]; + return [this.__list__[i], this.__list__[i]]; + }), + toString: d(function () { return '[object Set Iterator]'; }) +}); +defineProperty(SetIterator.prototype, toStringTagSymbol, + d('c', 'Set Iterator')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/primitive-iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/primitive-iterator.js new file mode 100644 index 0000000..1f0326a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/lib/primitive-iterator.js @@ -0,0 +1,53 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , assign = require('es5-ext/object/assign') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , autoBind = require('d/auto-bind') + , Iterator = require('es6-iterator') + , toStringTagSymbol = require('es6-symbol').toStringTag + + , defineProperties = Object.defineProperties, keys = Object.keys + , unBind = Iterator.prototype._unBind + , PrimitiveSetIterator; + +PrimitiveSetIterator = module.exports = function (set, kind) { + if (!(this instanceof PrimitiveSetIterator)) { + return new PrimitiveSetIterator(set, kind); + } + Iterator.call(this, keys(set.__setData__), set); + kind = (!kind || !contains.call(kind, 'key+value')) ? 'value' : 'key+value'; + defineProperties(this, { + __kind__: d('', kind), + __data__: d('w', set.__setData__) + }); +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveSetIterator, Iterator); + +PrimitiveSetIterator.prototype = Object.create(Iterator.prototype, assign({ + constructor: d(PrimitiveSetIterator), + _resolve: d(function (i) { + var value = this.__data__[this.__list__[i]]; + return (this.__kind__ === 'value') ? value : [value, value]; + }), + _unBind: d(function () { + this.__data__ = null; + unBind.call(this); + }), + toString: d(function () { return '[object Set Iterator]'; }) +}, autoBind({ + _onAdd: d(function (key) { this.__list__.push(key); }), + _onDelete: d(function (key) { + var index = this.__list__.lastIndexOf(key); + if (index < this.__nextIndex__) return; + this.__list__.splice(index, 1); + }), + _onClear: d(function () { + clear.call(this.__list__); + this.__nextIndex__ = 0; + }) +}))); +Object.defineProperty(PrimitiveSetIterator.prototype, toStringTagSymbol, + d('c', 'Set Iterator')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/package.json new file mode 100644 index 0000000..dd17209 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/package.json @@ -0,0 +1,66 @@ +{ + "name": "es6-set", + "version": "0.1.1", + "description": "ECMAScript6 Set polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "set", + "collection", + "es6", + "harmony", + "list", + "hash" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-set.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.4", + "es6-iterator": "~0.1.1", + "es6-symbol": "~0.1.1", + "event-emitter": "~0.3.1" + }, + "devDependencies": { + "tad": "0.2.x", + "xlint": "~0.2.1", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "769f7391b194b25900a79d132d21f4abefb14201", + "bugs": { + "url": "https://github.com/medikoo/es6-set/issues" + }, + "homepage": "https://github.com/medikoo/es6-set", + "_id": "es6-set@0.1.1", + "_shasum": "497cd235c9a2691f4caa0e33dd73ef86bde738ac", + "_from": "es6-set@>=0.1.1 <0.2.0", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "497cd235c9a2691f4caa0e33dd73ef86bde738ac", + "tarball": "http://registry.npmjs.org/es6-set/-/es6-set-0.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/polyfill.js new file mode 100644 index 0000000..d272429 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/polyfill.js @@ -0,0 +1,79 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , eIndexOf = require('es5-ext/array/#/e-index-of') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , callable = require('es5-ext/object/valid-callable') + , d = require('d') + , ee = require('event-emitter') + , Symbol = require('es6-symbol') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Iterator = require('./lib/iterator') + , isNative = require('./is-native-implemented') + + , call = Function.prototype.call, defineProperty = Object.defineProperty + , SetPoly, getValues; + +module.exports = SetPoly = function (/*iterable*/) { + var iterable = arguments[0]; + if (!(this instanceof SetPoly)) return new SetPoly(iterable); + if (this.__setData__ !== undefined) { + throw new TypeError(this + " cannot be reinitialized"); + } + if (iterable != null) iterator(iterable); + defineProperty(this, '__setData__', d('c', [])); + if (!iterable) return; + forOf(iterable, function (value) { + if (eIndexOf.call(this, value) !== -1) return; + this.push(value); + }, this.__setData__); +}; + +if (isNative) { + if (setPrototypeOf) setPrototypeOf(SetPoly, Set); + SetPoly.prototype = Object.create(Set.prototype, { + constructor: d(SetPoly) + }); +} + +ee(Object.defineProperties(SetPoly.prototype, { + add: d(function (value) { + if (this.has(value)) return this; + this.emit('_add', this.__setData__.push(value) - 1, value); + return this; + }), + clear: d(function () { + if (!this.__setData__.length) return; + clear.call(this.__setData__); + this.emit('_clear'); + }), + delete: d(function (value) { + var index = eIndexOf.call(this.__setData__, value); + if (index === -1) return false; + this.__setData__.splice(index, 1); + this.emit('_delete', index, value); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + forEach: d(function (cb/*, thisArg*/) { + var thisArg = arguments[1], iterator, result, value; + callable(cb); + iterator = this.values(); + result = iterator._next(); + while (result !== undefined) { + value = iterator._resolve(result); + call.call(cb, thisArg, value, value, this); + result = iterator._next(); + } + }), + has: d(function (value) { + return (eIndexOf.call(this.__setData__, value) !== -1); + }), + keys: d(getValues = function () { return this.values(); }), + size: d.gs(function () { return this.__setData__.length; }), + values: d(function () { return new Iterator(this); }), + toString: d(function () { return '[object Set]'; }) +})); +defineProperty(SetPoly.prototype, Symbol.iterator, d(getValues)); +defineProperty(SetPoly.prototype, Symbol.toStringTag, d('c', 'Set')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/primitive/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/primitive/index.js new file mode 100644 index 0000000..4565887 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/primitive/index.js @@ -0,0 +1,88 @@ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , clear = require('es5-ext/object/clear') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Set = require('../polyfill') + , Iterator = require('../lib/primitive-iterator') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty + , hasOwnProperty = Object.prototype.hasOwnProperty + , PrimitiveSet; + +module.exports = PrimitiveSet = function (/*iterable, serialize*/) { + var iterable = arguments[0], serialize = arguments[1]; + if (!(this instanceof PrimitiveSet)) { + return new PrimitiveSet(iterable, serialize); + } + if (this.__setData__ !== undefined) { + throw new TypeError(this + " cannot be reinitialized"); + } + if (iterable != null) iterator(iterable); + if (serialize !== undefined) { + callable(serialize); + defineProperty(this, '_serialize', d('', serialize)); + } + defineProperties(this, { + __setData__: d('c', create(null)), + __size__: d('w', 0) + }); + if (!iterable) return; + forOf(iterable, function (value) { + var key = this._serialize(value); + if (key == null) throw new TypeError(value + " cannot be serialized"); + if (hasOwnProperty.call(this.__setData__, key)) return; + this.__setData__[key] = value; + ++this.__size__; + }, this); +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveSet, Set); + +PrimitiveSet.prototype = create(Set.prototype, { + constructor: d(PrimitiveSet), + _serialize: d(function (value) { + if (value && (typeof value.toString !== 'function')) return null; + return String(value); + }), + add: d(function (value) { + var key = this._serialize(value); + if (key == null) throw new TypeError(value + " cannot be serialized"); + if (hasOwnProperty.call(this.__setData__, key)) return this; + this.__setData__[key] = value; + ++this.__size__; + this.emit('_add', key); + return this; + }), + clear: d(function () { + if (!this.__size__) return; + clear(this.__setData__); + this.__size__ = 0; + this.emit('_clear'); + }), + delete: d(function (value) { + var key = this._serialize(value); + if (key == null) return false; + if (!hasOwnProperty.call(this.__setData__, key)) return false; + delete this.__setData__[key]; + --this.__size__; + this.emit('_delete', key); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + get: d(function (key) { + key = this._serialize(key); + if (key == null) return; + return this.__setData__[key]; + }), + has: d(function (value) { + var key = this._serialize(value); + if (key == null) return false; + return hasOwnProperty.call(this.__setData__, key); + }), + size: d.gs(function () { return this.__size__; }), + values: d(function () { return new Iterator(this); }) +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/copy.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/copy.js new file mode 100644 index 0000000..84fe912 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/copy.js @@ -0,0 +1,12 @@ +'use strict'; + +var toArray = require('es5-ext/array/to-array') + , Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content), copy; + + copy = t.call(set); + a.not(copy, set, "Copy"); + a.deep(toArray(copy), content, "Content"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/every.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/every.js new file mode 100644 index 0000000..f56ca38 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/every.js @@ -0,0 +1,9 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + a(t.call(new Set(), Boolean), true, "Empty set"); + a(t.call(new Set([2, 3, 4]), Boolean), true, "Truthy"); + a(t.call(new Set([2, 0, 4]), Boolean), false, "Falsy"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-first.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-first.js new file mode 100644 index 0000000..f99829e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-first.js @@ -0,0 +1,12 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content); + + a(t.call(set), 'raz'); + + set = new Set(); + a(t.call(set), undefined); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-last.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-last.js new file mode 100644 index 0000000..1dcc993 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/get-last.js @@ -0,0 +1,12 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + var content = ['raz', 2, true], set = new Set(content); + + a(t.call(set), true); + + set = new Set(); + a(t.call(set), undefined); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/some.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/some.js new file mode 100644 index 0000000..84ce119 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/ext/some.js @@ -0,0 +1,10 @@ +'use strict'; + +var Set = require('../../'); + +module.exports = function (t, a) { + a(t.call(new Set(), Boolean), false, "Empty set"); + a(t.call(new Set([2, 3, 4]), Boolean), true, "All true"); + a(t.call(new Set([0, false, 4]), Boolean), true, "Some false"); + a(t.call(new Set([0, false, null]), Boolean), false, "All false"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/implement.js new file mode 100644 index 0000000..4882d37 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Set, 'function'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/index.js new file mode 100644 index 0000000..19c6486 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (T, a) { a((new T(['raz', 'dwa'])).size, 2); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-implemented.js new file mode 100644 index 0000000..124793e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Set; + global.Set = polyfill; + a(t(), true); + if (cache === undefined) delete global.Set; + else global.Set = cache; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-native-implemented.js new file mode 100644 index 0000000..df8ba03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-set.js new file mode 100644 index 0000000..c969cce --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/is-set.js @@ -0,0 +1,16 @@ +'use strict'; + +var SetPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Set !== 'undefined') { + a(t(new Set()), true, "Native"); + } + a(t(new SetPoly()), true, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/iterator.js new file mode 100644 index 0000000..9e5cfb9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/iterator.js @@ -0,0 +1,13 @@ +'use strict'; + +var Set = require('../../polyfill') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var set = new Set(['raz', 'dwa']); + + a.deep(toArray(new T(set)), ['raz', 'dwa'], "Default"); + a.deep(toArray(new T(set, 'key+value')), [['raz', 'raz'], ['dwa', 'dwa']], + "Key & Value"); + a.deep(toArray(new T(set, 'value')), ['raz', 'dwa'], "Other"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/primitive-iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/primitive-iterator.js new file mode 100644 index 0000000..2a4956b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/lib/primitive-iterator.js @@ -0,0 +1,113 @@ +'use strict'; + +var Set = require('../../primitive') + , toArray = require('es5-ext/array/to-array') + , iteratorSymbol = require('es6-symbol').iterator + + , compare, map; + +compare = function (a, b) { + if (!a.value) return -1; + if (!b.value) return 1; + return a.value.localeCompare(b.value); +}; + +map = function (arr) { + return arr.sort().map(function (value) { + return { done: false, value: value }; + }); +}; + +module.exports = function (T) { + return { + "": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it, y, z + , set = new Set(arr), result = []; + + it = new T(set); + a(it[iteratorSymbol](), it, "@@iterator"); + y = it.next(); + result.push(y); + z = it.next(); + a.not(y, z, "Recreate result"); + result.push(z); + result.push(it.next()); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(y = it.next(), { done: true, value: undefined }, "End"); + a.not(y, it.next(), "Recreate result on dead"); + }, + Emited: function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.add('sześć'); + arr.push('sześć'); + result.push(it.next()); + set.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited #2": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.add('siedem'); + set.delete('siedem'); + result.push(it.next()); + result.push(it.next()); + set.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #1": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + arr = ['raz', 'dwa']; + set.clear(); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #2": function (a) { + var arr = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it + , set = new Set(arr), result = []; + + it = new T(set); + result.push(it.next()); + result.push(it.next()); + set.clear(); + set.add('foo'); + set.add('bar'); + arr = ['raz', 'dwa', 'foo', 'bar']; + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), map(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + Kinds: function (a) { + var set = new Set(['raz', 'dwa']); + + a.deep(toArray(new T(set)).sort(), ['raz', 'dwa'].sort(), "Default"); + a.deep(toArray(new T(set, 'key+value')).sort(), + [['raz', 'raz'], ['dwa', 'dwa']].sort(), "Key & Value"); + a.deep(toArray(new T(set, 'value')).sort(), ['raz', 'dwa'].sort(), + "Other"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/polyfill.js new file mode 100644 index 0000000..10ce6d3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/polyfill.js @@ -0,0 +1,44 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = {}, y = {}, i = 0; + + a(set instanceof T, true, "Set"); + a(set.size, 3, "Size"); + a(set.has('raz'), true, "Has: true"); + a(set.has(x), false, "Has: false"); + a(set.add(x), set, "Add: return"); + a(set.has(x), true, "Add"); + a(set.size, 4, "Add: Size"); + a(set.delete({}), false, "Delete: false"); + + arr.push(x); + set.forEach(function () { + a.deep(aFrom(arguments), [arr[i], arr[i], set], + "ForEach: Arguments: #" + i); + a(this, y, "ForEach: Context: #" + i); + if (i === 0) { + a(set.delete('raz'), true, "Delete: true"); + a(set.has('raz'), false, "Delete"); + a(set.size, 3, "Delete: size"); + set.add('cztery'); + arr.push('cztery'); + } + i++; + }, y); + arr.splice(0, 1); + + a.deep(toArray(set.entries()), [['dwa', 'dwa'], ['trzy', 'trzy'], [x, x], + ['cztery', 'cztery']], "Entries"); + a.deep(toArray(set.keys()), ['dwa', 'trzy', x, 'cztery'], "Keys"); + a.deep(toArray(set.values()), ['dwa', 'trzy', x, 'cztery'], "Values"); + a.deep(toArray(set), ['dwa', 'trzy', x, 'cztery'], "Iterator"); + + set.clear(); + a(set.size, 0, "Clear: size"); + a(set.has('trzy'), false, "Clear: has"); + a.deep(toArray(set), [], "Clear: Values"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/primitive/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/primitive/index.js new file mode 100644 index 0000000..54765d2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/primitive/index.js @@ -0,0 +1,44 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , getIterator = require('es6-iterator/get') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = 'other', y = 'other2' + , i = 0, result = []; + + a(set instanceof T, true, "Set"); + a(set.size, 3, "Size"); + a(set.has('raz'), true, "Has: true"); + a(set.has(x), false, "Has: false"); + a(set.add(x), set, "Add: return"); + a(set.has(x), true, "Add"); + a(set.size, 4, "Add: Size"); + a(set.delete('else'), false, "Delete: false"); + a(set.get('raz'), 'raz', "Get"); + + arr.push(x); + set.forEach(function () { + result.push(aFrom(arguments)); + a(this, y, "ForEach: Context: #" + i); + }, y); + + a.deep(result.sort(function (a, b) { + return a[0].localeCompare(b[0]); + }), arr.sort().map(function (val) { return [val, val, set]; })); + + a.deep(toArray(set.entries()).sort(), [['dwa', 'dwa'], ['trzy', 'trzy'], + [x, x], ['raz', 'raz']].sort(), "Entries"); + a.deep(toArray(set.keys()).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Keys"); + a.deep(toArray(set.values()).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Values"); + a.deep(toArray(getIterator(set)).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Iterator"); + + set.clear(); + a(set.size, 0, "Clear: size"); + a(set.has('trzy'), false, "Clear: has"); + a.deep(toArray(set.values()), [], "Clear: Values"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/valid-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/valid-set.js new file mode 100644 index 0000000..8c71f5f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/test/valid-set.js @@ -0,0 +1,19 @@ +'use strict'; + +var SetPoly = require('../polyfill'); + +module.exports = function (t, a) { + var set; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Set !== 'undefined') { + set = new Set(); + a(t(set), set, "Native"); + } + set = new SetPoly(); + a(t(set), set, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/valid-set.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/valid-set.js new file mode 100644 index 0000000..9336fd3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-set/valid-set.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSet = require('./is-set'); + +module.exports = function (x) { + if (!isSet(x)) throw new TypeError(x + " is not a Set"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.lint new file mode 100644 index 0000000..701a50c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.lint @@ -0,0 +1,13 @@ +@root + +module + +tabs +indent 2 +maxlen 80 + +ass +nomen +plusplus + +newcap diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.npmignore new file mode 100644 index 0000000..155e41f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.travis.yml new file mode 100644 index 0000000..afd3509 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +notifications: + email: + - medikoo+es6-symbol@medikoo.com diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/CHANGES new file mode 100644 index 0000000..ff5e1b4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/CHANGES @@ -0,0 +1,12 @@ +v0.1.1 -- 2014.10.07 +* Fix isImplemented, so it returns true in case of polyfill +* Improve documentations + +v0.1.0 -- 2014.04.28 +* Assure strictly npm dependencies +* Update to use latest versions of dependencies +* Fix implementation detection so it doesn't crash on `String(symbol)` +* throw on `new Symbol()` (as decided by TC39) + +v0.0.0 -- 2013.11.15 +* Initial (dev) version \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/LICENCE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/LICENCE new file mode 100644 index 0000000..aaf3528 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/LICENCE @@ -0,0 +1,19 @@ +Copyright (C) 2013 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/README.md new file mode 100644 index 0000000..978eb59 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/README.md @@ -0,0 +1,67 @@ +# es6-symbol +## ECMAScript6 Symbol polyfill + +### Limitations + +- Underneath it uses real string property names which can easily be retrieved (however accidental collision with other property names is unlikely) +- As it needs custom `toString` behavior to work properly. Original `Symbol.prototype.toString` couldn't be implemented as specified, still it's accessible as `Symbol.prototoype.properToString` + +### Usage + +If you want to make sure your environment implements `Symbol`, do: + +```javascript +require('es6-symbol/implement'); +``` + +If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Symbol` on global scope, do: + +```javascript +var Symbol = require('es6-symbol'); +``` + +If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do: + +```javascript +var Symbol = require('es6-symbol/polyfill'); +``` + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples: + +```javascript +var Symbol = require('es6-symbol'); + +var symbol = Symbol('My custom symbol'); +var x = {}; + +x[symbol] = 'foo'; +console.log(x[symbol]); 'foo' + +// Detect iterable: +var iterator, result; +if (possiblyIterable[Symbol.iterator]) { + iterator = possiblyIterable[Symbol.iterator](); + result = iterator.next(); + while(!result.done) { + console.log(result.value); + result = iterator.next(); + } +} +``` + +### Installation +#### NPM + +In your project path: + + $ npm install es6-symbol + +##### Browser + +You can easily bundle _es6-symbol_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake) + +## Tests [](https://travis-ci.org/medikoo/es6-symbol) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/implement.js new file mode 100644 index 0000000..153edac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Symbol', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/index.js new file mode 100644 index 0000000..609f1fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-implemented.js new file mode 100644 index 0000000..02a06b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-implemented.js @@ -0,0 +1,19 @@ +'use strict'; + +module.exports = function () { + var symbol; + if (typeof Symbol !== 'function') return false; + symbol = Symbol('test symbol'); + try { String(symbol); } catch (e) { return false; } + if (typeof Symbol.iterator === 'symbol') return true; + + // Return 'true' for polyfills + if (typeof Symbol.isConcatSpreadable !== 'object') return false; + if (typeof Symbol.isRegExp !== 'object') return false; + if (typeof Symbol.iterator !== 'object') return false; + if (typeof Symbol.toPrimitive !== 'object') return false; + if (typeof Symbol.toStringTag !== 'object') return false; + if (typeof Symbol.unscopables !== 'object') return false; + + return true; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-native-implemented.js new file mode 100644 index 0000000..a8cb8b8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-native-implemented.js @@ -0,0 +1,8 @@ +// Exports true if environment provides native `Symbol` implementation + +'use strict'; + +module.exports = (function () { + if (typeof Symbol !== 'function') return false; + return (typeof Symbol.iterator === 'symbol'); +}()); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-symbol.js new file mode 100644 index 0000000..dcf72c9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/is-symbol.js @@ -0,0 +1,12 @@ +'use strict'; + +var toString = Object.prototype.toString + , toStringTag = require('./').toStringTag + + , id = '[object Symbol]' + , Global = (typeof Symbol === 'undefined') ? null : Symbol; + +module.exports = function (x) { + return (x && ((Global && (x instanceof Global)) || + (toString.call(x) === id) || (x[toStringTag] === 'Symbol'))) || false; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/package.json new file mode 100644 index 0000000..a6ddc1a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/package.json @@ -0,0 +1,59 @@ +{ + "name": "es6-symbol", + "version": "0.1.1", + "description": "ECMAScript6 Symbol polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "symbol", + "private", + "property", + "es6", + "ecmascript", + "harmony" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-symbol.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.4" + }, + "devDependencies": { + "tad": "0.2.x" + }, + "scripts": { + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "2ca76a05feafaa14c838337722562625fb5072b4", + "bugs": { + "url": "https://github.com/medikoo/es6-symbol/issues" + }, + "homepage": "https://github.com/medikoo/es6-symbol", + "_id": "es6-symbol@0.1.1", + "_shasum": "9cf7fab2edaff1b1da8fe8e68bfe3f5aca6ca218", + "_from": "es6-symbol@>=0.1.1 <0.2.0", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "9cf7fab2edaff1b1da8fe8e68bfe3f5aca6ca218", + "tarball": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-0.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-0.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/polyfill.js new file mode 100644 index 0000000..f7dfa25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/polyfill.js @@ -0,0 +1,53 @@ +'use strict'; + +var d = require('d') + + , create = Object.create, defineProperties = Object.defineProperties + , generateName, Symbol; + +generateName = (function () { + var created = create(null); + return function (desc) { + var postfix = 0; + while (created[desc + (postfix || '')]) ++postfix; + desc += (postfix || ''); + created[desc] = true; + return '@@' + desc; + }; +}()); + +module.exports = Symbol = function (description) { + var symbol; + if (this instanceof Symbol) { + throw new TypeError('TypeError: Symbol is not a constructor'); + } + symbol = create(Symbol.prototype); + description = (description === undefined ? '' : String(description)); + return defineProperties(symbol, { + __description__: d('', description), + __name__: d('', generateName(description)) + }); +}; + +Object.defineProperties(Symbol, { + create: d('', Symbol('create')), + hasInstance: d('', Symbol('hasInstance')), + isConcatSpreadable: d('', Symbol('isConcatSpreadable')), + isRegExp: d('', Symbol('isRegExp')), + iterator: d('', Symbol('iterator')), + toPrimitive: d('', Symbol('toPrimitive')), + toStringTag: d('', Symbol('toStringTag')), + unscopables: d('', Symbol('unscopables')) +}); + +defineProperties(Symbol.prototype, { + properToString: d(function () { + return 'Symbol (' + this.__description__ + ')'; + }), + toString: d('', function () { return this.__name__; }) +}); +Object.defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', + function (hint) { + throw new TypeError("Conversion of symbol objects is not allowed"); + })); +Object.defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/implement.js new file mode 100644 index 0000000..eb35c30 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Symbol, 'function'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/index.js new file mode 100644 index 0000000..62b3296 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var d = require('d') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-implemented.js new file mode 100644 index 0000000..bb0d645 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Symbol; + global.Symbol = polyfill; + a(t(), true); + if (cache === undefined) delete global.Symbol; + else global.Symbol = cache; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-native-implemented.js new file mode 100644 index 0000000..df8ba03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-symbol.js new file mode 100644 index 0000000..ac24b9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/is-symbol.js @@ -0,0 +1,16 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Symbol !== 'undefined') { + a(t(Symbol()), true, "Native"); + } + a(t(SymbolPoly()), true, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/polyfill.js new file mode 100644 index 0000000..cac9cd5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/polyfill.js @@ -0,0 +1,17 @@ +'use strict'; + +var d = require('d') + , isSymbol = require('../is-symbol') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); + + a(isSymbol(symbol), true, "Symbol"); + a(isSymbol(T.iterator), true, "iterator"); + a(isSymbol(T.toStringTag), true, "toStringTag"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-iterable.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-iterable.js new file mode 100644 index 0000000..d277bc9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-iterable.js @@ -0,0 +1,14 @@ +'use strict'; + +var Iterator = require('../'); + +module.exports = function (t, a) { + var obj; + a.throws(function () { t(); }, TypeError, "Undefined"); + a.throws(function () { t({}); }, TypeError, "Plain object"); + a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); + obj = { '@@iterator': function () { return new Iterator([]); } }; + a(t(obj), obj, "Iterator"); + obj = []; + a(t(obj), obj, 'Array'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-symbol.js new file mode 100644 index 0000000..2c8f84c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/test/valid-symbol.js @@ -0,0 +1,19 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + var symbol; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Symbol !== 'undefined') { + symbol = Symbol(); + a(t(symbol), symbol, "Native"); + } + symbol = SymbolPoly(); + a(t(symbol), symbol, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/valid-symbol.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/valid-symbol.js new file mode 100644 index 0000000..4275004 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/es6-symbol/valid-symbol.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSymbol = require('./is-symbol'); + +module.exports = function (value) { + if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); + return value; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.lint b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.lint new file mode 100644 index 0000000..f76e528 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.lint @@ -0,0 +1,15 @@ +@root + +module +es5 + +indent 2 +maxlen 80 +tabs + +ass +plusplus +nomen + +./benchmark +predef+ console diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.npmignore new file mode 100644 index 0000000..68ebfdd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.npmignore @@ -0,0 +1,3 @@ +.DS_Store +/.lintcache +/node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.testignore b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.testignore new file mode 100644 index 0000000..f9c8c38 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.testignore @@ -0,0 +1 @@ +/benchmark diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.travis.yml new file mode 100644 index 0000000..a6ec240 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/.travis.yml @@ -0,0 +1,14 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 + +before_install: + - mkdir node_modules; ln -s ../ node_modules/event-emitter + +notifications: + email: + - medikoo+event-emitter@medikoo.com + +script: "npm test && npm run lint" diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/CHANGES b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/CHANGES new file mode 100644 index 0000000..dbc1b17 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/CHANGES @@ -0,0 +1,66 @@ +v0.3.3 -- 2015.01.30 +* Fix reference to module in benchmarks + +v0.3.2 -- 2015.01.20 +* Improve documentation +* Configure lint scripts +* Fix spelling of LICENSE + +v0.3.1 -- 2014.04.25 +* Fix redefinition of emit method in `pipe` +* Allow custom emit method name in `pipe` + +v0.3.0 -- 2014.04.24 +* Move out from lib folder +* Do not expose all utilities on main module +* Support objects which do not inherit from Object.prototype +* Improve arguments validation +* Improve internals +* Remove Makefile +* Improve documentation + +v0.2.2 -- 2013.06.05 +* `unify` functionality + +v0.2.1 -- 2012.09.21 +* hasListeners module +* Simplified internal id (improves performance a little), now it starts with + underscore (hint it's private). Abstracted it to external module to have it + one place +* Documentation cleanup + +v0.2.0 -- 2012.09.19 +* Trashed poor implementation of v0.1 and came up with something solid + +Changes: +* Improved performance +* Fixed bugs event-emitter is now cross-prototype safe and not affected by + unexpected methods attached to Object.prototype +* Removed support for optional "emitter" argument in `emit` method, it was + cumbersome to use, and should be solved just with event objects + +v0.1.5 -- 2012.08.06 +* (maintanance) Do not use descriptors for internal objects, it exposes V8 bugs + (only Node v0.6 branch) + +v0.1.4 -- 2012.06.13 +* Fix detachment of listeners added with 'once' + +v0.1.3 -- 2012.05.28 +* Updated es5-ext to latest version (v0.8) +* Cleared package.json so it's in npm friendly format + +v0.1.2 -- 2012.01.22 +* Support for emitter argument in emit function, this allows some listeners not + to be notified about event +* allOff - removes all listeners from object +* All methods returns self object +* Internal fixes +* Travis CI integration + +v0.1.1 -- 2011.08.08 +* Added TAD test suite to devDependencies, configured test commands. + Tests can be run with 'make test' or 'npm test' + +v0.1.0 -- 2011.08.08 +Initial version diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/LICENSE new file mode 100644 index 0000000..ccb76f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2012-2015 Mariusz Nowak (www.medikoo.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/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/README.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/README.md new file mode 100644 index 0000000..17f4524 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/README.md @@ -0,0 +1,95 @@ +# event-emitter +## Environment agnostic event emitter + +### Installation + + $ npm install event-emitter + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +### Usage + +```javascript +var ee = require('event-emitter'); + +var emitter = ee({}), listener; + +emitter.on('test', listener = function (args) { + // …emitter logic +}); + +emitter.once('test', function (args) { + // …invoked only once(!) +}); + +emitter.emit('test', arg1, arg2/*…args*/); // Two above listeners invoked +emitter.emit('test', arg1, arg2/*…args*/); // Only first listener invoked + +emitter.off('test', listener); // Removed first listener +emitter.emit('test', arg1, arg2/*…args*/); // No listeners invoked +``` +### Additional utilities + +#### allOff(obj) _(event-emitter/all-off)_ + +Removes all listeners from given event emitter object + +#### hasListeners(obj[, name]) _(event-emitter/has-listeners)_ + +Whether object has some listeners attached to the object. +When `name` is provided, it checks listeners for specific event name + +```javascript +var emitter = ee(); +var hasListeners = require('event-emitter/has-listeners'); +var listener = function () {}; + +hasListeners(emitter); // false + +emitter.on('foo', listener); +hasListeners(emitter); // true +hasListeners(emitter, 'foo'); // true +hasListeners(emitter, 'bar'); // false + +emitter.off('foo', listener); +hasListeners(emitter, 'foo'); // false +``` + +#### pipe(source, target[, emitMethodName]) _(event-emitter/pipe)_ + +Pipes all events from _source_ emitter onto _target_ emitter (all events from _source_ emitter will be emitted also on _target_ emitter, but not other way). +Returns _pipe_ object which exposes `pipe.close` function. Invoke it to close configured _pipe_. +It works internally by redefinition of `emit` method, if in your interface this method is referenced differently, provide its name (or symbol) with third argument. + +#### unify(emitter1, emitter2) _(event-emitter/unify)_ + +Unifies event handling for two objects. Events emitted on _emitter1_ would be also emitter on _emitter2_, and other way back. +Non reversible. + +```javascript +var eeUnify = require('event-emitter/unify'); + +var emitter1 = ee(), listener1, listener3; +var emitter2 = ee(), listener2, listener4; + +emitter1.on('test', listener1 = function () { }); +emitter2.on('test', listener2 = function () { }); + +emitter1.emit('test'); // Invoked listener1 +emitter2.emit('test'); // Invoked listener2 + +var unify = eeUnify(emitter1, emitter2); + +emitter1.emit('test'); // Invoked listener1 and listener2 +emitter2.emit('test'); // Invoked listener1 and listener2 + +emitter1.on('test', listener3 = function () { }); +emitter2.on('test', listener4 = function () { }); + +emitter1.emit('test'); // Invoked listener1, listener2, listener3 and listener4 +emitter2.emit('test'); // Invoked listener1, listener2, listener3 and listener4 +``` + +### Tests [](https://travis-ci.org/medikoo/event-emitter) + + $ npm test diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/all-off.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/all-off.js new file mode 100644 index 0000000..829be65 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/all-off.js @@ -0,0 +1,19 @@ +'use strict'; + +var value = require('es5-ext/object/valid-object') + + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function (emitter/*, type*/) { + var type = arguments[1], data; + + value(emitter); + + if (type !== undefined) { + data = hasOwnProperty.call(emitter, '__ee__') && emitter.__ee__; + if (!data) return; + if (data[type]) delete data[type]; + return; + } + if (hasOwnProperty.call(emitter, '__ee__')) delete emitter.__ee__; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/many-on.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/many-on.js new file mode 100644 index 0000000..e09bfde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/many-on.js @@ -0,0 +1,83 @@ +'use strict'; + +// Benchmark comparing performance of event emit for many listeners +// To run it, do following in memoizee package path: +// +// $ npm install eventemitter2 signals +// $ node benchmark/many-on.js + +var forEach = require('es5-ext/object/for-each') + , pad = require('es5-ext/string/#/pad') + + , now = Date.now + + , time, count = 1000000, i, data = {} + , ee, native, ee2, signals, a = {}, b = {}; + +ee = (function () { + var ee = require('../')(); + ee.on('test', function () { return arguments; }); + ee.on('test', function () { return arguments; }); + return ee.on('test', function () { return arguments; }); +}()); + +native = (function () { + var ee = require('events'); + ee = new ee.EventEmitter(); + ee.on('test', function () { return arguments; }); + ee.on('test', function () { return arguments; }); + return ee.on('test', function () { return arguments; }); +}()); + +ee2 = (function () { + var ee = require('eventemitter2'); + ee = new ee.EventEmitter2(); + ee.on('test', function () { return arguments; }); + ee.on('test', function () { return arguments; }); + return ee.on('test', function () { return arguments; }); +}()); + +signals = (function () { + var Signal = require('signals') + , ee = { test: new Signal() }; + ee.test.add(function () { return arguments; }); + ee.test.add(function () { return arguments; }); + ee.test.add(function () { return arguments; }); + return ee; +}()); + +console.log("Emit for 3 listeners", "x" + count + ":\n"); + +i = count; +time = now(); +while (i--) { + ee.emit('test', a, b); +} +data["event-emitter (this implementation)"] = now() - time; + +i = count; +time = now(); +while (i--) { + native.emit('test', a, b); +} +data["EventEmitter (Node.js native)"] = now() - time; + +i = count; +time = now(); +while (i--) { + ee2.emit('test', a, b); +} +data.EventEmitter2 = now() - time; + +i = count; +time = now(); +while (i--) { + signals.test.dispatch(a, b); +} +data.Signals = now() - time; + +forEach(data, function (value, name, obj, index) { + console.log(index + 1 + ":", pad.call(value, " ", 5), name); +}, null, function (a, b) { + return this[a] - this[b]; +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/single-on.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/single-on.js new file mode 100644 index 0000000..99decbd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/benchmark/single-on.js @@ -0,0 +1,73 @@ +'use strict'; + +// Benchmark comparing performance of event emit for single listener +// To run it, do following in memoizee package path: +// +// $ npm install eventemitter2 signals +// $ node benchmark/single-on.js + +var forEach = require('es5-ext/object/for-each') + , pad = require('es5-ext/string/#/pad') + + , now = Date.now + + , time, count = 1000000, i, data = {} + , ee, native, ee2, signals, a = {}, b = {}; + +ee = (function () { + var ee = require('../'); + return ee().on('test', function () { return arguments; }); +}()); + +native = (function () { + var ee = require('events'); + return (new ee.EventEmitter()).on('test', function () { return arguments; }); +}()); + +ee2 = (function () { + var ee = require('eventemitter2'); + return (new ee.EventEmitter2()).on('test', function () { return arguments; }); +}()); + +signals = (function () { + var Signal = require('signals') + , ee = { test: new Signal() }; + ee.test.add(function () { return arguments; }); + return ee; +}()); + +console.log("Emit for single listener", "x" + count + ":\n"); + +i = count; +time = now(); +while (i--) { + ee.emit('test', a, b); +} +data["event-emitter (this implementation)"] = now() - time; + +i = count; +time = now(); +while (i--) { + native.emit('test', a, b); +} +data["EventEmitter (Node.js native)"] = now() - time; + +i = count; +time = now(); +while (i--) { + ee2.emit('test', a, b); +} +data.EventEmitter2 = now() - time; + +i = count; +time = now(); +while (i--) { + signals.test.dispatch(a, b); +} +data.Signals = now() - time; + +forEach(data, function (value, name, obj, index) { + console.log(index + 1 + ":", pad.call(value, " ", 5), name); +}, null, function (a, b) { + return this[a] - this[b]; +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/has-listeners.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/has-listeners.js new file mode 100644 index 0000000..8744522 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/has-listeners.js @@ -0,0 +1,16 @@ +'use strict'; + +var isEmpty = require('es5-ext/object/is-empty') + , value = require('es5-ext/object/valid-value') + + , hasOwnProperty = Object.prototype.hasOwnProperty; + +module.exports = function (obj/*, type*/) { + var type; + value(obj); + type = arguments[1]; + if (arguments.length > 1) { + return hasOwnProperty.call(obj, '__ee__') && Boolean(obj.__ee__[type]); + } + return obj.hasOwnProperty('__ee__') && !isEmpty(obj.__ee__); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/index.js new file mode 100644 index 0000000..c36d3e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/index.js @@ -0,0 +1,132 @@ +'use strict'; + +var d = require('d') + , callable = require('es5-ext/object/valid-callable') + + , apply = Function.prototype.apply, call = Function.prototype.call + , create = Object.create, defineProperty = Object.defineProperty + , defineProperties = Object.defineProperties + , hasOwnProperty = Object.prototype.hasOwnProperty + , descriptor = { configurable: true, enumerable: false, writable: true } + + , on, once, off, emit, methods, descriptors, base; + +on = function (type, listener) { + var data; + + callable(listener); + + if (!hasOwnProperty.call(this, '__ee__')) { + data = descriptor.value = create(null); + defineProperty(this, '__ee__', descriptor); + descriptor.value = null; + } else { + data = this.__ee__; + } + if (!data[type]) data[type] = listener; + else if (typeof data[type] === 'object') data[type].push(listener); + else data[type] = [data[type], listener]; + + return this; +}; + +once = function (type, listener) { + var once, self; + + callable(listener); + self = this; + on.call(this, type, once = function () { + off.call(self, type, once); + apply.call(listener, this, arguments); + }); + + once.__eeOnceListener__ = listener; + return this; +}; + +off = function (type, listener) { + var data, listeners, candidate, i; + + callable(listener); + + if (!hasOwnProperty.call(this, '__ee__')) return this; + data = this.__ee__; + if (!data[type]) return this; + listeners = data[type]; + + if (typeof listeners === 'object') { + for (i = 0; (candidate = listeners[i]); ++i) { + if ((candidate === listener) || + (candidate.__eeOnceListener__ === listener)) { + if (listeners.length === 2) data[type] = listeners[i ? 0 : 1]; + else listeners.splice(i, 1); + } + } + } else { + if ((listeners === listener) || + (listeners.__eeOnceListener__ === listener)) { + delete data[type]; + } + } + + return this; +}; + +emit = function (type) { + var i, l, listener, listeners, args; + + if (!hasOwnProperty.call(this, '__ee__')) return; + listeners = this.__ee__[type]; + if (!listeners) return; + + if (typeof listeners === 'object') { + l = arguments.length; + args = new Array(l - 1); + for (i = 1; i < l; ++i) args[i - 1] = arguments[i]; + + listeners = listeners.slice(); + for (i = 0; (listener = listeners[i]); ++i) { + apply.call(listener, this, args); + } + } else { + switch (arguments.length) { + case 1: + call.call(listeners, this); + break; + case 2: + call.call(listeners, this, arguments[1]); + break; + case 3: + call.call(listeners, this, arguments[1], arguments[2]); + break; + default: + l = arguments.length; + args = new Array(l - 1); + for (i = 1; i < l; ++i) { + args[i - 1] = arguments[i]; + } + apply.call(listeners, this, args); + } + } +}; + +methods = { + on: on, + once: once, + off: off, + emit: emit +}; + +descriptors = { + on: d(on), + once: d(once), + off: d(off), + emit: d(emit) +}; + +base = defineProperties({}, descriptors); + +module.exports = exports = function (o) { + return (o == null) ? create(base) : defineProperties(Object(o), descriptors); +}; +exports.methods = methods; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/package.json new file mode 100644 index 0000000..17a904e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/package.json @@ -0,0 +1,64 @@ +{ + "name": "event-emitter", + "version": "0.3.3", + "description": "Environment agnostic event emitter", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "event", + "events", + "trigger", + "observer", + "listener", + "emitter", + "pubsub" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/event-emitter.git" + }, + "dependencies": { + "es5-ext": "~0.10.5", + "d": "~0.1.1" + }, + "devDependencies": { + "tad": "~0.2.1", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "13f184ab039e3559164691d3a6a3d6b8c84aed3e", + "bugs": { + "url": "https://github.com/medikoo/event-emitter/issues" + }, + "homepage": "https://github.com/medikoo/event-emitter", + "_id": "event-emitter@0.3.3", + "_shasum": "df8e806541c68ab8ff20a79a1841b91abaa1bee4", + "_from": "event-emitter@>=0.3.1 <0.4.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "df8e806541c68ab8ff20a79a1841b91abaa1bee4", + "tarball": "http://registry.npmjs.org/event-emitter/-/event-emitter-0.3.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/pipe.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/pipe.js new file mode 100644 index 0000000..0088efe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/pipe.js @@ -0,0 +1,42 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , remove = require('es5-ext/array/#/remove') + , value = require('es5-ext/object/valid-object') + , d = require('d') + , emit = require('./').methods.emit + + , defineProperty = Object.defineProperty + , hasOwnProperty = Object.prototype.hasOwnProperty + , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +module.exports = function (e1, e2/*, name*/) { + var pipes, pipe, desc, name; + + (value(e1) && value(e2)); + name = arguments[2]; + if (name === undefined) name = 'emit'; + + pipe = { + close: function () { remove.call(pipes, e2); } + }; + if (hasOwnProperty.call(e1, '__eePipes__')) { + (pipes = e1.__eePipes__).push(e2); + return pipe; + } + defineProperty(e1, '__eePipes__', d('c', pipes = [e2])); + desc = getOwnPropertyDescriptor(e1, name); + if (!desc) { + desc = d('c', undefined); + } else { + delete desc.get; + delete desc.set; + } + desc.value = function () { + var i, emitter, data = aFrom(pipes); + emit.apply(this, arguments); + for (i = 0; (emitter = data[i]); ++i) emit.apply(emitter, arguments); + }; + defineProperty(e1, name, desc); + return pipe; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/all-off.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/all-off.js new file mode 100644 index 0000000..8aa872e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/all-off.js @@ -0,0 +1,48 @@ +'use strict'; + +var ee = require('../'); + +module.exports = function (t, a) { + var x, count, count2; + + x = ee(); + count = 0; + count2 = 0; + x.on('foo', function () { + ++count; + }); + x.on('foo', function () { + ++count; + }); + x.on('bar', function () { + ++count2; + }); + x.on('bar', function () { + ++count2; + }); + t(x, 'foo'); + x.emit('foo'); + x.emit('bar'); + a(count, 0, "All off: type"); + a(count2, 2, "All off: ohter type"); + + count = 0; + count2 = 0; + x.on('foo', function () { + ++count; + }); + x.on('foo', function () { + ++count; + }); + x.on('bar', function () { + ++count2; + }); + x.on('bar', function () { + ++count2; + }); + t(x); + x.emit('foo'); + x.emit('bar'); + a(count, 0, "All off: type"); + a(count2, 0, "All off: other type"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/has-listeners.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/has-listeners.js new file mode 100644 index 0000000..875b048 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/has-listeners.js @@ -0,0 +1,42 @@ +'use strict'; + +var ee = require('../'); + +module.exports = function (t) { + var x, y; + return { + Any: function (a) { + a(t(true), false, "Primitive"); + a(t({ events: [] }), false, "Other object"); + a(t(x = ee()), false, "Emitter: empty"); + + x.on('test', y = function () {}); + a(t(x), true, "Emitter: full"); + x.off('test', y); + a(t(x), false, "Emitter: empty but touched"); + x.once('test', y = function () {}); + a(t(x), true, "Emitter: full: Once"); + x.off('test', y); + a(t(x), false, "Emitter: empty but touched by once"); + }, + Specific: function (a) { + a(t(true, 'test'), false, "Primitive"); + a(t({ events: [] }, 'test'), false, "Other object"); + a(t(x = ee(), 'test'), false, "Emitter: empty"); + + x.on('test', y = function () {}); + a(t(x, 'test'), true, "Emitter: full"); + a(t(x, 'foo'), false, "Emitter: full, other event"); + x.off('test', y); + a(t(x, 'test'), false, "Emitter: empty but touched"); + a(t(x, 'foo'), false, "Emitter: empty but touched, other event"); + + x.once('test', y = function () {}); + a(t(x, 'test'), true, "Emitter: full: Once"); + a(t(x, 'foo'), false, "Emitter: full: Once, other event"); + x.off('test', y); + a(t(x, 'test'), false, "Emitter: empty but touched by once"); + a(t(x, 'foo'), false, "Emitter: empty but touched by once, other event"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/index.js new file mode 100644 index 0000000..c7c3f24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/index.js @@ -0,0 +1,107 @@ +'use strict'; + +module.exports = function (t, a) { + var x = t(), y, count, count2, count3, count4, test, listener1, listener2; + + x.emit('none'); + + test = "Once: "; + count = 0; + x.once('foo', function (a1, a2, a3) { + a(this, x, test + "Context"); + a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments"); + ++count; + }); + + x.emit('foobar'); + a(count, 0, test + "Not invoked on other event"); + x.emit('foo', 'foo', x, 15); + a(count, 1, test + "Emitted"); + x.emit('foo'); + a(count, 1, test + "Emitted once"); + + test = "On & Once: "; + count = 0; + x.on('foo', listener1 = function (a1, a2, a3) { + a(this, x, test + "Context"); + a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments"); + ++count; + }); + count2 = 0; + x.once('foo', listener2 = function (a1, a2, a3) { + a(this, x, test + "Context"); + a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments"); + ++count2; + }); + + x.emit('foobar'); + a(count, 0, test + "Not invoked on other event"); + x.emit('foo', 'foo', x, 15); + a(count, 1, test + "Emitted"); + x.emit('foo', 'foo', x, 15); + a(count, 2, test + "Emitted twice"); + a(count2, 1, test + "Emitted once"); + x.off('foo', listener1); + x.emit('foo'); + a(count, 2, test + "Not emitter after off"); + + count = 0; + x.once('foo', listener1 = function () { ++count; }); + + x.off('foo', listener1); + x.emit('foo'); + a(count, 0, "Once Off: Not emitted"); + + count = 0; + x.on('foo', listener2 = function () {}); + x.once('foo', listener1 = function () { ++count; }); + + x.off('foo', listener1); + x.emit('foo'); + a(count, 0, "Once Off (multi): Not emitted"); + x.off('foo', listener2); + + test = "Prototype Share: "; + + y = Object.create(x); + + count = 0; + count2 = 0; + count3 = 0; + count4 = 0; + x.on('foo', function () { + ++count; + }); + y.on('foo', function () { + ++count2; + }); + x.once('foo', function () { + ++count3; + }); + y.once('foo', function () { + ++count4; + }); + x.emit('foo'); + a(count, 1, test + "x on count"); + a(count2, 0, test + "y on count"); + a(count3, 1, test + "x once count"); + a(count4, 0, test + "y once count"); + + y.emit('foo'); + a(count, 1, test + "x on count"); + a(count2, 1, test + "y on count"); + a(count3, 1, test + "x once count"); + a(count4, 1, test + "y once count"); + + x.emit('foo'); + a(count, 2, test + "x on count"); + a(count2, 1, test + "y on count"); + a(count3, 1, test + "x once count"); + a(count4, 1, test + "y once count"); + + y.emit('foo'); + a(count, 2, test + "x on count"); + a(count2, 2, test + "y on count"); + a(count3, 1, test + "x once count"); + a(count4, 1, test + "y once count"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/pipe.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/pipe.js new file mode 100644 index 0000000..9d15d6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/pipe.js @@ -0,0 +1,53 @@ +'use strict'; + +var ee = require('../'); + +module.exports = function (t, a) { + var x = {}, y = {}, z = {}, count, count2, count3, pipe; + + ee(x); + x = Object.create(x); + ee(y); + ee(z); + + count = 0; + count2 = 0; + count3 = 0; + x.on('foo', function () { + ++count; + }); + y.on('foo', function () { + ++count2; + }); + z.on('foo', function () { + ++count3; + }); + + x.emit('foo'); + a(count, 1, "Pre pipe, x"); + a(count2, 0, "Pre pipe, y"); + a(count3, 0, "Pre pipe, z"); + + pipe = t(x, y); + x.emit('foo'); + a(count, 2, "Post pipe, x"); + a(count2, 1, "Post pipe, y"); + a(count3, 0, "Post pipe, z"); + + y.emit('foo'); + a(count, 2, "Post pipe, on y, x"); + a(count2, 2, "Post pipe, on y, y"); + a(count3, 0, "Post pipe, on y, z"); + + t(x, z); + x.emit('foo'); + a(count, 3, "Post pipe z, x"); + a(count2, 3, "Post pipe z, y"); + a(count3, 1, "Post pipe z, z"); + + pipe.close(); + x.emit('foo'); + a(count, 4, "Close pipe y, x"); + a(count2, 3, "Close pipe y, y"); + a(count3, 2, "Close pipe y, z"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/unify.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/unify.js new file mode 100644 index 0000000..69295e0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/test/unify.js @@ -0,0 +1,123 @@ +'use strict'; + +var ee = require('../'); + +module.exports = function (t) { + + return { + "": function (a) { + var x = {}, y = {}, z = {}, count, count2, count3; + + ee(x); + ee(y); + ee(z); + + count = 0; + count2 = 0; + count3 = 0; + x.on('foo', function () { ++count; }); + y.on('foo', function () { ++count2; }); + z.on('foo', function () { ++count3; }); + + x.emit('foo'); + a(count, 1, "Pre unify, x"); + a(count2, 0, "Pre unify, y"); + a(count3, 0, "Pre unify, z"); + + t(x, y); + a(x.__ee__, y.__ee__, "Post unify y"); + x.emit('foo'); + a(count, 2, "Post unify, x"); + a(count2, 1, "Post unify, y"); + a(count3, 0, "Post unify, z"); + + y.emit('foo'); + a(count, 3, "Post unify, on y, x"); + a(count2, 2, "Post unify, on y, y"); + a(count3, 0, "Post unify, on y, z"); + + t(x, z); + a(x.__ee__, x.__ee__, "Post unify z"); + x.emit('foo'); + a(count, 4, "Post unify z, x"); + a(count2, 3, "Post unify z, y"); + a(count3, 1, "Post unify z, z"); + }, + "On empty": function (a) { + var x = {}, y = {}, z = {}, count, count2, count3; + + ee(x); + ee(y); + ee(z); + + count = 0; + count2 = 0; + count3 = 0; + y.on('foo', function () { ++count2; }); + x.emit('foo'); + a(count, 0, "Pre unify, x"); + a(count2, 0, "Pre unify, y"); + a(count3, 0, "Pre unify, z"); + + t(x, y); + a(x.__ee__, y.__ee__, "Post unify y"); + x.on('foo', function () { ++count; }); + x.emit('foo'); + a(count, 1, "Post unify, x"); + a(count2, 1, "Post unify, y"); + a(count3, 0, "Post unify, z"); + + y.emit('foo'); + a(count, 2, "Post unify, on y, x"); + a(count2, 2, "Post unify, on y, y"); + a(count3, 0, "Post unify, on y, z"); + + t(x, z); + a(x.__ee__, z.__ee__, "Post unify z"); + z.on('foo', function () { ++count3; }); + x.emit('foo'); + a(count, 3, "Post unify z, x"); + a(count2, 3, "Post unify z, y"); + a(count3, 1, "Post unify z, z"); + }, + Many: function (a) { + var x = {}, y = {}, z = {}, count, count2, count3; + + ee(x); + ee(y); + ee(z); + + count = 0; + count2 = 0; + count3 = 0; + x.on('foo', function () { ++count; }); + y.on('foo', function () { ++count2; }); + y.on('foo', function () { ++count2; }); + z.on('foo', function () { ++count3; }); + + x.emit('foo'); + a(count, 1, "Pre unify, x"); + a(count2, 0, "Pre unify, y"); + a(count3, 0, "Pre unify, z"); + + t(x, y); + a(x.__ee__, y.__ee__, "Post unify y"); + x.emit('foo'); + a(count, 2, "Post unify, x"); + a(count2, 2, "Post unify, y"); + a(count3, 0, "Post unify, z"); + + y.emit('foo'); + a(count, 3, "Post unify, on y, x"); + a(count2, 4, "Post unify, on y, y"); + a(count3, 0, "Post unify, on y, z"); + + t(x, z); + a(x.__ee__, x.__ee__, "Post unify z"); + x.emit('foo'); + a(count, 4, "Post unify z, x"); + a(count2, 6, "Post unify z, y"); + a(count3, 1, "Post unify z, z"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/unify.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/unify.js new file mode 100644 index 0000000..c6a858a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/node_modules/event-emitter/unify.js @@ -0,0 +1,50 @@ +'use strict'; + +var forEach = require('es5-ext/object/for-each') + , validValue = require('es5-ext/object/valid-object') + + , push = Array.prototype.apply, defineProperty = Object.defineProperty + , create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty + , d = { configurable: true, enumerable: false, writable: true }; + +module.exports = function (e1, e2) { + var data; + (validValue(e1) && validValue(e2)); + if (!hasOwnProperty.call(e1, '__ee__')) { + if (!hasOwnProperty.call(e2, '__ee__')) { + d.value = create(null); + defineProperty(e1, '__ee__', d); + defineProperty(e2, '__ee__', d); + d.value = null; + return; + } + d.value = e2.__ee__; + defineProperty(e1, '__ee__', d); + d.value = null; + return; + } + data = d.value = e1.__ee__; + if (!hasOwnProperty.call(e2, '__ee__')) { + defineProperty(e2, '__ee__', d); + d.value = null; + return; + } + if (data === e2.__ee__) return; + forEach(e2.__ee__, function (listener, name) { + if (!data[name]) { + data[name] = listener; + return; + } + if (typeof data[name] === 'object') { + if (typeof listener === 'object') push.apply(data[name], listener); + else data[name].push(listener); + } else if (typeof listener === 'object') { + listener.unshift(data[name]); + data[name] = listener; + } else { + data[name] = [data[name], listener]; + } + }); + defineProperty(e2, '__ee__', d); + d.value = null; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/package.json new file mode 100644 index 0000000..51b50e2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/package.json @@ -0,0 +1,70 @@ +{ + "name": "es6-map", + "version": "0.1.1", + "description": "ECMAScript6 Map polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "collection", + "es6", + "shim", + "harmony", + "list", + "hash", + "map", + "polyfill", + "ecmascript" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-map.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.4", + "es6-iterator": "~0.1.1", + "es6-set": "~0.1.1", + "es6-symbol": "~0.1.1", + "event-emitter": "~0.3.1" + }, + "devDependencies": { + "tad": "0.2.x", + "xlint": "~0.2.1", + "xlint-jslint-medikoo": "~0.1.2" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "16b0bce8defe9742a40b9cac1eed194ee4e2d820", + "bugs": { + "url": "https://github.com/medikoo/es6-map/issues" + }, + "homepage": "https://github.com/medikoo/es6-map", + "_id": "es6-map@0.1.1", + "_shasum": "b879239ed7819e0b08c40ba6e19fa047ca7c8d1d", + "_from": "es6-map@>=0.1.1 <0.2.0", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "dist": { + "shasum": "b879239ed7819e0b08c40ba6e19fa047ca7c8d1d", + "tarball": "http://registry.npmjs.org/es6-map/-/es6-map-0.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/polyfill.js new file mode 100644 index 0000000..fc44527 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/polyfill.js @@ -0,0 +1,100 @@ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , eIndexOf = require('es5-ext/array/#/e-index-of') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , callable = require('es5-ext/object/valid-callable') + , validValue = require('es5-ext/object/valid-value') + , d = require('d') + , ee = require('event-emitter') + , Symbol = require('es6-symbol') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Iterator = require('./lib/iterator') + , isNative = require('./is-native-implemented') + + , call = Function.prototype.call, defineProperties = Object.defineProperties + , MapPoly; + +module.exports = MapPoly = function (/*iterable*/) { + var iterable = arguments[0], keys, values; + if (!(this instanceof MapPoly)) return new MapPoly(iterable); + if (this.__mapKeysData__ !== undefined) { + throw new TypeError(this + " cannot be reinitialized"); + } + if (iterable != null) iterator(iterable); + defineProperties(this, { + __mapKeysData__: d('c', keys = []), + __mapValuesData__: d('c', values = []) + }); + if (!iterable) return; + forOf(iterable, function (value) { + var key = validValue(value)[0]; + value = value[1]; + if (eIndexOf.call(keys, key) !== -1) return; + keys.push(key); + values.push(value); + }, this); +}; + +if (isNative) { + if (setPrototypeOf) setPrototypeOf(MapPoly, Map); + MapPoly.prototype = Object.create(Map.prototype, { + constructor: d(MapPoly) + }); +} + +ee(defineProperties(MapPoly.prototype, { + clear: d(function () { + if (!this.__mapKeysData__.length) return; + clear.call(this.__mapKeysData__); + clear.call(this.__mapValuesData__); + this.emit('_clear'); + }), + delete: d(function (key) { + var index = eIndexOf.call(this.__mapKeysData__, key); + if (index === -1) return false; + this.__mapKeysData__.splice(index, 1); + this.__mapValuesData__.splice(index, 1); + this.emit('_delete', index, key); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + forEach: d(function (cb/*, thisArg*/) { + var thisArg = arguments[1], iterator, result; + callable(cb); + iterator = this.entries(); + result = iterator._next(); + while (result !== undefined) { + call.call(cb, thisArg, this.__mapValuesData__[result], + this.__mapKeysData__[result], this); + result = iterator._next(); + } + }), + get: d(function (key) { + var index = eIndexOf.call(this.__mapKeysData__, key); + if (index === -1) return; + return this.__mapValuesData__[index]; + }), + has: d(function (key) { + return (eIndexOf.call(this.__mapKeysData__, key) !== -1); + }), + keys: d(function () { return new Iterator(this, 'key'); }), + set: d(function (key, value) { + var index = eIndexOf.call(this.__mapKeysData__, key), emit; + if (index === -1) { + index = this.__mapKeysData__.push(key) - 1; + emit = true; + } + this.__mapValuesData__[index] = value; + if (emit) this.emit('_add', index, key); + return this; + }), + size: d.gs(function () { return this.__mapKeysData__.length; }), + values: d(function () { return new Iterator(this, 'value'); }), + toString: d(function () { return '[object Map]'; }) +})); +Object.defineProperty(MapPoly.prototype, Symbol.iterator, d(function () { + return this.entries(); +})); +Object.defineProperty(MapPoly.prototype, Symbol.toStringTag, d('c', 'Map')); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/primitive/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/primitive/index.js new file mode 100644 index 0000000..425d482 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/primitive/index.js @@ -0,0 +1,115 @@ +'use strict'; + +var clear = require('es5-ext/object/clear') + , setPrototypeOf = require('es5-ext/object/set-prototype-of') + , validValue = require('es5-ext/object/valid-value') + , callable = require('es5-ext/object/valid-callable') + , d = require('d') + , iterator = require('es6-iterator/valid-iterable') + , forOf = require('es6-iterator/for-of') + , Map = require('../polyfill') + , Iterator = require('../lib/primitive-iterator') + + , call = Function.prototype.call + , defineProperty = Object.defineProperty + , create = Object.create, defineProperties = Object.defineProperties + , hasOwnProperty = Object.prototype.hasOwnProperty + , PrimitiveMap; + +module.exports = PrimitiveMap = function (/*iterable, serialize*/) { + var iterable = arguments[0], serialize = arguments[1]; + if (!(this instanceof PrimitiveMap)) { + return new PrimitiveMap(iterable, serialize); + } + if (this.__mapData__ !== undefined) { + throw new TypeError(this + " cannot be reinitialized"); + } + if (iterable != null) iterator(iterable); + if (serialize !== undefined) { + callable(serialize); + defineProperty(this, '_serialize', d('', serialize)); + } + defineProperties(this, { + __mapKeysData__: d('c', create(null)), + __mapValuesData__: d('c', create(null)), + __size__: d('w', 0) + }); + if (!iterable) return; + forOf(iterable, function (value) { + var key = validValue(value)[0], sKey = this._serialize(key); + if (sKey == null) throw new TypeError(key + " cannot be serialized"); + value = value[1]; + if (hasOwnProperty.call(this.__mapKeysData__, sKey)) { + if (this.__mapValuesData__[sKey] === value) return; + } else { + ++this.__size__; + } + this.__mapKeysData__[sKey] = key; + this.__mapValuesData__[sKey] = value; + }, this); +}; +if (setPrototypeOf) setPrototypeOf(PrimitiveMap, Map); + +PrimitiveMap.prototype = create(Map.prototype, { + constructor: d(PrimitiveMap), + _serialize: d(function (value) { + if (value && (typeof value.toString !== 'function')) return null; + return String(value); + }), + clear: d(function () { + if (!this.__size__) return; + clear(this.__mapKeysData__); + clear(this.__mapValuesData__); + this.__size__ = 0; + this.emit('_clear'); + }), + delete: d(function (key) { + var sKey = this._serialize(key); + if (sKey == null) return false; + if (!hasOwnProperty.call(this.__mapKeysData__, sKey)) return false; + delete this.__mapKeysData__[sKey]; + delete this.__mapValuesData__[sKey]; + --this.__size__; + this.emit('_delete', sKey); + return true; + }), + entries: d(function () { return new Iterator(this, 'key+value'); }), + forEach: d(function (cb/*, thisArg*/) { + var thisArg = arguments[1], iterator, result, sKey; + callable(cb); + iterator = this.entries(); + result = iterator._next(); + while (result !== undefined) { + sKey = iterator.__list__[result]; + call.call(cb, thisArg, this.__mapValuesData__[sKey], + this.__mapKeysData__[sKey], this); + result = iterator._next(); + } + }), + get: d(function (key) { + var sKey = this._serialize(key); + if (sKey == null) return; + return this.__mapValuesData__[sKey]; + }), + has: d(function (key) { + var sKey = this._serialize(key); + if (sKey == null) return false; + return hasOwnProperty.call(this.__mapKeysData__, sKey); + }), + keys: d(function () { return new Iterator(this, 'key'); }), + size: d.gs(function () { return this.__size__; }), + set: d(function (key, value) { + var sKey = this._serialize(key); + if (sKey == null) throw new TypeError(key + " cannot be serialized"); + if (hasOwnProperty.call(this.__mapKeysData__, sKey)) { + if (this.__mapValuesData__[sKey] === value) return this; + } else { + ++this.__size__; + } + this.__mapKeysData__[sKey] = key; + this.__mapValuesData__[sKey] = value; + this.emit('_add', sKey); + return this; + }), + values: d(function () { return new Iterator(this, 'value'); }) +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/implement.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/implement.js new file mode 100644 index 0000000..3569df6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Map, 'function'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/index.js new file mode 100644 index 0000000..907b8c5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (T, a) { + a((new T([['raz', 1], ['dwa', 2]])).size, 2); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-implemented.js new file mode 100644 index 0000000..06df91c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Map; + global.Map = polyfill; + a(t(), true); + if (cache === undefined) delete global.Map; + else global.Map = cache; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-map.js new file mode 100644 index 0000000..f600b22 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-map.js @@ -0,0 +1,16 @@ +'use strict'; + +var MapPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Map !== 'undefined') { + a(t(new Map()), true, "Native"); + } + a(t(new MapPoly()), true, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-native-implemented.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-native-implemented.js new file mode 100644 index 0000000..df8ba03 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator-kinds.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator-kinds.js new file mode 100644 index 0000000..41ea10c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator-kinds.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (t, a) { + a.deep(t, { key: true, value: true, 'key+value': true }); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator.js new file mode 100644 index 0000000..2688ed2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/iterator.js @@ -0,0 +1,13 @@ +'use strict'; + +var Map = require('../../polyfill') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = [['raz', 'one'], ['dwa', 'two']], map = new Map(arr); + + a.deep(toArray(new T(map)), arr, "Default"); + a.deep(toArray(new T(map, 'key+value')), arr, "Key & Value"); + a.deep(toArray(new T(map, 'value')), ['one', 'two'], "Value"); + a.deep(toArray(new T(map, 'key')), ['raz', 'dwa'], "Value"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/primitive-iterator.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/primitive-iterator.js new file mode 100644 index 0000000..ed2790d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/lib/primitive-iterator.js @@ -0,0 +1,130 @@ +'use strict'; + +var iteratorSymbol = require('es6-symbol').iterator + , toArray = require('es5-ext/array/to-array') + , Map = require('../../primitive') + + , compare, mapToResults; + +compare = function (a, b) { + if (!a.value) return -1; + if (!b.value) return 1; + return a.value[0].localeCompare(b.value[0]); +}; + +mapToResults = function (arr) { + return arr.sort().map(function (value) { + return { done: false, value: value }; + }); +}; + +module.exports = function (T) { + return { + "": function (a) { + var arr, it, y, z, map, result = []; + + arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three'], + ['cztery', 'four'], ['pięć', 'five']]; + map = new Map(arr); + + it = new T(map); + a(it[iteratorSymbol](), it, "@@iterator"); + y = it.next(); + result.push(y); + z = it.next(); + a.not(y, z, "Recreate result"); + result.push(z); + result.push(it.next()); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), mapToResults(arr)); + a.deep(y = it.next(), { done: true, value: undefined }, "End"); + a.not(y, it.next(), "Recreate result on dead"); + }, + Emited: function (a) { + var arr, it, map, result = []; + + arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three'], + ['cztery', 'four'], ['pięć', 'five']]; + map = new Map(arr); + + it = new T(map); + result.push(it.next()); + result.push(it.next()); + map.set('sześć', 'six'); + arr.push(['sześć', 'six']); + result.push(it.next()); + map.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), mapToResults(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited #2": function (a) { + var arr, it, map, result = []; + + arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three'], + ['cztery', 'four'], ['pięć', 'five'], ['sześć', 'six']]; + map = new Map(arr); + + it = new T(map); + result.push(it.next()); + result.push(it.next()); + map.set('siedem', 'seven'); + map.delete('siedem'); + result.push(it.next()); + result.push(it.next()); + map.delete('pięć'); + arr.splice(4, 1); + result.push(it.next()); + a.deep(result.sort(compare), mapToResults(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #1": function (a) { + var arr, it, map, result = []; + + arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three'], + ['cztery', 'four'], ['pięć', 'five'], ['sześć', 'six']]; + map = new Map(arr); + + it = new T(map); + result.push(it.next()); + result.push(it.next()); + arr = [['raz', 'one'], ['dwa', 'two']]; + map.clear(); + a.deep(result.sort(compare), mapToResults(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + "Emited: Clear #2": function (a) { + var arr, it, map, result = []; + + arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three'], + ['cztery', 'four'], ['pięć', 'five'], ['sześć', 'six']]; + map = new Map(arr); + + it = new T(map); + result.push(it.next()); + result.push(it.next()); + map.clear(); + map.set('foo', 'bru'); + map.set('bar', 'far'); + arr = [['raz', 'one'], ['dwa', 'two'], ['foo', 'bru'], ['bar', 'far']]; + result.push(it.next()); + result.push(it.next()); + a.deep(result.sort(compare), mapToResults(arr)); + a.deep(it.next(), { done: true, value: undefined }, "End"); + }, + Kinds: function (a) { + var arr = [['raz', 'one'], ['dwa', 'two']], map = new Map(arr); + + a.deep(toArray(new T(map)).sort(), arr.sort(), "Default"); + a.deep(toArray(new T(map, 'key+value')).sort(), arr.sort(), + "Key + Value"); + a.deep(toArray(new T(map, 'value')).sort(), ['one', 'two'].sort(), + "Value"); + a.deep(toArray(new T(map, 'key')).sort(), ['raz', 'dwa'].sort(), + "Key"); + } + }; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/polyfill.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/polyfill.js new file mode 100644 index 0000000..6640e35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/polyfill.js @@ -0,0 +1,54 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']] + , map = new T(arr), x = {}, y = {}, i = 0; + + a(map instanceof T, true, "Map"); + a(map.size, 3, "Size"); + a(map.get('raz'), 'one', "Get: contained"); + a(map.get(x), undefined, "Get: not contained"); + a(map.has('raz'), true, "Has: contained"); + a(map.has(x), false, "Has: not contained"); + a(map.set(x, y), map, "Set: return"); + a(map.has(x), true, "Set: has"); + a(map.get(x), y, "Set: get"); + a(map.size, 4, "Set: Size"); + map.set('dwa', x); + a(map.get('dwa'), x, "Overwrite: get"); + a(map.size, 4, "Overwrite: size"); + + a(map.delete({}), false, "Delete: false"); + + arr.push([x, y]); + arr[1][1] = x; + map.forEach(function () { + a.deep(aFrom(arguments), [arr[i][1], arr[i][0], map], + "ForEach: Arguments: #" + i); + a(this, y, "ForEach: Context: #" + i); + if (i === 0) { + a(map.delete('raz'), true, "Delete: true"); + a(map.has('raz'), false, "Delete"); + a(map.size, 3, "Delete: size"); + map.set('cztery', 'four'); + arr.push(['cztery', 'four']); + } + i++; + }, y); + arr.splice(0, 1); + + a.deep(toArray(map.entries()), [['dwa', x], ['trzy', 'three'], [x, y], + ['cztery', 'four']], "Entries"); + a.deep(toArray(map.keys()), ['dwa', 'trzy', x, 'cztery'], "Keys"); + a.deep(toArray(map.values()), [x, 'three', y, 'four'], "Values"); + a.deep(toArray(map), [['dwa', x], ['trzy', 'three'], [x, y], + ['cztery', 'four']], "Iterator"); + + map.clear(); + a(map.size, 0, "Clear: size"); + a(map.has('trzy'), false, "Clear: has"); + a.deep(toArray(map), [], "Clear: Values"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/primitive/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/primitive/index.js new file mode 100644 index 0000000..1167d2e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/primitive/index.js @@ -0,0 +1,53 @@ +'use strict'; + +var aFrom = require('es5-ext/array/from') + , getIterator = require('es6-iterator/get') + , toArray = require('es5-ext/array/to-array'); + +module.exports = function (T, a) { + var arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']] + , map = new T(arr), x = 'other', y = 'other2' + , i = 0, result = []; + + a(map instanceof T, true, "Map"); + a(map.size, 3, "Size"); + a(map.get('raz'), 'one', "Get: contained"); + a(map.get(x), undefined, "Get: not contained"); + a(map.has('raz'), true, "Has: true"); + a(map.has(x), false, "Has: false"); + a(map.set(x, y), map, "Add: return"); + a(map.has(x), true, "Add"); + a(map.size, 4, "Add: Size"); + map.set('dwa', x); + a(map.get('dwa'), x, "Overwrite: get"); + a(map.size, 4, "Overwrite: size"); + + a(map.delete('else'), false, "Delete: false"); + + arr.push([x, y]); + arr[1][1] = x; + map.forEach(function () { + result.push(aFrom(arguments)); + a(this, y, "ForEach: Context: #" + i); + }, y); + + a.deep(result.sort(function (a, b) { + return String([a[1], a[0]]).localeCompare([b[1], b[0]]); + }), arr.sort().map(function (val) { return [val[1], val[0], map]; }), + "ForEach: Arguments"); + + a.deep(toArray(map.entries()).sort(), [['dwa', x], ['trzy', 'three'], + [x, y], ['raz', 'one']].sort(), "Entries"); + a.deep(toArray(map.keys()).sort(), ['dwa', 'trzy', x, 'raz'].sort(), + "Keys"); + a.deep(toArray(map.values()).sort(), [x, 'three', y, 'one'].sort(), + "Values"); + a.deep(toArray(getIterator(map)).sort(), [['dwa', x], ['trzy', 'three'], + [x, y], ['raz', 'one']].sort(), + "Iterator"); + + map.clear(); + a(map.size, 0, "Clear: size"); + a(map.has('trzy'), false, "Clear: has"); + a.deep(toArray(map.values()), [], "Clear: Values"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/valid-map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/valid-map.js new file mode 100644 index 0000000..ac03149 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/test/valid-map.js @@ -0,0 +1,19 @@ +'use strict'; + +var MapPoly = require('../polyfill'); + +module.exports = function (t, a) { + var map; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Map !== 'undefined') { + map = new Map(); + a(t(map), map, "Native"); + } + map = new MapPoly(); + a(t(map), map, "Polyfill"); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/valid-map.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/valid-map.js new file mode 100644 index 0000000..e2aca87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/es6-map/valid-map.js @@ -0,0 +1,8 @@ +'use strict'; + +var isMap = require('./is-map'); + +module.exports = function (x) { + if (!isMap(x)) throw new TypeError(x + " is not a Map"); + return x; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/index.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/index.js new file mode 100644 index 0000000..4885db7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/index.js @@ -0,0 +1,37 @@ +'use strict'; + +function ToObject(val) { + if (val == null) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +module.exports = Object.assign || function (target, source) { + var pendingException; + var from; + var keys; + var to = ToObject(target); + + for (var s = 1; s < arguments.length; s++) { + from = arguments[s]; + keys = Object.keys(Object(from)); + + for (var i = 0; i < keys.length; i++) { + try { + to[keys[i]] = from[keys[i]]; + } catch (err) { + if (pendingException === undefined) { + pendingException = err; + } + } + } + } + + if (pendingException) { + throw pendingException; + } + + return to; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/package.json new file mode 100644 index 0000000..fb3ecfc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/package.json @@ -0,0 +1,67 @@ +{ + "name": "object-assign", + "version": "1.0.0", + "description": "ES6 Object.assign() ponyfill", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/sindresorhus/object-assign" + }, + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "index.js" + ], + "keywords": [ + "object", + "assign", + "extend", + "properties", + "es6", + "ecmascript", + "harmony", + "ponyfill", + "prollyfill", + "polyfill", + "shim", + "browser" + ], + "devDependencies": { + "mocha": "*" + }, + "gitHead": "a17eef6882cf3ffcee46f7d9d5a5ba0abc6b029c", + "bugs": { + "url": "https://github.com/sindresorhus/object-assign/issues" + }, + "homepage": "https://github.com/sindresorhus/object-assign", + "_id": "object-assign@1.0.0", + "_shasum": "e65dc8766d3b47b4b8307465c8311da030b070a6", + "_from": "object-assign@>=1.0.0 <1.1.0", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "dist": { + "shasum": "e65dc8766d3b47b4b8307465c8311da030b070a6", + "tarball": "http://registry.npmjs.org/object-assign/-/object-assign-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-1.0.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/readme.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/readme.md new file mode 100644 index 0000000..24cdf76 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/node_modules/object-assign/readme.md @@ -0,0 +1,47 @@ +# object-assign [](https://travis-ci.org/sindresorhus/object-assign) + +> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +```sh +$ npm install --save object-assign +``` + + +## Usage + +```js +var objectAssign = require('object-assign'); + +objectAssign({foo: 0}, {bar: 1}); +//=> {foo: 0, bar: 1} + +// multiple sources +objectAssign({foo: 0}, {bar: 1}, {baz: 3}); +//=> {foo: 0, bar: 1, baz: 2} + +// ignores null and undefined sources +objectAssign({foo: 0}, null, {bar: 1}, undefined); +//=> {foo: 0, bar: 1, baz: 2} +``` + + +## API + +### objectAssign(target, source, [source, ...]) + +Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. + + +## Resources + +- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/package.json b/JavaScript/node_modules/johnny-five/node_modules/firmata/package.json new file mode 100644 index 0000000..32ac417 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/package.json @@ -0,0 +1,71 @@ +{ + "name": "firmata", + "description": "A library to control an arduino running firmata", + "version": "0.5.5", + "author": { + "name": "Julian Gautier" + }, + "homepage": "http://www.github.com/jgautier/firmata", + "repository": { + "type": "git", + "url": "git://github.com/jgautier/firmata.git" + }, + "main": "lib/firmata", + "bin": { + "firmata": "./repl.js" + }, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.4.3", + "grunt-jsbeautifier": "~0.2.7", + "grunt-jscs": "~0.8.1", + "grunt-mocha-test": "~0.2.2", + "johnny-five": "^0.8.62", + "mocha": ">=0.13.x", + "rewire": "~2.1.2", + "should": ">=0.5.x", + "sinon": "~1.11.1" + }, + "dependencies": { + "browser-serialport": "*", + "es6-map": "~0.1.1", + "object-assign": "~1.0.0", + "serialport": ">=0.7.5" + }, + "optionalDependencies": {}, + "scripts": { + "test": "grunt" + }, + "engines": { + "node": "*" + }, + "gitHead": "3e093e43c9d9847281854e7ffc4313764a3b9486", + "bugs": { + "url": "https://github.com/jgautier/firmata/issues" + }, + "_id": "firmata@0.5.5", + "_shasum": "974c461fe3540d109e25355a0a5c449fe528988a", + "_from": "firmata@>=0.2.9", + "_npmVersion": "2.7.5", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "rwaldron", + "email": "waldron.rick@gmail.com" + }, + "maintainers": [ + { + "name": "jgautier", + "email": "julian.gautier@alumni.neumont.edu" + }, + { + "name": "rwaldron", + "email": "waldron.rick@gmail.com" + } + ], + "dist": { + "shasum": "974c461fe3540d109e25355a0a5c449fe528988a", + "tarball": "http://registry.npmjs.org/firmata/-/firmata-0.5.5.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/firmata/-/firmata-0.5.5.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/readme.md b/JavaScript/node_modules/johnny-five/node_modules/firmata/readme.md new file mode 100644 index 0000000..959612e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/readme.md @@ -0,0 +1,219 @@ +[](http://travis-ci.org/jgautier/firmata) +#Firmata +A Node library to interact with an Arduino running the firmata protocol. +#Install + npm install -g firmata +#Tests +The tests are written with expresso and assume you have the async library install globally. It also assumes you have an Arduino Uno running firmata 2.2 with a photocell and an LED hooked up. +#Usage + + var firmata = require('firmata'); + var board = new firmata.Board('path to usb',function(){ + //arduino is ready to communicate + }); +#REPL +If you run *firmata* from the command line it will prompt you for the usb port. Then it will present you with a REPL with a board variable available. +# Board + The Board object is where all the functionality is for the library. + +## Board Instance API + + *MODES* + +```js +{ + INPUT: 0x00, + OUTPUT: 0x01, + ANALOG: 0x02, + PWM: 0x03, + SERVO: 0x04 +} +``` + +This is an enumeration of the different modes available. These are used in calls to the *pinMode* function. + +*HIGH* and *LOW* + +These are constants used to set a digital pin low or high. Used in calls to the *digitalWrite* function. + +*pins* + +This is an array of all the pins on the arduino board. + +Each value in the array is an object: + +```js +{ + mode: Number, // Current mode of pin which is on the the board.MODES. + value: Number, // Current value of the pin. when pin is digital and set to output it will be Board.HIGH or Board.LOW. If the pin is an analog pin it will be an numeric value between 0 and 1023. + supportedModes: [ ...Number ], // Array of modes from board.MODES that are supported on this pin. + analogChannel: Number, // Will be 127 for digital pins and the pin number for analog pins. + state: Number // For output pins this is the value of the pin on the board, for digital input it's the status of the pullup resistor (1 = pullup enabled, 0 = pullup disabled) +} +``` + + This array holds all pins digital and analog. To get the analog pin number as seen on the arduino board use the analogChannel attribute. + + *analogPins* + + This is an array of all the array indexes of the analog pins in the *Board.pins* array. + For example to get the analog pin 5 from the *Board.pins* attributes use: + +`pins[board.analogPins[5]];` + + +## Board Prototype API + +### Pin + +`pinMode(pin,mode)` + + Set a mode for a pin. pin is the number of the pin and the mode is on of the Board.MODES values. + +`digitalWrite(pin,value)` + + Write an output to a digital pin. pin is the number of the pin and the value is either board.HGH or board.LOW. + +`digitalRead(pin,callback)` + + Read a digital value from the pin. Evertime there is data for the pin the callback will be fired with a value argument. + +`analogWrite(pin,value)` + + Write an output to an analog pin. pin is the number of the pin and the value is between 0 and 255. + +`analogRead(pin,callback)` + + Read an input for an analog pin. Every time there is data on the pin the callback will be fired with a value argument. + +### Servo + +`servoWrite(pin, degree)` + + Write a degree value to a servo pin. + +`servoConfig(pin, min, max)` + + Setup a servo with a specific min and max pulse (call instead of `pinMode`, which will provide default). + +### I2C + +`i2cConfig()` + + Configure and enable I2C, provide no options or delay. Required to enable I2C communication. + +`i2cConfig(delay)` + + Configure and enable I2C, optionally provide a value in μs to delay between reads (defaults to `0`). Required to enable I2C communication. + +`i2cConfig(options)` + + Configure and enable I2C, optionally provide an object that contains a `delay` property whose value is a number in μs to delay between reads. Required to enable I2C communication. + + +`i2cWrite(address, [...bytes])` + + Write an arbitrary number of bytes. May not exceed 64 Bytes. + +`i2cWrite(address, register, [...bytes])` + + Write an arbitrary number of bytes to the specified register. May not exceed 64 Bytes. + +`i2cWriteReg(address, register, byte)` + + Write a byte value to a specific register. + +`i2cRead(address, numberOfBytesToRead, handler(data))` + + Read a specified number of bytes, continuously. `handler` receives an array of values, with a length corresponding to the number of read bytes. + +`i2cRead(address, register, numberOfBytesToRead, handler(data))` + + Read a specified number of bytes from a register, continuously. `handler` receives an array of values, with a length corresponding to the number of read bytes. + +`i2cReadOnce(address, numberOfBytesToRead, handler(data))` + + Read a specified number of bytes, one time. `handler` receives an array of values, with a length corresponding to the number of read bytes. + +`i2cReadOnce(address, register, numberOfBytesToRead, handler(data))` + + Read a specified number of bytes from a register, one time. `handler` receives an array of values, with a length corresponding to the number of read bytes. + + +`sendI2CConfig(delay)` **Deprecated** + + Set I2C Config on the arduino + +`sendI2CWriteRequest(slaveAddress,[bytes])` **Deprecated** + + Write an array of bytes to a an I2C device. + +`sendI2CReadRequest(slaveAddress,numBytes,function(data))` **Deprecated** + + Requests a number of bytes from a slave I2C device. When the bytes are received from the I2C device the callback is called with the byte array. + +### Debug + +`sendString("a string")` + + Send an arbitrary string. + +### One-Wire + +`sendOneWireConfig(pin, enableParasiticPower)` + + Configure the pin as the controller in a 1-wire bus. Set `enableParasiticPower` to `true` if you want the data pin to power the bus. + +`sendOneWireSearch(pin, callback)` + + Searches for 1-wire devices on the bus. The callback should accept an error argument and an array of device identifiers. + +`sendOneWireAlarmsSearch(pin, callback)` + + Searches for 1-wire devices on the bus in an alarmed state. The callback should accept and error argument and an array of device identifiers. + +`sendOneWireRead(pin, device, numBytesToRead, callback)` + + Reads data from a device on the bus and invokes the callback. + +`sendOneWireReset()` + + Resets all devices on the bus. + +`sendOneWireWrite(pin, device, data)` + + Writes data to the bus to be received by the device. The device should be obtained from a previous call to `sendOneWireSearch`. + +`sendOneWireDelay(pin, delay)` + + Tells Firmata to not do anything for the amount of ms. Use when you need to give a device attached to the bus time to do a calculation. + +`sendOneWireWriteAndRead(pin, device, data, numBytesToRead, callback)` + + Sends the `data` to the `device` on the bus, reads the specified number of bytes and invokes the `callback`. + + +## License + +(The MIT License) + +Copyright (c) 2011-2015 Julian Gautier + +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/node_modules/johnny-five/node_modules/firmata/repl.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/repl.js new file mode 100755 index 0000000..48d6cd6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/repl.js @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +var firmata = require('./lib/firmata.js'), + repl = require('repl'); +console.log('Enter USB Port and press enter:'); +process.stdin.resume(); +process.stdin.setEncoding('utf8'); +process.stdin.once('data', function(chunk) { + var port = chunk.replace('\n', ''); + var board = new firmata.Board(port, function() { + console.log('Successfully Connected to ' + port); + repl.start('firmata>').context.board = board; + }); +}); \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/test/MockSerialPort.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/MockSerialPort.js new file mode 100644 index 0000000..a4db8a8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/MockSerialPort.js @@ -0,0 +1,25 @@ +var util = require("util"), events = require("events"); + +var MockSerialPort = function (path) { + this.isClosed = false; +}; + +util.inherits(MockSerialPort, events.EventEmitter); + +MockSerialPort.prototype.write = function (buffer) { + // Tests are written to work with arrays not buffers + // this shouldn"t impact the data, just the container + // This also should be changed in future test rewrites + if (Buffer.isBuffer(buffer)) { + buffer = Array.prototype.slice.call(buffer, 0); + } + + this.lastWrite = buffer; + this.emit("write", buffer); +}; + +MockSerialPort.prototype.close = function () { + this.isClosed = true; +}; + +module.exports.SerialPort = MockSerialPort; diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/test/encoder7bit.test.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/encoder7bit.test.js new file mode 100644 index 0000000..99674a8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/encoder7bit.test.js @@ -0,0 +1,14 @@ +var should = require("should"), + Encoder7Bit = require("../lib/encoder7bit"); + +describe("board", function () { + it("should encode and decode via in-memory array", function (done) { + var input = [40, 219, 239, 33, 5, 0, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0]; + var encoded = Encoder7Bit.to7BitArray(input); + var decoded = Encoder7Bit.from7BitArray(encoded); + + decoded.should.eql(input); + + done(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test-backup.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test-backup.js new file mode 100644 index 0000000..80189db --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test-backup.js @@ -0,0 +1,1139 @@ +// var rewire = require("rewire"); +// var firmata = process.env.FIRMATA_COV ? +// rewire("../lib-cov/firmata") : +// rewire("../lib/firmata"); +// var SerialPort = require("./MockSerialPort").SerialPort; +// var Encoder7Bit = require("../lib/encoder7bit"); +// var should = require("should"); +// var sinon = require("sinon"); + +// var Board = firmata.Board; +// var spy; + + + +// describe("board", function() { + +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var boardStarted = false; +// var board = new Board(serialPort, function(err) { +// boardStarted = true; +// (typeof err).should.equal("undefined"); +// }); + + +// beforeEach(function() { +// spy = sinon.spy(SerialPort); + +// board._events.length = 0; + +// firmata.__set__("SerialPort", spy); +// }); + +// it("uses serialport defaults", function(done) { +// var a = new Board("/path/to/fake/usb1", function(err) {}); +// var b = new Board("/path/to/fake/usb2", function(err) {}); + +// should.equal(spy.getCall(0).args[0], "/path/to/fake/usb1"); +// should.deepEqual(spy.getCall(0).args[1], { baudRate: 57600, bufferSize: 1 }); + +// should.equal(spy.getCall(1).args[0], "/path/to/fake/usb2"); +// should.deepEqual(spy.getCall(1).args[1], { baudRate: 57600, bufferSize: 1 }); + +// done(); +// }); + + +// it("has a name", function(done) { +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var board = new Board(serialPort, function(err) {}); + +// board.name.should.equal("Firmata"); +// done(); +// }); + +// it("emits 'connect' when the transport is opened.", function(done) { +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var board = new Board(serialPort, function(err) {}); + +// board.on("connect", function() { +// done(); +// }); + +// serialPort.emit("open"); +// }); + +// it("emits 'ready' after handshakes complete (skipCapabilities)", function(done) { +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var board = new Board(serialPort, {skipCapabilities: true}, function(err) {}); +// var connected = false; + +// board.on("connect", function() { +// connected = true; +// }); + +// board.on("ready", function() { +// should.equal(connected, true); +// should.equal(this.isReady, true); +// done(); +// }); + +// serialPort.emit("open"); +// board.emit("reportversion"); +// board.emit("queryfirmware"); +// }); + +// it("emits 'ready' after handshakes complete", function(done) { +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var board = new Board(serialPort, function(err) {}); +// var connected = false; + +// board.on("connect", function() { +// connected = true; +// }); + +// board.on("ready", function() { +// should.equal(connected, true); +// should.equal(this.isReady, true); +// done(); +// }); + +// serialPort.emit("open"); +// board.emit("reportversion"); +// board.emit("queryfirmware"); +// board.emit("capability-query"); +// board.emit("analog-mapping-query"); +// }); + +// it("reports errors", function(done) { +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var board = new Board(serialPort, function(err) { +// "test error".should.equal(err); +// done(); +// }); + +// serialPort.emit("error", "test error"); +// }); + +// it("sends report version and query firmware if it hasnt received the version within the timeout", function(done) { +// this.timeout(50000); +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var opt = { +// reportVersionTimeout: 1 +// }; +// var board = new Board(serialPort, opt, function(err) {}); + +// // rcheck for report version +// serialPort.once("write", function(data) { +// should.deepEqual(data, [0xF9]); +// // check for query firmware +// serialPort.once("write", function(data) { +// should.deepEqual(data, [240, 121, 247]); +// done(); +// }); +// }); +// }); + +// it("uses default baud rate and buffer size", function (done) { +// var port = "fake port"; +// var board = new Board(port, function (err) {}); + +// should.deepEqual( +// spy.args, [ [ "fake port", { baudRate: 57600, bufferSize: 1 } ] ] +// ); + +// done(); +// }); + +// it("overrides baud rate and buffer size", function (done) { +// var port = "fake port"; +// var opt = { +// reportVersionTimeout: 1, +// serialport: { +// baudRate: 5, +// bufferSize: 10 +// } +// }; +// var board = new Board(port, opt, function (err) {}); + +// should.deepEqual( +// spy.args, [ [ "fake port", { baudRate: 5, bufferSize: 10 } ] ] +// ); + +// done(); +// }); + +// it("receives the version on startup", function(done) { +// //"send" report version command back from arduino +// serialPort.emit("data", [0xF9]); +// serialPort.emit("data", [0x02]); + +// //subscribe to the "data" event to capture the event +// serialPort.once("data", function(buffer) { +// board.version.major.should.equal(2); +// board.version.minor.should.equal(3); +// done(); +// }); + +// //send the last byte of command to get "data" event to fire when the report version function is called +// serialPort.emit("data", [0x03]); +// }); + +// it("receives the firmware after the version", function(done) { +// board.once("queryfirmware", function() { +// board.firmware.version.major.should.equal(2); +// board.firmware.version.minor.should.equal(3); +// board.firmware.name.should.equal("StandardFirmata"); +// done(); +// }); +// serialPort.emit("data", [240]); +// serialPort.emit("data", [121]); +// serialPort.emit("data", [2]); +// serialPort.emit("data", [3]); +// serialPort.emit("data", [83]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [116]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [97]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [110]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [100]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [97]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [114]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [100]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [70]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [105]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [114]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [109]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [97]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [116]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [97]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [247]); +// }); + +// it("Optionally call setSamplingInterval after queryfirmware", function(done) { +// var spy = sinon.spy(Board.prototype, "setSamplingInterval"); +// var serialPort = new SerialPort("/path/to/fake/usb"); +// var options = { +// skipCapabilities: true, +// samplingInterval: 100 +// }; + +// var board = new Board(serialPort, options, function(err) { +// should.deepEqual(serialPort.lastWrite, [ 240, 122, 100, 0, 247 ]); +// should.equal(spy.callCount, 1); +// should.ok(spy.calledWith(100)); +// done(); +// }); + +// // Trigger fake "reportversion" +// serialPort.emit("data", [0xF9, 0x02, 0x03]); + +// // Trigger fake "queryfirmware" +// serialPort.emit("data", [ +// 240, 121, 2, 3, 83, 0, 116, 0, 97, 0, 110, 0, 100, 0, +// 97, 0, 114, 0, 100, 0, 70, 0, 105, 0, 114, 0, 109, 0, +// 97, 0, 116, 0, 97, 0, 247 +// ]); +// }); + +// it("gets the capabilities after the firmware", function(done) { +// //[START_SYSEX, CAPABILITY_QUERY, END_SYSEX] +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, CAPABILITY_QUERY, END_SYSEX]); + +// //report back mock capabilities +// //taken from boards.h for arduino uno +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x6C]); + +// for (var i = 0; i < 20; i++) { +// // if "pin" is digital it can be input and output +// if (i >= 2 && i <= 19) { +// //input is on +// serialPort.emit("data", [0]); +// serialPort.emit("data", [1]); +// //output is on +// serialPort.emit("data", [1]); +// serialPort.emit("data", [1]); +// } +// //if pin is analog +// if (i >= 14 && i <= 19) { +// serialPort.emit("data", [0x02]); +// serialPort.emit("data", [10]); +// } +// //if pin is PWM +// if ([3, 5, 6, 10, 11].indexOf(i) > -1) { +// serialPort.emit("data", [0x03]); +// serialPort.emit("data", [8]); +// } +// //all pins are servo +// if (i >= 2) { +// serialPort.emit("data", [0x04]); +// serialPort.emit("data", [14]); +// } +// //signal end of command for pin +// serialPort.emit("data", [127]); +// } + +// //capture the event once to make all pin modes are set correctly +// serialPort.once("data", function() { +// board.pins.length.should.equal(20); +// board.pins.forEach(function(value, index) { +// if (index >= 2 && index <= 19) { +// value.supportedModes.indexOf(0).should.not.equal(-1); +// value.supportedModes.indexOf(1).should.not.equal(-1); +// } else { +// value.supportedModes.length.should.equal(0); +// } +// if (index >= 14 && index <= 19) { +// value.supportedModes.indexOf(0x02).should.not.equal(-1); +// } else { +// value.supportedModes.indexOf(0x02).should.equal(-1); +// } +// if ([3, 5, 6, 10, 11].indexOf(index) > -1) { +// value.supportedModes.indexOf(0x03).should.not.equal(-1); +// } else { +// value.supportedModes.indexOf(0x03).should.equal(-1); +// } +// if (index >= 2) { +// value.supportedModes.indexOf(0x04).should.not.equal(-1); +// } +// }); +// done(); +// }); +// //end the sysex message +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("capabilities response is an idempotent operation", function(done) { + +// var count = 0; +// var i = 0; + +// serialPort.on("data", function data() { +// count++; + +// // Should be 20 after both responses. +// board.pins.length.should.equal(20); + +// if (count === 2) { +// serialPort.removeListener("data", data); +// done(); +// } +// }); + +// // Fake two capabilities responses... +// // 1 +// serialPort.emit("data", [START_SYSEX, 0x6C]); +// for (i = 0; i < 20; i++) { +// serialPort.emit("data", [0, 1, 1, 1, 127]); +// } +// serialPort.emit("data", [END_SYSEX]); +// // 2 +// serialPort.emit("data", [START_SYSEX, 0x6C]); +// for (i = 0; i < 20; i++) { +// serialPort.emit("data", [0, 1, 1, 1, 127]); +// } +// serialPort.emit("data", [END_SYSEX]); +// }); + + +// it("querys analog mappings after capabilities", function(done) { +// //[START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX] +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]); + +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [ANALOG_MAPPING_RESPONSE]); +// for (var i = 0; i < 20; i++) { +// if (i >= 14 && i < 20) { +// serialPort.emit("data", [i - 14]); +// } else { +// serialPort.emit("data", [127]); +// } +// } + +// serialPort.once("data", function() { +// board.pins[14].analogChannel.should.equal(0); +// board.pins[15].analogChannel.should.equal(1); +// board.pins[16].analogChannel.should.equal(2); +// board.pins[17].analogChannel.should.equal(3); +// board.pins[18].analogChannel.should.equal(4); +// board.pins[19].analogChannel.should.equal(5); +// board.analogPins.length.should.equal(6); +// board.analogPins[0].should.equal(14); +// board.analogPins[1].should.equal(15); +// board.analogPins[2].should.equal(16); +// board.analogPins[3].should.equal(17); +// board.analogPins[4].should.equal(18); +// board.analogPins[5].should.equal(19); +// done(); +// }); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("should now be started", function() { +// boardStarted.should.equal(true); +// }); + +// it("should be able to set pin mode on digital pin", function(done) { +// board.pinMode(2, board.MODES.INPUT); +// serialPort.lastWrite[0].should.equal(0xF4); +// serialPort.lastWrite[1].should.equal(2); +// serialPort.lastWrite[2].should.equal(board.MODES.INPUT); +// board.pins[2].mode.should.equal(board.MODES.INPUT); +// done(); +// }); + +// it("should be able to read value of digital pin", function(done) { +// var counter = 0; +// var order = [1, 0, 1, 0]; +// board.digitalRead(2, function(value) { +// if (value === 1) { +// counter++; +// } +// if (value === 0) { +// counter++; +// } +// if (order[0] === value) { +// order.shift(); +// } +// if (counter === 4) { +// order.length.should.equal(0); +// done(); +// } +// }); + +// // Digital reporting turned on... +// should.deepEqual(serialPort.lastWrite, [ 208, 1 ]); + +// // Single Byte +// serialPort.emit("data", [0x90]); +// serialPort.emit("data", [4 % 128]); +// serialPort.emit("data", [4 >> 7]); + +// serialPort.emit("data", [0x90]); +// serialPort.emit("data", [0x00]); +// serialPort.emit("data", [0x00]); + +// // Multi Byte +// serialPort.emit("data", [0x90, 4 % 128, 4 >> 7]); +// serialPort.emit("data", [0x90, 0x00, 0x00]); +// }); + +// it("should be able to set mode on analog pins", function(done) { +// board.pinMode(board.analogPins[0], board.MODES.INPUT); +// serialPort.lastWrite[0].should.equal(0xF4); +// serialPort.lastWrite[1].should.equal(board.analogPins[0]); +// serialPort.lastWrite[2].should.equal(board.MODES.INPUT); +// done(); +// }); + +// it("should be able to read value of analog pin", function(done) { +// var counter = 0; +// var order = [1023, 0, 1023, 0]; +// board.analogRead(1, function(value) { +// if (value === 1023) { +// counter++; +// } +// if (value === 0) { +// counter++; +// } +// if (order[0] === value) { +// order.shift(); +// } +// if (counter === 4) { +// order.length.should.equal(0); +// done(); +// } +// }); + +// // Analog reporting turned on... +// should.deepEqual(serialPort.lastWrite, [ 193, 1 ]); + +// // Single Byte +// serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); +// serialPort.emit("data", [1023 % 128]); +// serialPort.emit("data", [1023 >> 7]); + +// serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); +// serialPort.emit("data", [0 % 128]); +// serialPort.emit("data", [0 >> 7]); + +// // Multi Byte +// serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 1023 % 128, 1023 >> 7]); +// serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 0 % 128, 0 >> 7]); +// }); + +// it("should be able to write a value to a digital output", function(done) { +// board.digitalWrite(3, board.HIGH); +// should.deepEqual(serialPort.lastWrite, [0x90, 8, 0]); + +// board.digitalWrite(3, board.LOW); +// should.deepEqual(serialPort.lastWrite, [0x90, 0, 0]); + +// done(); +// }); + +// it("should be able to write a value to a analog output", function(done) { +// board.analogWrite(board.analogPins[1], 1023); +// should.deepEqual(serialPort.lastWrite, [ANALOG_MESSAGE | board.analogPins[1], 127, 7]); + +// board.analogWrite(board.analogPins[1], 0); +// should.deepEqual(serialPort.lastWrite, [ANALOG_MESSAGE | board.analogPins[1], 0, 0]); +// done(); +// }); + +// it("should be able to write a value to an extended analog output", function(done) { +// var length = board.pins.length; + +// board.pins[46] = { +// supportedModes: [0, 1, 4], +// mode: 4, +// value: 0, +// report: 1, +// analogChannel: 127 +// }; + +// board.analogWrite(46, 180); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, 0x6F, 46, 52, 1, END_SYSEX]); + +// board.analogWrite(46, 0); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, 0x6F, 46, 0, 0, END_SYSEX]); + +// // Restore to original length +// board.pins.length = length; + +// done(); +// }); + +// it("throws if i2c not enabled", function(done) { + +// should.throws(function() { +// board.i2cRead(1, 1, function() {}); +// }); +// should.throws(function() { +// board.i2cReadOnce(1, 1, function() {}); +// }); +// should.throws(function() { +// board.i2cWrite(1, [1, 2, 3]); +// }); +// should.throws(function() { +// board.i2cWriteReg(1, 1, 1); +// }); + +// done(); +// }); + +// it("should be able to send an i2c config", function(done) { +// board.i2cConfig(1); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, 0x78, 1 & 0xFF, (1 >> 8) & 0xFF, END_SYSEX]); +// done(); +// }); + +// it("should be able to send an i2c request", function(done) { +// board.i2cConfig(1); +// board.sendI2CWriteRequest(0x68, [1, 2, 3]); +// var request = [START_SYSEX, 0x76, 0x68, 0 << 3, 1 & 0x7F, (1 >> 7) & 0x7F, 2 & 0x7F, (2 >> 7) & 0x7F, 3 & 0x7F, (3 >> 7) & 0x7F, END_SYSEX]; +// should.deepEqual(serialPort.lastWrite, request); +// done(); +// }); + +// it("should be able to receive an i2c reply", function(done) { +// var handler = sinon.spy(function() {}); +// board.i2cConfig(1); +// board.sendI2CReadRequest(0x68, 4, handler); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, 0x76, 0x68, 1 << 3, 4 & 0x7F, (4 >> 7) & 0x7F, END_SYSEX]); + +// // Start +// serialPort.emit("data", [START_SYSEX]); +// // Reply +// serialPort.emit("data", [0x77]); +// // Address +// serialPort.emit("data", [0x68 % 128]); +// serialPort.emit("data", [0x68 >> 7]); +// // Register +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// // Data 0 +// serialPort.emit("data", [1 & 0x7F]); +// serialPort.emit("data", [(1 >> 7) & 0x7F]); +// // Data 1 +// serialPort.emit("data", [2 & 0x7F]); +// serialPort.emit("data", [(2 >> 7) & 0x7F]); +// // Data 2 +// serialPort.emit("data", [3 & 0x7F]); +// serialPort.emit("data", [(3 >> 7) & 0x7F]); +// // Data 3 +// serialPort.emit("data", [4 & 0x7F]); +// serialPort.emit("data", [(4 >> 7) & 0x7F]); +// // End +// serialPort.emit("data", [END_SYSEX]); + +// should.equal(handler.callCount, 1); +// should.deepEqual(handler.getCall(0).args[0], [1, 2, 3, 4]); + +// done(); +// }); +// it("should be able to send a string", function(done) { +// var bytes = new Buffer("test string", "utf8"); +// var length = bytes.length; +// board.sendString(bytes); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x71); +// for (var i = 0; i < length; i++) { +// serialPort.lastWrite[i * 2 + 2].should.equal(bytes[i] & 0x7F); +// serialPort.lastWrite[i * 2 + 3].should.equal((bytes[i + 1] >> 7) & 0x7F); +// } +// serialPort.lastWrite[length * 2 + 2].should.equal(0); +// serialPort.lastWrite[length * 2 + 3].should.equal(0); +// serialPort.lastWrite[length * 2 + 4].should.equal(END_SYSEX); +// done(); +// }); +// it("should emit a string event", function(done) { +// board.on("string", function(string) { +// string.should.equal("test string"); +// done(); +// }); +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x71]); +// var bytes = new Buffer("test string", "utf8"); +// Array.prototype.forEach.call(bytes, function(value, index) { +// serialPort.emit("data", [value]); +// }); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("can query pin state", function(done) { +// board.queryPinState(2, function() { +// board.pins[2].state.should.equal(1024); +// done(); +// }); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, 0x6D, 2, END_SYSEX]); +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x6E]); +// serialPort.emit("data", [2]); +// serialPort.emit("data", [board.MODES.INPUT]); +// serialPort.emit("data", [1024]); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("can send a pingRead without a timeout and without a pulse out", function(done) { +// board.pingRead({ +// pin: 3, +// value: board.HIGH, +// timeout: 1000000 +// }, function(duration) { +// duration.should.equal(0); +// done(); +// }); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, PING_READ, 3, board.HIGH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 66, 0, 64, 0, END_SYSEX]); + +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x74]); +// serialPort.emit("data", [3]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("can send a pingRead with a timeout and a pulse out", function(done) { +// board.pingRead({ +// pin: 3, +// value: board.HIGH, +// pulseOut: 5, +// timeout: 1000000 +// }, function(duration) { +// duration.should.equal(1000000); +// done(); +// }); +// should.deepEqual(serialPort.lastWrite, [START_SYSEX, PING_READ, 3, board.HIGH, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 15, 0, 66, 0, 64, 0, END_SYSEX]); + +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x74]); +// serialPort.emit("data", [3]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [15]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [66]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [64]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [END_SYSEX]); +// }); +// it("can send a pingRead with a pulse out and without a timeout ", function(done) { +// board.pingRead({ +// pin: 3, +// value: board.HIGH, +// pulseOut: 5 +// }, function(duration) { +// duration.should.equal(1000000); +// done(); +// }); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(PING_READ); +// serialPort.lastWrite[2].should.equal(3); +// serialPort.lastWrite[3].should.equal(board.HIGH); +// serialPort.lastWrite[4].should.equal(0); +// serialPort.lastWrite[5].should.equal(0); +// serialPort.lastWrite[6].should.equal(0); +// serialPort.lastWrite[7].should.equal(0); +// serialPort.lastWrite[8].should.equal(0); +// serialPort.lastWrite[9].should.equal(0); +// serialPort.lastWrite[10].should.equal(5); +// serialPort.lastWrite[11].should.equal(0); +// serialPort.lastWrite[12].should.equal(0); +// serialPort.lastWrite[13].should.equal(0); +// serialPort.lastWrite[14].should.equal(15); +// serialPort.lastWrite[15].should.equal(0); +// serialPort.lastWrite[16].should.equal(66); +// serialPort.lastWrite[17].should.equal(0); +// serialPort.lastWrite[18].should.equal(64); +// serialPort.lastWrite[19].should.equal(0); +// serialPort.lastWrite[20].should.equal(END_SYSEX); +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x74]); +// serialPort.emit("data", [3]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [15]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [66]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [64]); +// serialPort.emit("data", [0]); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("can send a stepper config for a driver configuration", function(done) { +// board.stepperConfig(0, board.STEPPER.TYPE.DRIVER, 200, 2, 3); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x72); +// serialPort.lastWrite[2].should.equal(0); +// serialPort.lastWrite[3].should.equal(0); +// serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.DRIVER); +// serialPort.lastWrite[5].should.equal(200 & 0x7F); +// serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); +// serialPort.lastWrite[7].should.equal(2); +// serialPort.lastWrite[8].should.equal(3); +// serialPort.lastWrite[9].should.equal(END_SYSEX); +// done(); +// }); + +// it("can send a stepper config for a two wire configuration", function(done) { +// board.stepperConfig(0, board.STEPPER.TYPE.TWO_WIRE, 200, 2, 3); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x72); +// serialPort.lastWrite[2].should.equal(0); +// serialPort.lastWrite[3].should.equal(0); +// serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.TWO_WIRE); +// serialPort.lastWrite[5].should.equal(200 & 0x7F); +// serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); +// serialPort.lastWrite[7].should.equal(2); +// serialPort.lastWrite[8].should.equal(3); +// serialPort.lastWrite[9].should.equal(END_SYSEX); +// done(); +// }); + +// it("can send a stepper config for a four wire configuration", function(done) { +// board.stepperConfig(0, board.STEPPER.TYPE.FOUR_WIRE, 200, 2, 3, 4, 5); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x72); +// serialPort.lastWrite[2].should.equal(0); +// serialPort.lastWrite[3].should.equal(0); +// serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.FOUR_WIRE); +// serialPort.lastWrite[5].should.equal(200 & 0x7F); +// serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); +// serialPort.lastWrite[7].should.equal(2); +// serialPort.lastWrite[8].should.equal(3); +// serialPort.lastWrite[9].should.equal(4); +// serialPort.lastWrite[10].should.equal(5); +// serialPort.lastWrite[11].should.equal(END_SYSEX); +// done(); +// }); + +// it("can send a stepper move without acceleration or deceleration", function(done) { +// board.stepperStep(2, board.STEPPER.DIRECTION.CCW, 10000, 2000, function(complete) { +// complete.should.equal(true); +// done(); +// }); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x72); +// serialPort.lastWrite[2].should.equal(1); +// serialPort.lastWrite[3].should.equal(2); +// serialPort.lastWrite[4].should.equal(board.STEPPER.DIRECTION.CCW); +// serialPort.lastWrite[5].should.equal(10000 & 0x7F); +// serialPort.lastWrite[6].should.equal((10000 >> 7) & 0x7F); +// serialPort.lastWrite[7].should.equal((10000 >> 14) & 0x7F); +// serialPort.lastWrite[8].should.equal(2000 & 0x7F); +// serialPort.lastWrite[9].should.equal((2000 >> 7) & 0x7F); +// serialPort.lastWrite[9].should.equal((2000 >> 7) & 0x7F); +// serialPort.lastWrite[10].should.equal(END_SYSEX); +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x72]); +// serialPort.emit("data", [2]); +// serialPort.emit("data", [END_SYSEX]); +// }); + +// it("can send a stepper move with acceleration and deceleration", function(done) { +// board.stepperStep(3, board.STEPPER.DIRECTION.CCW, 10000, 2000, 3000, 8000, function(complete) { +// complete.should.equal(true); +// done(); +// }); + +// var message = [START_SYSEX, 0x72, 1, 3, board.STEPPER.DIRECTION.CCW, 10000 & 0x7F, (10000 >> 7) & 0x7F, (10000 >> 14) & 0x7F, 2000 & 0x7F, (2000 >> 7) & 0x7F, 3000 & 0x7F, (3000 >> 7) & 0x7F, 8000 & 0x7F, (8000 >> 7) & 0x7F, END_SYSEX]; +// should.deepEqual(serialPort.lastWrite, message); + +// serialPort.emit("data", [START_SYSEX]); +// serialPort.emit("data", [0x72]); +// serialPort.emit("data", [3]); +// serialPort.emit("data", [END_SYSEX]); +// }); +// it("should be able to send a 1-wire config with parasitic power enabled", function(done) { +// board.sendOneWireConfig(1, true); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x41); +// serialPort.lastWrite[3].should.equal(0x01); +// serialPort.lastWrite[4].should.equal(0x01); +// serialPort.lastWrite[5].should.equal(END_SYSEX); +// done(); +// }); +// it("should be able to send a 1-wire config with parasitic power disabled", function(done) { +// board.sendOneWireConfig(1, false); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x41); +// serialPort.lastWrite[3].should.equal(0x01); +// serialPort.lastWrite[4].should.equal(0x00); +// serialPort.lastWrite[5].should.equal(END_SYSEX); +// done(); +// }); +// it("should be able to send a 1-wire search request and recieve a reply", function(done) { +// board.sendOneWireSearch(1, function(error, devices) { +// devices.length.should.equal(1); + +// done(); +// }); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x40); +// serialPort.lastWrite[3].should.equal(0x01); +// serialPort.lastWrite[4].should.equal(END_SYSEX); + +// serialPort.emit("data", [START_SYSEX, 0x73, 0x42, 0x01, 0x28, 0x36, 0x3F, 0x0F, 0x52, 0x00, 0x00, 0x00, 0x5D, 0x00, END_SYSEX]); +// }); +// it("should be able to send a 1-wire search alarm request and recieve a reply", function(done) { +// board.sendOneWireAlarmsSearch(1, function(error, devices) { +// devices.length.should.equal(1); + +// done(); +// }); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x44); +// serialPort.lastWrite[3].should.equal(0x01); +// serialPort.lastWrite[4].should.equal(END_SYSEX); + +// serialPort.emit("data", [START_SYSEX, 0x73, 0x45, 0x01, 0x28, 0x36, 0x3F, 0x0F, 0x52, 0x00, 0x00, 0x00, 0x5D, 0x00, END_SYSEX]); +// }); +// it("should be able to send a 1-wire reset request", function(done) { +// board.sendOneWireReset(1); + +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x01); +// serialPort.lastWrite[3].should.equal(0x01); + +// done(); +// }); +// it("should be able to send a 1-wire delay request", function(done) { +// var delay = 1000; + +// board.sendOneWireDelay(1, delay); + +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x3C); +// serialPort.lastWrite[3].should.equal(0x01); + +// // decode delay from request +// var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); +// var sentDelay = request[12] | (request[13] << 8) | (request[14] << 12) | request[15] << 24; +// sentDelay.should.equal(delay); + +// done(); +// }); +// it("should be able to send a 1-wire write request", function(done) { +// var device = [40, 219, 239, 33, 5, 0, 0, 93]; +// var data = 0x33; + +// board.sendOneWireWrite(1, device, data); + +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x3C); +// serialPort.lastWrite[3].should.equal(0x01); + +// // decode delay from request +// var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); + +// // should select the passed device +// request[0].should.equal(device[0]); +// request[1].should.equal(device[1]); +// request[2].should.equal(device[2]); +// request[3].should.equal(device[3]); +// request[4].should.equal(device[4]); +// request[5].should.equal(device[5]); +// request[6].should.equal(device[6]); +// request[7].should.equal(device[7]); + +// // and send the passed data +// request[16].should.equal(data); + +// done(); +// }); +// it("should be able to send a 1-wire write and read request and recieve a reply", function(done) { +// var device = [40, 219, 239, 33, 5, 0, 0, 93]; +// var data = 0x33; +// var output = [0x01, 0x02]; + +// board.sendOneWireWriteAndRead(1, device, data, 2, function(error, receieved) { +// receieved.should.eql(output); + +// done(); +// }); + +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x73); +// serialPort.lastWrite[2].should.equal(0x3C); +// serialPort.lastWrite[3].should.equal(0x01); + +// // decode delay from request +// var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); + +// // should select the passed device +// request[0].should.equal(device[0]); +// request[1].should.equal(device[1]); +// request[2].should.equal(device[2]); +// request[3].should.equal(device[3]); +// request[4].should.equal(device[4]); +// request[5].should.equal(device[5]); +// request[6].should.equal(device[6]); +// request[7].should.equal(device[7]); + +// // and send the passed data +// request[16].should.equal(data); + +// var dataSentFromBoard = []; + +// // respond with the same correlation id +// dataSentFromBoard[0] = request[10]; +// dataSentFromBoard[1] = request[11]; + +// // data "read" from the 1-wire device +// dataSentFromBoard[2] = output[0]; +// dataSentFromBoard[3] = output[1]; + +// serialPort.emit("data", [START_SYSEX, 0x73, 0x43, 0x01].concat(Encoder7Bit.to7BitArray(dataSentFromBoard)).concat([END_SYSEX])); +// }); + +// it("can configure a servo pwm range", function(done) { +// board.servoConfig(3, 1000, 2000); +// serialPort.lastWrite[0].should.equal(START_SYSEX); +// serialPort.lastWrite[1].should.equal(0x70); +// serialPort.lastWrite[2].should.equal(0x03); + +// serialPort.lastWrite[3].should.equal(1000 & 0x7F); +// serialPort.lastWrite[4].should.equal((1000 >> 7) & 0x7F); + +// serialPort.lastWrite[5].should.equal(2000 & 0x7F); +// serialPort.lastWrite[6].should.equal((2000 >> 7) & 0x7F); + +// done(); +// }); + +// it("has an i2cWrite method, that writes a data array", function(done) { +// var spy = sinon.spy(serialPort, "write"); + +// board.i2cConfig(0); +// board.i2cWrite(0x53, [1, 2]); + +// should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 1, 0, 2, 0, 247 ]); +// should.equal(spy.callCount, 2); +// spy.restore(); +// done(); +// }); + +// it("has an i2cWrite method, that writes a byte", function(done) { +// var spy = sinon.spy(serialPort, "write"); + +// board.i2cConfig(0); +// board.i2cWrite(0x53, 1); + +// should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 1, 0, 247 ]); +// should.equal(spy.callCount, 2); +// spy.restore(); +// done(); +// }); + +// it("has an i2cWrite method, that writes a data array to a register", function(done) { +// var spy = sinon.spy(serialPort, "write"); + +// board.i2cConfig(0); +// board.i2cWrite(0x53, 0xB2, [1, 2]); + +// should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 2, 0, 247 ]); +// should.equal(spy.callCount, 2); +// spy.restore(); +// done(); +// }); + +// it("has an i2cWrite method, that writes a data byte to a register", function(done) { +// var spy = sinon.spy(serialPort, "write"); + +// board.i2cConfig(0); +// board.i2cWrite(0x53, 0xB2, 1); + +// should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 247 ]); +// should.equal(spy.callCount, 2); +// spy.restore(); +// done(); +// }); + +// it("has an i2cWriteReg method, that writes a data byte to a register", function(done) { +// var spy = sinon.spy(serialPort, "write"); + +// board.i2cConfig(0); +// board.i2cWrite(0x53, 0xB2, 1); + +// should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 247 ]); +// should.equal(spy.callCount, 2); +// spy.restore(); +// done(); +// }); + +// it("has an i2cRead method that reads continuously", function(done) { +// var handler = sinon.spy(function() {}); + +// board.i2cConfig(0); +// board.i2cRead(0x53, 0x04, handler); + +// for (var i = 0; i < 5; i++) { +// serialPort.emit("data", [ +// START_SYSEX, 0x77, 83, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX +// ]); +// } + +// should.equal(handler.callCount, 5); +// should.equal(handler.getCall(0).args[0].length, 4); +// should.equal(handler.getCall(1).args[0].length, 4); +// should.equal(handler.getCall(2).args[0].length, 4); +// should.equal(handler.getCall(3).args[0].length, 4); +// should.equal(handler.getCall(4).args[0].length, 4); + +// done(); +// }); + +// it("has an i2cRead method that reads a register continuously", function(done) { +// var handler = sinon.spy(function() {}); + +// board.i2cConfig(0); +// board.i2cRead(0x53, 0xB2, 0x04, handler); + +// for (var i = 0; i < 5; i++) { +// serialPort.emit("data", [ +// START_SYSEX, 0x77, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX +// ]); +// } + +// should.equal(handler.callCount, 5); +// should.equal(handler.getCall(0).args[0].length, 4); +// should.equal(handler.getCall(1).args[0].length, 4); +// should.equal(handler.getCall(2).args[0].length, 4); +// should.equal(handler.getCall(3).args[0].length, 4); +// should.equal(handler.getCall(4).args[0].length, 4); + +// done(); +// }); + + +// it("has an i2cRead method that reads continuously", function(done) { +// var handler = sinon.spy(function() {}); + +// board.i2cConfig(0); +// board.i2cRead(0x53, 0x04, handler); + +// for (var i = 0; i < 5; i++) { +// serialPort.emit("data", [ +// START_SYSEX, 0x77, 83, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX +// ]); +// } + +// should.equal(handler.callCount, 5); +// should.equal(handler.getCall(0).args[0].length, 4); +// should.equal(handler.getCall(1).args[0].length, 4); +// should.equal(handler.getCall(2).args[0].length, 4); +// should.equal(handler.getCall(3).args[0].length, 4); +// should.equal(handler.getCall(4).args[0].length, 4); + +// done(); +// }); + +// it("has an i2cReadOnce method that reads a register once", function(done) { +// var handler = sinon.spy(function() {}); + +// board.i2cConfig(0); +// board.i2cReadOnce(0x53, 0xB2, 0x04, handler); + +// // Emit data enough times to potentially break it. +// for (var i = 0; i < 5; i++) { +// serialPort.emit("data", [ +// START_SYSEX, 0x77, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX +// ]); +// } + +// should.equal(handler.callCount, 1); +// should.equal(handler.getCall(0).args[0].length, 4); +// done(); +// }); + +// it("has an i2cReadOnce method that reads a register once", function(done) { +// var handler = sinon.spy(function() {}); + +// board.i2cConfig(0); +// board.i2cReadOnce(0x53, 0xB2, 0x04, handler); + +// // Emit data enough times to potentially break it. +// for (var i = 0; i < 5; i++) { +// serialPort.emit("data", [ +// START_SYSEX, 0x77, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX +// ]); +// } + +// should.equal(handler.callCount, 1); +// should.equal(handler.getCall(0).args[0].length, 4); +// done(); +// }); +// }); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test.js new file mode 100644 index 0000000..2da0414 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/firmata.test.js @@ -0,0 +1,1312 @@ +var rewire = require("rewire"); +var firmata = process.env.FIRMATA_COV ? + rewire("../lib-cov/firmata") : + rewire("../lib/firmata"); +var SerialPort = require("./MockSerialPort").SerialPort; +var Encoder7Bit = require("../lib/encoder7bit"); +var should = require("should"); +var sinon = require("sinon"); + +var Board = firmata.Board; +var spy; + +var ANALOG_MAPPING_QUERY = 0x69; +var ANALOG_MAPPING_RESPONSE = 0x6A; +var ANALOG_MESSAGE = 0xE0; +var CAPABILITY_QUERY = 0x6B; +var CAPABILITY_RESPONSE = 0x6C; +var DIGITAL_MESSAGE = 0x90; +var END_SYSEX = 0xF7; +var EXTENDED_ANALOG = 0x6F; +var I2C_CONFIG = 0x78; +var I2C_REPLY = 0x77; +var I2C_REQUEST = 0x76; +var ONEWIRE_CONFIG_REQUEST = 0x41; +var ONEWIRE_DATA = 0x73; +var ONEWIRE_DELAY_REQUEST_BIT = 0x10; +var ONEWIRE_READ_REPLY = 0x43; +var ONEWIRE_READ_REQUEST_BIT = 0x08; +var ONEWIRE_RESET_REQUEST_BIT = 0x01; +var ONEWIRE_SEARCH_ALARMS_REPLY = 0x45; +var ONEWIRE_SEARCH_ALARMS_REQUEST = 0x44; +var ONEWIRE_SEARCH_REPLY = 0x42; +var ONEWIRE_SEARCH_REQUEST = 0x40; +var ONEWIRE_WITHDATA_REQUEST_BITS = 0x3C; +var ONEWIRE_WRITE_REQUEST_BIT = 0x20; +var PIN_MODE = 0xF4; +var PIN_STATE_QUERY = 0x6D; +var PIN_STATE_RESPONSE = 0x6E; +var PING_READ = 0x75; +var PULSE_IN = 0x74; +var PULSE_OUT = 0x73; +var QUERY_FIRMWARE = 0x79; +var REPORT_ANALOG = 0xC0; +var REPORT_DIGITAL = 0xD0; +var REPORT_VERSION = 0xF9; +var SAMPLING_INTERVAL = 0x7A; +var SERVO_CONFIG = 0x70; +var START_SYSEX = 0xF0; +var STEPPER = 0x72; +var STRING_DATA = 0x71; +var SYSTEM_RESET = 0xFF; + + +describe("board", function() { + + var serialPort = new SerialPort("/path/to/fake/usb"); + var boardStarted = false; + var board = new Board(serialPort, function(err) { + boardStarted = true; + (typeof err).should.equal("undefined"); + }); + + + beforeEach(function() { + spy = sinon.spy(SerialPort); + + board._events.length = 0; + + firmata.__set__("SerialPort", spy); + }); + + it("uses serialport defaults", function(done) { + var a = new Board("/path/to/fake/usb1", function(err) {}); + var b = new Board("/path/to/fake/usb2", function(err) {}); + + should.equal(spy.getCall(0).args[0], "/path/to/fake/usb1"); + should.deepEqual(spy.getCall(0).args[1], { baudRate: 57600, bufferSize: 1 }); + + should.equal(spy.getCall(1).args[0], "/path/to/fake/usb2"); + should.deepEqual(spy.getCall(1).args[1], { baudRate: 57600, bufferSize: 1 }); + + done(); + }); + + + it("has a name", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, function(err) {}); + + board.name.should.equal("Firmata"); + done(); + }); + + it("emits 'connect' when the transport is opened.", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, function(err) {}); + + board.on("connect", function() { + done(); + }); + + serialPort.emit("open"); + }); + + it("emits 'ready' after handshakes complete (skipCapabilities)", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, {skipCapabilities: true}, function(err) {}); + var connected = false; + + board.on("connect", function() { + connected = true; + }); + + board.on("ready", function() { + should.equal(connected, true); + should.equal(this.isReady, true); + done(); + }); + + serialPort.emit("open"); + board.emit("reportversion"); + board.emit("queryfirmware"); + }); + + it("emits 'ready' after handshakes complete", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, function(err) {}); + var connected = false; + + board.on("connect", function() { + connected = true; + }); + + board.on("ready", function() { + should.equal(connected, true); + should.equal(this.isReady, true); + done(); + }); + + serialPort.emit("open"); + board.emit("reportversion"); + board.emit("queryfirmware"); + board.emit("capability-query"); + board.emit("analog-mapping-query"); + }); + + it("reports errors", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, function(err) { + "test error".should.equal(err); + done(); + }); + + serialPort.emit("error", "test error"); + }); + + it("sends report version and query firmware if it hasnt received the version within the timeout", function(done) { + this.timeout(50000); + var serialPort = new SerialPort("/path/to/fake/usb"); + var opt = { + reportVersionTimeout: 1 + }; + var board = new Board(serialPort, opt, function(err) {}); + + // rcheck for report version + serialPort.once("write", function(data) { + should.deepEqual(data, [REPORT_VERSION]); + // check for query firmware + serialPort.once("write", function(data) { + should.deepEqual(data, [240, 121, 247]); + done(); + }); + }); + }); + + it("uses default baud rate and buffer size", function (done) { + var port = "fake port"; + var board = new Board(port, function (err) {}); + + should.deepEqual( + spy.args, [ [ "fake port", { baudRate: 57600, bufferSize: 1 } ] ] + ); + + done(); + }); + + it("overrides baud rate and buffer size", function (done) { + var port = "fake port"; + var opt = { + reportVersionTimeout: 1, + serialport: { + baudRate: 5, + bufferSize: 10 + } + }; + var board = new Board(port, opt, function (err) {}); + + should.deepEqual( + spy.args, [ [ "fake port", { baudRate: 5, bufferSize: 10 } ] ] + ); + + done(); + }); + + it("receives the version on startup", function(done) { + //"send" report version command back from arduino + serialPort.emit("data", [REPORT_VERSION]); + serialPort.emit("data", [0x02]); + + //subscribe to the "data" event to capture the event + serialPort.once("data", function(buffer) { + board.version.major.should.equal(2); + board.version.minor.should.equal(3); + done(); + }); + + //send the last byte of command to get "data" event to fire when the report version function is called + serialPort.emit("data", [0x03]); + }); + + it("receives the firmware after the version", function(done) { + board.once("queryfirmware", function() { + board.firmware.version.major.should.equal(2); + board.firmware.version.minor.should.equal(3); + board.firmware.name.should.equal("StandardFirmata"); + done(); + }); + serialPort.emit("data", [240]); + serialPort.emit("data", [121]); + serialPort.emit("data", [2]); + serialPort.emit("data", [3]); + serialPort.emit("data", [83]); + serialPort.emit("data", [0]); + serialPort.emit("data", [116]); + serialPort.emit("data", [0]); + serialPort.emit("data", [97]); + serialPort.emit("data", [0]); + serialPort.emit("data", [110]); + serialPort.emit("data", [0]); + serialPort.emit("data", [100]); + serialPort.emit("data", [0]); + serialPort.emit("data", [97]); + serialPort.emit("data", [0]); + serialPort.emit("data", [114]); + serialPort.emit("data", [0]); + serialPort.emit("data", [100]); + serialPort.emit("data", [0]); + serialPort.emit("data", [70]); + serialPort.emit("data", [0]); + serialPort.emit("data", [105]); + serialPort.emit("data", [0]); + serialPort.emit("data", [114]); + serialPort.emit("data", [0]); + serialPort.emit("data", [109]); + serialPort.emit("data", [0]); + serialPort.emit("data", [97]); + serialPort.emit("data", [0]); + serialPort.emit("data", [116]); + serialPort.emit("data", [0]); + serialPort.emit("data", [97]); + serialPort.emit("data", [0]); + serialPort.emit("data", [247]); + }); + + it("Optionally call setSamplingInterval after queryfirmware", function(done) { + var spy = sinon.spy(Board.prototype, "setSamplingInterval"); + var serialPort = new SerialPort("/path/to/fake/usb"); + var options = { + skipCapabilities: true, + samplingInterval: 100 + }; + + var board = new Board(serialPort, options, function(err) { + should.deepEqual(serialPort.lastWrite, [ 240, 122, 100, 0, 247 ]); + should.equal(spy.callCount, 1); + should.ok(spy.calledWith(100)); + + spy.restore(); + done(); + }); + + // Trigger fake "reportversion" + serialPort.emit("data", [REPORT_VERSION, 0x02, 0x03]); + + // Trigger fake "queryfirmware" + serialPort.emit("data", [ + 240, 121, 2, 3, 83, 0, 116, 0, 97, 0, 110, 0, 100, 0, + 97, 0, 114, 0, 100, 0, 70, 0, 105, 0, 114, 0, 109, 0, + 97, 0, 116, 0, 97, 0, 247 + ]); + }); + + it("Does not call setSamplingInterval after queryfirmware by default", function(done) { + var spy = sinon.spy(Board.prototype, "setSamplingInterval"); + var serialPort = new SerialPort("/path/to/fake/usb"); + var options = { + skipCapabilities: true, + }; + + var board = new Board(serialPort, options, function() { + should.equal(spy.callCount, 0); + spy.restore(); + done(); + }); + + // Trigger fake "reportversion" + serialPort.emit("data", [REPORT_VERSION, 0x02, 0x03]); + + // Trigger fake "queryfirmware" + serialPort.emit("data", [ + 240, 121, 2, 3, 83, 0, 116, 0, 97, 0, 110, 0, 100, 0, + 97, 0, 114, 0, 100, 0, 70, 0, 105, 0, 114, 0, 109, 0, + 97, 0, 116, 0, 97, 0, 247 + ]); + }); + + it("gets the capabilities after the firmware", function(done) { + //[START_SYSEX, CAPABILITY_QUERY, END_SYSEX] + should.deepEqual(serialPort.lastWrite, [START_SYSEX, CAPABILITY_QUERY, END_SYSEX]); + + //report back mock capabilities + //taken from boards.h for arduino uno + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [CAPABILITY_RESPONSE]); + + for (var i = 0; i < 20; i++) { + // if "pin" is digital it can be input and output + if (i >= 2 && i <= 19) { + //input is on + serialPort.emit("data", [0]); + serialPort.emit("data", [1]); + //output is on + serialPort.emit("data", [1]); + serialPort.emit("data", [1]); + } + //if pin is analog + if (i >= 14 && i <= 19) { + serialPort.emit("data", [0x02]); + serialPort.emit("data", [10]); + } + //if pin is PWM + if ([3, 5, 6, 10, 11].indexOf(i) > -1) { + serialPort.emit("data", [0x03]); + serialPort.emit("data", [8]); + } + //all pins are servo + if (i >= 2) { + serialPort.emit("data", [0x04]); + serialPort.emit("data", [14]); + } + //signal end of command for pin + serialPort.emit("data", [127]); + } + + //capture the event once to make all pin modes are set correctly + serialPort.once("data", function() { + board.pins.length.should.equal(20); + board.pins.forEach(function(value, index) { + if (index >= 2 && index <= 19) { + value.supportedModes.indexOf(0).should.not.equal(-1); + value.supportedModes.indexOf(1).should.not.equal(-1); + } else { + value.supportedModes.length.should.equal(0); + } + if (index >= 14 && index <= 19) { + value.supportedModes.indexOf(0x02).should.not.equal(-1); + } else { + value.supportedModes.indexOf(0x02).should.equal(-1); + } + if ([3, 5, 6, 10, 11].indexOf(index) > -1) { + value.supportedModes.indexOf(0x03).should.not.equal(-1); + } else { + value.supportedModes.indexOf(0x03).should.equal(-1); + } + if (index >= 2) { + value.supportedModes.indexOf(0x04).should.not.equal(-1); + } + }); + done(); + }); + //end the sysex message + serialPort.emit("data", [END_SYSEX]); + }); + + it("capabilities response is an idempotent operation", function(done) { + + var count = 0; + var i = 0; + + serialPort.on("data", function data() { + count++; + + // Should be 20 after both responses. + board.pins.length.should.equal(20); + + if (count === 2) { + serialPort.removeListener("data", data); + done(); + } + }); + + // Fake two capabilities responses... + // 1 + serialPort.emit("data", [START_SYSEX, CAPABILITY_RESPONSE]); + for (i = 0; i < 20; i++) { + serialPort.emit("data", [0, 1, 1, 1, 127]); + } + serialPort.emit("data", [END_SYSEX]); + // 2 + serialPort.emit("data", [START_SYSEX, CAPABILITY_RESPONSE]); + for (i = 0; i < 20; i++) { + serialPort.emit("data", [0, 1, 1, 1, 127]); + } + serialPort.emit("data", [END_SYSEX]); + }); + + + it("querys analog mappings after capabilities", function(done) { + //[START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX] + should.deepEqual(serialPort.lastWrite, [START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]); + + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [ANALOG_MAPPING_RESPONSE]); + for (var i = 0; i < 20; i++) { + if (i >= 14 && i < 20) { + serialPort.emit("data", [i - 14]); + } else { + serialPort.emit("data", [127]); + } + } + + serialPort.once("data", function() { + board.pins[14].analogChannel.should.equal(0); + board.pins[15].analogChannel.should.equal(1); + board.pins[16].analogChannel.should.equal(2); + board.pins[17].analogChannel.should.equal(3); + board.pins[18].analogChannel.should.equal(4); + board.pins[19].analogChannel.should.equal(5); + board.analogPins.length.should.equal(6); + board.analogPins[0].should.equal(14); + board.analogPins[1].should.equal(15); + board.analogPins[2].should.equal(16); + board.analogPins[3].should.equal(17); + board.analogPins[4].should.equal(18); + board.analogPins[5].should.equal(19); + done(); + }); + serialPort.emit("data", [END_SYSEX]); + }); + + it("should now be started", function() { + boardStarted.should.equal(true); + }); + + it("allows setting a valid sampling interval", function(done) { + var spy = sinon.spy(board.transport, "write"); + + // Valid sampling interval + board.setSamplingInterval(20); + should.ok((new Buffer([0xf0, 0x7a, 0x14, 0x00, 0xf7])).equals(spy.lastCall.args[0])); + + // Invalid sampling interval is constrained to a valid interval + // > 65535 => 65535 + board.setSamplingInterval(65540); + should.ok((new Buffer([0xf0, 0x7a, 0x7f, 0x7f, 0xf7])).equals(spy.lastCall.args[0])); + + // Invalid sampling interval is constrained to a valid interval + // < 10 => 10 + board.setSamplingInterval(0); + should.ok((new Buffer([0xf0, 0x7a, 0x0a, 0x00, 0xf7])).equals(spy.lastCall.args[0])); + + spy.restore(); + done(); + }); + + it("should be able to set pin mode on digital pin", function(done) { + board.pinMode(2, board.MODES.INPUT); + serialPort.lastWrite[0].should.equal(PIN_MODE); + serialPort.lastWrite[1].should.equal(2); + serialPort.lastWrite[2].should.equal(board.MODES.INPUT); + board.pins[2].mode.should.equal(board.MODES.INPUT); + done(); + }); + + it("should be able to read value of digital pin", function(done) { + var counter = 0; + var order = [1, 0, 1, 0]; + board.digitalRead(2, function(value) { + if (value === 1) { + counter++; + } + if (value === 0) { + counter++; + } + if (order[0] === value) { + order.shift(); + } + if (counter === 4) { + order.length.should.equal(0); + done(); + } + }); + + // Digital reporting turned on... + should.deepEqual(serialPort.lastWrite, [ 208, 1 ]); + + // Single Byte + serialPort.emit("data", [DIGITAL_MESSAGE]); + serialPort.emit("data", [4 % 128]); + serialPort.emit("data", [4 >> 7]); + + serialPort.emit("data", [DIGITAL_MESSAGE]); + serialPort.emit("data", [0x00]); + serialPort.emit("data", [0x00]); + + // Multi Byte + serialPort.emit("data", [DIGITAL_MESSAGE, 4 % 128, 4 >> 7]); + serialPort.emit("data", [DIGITAL_MESSAGE, 0x00, 0x00]); + }); + + it("should be able to set mode on analog pins", function(done) { + board.pinMode(board.analogPins[0], board.MODES.INPUT); + serialPort.lastWrite[0].should.equal(PIN_MODE); + serialPort.lastWrite[1].should.equal(board.analogPins[0]); + serialPort.lastWrite[2].should.equal(board.MODES.INPUT); + done(); + }); + + it("should be able to read value of analog pin", function(done) { + var counter = 0; + var order = [1023, 0, 1023, 0]; + board.analogRead(1, function(value) { + if (value === 1023) { + counter++; + } + if (value === 0) { + counter++; + } + if (order[0] === value) { + order.shift(); + } + if (counter === 4) { + order.length.should.equal(0); + done(); + } + }); + + // Analog reporting turned on... + should.deepEqual(serialPort.lastWrite, [ 193, 1 ]); + + // Single Byte + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); + serialPort.emit("data", [1023 % 128]); + serialPort.emit("data", [1023 >> 7]); + + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); + serialPort.emit("data", [0 % 128]); + serialPort.emit("data", [0 >> 7]); + + // Multi Byte + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 1023 % 128, 1023 >> 7]); + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 0 % 128, 0 >> 7]); + }); + + it("should be able to read value of analog pin on a board that skipped capabilities check", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, {skipCapabilities: true, analogPins: [14,15,16,17,18,19]}, function(err) {}); + + board.on("ready", function() { + var counter = 0; + var order = [1023, 0, 1023, 0]; + board.analogRead(1, function(value) { + if (value === 1023) { + counter++; + } + if (value === 0) { + counter++; + } + if (order[0] === value) { + order.shift(); + } + if (counter === 4) { + order.length.should.equal(0); + done(); + } + }); + + // Analog reporting turned on... + should.deepEqual(serialPort.lastWrite, [ 193, 1 ]); + + // Single Byte + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); + serialPort.emit("data", [1023 % 128]); + serialPort.emit("data", [1023 >> 7]); + + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF)]); + serialPort.emit("data", [0 % 128]); + serialPort.emit("data", [0 >> 7]); + + // Multi Byte + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 1023 % 128, 1023 >> 7]); + serialPort.emit("data", [ANALOG_MESSAGE | (1 & 0xF), 0 % 128, 0 >> 7]); + }); + + serialPort.emit("open"); + board.emit("reportversion"); + board.emit("queryfirmware"); + }); + + it("should be able to write a value to a digital output", function(done) { + board.digitalWrite(3, board.HIGH); + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE, 8, 0]); + + board.digitalWrite(3, board.LOW); + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE, 0, 0]); + + done(); + }); + + it("should be able to write a value to a digital output to a board that skipped capabilities check", function(done) { + var serialPort = new SerialPort("/path/to/fake/usb"); + var board = new Board(serialPort, {skipCapabilities: true}, function(err) {}); + + board.on("ready", function() { + board.digitalWrite(3, board.HIGH); + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE, 8, 0]); + + board.digitalWrite(3, board.LOW); + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE, 0, 0]); + done(); + }); + + serialPort.emit("open"); + board.emit("reportversion"); + board.emit("queryfirmware"); + + }); + + it("should be able to write a value to an analog pin being used as a digital output", function(done) { + board.digitalWrite(19, board.HIGH); + // `DIGITAL_MESSAGE | 2` => Digital Message on Port 2 + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE | 2, 8, 0]); + + board.digitalWrite(19, board.LOW); + should.deepEqual(serialPort.lastWrite, [DIGITAL_MESSAGE | 2, 0, 0]); + + done(); + }); + + it("should be able to write a value to a analog output", function(done) { + board.analogWrite(board.analogPins[1], 1023); + should.deepEqual(serialPort.lastWrite, [ANALOG_MESSAGE | board.analogPins[1], 127, 7]); + + board.analogWrite(board.analogPins[1], 0); + should.deepEqual(serialPort.lastWrite, [ANALOG_MESSAGE | board.analogPins[1], 0, 0]); + done(); + }); + + it("should be able to write a value to an extended analog output", function(done) { + var length = board.pins.length; + + board.pins[46] = { + supportedModes: [0, 1, 4], + mode: 4, + value: 0, + report: 1, + analogChannel: 127 + }; + + board.analogWrite(46, 180); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, EXTENDED_ANALOG, 46, 52, 1, END_SYSEX]); + + board.analogWrite(46, 0); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, EXTENDED_ANALOG, 46, 0, 0, END_SYSEX]); + + // Restore to original length + board.pins.length = length; + + done(); + }); + + it("throws if i2c not enabled", function(done) { + + should.throws(function() { + board.i2cRead(1, 1, function() {}); + }); + should.throws(function() { + board.i2cReadOnce(1, 1, function() {}); + }); + should.throws(function() { + board.i2cWrite(1, [1, 2, 3]); + }); + should.throws(function() { + board.i2cWriteReg(1, 1, 1); + }); + + done(); + }); + + it("should be able to send an i2c config (empty)", function(done) { + board.i2cConfig(); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, I2C_CONFIG, 0, 0, END_SYSEX]); + done(); + }); + + it("should be able to send an i2c config (number)", function(done) { + board.i2cConfig(1); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, I2C_CONFIG, 1 & 0xFF, (1 >> 8) & 0xFF, END_SYSEX]); + done(); + }); + + it("should be able to send an i2c config (object with delay property)", function(done) { + board.i2cConfig({ delay: 1 }); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, I2C_CONFIG, 1 & 0xFF, (1 >> 8) & 0xFF, END_SYSEX]); + done(); + }); + + it("should be able to send an i2c request", function(done) { + board.i2cConfig(1); + board.sendI2CWriteRequest(0x68, [1, 2, 3]); + var request = [START_SYSEX, I2C_REQUEST, 0x68, 0 << 3, 1 & 0x7F, (1 >> 7) & 0x7F, 2 & 0x7F, (2 >> 7) & 0x7F, 3 & 0x7F, (3 >> 7) & 0x7F, END_SYSEX]; + should.deepEqual(serialPort.lastWrite, request); + done(); + }); + + it("should be able to receive an i2c reply", function(done) { + var handler = sinon.spy(function() {}); + board.i2cConfig(1); + board.sendI2CReadRequest(0x68, 4, handler); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, I2C_REQUEST, 0x68, 1 << 3, 4 & 0x7F, (4 >> 7) & 0x7F, END_SYSEX]); + + // Start + serialPort.emit("data", [START_SYSEX]); + // Reply + serialPort.emit("data", [I2C_REPLY]); + // Address + serialPort.emit("data", [0x68 % 128]); + serialPort.emit("data", [0x68 >> 7]); + // Register + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + // Data 0 + serialPort.emit("data", [1 & 0x7F]); + serialPort.emit("data", [(1 >> 7) & 0x7F]); + // Data 1 + serialPort.emit("data", [2 & 0x7F]); + serialPort.emit("data", [(2 >> 7) & 0x7F]); + // Data 2 + serialPort.emit("data", [3 & 0x7F]); + serialPort.emit("data", [(3 >> 7) & 0x7F]); + // Data 3 + serialPort.emit("data", [4 & 0x7F]); + serialPort.emit("data", [(4 >> 7) & 0x7F]); + // End + serialPort.emit("data", [END_SYSEX]); + + should.equal(handler.callCount, 1); + should.deepEqual(handler.getCall(0).args[0], [1, 2, 3, 4]); + + done(); + }); + it("should be able to send a string", function(done) { + var bytes = new Buffer("test string", "utf8"); + var length = bytes.length; + board.sendString(bytes); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(STRING_DATA); + for (var i = 0; i < length; i++) { + serialPort.lastWrite[i * 2 + 2].should.equal(bytes[i] & 0x7F); + serialPort.lastWrite[i * 2 + 3].should.equal((bytes[i + 1] >> 7) & 0x7F); + } + serialPort.lastWrite[length * 2 + 2].should.equal(0); + serialPort.lastWrite[length * 2 + 3].should.equal(0); + serialPort.lastWrite[length * 2 + 4].should.equal(END_SYSEX); + done(); + }); + it("should emit a string event", function(done) { + board.on("string", function(string) { + string.should.equal("test string"); + done(); + }); + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [STRING_DATA]); + var bytes = new Buffer("test string", "utf8"); + Array.prototype.forEach.call(bytes, function(value, index) { + serialPort.emit("data", [value]); + }); + serialPort.emit("data", [END_SYSEX]); + }); + + it("can query pin state", function(done) { + board.queryPinState(2, function() { + board.pins[2].state.should.equal(1024); + done(); + }); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, PIN_STATE_QUERY, 2, END_SYSEX]); + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [PIN_STATE_RESPONSE]); + serialPort.emit("data", [2]); + serialPort.emit("data", [board.MODES.INPUT]); + serialPort.emit("data", [1024]); + serialPort.emit("data", [END_SYSEX]); + }); + + it("can send a pingRead without a timeout and without a pulse out", function(done) { + board.pingRead({ + pin: 3, + value: board.HIGH, + timeout: 1000000 + }, function(duration) { + duration.should.equal(0); + done(); + }); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, PING_READ, 3, board.HIGH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 66, 0, 64, 0, END_SYSEX]); + + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [PING_READ]); + serialPort.emit("data", [3]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [END_SYSEX]); + }); + + it("can send a pingRead with a timeout and a pulse out", function(done) { + board.pingRead({ + pin: 3, + value: board.HIGH, + pulseOut: 5, + timeout: 1000000 + }, function(duration) { + duration.should.equal(1000000); + done(); + }); + should.deepEqual(serialPort.lastWrite, [START_SYSEX, PING_READ, 3, board.HIGH, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 15, 0, 66, 0, 64, 0, END_SYSEX]); + + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [PING_READ]); + serialPort.emit("data", [3]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [15]); + serialPort.emit("data", [0]); + serialPort.emit("data", [66]); + serialPort.emit("data", [0]); + serialPort.emit("data", [64]); + serialPort.emit("data", [0]); + serialPort.emit("data", [END_SYSEX]); + }); + it("can send a pingRead with a pulse out and without a timeout ", function(done) { + board.pingRead({ + pin: 3, + value: board.HIGH, + pulseOut: 5 + }, function(duration) { + duration.should.equal(1000000); + done(); + }); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PING_READ); + serialPort.lastWrite[2].should.equal(3); + serialPort.lastWrite[3].should.equal(board.HIGH); + serialPort.lastWrite[4].should.equal(0); + serialPort.lastWrite[5].should.equal(0); + serialPort.lastWrite[6].should.equal(0); + serialPort.lastWrite[7].should.equal(0); + serialPort.lastWrite[8].should.equal(0); + serialPort.lastWrite[9].should.equal(0); + serialPort.lastWrite[10].should.equal(5); + serialPort.lastWrite[11].should.equal(0); + serialPort.lastWrite[12].should.equal(0); + serialPort.lastWrite[13].should.equal(0); + serialPort.lastWrite[14].should.equal(15); + serialPort.lastWrite[15].should.equal(0); + serialPort.lastWrite[16].should.equal(66); + serialPort.lastWrite[17].should.equal(0); + serialPort.lastWrite[18].should.equal(64); + serialPort.lastWrite[19].should.equal(0); + serialPort.lastWrite[20].should.equal(END_SYSEX); + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [PING_READ]); + serialPort.emit("data", [3]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [0]); + serialPort.emit("data", [15]); + serialPort.emit("data", [0]); + serialPort.emit("data", [66]); + serialPort.emit("data", [0]); + serialPort.emit("data", [64]); + serialPort.emit("data", [0]); + serialPort.emit("data", [END_SYSEX]); + }); + + it("can send a stepper config for a driver configuration", function(done) { + board.stepperConfig(0, board.STEPPER.TYPE.DRIVER, 200, 2, 3); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(STEPPER); + serialPort.lastWrite[2].should.equal(0); + serialPort.lastWrite[3].should.equal(0); + serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.DRIVER); + serialPort.lastWrite[5].should.equal(200 & 0x7F); + serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); + serialPort.lastWrite[7].should.equal(2); + serialPort.lastWrite[8].should.equal(3); + serialPort.lastWrite[9].should.equal(END_SYSEX); + done(); + }); + + it("can send a stepper config for a two wire configuration", function(done) { + board.stepperConfig(0, board.STEPPER.TYPE.TWO_WIRE, 200, 2, 3); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(STEPPER); + serialPort.lastWrite[2].should.equal(0); + serialPort.lastWrite[3].should.equal(0); + serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.TWO_WIRE); + serialPort.lastWrite[5].should.equal(200 & 0x7F); + serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); + serialPort.lastWrite[7].should.equal(2); + serialPort.lastWrite[8].should.equal(3); + serialPort.lastWrite[9].should.equal(END_SYSEX); + done(); + }); + + it("can send a stepper config for a four wire configuration", function(done) { + board.stepperConfig(0, board.STEPPER.TYPE.FOUR_WIRE, 200, 2, 3, 4, 5); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(STEPPER); + serialPort.lastWrite[2].should.equal(0); + serialPort.lastWrite[3].should.equal(0); + serialPort.lastWrite[4].should.equal(board.STEPPER.TYPE.FOUR_WIRE); + serialPort.lastWrite[5].should.equal(200 & 0x7F); + serialPort.lastWrite[6].should.equal((200 >> 7) & 0x7F); + serialPort.lastWrite[7].should.equal(2); + serialPort.lastWrite[8].should.equal(3); + serialPort.lastWrite[9].should.equal(4); + serialPort.lastWrite[10].should.equal(5); + serialPort.lastWrite[11].should.equal(END_SYSEX); + done(); + }); + + it("can send a stepper move without acceleration or deceleration", function(done) { + board.stepperStep(2, board.STEPPER.DIRECTION.CCW, 10000, 2000, function(complete) { + complete.should.equal(true); + done(); + }); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(STEPPER); + serialPort.lastWrite[2].should.equal(1); + serialPort.lastWrite[3].should.equal(2); + serialPort.lastWrite[4].should.equal(board.STEPPER.DIRECTION.CCW); + serialPort.lastWrite[5].should.equal(10000 & 0x7F); + serialPort.lastWrite[6].should.equal((10000 >> 7) & 0x7F); + serialPort.lastWrite[7].should.equal((10000 >> 14) & 0x7F); + serialPort.lastWrite[8].should.equal(2000 & 0x7F); + serialPort.lastWrite[9].should.equal((2000 >> 7) & 0x7F); + serialPort.lastWrite[9].should.equal((2000 >> 7) & 0x7F); + serialPort.lastWrite[10].should.equal(END_SYSEX); + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [STEPPER]); + serialPort.emit("data", [2]); + serialPort.emit("data", [END_SYSEX]); + }); + + it("can send a stepper move with acceleration and deceleration", function(done) { + board.stepperStep(3, board.STEPPER.DIRECTION.CCW, 10000, 2000, 3000, 8000, function(complete) { + complete.should.equal(true); + done(); + }); + + var message = [START_SYSEX, STEPPER, 1, 3, board.STEPPER.DIRECTION.CCW, 10000 & 0x7F, (10000 >> 7) & 0x7F, (10000 >> 14) & 0x7F, 2000 & 0x7F, (2000 >> 7) & 0x7F, 3000 & 0x7F, (3000 >> 7) & 0x7F, 8000 & 0x7F, (8000 >> 7) & 0x7F, END_SYSEX]; + should.deepEqual(serialPort.lastWrite, message); + + serialPort.emit("data", [START_SYSEX]); + serialPort.emit("data", [STEPPER]); + serialPort.emit("data", [3]); + serialPort.emit("data", [END_SYSEX]); + }); + it("should be able to send a 1-wire config with parasitic power enabled", function(done) { + board.sendOneWireConfig(1, true); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_CONFIG_REQUEST); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[4].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[5].should.equal(END_SYSEX); + done(); + }); + it("should be able to send a 1-wire config with parasitic power disabled", function(done) { + board.sendOneWireConfig(1, false); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_CONFIG_REQUEST); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[4].should.equal(0x00); + serialPort.lastWrite[5].should.equal(END_SYSEX); + done(); + }); + it("should be able to send a 1-wire search request and recieve a reply", function(done) { + board.sendOneWireSearch(1, function(error, devices) { + devices.length.should.equal(1); + + done(); + }); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_SEARCH_REQUEST); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[4].should.equal(END_SYSEX); + + serialPort.emit("data", [START_SYSEX, PULSE_OUT, ONEWIRE_SEARCH_REPLY, ONEWIRE_RESET_REQUEST_BIT, 0x28, 0x36, 0x3F, 0x0F, 0x52, 0x00, 0x00, 0x00, 0x5D, 0x00, END_SYSEX]); + }); + it("should be able to send a 1-wire search alarm request and recieve a reply", function(done) { + board.sendOneWireAlarmsSearch(1, function(error, devices) { + devices.length.should.equal(1); + + done(); + }); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_SEARCH_ALARMS_REQUEST); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[4].should.equal(END_SYSEX); + + serialPort.emit("data", [START_SYSEX, PULSE_OUT, ONEWIRE_SEARCH_ALARMS_REPLY, ONEWIRE_RESET_REQUEST_BIT, 0x28, 0x36, 0x3F, 0x0F, 0x52, 0x00, 0x00, 0x00, 0x5D, 0x00, END_SYSEX]); + }); + it("should be able to send a 1-wire reset request", function(done) { + board.sendOneWireReset(1); + + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_RESET_REQUEST_BIT); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + + done(); + }); + it("should be able to send a 1-wire delay request", function(done) { + var delay = 1000; + + board.sendOneWireDelay(1, delay); + + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_WITHDATA_REQUEST_BITS); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + + // decode delay from request + var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); + var sentDelay = request[12] | (request[13] << 8) | (request[14] << 12) | request[15] << 24; + sentDelay.should.equal(delay); + + done(); + }); + it("should be able to send a 1-wire write request", function(done) { + var device = [40, 219, 239, 33, 5, 0, 0, 93]; + var data = 0x33; + + board.sendOneWireWrite(1, device, data); + + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_WITHDATA_REQUEST_BITS); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + + // decode delay from request + var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); + + // should select the passed device + request[0].should.equal(device[0]); + request[1].should.equal(device[1]); + request[2].should.equal(device[2]); + request[3].should.equal(device[3]); + request[4].should.equal(device[4]); + request[5].should.equal(device[5]); + request[6].should.equal(device[6]); + request[7].should.equal(device[7]); + + // and send the passed data + request[16].should.equal(data); + + done(); + }); + it("should be able to send a 1-wire write and read request and recieve a reply", function(done) { + var device = [40, 219, 239, 33, 5, 0, 0, 93]; + var data = 0x33; + var output = [ONEWIRE_RESET_REQUEST_BIT, 0x02]; + + board.sendOneWireWriteAndRead(1, device, data, 2, function(error, receieved) { + receieved.should.eql(output); + + done(); + }); + + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(PULSE_OUT); + serialPort.lastWrite[2].should.equal(ONEWIRE_WITHDATA_REQUEST_BITS); + serialPort.lastWrite[3].should.equal(ONEWIRE_RESET_REQUEST_BIT); + + // decode delay from request + var request = Encoder7Bit.from7BitArray(serialPort.lastWrite.slice(4, serialPort.lastWrite.length - 1)); + + // should select the passed device + request[0].should.equal(device[0]); + request[1].should.equal(device[1]); + request[2].should.equal(device[2]); + request[3].should.equal(device[3]); + request[4].should.equal(device[4]); + request[5].should.equal(device[5]); + request[6].should.equal(device[6]); + request[7].should.equal(device[7]); + + // and send the passed data + request[16].should.equal(data); + + var dataSentFromBoard = []; + + // respond with the same correlation id + dataSentFromBoard[0] = request[10]; + dataSentFromBoard[1] = request[11]; + + // data "read" from the 1-wire device + dataSentFromBoard[2] = output[0]; + dataSentFromBoard[3] = output[1]; + + serialPort.emit("data", [START_SYSEX, PULSE_OUT, ONEWIRE_READ_REPLY, ONEWIRE_RESET_REQUEST_BIT].concat(Encoder7Bit.to7BitArray(dataSentFromBoard)).concat([END_SYSEX])); + }); + + it("can configure a servo pwm range", function(done) { + board.servoConfig(3, 1000, 2000); + serialPort.lastWrite[0].should.equal(START_SYSEX); + serialPort.lastWrite[1].should.equal(SERVO_CONFIG); + serialPort.lastWrite[2].should.equal(0x03); + + serialPort.lastWrite[3].should.equal(1000 & 0x7F); + serialPort.lastWrite[4].should.equal((1000 >> 7) & 0x7F); + + serialPort.lastWrite[5].should.equal(2000 & 0x7F); + serialPort.lastWrite[6].should.equal((2000 >> 7) & 0x7F); + + done(); + }); + + it("has an i2cWrite method, that writes a data array", function(done) { + var spy = sinon.spy(serialPort, "write"); + + board.i2cConfig(0); + board.i2cWrite(0x53, [1, 2]); + + should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 1, 0, 2, 0, 247 ]); + should.equal(spy.callCount, 2); + spy.restore(); + done(); + }); + + it("has an i2cWrite method, that writes a byte", function(done) { + var spy = sinon.spy(serialPort, "write"); + + board.i2cConfig(0); + board.i2cWrite(0x53, 1); + + should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 1, 0, 247 ]); + should.equal(spy.callCount, 2); + spy.restore(); + done(); + }); + + it("has an i2cWrite method, that writes a data array to a register", function(done) { + var spy = sinon.spy(serialPort, "write"); + + board.i2cConfig(0); + board.i2cWrite(0x53, 0xB2, [1, 2]); + + should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 2, 0, 247 ]); + should.equal(spy.callCount, 2); + spy.restore(); + done(); + }); + + it("has an i2cWrite method, that writes a data byte to a register", function(done) { + var spy = sinon.spy(serialPort, "write"); + + board.i2cConfig(0); + board.i2cWrite(0x53, 0xB2, 1); + + should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 247 ]); + should.equal(spy.callCount, 2); + spy.restore(); + done(); + }); + + it("has an i2cWriteReg method, that writes a data byte to a register", function(done) { + var spy = sinon.spy(serialPort, "write"); + + board.i2cConfig(0); + board.i2cWrite(0x53, 0xB2, 1); + + should.deepEqual(serialPort.lastWrite, [ 240, 118, 83, 0, 50, 1, 1, 0, 247 ]); + should.equal(spy.callCount, 2); + spy.restore(); + done(); + }); + + it("has an i2cRead method that reads continuously", function(done) { + var handler = sinon.spy(function() {}); + + board.i2cConfig(0); + board.i2cRead(0x53, 0x04, handler); + + for (var i = 0; i < 5; i++) { + serialPort.emit("data", [ + START_SYSEX, I2C_REPLY, 83, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX + ]); + } + + should.equal(handler.callCount, 5); + should.equal(handler.getCall(0).args[0].length, 4); + should.equal(handler.getCall(1).args[0].length, 4); + should.equal(handler.getCall(2).args[0].length, 4); + should.equal(handler.getCall(3).args[0].length, 4); + should.equal(handler.getCall(4).args[0].length, 4); + + done(); + }); + + it("has an i2cRead method that reads a register continuously", function(done) { + var handler = sinon.spy(function() {}); + + board.i2cConfig(0); + board.i2cRead(0x53, 0xB2, 0x04, handler); + + for (var i = 0; i < 5; i++) { + serialPort.emit("data", [ + START_SYSEX, I2C_REPLY, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX + ]); + } + + should.equal(handler.callCount, 5); + should.equal(handler.getCall(0).args[0].length, 4); + should.equal(handler.getCall(1).args[0].length, 4); + should.equal(handler.getCall(2).args[0].length, 4); + should.equal(handler.getCall(3).args[0].length, 4); + should.equal(handler.getCall(4).args[0].length, 4); + + done(); + }); + + + it("has an i2cRead method that reads continuously", function(done) { + var handler = sinon.spy(function() {}); + + board.i2cConfig(0); + board.i2cRead(0x53, 0x04, handler); + + for (var i = 0; i < 5; i++) { + serialPort.emit("data", [ + START_SYSEX, I2C_REPLY, 83, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX + ]); + } + + should.equal(handler.callCount, 5); + should.equal(handler.getCall(0).args[0].length, 4); + should.equal(handler.getCall(1).args[0].length, 4); + should.equal(handler.getCall(2).args[0].length, 4); + should.equal(handler.getCall(3).args[0].length, 4); + should.equal(handler.getCall(4).args[0].length, 4); + + done(); + }); + + it("has an i2cReadOnce method that reads a register once", function(done) { + var handler = sinon.spy(function() {}); + + board.i2cConfig(0); + board.i2cReadOnce(0x53, 0xB2, 0x04, handler); + + // Emit data enough times to potentially break it. + for (var i = 0; i < 5; i++) { + serialPort.emit("data", [ + START_SYSEX, I2C_REPLY, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX + ]); + } + + should.equal(handler.callCount, 1); + should.equal(handler.getCall(0).args[0].length, 4); + done(); + }); + + it("has an i2cReadOnce method that reads a register once", function(done) { + var handler = sinon.spy(function() {}); + + board.i2cConfig(0); + board.i2cReadOnce(0x53, 0xB2, 0x04, handler); + + // Emit data enough times to potentially break it. + for (var i = 0; i < 5; i++) { + serialPort.emit("data", [ + START_SYSEX, I2C_REPLY, 83, 0, 50, 1, 1, 0, 2, 0, 3, 0, 4, 0, END_SYSEX + ]); + } + + should.equal(handler.callCount, 1); + should.equal(handler.getCall(0).args[0].length, 4); + done(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/test/onewireutils.test.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/onewireutils.test.js new file mode 100644 index 0000000..25fbfde --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/test/onewireutils.test.js @@ -0,0 +1,45 @@ +var should = require("should"), + OneWireUtils = require("../lib/onewireutils"); +var Encoder7Bit = require("../lib/encoder7bit.js"); +describe("board", function () { + it("should CRC check data read from firmata", function (done) { + var input = [0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D]; + var crcByte = OneWireUtils.crc8(input.slice(0, input.length - 1)); + + crcByte.should.equal(input[input.length - 1]); + + done(); + }); + it("should return an invalid CRC check for corrupt data", function (done) { + var input = [0x28, 0xDB, 0xEF, 0x22, 0x05, 0x00, 0x00, 0x5D]; + var crcByte = OneWireUtils.crc8(input.slice(0, input.length - 1)); + + crcByte.should.not.equal(input[input.length - 1]); + + done(); + }); + it("should read device identifier", function (done) { + var input = Encoder7Bit.to7BitArray([0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D]); + var devices = OneWireUtils.readDevices(input); + + devices.length.should.equal(1); + + done(); + }); + it("should read device identifiers", function (done) { + var input = Encoder7Bit.to7BitArray([0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D, 0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D]); + var devices = OneWireUtils.readDevices(input); + + devices.length.should.equal(2); + + done(); + }); + it("should read only complete device identifiers", function (done) { + var input = Encoder7Bit.to7BitArray([0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D, 0x28, 0xDB, 0xEF, 0x21, 0x05, 0x00, 0x00, 0x5D, 0x00, 0x01, 0x02]); + var devices = OneWireUtils.readDevices(input); + + devices.length.should.equal(2); + + done(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/todo b/JavaScript/node_modules/johnny-five/node_modules/firmata/todo new file mode 100644 index 0000000..7e8c7ed --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/todo @@ -0,0 +1,5 @@ +# TODO + +1. Make repl use serialport.list + +2. diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/update test b/JavaScript/node_modules/johnny-five/node_modules/firmata/update test new file mode 100644 index 0000000..e632c6e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/update test @@ -0,0 +1,49 @@ +var fs = require("fs"); + +var commands = { + ANALOG_MAPPING_QUERY: 0x69, + ANALOG_MAPPING_RESPONSE: 0x6A, + ANALOG_MESSAGE: 0xE0, + CAPABILITY_QUERY: 0x6B, + CAPABILITY_RESPONSE: 0x6C, + DIGITAL_MESSAGE: 0x90, + END_SYSEX: 0xF7, + EXTENDED_ANALOG: 0x6F, + I2C_CONFIG: 0x78, + I2C_REPLY: 0x77, + I2C_REQUEST: 0x76, + ONEWIRE_CONFIG_REQUEST: 0x41, + ONEWIRE_DATA: 0x73, + ONEWIRE_DELAY_REQUEST_BIT: 0x10, + ONEWIRE_READ_REPLY: 0x43, + ONEWIRE_READ_REQUEST_BIT: 0x08, + ONEWIRE_RESET_REQUEST_BIT: 0x01, + ONEWIRE_SEARCH_ALARMS_REPLY: 0x45, + ONEWIRE_SEARCH_ALARMS_REQUEST: 0x44, + ONEWIRE_SEARCH_REPLY: 0x42, + ONEWIRE_SEARCH_REQUEST: 0x40, + ONEWIRE_WITHDATA_REQUEST_BITS: 0x3C, + ONEWIRE_WRITE_REQUEST_BIT: 0x20, + PIN_MODE: 0xF4, + PIN_STATE_QUERY: 0x6D, + PIN_STATE_RESPONSE: 0x6E, + PING_READ: 0x75, + PULSE_IN: 0x74, + PULSE_OUT: 0x73, + QUERY_FIRMWARE: 0x79, + REPORT_ANALOG: 0xC0, + REPORT_DIGITAL: 0xD0, + REPORT_VERSION: 0xF9, + SAMPLING_INTERVAL: 0x7A, + SERVO_CONFIG: 0x70, + START_SYSEX: 0xF0, + STEPPER: 0x72, + STRING_DATA: 0x71, + SYSTEM_RESET: 0xff, +}; + + +fs.openFile("test/firmata.test.js", "utf8", function(err, source) { + console.log(source); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/firmata/update.js b/JavaScript/node_modules/johnny-five/node_modules/firmata/update.js new file mode 100644 index 0000000..fec9d1f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/firmata/update.js @@ -0,0 +1,63 @@ +var fs = require("fs"); + +var commands = { + ANALOG_MAPPING_QUERY: "0x69", + ANALOG_MAPPING_RESPONSE: "0x6A", + ANALOG_MESSAGE: "0xE0", + CAPABILITY_QUERY: "0x6B", + CAPABILITY_RESPONSE: "0x6C", + DIGITAL_MESSAGE: "0x90", + END_SYSEX: "0xF7", + EXTENDED_ANALOG: "0x6F", + I2C_CONFIG: "0x78", + I2C_REPLY: "0x77", + I2C_REQUEST: "0x76", + ONEWIRE_CONFIG_REQUEST: "0x41", + ONEWIRE_DATA: "0x73", + ONEWIRE_DELAY_REQUEST_BIT: "0x10", + ONEWIRE_READ_REPLY: "0x43", + ONEWIRE_READ_REQUEST_BIT: "0x08", + ONEWIRE_RESET_REQUEST_BIT: "0x01", + ONEWIRE_SEARCH_ALARMS_REPLY: "0x45", + ONEWIRE_SEARCH_ALARMS_REQUEST: "0x44", + ONEWIRE_SEARCH_REPLY: "0x42", + ONEWIRE_SEARCH_REQUEST: "0x40", + ONEWIRE_WITHDATA_REQUEST_BITS: "0x3C", + ONEWIRE_WRITE_REQUEST_BIT: "0x20", + PIN_MODE: "0xF4", + PIN_STATE_QUERY: "0x6D", + PIN_STATE_RESPONSE: "0x6E", + PING_READ: "0x75", + PULSE_IN: "0x74", + PULSE_OUT: "0x73", + QUERY_FIRMWARE: "0x79", + REPORT_ANALOG: "0xC0", + REPORT_DIGITAL: "0xD0", + REPORT_VERSION: "0xF9", + SAMPLING_INTERVAL: "0x7A", + SERVO_CONFIG: "0x70", + START_SYSEX: "0xF0", + STEPPER: "0x72", + STRING_DATA: "0x71", + SYSTEM_RESET: "0xff", +}; + + +var targets = Object.keys(commands).reduce(function(accum, command) { + accum[commands[command]] = command; + return accum; +}, {}); + +fs.readFile("test/firmata.test.js", "utf8", function(err, source) { + + Object.keys(targets).forEach(function(target) { + var replacement = targets[target]; + + var rexp = new RegExp(target, "g"); + + source = source.replace(rexp, replacement); + }); + + + fs.writeFile("test/firmata.test.js", source, "utf8"); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/lodash/LICENSE new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/LICENSE @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/lodash/README.md b/JavaScript/node_modules/johnny-five/node_modules/lodash/README.md new file mode 100644 index 0000000..189265e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/README.md @@ -0,0 +1,121 @@ +# lodash v3.10.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules. + +Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): +```bash +$ lodash modularize modern exports=node -o ./ +$ lodash modern -d -o ./index.js +``` + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash +``` + +In Node.js/io.js: + +```js +// load the modern build +var _ = require('lodash'); +// or a method category +var array = require('lodash/array'); +// or a method (great for smaller builds with browserify/webpack) +var chunk = require('lodash/array/chunk'); +``` + +See the [package source](https://github.com/lodash/lodash/tree/3.10.0-npm) for more details. + +**Note:** +Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL. +Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default. + +## Module formats + +lodash is also available in a variety of other builds & module formats. + + * npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds + * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.10.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.10.0-amd) builds + * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.10.0-es) build + +## Further Reading + + * [API Documentation](https://lodash.com/docs) + * [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences) + * [Changelog](https://github.com/lodash/lodash/wiki/Changelog) + * [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap) + * [More Resources](https://github.com/lodash/lodash/wiki/Resources) + +## Features + + * ~100% [code coverage](https://coveralls.io/r/lodash) + * Follows [semantic versioning](http://semver.org/) for releases + * [Lazily evaluated](http://filimanjaro.com/blog/2014/introducing-lazy-evaluation/) chaining + * [_(…)](https://lodash.com/docs#_) supports implicit chaining + * [_.ary](https://lodash.com/docs#ary) & [_.rearg](https://lodash.com/docs#rearg) to change function argument limits & order + * [_.at](https://lodash.com/docs#at) for cherry-picking collection values + * [_.attempt](https://lodash.com/docs#attempt) to execute functions which may error without a try-catch + * [_.before](https://lodash.com/docs#before) to complement [_.after](https://lodash.com/docs#after) + * [_.bindKey](https://lodash.com/docs#bindKey) for binding [*“lazy”*](http://michaux.ca/articles/lazy-function-definition-pattern) defined methods + * [_.chunk](https://lodash.com/docs#chunk) for splitting an array into chunks of a given size + * [_.clone](https://lodash.com/docs#clone) supports shallow cloning of `Date` & `RegExp` objects + * [_.cloneDeep](https://lodash.com/docs#cloneDeep) for deep cloning arrays & objects + * [_.curry](https://lodash.com/docs#curry) & [_.curryRight](https://lodash.com/docs#curryRight) for creating [curried](http://hughfdjackson.com/javascript/why-curry-helps/) functions + * [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) are cancelable & accept options for more control + * [_.defaultsDeep](https://lodash.com/docs#defaultsDeep) for recursively assigning default properties + * [_.fill](https://lodash.com/docs#fill) to fill arrays with values + * [_.findKey](https://lodash.com/docs#findKey) for finding keys + * [_.flow](https://lodash.com/docs#flow) to complement [_.flowRight](https://lodash.com/docs#flowRight) (a.k.a `_.compose`) + * [_.forEach](https://lodash.com/docs#forEach) supports exiting early + * [_.forIn](https://lodash.com/docs#forIn) for iterating all enumerable properties + * [_.forOwn](https://lodash.com/docs#forOwn) for iterating own properties + * [_.get](https://lodash.com/docs#get) & [_.set](https://lodash.com/docs#set) for deep property getting & setting + * [_.gt](https://lodash.com/docs#gt), [_.gte](https://lodash.com/docs#gte), [_.lt](https://lodash.com/docs#lt), & [_.lte](https://lodash.com/docs#lte) relational methods + * [_.inRange](https://lodash.com/docs#inRange) for checking whether a number is within a given range + * [_.isNative](https://lodash.com/docs#isNative) to check for native functions + * [_.isPlainObject](https://lodash.com/docs#isPlainObject) & [_.toPlainObject](https://lodash.com/docs#toPlainObject) to check for & convert to `Object` objects + * [_.isTypedArray](https://lodash.com/docs#isTypedArray) to check for typed arrays + * [_.mapKeys](https://lodash.com/docs#mapKeys) for mapping keys to an object + * [_.matches](https://lodash.com/docs#matches) supports deep object comparisons + * [_.matchesProperty](https://lodash.com/docs#matchesProperty) to complement [_.matches](https://lodash.com/docs#matches) & [_.property](https://lodash.com/docs#property) + * [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend) + * [_.method](https://lodash.com/docs#method) & [_.methodOf](https://lodash.com/docs#methodOf) to create functions that invoke methods + * [_.modArgs](https://lodash.com/docs#modArgs) for more advanced functional composition + * [_.parseInt](https://lodash.com/docs#parseInt) for consistent cross-environment behavior + * [_.pull](https://lodash.com/docs#pull), [_.pullAt](https://lodash.com/docs#pullAt), & [_.remove](https://lodash.com/docs#remove) for mutating arrays + * [_.random](https://lodash.com/docs#random) supports returning floating-point numbers + * [_.restParam](https://lodash.com/docs#restParam) & [_.spread](https://lodash.com/docs#spread) for applying rest parameters & spreading arguments to functions + * [_.runInContext](https://lodash.com/docs#runInContext) for collisionless mixins & easier mocking + * [_.slice](https://lodash.com/docs#slice) for creating subsets of array-like values + * [_.sortByAll](https://lodash.com/docs#sortByAll) & [_.sortByOrder](https://lodash.com/docs#sortByOrder) for sorting by multiple properties & orders + * [_.support](https://lodash.com/docs#support) for flagging environment features + * [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings-imports) options & [ES template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) + * [_.transform](https://lodash.com/docs#transform) as a powerful alternative to [_.reduce](https://lodash.com/docs#reduce) for transforming objects + * [_.unzipWith](https://lodash.com/docs#unzipWith) & [_.zipWith](https://lodash.com/docs#zipWith) to specify how grouped values should be combined + * [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties + * [_.xor](https://lodash.com/docs#xor) to complement [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union) + * [_.add](https://lodash.com/docs#add), [_.round](https://lodash.com/docs#round), [_.sum](https://lodash.com/docs#sum), & + [more](https://lodash.com/docs "_.ceil & _.floor") math methods + * [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), & + [more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders + * [_.capitalize](https://lodash.com/docs#capitalize), [_.trim](https://lodash.com/docs#trim), & + [more](https://lodash.com/docs "_.camelCase, _.deburr, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc, _.words") string methods + * [_.clone](https://lodash.com/docs#clone), [_.isEqual](https://lodash.com/docs#isEqual), & + [more](https://lodash.com/docs "_.assign, _.cloneDeep, _.merge") accept customizer callbacks + * [_.dropWhile](https://lodash.com/docs#dropWhile), [_.takeWhile](https://lodash.com/docs#takeWhile), & + [more](https://lodash.com/docs "_.drop, _.dropRight, _.dropRightWhile, _.take, _.takeRight, _.takeRightWhile") to complement [_.first](https://lodash.com/docs#first), [_.initial](https://lodash.com/docs#initial), [_.last](https://lodash.com/docs#last), & [_.rest](https://lodash.com/docs#rest) + * [_.findLast](https://lodash.com/docs#findLast), [_.findLastKey](https://lodash.com/docs#findLastKey), & + [more](https://lodash.com/docs "_.curryRight, _.dropRight, _.dropRightWhile, _.flowRight, _.forEachRight, _.forInRight, _.forOwnRight, _.padRight, partialRight, _.takeRight, _.trimRight, _.takeRightWhile") right-associative methods + * [_.includes](https://lodash.com/docs#includes), [_.toArray](https://lodash.com/docs#toArray), & + [more](https://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.findLast, _.findWhere, _.forEach, _.forEachRight, _.groupBy, _.indexBy, _.invoke, _.map, _.max, _.min, _.partition, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy, _.sortByAll, _.sortByOrder, _.sum, _.where") accept strings + * [_#commit](https://lodash.com/docs#prototype-commit) & [_#plant](https://lodash.com/docs#prototype-plant) for working with chain sequences + * [_#thru](https://lodash.com/docs#thru) to pass values thru a chain sequence + +## Support + +Tested in Chrome 42-43, Firefox 37-38, IE 6-11, MS Edge, Opera 28-29, Safari 5-8, ChakraNode 0.12.2, io.js 2.3.1, Node.js 0.8.28, 0.10.38, & 0.12.5, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7.6. +Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing. diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array.js new file mode 100644 index 0000000..e5121fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array.js @@ -0,0 +1,44 @@ +module.exports = { + 'chunk': require('./array/chunk'), + 'compact': require('./array/compact'), + 'difference': require('./array/difference'), + 'drop': require('./array/drop'), + 'dropRight': require('./array/dropRight'), + 'dropRightWhile': require('./array/dropRightWhile'), + 'dropWhile': require('./array/dropWhile'), + 'fill': require('./array/fill'), + 'findIndex': require('./array/findIndex'), + 'findLastIndex': require('./array/findLastIndex'), + 'first': require('./array/first'), + 'flatten': require('./array/flatten'), + 'flattenDeep': require('./array/flattenDeep'), + 'head': require('./array/head'), + 'indexOf': require('./array/indexOf'), + 'initial': require('./array/initial'), + 'intersection': require('./array/intersection'), + 'last': require('./array/last'), + 'lastIndexOf': require('./array/lastIndexOf'), + 'object': require('./array/object'), + 'pull': require('./array/pull'), + 'pullAt': require('./array/pullAt'), + 'remove': require('./array/remove'), + 'rest': require('./array/rest'), + 'slice': require('./array/slice'), + 'sortedIndex': require('./array/sortedIndex'), + 'sortedLastIndex': require('./array/sortedLastIndex'), + 'tail': require('./array/tail'), + 'take': require('./array/take'), + 'takeRight': require('./array/takeRight'), + 'takeRightWhile': require('./array/takeRightWhile'), + 'takeWhile': require('./array/takeWhile'), + 'union': require('./array/union'), + 'uniq': require('./array/uniq'), + 'unique': require('./array/unique'), + 'unzip': require('./array/unzip'), + 'unzipWith': require('./array/unzipWith'), + 'without': require('./array/without'), + 'xor': require('./array/xor'), + 'zip': require('./array/zip'), + 'zipObject': require('./array/zipObject'), + 'zipWith': require('./array/zipWith') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/chunk.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/chunk.js new file mode 100644 index 0000000..c8be1fb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/chunk.js @@ -0,0 +1,46 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil, + nativeFloor = Math.floor, + nativeMax = Math.max; + +/** + * Creates an array of elements split into groups the length of `size`. + * If `collection` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the new array containing chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ +function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(nativeFloor(size) || 1, 1); + } + var index = 0, + length = array ? array.length : 0, + resIndex = -1, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[++resIndex] = baseSlice(array, index, (index += size)); + } + return result; +} + +module.exports = chunk; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/compact.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/compact.js new file mode 100644 index 0000000..1dc1c55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/compact.js @@ -0,0 +1,30 @@ +/** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ +function compact(array) { + var index = -1, + length = array ? array.length : 0, + resIndex = -1, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[++resIndex] = value; + } + } + return result; +} + +module.exports = compact; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/difference.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/difference.js new file mode 100644 index 0000000..128932a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/difference.js @@ -0,0 +1,29 @@ +var baseDifference = require('../internal/baseDifference'), + baseFlatten = require('../internal/baseFlatten'), + isArrayLike = require('../internal/isArrayLike'), + isObjectLike = require('../internal/isObjectLike'), + restParam = require('../function/restParam'); + +/** + * Creates an array of unique `array` values not included in the other + * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The arrays of values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.difference([1, 2, 3], [4, 2]); + * // => [1, 3] + */ +var difference = restParam(function(array, values) { + return (isObjectLike(array) && isArrayLike(array)) + ? baseDifference(array, baseFlatten(values, false, true)) + : []; +}); + +module.exports = difference; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/drop.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/drop.js new file mode 100644 index 0000000..039a0b5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/drop.js @@ -0,0 +1,39 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates a slice of `array` with `n` elements dropped from the beginning. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.drop([1, 2, 3]); + * // => [2, 3] + * + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] + */ +function drop(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, n < 0 ? 0 : n); +} + +module.exports = drop; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRight.js new file mode 100644 index 0000000..14b5eb6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRight.js @@ -0,0 +1,40 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates a slice of `array` with `n` elements dropped from the end. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRight([1, 2, 3]); + * // => [1, 2] + * + * _.dropRight([1, 2, 3], 2); + * // => [1] + * + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ +function dropRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, 0, n < 0 ? 0 : n); +} + +module.exports = dropRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRightWhile.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRightWhile.js new file mode 100644 index 0000000..be158bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropRightWhile.js @@ -0,0 +1,59 @@ +var baseCallback = require('../internal/baseCallback'), + baseWhile = require('../internal/baseWhile'); + +/** + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that match the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); + * // => [1] + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); + * // => ['barney', 'fred'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active', false), 'user'); + * // => ['barney'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ +function dropRightWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true) + : []; +} + +module.exports = dropRightWhile; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropWhile.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropWhile.js new file mode 100644 index 0000000..d9eabae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/dropWhile.js @@ -0,0 +1,59 @@ +var baseCallback = require('../internal/baseCallback'), + baseWhile = require('../internal/baseWhile'); + +/** + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropWhile([1, 2, 3], function(n) { + * return n < 3; + * }); + * // => [3] + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); + * // => ['fred', 'pebbles'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropWhile(users, 'active', false), 'user'); + * // => ['pebbles'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.dropWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ +function dropWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, baseCallback(predicate, thisArg, 3), true) + : []; +} + +module.exports = dropWhile; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/fill.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/fill.js new file mode 100644 index 0000000..2c8f6da --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/fill.js @@ -0,0 +1,44 @@ +var baseFill = require('../internal/baseFill'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. + * + * **Note:** This method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] + * + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8], '*', 1, 2); + * // => [4, '*', 8] + */ +function fill(array, value, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); +} + +module.exports = fill; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findIndex.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findIndex.js new file mode 100644 index 0000000..2a6b8e1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findIndex.js @@ -0,0 +1,53 @@ +var createFindIndex = require('../internal/createFindIndex'); + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(chr) { + * return chr.user == 'barney'; + * }); + * // => 0 + * + * // using the `_.matches` callback shorthand + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // using the `_.matchesProperty` callback shorthand + * _.findIndex(users, 'active', false); + * // => 0 + * + * // using the `_.property` callback shorthand + * _.findIndex(users, 'active'); + * // => 2 + */ +var findIndex = createFindIndex(); + +module.exports = findIndex; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findLastIndex.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findLastIndex.js new file mode 100644 index 0000000..d6d8eca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/findLastIndex.js @@ -0,0 +1,53 @@ +var createFindIndex = require('../internal/createFindIndex'); + +/** + * This method is like `_.findIndex` except that it iterates over elements + * of `collection` from right to left. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.findLastIndex(users, function(chr) { + * return chr.user == 'pebbles'; + * }); + * // => 2 + * + * // using the `_.matches` callback shorthand + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // using the `_.matchesProperty` callback shorthand + * _.findLastIndex(users, 'active', false); + * // => 2 + * + * // using the `_.property` callback shorthand + * _.findLastIndex(users, 'active'); + * // => 0 + */ +var findLastIndex = createFindIndex(true); + +module.exports = findLastIndex; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/first.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/first.js new file mode 100644 index 0000000..b3b9c79 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/first.js @@ -0,0 +1,22 @@ +/** + * Gets the first element of `array`. + * + * @static + * @memberOf _ + * @alias head + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. + * @example + * + * _.first([1, 2, 3]); + * // => 1 + * + * _.first([]); + * // => undefined + */ +function first(array) { + return array ? array[0] : undefined; +} + +module.exports = first; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flatten.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flatten.js new file mode 100644 index 0000000..65bbeef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flatten.js @@ -0,0 +1,32 @@ +var baseFlatten = require('../internal/baseFlatten'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Flattens a nested array. If `isDeep` is `true` the array is recursively + * flattened, otherwise it is only flattened a single level. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to flatten. + * @param {boolean} [isDeep] Specify a deep flatten. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, 3, [4]]]); + * // => [1, 2, 3, [4]] + * + * // using `isDeep` + * _.flatten([1, [2, 3, [4]]], true); + * // => [1, 2, 3, 4] + */ +function flatten(array, isDeep, guard) { + var length = array ? array.length : 0; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; +} + +module.exports = flatten; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flattenDeep.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flattenDeep.js new file mode 100644 index 0000000..9f775fe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/flattenDeep.js @@ -0,0 +1,21 @@ +var baseFlatten = require('../internal/baseFlatten'); + +/** + * Recursively flattens a nested array. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to recursively flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flattenDeep([1, [2, 3, [4]]]); + * // => [1, 2, 3, 4] + */ +function flattenDeep(array) { + var length = array ? array.length : 0; + return length ? baseFlatten(array, true) : []; +} + +module.exports = flattenDeep; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/head.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/head.js new file mode 100644 index 0000000..1961b08 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/head.js @@ -0,0 +1 @@ +module.exports = require('./first'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/indexOf.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/indexOf.js new file mode 100644 index 0000000..bad3107 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/indexOf.js @@ -0,0 +1,53 @@ +var baseIndexOf = require('../internal/baseIndexOf'), + binaryIndex = require('../internal/binaryIndex'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` + * performs a faster binary search. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=0] The index to search from or `true` + * to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 + * + * // using `fromIndex` + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 + * + * // performing a binary search + * _.indexOf([1, 1, 2, 2], 2, true); + * // => 2 + */ +function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == 'number') { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && + (value === value ? (value === array[index]) : (array[index] !== array[index]))) { + return index; + } + return -1; + } + return baseIndexOf(array, value, fromIndex || 0); +} + +module.exports = indexOf; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/initial.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/initial.js new file mode 100644 index 0000000..59b7a7d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/initial.js @@ -0,0 +1,20 @@ +var dropRight = require('./dropRight'); + +/** + * Gets all but the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.initial([1, 2, 3]); + * // => [1, 2] + */ +function initial(array) { + return dropRight(array, 1); +} + +module.exports = initial; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/intersection.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/intersection.js new file mode 100644 index 0000000..f218432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/intersection.js @@ -0,0 +1,58 @@ +var baseIndexOf = require('../internal/baseIndexOf'), + cacheIndexOf = require('../internal/cacheIndexOf'), + createCache = require('../internal/createCache'), + isArrayLike = require('../internal/isArrayLike'), + restParam = require('../function/restParam'); + +/** + * Creates an array of unique values that are included in all of the provided + * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of shared values. + * @example + * _.intersection([1, 2], [4, 2], [2, 1]); + * // => [2] + */ +var intersection = restParam(function(arrays) { + var othLength = arrays.length, + othIndex = othLength, + caches = Array(length), + indexOf = baseIndexOf, + isCommon = true, + result = []; + + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; + } + var array = arrays[0], + index = -1, + length = array ? array.length : 0, + seen = caches[0]; + + outer: + while (++index < length) { + value = array[index]; + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { + continue outer; + } + } + if (seen) { + seen.push(value); + } + result.push(value); + } + } + return result; +}); + +module.exports = intersection; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/last.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/last.js new file mode 100644 index 0000000..299af31 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/last.js @@ -0,0 +1,19 @@ +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; +} + +module.exports = last; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/lastIndexOf.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/lastIndexOf.js new file mode 100644 index 0000000..02b8062 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/lastIndexOf.js @@ -0,0 +1,60 @@ +var binaryIndex = require('../internal/binaryIndex'), + indexOfNaN = require('../internal/indexOfNaN'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max, + nativeMin = Math.min; + +/** + * This method is like `_.indexOf` except that it iterates over elements of + * `array` from right to left. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=array.length-1] The index to search from + * or `true` to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 + * + * // using `fromIndex` + * _.lastIndexOf([1, 2, 1, 2], 2, 2); + * // => 1 + * + * // performing a binary search + * _.lastIndexOf([1, 1, 2, 2], 2, true); + * // => 3 + */ +function lastIndexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; + if (typeof fromIndex == 'number') { + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } else if (fromIndex) { + index = binaryIndex(array, value, true) - 1; + var other = array[index]; + if (value === value ? (value === other) : (other !== other)) { + return index; + } + return -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); + } + while (index--) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +module.exports = lastIndexOf; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/object.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/object.js new file mode 100644 index 0000000..f4a3453 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/object.js @@ -0,0 +1 @@ +module.exports = require('./zipObject'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pull.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pull.js new file mode 100644 index 0000000..7bcbb4a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pull.js @@ -0,0 +1,52 @@ +var baseIndexOf = require('../internal/baseIndexOf'); + +/** Used for native method references. */ +var arrayProto = Array.prototype; + +/** Native method references. */ +var splice = arrayProto.splice; + +/** + * Removes all provided values from `array` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.without`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {...*} [values] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3, 1, 2, 3]; + * + * _.pull(array, 2, 3); + * console.log(array); + * // => [1, 1] + */ +function pull() { + var args = arguments, + array = args[0]; + + if (!(array && array.length)) { + return array; + } + var index = 0, + indexOf = baseIndexOf, + length = args.length; + + while (++index < length) { + var fromIndex = 0, + value = args[index]; + + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); + } + } + return array; +} + +module.exports = pull; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pullAt.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pullAt.js new file mode 100644 index 0000000..4ca2476 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/pullAt.js @@ -0,0 +1,40 @@ +var baseAt = require('../internal/baseAt'), + baseCompareAscending = require('../internal/baseCompareAscending'), + baseFlatten = require('../internal/baseFlatten'), + basePullAt = require('../internal/basePullAt'), + restParam = require('../function/restParam'); + +/** + * Removes elements from `array` corresponding to the given indexes and returns + * an array of the removed elements. Indexes may be specified as an array of + * indexes or as individual arguments. + * + * **Note:** Unlike `_.at`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove, + * specified as individual indexes or arrays of indexes. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [5, 10, 15, 20]; + * var evens = _.pullAt(array, 1, 3); + * + * console.log(array); + * // => [5, 15] + * + * console.log(evens); + * // => [10, 20] + */ +var pullAt = restParam(function(array, indexes) { + indexes = baseFlatten(indexes); + + var result = baseAt(array, indexes); + basePullAt(array, indexes.sort(baseCompareAscending)); + return result; +}); + +module.exports = pullAt; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/remove.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/remove.js new file mode 100644 index 0000000..0cf979b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/remove.js @@ -0,0 +1,64 @@ +var baseCallback = require('../internal/baseCallback'), + basePullAt = require('../internal/basePullAt'); + +/** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is bound to + * `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * **Note:** Unlike `_.filter`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ +function remove(array, predicate, thisArg) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, + indexes = [], + length = array.length; + + predicate = baseCallback(predicate, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; +} + +module.exports = remove; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/rest.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/rest.js new file mode 100644 index 0000000..9bfb734 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/rest.js @@ -0,0 +1,21 @@ +var drop = require('./drop'); + +/** + * Gets all but the first element of `array`. + * + * @static + * @memberOf _ + * @alias tail + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.rest([1, 2, 3]); + * // => [2, 3] + */ +function rest(array) { + return drop(array, 1); +} + +module.exports = rest; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/slice.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/slice.js new file mode 100644 index 0000000..48ef1a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/slice.js @@ -0,0 +1,30 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates a slice of `array` from `start` up to, but not including, `end`. + * + * **Note:** This method is used instead of `Array#slice` to support node + * lists in IE < 9 and to ensure dense arrays are returned. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function slice(array, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + return baseSlice(array, start, end); +} + +module.exports = slice; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedIndex.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedIndex.js new file mode 100644 index 0000000..51d150e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedIndex.js @@ -0,0 +1,53 @@ +var createSortedIndex = require('../internal/createSortedIndex'); + +/** + * Uses a binary search to determine the lowest index at which `value` should + * be inserted into `array` in order to maintain its sort order. If an iteratee + * function is provided it is invoked for `value` and each element of `array` + * to compute their sort ranking. The iteratee is bound to `thisArg` and + * invoked with one argument; (value). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedIndex([30, 50], 40); + * // => 1 + * + * _.sortedIndex([4, 4, 5, 5], 5); + * // => 2 + * + * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; + * + * // using an iteratee function + * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { + * return this.data[word]; + * }, dict); + * // => 1 + * + * // using the `_.property` callback shorthand + * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); + * // => 1 + */ +var sortedIndex = createSortedIndex(); + +module.exports = sortedIndex; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedLastIndex.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedLastIndex.js new file mode 100644 index 0000000..81a4a86 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/sortedLastIndex.js @@ -0,0 +1,25 @@ +var createSortedIndex = require('../internal/createSortedIndex'); + +/** + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedLastIndex([4, 4, 5, 5], 5); + * // => 4 + */ +var sortedLastIndex = createSortedIndex(true); + +module.exports = sortedLastIndex; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/tail.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/tail.js new file mode 100644 index 0000000..c5dfe77 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/tail.js @@ -0,0 +1 @@ +module.exports = require('./rest'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/take.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/take.js new file mode 100644 index 0000000..875917a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/take.js @@ -0,0 +1,39 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates a slice of `array` with `n` elements taken from the beginning. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.take([1, 2, 3]); + * // => [1] + * + * _.take([1, 2, 3], 2); + * // => [1, 2] + * + * _.take([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.take([1, 2, 3], 0); + * // => [] + */ +function take(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, 0, n < 0 ? 0 : n); +} + +module.exports = take; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRight.js new file mode 100644 index 0000000..6e89c87 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRight.js @@ -0,0 +1,40 @@ +var baseSlice = require('../internal/baseSlice'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates a slice of `array` with `n` elements taken from the end. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRight([1, 2, 3]); + * // => [3] + * + * _.takeRight([1, 2, 3], 2); + * // => [2, 3] + * + * _.takeRight([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.takeRight([1, 2, 3], 0); + * // => [] + */ +function takeRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, n < 0 ? 0 : n); +} + +module.exports = takeRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRightWhile.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRightWhile.js new file mode 100644 index 0000000..5464d13 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeRightWhile.js @@ -0,0 +1,59 @@ +var baseCallback = require('../internal/baseCallback'), + baseWhile = require('../internal/baseWhile'); + +/** + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until `predicate` returns falsey. The predicate is bound to `thisArg` + * and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); + * // => [2, 3] + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); + * // => ['pebbles'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active', false), 'user'); + * // => ['fred', 'pebbles'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active'), 'user'); + * // => [] + */ +function takeRightWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, baseCallback(predicate, thisArg, 3), false, true) + : []; +} + +module.exports = takeRightWhile; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeWhile.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeWhile.js new file mode 100644 index 0000000..f7e28a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/takeWhile.js @@ -0,0 +1,59 @@ +var baseCallback = require('../internal/baseCallback'), + baseWhile = require('../internal/baseWhile'); + +/** + * Creates a slice of `array` with elements taken from the beginning. Elements + * are taken until `predicate` returns falsey. The predicate is bound to + * `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeWhile([1, 2, 3], function(n) { + * return n < 3; + * }); + * // => [1, 2] + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false}, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeWhile(users, 'active', false), 'user'); + * // => ['barney', 'fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.takeWhile(users, 'active'), 'user'); + * // => [] + */ +function takeWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, baseCallback(predicate, thisArg, 3)) + : []; +} + +module.exports = takeWhile; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/union.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/union.js new file mode 100644 index 0000000..53cefe4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/union.js @@ -0,0 +1,24 @@ +var baseFlatten = require('../internal/baseFlatten'), + baseUniq = require('../internal/baseUniq'), + restParam = require('../function/restParam'); + +/** + * Creates an array of unique values, in order, from all of the provided arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([1, 2], [4, 2], [2, 1]); + * // => [1, 2, 4] + */ +var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); +}); + +module.exports = union; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/uniq.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/uniq.js new file mode 100644 index 0000000..f81a2b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/uniq.js @@ -0,0 +1,71 @@ +var baseCallback = require('../internal/baseCallback'), + baseUniq = require('../internal/baseUniq'), + isIterateeCall = require('../internal/isIterateeCall'), + sortedUniq = require('../internal/sortedUniq'); + +/** + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurence of each element + * is kept. Providing `true` for `isSorted` performs a faster search algorithm + * for sorted arrays. If an iteratee function is provided it is invoked for + * each element in the array to generate the criterion by which uniqueness + * is computed. The `iteratee` is bound to `thisArg` and invoked with three + * arguments: (value, index, array). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias unique + * @category Array + * @param {Array} array The array to inspect. + * @param {boolean} [isSorted] Specify the array is sorted. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new duplicate-value-free array. + * @example + * + * _.uniq([2, 1, 2]); + * // => [2, 1] + * + * // using `isSorted` + * _.uniq([1, 1, 2], true); + * // => [1, 2] + * + * // using an iteratee function + * _.uniq([1, 2.5, 1.5, 2], function(n) { + * return this.floor(n); + * }, Math); + * // => [1, 2.5] + * + * // using the `_.property` callback shorthand + * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ +function uniq(array, isSorted, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (isSorted != null && typeof isSorted != 'boolean') { + thisArg = iteratee; + iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; + isSorted = false; + } + iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3); + return (isSorted) + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); +} + +module.exports = uniq; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unique.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unique.js new file mode 100644 index 0000000..396de1b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unique.js @@ -0,0 +1 @@ +module.exports = require('./uniq'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzip.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzip.js new file mode 100644 index 0000000..0a539fa --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzip.js @@ -0,0 +1,47 @@ +var arrayFilter = require('../internal/arrayFilter'), + arrayMap = require('../internal/arrayMap'), + baseProperty = require('../internal/baseProperty'), + isArrayLike = require('../internal/isArrayLike'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]); + * // => [['fred', 30, true], ['barney', 40, false]] + * + * _.unzip(zipped); + * // => [['fred', 'barney'], [30, 40], [true, false]] + */ +function unzip(array) { + if (!(array && array.length)) { + return []; + } + var index = -1, + length = 0; + + array = arrayFilter(array, function(group) { + if (isArrayLike(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + var result = Array(length); + while (++index < length) { + result[index] = arrayMap(array, baseProperty(index)); + } + return result; +} + +module.exports = unzip; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzipWith.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzipWith.js new file mode 100644 index 0000000..324a2b1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/unzipWith.js @@ -0,0 +1,41 @@ +var arrayMap = require('../internal/arrayMap'), + arrayReduce = require('../internal/arrayReduce'), + bindCallback = require('../internal/bindCallback'), + unzip = require('./unzip'); + +/** + * This method is like `_.unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. The `iteratee` is bound to `thisArg` + * and invoked with four arguments: (accumulator, value, index, group). + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array of grouped elements to process. + * @param {Function} [iteratee] The function to combine regrouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip([1, 2], [10, 20], [100, 200]); + * // => [[1, 10, 100], [2, 20, 200]] + * + * _.unzipWith(zipped, _.add); + * // => [3, 30, 300] + */ +function unzipWith(array, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + iteratee = bindCallback(iteratee, thisArg, 4); + return arrayMap(result, function(group) { + return arrayReduce(group, iteratee, undefined, true); + }); +} + +module.exports = unzipWith; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/without.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/without.js new file mode 100644 index 0000000..2ac3d11 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/without.js @@ -0,0 +1,27 @@ +var baseDifference = require('../internal/baseDifference'), + isArrayLike = require('../internal/isArrayLike'), + restParam = require('../function/restParam'); + +/** + * Creates an array excluding all provided values using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to filter. + * @param {...*} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.without([1, 2, 1, 3], 1, 2); + * // => [3] + */ +var without = restParam(function(array, values) { + return isArrayLike(array) + ? baseDifference(array, values) + : []; +}); + +module.exports = without; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/xor.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/xor.js new file mode 100644 index 0000000..04ef32a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/xor.js @@ -0,0 +1,35 @@ +var arrayPush = require('../internal/arrayPush'), + baseDifference = require('../internal/baseDifference'), + baseUniq = require('../internal/baseUniq'), + isArrayLike = require('../internal/isArrayLike'); + +/** + * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the provided arrays. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of values. + * @example + * + * _.xor([1, 2], [4, 2]); + * // => [1, 4] + */ +function xor() { + var index = -1, + length = arguments.length; + + while (++index < length) { + var array = arguments[index]; + if (isArrayLike(array)) { + var result = result + ? arrayPush(baseDifference(result, array), baseDifference(array, result)) + : array; + } + } + return result ? baseUniq(result) : []; +} + +module.exports = xor; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zip.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zip.js new file mode 100644 index 0000000..53a6f69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zip.js @@ -0,0 +1,21 @@ +var restParam = require('../function/restParam'), + unzip = require('./unzip'); + +/** + * Creates an array of grouped elements, the first of which contains the first + * elements of the given arrays, the second of which contains the second elements + * of the given arrays, and so on. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zip(['fred', 'barney'], [30, 40], [true, false]); + * // => [['fred', 30, true], ['barney', 40, false]] + */ +var zip = restParam(unzip); + +module.exports = zip; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipObject.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipObject.js new file mode 100644 index 0000000..dec7a21 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipObject.js @@ -0,0 +1,43 @@ +var isArray = require('../lang/isArray'); + +/** + * The inverse of `_.pairs`; this method returns an object composed from arrays + * of property names and values. Provide either a single two dimensional array, + * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names + * and one of corresponding values. + * + * @static + * @memberOf _ + * @alias object + * @category Array + * @param {Array} props The property names. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject([['fred', 30], ['barney', 40]]); + * // => { 'fred': 30, 'barney': 40 } + * + * _.zipObject(['fred', 'barney'], [30, 40]); + * // => { 'fred': 30, 'barney': 40 } + */ +function zipObject(props, values) { + var index = -1, + length = props ? props.length : 0, + result = {}; + + if (length && !values && !isArray(props[0])) { + values = []; + } + while (++index < length) { + var key = props[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; +} + +module.exports = zipObject; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipWith.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipWith.js new file mode 100644 index 0000000..ad10374 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/array/zipWith.js @@ -0,0 +1,36 @@ +var restParam = require('../function/restParam'), + unzipWith = require('./unzipWith'); + +/** + * This method is like `_.zip` except that it accepts an iteratee to specify + * how grouped values should be combined. The `iteratee` is bound to `thisArg` + * and invoked with four arguments: (accumulator, value, index, group). + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee] The function to combine grouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zipWith([1, 2], [10, 20], [100, 200], _.add); + * // => [111, 222] + */ +var zipWith = restParam(function(arrays) { + var length = arrays.length, + iteratee = length > 2 ? arrays[length - 2] : undefined, + thisArg = length > 1 ? arrays[length - 1] : undefined; + + if (length > 2 && typeof iteratee == 'function') { + length -= 2; + } else { + iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined; + thisArg = undefined; + } + arrays.length = length; + return unzipWith(arrays, iteratee, thisArg); +}); + +module.exports = zipWith; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain.js new file mode 100644 index 0000000..6439627 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain.js @@ -0,0 +1,16 @@ +module.exports = { + 'chain': require('./chain/chain'), + 'commit': require('./chain/commit'), + 'concat': require('./chain/concat'), + 'lodash': require('./chain/lodash'), + 'plant': require('./chain/plant'), + 'reverse': require('./chain/reverse'), + 'run': require('./chain/run'), + 'tap': require('./chain/tap'), + 'thru': require('./chain/thru'), + 'toJSON': require('./chain/toJSON'), + 'toString': require('./chain/toString'), + 'value': require('./chain/value'), + 'valueOf': require('./chain/valueOf'), + 'wrapperChain': require('./chain/wrapperChain') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/chain.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/chain.js new file mode 100644 index 0000000..453ba1e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/chain.js @@ -0,0 +1,35 @@ +var lodash = require('./lodash'); + +/** + * Creates a `lodash` object that wraps `value` with explicit method + * chaining enabled. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; + * + * var youngest = _.chain(users) + * .sortBy('age') + * .map(function(chr) { + * return chr.user + ' is ' + chr.age; + * }) + * .first() + * .value(); + * // => 'pebbles is 1' + */ +function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; +} + +module.exports = chain; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/commit.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/commit.js new file mode 100644 index 0000000..c732d1b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/commit.js @@ -0,0 +1 @@ +module.exports = require('./wrapperCommit'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/concat.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/concat.js new file mode 100644 index 0000000..90607d1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/concat.js @@ -0,0 +1 @@ +module.exports = require('./wrapperConcat'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/lodash.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/lodash.js new file mode 100644 index 0000000..1c3467e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/lodash.js @@ -0,0 +1,125 @@ +var LazyWrapper = require('../internal/LazyWrapper'), + LodashWrapper = require('../internal/LodashWrapper'), + baseLodash = require('../internal/baseLodash'), + isArray = require('../lang/isArray'), + isObjectLike = require('../internal/isObjectLike'), + wrapperClone = require('../internal/wrapperClone'); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Creates a `lodash` object which wraps `value` to enable implicit chaining. + * Methods that operate on and return arrays, collections, and functions can + * be chained together. Methods that retrieve a single value or may return a + * primitive value will automatically end the chain returning the unwrapped + * value. Explicit chaining may be enabled using `_.chain`. The execution of + * chained methods is lazy, that is, execution is deferred until `_#value` + * is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. Shortcut + * fusion is an optimization strategy which merge iteratee calls; this can help + * to avoid the creation of intermediate data structures and greatly reduce the + * number of iteratee executions. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, + * `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, + * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, + * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, + * and `where` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, + * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, + * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, + * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, + * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, + * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, + * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, + * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, + * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, + * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, + * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, + * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, + * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, + * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, + * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, + * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, + * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, + * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, + * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, + * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, + * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, + * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, + * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, + * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, + * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, + * `unescape`, `uniqueId`, `value`, and `words` + * + * The wrapper method `sample` will return a wrapped value when `n` is provided, + * otherwise an unwrapped value is returned. + * + * @name _ + * @constructor + * @category Chain + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var wrapped = _([1, 2, 3]); + * + * // returns an unwrapped value + * wrapped.reduce(function(total, n) { + * return total + n; + * }); + * // => 6 + * + * // returns a wrapped value + * var squares = wrapped.map(function(n) { + * return n * n; + * }); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ +function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); +} + +// Ensure wrappers are instances of `baseLodash`. +lodash.prototype = baseLodash.prototype; + +module.exports = lodash; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/plant.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/plant.js new file mode 100644 index 0000000..04099f2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/plant.js @@ -0,0 +1 @@ +module.exports = require('./wrapperPlant'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/reverse.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/reverse.js new file mode 100644 index 0000000..f72a64a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/reverse.js @@ -0,0 +1 @@ +module.exports = require('./wrapperReverse'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/run.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/run.js new file mode 100644 index 0000000..5e751a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/run.js @@ -0,0 +1 @@ +module.exports = require('./wrapperValue'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/tap.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/tap.js new file mode 100644 index 0000000..3d0257e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/tap.js @@ -0,0 +1,29 @@ +/** + * This method invokes `interceptor` and returns `value`. The interceptor is + * bound to `thisArg` and invoked with one argument; (value). The purpose of + * this method is to "tap into" a method chain in order to perform operations + * on intermediate results within the chain. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @param {*} [thisArg] The `this` binding of `interceptor`. + * @returns {*} Returns `value`. + * @example + * + * _([1, 2, 3]) + * .tap(function(array) { + * array.pop(); + * }) + * .reverse() + * .value(); + * // => [2, 1] + */ +function tap(value, interceptor, thisArg) { + interceptor.call(thisArg, value); + return value; +} + +module.exports = tap; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/thru.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/thru.js new file mode 100644 index 0000000..a715780 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/thru.js @@ -0,0 +1,26 @@ +/** + * This method is like `_.tap` except that it returns the result of `interceptor`. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @param {*} [thisArg] The `this` binding of `interceptor`. + * @returns {*} Returns the result of `interceptor`. + * @example + * + * _(' abc ') + * .chain() + * .trim() + * .thru(function(value) { + * return [value]; + * }) + * .value(); + * // => ['abc'] + */ +function thru(value, interceptor, thisArg) { + return interceptor.call(thisArg, value); +} + +module.exports = thru; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toJSON.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toJSON.js new file mode 100644 index 0000000..5e751a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toJSON.js @@ -0,0 +1 @@ +module.exports = require('./wrapperValue'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toString.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toString.js new file mode 100644 index 0000000..c7bcbf9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/toString.js @@ -0,0 +1 @@ +module.exports = require('./wrapperToString'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/value.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/value.js new file mode 100644 index 0000000..5e751a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/value.js @@ -0,0 +1 @@ +module.exports = require('./wrapperValue'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/valueOf.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/valueOf.js new file mode 100644 index 0000000..5e751a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/valueOf.js @@ -0,0 +1 @@ +module.exports = require('./wrapperValue'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperChain.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperChain.js new file mode 100644 index 0000000..3823481 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperChain.js @@ -0,0 +1,32 @@ +var chain = require('./chain'); + +/** + * Enables explicit method chaining on the wrapper object. + * + * @name chain + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * // without explicit chaining + * _(users).first(); + * // => { 'user': 'barney', 'age': 36 } + * + * // with explicit chaining + * _(users).chain() + * .first() + * .pick('user') + * .value(); + * // => { 'user': 'barney' } + */ +function wrapperChain() { + return chain(this); +} + +module.exports = wrapperChain; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperCommit.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperCommit.js new file mode 100644 index 0000000..c3d2898 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperCommit.js @@ -0,0 +1,32 @@ +var LodashWrapper = require('../internal/LodashWrapper'); + +/** + * Executes the chained sequence and returns the wrapped result. + * + * @name commit + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).push(3); + * + * console.log(array); + * // => [1, 2] + * + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] + * + * wrapped.last(); + * // => 3 + * + * console.log(array); + * // => [1, 2, 3] + */ +function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); +} + +module.exports = wrapperCommit; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperConcat.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperConcat.js new file mode 100644 index 0000000..799156c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperConcat.js @@ -0,0 +1,34 @@ +var arrayConcat = require('../internal/arrayConcat'), + baseFlatten = require('../internal/baseFlatten'), + isArray = require('../lang/isArray'), + restParam = require('../function/restParam'), + toObject = require('../internal/toObject'); + +/** + * Creates a new array joining a wrapped array with any additional arrays + * and/or values. + * + * @name concat + * @memberOf _ + * @category Chain + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var wrapped = _(array).concat(2, [3], [[4]]); + * + * console.log(wrapped.value()); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ +var wrapperConcat = restParam(function(values) { + values = baseFlatten(values); + return this.thru(function(array) { + return arrayConcat(isArray(array) ? array : [toObject(array)], values); + }); +}); + +module.exports = wrapperConcat; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperPlant.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperPlant.js new file mode 100644 index 0000000..234fe41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperPlant.js @@ -0,0 +1,45 @@ +var baseLodash = require('../internal/baseLodash'), + wrapperClone = require('../internal/wrapperClone'); + +/** + * Creates a clone of the chained sequence planting `value` as the wrapped value. + * + * @name plant + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).map(function(value) { + * return Math.pow(value, 2); + * }); + * + * var other = [3, 4]; + * var otherWrapped = wrapped.plant(other); + * + * otherWrapped.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] + */ +function wrapperPlant(value) { + var result, + parent = this; + + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; +} + +module.exports = wrapperPlant; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperReverse.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperReverse.js new file mode 100644 index 0000000..f2b3d19 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperReverse.js @@ -0,0 +1,43 @@ +var LazyWrapper = require('../internal/LazyWrapper'), + LodashWrapper = require('../internal/LodashWrapper'), + thru = require('./thru'); + +/** + * Reverses the wrapped array so the first element becomes the last, the + * second element becomes the second to last, and so on. + * + * **Note:** This method mutates the wrapped array. + * + * @name reverse + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new reversed `lodash` wrapper instance. + * @example + * + * var array = [1, 2, 3]; + * + * _(array).reverse().value() + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ +function wrapperReverse() { + var value = this.__wrapped__; + + var interceptor = function(value) { + return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse(); + }; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(interceptor); +} + +module.exports = wrapperReverse; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperToString.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperToString.js new file mode 100644 index 0000000..db975a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperToString.js @@ -0,0 +1,17 @@ +/** + * Produces the result of coercing the unwrapped value to a string. + * + * @name toString + * @memberOf _ + * @category Chain + * @returns {string} Returns the coerced string value. + * @example + * + * _([1, 2, 3]).toString(); + * // => '1,2,3' + */ +function wrapperToString() { + return (this.value() + ''); +} + +module.exports = wrapperToString; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperValue.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperValue.js new file mode 100644 index 0000000..2734e41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/chain/wrapperValue.js @@ -0,0 +1,20 @@ +var baseWrapperValue = require('../internal/baseWrapperValue'); + +/** + * Executes the chained sequence to extract the unwrapped value. + * + * @name value + * @memberOf _ + * @alias run, toJSON, valueOf + * @category Chain + * @returns {*} Returns the resolved unwrapped value. + * @example + * + * _([1, 2, 3]).value(); + * // => [1, 2, 3] + */ +function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); +} + +module.exports = wrapperValue; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection.js new file mode 100644 index 0000000..0338857 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection.js @@ -0,0 +1,44 @@ +module.exports = { + 'all': require('./collection/all'), + 'any': require('./collection/any'), + 'at': require('./collection/at'), + 'collect': require('./collection/collect'), + 'contains': require('./collection/contains'), + 'countBy': require('./collection/countBy'), + 'detect': require('./collection/detect'), + 'each': require('./collection/each'), + 'eachRight': require('./collection/eachRight'), + 'every': require('./collection/every'), + 'filter': require('./collection/filter'), + 'find': require('./collection/find'), + 'findLast': require('./collection/findLast'), + 'findWhere': require('./collection/findWhere'), + 'foldl': require('./collection/foldl'), + 'foldr': require('./collection/foldr'), + 'forEach': require('./collection/forEach'), + 'forEachRight': require('./collection/forEachRight'), + 'groupBy': require('./collection/groupBy'), + 'include': require('./collection/include'), + 'includes': require('./collection/includes'), + 'indexBy': require('./collection/indexBy'), + 'inject': require('./collection/inject'), + 'invoke': require('./collection/invoke'), + 'map': require('./collection/map'), + 'max': require('./math/max'), + 'min': require('./math/min'), + 'partition': require('./collection/partition'), + 'pluck': require('./collection/pluck'), + 'reduce': require('./collection/reduce'), + 'reduceRight': require('./collection/reduceRight'), + 'reject': require('./collection/reject'), + 'sample': require('./collection/sample'), + 'select': require('./collection/select'), + 'shuffle': require('./collection/shuffle'), + 'size': require('./collection/size'), + 'some': require('./collection/some'), + 'sortBy': require('./collection/sortBy'), + 'sortByAll': require('./collection/sortByAll'), + 'sortByOrder': require('./collection/sortByOrder'), + 'sum': require('./math/sum'), + 'where': require('./collection/where') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/all.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/all.js new file mode 100644 index 0000000..d0839f7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/all.js @@ -0,0 +1 @@ +module.exports = require('./every'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/any.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/any.js new file mode 100644 index 0000000..900ac25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/any.js @@ -0,0 +1 @@ +module.exports = require('./some'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/at.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/at.js new file mode 100644 index 0000000..29236e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/at.js @@ -0,0 +1,29 @@ +var baseAt = require('../internal/baseAt'), + baseFlatten = require('../internal/baseFlatten'), + restParam = require('../function/restParam'); + +/** + * Creates an array of elements corresponding to the given keys, or indexes, + * of `collection`. Keys may be specified as individual arguments or as arrays + * of keys. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(number|number[]|string|string[])} [props] The property names + * or indexes of elements to pick, specified individually or in arrays. + * @returns {Array} Returns the new array of picked elements. + * @example + * + * _.at(['a', 'b', 'c'], [0, 2]); + * // => ['a', 'c'] + * + * _.at(['barney', 'fred', 'pebbles'], 0, 2); + * // => ['barney', 'pebbles'] + */ +var at = restParam(function(collection, props) { + return baseAt(collection, baseFlatten(props)); +}); + +module.exports = at; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/collect.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/collect.js new file mode 100644 index 0000000..0d1e1ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/collect.js @@ -0,0 +1 @@ +module.exports = require('./map'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/contains.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/contains.js new file mode 100644 index 0000000..594722a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/contains.js @@ -0,0 +1 @@ +module.exports = require('./includes'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/countBy.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/countBy.js new file mode 100644 index 0000000..e97dbb7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/countBy.js @@ -0,0 +1,54 @@ +var createAggregator = require('../internal/createAggregator'); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); + * // => { '4': 1, '6': 2 } + * + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); + * // => { '4': 1, '6': 2 } + * + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } + */ +var countBy = createAggregator(function(result, value, key) { + hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1); +}); + +module.exports = countBy; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/detect.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/detect.js new file mode 100644 index 0000000..2fb6303 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/detect.js @@ -0,0 +1 @@ +module.exports = require('./find'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/each.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/each.js new file mode 100644 index 0000000..8800f42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/each.js @@ -0,0 +1 @@ +module.exports = require('./forEach'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/eachRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/eachRight.js new file mode 100644 index 0000000..3252b2a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/eachRight.js @@ -0,0 +1 @@ +module.exports = require('./forEachRight'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/every.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/every.js new file mode 100644 index 0000000..5a2d0f5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/every.js @@ -0,0 +1,66 @@ +var arrayEvery = require('../internal/arrayEvery'), + baseCallback = require('../internal/baseCallback'), + baseEvery = require('../internal/baseEvery'), + isArray = require('../lang/isArray'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * The predicate is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias all + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.every(users, 'active', false); + * // => true + * + * // using the `_.property` callback shorthand + * _.every(users, 'active'); + * // => false + */ +function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != 'function' || thisArg !== undefined) { + predicate = baseCallback(predicate, thisArg, 3); + } + return func(collection, predicate); +} + +module.exports = every; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/filter.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/filter.js new file mode 100644 index 0000000..7620aa7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/filter.js @@ -0,0 +1,61 @@ +var arrayFilter = require('../internal/arrayFilter'), + baseCallback = require('../internal/baseCallback'), + baseFilter = require('../internal/baseFilter'), + isArray = require('../lang/isArray'); + +/** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is bound to `thisArg` and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias select + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new filtered array. + * @example + * + * _.filter([4, 5, 6], function(n) { + * return n % 2 == 0; + * }); + * // => [4, 6] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.filter(users, 'active', false), 'user'); + * // => ['fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.filter(users, 'active'), 'user'); + * // => ['barney'] + */ +function filter(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = baseCallback(predicate, thisArg, 3); + return func(collection, predicate); +} + +module.exports = filter; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/find.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/find.js new file mode 100644 index 0000000..7358cfe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/find.js @@ -0,0 +1,56 @@ +var baseEach = require('../internal/baseEach'), + createFind = require('../internal/createFind'); + +/** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias detect + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.result(_.find(users, function(chr) { + * return chr.age < 40; + * }), 'user'); + * // => 'barney' + * + * // using the `_.matches` callback shorthand + * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); + * // => 'pebbles' + * + * // using the `_.matchesProperty` callback shorthand + * _.result(_.find(users, 'active', false), 'user'); + * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.result(_.find(users, 'active'), 'user'); + * // => 'barney' + */ +var find = createFind(baseEach); + +module.exports = find; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findLast.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findLast.js new file mode 100644 index 0000000..75dbadc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findLast.js @@ -0,0 +1,25 @@ +var baseEachRight = require('../internal/baseEachRight'), + createFind = require('../internal/createFind'); + +/** + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 + */ +var findLast = createFind(baseEachRight, true); + +module.exports = findLast; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findWhere.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findWhere.js new file mode 100644 index 0000000..2d62065 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/findWhere.js @@ -0,0 +1,37 @@ +var baseMatches = require('../internal/baseMatches'), + find = require('./find'); + +/** + * Performs a deep comparison between each element in `collection` and the + * source object, returning the first element that has equivalent property + * values. + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Object} source The object of property values to match. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); + * // => 'barney' + * + * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); + * // => 'fred' + */ +function findWhere(collection, source) { + return find(collection, baseMatches(source)); +} + +module.exports = findWhere; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldl.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldl.js new file mode 100644 index 0000000..26f53cf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldl.js @@ -0,0 +1 @@ +module.exports = require('./reduce'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldr.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldr.js new file mode 100644 index 0000000..8fb199e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/foldr.js @@ -0,0 +1 @@ +module.exports = require('./reduceRight'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEach.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEach.js new file mode 100644 index 0000000..05a8e21 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEach.js @@ -0,0 +1,37 @@ +var arrayEach = require('../internal/arrayEach'), + baseEach = require('../internal/baseEach'), + createForEach = require('../internal/createForEach'); + +/** + * Iterates over elements of `collection` invoking `iteratee` for each element. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). Iteratee functions may exit iteration early + * by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" property + * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` + * may be used for object iteration. + * + * @static + * @memberOf _ + * @alias each + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2]).forEach(function(n) { + * console.log(n); + * }).value(); + * // => logs each value from left to right and returns the array + * + * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + * console.log(n, key); + * }); + * // => logs each value-key pair and returns the object (iteration order is not guaranteed) + */ +var forEach = createForEach(arrayEach, baseEach); + +module.exports = forEach; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEachRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEachRight.js new file mode 100644 index 0000000..3499711 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/forEachRight.js @@ -0,0 +1,26 @@ +var arrayEachRight = require('../internal/arrayEachRight'), + baseEachRight = require('../internal/baseEachRight'), + createForEach = require('../internal/createForEach'); + +/** + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @alias eachRight + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2]).forEachRight(function(n) { + * console.log(n); + * }).value(); + * // => logs each value from right to left and returns the array + */ +var forEachRight = createForEach(arrayEachRight, baseEachRight); + +module.exports = forEachRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/groupBy.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/groupBy.js new file mode 100644 index 0000000..a925c89 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/groupBy.js @@ -0,0 +1,59 @@ +var createAggregator = require('../internal/createAggregator'); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is an array of the elements responsible for generating the key. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * // using the `_.property` callback shorthand + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } + */ +var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + result[key] = [value]; + } +}); + +module.exports = groupBy; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/include.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/include.js new file mode 100644 index 0000000..594722a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/include.js @@ -0,0 +1 @@ +module.exports = require('./includes'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/includes.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/includes.js new file mode 100644 index 0000000..482e42d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/includes.js @@ -0,0 +1,57 @@ +var baseIndexOf = require('../internal/baseIndexOf'), + getLength = require('../internal/getLength'), + isArray = require('../lang/isArray'), + isIterateeCall = require('../internal/isIterateeCall'), + isLength = require('../internal/isLength'), + isString = require('../lang/isString'), + values = require('../object/values'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * Checks if `value` is in `collection` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of `collection`. + * + * @static + * @memberOf _ + * @alias contains, include + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {*} target The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. + * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.includes('pebbles', 'eb'); + * // => true + */ +function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + } + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) + : (!!length && baseIndexOf(collection, target, fromIndex) > -1); +} + +module.exports = includes; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/indexBy.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/indexBy.js new file mode 100644 index 0000000..34a941e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/indexBy.js @@ -0,0 +1,53 @@ +var createAggregator = require('../internal/createAggregator'); + +/** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the last element responsible for generating the key. The + * iteratee function is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var keyData = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.indexBy(keyData, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keyData, function(object) { + * return String.fromCharCode(object.code); + * }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keyData, function(object) { + * return this.fromCharCode(object.code); + * }, String); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + */ +var indexBy = createAggregator(function(result, value, key) { + result[key] = value; +}); + +module.exports = indexBy; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/inject.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/inject.js new file mode 100644 index 0000000..26f53cf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/inject.js @@ -0,0 +1 @@ +module.exports = require('./reduce'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/invoke.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/invoke.js new file mode 100644 index 0000000..a1f8a20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/invoke.js @@ -0,0 +1,42 @@ +var baseEach = require('../internal/baseEach'), + invokePath = require('../internal/invokePath'), + isArrayLike = require('../internal/isArrayLike'), + isKey = require('../internal/isKey'), + restParam = require('../function/restParam'); + +/** + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `methodName` is a function it is + * invoked for, and `this` bound to, each element in `collection`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {Array} Returns the array of results. + * @example + * + * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invoke([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] + */ +var invoke = restParam(function(collection, path, args) { + var index = -1, + isFunc = typeof path == 'function', + isProp = isKey(path), + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value) { + var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); + result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + }); + return result; +}); + +module.exports = invoke; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/map.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/map.js new file mode 100644 index 0000000..5381110 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/map.js @@ -0,0 +1,68 @@ +var arrayMap = require('../internal/arrayMap'), + baseCallback = require('../internal/baseCallback'), + baseMap = require('../internal/baseMap'), + isArray = require('../lang/isArray'); + +/** + * Creates an array of values by running each element in `collection` through + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three + * arguments: (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, + * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, + * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, + * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, + * `sum`, `uniq`, and `words` + * + * @static + * @memberOf _ + * @alias collect + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new mapped array. + * @example + * + * function timesThree(n) { + * return n * 3; + * } + * + * _.map([1, 2], timesThree); + * // => [3, 6] + * + * _.map({ 'a': 1, 'b': 2 }, timesThree); + * // => [3, 6] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // using the `_.property` callback shorthand + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ +function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = baseCallback(iteratee, thisArg, 3); + return func(collection, iteratee); +} + +module.exports = map; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/max.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/max.js new file mode 100644 index 0000000..bb1d213 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/max.js @@ -0,0 +1 @@ +module.exports = require('../math/max'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/min.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/min.js new file mode 100644 index 0000000..eef13d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/min.js @@ -0,0 +1 @@ +module.exports = require('../math/min'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/partition.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/partition.js new file mode 100644 index 0000000..ee35f27 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/partition.js @@ -0,0 +1,66 @@ +var createAggregator = require('../internal/createAggregator'); + +/** + * Creates an array of elements split into two groups, the first of which + * contains elements `predicate` returns truthy for, while the second of which + * contains elements `predicate` returns falsey for. The predicate is bound + * to `thisArg` and invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the array of grouped elements. + * @example + * + * _.partition([1, 2, 3], function(n) { + * return n % 2; + * }); + * // => [[1, 3], [2]] + * + * _.partition([1.2, 2.3, 3.4], function(n) { + * return this.floor(n) % 2; + * }, Math); + * // => [[1.2, 3.4], [2.3]] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true }, + * { 'user': 'pebbles', 'age': 1, 'active': false } + * ]; + * + * var mapper = function(array) { + * return _.pluck(array, 'user'); + * }; + * + * // using the `_.matches` callback shorthand + * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); + * // => [['pebbles'], ['barney', 'fred']] + * + * // using the `_.matchesProperty` callback shorthand + * _.map(_.partition(users, 'active', false), mapper); + * // => [['barney', 'pebbles'], ['fred']] + * + * // using the `_.property` callback shorthand + * _.map(_.partition(users, 'active'), mapper); + * // => [['fred'], ['barney', 'pebbles']] + */ +var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); +}, function() { return [[], []]; }); + +module.exports = partition; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/pluck.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/pluck.js new file mode 100644 index 0000000..5ee1ec8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/pluck.js @@ -0,0 +1,31 @@ +var map = require('./map'), + property = require('../utility/property'); + +/** + * Gets the property value of `path` from all elements in `collection`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|string} path The path of the property to pluck. + * @returns {Array} Returns the property values. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.pluck(users, 'user'); + * // => ['barney', 'fred'] + * + * var userIndex = _.indexBy(users, 'user'); + * _.pluck(userIndex, 'age'); + * // => [36, 40] (iteration order is not guaranteed) + */ +function pluck(collection, path) { + return map(collection, property(path)); +} + +module.exports = pluck; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduce.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduce.js new file mode 100644 index 0000000..5d5e8c9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduce.js @@ -0,0 +1,44 @@ +var arrayReduce = require('../internal/arrayReduce'), + baseEach = require('../internal/baseEach'), + createReduce = require('../internal/createReduce'); + +/** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` through `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not provided the first element of `collection` is used as the initial + * value. The `iteratee` is bound to `thisArg` and invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, + * and `sortByOrder` + * + * @static + * @memberOf _ + * @alias foldl, inject + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * _.reduce([1, 2], function(total, n) { + * return total + n; + * }); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { + * result[key] = n * 3; + * return result; + * }, {}); + * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) + */ +var reduce = createReduce(arrayReduce, baseEach); + +module.exports = reduce; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduceRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduceRight.js new file mode 100644 index 0000000..5a5753b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reduceRight.js @@ -0,0 +1,29 @@ +var arrayReduceRight = require('../internal/arrayReduceRight'), + baseEachRight = require('../internal/baseEachRight'), + createReduce = require('../internal/createReduce'); + +/** + * This method is like `_.reduce` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @alias foldr + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * var array = [[0, 1], [2, 3], [4, 5]]; + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); + * // => [4, 5, 2, 3, 0, 1] + */ +var reduceRight = createReduce(arrayReduceRight, baseEachRight); + +module.exports = reduceRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reject.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reject.js new file mode 100644 index 0000000..5592453 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/reject.js @@ -0,0 +1,50 @@ +var arrayFilter = require('../internal/arrayFilter'), + baseCallback = require('../internal/baseCallback'), + baseFilter = require('../internal/baseFilter'), + isArray = require('../lang/isArray'); + +/** + * The opposite of `_.filter`; this method returns the elements of `collection` + * that `predicate` does **not** return truthy for. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new filtered array. + * @example + * + * _.reject([1, 2, 3, 4], function(n) { + * return n % 2 == 0; + * }); + * // => [1, 3] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.reject(users, 'active', false), 'user'); + * // => ['fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.reject(users, 'active'), 'user'); + * // => ['barney'] + */ +function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = baseCallback(predicate, thisArg, 3); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); +} + +module.exports = reject; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sample.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sample.js new file mode 100644 index 0000000..8e01533 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sample.js @@ -0,0 +1,50 @@ +var baseRandom = require('../internal/baseRandom'), + isIterateeCall = require('../internal/isIterateeCall'), + toArray = require('../lang/toArray'), + toIterable = require('../internal/toIterable'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * Gets a random element or `n` random elements from a collection. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to sample. + * @param {number} [n] The number of elements to sample. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {*} Returns the random sample(s). + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + * + * _.sample([1, 2, 3, 4], 2); + * // => [3, 1] + */ +function sample(collection, n, guard) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { + collection = toIterable(collection); + var length = collection.length; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; + } + var index = -1, + result = toArray(collection), + length = result.length, + lastIndex = length - 1; + + n = nativeMin(n < 0 ? 0 : (+n || 0), length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), + value = result[rand]; + + result[rand] = result[index]; + result[index] = value; + } + result.length = n; + return result; +} + +module.exports = sample; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/select.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/select.js new file mode 100644 index 0000000..ade80f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/select.js @@ -0,0 +1 @@ +module.exports = require('./filter'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/shuffle.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/shuffle.js new file mode 100644 index 0000000..949689c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/shuffle.js @@ -0,0 +1,24 @@ +var sample = require('./sample'); + +/** Used as references for `-Infinity` and `Infinity`. */ +var POSITIVE_INFINITY = Number.POSITIVE_INFINITY; + +/** + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + * @example + * + * _.shuffle([1, 2, 3, 4]); + * // => [4, 1, 3, 2] + */ +function shuffle(collection) { + return sample(collection, POSITIVE_INFINITY); +} + +module.exports = shuffle; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/size.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/size.js new file mode 100644 index 0000000..78dcf4c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/size.js @@ -0,0 +1,30 @@ +var getLength = require('../internal/getLength'), + isLength = require('../internal/isLength'), + keys = require('../object/keys'); + +/** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable properties for objects. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the size of `collection`. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ +function size(collection) { + var length = collection ? getLength(collection) : 0; + return isLength(length) ? length : keys(collection).length; +} + +module.exports = size; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/some.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/some.js new file mode 100644 index 0000000..d0b09a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/some.js @@ -0,0 +1,67 @@ +var arraySome = require('../internal/arraySome'), + baseCallback = require('../internal/baseCallback'), + baseSome = require('../internal/baseSome'), + isArray = require('../lang/isArray'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Checks if `predicate` returns truthy for **any** element of `collection`. + * The function returns as soon as it finds a passing value and does not iterate + * over the entire collection. The predicate is bound to `thisArg` and invoked + * with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias any + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.some(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.some(users, 'active', false); + * // => true + * + * // using the `_.property` callback shorthand + * _.some(users, 'active'); + * // => true + */ +function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != 'function' || thisArg !== undefined) { + predicate = baseCallback(predicate, thisArg, 3); + } + return func(collection, predicate); +} + +module.exports = some; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortBy.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortBy.js new file mode 100644 index 0000000..4401c77 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortBy.js @@ -0,0 +1,71 @@ +var baseCallback = require('../internal/baseCallback'), + baseMap = require('../internal/baseMap'), + baseSortBy = require('../internal/baseSortBy'), + compareAscending = require('../internal/compareAscending'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection through `iteratee`. This method performs + * a stable sort, that is, it preserves the original sort order of equal elements. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new sorted array. + * @example + * + * _.sortBy([1, 2, 3], function(n) { + * return Math.sin(n); + * }); + * // => [3, 1, 2] + * + * _.sortBy([1, 2, 3], function(n) { + * return this.sin(n); + * }, Math); + * // => [3, 1, 2] + * + * var users = [ + * { 'user': 'fred' }, + * { 'user': 'pebbles' }, + * { 'user': 'barney' } + * ]; + * + * // using the `_.property` callback shorthand + * _.pluck(_.sortBy(users, 'user'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ +function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + var index = -1; + iteratee = baseCallback(iteratee, thisArg, 3); + + var result = baseMap(collection, function(value, key, collection) { + return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; + }); + return baseSortBy(result, compareAscending); +} + +module.exports = sortBy; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByAll.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByAll.js new file mode 100644 index 0000000..4766c20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByAll.js @@ -0,0 +1,52 @@ +var baseFlatten = require('../internal/baseFlatten'), + baseSortByOrder = require('../internal/baseSortByOrder'), + isIterateeCall = require('../internal/isIterateeCall'), + restParam = require('../function/restParam'); + +/** + * This method is like `_.sortBy` except that it can sort by multiple iteratees + * or property names. + * + * If a property name is provided for an iteratee the created `_.property` + * style callback returns the property value of the given element. + * + * If an object is provided for an iteratee the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees + * The iteratees to sort by, specified as individual values or arrays of values. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 42 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.map(_.sortByAll(users, ['user', 'age']), _.values); + * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * + * _.map(_.sortByAll(users, 'user', function(chr) { + * return Math.floor(chr.age / 10); + * }), _.values); + * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + */ +var sortByAll = restParam(function(collection, iteratees) { + if (collection == null) { + return []; + } + var guard = iteratees[2]; + if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { + iteratees.length = 1; + } + return baseSortByOrder(collection, baseFlatten(iteratees), []); +}); + +module.exports = sortByAll; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByOrder.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByOrder.js new file mode 100644 index 0000000..8b4fc19 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sortByOrder.js @@ -0,0 +1,55 @@ +var baseSortByOrder = require('../internal/baseSortByOrder'), + isArray = require('../lang/isArray'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** + * This method is like `_.sortByAll` except that it allows specifying the + * sort orders of the iteratees to sort by. If `orders` is unspecified, all + * values are sorted in ascending order. Otherwise, a value is sorted in + * ascending order if its corresponding order is "asc", and descending if "desc". + * + * If a property name is provided for an iteratee the created `_.property` + * style callback returns the property value of the given element. + * + * If an object is provided for an iteratee the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {boolean[]} [orders] The sort orders of `iteratees`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 42 }, + * { 'user': 'barney', 'age': 36 } + * ]; + * + * // sort by `user` in ascending order and by `age` in descending order + * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); + * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + */ +function sortByOrder(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(iteratees, orders, guard)) { + orders = undefined; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseSortByOrder(collection, iteratees, orders); +} + +module.exports = sortByOrder; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sum.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sum.js new file mode 100644 index 0000000..a2e9380 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/sum.js @@ -0,0 +1 @@ +module.exports = require('../math/sum'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/where.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/where.js new file mode 100644 index 0000000..f603bf8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/collection/where.js @@ -0,0 +1,37 @@ +var baseMatches = require('../internal/baseMatches'), + filter = require('./filter'); + +/** + * Performs a deep comparison between each element in `collection` and the + * source object, returning an array of all elements that have equivalent + * property values. + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Object} source The object of property values to match. + * @returns {Array} Returns the new filtered array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, + * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } + * ]; + * + * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); + * // => ['barney'] + * + * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); + * // => ['fred'] + */ +function where(collection, source) { + return filter(collection, baseMatches(source)); +} + +module.exports = where; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/date.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/date.js new file mode 100644 index 0000000..195366e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/date.js @@ -0,0 +1,3 @@ +module.exports = { + 'now': require('./date/now') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/date/now.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/date/now.js new file mode 100644 index 0000000..ffe3060 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/date/now.js @@ -0,0 +1,24 @@ +var getNative = require('../internal/getNative'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeNow = getNative(Date, 'now'); + +/** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Date + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => logs the number of milliseconds it took for the deferred function to be invoked + */ +var now = nativeNow || function() { + return new Date().getTime(); +}; + +module.exports = now; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function.js new file mode 100644 index 0000000..71f8ebe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function.js @@ -0,0 +1,28 @@ +module.exports = { + 'after': require('./function/after'), + 'ary': require('./function/ary'), + 'backflow': require('./function/backflow'), + 'before': require('./function/before'), + 'bind': require('./function/bind'), + 'bindAll': require('./function/bindAll'), + 'bindKey': require('./function/bindKey'), + 'compose': require('./function/compose'), + 'curry': require('./function/curry'), + 'curryRight': require('./function/curryRight'), + 'debounce': require('./function/debounce'), + 'defer': require('./function/defer'), + 'delay': require('./function/delay'), + 'flow': require('./function/flow'), + 'flowRight': require('./function/flowRight'), + 'memoize': require('./function/memoize'), + 'modArgs': require('./function/modArgs'), + 'negate': require('./function/negate'), + 'once': require('./function/once'), + 'partial': require('./function/partial'), + 'partialRight': require('./function/partialRight'), + 'rearg': require('./function/rearg'), + 'restParam': require('./function/restParam'), + 'spread': require('./function/spread'), + 'throttle': require('./function/throttle'), + 'wrap': require('./function/wrap') +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/after.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/after.js new file mode 100644 index 0000000..e6a5de4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/after.js @@ -0,0 +1,48 @@ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it is called `n` or more times. + * + * @static + * @memberOf _ + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => logs 'done saving!' after the two async saves have completed + */ +function after(n, func) { + if (typeof func != 'function') { + if (typeof n == 'function') { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + n = nativeIsFinite(n = +n) ? n : 0; + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; +} + +module.exports = after; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/ary.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/ary.js new file mode 100644 index 0000000..53a6913 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/ary.js @@ -0,0 +1,34 @@ +var createWrapper = require('../internal/createWrapper'), + isIterateeCall = require('../internal/isIterateeCall'); + +/** Used to compose bitmasks for wrapper metadata. */ +var ARY_FLAG = 128; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * Creates a function that accepts up to `n` arguments ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new function. + * @example + * + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] + */ +function ary(func, n, guard) { + if (guard && isIterateeCall(func, n, guard)) { + n = undefined; + } + n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); + return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); +} + +module.exports = ary; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/backflow.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/backflow.js new file mode 100644 index 0000000..1954e94 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/backflow.js @@ -0,0 +1 @@ +module.exports = require('./flowRight'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/before.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/before.js new file mode 100644 index 0000000..dd1d03b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/before.js @@ -0,0 +1,42 @@ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it is called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @static + * @memberOf _ + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery('#add').on('click', _.before(5, addContactToList)); + * // => allows adding up to 4 contacts to the list + */ +function before(n, func) { + var result; + if (typeof func != 'function') { + if (typeof n == 'function') { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; +} + +module.exports = before; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bind.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bind.js new file mode 100644 index 0000000..0de126a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bind.js @@ -0,0 +1,56 @@ +var createWrapper = require('../internal/createWrapper'), + replaceHolders = require('../internal/replaceHolders'), + restParam = require('./restParam'); + +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + PARTIAL_FLAG = 32; + +/** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and prepends any additional `_.bind` arguments to those provided to the + * bound function. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind` this method does not set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var greet = function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * }; + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // using placeholders + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ +var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); +}); + +// Assign default placeholders. +bind.placeholder = {}; + +module.exports = bind; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindAll.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindAll.js new file mode 100644 index 0000000..a09e948 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindAll.js @@ -0,0 +1,50 @@ +var baseFlatten = require('../internal/baseFlatten'), + createWrapper = require('../internal/createWrapper'), + functions = require('../object/functions'), + restParam = require('./restParam'); + +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1; + +/** + * Binds methods of an object to the object itself, overwriting the existing + * method. Method names may be specified as individual arguments or as arrays + * of method names. If no method names are provided all enumerable function + * properties, own and inherited, of `object` are bound. + * + * **Note:** This method does not set the "length" property of bound functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...(string|string[])} [methodNames] The object method names to bind, + * specified as individual method names or arrays of method names. + * @returns {Object} Returns `object`. + * @example + * + * var view = { + * 'label': 'docs', + * 'onClick': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * _.bindAll(view); + * jQuery('#docs').on('click', view.onClick); + * // => logs 'clicked docs' when the element is clicked + */ +var bindAll = restParam(function(object, methodNames) { + methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); + + var index = -1, + length = methodNames.length; + + while (++index < length) { + var key = methodNames[index]; + object[key] = createWrapper(object[key], BIND_FLAG, object); + } + return object; +}); + +module.exports = bindAll; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindKey.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindKey.js new file mode 100644 index 0000000..b787fe7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/bindKey.js @@ -0,0 +1,66 @@ +var createWrapper = require('../internal/createWrapper'), + replaceHolders = require('../internal/replaceHolders'), + restParam = require('./restParam'); + +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + BIND_KEY_FLAG = 2, + PARTIAL_FLAG = 32; + +/** + * Creates a function that invokes the method at `object[key]` and prepends + * any additional `_.bindKey` arguments to those provided to the bound function. + * + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. + * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. + * + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * @static + * @memberOf _ + * @category Function + * @param {Object} object The object the method belongs to. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * }; + * + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // using placeholders + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ +var bindKey = restParam(function(object, key, partials) { + var bitmask = BIND_FLAG | BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bindKey.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(key, bitmask, object, partials, holders); +}); + +// Assign default placeholders. +bindKey.placeholder = {}; + +module.exports = bindKey; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/compose.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/compose.js new file mode 100644 index 0000000..1954e94 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/compose.js @@ -0,0 +1 @@ +module.exports = require('./flowRight'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curry.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curry.js new file mode 100644 index 0000000..b7db3fd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curry.js @@ -0,0 +1,51 @@ +var createCurry = require('../internal/createCurry'); + +/** Used to compose bitmasks for wrapper metadata. */ +var CURRY_FLAG = 8; + +/** + * Creates a function that accepts one or more arguments of `func` that when + * called either invokes `func` returning its result, if all `func` arguments + * have been provided, or returns a function that accepts one or more of the + * remaining `func` arguments, and so on. The arity of `func` may be specified + * if `func.length` is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method does not set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curry(abc); + * + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // using placeholders + * curried(1)(_, 3)(2); + * // => [1, 2, 3] + */ +var curry = createCurry(CURRY_FLAG); + +// Assign default placeholders. +curry.placeholder = {}; + +module.exports = curry; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curryRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curryRight.js new file mode 100644 index 0000000..11c5403 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/curryRight.js @@ -0,0 +1,48 @@ +var createCurry = require('../internal/createCurry'); + +/** Used to compose bitmasks for wrapper metadata. */ +var CURRY_RIGHT_FLAG = 16; + +/** + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method does not set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curryRight(abc); + * + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // using placeholders + * curried(3)(1, _)(2); + * // => [1, 2, 3] + */ +var curryRight = createCurry(CURRY_RIGHT_FLAG); + +// Assign default placeholders. +curryRight.placeholder = {}; + +module.exports = curryRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/debounce.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/debounce.js new file mode 100644 index 0000000..caf2a69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/debounce.js @@ -0,0 +1,181 @@ +var isObject = require('../lang/isObject'), + now = require('../date/now'); + +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed invocations. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the debounced function return the result of the last + * `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked + * on the trailing edge of the timeout only if the the debounced function is + * invoked more than once during the `wait` timeout. + * + * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=false] Specify invoking on the leading + * edge of the timeout. + * @param {number} [options.maxWait] The maximum time `func` is allowed to be + * delayed before it is invoked. + * @param {boolean} [options.trailing=true] Specify invoking on the trailing + * edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // avoid costly calculations while the window size is in flux + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // invoke `sendMail` when the click event is fired, debouncing subsequent calls + * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // ensure `batchLog` is invoked once after 1 second of debounced calls + * var source = new EventSource('/stream'); + * jQuery(source).on('message', _.debounce(batchLog, 250, { + * 'maxWait': 1000 + * })); + * + * // cancel a debounced call + * var todoChanges = _.debounce(batchLog, 1000); + * Object.observe(models.todo, todoChanges); + * + * Object.observe(models, function(changes) { + * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { + * todoChanges.cancel(); + * } + * }, ['delete']); + * + * // ...at some point `models.todo` is changed + * models.todo.completed = true; + * + * // ...before 1 second has passed `models.todo` is deleted + * // which cancels the debounced `todoChanges` call + * delete models.todo; + */ +function debounce(func, wait, options) { + var args, + maxTimeoutId, + result, + stamp, + thisArg, + timeoutId, + trailingCall, + lastCalled = 0, + maxWait = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = wait < 0 ? 0 : (+wait || 0); + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = !!options.leading; + maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + lastCalled = 0; + maxTimeoutId = timeoutId = trailingCall = undefined; + } + + function complete(isCalled, id) { + if (id) { + clearTimeout(id); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + } + } + + function delayed() { + var remaining = wait - (now() - stamp); + if (remaining <= 0 || remaining > wait) { + complete(trailingCall, maxTimeoutId); + } else { + timeoutId = setTimeout(delayed, remaining); + } + } + + function maxDelayed() { + complete(trailing, timeoutId); + } + + function debounced() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), + isCalled = remaining <= 0 || remaining > maxWait; + + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } + else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } + else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); + } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + return result; + } + debounced.cancel = cancel; + return debounced; +} + +module.exports = debounce; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/defer.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/defer.js new file mode 100644 index 0000000..369790c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/defer.js @@ -0,0 +1,25 @@ +var baseDelay = require('../internal/baseDelay'), + restParam = require('./restParam'); + +/** + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // logs 'deferred' after one or more milliseconds + */ +var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); +}); + +module.exports = defer; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/delay.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/delay.js new file mode 100644 index 0000000..955b059 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/delay.js @@ -0,0 +1,26 @@ +var baseDelay = require('../internal/baseDelay'), + restParam = require('./restParam'); + +/** + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => logs 'later' after one second + */ +var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); +}); + +module.exports = delay; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flow.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flow.js new file mode 100644 index 0000000..a435a3d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flow.js @@ -0,0 +1,25 @@ +var createFlow = require('../internal/createFlow'); + +/** + * Creates a function that returns the result of invoking the provided + * functions with the `this` binding of the created function, where each + * successive invocation is supplied the return value of the previous. + * + * @static + * @memberOf _ + * @category Function + * @param {...Function} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flow(_.add, square); + * addSquare(1, 2); + * // => 9 + */ +var flow = createFlow(); + +module.exports = flow; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flowRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flowRight.js new file mode 100644 index 0000000..23b9d76 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/flowRight.js @@ -0,0 +1,25 @@ +var createFlow = require('../internal/createFlow'); + +/** + * This method is like `_.flow` except that it creates a function that + * invokes the provided functions from right to left. + * + * @static + * @memberOf _ + * @alias backflow, compose + * @category Function + * @param {...Function} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flowRight(square, _.add); + * addSquare(1, 2); + * // => 9 + */ +var flowRight = createFlow(true); + +module.exports = flowRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/memoize.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/memoize.js new file mode 100644 index 0000000..f3b8d69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/memoize.js @@ -0,0 +1,80 @@ +var MapCache = require('../internal/MapCache'); + +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is coerced to a string and used as the + * cache key. The `func` is invoked with the `this` binding of the memoized + * function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * method interface of `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoizing function. + * @example + * + * var upperCase = _.memoize(function(string) { + * return string.toUpperCase(); + * }); + * + * upperCase('fred'); + * // => 'FRED' + * + * // modifying the result cache + * upperCase.cache.set('fred', 'BARNEY'); + * upperCase('fred'); + * // => 'BARNEY' + * + * // replacing `_.memoize.Cache` + * var object = { 'user': 'fred' }; + * var other = { 'user': 'barney' }; + * var identity = _.memoize(_.identity); + * + * identity(object); + * // => { 'user': 'fred' } + * identity(other); + * // => { 'user': 'fred' } + * + * _.memoize.Cache = WeakMap; + * var identity = _.memoize(_.identity); + * + * identity(object); + * // => { 'user': 'fred' } + * identity(other); + * // => { 'user': 'barney' } + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new memoize.Cache; + return memoized; +} + +// Assign cache to `_.memoize`. +memoize.Cache = MapCache; + +module.exports = memoize; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/modArgs.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/modArgs.js new file mode 100644 index 0000000..49b9b5e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/modArgs.js @@ -0,0 +1,58 @@ +var arrayEvery = require('../internal/arrayEvery'), + baseFlatten = require('../internal/baseFlatten'), + baseIsFunction = require('../internal/baseIsFunction'), + restParam = require('./restParam'); + +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * Creates a function that runs each argument through a corresponding + * transform function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms] The functions to transform + * arguments, specified as individual functions or arrays of functions. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var modded = _.modArgs(function(x, y) { + * return [x, y]; + * }, square, doubled); + * + * modded(1, 2); + * // => [1, 4] + * + * modded(5, 10); + * // => [25, 20] + */ +var modArgs = restParam(function(func, transforms) { + transforms = baseFlatten(transforms); + if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = transforms.length; + return restParam(function(args) { + var index = nativeMin(args.length, length); + while (index--) { + args[index] = transforms[index](args[index]); + } + return func.apply(this, args); + }); +}); + +module.exports = modArgs; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/negate.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/negate.js new file mode 100644 index 0000000..8247939 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/negate.js @@ -0,0 +1,32 @@ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ +function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + return !predicate.apply(this, arguments); + }; +} + +module.exports = negate; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/once.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/once.js new file mode 100644 index 0000000..0b5bd85 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/once.js @@ -0,0 +1,24 @@ +var before = require('./before'); + +/** + * Creates a function that is restricted to invoking `func` once. Repeat calls + * to the function return the value of the first call. The `func` is invoked + * with the `this` binding and arguments of the created function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // `initialize` invokes `createApplication` once + */ +function once(func) { + return before(2, func); +} + +module.exports = once; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partial.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partial.js new file mode 100644 index 0000000..fb1d04f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partial.js @@ -0,0 +1,43 @@ +var createPartial = require('../internal/createPartial'); + +/** Used to compose bitmasks for wrapper metadata. */ +var PARTIAL_FLAG = 32; + +/** + * Creates a function that invokes `func` with `partial` arguments prepended + * to those provided to the new function. This method is like `_.bind` except + * it does **not** alter the `this` binding. + * + * The `_.partial.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method does not set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var greet = function(greeting, name) { + * return greeting + ' ' + name; + * }; + * + * var sayHelloTo = _.partial(greet, 'hello'); + * sayHelloTo('fred'); + * // => 'hello fred' + * + * // using placeholders + * var greetFred = _.partial(greet, _, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + */ +var partial = createPartial(PARTIAL_FLAG); + +// Assign default placeholders. +partial.placeholder = {}; + +module.exports = partial; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partialRight.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partialRight.js new file mode 100644 index 0000000..634e6a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/partialRight.js @@ -0,0 +1,42 @@ +var createPartial = require('../internal/createPartial'); + +/** Used to compose bitmasks for wrapper metadata. */ +var PARTIAL_RIGHT_FLAG = 64; + +/** + * This method is like `_.partial` except that partially applied arguments + * are appended to those provided to the new function. + * + * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method does not set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var greet = function(greeting, name) { + * return greeting + ' ' + name; + * }; + * + * var greetFred = _.partialRight(greet, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + * + * // using placeholders + * var sayHelloTo = _.partialRight(greet, 'hello', _); + * sayHelloTo('fred'); + * // => 'hello fred' + */ +var partialRight = createPartial(PARTIAL_RIGHT_FLAG); + +// Assign default placeholders. +partialRight.placeholder = {}; + +module.exports = partialRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/rearg.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/rearg.js new file mode 100644 index 0000000..f2bd9c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/rearg.js @@ -0,0 +1,40 @@ +var baseFlatten = require('../internal/baseFlatten'), + createWrapper = require('../internal/createWrapper'), + restParam = require('./restParam'); + +/** Used to compose bitmasks for wrapper metadata. */ +var REARG_FLAG = 256; + +/** + * Creates a function that invokes `func` with arguments arranged according + * to the specified indexes where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes, + * specified as individual indexes or arrays of indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, 2, 0, 1); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + * + * var map = _.rearg(_.map, [1, 0]); + * map(function(n) { + * return n * 3; + * }, [1, 2, 3]); + * // => [3, 6, 9] + */ +var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); +}); + +module.exports = rearg; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/restParam.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/restParam.js new file mode 100644 index 0000000..3a1c157 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/restParam.js @@ -0,0 +1,58 @@ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as an array. + * + * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.restParam(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ +function restParam(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + rest = Array(length); + + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: return func.call(this, rest); + case 1: return func.call(this, args[0], rest); + case 2: return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; +} + +module.exports = restParam; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/spread.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/spread.js new file mode 100644 index 0000000..aad4b71 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/spread.js @@ -0,0 +1,44 @@ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that invokes `func` with the `this` binding of the created + * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3). + * + * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to spread arguments over. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.spread(function(who, what) { + * return who + ' says ' + what; + * }); + * + * say(['fred', 'hello']); + * // => 'fred says hello' + * + * // with a Promise + * var numbers = Promise.all([ + * Promise.resolve(40), + * Promise.resolve(36) + * ]); + * + * numbers.then(_.spread(function(x, y) { + * return x + y; + * })); + * // => a Promise of 76 + */ +function spread(func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function(array) { + return func.apply(this, array); + }; +} + +module.exports = spread; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/throttle.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/throttle.js new file mode 100644 index 0000000..1dd00ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/throttle.js @@ -0,0 +1,62 @@ +var debounce = require('./debounce'), + isObject = require('../lang/isObject'); + +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed invocations. Provide an options object to indicate + * that `func` should be invoked on the leading and/or trailing edge of the + * `wait` timeout. Subsequent calls to the throttled function return the + * result of the last `func` call. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * + * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=true] Specify invoking on the leading + * edge of the timeout. + * @param {boolean} [options.trailing=true] Specify invoking on the trailing + * edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // avoid excessively updating the position while scrolling + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); + * + * // cancel a trailing throttled call + * jQuery(window).on('popstate', throttled.cancel); + */ +function throttle(func, wait, options) { + var leading = true, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); +} + +module.exports = throttle; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/function/wrap.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/wrap.js new file mode 100644 index 0000000..6a33c5e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/function/wrap.js @@ -0,0 +1,33 @@ +var createWrapper = require('../internal/createWrapper'), + identity = require('../utility/identity'); + +/** Used to compose bitmasks for wrapper metadata. */ +var PARTIAL_FLAG = 32; + +/** + * Creates a function that provides `value` to the wrapper function as its + * first argument. Any additional arguments provided to the function are + * appended to those provided to the wrapper function. The wrapper is invoked + * with the `this` binding of the created function. + * + * @static + * @memberOf _ + * @category Function + * @param {*} value The value to wrap. + * @param {Function} wrapper The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '' + func(text) + ''; + * }); + * + * p('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ +function wrap(value, wrapper) { + wrapper = wrapper == null ? identity : wrapper; + return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []); +} + +module.exports = wrap; diff --git a/JavaScript/node_modules/johnny-five/node_modules/lodash/index.js b/JavaScript/node_modules/johnny-five/node_modules/lodash/index.js new file mode 100644 index 0000000..be768ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/lodash/index.js @@ -0,0 +1,12351 @@ +/** + * @license + * lodash 3.10.0 (Custom Build) + * Build: `lodash modern -d -o ./index.js` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +;(function() { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** Used as the semantic version number. */ + var VERSION = '3.10.0'; + + /** Used to compose bitmasks for wrapper metadata. */ + var BIND_FLAG = 1, + BIND_KEY_FLAG = 2, + CURRY_BOUND_FLAG = 4, + CURRY_FLAG = 8, + CURRY_RIGHT_FLAG = 16, + PARTIAL_FLAG = 32, + PARTIAL_RIGHT_FLAG = 64, + ARY_FLAG = 128, + REARG_FLAG = 256; + + /** Used as default options for `_.trunc`. */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; + + /** Used to detect when a function becomes hot. */ + var HOT_COUNT = 150, + HOT_SPAN = 16; + + /** Used as the size to enable large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Used to indicate the type of lazy iteratees. */ + var LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2; + + /** Used as the `TypeError` message for "Functions" methods. */ + var FUNC_ERROR_TEXT = 'Expected a function'; + + /** Used as the internal argument placeholder. */ + var PLACEHOLDER = '__lodash_placeholder__'; + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; + + var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to match empty string literals in compiled template source. */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + + /** Used to match HTML entities and HTML characters. */ + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, + reUnescapedHtml = /[&<>"'`]/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + + /** Used to match template delimiters. */ + var reEscape = /<%-([\s\S]+?)%>/g, + reEvaluate = /<%([\s\S]+?)%>/g, + reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match property names within property paths. */ + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + + /** + * Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns) + * and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern). + */ + var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, + reHasRegExpChars = RegExp(reRegExpChars.source); + + /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */ + var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g; + + /** Used to match backslashes in property paths. */ + var reEscapeChar = /\\(\\)?/g; + + /** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** Used to detect hexadecimal string values. */ + var reHasHexPrefix = /^0[xX]/; + + /** Used to detect host constructors (Safari > 5). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; + + /** Used to detect unsigned integer values. */ + var reIsUint = /^\d+$/; + + /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ + var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; + + /** Used to ensure capturing order of template delimiters. */ + var reNoMatch = /($^)/; + + /** Used to match unescaped characters in compiled string literals. */ + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + + /** Used to match words to create compound words. */ + var reWords = (function() { + var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', + lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; + + return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); + }()); + + /** Used to assign default `context` object properties. */ + var contextProps = [ + 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', + 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'isFinite', + 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap' + ]; + + /** Used to make template sourceURLs easier to identify. */ + var templateCounter = -1; + + /** Used to identify `toStringTag` values of typed arrays. */ + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = + typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = + typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = + typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = + typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = + typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = + typedArrayTags[dateTag] = typedArrayTags[errorTag] = + typedArrayTags[funcTag] = typedArrayTags[mapTag] = + typedArrayTags[numberTag] = typedArrayTags[objectTag] = + typedArrayTags[regexpTag] = typedArrayTags[setTag] = + typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = + cloneableTags[dateTag] = cloneableTags[float32Tag] = + cloneableTags[float64Tag] = cloneableTags[int8Tag] = + cloneableTags[int16Tag] = cloneableTags[int32Tag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[stringTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[mapTag] = cloneableTags[setTag] = + cloneableTags[weakMapTag] = false; + + /** Used to map latin-1 supplementary letters to basic latin letters. */ + var deburredLetters = { + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss' + }; + + /** Used to map characters to HTML entities. */ + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + /** Used to map HTML entities to characters. */ + var htmlUnescapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'", + '`': '`' + }; + + /** Used to determine if values are of the language type `Object`. */ + var objectTypes = { + 'function': true, + 'object': true + }; + + /** Used to escape characters for inclusion in compiled regexes. */ + var regexpEscapes = { + '0': 'x30', '1': 'x31', '2': 'x32', '3': 'x33', '4': 'x34', + '5': 'x35', '6': 'x36', '7': 'x37', '8': 'x38', '9': 'x39', + 'A': 'x41', 'B': 'x42', 'C': 'x43', 'D': 'x44', 'E': 'x45', 'F': 'x46', + 'a': 'x61', 'b': 'x62', 'c': 'x63', 'd': 'x64', 'e': 'x65', 'f': 'x66', + 'n': 'x6e', 'r': 'x72', 't': 'x74', 'u': 'x75', 'v': 'x76', 'x': 'x78' + }; + + /** Used to escape characters for inclusion in compiled string literals. */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + /** Detect free variable `exports`. */ + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; + + /** Detect free variable `module`. */ + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect free variable `global` from Node.js. */ + var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global; + + /** Detect free variable `self`. */ + var freeSelf = objectTypes[typeof self] && self && self.Object && self; + + /** Detect free variable `window`. */ + var freeWindow = objectTypes[typeof window] && window && window.Object && window; + + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + + /** + * Used as a reference to the global object. + * + * The `this` value is used if it's the global object to avoid Greasemonkey's + * restricted `window` object, otherwise the `window` object is used. + */ + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; + + /*--------------------------------------------------------------------------*/ + + /** + * The base implementation of `compareAscending` which compares values and + * sorts them in ascending order without guaranteeing a stable sort. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ + function baseCompareAscending(value, other) { + if (value !== other) { + var valIsNull = value === null, + valIsUndef = value === undefined, + valIsReflexive = value === value; + + var othIsNull = other === null, + othIsUndef = other === undefined, + othIsReflexive = other === other; + + if ((value > other && !othIsNull) || !valIsReflexive || + (valIsNull && !othIsUndef && othIsReflexive) || + (valIsUndef && othIsReflexive)) { + return 1; + } + if ((value < other && !valIsNull) || !othIsReflexive || + (othIsNull && !valIsUndef && valIsReflexive) || + (othIsUndef && valIsReflexive)) { + return -1; + } + } + return 0; + } + + /** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to search. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseFindIndex(array, predicate, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.indexOf` without support for binary searches. + * + * @private + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.isFunction` without support for environments + * with incorrect `typeof` results. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + */ + function baseIsFunction(value) { + // Avoid a Chakra JIT bug in compatibility modes of IE 11. + // See https://github.com/jashkenas/underscore/issues/1621 for more details. + return typeof value == 'function' || false; + } + + /** + * Converts `value` to a string if it's not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ + function baseToString(value) { + return value == null ? '' : (value + ''); + } + + /** + * Used by `_.trim` and `_.trimLeft` to get the index of the first character + * of `string` that is not found in `chars`. + * + * @private + * @param {string} string The string to inspect. + * @param {string} chars The characters to find. + * @returns {number} Returns the index of the first character not found in `chars`. + */ + function charsLeftIndex(string, chars) { + var index = -1, + length = string.length; + + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + + /** + * Used by `_.trim` and `_.trimRight` to get the index of the last character + * of `string` that is not found in `chars`. + * + * @private + * @param {string} string The string to inspect. + * @param {string} chars The characters to find. + * @returns {number} Returns the index of the last character not found in `chars`. + */ + function charsRightIndex(string, chars) { + var index = string.length; + + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} + return index; + } + + /** + * Used by `_.sortBy` to compare transformed elements of a collection and stable + * sort them in ascending order. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareAscending(object, other) { + return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index); + } + + /** + * Used by `_.sortByOrder` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise, + * a value is sorted in ascending order if its corresponding order is "asc", and + * descending if "desc". + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * ((order === 'asc' || order === true) ? 1 : -1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://code.google.com/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; + } + + /** + * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + function deburrLetter(letter) { + return deburredLetters[letter]; + } + + /** + * Used by `_.escape` to convert characters to HTML entities. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeHtmlChar(chr) { + return htmlEscapes[chr]; + } + + /** + * Used by `_.escapeRegExp` to escape characters for inclusion in compiled regexes. + * + * @private + * @param {string} chr The matched character to escape. + * @param {string} leadingChar The capture group for a leading character. + * @param {string} whitespaceChar The capture group for a whitespace character. + * @returns {string} Returns the escaped character. + */ + function escapeRegExpChar(chr, leadingChar, whitespaceChar) { + if (leadingChar) { + chr = regexpEscapes[chr]; + } else if (whitespaceChar) { + chr = stringEscapes[chr]; + } + return '\\' + chr; + } + + /** + * Used by `_.template` to escape characters for inclusion in compiled string literals. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; + } + + /** + * Gets the index at which the first occurrence of `NaN` is found in `array`. + * + * @private + * @param {Array} array The array to search. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched `NaN`, else `-1`. + */ + function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 0 : -1); + + while ((fromRight ? index-- : ++index < length)) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; + } + + /** + * Checks if `value` is object-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + */ + function isObjectLike(value) { + return !!value && typeof value == 'object'; + } + + /** + * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a + * character code is whitespace. + * + * @private + * @param {number} charCode The character code to inspect. + * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`. + */ + function isSpace(charCode) { + return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 || + (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279))); + } + + /** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ + function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = -1, + result = []; + + while (++index < length) { + if (array[index] === placeholder) { + array[index] = PLACEHOLDER; + result[++resIndex] = index; + } + } + return result; + } + + /** + * An implementation of `_.uniq` optimized for sorted arrays without support + * for callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The function invoked per iteration. + * @returns {Array} Returns the new duplicate-value-free array. + */ + function sortedUniq(array, iteratee) { + var seen, + index = -1, + length = array.length, + resIndex = -1, + result = []; + + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value, index, array) : value; + + if (!index || seen !== computed) { + seen = computed; + result[++resIndex] = value; + } + } + return result; + } + + /** + * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the first non-whitespace character. + */ + function trimmedLeftIndex(string) { + var index = -1, + length = string.length; + + while (++index < length && isSpace(string.charCodeAt(index))) {} + return index; + } + + /** + * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedRightIndex(string) { + var index = string.length; + + while (index-- && isSpace(string.charCodeAt(index))) {} + return index; + } + + /** + * Used by `_.unescape` to convert HTML entities to characters. + * + * @private + * @param {string} chr The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + function unescapeHtmlChar(chr) { + return htmlUnescapes[chr]; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new pristine `lodash` function using the given `context` object. + * + * @static + * @memberOf _ + * @category Utility + * @param {Object} [context=root] The context object. + * @returns {Function} Returns a new `lodash` function. + * @example + * + * _.mixin({ 'foo': _.constant('foo') }); + * + * var lodash = _.runInContext(); + * lodash.mixin({ 'bar': lodash.constant('bar') }); + * + * _.isFunction(_.foo); + * // => true + * _.isFunction(_.bar); + * // => false + * + * lodash.isFunction(lodash.foo); + * // => false + * lodash.isFunction(lodash.bar); + * // => true + * + * // using `context` to mock `Date#getTime` use in `_.now` + * var mock = _.runInContext({ + * 'Date': function() { + * return { 'getTime': getTimeMock }; + * } + * }); + * + * // or creating a suped-up `defer` in Node.js + * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; + */ + function runInContext(context) { + // Avoid issues with some ES3 environments that attempt to use values, named + // after built-in constructors like `Object`, for the creation of literals. + // ES5 clears this up by stating that literals must use built-in constructors. + // See https://es5.github.io/#x11.1.5 for more details. + context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; + + /** Native constructor references. */ + var Array = context.Array, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Number = context.Number, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; + + /** Used for native method references. */ + var arrayProto = Array.prototype, + objectProto = Object.prototype, + stringProto = String.prototype; + + /** Used to resolve the decompiled source of functions. */ + var fnToString = Function.prototype.toString; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** Used to generate unique IDs. */ + var idCounter = 0; + + /** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ + var objToString = objectProto.toString; + + /** Used to restore the original `_` reference in `_.noConflict`. */ + var oldDash = root._; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Native method references. */ + var ArrayBuffer = context.ArrayBuffer, + clearTimeout = context.clearTimeout, + parseFloat = context.parseFloat, + pow = Math.pow, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + Set = getNative(context, 'Set'), + setTimeout = context.setTimeout, + splice = arrayProto.splice, + Uint8Array = context.Uint8Array, + WeakMap = getNative(context, 'WeakMap'); + + /* Native method references for those with the same name as other `lodash` methods. */ + var nativeCeil = Math.ceil, + nativeCreate = getNative(Object, 'create'), + nativeFloor = Math.floor, + nativeIsArray = getNative(Array, 'isArray'), + nativeIsFinite = context.isFinite, + nativeKeys = getNative(Object, 'keys'), + nativeMax = Math.max, + nativeMin = Math.min, + nativeNow = getNative(Date, 'now'), + nativeParseInt = context.parseInt, + nativeRandom = Math.random; + + /** Used as references for `-Infinity` and `Infinity`. */ + var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, + POSITIVE_INFINITY = Number.POSITIVE_INFINITY; + + /** Used as references for the maximum length and index of an array. */ + var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + + /** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ + var MAX_SAFE_INTEGER = 9007199254740991; + + /** Used to store function metadata. */ + var metaMap = WeakMap && new WeakMap; + + /** Used to lookup unminified function names. */ + var realNames = {}; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object which wraps `value` to enable implicit chaining. + * Methods that operate on and return arrays, collections, and functions can + * be chained together. Methods that retrieve a single value or may return a + * primitive value will automatically end the chain returning the unwrapped + * value. Explicit chaining may be enabled using `_.chain`. The execution of + * chained methods is lazy, that is, execution is deferred until `_#value` + * is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. Shortcut + * fusion is an optimization strategy which merge iteratee calls; this can help + * to avoid the creation of intermediate data structures and greatly reduce the + * number of iteratee executions. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, + * `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, + * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, + * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, + * and `where` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, + * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, + * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, + * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, + * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, + * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, + * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, + * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, + * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, + * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, + * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, + * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, + * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, + * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, + * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, + * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, + * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, + * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, + * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, + * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, + * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, + * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, + * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, + * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, + * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, + * `unescape`, `uniqueId`, `value`, and `words` + * + * The wrapper method `sample` will return a wrapped value when `n` is provided, + * otherwise an unwrapped value is returned. + * + * @name _ + * @constructor + * @category Chain + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var wrapped = _([1, 2, 3]); + * + * // returns an unwrapped value + * wrapped.reduce(function(total, n) { + * return total + n; + * }); + * // => 6 + * + * // returns a wrapped value + * var squares = wrapped.map(function(n) { + * return n * n; + * }); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + + /** + * The function whose prototype all chaining wrappers inherit from. + * + * @private + */ + function baseLodash() { + // No operation performed. + } + + /** + * The base constructor for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable chaining for all wrapper methods. + * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. + */ + function LodashWrapper(value, chainAll, actions) { + this.__wrapped__ = value; + this.__actions__ = actions || []; + this.__chain__ = !!chainAll; + } + + /** + * An object environment feature flags. + * + * @static + * @memberOf _ + * @type Object + */ + var support = lodash.support = {}; + + /** + * By default, the template delimiters used by lodash are like those in + * embedded Ruby (ERB). Change the following template settings to use + * alternative delimiters. + * + * @static + * @memberOf _ + * @type Object + */ + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'escape': reEscape, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'evaluate': reEvaluate, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type RegExp + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type string + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type Object + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type Function + */ + '_': lodash + } + }; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. + * + * @private + * @param {*} value The value to wrap. + */ + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = POSITIVE_INFINITY; + this.__views__ = []; + } + + /** + * Creates a clone of the lazy wrapper object. + * + * @private + * @name clone + * @memberOf LazyWrapper + * @returns {Object} Returns the cloned `LazyWrapper` object. + */ + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = arrayCopy(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = arrayCopy(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = arrayCopy(this.__views__); + return result; + } + + /** + * Reverses the direction of lazy iteration. + * + * @private + * @name reverse + * @memberOf LazyWrapper + * @returns {Object} Returns the new reversed `LazyWrapper` object. + */ + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; + } + + /** + * Extracts the unwrapped value from its lazy wrapper. + * + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. + */ + function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) { + return baseWrapperValue((isRight && isArr) ? array.reverse() : array, this.__actions__); + } + var result = []; + + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates a cache object to store key/value pairs. + * + * @private + * @static + * @name Cache + * @memberOf _.memoize + */ + function MapCache() { + this.__data__ = {}; + } + + /** + * Removes `key` and its value from the cache. + * + * @private + * @name delete + * @memberOf _.memoize.Cache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`. + */ + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + + /** + * Gets the cached value for `key`. + * + * @private + * @name get + * @memberOf _.memoize.Cache + * @param {string} key The key of the value to get. + * @returns {*} Returns the cached value. + */ + function mapGet(key) { + return key == '__proto__' ? undefined : this.__data__[key]; + } + + /** + * Checks if a cached value for `key` exists. + * + * @private + * @name has + * @memberOf _.memoize.Cache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function mapHas(key) { + return key != '__proto__' && hasOwnProperty.call(this.__data__, key); + } + + /** + * Sets `value` to `key` of the cache. + * + * @private + * @name set + * @memberOf _.memoize.Cache + * @param {string} key The key of the value to cache. + * @param {*} value The value to cache. + * @returns {Object} Returns the cache object. + */ + function mapSet(key, value) { + if (key != '__proto__') { + this.__data__[key] = value; + } + return this; + } + + /*------------------------------------------------------------------------*/ + + /** + * + * Creates a cache object to store unique values. + * + * @private + * @param {Array} [values] The values to cache. + */ + function SetCache(values) { + var length = values ? values.length : 0; + + this.data = { 'hash': nativeCreate(null), 'set': new Set }; + while (length--) { + this.push(values[length]); + } + } + + /** + * Checks if `value` is in `cache` mimicking the return signature of + * `_.indexOf` by returning `0` if the value is found, else `-1`. + * + * @private + * @param {Object} cache The cache to search. + * @param {*} value The value to search for. + * @returns {number} Returns `0` if `value` is found, else `-1`. + */ + function cacheIndexOf(cache, value) { + var data = cache.data, + result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value]; + + return result ? 0 : -1; + } + + /** + * Adds `value` to the cache. + * + * @private + * @name push + * @memberOf SetCache + * @param {*} value The value to cache. + */ + function cachePush(value) { + var data = this.data; + if (typeof value == 'string' || isObject(value)) { + data.set.add(value); + } else { + data.hash[value] = true; + } + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates a new array joining `array` with `other`. + * + * @private + * @param {Array} array The array to join. + * @param {Array} other The other array to join. + * @returns {Array} Returns the new concatenated array. + */ + function arrayConcat(array, other) { + var index = -1, + length = array.length, + othIndex = -1, + othLength = other.length, + result = Array(length + othLength); + + while (++index < length) { + result[index] = array[index]; + } + while (++othIndex < othLength) { + result[index++] = other[othIndex]; + } + return result; + } + + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function arrayCopy(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * A specialized version of `_.forEach` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.forEachRight` for arrays without support for + * callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEachRight(array, iteratee) { + var length = array.length; + + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.every` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ + function arrayEvery(array, predicate) { + var index = -1, + length = array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + + /** + * A specialized version of `baseExtremum` for arrays which invokes `iteratee` + * with one argument: (value). + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. + * @returns {*} Returns the extremum value. + */ + function arrayExtremum(array, iteratee, comparator, exValue) { + var index = -1, + length = array.length, + computed = exValue, + result = computed; + + while (++index < length) { + var value = array[index], + current = +iteratee(value); + + if (comparator(current, computed)) { + computed = current; + result = value; + } + } + return result; + } + + /** + * A specialized version of `_.filter` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function arrayFilter(array, predicate) { + var index = -1, + length = array.length, + resIndex = -1, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[++resIndex] = value; + } + } + return result; + } + + /** + * A specialized version of `_.map` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + + /** + * A specialized version of `_.reduce` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initFromArray] Specify using the first element of `array` + * as the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initFromArray) { + var index = -1, + length = array.length; + + if (initFromArray && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + + /** + * A specialized version of `_.reduceRight` for arrays without support for + * callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initFromArray] Specify using the last element of `array` + * as the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + var length = array.length; + if (initFromArray && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + + /** + * A specialized version of `_.some` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function arraySome(array, predicate) { + var index = -1, + length = array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + + /** + * A specialized version of `_.sum` for arrays without support for callback + * shorthands and `this` binding.. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function arraySum(array, iteratee) { + var length = array.length, + result = 0; + + while (length--) { + result += +iteratee(array[length]) || 0; + } + return result; + } + + /** + * Used by `_.defaults` to customize its `_.assign` use. + * + * @private + * @param {*} objectValue The destination object property value. + * @param {*} sourceValue The source object property value. + * @returns {*} Returns the value to assign to the destination object. + */ + function assignDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : objectValue; + } + + /** + * Used by `_.template` to customize its `_.assign` use. + * + * **Note:** This function is like `assignDefaults` except that it ignores + * inherited property values when checking if a property is `undefined`. + * + * @private + * @param {*} objectValue The destination object property value. + * @param {*} sourceValue The source object property value. + * @param {string} key The key associated with the object and source values. + * @param {Object} object The destination object. + * @returns {*} Returns the value to assign to the destination object. + */ + function assignOwnDefaults(objectValue, sourceValue, key, object) { + return (objectValue === undefined || !hasOwnProperty.call(object, key)) + ? sourceValue + : objectValue; + } + + /** + * A specialized version of `_.assign` for customizing assigned values without + * support for argument juggling, multiple sources, and `this` binding `customizer` + * functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. + */ + function assignWith(object, source, customizer) { + var index = -1, + props = keys(source), + length = props.length; + + while (++index < length) { + var key = props[index], + value = object[key], + result = customizer(value, source[key], key, object, source); + + if ((result === result ? (result !== value) : (value === value)) || + (value === undefined && !(key in object))) { + object[key] = result; + } + } + return object; + } + + /** + * The base implementation of `_.assign` without support for argument juggling, + * multiple sources, and `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssign(object, source) { + return source == null + ? object + : baseCopy(source, keys(source), object); + } + + /** + * The base implementation of `_.at` without support for string collections + * and individual key arguments. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {number[]|string[]} props The property names or indexes of elements to pick. + * @returns {Array} Returns the new array of picked elements. + */ + function baseAt(collection, props) { + var index = -1, + isNil = collection == null, + isArr = !isNil && isArrayLike(collection), + length = isArr ? collection.length : 0, + propsLength = props.length, + result = Array(propsLength); + + while(++index < propsLength) { + var key = props[index]; + if (isArr) { + result[index] = isIndex(key, length) ? collection[key] : undefined; + } else { + result[index] = isNil ? undefined : collection[key]; + } + } + return result; + } + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @returns {Object} Returns `object`. + */ + function baseCopy(source, props, object) { + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; + } + + /** + * The base implementation of `_.callback` which supports specifying the + * number of arguments to provide to `func`. + * + * @private + * @param {*} [func=_.identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ + function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == 'function') { + return thisArg === undefined + ? func + : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == 'object') { + return baseMatches(func); + } + return thisArg === undefined + ? property(func) + : baseMatchesProperty(func, thisArg); + } + + /** + * The base implementation of `_.clone` without support for argument juggling + * and `this` binding `customizer` functions. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The object `value` belongs to. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates clones with source counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), + isFunc = tag == funcTag; + + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseAssign(result, value); + } + } else { + return cloneableTags[tag] + ? initCloneByTag(value, tag, isDeep) + : (object ? value : {}); + } + } + // Check for circular references and return its corresponding clone. + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + // Add the source value to the stack of traversed objects and associate it with its clone. + stackA.push(value); + stackB.push(result); + + // Recursively populate clone (susceptible to call stack limits). + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; + } + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ + var baseCreate = (function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object; + object.prototype = undefined; + } + return result || {}; + }; + }()); + + /** + * The base implementation of `_.delay` and `_.defer` which accepts an index + * of where to slice the arguments to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Object} args The arguments provide to `func`. + * @returns {number} Returns the timer id. + */ + function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, args); }, wait); + } + + /** + * The base implementation of `_.difference` which accepts a single array + * of values to exclude. + * + * @private + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @returns {Array} Returns the new array of filtered values. + */ + function baseDifference(array, values) { + var length = array ? array.length : 0, + result = []; + + if (!length) { + return result; + } + var index = -1, + indexOf = getIndexOf(), + isCommon = indexOf == baseIndexOf, + cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null, + valuesLength = values.length; + + if (cache) { + indexOf = cacheIndexOf; + isCommon = false; + values = cache; + } + outer: + while (++index < length) { + var value = array[index]; + + if (isCommon && value === value) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === value) { + continue outer; + } + } + result.push(value); + } + else if (indexOf(values, value, 0) < 0) { + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.forEach` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object|string} Returns `collection`. + */ + var baseEach = createBaseEach(baseForOwn); + + /** + * The base implementation of `_.forEachRight` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object|string} Returns `collection`. + */ + var baseEachRight = createBaseEach(baseForOwnRight, true); + + /** + * The base implementation of `_.every` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + + /** + * Gets the extremum value of `collection` invoking `iteratee` for each value + * in `collection` to generate the criterion by which the value is ranked. + * The `iteratee` is invoked with three arguments: (value, index|key, collection). + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(collection, iteratee, comparator, exValue) { + var computed = exValue, + result = computed; + + baseEach(collection, function(value, index, collection) { + var current = +iteratee(value, index, collection); + if (comparator(current, computed) || (current === exValue && current === result)) { + computed = current; + result = value; + } + }); + return result; + } + + /** + * The base implementation of `_.fill` without an iteratee call guard. + * + * @private + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + */ + function baseFill(array, value, start, end) { + var length = array.length; + + start = start == null ? 0 : (+start || 0); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : (+end || 0); + if (end < 0) { + end += length; + } + length = start > end ? 0 : (end >>> 0); + start >>>= 0; + + while (start < length) { + array[start++] = value; + } + return array; + } + + /** + * The base implementation of `_.filter` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } + + /** + * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`, + * without support for callback shorthands and `this` binding, which iterates + * over `collection` using the provided `eachFunc`. + * + * @private + * @param {Array|Object|string} collection The collection to search. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @param {boolean} [retKey] Specify returning the key of the found element + * instead of the element itself. + * @returns {*} Returns the found element or its key, else `undefined`. + */ + function baseFind(collection, predicate, eachFunc, retKey) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = retKey ? key : value; + return false; + } + }); + return result; + } + + /** + * The base implementation of `_.flatten` with added support for restricting + * flattening and specifying the start index. + * + * @private + * @param {Array} array The array to flatten. + * @param {boolean} [isDeep] Specify a deep flatten. + * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ + function baseFlatten(array, isDeep, isStrict, result) { + result || (result = []); + + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index]; + if (isObjectLike(value) && isArrayLike(value) && + (isStrict || isArray(value) || isArguments(value))) { + if (isDeep) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, isDeep, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + + /** + * The base implementation of `baseForIn` and `baseForOwn` which iterates + * over `object` properties returned by `keysFunc` invoking `iteratee` for + * each property. Iteratee functions may exit iteration early by explicitly + * returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseFor = createBaseFor(); + + /** + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseForRight = createBaseFor(true); + + /** + * The base implementation of `_.forIn` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); + } + + /** + * The base implementation of `_.forOwn` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); + } + + /** + * The base implementation of `_.forOwnRight` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); + } + + /** + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from those provided. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the new array of filtered property names. + */ + function baseFunctions(object, props) { + var index = -1, + length = props.length, + resIndex = -1, + result = []; + + while (++index < length) { + var key = props[index]; + if (isFunction(object[key])) { + result[++resIndex] = key; + } + } + return result; + } + + /** + * The base implementation of `get` without support for string paths + * and default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path of the property to get. + * @param {string} [pathKey] The key representation of path. + * @returns {*} Returns the resolved value. + */ + function baseGet(object, path, pathKey) { + if (object == null) { + return; + } + if (pathKey !== undefined && pathKey in toObject(object)) { + path = [pathKey]; + } + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[path[index++]]; + } + return (index && index == length) ? object : undefined; + } + + /** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); + } + + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing objects. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `value` objects. + * @param {Array} [stackB=[]] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = arrayTag, + othTag = arrayTag; + + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); + } + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); + } + } + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); + } + } + if (!isSameTag) { + return false; + } + // Assume cyclic values are equal. + // For more information on detecting circular references see https://es5.github.io/#JO. + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + // Add `object` and `other` to the stack of traversed objects. + stackA.push(object); + stackB.push(other); + + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); + + stackA.pop(); + stackB.pop(); + + return result; + } + + /** + * The base implementation of `_.isMatch` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} matchData The propery names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; + } + } + } + return true; + } + + /** + * The base implementation of `_.map` without support for callback shorthands + * and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + + /** + * The base implementation of `_.matches` which does not clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new function. + */ + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], + value = matchData[0][1]; + + return function(object) { + if (object == null) { + return false; + } + return object[key] === value && (value !== undefined || (key in toObject(object))); + }; + } + return function(object) { + return baseIsMatch(object, matchData); + }; + } + + /** + * The base implementation of `_.matchesProperty` which does not clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to compare. + * @returns {Function} Returns the new function. + */ + function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), + isCommon = isKey(path) && isStrictComparable(srcValue), + pathKey = (path + ''); + + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + key = last(path); + object = toObject(object); + } + return object[key] === srcValue + ? (srcValue !== undefined || (key in object)) + : baseIsEqual(srcValue, object[key], undefined, true); + }; + } + + /** + * The base implementation of `_.merge` without support for argument juggling, + * multiple sources, and `this` binding `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} [customizer] The function to customize merged values. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates values with source counterparts. + * @returns {Object} Returns `object`. + */ + function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObject(object)) { + return object; + } + var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), + props = isSrcArr ? undefined : keys(source); + + arrayEach(props || source, function(srcValue, key) { + if (props) { + key = srcValue; + srcValue = source[key]; + } + if (isObjectLike(srcValue)) { + stackA || (stackA = []); + stackB || (stackB = []); + baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); + } + else { + var value = object[key], + result = customizer ? customizer(value, srcValue, key, object, source) : undefined, + isCommon = result === undefined; + + if (isCommon) { + result = srcValue; + } + if ((result !== undefined || (isSrcArr && !(key in object))) && + (isCommon || (result === result ? (result !== value) : (value === value)))) { + object[key] = result; + } + } + }); + return object; + } + + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize merged values. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates values with source counterparts. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { + var length = stackA.length, + srcValue = source[key]; + + while (length--) { + if (stackA[length] == srcValue) { + object[key] = stackB[length]; + return; + } + } + var value = object[key], + result = customizer ? customizer(value, srcValue, key, object, source) : undefined, + isCommon = result === undefined; + + if (isCommon) { + result = srcValue; + if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) { + result = isArray(value) + ? value + : (isArrayLike(value) ? arrayCopy(value) : []); + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + result = isArguments(value) + ? toPlainObject(value) + : (isPlainObject(value) ? value : {}); + } + else { + isCommon = false; + } + } + // Add the source value to the stack of traversed objects and associate + // it with its merged value. + stackA.push(srcValue); + stackB.push(result); + + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); + } else if (result === result ? (result !== value) : (value === value)) { + object[key] = result; + } + } + + /** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + + /** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new function. + */ + function basePropertyDeep(path) { + var pathKey = (path + ''); + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; + } + + /** + * The base implementation of `_.pullAt` without support for individual + * index arguments and capturing the removed elements. + * + * @private + * @param {Array} array The array to modify. + * @param {number[]} indexes The indexes of elements to remove. + * @returns {Array} Returns `array`. + */ + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0; + while (length--) { + var index = indexes[length]; + if (index != previous && isIndex(index)) { + var previous = index; + splice.call(array, index, 1); + } + } + return array; + } + + /** + * The base implementation of `_.random` without support for argument juggling + * and returning floating-point numbers. + * + * @private + * @param {number} min The minimum possible value. + * @param {number} max The maximum possible value. + * @returns {number} Returns the random number. + */ + function baseRandom(min, max) { + return min + nativeFloor(nativeRandom() * (max - min + 1)); + } + + /** + * The base implementation of `_.reduce` and `_.reduceRight` without support + * for callback shorthands and `this` binding, which iterates over `collection` + * using the provided `eachFunc`. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initFromCollection Specify using the first or last element + * of `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initFromCollection + ? (initFromCollection = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The base implementation of `setData` without support for hot loop detection. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + + /** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + start = start == null ? 0 : (+start || 0); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : (+end || 0); + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + + /** + * The base implementation of `_.some` without support for callback shorthands + * and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function baseSome(collection, predicate) { + var result; + + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + + /** + * The base implementation of `_.sortBy` which uses `comparer` to define + * the sort order of `array` and replaces criteria objects with their + * corresponding values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sortByOrder` without param guards. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {boolean[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseSortByOrder(collection, iteratees, orders) { + var callback = getCallback(), + index = -1; + + iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); }); + + var result = baseMap(collection, function(value) { + var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + + /** + * The base implementation of `_.sum` without support for callback shorthands + * and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(collection, iteratee) { + var result = 0; + baseEach(collection, function(value, index, collection) { + result += +iteratee(value, index, collection) || 0; + }); + return result; + } + + /** + * The base implementation of `_.uniq` without support for callback shorthands + * and `this` binding. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The function invoked per iteration. + * @returns {Array} Returns the new duplicate-value-free array. + */ + function baseUniq(array, iteratee) { + var index = -1, + indexOf = getIndexOf(), + length = array.length, + isCommon = indexOf == baseIndexOf, + isLarge = isCommon && length >= LARGE_ARRAY_SIZE, + seen = isLarge ? createCache() : null, + result = []; + + if (seen) { + indexOf = cacheIndexOf; + isCommon = false; + } else { + isLarge = false; + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value, index, array) : value; + + if (isCommon && value === value) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (indexOf(seen, computed, 0) < 0) { + if (iteratee || isLarge) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ + function baseValues(object, props) { + var index = -1, + length = props.length, + result = Array(length); + + while (++index < length) { + result[index] = object[props[index]]; + } + return result; + } + + /** + * The base implementation of `_.dropRightWhile`, `_.dropWhile`, `_.takeRightWhile`, + * and `_.takeWhile` without support for callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } + + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to peform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, + length = actions.length; + + while (++index < length) { + var action = actions[index]; + result = action.func.apply(action.thisArg, arrayPush([result], action.args)); + } + return result; + } + + /** + * Performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function binaryIndex(array, value, retHighest) { + var low = 0, + high = array ? array.length : low; + + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return binaryIndexBy(array, value, identity, retHighest); + } + + /** + * This function is like `binaryIndex` except that it invokes `iteratee` for + * `value` and each element of `array` to compute their sort ranking. The + * iteratee is invoked with one argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function binaryIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + + var low = 0, + high = array ? array.length : 0, + valIsNaN = value !== value, + valIsNull = value === null, + valIsUndef = value === undefined; + + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + isDef = computed !== undefined, + isReflexive = computed === computed; + + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + + /** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ + function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + + /** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function bufferClone(buffer) { + var result = new ArrayBuffer(buffer.byteLength), + view = new Uint8Array(result); + + view.set(new Uint8Array(buffer)); + return result; + } + + /** + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. + * + * @private + * @param {Array|Object} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgs(args, partials, holders) { + var holdersLength = holders.length, + argsIndex = -1, + argsLength = nativeMax(args.length - holdersLength, 0), + leftIndex = -1, + leftLength = partials.length, + result = Array(leftLength + argsLength); + + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + while (argsLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } + + /** + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. + * + * @private + * @param {Array|Object} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgsRight(args, partials, holders) { + var holdersIndex = -1, + holdersLength = holders.length, + argsIndex = -1, + argsLength = nativeMax(args.length - holdersLength, 0), + rightIndex = -1, + rightLength = partials.length, + result = Array(argsLength + rightLength); + + while (++argsIndex < argsLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + return result; + } + + /** + * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function. + * + * @private + * @param {Function} setter The function to set keys and values of the accumulator object. + * @param {Function} [initializer] The function to initialize the accumulator object. + * @returns {Function} Returns the new aggregator function. + */ + function createAggregator(setter, initializer) { + return function(collection, iteratee, thisArg) { + var result = initializer ? initializer() : {}; + iteratee = getCallback(iteratee, thisArg, 3); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + setter(result, value, iteratee(value, index, collection), collection); + } + } else { + baseEach(collection, function(value, key, collection) { + setter(result, value, iteratee(value, key, collection), collection); + }); + } + return result; + }; + } + + /** + * Creates a `_.assign`, `_.defaults`, or `_.merge` function. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ + function createAssigner(assigner) { + return restParam(function(object, sources) { + var index = -1, + length = object == null ? 0 : sources.length, + customizer = length > 2 ? sources[length - 2] : undefined, + guard = length > 2 ? sources[2] : undefined, + thisArg = length > 1 ? sources[length - 1] : undefined; + + if (typeof customizer == 'function') { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = typeof thisArg == 'function' ? thisArg : undefined; + length -= (customizer ? 1 : 0); + } + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, customizer); + } + } + return object; + }); + } + + /** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, + iterable = toObject(collection); + + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } + + /** + * Creates a base function for `_.forIn` or `_.forInRight`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), + props = keysFunc(object), + length = props.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length)) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + + /** + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new bound function. + */ + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); + + function wrapper() { + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; + } + + /** + * Creates a `Set` cache object to optimize linear searches of large arrays. + * + * @private + * @param {Array} [values] The values to cache. + * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`. + */ + function createCache(values) { + return (nativeCreate && Set) ? new SetCache(values) : null; + } + + /** + * Creates a function that produces compound words out of the words in a + * given string. + * + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + var index = -1, + array = words(deburr(string)), + length = array.length, + result = ''; + + while (++index < length) { + result = callback(result, array[index], index); + } + return result; + }; + } + + /** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ + function createCtorWrapper(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. + // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); + + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; + } + + /** + * Creates a `_.curry` or `_.curryRight` function. + * + * @private + * @param {boolean} flag The curry bit flag. + * @returns {Function} Returns the new curry function. + */ + function createCurry(flag) { + function curryFunc(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = undefined; + } + var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryFunc.placeholder; + return result; + } + return curryFunc; + } + + /** + * Creates a `_.defaults` or `_.defaultsDeep` function. + * + * @private + * @param {Function} assigner The function to assign values. + * @param {Function} customizer The function to customize assigned values. + * @returns {Function} Returns the new defaults function. + */ + function createDefaults(assigner, customizer) { + return restParam(function(args) { + var object = args[0]; + if (object == null) { + return object; + } + args.push(customizer); + return assigner.apply(undefined, args); + }); + } + + /** + * Creates a `_.max` or `_.min` function. + * + * @private + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. + * @returns {Function} Returns the new extremum function. + */ + function createExtremum(comparator, exValue) { + return function(collection, iteratee, thisArg) { + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + iteratee = getCallback(iteratee, thisArg, 3); + if (iteratee.length == 1) { + collection = isArray(collection) ? collection : toIterable(collection); + var result = arrayExtremum(collection, iteratee, comparator, exValue); + if (!(collection.length && result === exValue)) { + return result; + } + } + return baseExtremum(collection, iteratee, comparator, exValue); + }; + } + + /** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new find function. + */ + function createFind(eachFunc, fromRight) { + return function(collection, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + if (isArray(collection)) { + var index = baseFindIndex(collection, predicate, fromRight); + return index > -1 ? collection[index] : undefined; + } + return baseFind(collection, predicate, eachFunc); + }; + } + + /** + * Creates a `_.findIndex` or `_.findLastIndex` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new find function. + */ + function createFindIndex(fromRight) { + return function(array, predicate, thisArg) { + if (!(array && array.length)) { + return -1; + } + predicate = getCallback(predicate, thisArg, 3); + return baseFindIndex(array, predicate, fromRight); + }; + } + + /** + * Creates a `_.findKey` or `_.findLastKey` function. + * + * @private + * @param {Function} objectFunc The function to iterate over an object. + * @returns {Function} Returns the new find function. + */ + function createFindKey(objectFunc) { + return function(object, predicate, thisArg) { + predicate = getCallback(predicate, thisArg, 3); + return baseFind(object, predicate, objectFunc, true); + }; + } + + /** + * Creates a `_.flow` or `_.flowRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. + */ + function createFlow(fromRight) { + return function() { + var wrapper, + length = arguments.length, + index = fromRight ? length : -1, + leftIndex = 0, + funcs = Array(length); + + while ((fromRight ? index-- : ++index < length)) { + var func = funcs[leftIndex++] = arguments[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') { + wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? -1 : length; + while (++index < length) { + func = funcs[index]; + + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; + + if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); + } + } + return function() { + var args = arguments, + value = args[0]; + + if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; + + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }; + } + + /** + * Creates a function for `_.forEach` or `_.forEachRight`. + * + * @private + * @param {Function} arrayFunc The function to iterate over an array. + * @param {Function} eachFunc The function to iterate over a collection. + * @returns {Function} Returns the new each function. + */ + function createForEach(arrayFunc, eachFunc) { + return function(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) + ? arrayFunc(collection, iteratee) + : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); + }; + } + + /** + * Creates a function for `_.forIn` or `_.forInRight`. + * + * @private + * @param {Function} objectFunc The function to iterate over an object. + * @returns {Function} Returns the new each function. + */ + function createForIn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee, keysIn); + }; + } + + /** + * Creates a function for `_.forOwn` or `_.forOwnRight`. + * + * @private + * @param {Function} objectFunc The function to iterate over an object. + * @returns {Function} Returns the new each function. + */ + function createForOwn(objectFunc) { + return function(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || thisArg !== undefined) { + iteratee = bindCallback(iteratee, thisArg, 3); + } + return objectFunc(object, iteratee); + }; + } + + /** + * Creates a function for `_.mapKeys` or `_.mapValues`. + * + * @private + * @param {boolean} [isMapKeys] Specify mapping keys instead of values. + * @returns {Function} Returns the new map function. + */ + function createObjectMapper(isMapKeys) { + return function(object, iteratee, thisArg) { + var result = {}; + iteratee = getCallback(iteratee, thisArg, 3); + + baseForOwn(object, function(value, key, object) { + var mapped = iteratee(value, key, object); + key = isMapKeys ? mapped : key; + value = isMapKeys ? value : mapped; + result[key] = value; + }); + return result; + }; + } + + /** + * Creates a function for `_.padLeft` or `_.padRight`. + * + * @private + * @param {boolean} [fromRight] Specify padding from the right. + * @returns {Function} Returns the new pad function. + */ + function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string); + }; + } + + /** + * Creates a `_.partial` or `_.partialRight` function. + * + * @private + * @param {boolean} flag The partial bit flag. + * @returns {Function} Returns the new partial function. + */ + function createPartial(flag) { + var partialFunc = restParam(function(func, partials) { + var holders = replaceHolders(partials, partialFunc.placeholder); + return createWrapper(func, flag, undefined, partials, holders); + }); + return partialFunc; + } + + /** + * Creates a function for `_.reduce` or `_.reduceRight`. + * + * @private + * @param {Function} arrayFunc The function to iterate over an array. + * @param {Function} eachFunc The function to iterate over a collection. + * @returns {Function} Returns the new each function. + */ + function createReduce(arrayFunc, eachFunc) { + return function(collection, iteratee, accumulator, thisArg) { + var initFromArray = arguments.length < 3; + return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) + ? arrayFunc(collection, iteratee, accumulator, initFromArray) + : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); + }; + } + + /** + * Creates a function that wraps `func` and invokes it with optional `this` + * binding of, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & ARY_FLAG, + isBind = bitmask & BIND_FLAG, + isBindKey = bitmask & BIND_KEY_FLAG, + isCurry = bitmask & CURRY_FLAG, + isCurryBound = bitmask & CURRY_BOUND_FLAG, + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + Ctor = isBindKey ? undefined : createCtorWrapper(func); + + function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it to other functions. + var length = arguments.length, + index = length, + args = Array(length); + + while (index--) { + args[index] = arguments[index]; + } + if (partials) { + args = composeArgs(args, partials, holders); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, + argsHolders = replaceHolders(args, placeholder); + + length -= argsHolders.length; + if (length < arity) { + var newArgPos = argPos ? arrayCopy(argPos) : undefined, + newArity = nativeMax(arity - length, 0), + newsHolders = isCurry ? argsHolders : undefined, + newHoldersRight = isCurry ? undefined : argsHolders, + newPartials = isCurry ? args : undefined, + newPartialsRight = isCurry ? undefined : args; + + bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity], + result = createHybridWrapper.apply(undefined, newData); + + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; + + if (argPos) { + args = reorder(args, argPos); + } + if (isAry && ary < args.length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } + return fn.apply(thisBinding, args); + } + return wrapper; + } + + /** + * Creates the padding required for `string` based on the given `length`. + * The `chars` string is truncated if the number of characters exceeds `length`. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ + function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + + if (strLength >= length || !nativeIsFinite(length)) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : (chars + ''); + return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); + } + + /** + * Creates a function that wraps `func` and invokes it with the optional `this` + * binding of `thisArg` and the `partials` prepended to those provided to + * the wrapper. + * + * @private + * @param {Function} func The function to partially apply arguments to. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to the new function. + * @returns {Function} Returns the new bound function. + */ + function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, + Ctor = createCtorWrapper(func); + + function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it `func`. + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength); + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, args); + } + return wrapper; + } + + /** + * Creates a `_.ceil`, `_.floor`, or `_.round` function. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + precision = precision === undefined ? 0 : (+precision || 0); + if (precision) { + precision = pow(10, precision); + return func(number * precision) / precision; + } + return func(number); + }; + } + + /** + * Creates a `_.sortedIndex` or `_.sortedLastIndex` function. + * + * @private + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {Function} Returns the new index function. + */ + function createSortedIndex(retHighest) { + return function(array, value, iteratee, thisArg) { + var callback = getCallback(iteratee); + return (iteratee == null && callback === baseCallback) + ? binaryIndex(array, value, retHighest) + : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); + }; + } + + /** + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + length -= (holders ? holders.length : 0); + if (bitmask & PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func), + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; + + if (data) { + mergeData(newData, data); + bitmask = newData[1]; + arity = newData[9]; + } + newData[9] = arity == null + ? (isBindKey ? 0 : func.length) + : (nativeMax(arity - length, 0) || 0); + + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(undefined, newData); + } else { + result = createHybridWrapper.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setter(result, newData); + } + + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing arrays. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index], + result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + // Recursively compare arrays (susceptible to call stack limits). + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; + } + } + return true; + } + + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + return +object == +other; + + case errorTag: + return object.name == other.name && object.message == other.message; + + case numberTag: + // Treat `NaN` vs. `NaN` as equal. + return (object != +object) + ? other != +other + : object == +other; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings primitives and string + // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + return object == (other + ''); + } + return false; + } + + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; + + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key], + result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; + + // Recursively compare objects (susceptible to call stack limits). + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (!skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + return false; + } + } + return true; + } + + /** + * Gets the appropriate "callback" function. If the `_.callback` method is + * customized this function returns the custom method, otherwise it returns + * the `baseCallback` function. If arguments are provided the chosen function + * is invoked with them and its result is returned. + * + * @private + * @returns {Function} Returns the chosen function or its result. + */ + function getCallback(func, thisArg, argCount) { + var result = lodash.callback || callback; + result = result === callback ? baseCallback : result; + return argCount ? result(func, thisArg, argCount) : result; + } + + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + function getFuncName(func) { + var result = func.name, + array = realNames[result], + length = array ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; + } + + /** + * Gets the appropriate "indexOf" function. If the `_.indexOf` method is + * customized this function returns the custom method, otherwise it returns + * the `baseIndexOf` function. If arguments are provided the chosen function + * is invoked with them and its result is returned. + * + * @private + * @returns {Function|number} Returns the chosen function or its result. + */ + function getIndexOf(collection, target, fromIndex) { + var result = lodash.indexOf || indexOf; + result = result === indexOf ? baseIndexOf : result; + return collection ? result(collection, target, fromIndex) : result; + } + + /** + * Gets the "length" property value of `object`. + * + * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) + * that affects Safari on at least iOS 8.1-8.3 ARM64. + * + * @private + * @param {Object} object The object to query. + * @returns {*} Returns the "length" value. + */ + var getLength = baseProperty('length'); + + /** + * Gets the propery names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ + function getMatchData(object) { + var result = pairs(object), + length = result.length; + + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; + } + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; + } + + /** + * Gets the view, applying any `transforms` to the `start` and `end` positions. + * + * @private + * @param {number} start The start of the view. + * @param {number} end The end of the view. + * @param {Array} transforms The transformations to apply to the view. + * @returns {Object} Returns an object containing the `start` and `end` + * positions of the view. + */ + function getView(start, end, transforms) { + var index = -1, + length = transforms.length; + + while (++index < length) { + var data = transforms[index], + size = data.size; + + switch (data.type) { + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; + } + } + return { 'start': start, 'end': end }; + } + + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add array properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor; + } + + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + + /** + * Invokes the method at `path` on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ + function invokePath(object, path, args) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : func.apply(object, args); + } + + /** + * Checks if `value` is array-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + */ + function isArrayLike(value) { + return value != null && isLength(getLength(value)); + } + + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; + } + + /** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object)) { + var other = object[index]; + return value === value ? (value === other) : (other !== other); + } + return false; + } + + /** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ + function isKey(value, object) { + var type = typeof value; + if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || (object != null && value in toObject(object)); + } + + /** + * Checks if `func` has a lazy counterpart. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`. + */ + function isLaziable(func) { + var funcName = getFuncName(func); + if (!(funcName in LazyWrapper.prototype)) { + return false; + } + var other = lodash[funcName]; + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ + function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ + function isStrictComparable(value) { + return value === value && !isObject(value); + } + + /** + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers required to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg` + * augment function arguments, making the order in which they are executed important, + * preventing the merging of metadata. However, we make an exception for a safe + * common case where curried functions have `_.ary` and or `_.rearg` applied. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < ARY_FLAG; + + var isCombo = + (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) || + (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) || + (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG); + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; + } + // Use source `thisArg` if available. + if (srcBitmask & BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = arrayCopy(value); + } + // Use source `ary` if it's smaller. + if (srcBitmask & ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; + + return data; + } + + /** + * Used by `_.defaultsDeep` to customize its `_.merge` use. + * + * @private + * @param {*} objectValue The destination object property value. + * @param {*} sourceValue The source object property value. + * @returns {*} Returns the value to assign to the destination object. + */ + function mergeDefaults(objectValue, sourceValue) { + return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); + } + + /** + * A specialized version of `_.pick` which picks `object` properties specified + * by `props`. + * + * @private + * @param {Object} object The source object. + * @param {string[]} props The property names to pick. + * @returns {Object} Returns the new object. + */ + function pickByArray(object, props) { + object = toObject(object); + + var index = -1, + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + return result; + } + + /** + * A specialized version of `_.pick` which picks `object` properties `predicate` + * returns truthy for. + * + * @private + * @param {Object} object The source object. + * @param {Function} predicate The function invoked per iteration. + * @returns {Object} Returns the new object. + */ + function pickByCallback(object, predicate) { + var result = {}; + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; + } + }); + return result; + } + + /** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. + * + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. + */ + function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = arrayCopy(array); + + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + + /** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity function + * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var setData = (function() { + var count = 0, + lastCalled = 0; + + return function(key, value) { + var stamp = now(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); + }; + }()); + + /** + * A fallback implementation of `Object.keys` which creates an array of the + * own enumerable property names of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function shimKeys(object) { + var props = keysIn(object), + propsLength = props.length, + length = propsLength && object.length; + + var allowIndexes = !!length && isLength(length) && + (isArray(object) || isArguments(object)); + + var index = -1, + result = []; + + while (++index < propsLength) { + var key = props[index]; + if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; + } + + /** + * Converts `value` to an array-like object if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Array|Object} Returns the array-like object. + */ + function toIterable(value) { + if (value == null) { + return []; + } + if (!isArrayLike(value)) { + return values(value); + } + return isObject(value) ? value : Object(value); + } + + /** + * Converts `value` to an object if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Object} Returns the object. + */ + function toObject(value) { + return isObject(value) ? value : Object(value); + } + + /** + * Converts `value` to property path array if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Array} Returns the property path array. + */ + function toPath(value) { + if (isArray(value)) { + return value; + } + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; + } + + /** + * Creates a clone of `wrapper`. + * + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ + function wrapperClone(wrapper) { + return wrapper instanceof LazyWrapper + ? wrapper.clone() + : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of elements split into groups the length of `size`. + * If `collection` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the new array containing chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ + function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(nativeFloor(size) || 1, 1); + } + var index = 0, + length = array ? array.length : 0, + resIndex = -1, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[++resIndex] = baseSlice(array, index, (index += size)); + } + return result; + } + + /** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ + function compact(array) { + var index = -1, + length = array ? array.length : 0, + resIndex = -1, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[++resIndex] = value; + } + } + return result; + } + + /** + * Creates an array of unique `array` values not included in the other + * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The arrays of values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.difference([1, 2, 3], [4, 2]); + * // => [1, 3] + */ + var difference = restParam(function(array, values) { + return (isObjectLike(array) && isArrayLike(array)) + ? baseDifference(array, baseFlatten(values, false, true)) + : []; + }); + + /** + * Creates a slice of `array` with `n` elements dropped from the beginning. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.drop([1, 2, 3]); + * // => [2, 3] + * + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function drop(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` with `n` elements dropped from the end. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRight([1, 2, 3]); + * // => [1, 2] + * + * _.dropRight([1, 2, 3], 2); + * // => [1] + * + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function dropRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, 0, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that match the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); + * // => [1] + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); + * // => ['barney', 'fred'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active', false), 'user'); + * // => ['barney'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.dropRightWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ + function dropRightWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) + : []; + } + + /** + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * bound to `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropWhile([1, 2, 3], function(n) { + * return n < 3; + * }); + * // => [3] + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user'); + * // => ['fred', 'pebbles'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.dropWhile(users, 'active', false), 'user'); + * // => ['pebbles'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.dropWhile(users, 'active'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ + function dropWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3), true) + : []; + } + + /** + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. + * + * **Note:** This method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3]; + * + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] + * + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8], '*', 1, 2); + * // => [4, '*', 8] + */ + function fill(array, value, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; + } + return baseFill(array, value, start, end); + } + + /** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(chr) { + * return chr.user == 'barney'; + * }); + * // => 0 + * + * // using the `_.matches` callback shorthand + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // using the `_.matchesProperty` callback shorthand + * _.findIndex(users, 'active', false); + * // => 0 + * + * // using the `_.property` callback shorthand + * _.findIndex(users, 'active'); + * // => 2 + */ + var findIndex = createFindIndex(); + + /** + * This method is like `_.findIndex` except that it iterates over elements + * of `collection` from right to left. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.findLastIndex(users, function(chr) { + * return chr.user == 'pebbles'; + * }); + * // => 2 + * + * // using the `_.matches` callback shorthand + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // using the `_.matchesProperty` callback shorthand + * _.findLastIndex(users, 'active', false); + * // => 2 + * + * // using the `_.property` callback shorthand + * _.findLastIndex(users, 'active'); + * // => 0 + */ + var findLastIndex = createFindIndex(true); + + /** + * Gets the first element of `array`. + * + * @static + * @memberOf _ + * @alias head + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. + * @example + * + * _.first([1, 2, 3]); + * // => 1 + * + * _.first([]); + * // => undefined + */ + function first(array) { + return array ? array[0] : undefined; + } + + /** + * Flattens a nested array. If `isDeep` is `true` the array is recursively + * flattened, otherwise it is only flattened a single level. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to flatten. + * @param {boolean} [isDeep] Specify a deep flatten. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, 3, [4]]]); + * // => [1, 2, 3, [4]] + * + * // using `isDeep` + * _.flatten([1, [2, 3, [4]]], true); + * // => [1, 2, 3, 4] + */ + function flatten(array, isDeep, guard) { + var length = array ? array.length : 0; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; + } + + /** + * Recursively flattens a nested array. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to recursively flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flattenDeep([1, [2, 3, [4]]]); + * // => [1, 2, 3, 4] + */ + function flattenDeep(array) { + var length = array ? array.length : 0; + return length ? baseFlatten(array, true) : []; + } + + /** + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` + * performs a faster binary search. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=0] The index to search from or `true` + * to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 + * + * // using `fromIndex` + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 + * + * // performing a binary search + * _.indexOf([1, 1, 2, 2], 2, true); + * // => 2 + */ + function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == 'number') { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && + (value === value ? (value === array[index]) : (array[index] !== array[index]))) { + return index; + } + return -1; + } + return baseIndexOf(array, value, fromIndex || 0); + } + + /** + * Gets all but the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.initial([1, 2, 3]); + * // => [1, 2] + */ + function initial(array) { + return dropRight(array, 1); + } + + /** + * Creates an array of unique values that are included in all of the provided + * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of shared values. + * @example + * _.intersection([1, 2], [4, 2], [2, 1]); + * // => [2] + */ + var intersection = restParam(function(arrays) { + var othLength = arrays.length, + othIndex = othLength, + caches = Array(length), + indexOf = getIndexOf(), + isCommon = indexOf == baseIndexOf, + result = []; + + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; + } + var array = arrays[0], + index = -1, + length = array ? array.length : 0, + seen = caches[0]; + + outer: + while (++index < length) { + value = array[index]; + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { + continue outer; + } + } + if (seen) { + seen.push(value); + } + result.push(value); + } + } + return result; + }); + + /** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ + function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; + } + + /** + * This method is like `_.indexOf` except that it iterates over elements of + * `array` from right to left. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=array.length-1] The index to search from + * or `true` to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 + * + * // using `fromIndex` + * _.lastIndexOf([1, 2, 1, 2], 2, 2); + * // => 1 + * + * // performing a binary search + * _.lastIndexOf([1, 1, 2, 2], 2, true); + * // => 3 + */ + function lastIndexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + var index = length; + if (typeof fromIndex == 'number') { + index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1; + } else if (fromIndex) { + index = binaryIndex(array, value, true) - 1; + var other = array[index]; + if (value === value ? (value === other) : (other !== other)) { + return index; + } + return -1; + } + if (value !== value) { + return indexOfNaN(array, index, true); + } + while (index--) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * Removes all provided values from `array` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * **Note:** Unlike `_.without`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {...*} [values] The values to remove. + * @returns {Array} Returns `array`. + * @example + * + * var array = [1, 2, 3, 1, 2, 3]; + * + * _.pull(array, 2, 3); + * console.log(array); + * // => [1, 1] + */ + function pull() { + var args = arguments, + array = args[0]; + + if (!(array && array.length)) { + return array; + } + var index = 0, + indexOf = getIndexOf(), + length = args.length; + + while (++index < length) { + var fromIndex = 0, + value = args[index]; + + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); + } + } + return array; + } + + /** + * Removes elements from `array` corresponding to the given indexes and returns + * an array of the removed elements. Indexes may be specified as an array of + * indexes or as individual arguments. + * + * **Note:** Unlike `_.at`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {...(number|number[])} [indexes] The indexes of elements to remove, + * specified as individual indexes or arrays of indexes. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [5, 10, 15, 20]; + * var evens = _.pullAt(array, 1, 3); + * + * console.log(array); + * // => [5, 15] + * + * console.log(evens); + * // => [10, 20] + */ + var pullAt = restParam(function(array, indexes) { + indexes = baseFlatten(indexes); + + var result = baseAt(array, indexes); + basePullAt(array, indexes.sort(baseCompareAscending)); + return result; + }); + + /** + * Removes all elements from `array` that `predicate` returns truthy for + * and returns an array of the removed elements. The predicate is bound to + * `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * **Note:** Unlike `_.filter`, this method mutates `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to modify. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new array of removed elements. + * @example + * + * var array = [1, 2, 3, 4]; + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); + * + * console.log(array); + * // => [1, 3] + * + * console.log(evens); + * // => [2, 4] + */ + function remove(array, predicate, thisArg) { + var result = []; + if (!(array && array.length)) { + return result; + } + var index = -1, + indexes = [], + length = array.length; + + predicate = getCallback(predicate, thisArg, 3); + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result.push(value); + indexes.push(index); + } + } + basePullAt(array, indexes); + return result; + } + + /** + * Gets all but the first element of `array`. + * + * @static + * @memberOf _ + * @alias tail + * @category Array + * @param {Array} array The array to query. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.rest([1, 2, 3]); + * // => [2, 3] + */ + function rest(array) { + return drop(array, 1); + } + + /** + * Creates a slice of `array` from `start` up to, but not including, `end`. + * + * **Note:** This method is used instead of `Array#slice` to support node + * lists in IE < 9 and to ensure dense arrays are returned. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function slice(array, start, end) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { + start = 0; + end = length; + } + return baseSlice(array, start, end); + } + + /** + * Uses a binary search to determine the lowest index at which `value` should + * be inserted into `array` in order to maintain its sort order. If an iteratee + * function is provided it is invoked for `value` and each element of `array` + * to compute their sort ranking. The iteratee is bound to `thisArg` and + * invoked with one argument; (value). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedIndex([30, 50], 40); + * // => 1 + * + * _.sortedIndex([4, 4, 5, 5], 5); + * // => 2 + * + * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; + * + * // using an iteratee function + * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { + * return this.data[word]; + * }, dict); + * // => 1 + * + * // using the `_.property` callback shorthand + * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); + * // => 1 + */ + var sortedIndex = createSortedIndex(); + + /** + * This method is like `_.sortedIndex` except that it returns the highest + * index at which `value` should be inserted into `array` in order to + * maintain its sort order. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + * @example + * + * _.sortedLastIndex([4, 4, 5, 5], 5); + * // => 4 + */ + var sortedLastIndex = createSortedIndex(true); + + /** + * Creates a slice of `array` with `n` elements taken from the beginning. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.take([1, 2, 3]); + * // => [1] + * + * _.take([1, 2, 3], 2); + * // => [1, 2] + * + * _.take([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.take([1, 2, 3], 0); + * // => [] + */ + function take(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + return baseSlice(array, 0, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` with `n` elements taken from the end. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to take. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRight([1, 2, 3]); + * // => [3] + * + * _.takeRight([1, 2, 3], 2); + * // => [2, 3] + * + * _.takeRight([1, 2, 3], 5); + * // => [1, 2, 3] + * + * _.takeRight([1, 2, 3], 0); + * // => [] + */ + function takeRight(array, n, guard) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = length - (+n || 0); + return baseSlice(array, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` with elements taken from the end. Elements are + * taken until `predicate` returns falsey. The predicate is bound to `thisArg` + * and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); + * // => [2, 3] + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); + * // => ['pebbles'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active', false), 'user'); + * // => ['fred', 'pebbles'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.takeRightWhile(users, 'active'), 'user'); + * // => [] + */ + function takeRightWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) + : []; + } + + /** + * Creates a slice of `array` with elements taken from the beginning. Elements + * are taken until `predicate` returns falsey. The predicate is bound to + * `thisArg` and invoked with three arguments: (value, index, array). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.takeWhile([1, 2, 3], function(n) { + * return n < 3; + * }); + * // => [1, 2] + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false}, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.takeWhile(users, 'active', false), 'user'); + * // => ['barney', 'fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.takeWhile(users, 'active'), 'user'); + * // => [] + */ + function takeWhile(array, predicate, thisArg) { + return (array && array.length) + ? baseWhile(array, getCallback(predicate, thisArg, 3)) + : []; + } + + /** + * Creates an array of unique values, in order, from all of the provided arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([1, 2], [4, 2], [2, 1]); + * // => [1, 2, 4] + */ + var union = restParam(function(arrays) { + return baseUniq(baseFlatten(arrays, false, true)); + }); + + /** + * Creates a duplicate-free version of an array, using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons, in which only the first occurence of each element + * is kept. Providing `true` for `isSorted` performs a faster search algorithm + * for sorted arrays. If an iteratee function is provided it is invoked for + * each element in the array to generate the criterion by which uniqueness + * is computed. The `iteratee` is bound to `thisArg` and invoked with three + * arguments: (value, index, array). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias unique + * @category Array + * @param {Array} array The array to inspect. + * @param {boolean} [isSorted] Specify the array is sorted. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new duplicate-value-free array. + * @example + * + * _.uniq([2, 1, 2]); + * // => [2, 1] + * + * // using `isSorted` + * _.uniq([1, 1, 2], true); + * // => [1, 2] + * + * // using an iteratee function + * _.uniq([1, 2.5, 1.5, 2], function(n) { + * return this.floor(n); + * }, Math); + * // => [1, 2.5] + * + * // using the `_.property` callback shorthand + * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }, { 'x': 2 }] + */ + function uniq(array, isSorted, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + if (isSorted != null && typeof isSorted != 'boolean') { + thisArg = iteratee; + iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; + isSorted = false; + } + var callback = getCallback(); + if (!(iteratee == null && callback === baseCallback)) { + iteratee = callback(iteratee, thisArg, 3); + } + return (isSorted && getIndexOf() == baseIndexOf) + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); + } + + /** + * This method is like `_.zip` except that it accepts an array of grouped + * elements and creates an array regrouping the elements to their pre-zip + * configuration. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array of grouped elements to process. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]); + * // => [['fred', 30, true], ['barney', 40, false]] + * + * _.unzip(zipped); + * // => [['fred', 'barney'], [30, 40], [true, false]] + */ + function unzip(array) { + if (!(array && array.length)) { + return []; + } + var index = -1, + length = 0; + + array = arrayFilter(array, function(group) { + if (isArrayLike(group)) { + length = nativeMax(group.length, length); + return true; + } + }); + var result = Array(length); + while (++index < length) { + result[index] = arrayMap(array, baseProperty(index)); + } + return result; + } + + /** + * This method is like `_.unzip` except that it accepts an iteratee to specify + * how regrouped values should be combined. The `iteratee` is bound to `thisArg` + * and invoked with four arguments: (accumulator, value, index, group). + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array of grouped elements to process. + * @param {Function} [iteratee] The function to combine regrouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new array of regrouped elements. + * @example + * + * var zipped = _.zip([1, 2], [10, 20], [100, 200]); + * // => [[1, 10, 100], [2, 20, 200]] + * + * _.unzipWith(zipped, _.add); + * // => [3, 30, 300] + */ + function unzipWith(array, iteratee, thisArg) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + var result = unzip(array); + if (iteratee == null) { + return result; + } + iteratee = bindCallback(iteratee, thisArg, 4); + return arrayMap(result, function(group) { + return arrayReduce(group, iteratee, undefined, true); + }); + } + + /** + * Creates an array excluding all provided values using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to filter. + * @param {...*} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.without([1, 2, 1, 3], 1, 2); + * // => [3] + */ + var without = restParam(function(array, values) { + return isArrayLike(array) + ? baseDifference(array, values) + : []; + }); + + /** + * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * of the provided arrays. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of values. + * @example + * + * _.xor([1, 2], [4, 2]); + * // => [1, 4] + */ + function xor() { + var index = -1, + length = arguments.length; + + while (++index < length) { + var array = arguments[index]; + if (isArrayLike(array)) { + var result = result + ? arrayPush(baseDifference(result, array), baseDifference(array, result)) + : array; + } + } + return result ? baseUniq(result) : []; + } + + /** + * Creates an array of grouped elements, the first of which contains the first + * elements of the given arrays, the second of which contains the second elements + * of the given arrays, and so on. + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zip(['fred', 'barney'], [30, 40], [true, false]); + * // => [['fred', 30, true], ['barney', 40, false]] + */ + var zip = restParam(unzip); + + /** + * The inverse of `_.pairs`; this method returns an object composed from arrays + * of property names and values. Provide either a single two dimensional array, + * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names + * and one of corresponding values. + * + * @static + * @memberOf _ + * @alias object + * @category Array + * @param {Array} props The property names. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject([['fred', 30], ['barney', 40]]); + * // => { 'fred': 30, 'barney': 40 } + * + * _.zipObject(['fred', 'barney'], [30, 40]); + * // => { 'fred': 30, 'barney': 40 } + */ + function zipObject(props, values) { + var index = -1, + length = props ? props.length : 0, + result = {}; + + if (length && !values && !isArray(props[0])) { + values = []; + } + while (++index < length) { + var key = props[index]; + if (values) { + result[key] = values[index]; + } else if (key) { + result[key[0]] = key[1]; + } + } + return result; + } + + /** + * This method is like `_.zip` except that it accepts an iteratee to specify + * how grouped values should be combined. The `iteratee` is bound to `thisArg` + * and invoked with four arguments: (accumulator, value, index, group). + * + * @static + * @memberOf _ + * @category Array + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee] The function to combine grouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new array of grouped elements. + * @example + * + * _.zipWith([1, 2], [10, 20], [100, 200], _.add); + * // => [111, 222] + */ + var zipWith = restParam(function(arrays) { + var length = arrays.length, + iteratee = length > 2 ? arrays[length - 2] : undefined, + thisArg = length > 1 ? arrays[length - 1] : undefined; + + if (length > 2 && typeof iteratee == 'function') { + length -= 2; + } else { + iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined; + thisArg = undefined; + } + arrays.length = length; + return unzipWith(arrays, iteratee, thisArg); + }); + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object that wraps `value` with explicit method + * chaining enabled. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; + * + * var youngest = _.chain(users) + * .sortBy('age') + * .map(function(chr) { + * return chr.user + ' is ' + chr.age; + * }) + * .first() + * .value(); + * // => 'pebbles is 1' + */ + function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; + } + + /** + * This method invokes `interceptor` and returns `value`. The interceptor is + * bound to `thisArg` and invoked with one argument; (value). The purpose of + * this method is to "tap into" a method chain in order to perform operations + * on intermediate results within the chain. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @param {*} [thisArg] The `this` binding of `interceptor`. + * @returns {*} Returns `value`. + * @example + * + * _([1, 2, 3]) + * .tap(function(array) { + * array.pop(); + * }) + * .reverse() + * .value(); + * // => [2, 1] + */ + function tap(value, interceptor, thisArg) { + interceptor.call(thisArg, value); + return value; + } + + /** + * This method is like `_.tap` except that it returns the result of `interceptor`. + * + * @static + * @memberOf _ + * @category Chain + * @param {*} value The value to provide to `interceptor`. + * @param {Function} interceptor The function to invoke. + * @param {*} [thisArg] The `this` binding of `interceptor`. + * @returns {*} Returns the result of `interceptor`. + * @example + * + * _(' abc ') + * .chain() + * .trim() + * .thru(function(value) { + * return [value]; + * }) + * .value(); + * // => ['abc'] + */ + function thru(value, interceptor, thisArg) { + return interceptor.call(thisArg, value); + } + + /** + * Enables explicit method chaining on the wrapper object. + * + * @name chain + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * // without explicit chaining + * _(users).first(); + * // => { 'user': 'barney', 'age': 36 } + * + * // with explicit chaining + * _(users).chain() + * .first() + * .pick('user') + * .value(); + * // => { 'user': 'barney' } + */ + function wrapperChain() { + return chain(this); + } + + /** + * Executes the chained sequence and returns the wrapped result. + * + * @name commit + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).push(3); + * + * console.log(array); + * // => [1, 2] + * + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] + * + * wrapped.last(); + * // => 3 + * + * console.log(array); + * // => [1, 2, 3] + */ + function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); + } + + /** + * Creates a new array joining a wrapped array with any additional arrays + * and/or values. + * + * @name concat + * @memberOf _ + * @category Chain + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var wrapped = _(array).concat(2, [3], [[4]]); + * + * console.log(wrapped.value()); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ + var wrapperConcat = restParam(function(values) { + values = baseFlatten(values); + return this.thru(function(array) { + return arrayConcat(isArray(array) ? array : [toObject(array)], values); + }); + }); + + /** + * Creates a clone of the chained sequence planting `value` as the wrapped value. + * + * @name plant + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var array = [1, 2]; + * var wrapped = _(array).map(function(value) { + * return Math.pow(value, 2); + * }); + * + * var other = [3, 4]; + * var otherWrapped = wrapped.plant(other); + * + * otherWrapped.value(); + * // => [9, 16] + * + * wrapped.value(); + * // => [1, 4] + */ + function wrapperPlant(value) { + var result, + parent = this; + + while (parent instanceof baseLodash) { + var clone = wrapperClone(parent); + if (result) { + previous.__wrapped__ = clone; + } else { + result = clone; + } + var previous = clone; + parent = parent.__wrapped__; + } + previous.__wrapped__ = value; + return result; + } + + /** + * Reverses the wrapped array so the first element becomes the last, the + * second element becomes the second to last, and so on. + * + * **Note:** This method mutates the wrapped array. + * + * @name reverse + * @memberOf _ + * @category Chain + * @returns {Object} Returns the new reversed `lodash` wrapper instance. + * @example + * + * var array = [1, 2, 3]; + * + * _(array).reverse().value() + * // => [3, 2, 1] + * + * console.log(array); + * // => [3, 2, 1] + */ + function wrapperReverse() { + var value = this.__wrapped__; + + var interceptor = function(value) { + return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse(); + }; + if (value instanceof LazyWrapper) { + var wrapped = value; + if (this.__actions__.length) { + wrapped = new LazyWrapper(this); + } + wrapped = wrapped.reverse(); + wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); + return new LodashWrapper(wrapped, this.__chain__); + } + return this.thru(interceptor); + } + + /** + * Produces the result of coercing the unwrapped value to a string. + * + * @name toString + * @memberOf _ + * @category Chain + * @returns {string} Returns the coerced string value. + * @example + * + * _([1, 2, 3]).toString(); + * // => '1,2,3' + */ + function wrapperToString() { + return (this.value() + ''); + } + + /** + * Executes the chained sequence to extract the unwrapped value. + * + * @name value + * @memberOf _ + * @alias run, toJSON, valueOf + * @category Chain + * @returns {*} Returns the resolved unwrapped value. + * @example + * + * _([1, 2, 3]).value(); + * // => [1, 2, 3] + */ + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of elements corresponding to the given keys, or indexes, + * of `collection`. Keys may be specified as individual arguments or as arrays + * of keys. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(number|number[]|string|string[])} [props] The property names + * or indexes of elements to pick, specified individually or in arrays. + * @returns {Array} Returns the new array of picked elements. + * @example + * + * _.at(['a', 'b', 'c'], [0, 2]); + * // => ['a', 'c'] + * + * _.at(['barney', 'fred', 'pebbles'], 0, 2); + * // => ['barney', 'pebbles'] + */ + var at = restParam(function(collection, props) { + return baseAt(collection, baseFlatten(props)); + }); + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); + * // => { '4': 1, '6': 2 } + * + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); + * // => { '4': 1, '6': 2 } + * + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } + */ + var countBy = createAggregator(function(result, value, key) { + hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1); + }); + + /** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * The predicate is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias all + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.every(users, 'active', false); + * // => true + * + * // using the `_.property` callback shorthand + * _.every(users, 'active'); + * // => false + */ + function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != 'function' || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + + /** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is bound to `thisArg` and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias select + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new filtered array. + * @example + * + * _.filter([4, 5, 6], function(n) { + * return n % 2 == 0; + * }); + * // => [4, 6] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.filter(users, 'active', false), 'user'); + * // => ['fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.filter(users, 'active'), 'user'); + * // => ['barney'] + */ + function filter(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, predicate); + } + + /** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias detect + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.result(_.find(users, function(chr) { + * return chr.age < 40; + * }), 'user'); + * // => 'barney' + * + * // using the `_.matches` callback shorthand + * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); + * // => 'pebbles' + * + * // using the `_.matchesProperty` callback shorthand + * _.result(_.find(users, 'active', false), 'user'); + * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.result(_.find(users, 'active'), 'user'); + * // => 'barney' + */ + var find = createFind(baseEach); + + /** + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 + */ + var findLast = createFind(baseEachRight, true); + + /** + * Performs a deep comparison between each element in `collection` and the + * source object, returning the first element that has equivalent property + * values. + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Object} source The object of property values to match. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user'); + * // => 'barney' + * + * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); + * // => 'fred' + */ + function findWhere(collection, source) { + return find(collection, baseMatches(source)); + } + + /** + * Iterates over elements of `collection` invoking `iteratee` for each element. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). Iteratee functions may exit iteration early + * by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" property + * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` + * may be used for object iteration. + * + * @static + * @memberOf _ + * @alias each + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2]).forEach(function(n) { + * console.log(n); + * }).value(); + * // => logs each value from left to right and returns the array + * + * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + * console.log(n, key); + * }); + * // => logs each value-key pair and returns the object (iteration order is not guaranteed) + */ + var forEach = createForEach(arrayEach, baseEach); + + /** + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @alias eachRight + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2]).forEachRight(function(n) { + * console.log(n); + * }).value(); + * // => logs each value from right to left and returns the array + */ + var forEachRight = createForEach(arrayEachRight, baseEachRight); + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is an array of the elements responsible for generating the key. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); + * // => { '4': [4.2], '6': [6.1, 6.4] } + * + * // using the `_.property` callback shorthand + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } + */ + var groupBy = createAggregator(function(result, value, key) { + if (hasOwnProperty.call(result, key)) { + result[key].push(value); + } else { + result[key] = [value]; + } + }); + + /** + * Checks if `value` is in `collection` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of `collection`. + * + * @static + * @memberOf _ + * @alias contains, include + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {*} target The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. + * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.includes('pebbles', 'eb'); + * // => true + */ + function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + } + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) + : (!!length && getIndexOf(collection, target, fromIndex) > -1); + } + + /** + * Creates an object composed of keys generated from the results of running + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the last element responsible for generating the key. The + * iteratee function is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var keyData = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.indexBy(keyData, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keyData, function(object) { + * return String.fromCharCode(object.code); + * }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keyData, function(object) { + * return this.fromCharCode(object.code); + * }, String); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + */ + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; + }); + + /** + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `methodName` is a function it is + * invoked for, and `this` bound to, each element in `collection`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {Array} Returns the array of results. + * @example + * + * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); + * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invoke([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] + */ + var invoke = restParam(function(collection, path, args) { + var index = -1, + isFunc = typeof path == 'function', + isProp = isKey(path), + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value) { + var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); + result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); + }); + return result; + }); + + /** + * Creates an array of values by running each element in `collection` through + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three + * arguments: (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, + * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, + * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, + * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, + * `sum`, `uniq`, and `words` + * + * @static + * @memberOf _ + * @alias collect + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new mapped array. + * @example + * + * function timesThree(n) { + * return n * 3; + * } + * + * _.map([1, 2], timesThree); + * // => [3, 6] + * + * _.map({ 'a': 1, 'b': 2 }, timesThree); + * // => [3, 6] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // using the `_.property` callback shorthand + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ + function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = getCallback(iteratee, thisArg, 3); + return func(collection, iteratee); + } + + /** + * Creates an array of elements split into two groups, the first of which + * contains elements `predicate` returns truthy for, while the second of which + * contains elements `predicate` returns falsey for. The predicate is bound + * to `thisArg` and invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the array of grouped elements. + * @example + * + * _.partition([1, 2, 3], function(n) { + * return n % 2; + * }); + * // => [[1, 3], [2]] + * + * _.partition([1.2, 2.3, 3.4], function(n) { + * return this.floor(n) % 2; + * }, Math); + * // => [[1.2, 3.4], [2.3]] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true }, + * { 'user': 'pebbles', 'age': 1, 'active': false } + * ]; + * + * var mapper = function(array) { + * return _.pluck(array, 'user'); + * }; + * + * // using the `_.matches` callback shorthand + * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); + * // => [['pebbles'], ['barney', 'fred']] + * + * // using the `_.matchesProperty` callback shorthand + * _.map(_.partition(users, 'active', false), mapper); + * // => [['barney', 'pebbles'], ['fred']] + * + * // using the `_.property` callback shorthand + * _.map(_.partition(users, 'active'), mapper); + * // => [['fred'], ['barney', 'pebbles']] + */ + var partition = createAggregator(function(result, value, key) { + result[key ? 0 : 1].push(value); + }, function() { return [[], []]; }); + + /** + * Gets the property value of `path` from all elements in `collection`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|string} path The path of the property to pluck. + * @returns {Array} Returns the property values. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.pluck(users, 'user'); + * // => ['barney', 'fred'] + * + * var userIndex = _.indexBy(users, 'user'); + * _.pluck(userIndex, 'age'); + * // => [36, 40] (iteration order is not guaranteed) + */ + function pluck(collection, path) { + return map(collection, property(path)); + } + + /** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` through `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not provided the first element of `collection` is used as the initial + * value. The `iteratee` is bound to `thisArg` and invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, + * and `sortByOrder` + * + * @static + * @memberOf _ + * @alias foldl, inject + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * _.reduce([1, 2], function(total, n) { + * return total + n; + * }); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { + * result[key] = n * 3; + * return result; + * }, {}); + * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) + */ + var reduce = createReduce(arrayReduce, baseEach); + + /** + * This method is like `_.reduce` except that it iterates over elements of + * `collection` from right to left. + * + * @static + * @memberOf _ + * @alias foldr + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * var array = [[0, 1], [2, 3], [4, 5]]; + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); + * // => [4, 5, 2, 3, 0, 1] + */ + var reduceRight = createReduce(arrayReduceRight, baseEachRight); + + /** + * The opposite of `_.filter`; this method returns the elements of `collection` + * that `predicate` does **not** return truthy for. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Array} Returns the new filtered array. + * @example + * + * _.reject([1, 2, 3, 4], function(n) { + * return n % 2 == 0; + * }); + * // => [1, 3] + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': true } + * ]; + * + * // using the `_.matches` callback shorthand + * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user'); + * // => ['barney'] + * + * // using the `_.matchesProperty` callback shorthand + * _.pluck(_.reject(users, 'active', false), 'user'); + * // => ['fred'] + * + * // using the `_.property` callback shorthand + * _.pluck(_.reject(users, 'active'), 'user'); + * // => ['barney'] + */ + function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); + } + + /** + * Gets a random element or `n` random elements from a collection. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to sample. + * @param {number} [n] The number of elements to sample. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {*} Returns the random sample(s). + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + * + * _.sample([1, 2, 3, 4], 2); + * // => [3, 1] + */ + function sample(collection, n, guard) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { + collection = toIterable(collection); + var length = collection.length; + return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; + } + var index = -1, + result = toArray(collection), + length = result.length, + lastIndex = length - 1; + + n = nativeMin(n < 0 ? 0 : (+n || 0), length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), + value = result[rand]; + + result[rand] = result[index]; + result[index] = value; + } + result.length = n; + return result; + } + + /** + * Creates an array of shuffled values, using a version of the + * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + * @example + * + * _.shuffle([1, 2, 3, 4]); + * // => [4, 1, 3, 2] + */ + function shuffle(collection) { + return sample(collection, POSITIVE_INFINITY); + } + + /** + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable properties for objects. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @returns {number} Returns the size of `collection`. + * @example + * + * _.size([1, 2, 3]); + * // => 3 + * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * + * _.size('pebbles'); + * // => 7 + */ + function size(collection) { + var length = collection ? getLength(collection) : 0; + return isLength(length) ? length : keys(collection).length; + } + + /** + * Checks if `predicate` returns truthy for **any** element of `collection`. + * The function returns as soon as it finds a passing value and does not iterate + * over the entire collection. The predicate is bound to `thisArg` and invoked + * with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias any + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + * @example + * + * _.some([null, 0, 'yes', false], Boolean); + * // => true + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.some(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.some(users, 'active', false); + * // => true + * + * // using the `_.property` callback shorthand + * _.some(users, 'active'); + * // => true + */ + function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != 'function' || thisArg !== undefined) { + predicate = getCallback(predicate, thisArg, 3); + } + return func(collection, predicate); + } + + /** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection through `iteratee`. This method performs + * a stable sort, that is, it preserves the original sort order of equal elements. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new sorted array. + * @example + * + * _.sortBy([1, 2, 3], function(n) { + * return Math.sin(n); + * }); + * // => [3, 1, 2] + * + * _.sortBy([1, 2, 3], function(n) { + * return this.sin(n); + * }, Math); + * // => [3, 1, 2] + * + * var users = [ + * { 'user': 'fred' }, + * { 'user': 'pebbles' }, + * { 'user': 'barney' } + * ]; + * + * // using the `_.property` callback shorthand + * _.pluck(_.sortBy(users, 'user'), 'user'); + * // => ['barney', 'fred', 'pebbles'] + */ + function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } + if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { + iteratee = undefined; + } + var index = -1; + iteratee = getCallback(iteratee, thisArg, 3); + + var result = baseMap(collection, function(value, key, collection) { + return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; + }); + return baseSortBy(result, compareAscending); + } + + /** + * This method is like `_.sortBy` except that it can sort by multiple iteratees + * or property names. + * + * If a property name is provided for an iteratee the created `_.property` + * style callback returns the property value of the given element. + * + * If an object is provided for an iteratee the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees + * The iteratees to sort by, specified as individual values or arrays of values. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 42 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.map(_.sortByAll(users, ['user', 'age']), _.values); + * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]] + * + * _.map(_.sortByAll(users, 'user', function(chr) { + * return Math.floor(chr.age / 10); + * }), _.values); + * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + */ + var sortByAll = restParam(function(collection, iteratees) { + if (collection == null) { + return []; + } + var guard = iteratees[2]; + if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) { + iteratees.length = 1; + } + return baseSortByOrder(collection, baseFlatten(iteratees), []); + }); + + /** + * This method is like `_.sortByAll` except that it allows specifying the + * sort orders of the iteratees to sort by. If `orders` is unspecified, all + * values are sorted in ascending order. Otherwise, a value is sorted in + * ascending order if its corresponding order is "asc", and descending if "desc". + * + * If a property name is provided for an iteratee the created `_.property` + * style callback returns the property value of the given element. + * + * If an object is provided for an iteratee the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {boolean[]} [orders] The sort orders of `iteratees`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 34 }, + * { 'user': 'fred', 'age': 42 }, + * { 'user': 'barney', 'age': 36 } + * ]; + * + * // sort by `user` in ascending order and by `age` in descending order + * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); + * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] + */ + function sortByOrder(collection, iteratees, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(iteratees, orders, guard)) { + orders = undefined; + } + if (!isArray(iteratees)) { + iteratees = iteratees == null ? [] : [iteratees]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseSortByOrder(collection, iteratees, orders); + } + + /** + * Performs a deep comparison between each element in `collection` and the + * source object, returning an array of all elements that have equivalent + * property values. + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. For comparing a single + * own or inherited property value see `_.matchesProperty`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Object} source The object of property values to match. + * @returns {Array} Returns the new filtered array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] }, + * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] } + * ]; + * + * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user'); + * // => ['barney'] + * + * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); + * // => ['fred'] + */ + function where(collection, source) { + return filter(collection, baseMatches(source)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Date + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => logs the number of milliseconds it took for the deferred function to be invoked + */ + var now = nativeNow || function() { + return new Date().getTime(); + }; + + /*------------------------------------------------------------------------*/ + + /** + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it is called `n` or more times. + * + * @static + * @memberOf _ + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => logs 'done saving!' after the two async saves have completed + */ + function after(n, func) { + if (typeof func != 'function') { + if (typeof n == 'function') { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + n = nativeIsFinite(n = +n) ? n : 0; + return function() { + if (--n < 1) { + return func.apply(this, arguments); + } + }; + } + + /** + * Creates a function that accepts up to `n` arguments ignoring any + * additional arguments. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new function. + * @example + * + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] + */ + function ary(func, n, guard) { + if (guard && isIterateeCall(func, n, guard)) { + n = undefined; + } + n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); + return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); + } + + /** + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it is called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. + * + * @static + * @memberOf _ + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery('#add').on('click', _.before(5, addContactToList)); + * // => allows adding up to 4 contacts to the list + */ + function before(n, func) { + var result; + if (typeof func != 'function') { + if (typeof n == 'function') { + var temp = n; + n = func; + func = temp; + } else { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + return function() { + if (--n > 0) { + result = func.apply(this, arguments); + } + if (n <= 1) { + func = undefined; + } + return result; + }; + } + + /** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and prepends any additional `_.bind` arguments to those provided to the + * bound function. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind` this method does not set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var greet = function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * }; + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // using placeholders + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ + var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); + }); + + /** + * Binds methods of an object to the object itself, overwriting the existing + * method. Method names may be specified as individual arguments or as arrays + * of method names. If no method names are provided all enumerable function + * properties, own and inherited, of `object` are bound. + * + * **Note:** This method does not set the "length" property of bound functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...(string|string[])} [methodNames] The object method names to bind, + * specified as individual method names or arrays of method names. + * @returns {Object} Returns `object`. + * @example + * + * var view = { + * 'label': 'docs', + * 'onClick': function() { + * console.log('clicked ' + this.label); + * } + * }; + * + * _.bindAll(view); + * jQuery('#docs').on('click', view.onClick); + * // => logs 'clicked docs' when the element is clicked + */ + var bindAll = restParam(function(object, methodNames) { + methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); + + var index = -1, + length = methodNames.length; + + while (++index < length) { + var key = methodNames[index]; + object[key] = createWrapper(object[key], BIND_FLAG, object); + } + return object; + }); + + /** + * Creates a function that invokes the method at `object[key]` and prepends + * any additional `_.bindKey` arguments to those provided to the bound function. + * + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. + * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. + * + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * @static + * @memberOf _ + * @category Function + * @param {Object} object The object the method belongs to. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } + * }; + * + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; + * + * bound('!'); + * // => 'hiya fred!' + * + * // using placeholders + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' + */ + var bindKey = restParam(function(object, key, partials) { + var bitmask = BIND_FLAG | BIND_KEY_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bindKey.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(key, bitmask, object, partials, holders); + }); + + /** + * Creates a function that accepts one or more arguments of `func` that when + * called either invokes `func` returning its result, if all `func` arguments + * have been provided, or returns a function that accepts one or more of the + * remaining `func` arguments, and so on. The arity of `func` may be specified + * if `func.length` is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method does not set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curry(abc); + * + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // using placeholders + * curried(1)(_, 3)(2); + * // => [1, 2, 3] + */ + var curry = createCurry(CURRY_FLAG); + + /** + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method does not set the "length" property of curried functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the new curried function. + * @example + * + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; + * + * var curried = _.curryRight(abc); + * + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // using placeholders + * curried(3)(1, _)(2); + * // => [1, 2, 3] + */ + var curryRight = createCurry(CURRY_RIGHT_FLAG); + + /** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed invocations. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the debounced function return the result of the last + * `func` invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked + * on the trailing edge of the timeout only if the the debounced function is + * invoked more than once during the `wait` timeout. + * + * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=false] Specify invoking on the leading + * edge of the timeout. + * @param {number} [options.maxWait] The maximum time `func` is allowed to be + * delayed before it is invoked. + * @param {boolean} [options.trailing=true] Specify invoking on the trailing + * edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // avoid costly calculations while the window size is in flux + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // invoke `sendMail` when the click event is fired, debouncing subsequent calls + * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // ensure `batchLog` is invoked once after 1 second of debounced calls + * var source = new EventSource('/stream'); + * jQuery(source).on('message', _.debounce(batchLog, 250, { + * 'maxWait': 1000 + * })); + * + * // cancel a debounced call + * var todoChanges = _.debounce(batchLog, 1000); + * Object.observe(models.todo, todoChanges); + * + * Object.observe(models, function(changes) { + * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) { + * todoChanges.cancel(); + * } + * }, ['delete']); + * + * // ...at some point `models.todo` is changed + * models.todo.completed = true; + * + * // ...before 1 second has passed `models.todo` is deleted + * // which cancels the debounced `todoChanges` call + * delete models.todo; + */ + function debounce(func, wait, options) { + var args, + maxTimeoutId, + result, + stamp, + thisArg, + timeoutId, + trailingCall, + lastCalled = 0, + maxWait = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + wait = wait < 0 ? 0 : (+wait || 0); + if (options === true) { + var leading = true; + trailing = false; + } else if (isObject(options)) { + leading = !!options.leading; + maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function cancel() { + if (timeoutId) { + clearTimeout(timeoutId); + } + if (maxTimeoutId) { + clearTimeout(maxTimeoutId); + } + lastCalled = 0; + maxTimeoutId = timeoutId = trailingCall = undefined; + } + + function complete(isCalled, id) { + if (id) { + clearTimeout(id); + } + maxTimeoutId = timeoutId = trailingCall = undefined; + if (isCalled) { + lastCalled = now(); + result = func.apply(thisArg, args); + if (!timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + } + } + + function delayed() { + var remaining = wait - (now() - stamp); + if (remaining <= 0 || remaining > wait) { + complete(trailingCall, maxTimeoutId); + } else { + timeoutId = setTimeout(delayed, remaining); + } + } + + function maxDelayed() { + complete(trailing, timeoutId); + } + + function debounced() { + args = arguments; + stamp = now(); + thisArg = this; + trailingCall = trailing && (timeoutId || !leading); + + if (maxWait === false) { + var leadingCall = leading && !timeoutId; + } else { + if (!maxTimeoutId && !leading) { + lastCalled = stamp; + } + var remaining = maxWait - (stamp - lastCalled), + isCalled = remaining <= 0 || remaining > maxWait; + + if (isCalled) { + if (maxTimeoutId) { + maxTimeoutId = clearTimeout(maxTimeoutId); + } + lastCalled = stamp; + result = func.apply(thisArg, args); + } + else if (!maxTimeoutId) { + maxTimeoutId = setTimeout(maxDelayed, remaining); + } + } + if (isCalled && timeoutId) { + timeoutId = clearTimeout(timeoutId); + } + else if (!timeoutId && wait !== maxWait) { + timeoutId = setTimeout(delayed, wait); + } + if (leadingCall) { + isCalled = true; + result = func.apply(thisArg, args); + } + if (isCalled && !timeoutId && !maxTimeoutId) { + args = thisArg = undefined; + } + return result; + } + debounced.cancel = cancel; + return debounced; + } + + /** + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // logs 'deferred' after one or more milliseconds + */ + var defer = restParam(function(func, args) { + return baseDelay(func, 1, args); + }); + + /** + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it is invoked. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke the function with. + * @returns {number} Returns the timer id. + * @example + * + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => logs 'later' after one second + */ + var delay = restParam(function(func, wait, args) { + return baseDelay(func, wait, args); + }); + + /** + * Creates a function that returns the result of invoking the provided + * functions with the `this` binding of the created function, where each + * successive invocation is supplied the return value of the previous. + * + * @static + * @memberOf _ + * @category Function + * @param {...Function} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flow(_.add, square); + * addSquare(1, 2); + * // => 9 + */ + var flow = createFlow(); + + /** + * This method is like `_.flow` except that it creates a function that + * invokes the provided functions from right to left. + * + * @static + * @memberOf _ + * @alias backflow, compose + * @category Function + * @param {...Function} [funcs] Functions to invoke. + * @returns {Function} Returns the new function. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flowRight(square, _.add); + * addSquare(1, 2); + * // => 9 + */ + var flowRight = createFlow(true); + + /** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is coerced to a string and used as the + * cache key. The `func` is invoked with the `this` binding of the memoized + * function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * method interface of `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoizing function. + * @example + * + * var upperCase = _.memoize(function(string) { + * return string.toUpperCase(); + * }); + * + * upperCase('fred'); + * // => 'FRED' + * + * // modifying the result cache + * upperCase.cache.set('fred', 'BARNEY'); + * upperCase('fred'); + * // => 'BARNEY' + * + * // replacing `_.memoize.Cache` + * var object = { 'user': 'fred' }; + * var other = { 'user': 'barney' }; + * var identity = _.memoize(_.identity); + * + * identity(object); + * // => { 'user': 'fred' } + * identity(other); + * // => { 'user': 'fred' } + * + * _.memoize.Cache = WeakMap; + * var identity = _.memoize(_.identity); + * + * identity(object); + * // => { 'user': 'fred' } + * identity(other); + * // => { 'user': 'barney' } + */ + function memoize(func, resolver) { + if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new memoize.Cache; + return memoized; + } + + /** + * Creates a function that runs each argument through a corresponding + * transform function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to wrap. + * @param {...(Function|Function[])} [transforms] The functions to transform + * arguments, specified as individual functions or arrays of functions. + * @returns {Function} Returns the new function. + * @example + * + * function doubled(n) { + * return n * 2; + * } + * + * function square(n) { + * return n * n; + * } + * + * var modded = _.modArgs(function(x, y) { + * return [x, y]; + * }, square, doubled); + * + * modded(1, 2); + * // => [1, 4] + * + * modded(5, 10); + * // => [25, 20] + */ + var modArgs = restParam(function(func, transforms) { + transforms = baseFlatten(transforms); + if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = transforms.length; + return restParam(function(args) { + var index = nativeMin(args.length, length); + while (index--) { + args[index] = transforms[index](args[index]); + } + return func.apply(this, args); + }); + }); + + /** + * Creates a function that negates the result of the predicate `func`. The + * `func` predicate is invoked with the `this` binding and arguments of the + * created function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} predicate The predicate to negate. + * @returns {Function} Returns the new function. + * @example + * + * function isEven(n) { + * return n % 2 == 0; + * } + * + * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); + * // => [1, 3, 5] + */ + function negate(predicate) { + if (typeof predicate != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function() { + return !predicate.apply(this, arguments); + }; + } + + /** + * Creates a function that is restricted to invoking `func` once. Repeat calls + * to the function return the value of the first call. The `func` is invoked + * with the `this` binding and arguments of the created function. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var initialize = _.once(createApplication); + * initialize(); + * initialize(); + * // `initialize` invokes `createApplication` once + */ + function once(func) { + return before(2, func); + } + + /** + * Creates a function that invokes `func` with `partial` arguments prepended + * to those provided to the new function. This method is like `_.bind` except + * it does **not** alter the `this` binding. + * + * The `_.partial.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method does not set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var greet = function(greeting, name) { + * return greeting + ' ' + name; + * }; + * + * var sayHelloTo = _.partial(greet, 'hello'); + * sayHelloTo('fred'); + * // => 'hello fred' + * + * // using placeholders + * var greetFred = _.partial(greet, _, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + */ + var partial = createPartial(PARTIAL_FLAG); + + /** + * This method is like `_.partial` except that partially applied arguments + * are appended to those provided to the new function. + * + * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. + * + * **Note:** This method does not set the "length" property of partially + * applied functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to partially apply arguments to. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new partially applied function. + * @example + * + * var greet = function(greeting, name) { + * return greeting + ' ' + name; + * }; + * + * var greetFred = _.partialRight(greet, 'fred'); + * greetFred('hi'); + * // => 'hi fred' + * + * // using placeholders + * var sayHelloTo = _.partialRight(greet, 'hello', _); + * sayHelloTo('fred'); + * // => 'hello fred' + */ + var partialRight = createPartial(PARTIAL_RIGHT_FLAG); + + /** + * Creates a function that invokes `func` with arguments arranged according + * to the specified indexes where the argument value at the first index is + * provided as the first argument, the argument value at the second index is + * provided as the second argument, and so on. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to rearrange arguments for. + * @param {...(number|number[])} indexes The arranged argument indexes, + * specified as individual indexes or arrays of indexes. + * @returns {Function} Returns the new function. + * @example + * + * var rearged = _.rearg(function(a, b, c) { + * return [a, b, c]; + * }, 2, 0, 1); + * + * rearged('b', 'c', 'a') + * // => ['a', 'b', 'c'] + * + * var map = _.rearg(_.map, [1, 0]); + * map(function(n) { + * return n * 3; + * }, [1, 2, 3]); + * // => [3, 6, 9] + */ + var rearg = restParam(function(func, indexes) { + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); + }); + + /** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as an array. + * + * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.restParam(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ + function restParam(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + rest = Array(length); + + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: return func.call(this, rest); + case 1: return func.call(this, args[0], rest); + case 2: return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; + } + + /** + * Creates a function that invokes `func` with the `this` binding of the created + * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3). + * + * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to spread arguments over. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.spread(function(who, what) { + * return who + ' says ' + what; + * }); + * + * say(['fred', 'hello']); + * // => 'fred says hello' + * + * // with a Promise + * var numbers = Promise.all([ + * Promise.resolve(40), + * Promise.resolve(36) + * ]); + * + * numbers.then(_.spread(function(x, y) { + * return x + y; + * })); + * // => a Promise of 76 + */ + function spread(func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return function(array) { + return func.apply(this, array); + }; + } + + /** + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed invocations. Provide an options object to indicate + * that `func` should be invoked on the leading and/or trailing edge of the + * `wait` timeout. Subsequent calls to the throttled function return the + * result of the last `func` call. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * + * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * for details over the differences between `_.throttle` and `_.debounce`. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to throttle. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. + * @param {Object} [options] The options object. + * @param {boolean} [options.leading=true] Specify invoking on the leading + * edge of the timeout. + * @param {boolean} [options.trailing=true] Specify invoking on the trailing + * edge of the timeout. + * @returns {Function} Returns the new throttled function. + * @example + * + * // avoid excessively updating the position while scrolling + * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); + * + * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); + * + * // cancel a trailing throttled call + * jQuery(window).on('popstate', throttled.cancel); + */ + function throttle(func, wait, options) { + var leading = true, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (options === false) { + leading = false; + } else if (isObject(options)) { + leading = 'leading' in options ? !!options.leading : leading; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); + } + + /** + * Creates a function that provides `value` to the wrapper function as its + * first argument. Any additional arguments provided to the function are + * appended to those provided to the wrapper function. The wrapper is invoked + * with the `this` binding of the created function. + * + * @static + * @memberOf _ + * @category Function + * @param {*} value The value to wrap. + * @param {Function} wrapper The wrapper function. + * @returns {Function} Returns the new function. + * @example + * + * var p = _.wrap(_.escape, function(func, text) { + * return '' + func(text) + ''; + * }); + * + * p('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function wrap(value, wrapper) { + wrapper = wrapper == null ? identity : wrapper; + return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []); + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, + * otherwise they are assigned by reference. If `customizer` is provided it is + * invoked to produce the cloned values. If `customizer` returns `undefined` + * cloning is handled by the method instead. The `customizer` is bound to + * `thisArg` and invoked with two argument; (value [, index|key, object]). + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). + * The enumerable properties of `arguments` objects and objects created by + * constructors other than `Object` are cloned to plain `Object` objects. An + * empty object is returned for uncloneable values such as functions, DOM nodes, + * Maps, Sets, and WeakMaps. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {*} Returns the cloned value. + * @example + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * var shallow = _.clone(users); + * shallow[0] === users[0]; + * // => true + * + * var deep = _.clone(users, true); + * deep[0] === users[0]; + * // => false + * + * // using a customizer callback + * var el = _.clone(document.body, function(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } + * }); + * + * el === document.body + * // => false + * el.nodeName + * // => BODY + * el.childNodes.length; + * // => 0 + */ + function clone(value, isDeep, customizer, thisArg) { + if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } + else if (typeof isDeep == 'function') { + thisArg = customizer; + customizer = isDeep; + isDeep = false; + } + return typeof customizer == 'function' + ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1)) + : baseClone(value, isDeep); + } + + /** + * Creates a deep clone of `value`. If `customizer` is provided it is invoked + * to produce the cloned values. If `customizer` returns `undefined` cloning + * is handled by the method instead. The `customizer` is bound to `thisArg` + * and invoked with two argument; (value [, index|key, object]). + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). + * The enumerable properties of `arguments` objects and objects created by + * constructors other than `Object` are cloned to plain `Object` objects. An + * empty object is returned for uncloneable values such as functions, DOM nodes, + * Maps, Sets, and WeakMaps. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {*} Returns the deep cloned value. + * @example + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * var deep = _.cloneDeep(users); + * deep[0] === users[0]; + * // => false + * + * // using a customizer callback + * var el = _.cloneDeep(document.body, function(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * }); + * + * el === document.body + * // => false + * el.nodeName + * // => BODY + * el.childNodes.length; + * // => 20 + */ + function cloneDeep(value, customizer, thisArg) { + return typeof customizer == 'function' + ? baseClone(value, true, bindCallback(customizer, thisArg, 1)) + : baseClone(value, true); + } + + /** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ + function gt(value, other) { + return value > other; + } + + /** + * Checks if `value` is greater than or equal to `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`. + * @example + * + * _.gte(3, 1); + * // => true + * + * _.gte(3, 3); + * // => true + * + * _.gte(1, 3); + * // => false + */ + function gte(value, other) { + return value >= other; + } + + /** + * Checks if `value` is classified as an `arguments` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ + function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && + hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); + } + + /** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(function() { return arguments; }()); + * // => false + */ + var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; + }; + + /** + * Checks if `value` is classified as a boolean primitive or object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isBoolean(false); + * // => true + * + * _.isBoolean(null); + * // => false + */ + function isBoolean(value) { + return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag); + } + + /** + * Checks if `value` is classified as a `Date` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isDate(new Date); + * // => true + * + * _.isDate('Mon April 23 2012'); + * // => false + */ + function isDate(value) { + return isObjectLike(value) && objToString.call(value) == dateTag; + } + + /** + * Checks if `value` is a DOM element. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. + * @example + * + * _.isElement(document.body); + * // => true + * + * _.isElement(''); + * // => false + */ + function isElement(value) { + return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); + } + + /** + * Checks if `value` is empty. A value is considered empty unless it is an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {Array|Object|string} value The value to inspect. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ + function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || + (isObjectLike(value) && isFunction(value.splice)))) { + return !value.length; + } + return !keys(value).length; + } + + /** + * Performs a deep comparison between two values to determine if they are + * equivalent. If `customizer` is provided it is invoked to compare values. + * If `customizer` returns `undefined` comparisons are handled by the method + * instead. The `customizer` is bound to `thisArg` and invoked with three + * arguments: (value, other [, index|key]). + * + * **Note:** This method supports comparing arrays, booleans, `Date` objects, + * numbers, `Object` objects, regexes, and strings. Objects are compared by + * their own, not inherited, enumerable properties. Functions and DOM nodes + * are **not** supported. Provide a customizer function to extend support + * for comparing other values. + * + * @static + * @memberOf _ + * @alias eq + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize value comparisons. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'user': 'fred' }; + * var other = { 'user': 'fred' }; + * + * object == other; + * // => false + * + * _.isEqual(object, other); + * // => true + * + * // using a customizer callback + * var array = ['hello', 'goodbye']; + * var other = ['hi', 'goodbye']; + * + * _.isEqual(array, other, function(value, other) { + * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { + * return true; + * } + * }); + * // => true + */ + function isEqual(value, other, customizer, thisArg) { + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; + var result = customizer ? customizer(value, other) : undefined; + return result === undefined ? baseIsEqual(value, other, customizer) : !!result; + } + + /** + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. + * @example + * + * _.isError(new Error); + * // => true + * + * _.isError(Error); + * // => false + */ + function isError(value) { + return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag; + } + + /** + * Checks if `value` is a finite primitive number. + * + * **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @example + * + * _.isFinite(10); + * // => true + * + * _.isFinite('10'); + * // => false + * + * _.isFinite(true); + * // => false + * + * _.isFinite(Object(10)); + * // => false + * + * _.isFinite(Infinity); + * // => false + */ + function isFinite(value) { + return typeof value == 'number' && nativeIsFinite(value); + } + + /** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ + function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return isObject(value) && objToString.call(value) == funcTag; + } + + /** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ + function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); + } + + /** + * Performs a deep comparison between `object` and `source` to determine if + * `object` contains equivalent property values. If `customizer` is provided + * it is invoked to compare values. If `customizer` returns `undefined` + * comparisons are handled by the method instead. The `customizer` is bound + * to `thisArg` and invoked with three arguments: (value, other, index|key). + * + * **Note:** This method supports comparing properties of arrays, booleans, + * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions + * and DOM nodes are **not** supported. Provide a customizer function to extend + * support for comparing other values. + * + * @static + * @memberOf _ + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Function} [customizer] The function to customize value comparisons. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.isMatch(object, { 'age': 40 }); + * // => true + * + * _.isMatch(object, { 'age': 36 }); + * // => false + * + * // using a customizer callback + * var object = { 'greeting': 'hello' }; + * var source = { 'greeting': 'hi' }; + * + * _.isMatch(object, source, function(value, other) { + * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + * }); + * // => true + */ + function isMatch(object, source, customizer, thisArg) { + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; + return baseIsMatch(object, getMatchData(source), customizer); + } + + /** + * Checks if `value` is `NaN`. + * + * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4) + * which returns `true` for `undefined` and other non-numeric values. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + * @example + * + * _.isNaN(NaN); + * // => true + * + * _.isNaN(new Number(NaN)); + * // => true + * + * isNaN(undefined); + * // => true + * + * _.isNaN(undefined); + * // => false + */ + function isNaN(value) { + // An `NaN` primitive is the only value that is not equal to itself. + // Perform the `toStringTag` check first to avoid errors with some host objects in IE. + return isNumber(value) && value != +value; + } + + /** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ + function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); + } + + /** + * Checks if `value` is `null`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `null`, else `false`. + * @example + * + * _.isNull(null); + * // => true + * + * _.isNull(void 0); + * // => false + */ + function isNull(value) { + return value === null; + } + + /** + * Checks if `value` is classified as a `Number` primitive or object. + * + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified + * as numbers, use the `_.isFinite` method. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isNumber(8.4); + * // => true + * + * _.isNumber(NaN); + * // => true + * + * _.isNumber('8.4'); + * // => false + */ + function isNumber(value) { + return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag); + } + + /** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * **Note:** This method assumes objects created by the `Object` constructor + * have no inherited enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ + function isPlainObject(value) { + var Ctor; + + // Exit early for non `Object` objects. + if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || + (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { + return false; + } + // IE < 9 iterates inherited properties before own properties. If the first + // iterated property is an object's own property then there are no inherited + // enumerable properties. + var result; + // In most environments an object's own properties are iterated before + // its inherited properties. If the last iterated property is an object's + // own property then there are no inherited enumerable properties. + baseForIn(value, function(subValue, key) { + result = key; + }); + return result === undefined || hasOwnProperty.call(value, result); + } + + /** + * Checks if `value` is classified as a `RegExp` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isRegExp(/abc/); + * // => true + * + * _.isRegExp('/abc/'); + * // => false + */ + function isRegExp(value) { + return isObject(value) && objToString.call(value) == regexpTag; + } + + /** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ + function isString(value) { + return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); + } + + /** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ + function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; + } + + /** + * Checks if `value` is `undefined`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ + function isUndefined(value) { + return value === undefined; + } + + /** + * Checks if `value` is less than `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. + * @example + * + * _.lt(1, 3); + * // => true + * + * _.lt(3, 3); + * // => false + * + * _.lt(3, 1); + * // => false + */ + function lt(value, other) { + return value < other; + } + + /** + * Checks if `value` is less than or equal to `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`. + * @example + * + * _.lte(1, 3); + * // => true + * + * _.lte(3, 3); + * // => true + * + * _.lte(3, 1); + * // => false + */ + function lte(value, other) { + return value <= other; + } + + /** + * Converts `value` to an array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * (function() { + * return _.toArray(arguments).slice(1); + * }(1, 2, 3)); + * // => [2, 3] + */ + function toArray(value) { + var length = value ? getLength(value) : 0; + if (!isLength(length)) { + return values(value); + } + if (!length) { + return []; + } + return arrayCopy(value); + } + + /** + * Converts `value` to a plain object flattening inherited enumerable + * properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ + function toPlainObject(value) { + return baseCopy(value, keysIn(value)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Recursively merges own enumerable properties of the source object(s), that + * don't resolve to `undefined` into the destination object. Subsequent sources + * overwrite property assignments of previous sources. If `customizer` is + * provided it is invoked to produce the merged values of the destination and + * source properties. If `customizer` returns `undefined` merging is handled + * by the method instead. The `customizer` is bound to `thisArg` and invoked + * with five arguments: (objectValue, sourceValue, key, object, source). + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {Object} Returns `object`. + * @example + * + * var users = { + * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }] + * }; + * + * var ages = { + * 'data': [{ 'age': 36 }, { 'age': 40 }] + * }; + * + * _.merge(users, ages); + * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } + * + * // using a customizer callback + * var object = { + * 'fruits': ['apple'], + * 'vegetables': ['beet'] + * }; + * + * var other = { + * 'fruits': ['banana'], + * 'vegetables': ['carrot'] + * }; + * + * _.merge(object, other, function(a, b) { + * if (_.isArray(a)) { + * return a.concat(b); + * } + * }); + * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } + */ + var merge = createAssigner(baseMerge); + + /** + * Assigns own enumerable properties of source object(s) to the destination + * object. Subsequent sources overwrite property assignments of previous sources. + * If `customizer` is provided it is invoked to produce the assigned values. + * The `customizer` is bound to `thisArg` and invoked with five arguments: + * (objectValue, sourceValue, key, object, source). + * + * **Note:** This method mutates `object` and is based on + * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). + * + * @static + * @memberOf _ + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {Object} Returns `object`. + * @example + * + * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); + * // => { 'user': 'fred', 'age': 40 } + * + * // using a customizer callback + * var defaults = _.partialRight(_.assign, function(value, other) { + * return _.isUndefined(value) ? other : value; + * }); + * + * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); + * // => { 'user': 'barney', 'age': 36 } + */ + var assign = createAssigner(function(object, source, customizer) { + return customizer + ? assignWith(object, source, customizer) + : baseAssign(object, source); + }); + + /** + * Creates an object that inherits from the given `prototype` object. If a + * `properties` object is provided its own enumerable properties are assigned + * to the created object. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ + function create(prototype, properties, guard) { + var result = baseCreate(prototype); + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = undefined; + } + return properties ? baseAssign(result, properties) : result; + } + + /** + * Assigns own enumerable properties of source object(s) to the destination + * object for all destination properties that resolve to `undefined`. Once a + * property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); + * // => { 'user': 'barney', 'age': 36 } + */ + var defaults = createDefaults(assign, assignDefaults); + + /** + * This method is like `_.defaults` except that it recursively assigns + * default properties. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } }); + * // => { 'user': { 'name': 'barney', 'age': 36 } } + * + */ + var defaultsDeep = createDefaults(merge, mergeDefaults); + + /** + * This method is like `_.find` except that it returns the key of the first + * element `predicate` returns truthy for instead of the element itself. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findKey(users, function(chr) { + * return chr.age < 40; + * }); + * // => 'barney' (iteration order is not guaranteed) + * + * // using the `_.matches` callback shorthand + * _.findKey(users, { 'age': 1, 'active': true }); + * // => 'pebbles' + * + * // using the `_.matchesProperty` callback shorthand + * _.findKey(users, 'active', false); + * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.findKey(users, 'active'); + * // => 'barney' + */ + var findKey = createFindKey(baseForOwn); + + /** + * This method is like `_.findKey` except that it iterates over elements of + * a collection in the opposite order. + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {string|undefined} Returns the key of the matched element, else `undefined`. + * @example + * + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findLastKey(users, function(chr) { + * return chr.age < 40; + * }); + * // => returns `pebbles` assuming `_.findKey` returns `barney` + * + * // using the `_.matches` callback shorthand + * _.findLastKey(users, { 'age': 36, 'active': true }); + * // => 'barney' + * + * // using the `_.matchesProperty` callback shorthand + * _.findLastKey(users, 'active', false); + * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.findLastKey(users, 'active'); + * // => 'pebbles' + */ + var findLastKey = createFindKey(baseForOwnRight); + + /** + * Iterates over own and inherited enumerable properties of an object invoking + * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns `object`. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed) + */ + var forIn = createForIn(baseFor); + + /** + * This method is like `_.forIn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns `object`. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forInRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c' + */ + var forInRight = createForIn(baseForRight); + + /** + * Iterates over own enumerable properties of an object invoking `iteratee` + * for each property. The `iteratee` is bound to `thisArg` and invoked with + * three arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns `object`. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => logs 'a' and 'b' (iteration order is not guaranteed) + */ + var forOwn = createForOwn(baseForOwn); + + /** + * This method is like `_.forOwn` except that it iterates over properties of + * `object` in the opposite order. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns `object`. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' + */ + var forOwnRight = createForOwn(baseForOwnRight); + + /** + * Creates an array of function property names from all enumerable properties, + * own and inherited, of `object`. + * + * @static + * @memberOf _ + * @alias methods + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the new array of property names. + * @example + * + * _.functions(_); + * // => ['after', 'ary', 'assign', ...] + */ + function functions(object) { + return baseFunctions(object, keysIn(object)); + } + + /** + * Gets the property value at `path` of `object`. If the resolved value is + * `undefined` the `defaultValue` is used in its place. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ + function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, toPath(path), path + ''); + return result === undefined ? defaultValue : result; + } + + /** + * Checks if `path` is a direct property. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` is a direct property, else `false`. + * @example + * + * var object = { 'a': { 'b': { 'c': 3 } } }; + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b.c'); + * // => true + * + * _.has(object, ['a', 'b', 'c']); + * // => true + */ + function has(object, path) { + if (object == null) { + return false; + } + var result = hasOwnProperty.call(object, path); + if (!result && !isKey(path)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + path = last(path); + result = hasOwnProperty.call(object, path); + } + return result || (isLength(object.length) && isIndex(path, object.length) && + (isArray(object) || isArguments(object))); + } + + /** + * Creates an object composed of the inverted keys and values of `object`. + * If `object` contains duplicate values, subsequent values overwrite property + * assignments of previous values unless `multiValue` is `true`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to invert. + * @param {boolean} [multiValue] Allow multiple values per key. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invert(object); + * // => { '1': 'c', '2': 'b' } + * + * // with `multiValue` + * _.invert(object, true); + * // => { '1': ['a', 'c'], '2': ['b'] } + */ + function invert(object, multiValue, guard) { + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = undefined; + } + var index = -1, + props = keys(object), + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index], + value = object[key]; + + if (multiValue) { + if (hasOwnProperty.call(result, value)) { + result[value].push(key); + } else { + result[value] = [key]; + } + } + else { + result[value] = key; + } + } + return result; + } + + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * for more details. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if ((typeof Ctor == 'function' && Ctor.prototype === object) || + (typeof object != 'function' && isArrayLike(object))) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; + }; + + /** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ + function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = (length && isLength(length) && + (isArray(object) || isArguments(object)) && length) || 0; + + var Ctor = object.constructor, + index = -1, + isProto = typeof Ctor == 'function' && Ctor.prototype === object, + result = Array(length), + skipIndexes = length > 0; + + while (++index < length) { + result[index] = (index + ''); + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && + !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; + } + + /** + * The opposite of `_.mapValues`; this method creates an object with the + * same values as `object` and keys generated by running each own enumerable + * property of `object` through `iteratee`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the new mapped object. + * @example + * + * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { + * return key + value; + * }); + * // => { 'a1': 1, 'b2': 2 } + */ + var mapKeys = createObjectMapper(true); + + /** + * Creates an object with the same keys as `object` and values generated by + * running each own enumerable property of `object` through `iteratee`. The + * iteratee function is bound to `thisArg` and invoked with three arguments: + * (value, key, object). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Object} Returns the new mapped object. + * @example + * + * _.mapValues({ 'a': 1, 'b': 2 }, function(n) { + * return n * 3; + * }); + * // => { 'a': 3, 'b': 6 } + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * // using the `_.property` callback shorthand + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ + var mapValues = createObjectMapper(); + + /** + * The opposite of `_.pick`; this method creates an object composed of the + * own and inherited enumerable properties of `object` that are not omitted. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {Function|...(string|string[])} [predicate] The function invoked per + * iteration or property names to omit, specified as individual property + * names or arrays of property names. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.omit(object, 'age'); + * // => { 'user': 'fred' } + * + * _.omit(object, _.isNumber); + * // => { 'user': 'fred' } + */ + var omit = restParam(function(object, props) { + if (object == null) { + return {}; + } + if (typeof props[0] != 'function') { + var props = arrayMap(baseFlatten(props), String); + return pickByArray(object, baseDifference(keysIn(object), props)); + } + var predicate = bindCallback(props[0], props[1], 3); + return pickByCallback(object, function(value, key, object) { + return !predicate(value, key, object); + }); + }); + + /** + * Creates a two dimensional array of the key-value pairs for `object`, + * e.g. `[[key1, value1], [key2, value2]]`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the new array of key-value pairs. + * @example + * + * _.pairs({ 'barney': 36, 'fred': 40 }); + * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) + */ + function pairs(object) { + object = toObject(object); + + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } + return result; + } + + /** + * Creates an object composed of the picked `object` properties. Property + * names may be specified as individual arguments or as arrays of property + * names. If `predicate` is provided it is invoked for each property of `object` + * picking the properties `predicate` returns truthy for. The predicate is + * bound to `thisArg` and invoked with three arguments: (value, key, object). + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {Function|...(string|string[])} [predicate] The function invoked per + * iteration or property names to pick, specified as individual property + * names or arrays of property names. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.pick(object, 'user'); + * // => { 'user': 'fred' } + * + * _.pick(object, _.isString); + * // => { 'user': 'fred' } + */ + var pick = restParam(function(object, props) { + if (object == null) { + return {}; + } + return typeof props[0] == 'function' + ? pickByCallback(object, bindCallback(props[0], props[1], 3)) + : pickByArray(object, baseFlatten(props)); + }); + + /** + * This method is like `_.get` except that if the resolved value is a function + * it is invoked with the `this` binding of its parent object and its result + * is returned. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to resolve. + * @param {*} [defaultValue] The value returned if the resolved value is `undefined`. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; + * + * _.result(object, 'a[0].b.c1'); + * // => 3 + * + * _.result(object, 'a[0].b.c2'); + * // => 4 + * + * _.result(object, 'a.b.c', 'default'); + * // => 'default' + * + * _.result(object, 'a.b.c', _.constant('default')); + * // => 'default' + */ + function result(object, path, defaultValue) { + var result = object == null ? undefined : object[path]; + if (result === undefined) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + result = object == null ? undefined : object[last(path)]; + } + result = result === undefined ? defaultValue : result; + } + return isFunction(result) ? result.call(object) : result; + } + + /** + * Sets the property value of `path` on `object`. If a portion of `path` + * does not exist it is created. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to augment. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, 'x[0].y.z', 5); + * console.log(object.x[0].y.z); + * // => 5 + */ + function set(object, path, value) { + if (object == null) { + return object; + } + var pathKey = (path + ''); + path = (object[pathKey] != null || isKey(path, object)) ? [pathKey] : toPath(path); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = path[index]; + if (isObject(nested)) { + if (index == lastIndex) { + nested[key] = value; + } else if (nested[key] == null) { + nested[key] = isIndex(path[index + 1]) ? [] : {}; + } + } + nested = nested[key]; + } + return object; + } + + /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own enumerable + * properties through `iteratee`, with each invocation potentially mutating + * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked + * with four arguments: (accumulator, value, key, object). Iteratee functions + * may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Array|Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; + * }); + * // => [4, 9] + * + * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { + * result[key] = n * 3; + * }); + * // => { 'a': 3, 'b': 6 } + */ + function transform(object, iteratee, accumulator, thisArg) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = getCallback(iteratee, thisArg, 4); + + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor : []; + } else { + accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); + } + } else { + accumulator = {}; + } + } + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; + } + + /** + * Creates an array of the own enumerable property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ + function values(object) { + return baseValues(object, keys(object)); + } + + /** + * Creates an array of the own and inherited enumerable property values + * of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.valuesIn(new Foo); + * // => [1, 2, 3] (iteration order is not guaranteed) + */ + function valuesIn(object) { + return baseValues(object, keysIn(object)); + } + + /*------------------------------------------------------------------------*/ + + /** + * Checks if `n` is between `start` and up to but not including, `end`. If + * `end` is not specified it is set to `start` with `start` then set to `0`. + * + * @static + * @memberOf _ + * @category Number + * @param {number} n The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `n` is in the range, else `false`. + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + */ + function inRange(value, start, end) { + start = +start || 0; + if (end === undefined) { + end = start; + start = 0; + } else { + end = +end || 0; + } + return value >= nativeMin(start, end) && value < nativeMax(start, end); + } + + /** + * Produces a random number between `min` and `max` (inclusive). If only one + * argument is provided a number between `0` and the given number is returned. + * If `floating` is `true`, or either `min` or `max` are floats, a floating-point + * number is returned instead of an integer. + * + * @static + * @memberOf _ + * @category Number + * @param {number} [min=0] The minimum possible value. + * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating] Specify returning a floating-point number. + * @returns {number} Returns the random number. + * @example + * + * _.random(0, 5); + * // => an integer between 0 and 5 + * + * _.random(5); + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 + */ + function random(min, max, floating) { + if (floating && isIterateeCall(min, max, floating)) { + max = floating = undefined; + } + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (noMax && typeof min == 'boolean') { + floating = min; + min = 1; + } + else if (typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { + max = 1; + noMax = false; + } + min = +min || 0; + if (noMax) { + max = min; + min = 0; + } else { + max = +max || 0; + } + if (floating || min % 1 || max % 1) { + var rand = nativeRandom(); + return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max); + } + return baseRandom(min, max); + } + + /*------------------------------------------------------------------------*/ + + /** + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Foo Bar'); + * // => 'fooBar' + * + * _.camelCase('--foo-bar'); + * // => 'fooBar' + * + * _.camelCase('__foo_bar__'); + * // => 'fooBar' + */ + var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word); + }); + + /** + * Capitalizes the first character of `string`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * _.capitalize('fred'); + * // => 'Fred' + */ + function capitalize(string) { + string = baseToString(string); + return string && (string.charAt(0).toUpperCase() + string.slice(1)); + } + + /** + * Deburrs `string` by converting [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. + * @example + * + * _.deburr('déjà vu'); + * // => 'deja vu' + */ + function deburr(string) { + string = baseToString(string); + return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, ''); + } + + /** + * Checks if `string` ends with the given target string. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search from. + * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ + function endsWith(string, target, position) { + string = baseToString(string); + target = (target + ''); + + var length = string.length; + position = position === undefined + ? length + : nativeMin(position < 0 ? 0 : (+position || 0), length); + + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; + } + + /** + * Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to + * their corresponding HTML entities. + * + * **Note:** No other characters are escaped. To escape additional characters + * use a third-party library like [_he_](https://mths.be/he). + * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't need escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. + * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can break out + * of attribute values or HTML comments. See [#59](https://html5sec.org/#59), + * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and + * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/) + * for more details. + * + * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping) + * to reduce XSS vectors. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ + function escape(string) { + // Reset `lastIndex` because in IE < 9 `String#replace` does not. + string = baseToString(string); + return (string && reHasUnescapedHtml.test(string)) + ? string.replace(reUnescapedHtml, escapeHtmlChar) + : string; + } + + /** + * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?", + * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https:\/\/lodash\.com\/\)' + */ + function escapeRegExp(string) { + string = baseToString(string); + return (string && reHasRegExpChars.test(string)) + ? string.replace(reRegExpChars, escapeRegExpChar) + : (string || '(?:)'); + } + + /** + * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the kebab cased string. + * @example + * + * _.kebabCase('Foo Bar'); + * // => 'foo-bar' + * + * _.kebabCase('fooBar'); + * // => 'foo-bar' + * + * _.kebabCase('__foo_bar__'); + * // => 'foo-bar' + */ + var kebabCase = createCompounder(function(result, word, index) { + return result + (index ? '-' : '') + word.toLowerCase(); + }); + + /** + * Pads `string` on the left and right sides if it's shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ + function pad(string, length, chars) { + string = baseToString(string); + length = +length; + + var strLength = string.length; + if (strLength >= length || !nativeIsFinite(length)) { + return string; + } + var mid = (length - strLength) / 2, + leftLength = nativeFloor(mid), + rightLength = nativeCeil(mid); + + chars = createPadding('', rightLength, chars); + return chars.slice(0, leftLength) + string + chars; + } + + /** + * Pads `string` on the left side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padLeft('abc', 6); + * // => ' abc' + * + * _.padLeft('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padLeft('abc', 3); + * // => 'abc' + */ + var padLeft = createPadDir(); + + /** + * Pads `string` on the right side if it's shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padRight('abc', 6); + * // => 'abc ' + * + * _.padRight('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padRight('abc', 3); + * // => 'abc' + */ + var padRight = createPadDir(true); + + /** + * Converts `string` to an integer of the specified radix. If `radix` is + * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, + * in which case a `radix` of `16` is used. + * + * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E) + * of `parseInt`. + * + * @static + * @memberOf _ + * @category String + * @param {string} string The string to convert. + * @param {number} [radix] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {number} Returns the converted integer. + * @example + * + * _.parseInt('08'); + * // => 8 + * + * _.map(['6', '08', '10'], _.parseInt); + * // => [6, 8, 10] + */ + function parseInt(string, radix, guard) { + // Firefox < 21 and Opera < 15 follow ES3 for `parseInt`. + // Chrome fails to trim leading whitespace characters. + // See https://code.google.com/p/v8/issues/detail?id=3109 for more details. + if (guard ? isIterateeCall(string, radix, guard) : radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + string = trim(string); + return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); + } + + /** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ + function repeat(string, n) { + var result = ''; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + string += string; + } while (n); + + return result; + } + + /** + * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the snake cased string. + * @example + * + * _.snakeCase('Foo Bar'); + * // => 'foo_bar' + * + * _.snakeCase('fooBar'); + * // => 'foo_bar' + * + * _.snakeCase('--foo-bar'); + * // => 'foo_bar' + */ + var snakeCase = createCompounder(function(result, word, index) { + return result + (index ? '_' : '') + word.toLowerCase(); + }); + + /** + * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the start cased string. + * @example + * + * _.startCase('--foo-bar'); + * // => 'Foo Bar' + * + * _.startCase('fooBar'); + * // => 'Foo Bar' + * + * _.startCase('__foo_bar__'); + * // => 'Foo Bar' + */ + var startCase = createCompounder(function(result, word, index) { + return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1)); + }); + + /** + * Checks if `string` starts with the given target string. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=0] The position to search from. + * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`. + * @example + * + * _.startsWith('abc', 'a'); + * // => true + * + * _.startsWith('abc', 'b'); + * // => false + * + * _.startsWith('abc', 'b', 1); + * // => true + */ + function startsWith(string, target, position) { + string = baseToString(string); + position = position == null + ? 0 + : nativeMin(position < 0 ? 0 : (+position || 0), string.length); + + return string.lastIndexOf(target, position) == position; + } + + /** + * Creates a compiled template function that can interpolate data properties + * in "interpolate" delimiters, HTML-escape interpolated data properties in + * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data + * properties may be accessed as free variables in the template. If a setting + * object is provided it takes precedence over `_.templateSettings` values. + * + * **Note:** In the development build `_.template` utilizes + * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * for easier debugging. + * + * For more information on precompiling templates see + * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * + * For more information on Chrome extension sandboxes see + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The template string. + * @param {Object} [options] The options object. + * @param {RegExp} [options.escape] The HTML "escape" delimiter. + * @param {RegExp} [options.evaluate] The "evaluate" delimiter. + * @param {Object} [options.imports] An object to import into the template as free variables. + * @param {RegExp} [options.interpolate] The "interpolate" delimiter. + * @param {string} [options.sourceURL] The sourceURL of the template's compiled source. + * @param {string} [options.variable] The data object variable name. + * @param- {Object} [otherOptions] Enables the legacy `options` param signature. + * @returns {Function} Returns the compiled template function. + * @example + * + * // using the "interpolate" delimiter to create a compiled template + * var compiled = _.template('hello <%= user %>!'); + * compiled({ 'user': 'fred' }); + * // => 'hello fred!' + * + * // using the HTML "escape" delimiter to escape data property values + * var compiled = _.template('<%- value %>'); + * compiled({ 'value': ' + +``` + +## Documentation + +### Collections + +* [`each`](#each) +* [`eachSeries`](#eachSeries) +* [`eachLimit`](#eachLimit) +* [`map`](#map) +* [`mapSeries`](#mapSeries) +* [`mapLimit`](#mapLimit) +* [`filter`](#filter) +* [`filterSeries`](#filterSeries) +* [`reject`](#reject) +* [`rejectSeries`](#rejectSeries) +* [`reduce`](#reduce) +* [`reduceRight`](#reduceRight) +* [`detect`](#detect) +* [`detectSeries`](#detectSeries) +* [`sortBy`](#sortBy) +* [`some`](#some) +* [`every`](#every) +* [`concat`](#concat) +* [`concatSeries`](#concatSeries) + +### Control Flow + +* [`series`](#seriestasks-callback) +* [`parallel`](#parallel) +* [`parallelLimit`](#parallellimittasks-limit-callback) +* [`whilst`](#whilst) +* [`doWhilst`](#doWhilst) +* [`until`](#until) +* [`doUntil`](#doUntil) +* [`forever`](#forever) +* [`waterfall`](#waterfall) +* [`compose`](#compose) +* [`seq`](#seq) +* [`applyEach`](#applyEach) +* [`applyEachSeries`](#applyEachSeries) +* [`queue`](#queue) +* [`priorityQueue`](#priorityQueue) +* [`cargo`](#cargo) +* [`auto`](#auto) +* [`retry`](#retry) +* [`iterator`](#iterator) +* [`apply`](#apply) +* [`nextTick`](#nextTick) +* [`times`](#times) +* [`timesSeries`](#timesSeries) + +### Utils + +* [`memoize`](#memoize) +* [`unmemoize`](#unmemoize) +* [`log`](#log) +* [`dir`](#dir) +* [`noConflict`](#noConflict) + + +## Collections + + + +### each(arr, iterator, callback) + +Applies the function `iterator` to each item in `arr`, in parallel. +The `iterator` is called with an item from the list, and a callback for when it +has finished. If the `iterator` passes an error to its `callback`, the main +`callback` (for the `each` function) is immediately called with the error. + +Note, that since this function applies `iterator` to each item in parallel, +there is no guarantee that the iterator functions will complete in order. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occured, the `callback` should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Examples__ + + +```js +// assuming openFiles is an array of file names and saveFile is a function +// to save the modified contents of that file: + +async.each(openFiles, saveFile, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +```js +// assuming openFiles is an array of file names + +async.each(openFiles, function( file, callback) { + + // Perform operation on file here. + console.log('Processing file ' + file); + + if( file.length > 32 ) { + console.log('This file name is too long'); + callback('File name too long'); + } else { + // Do work to process file here + console.log('File processed'); + callback(); + } +}, function(err){ + // if any of the file processing produced an error, err would equal that error + if( err ) { + // One of the iterations produced an error. + // All processing will now stop. + console.log('A file failed to process'); + } else { + console.log('All files have been processed successfully'); + } +}); +``` + +--------------------------------------- + + + +### eachSeries(arr, iterator, callback) + +The same as [`each`](#each), only `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +This means the `iterator` functions will complete in order. + + +--------------------------------------- + + + +### eachLimit(arr, limit, iterator, callback) + +The same as [`each`](#each), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items in `arr` are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occured, the callback should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Example__ + +```js +// Assume documents is an array of JSON objects and requestApi is a +// function that interacts with a rate-limited REST api. + +async.eachLimit(documents, 20, requestApi, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +--------------------------------------- + + +### map(arr, iterator, callback) + +Produces a new array of values by mapping each value in `arr` through +the `iterator` function. The `iterator` is called with an item from `arr` and a +callback for when it has finished processing. Each of these callback takes 2 arguments: +an `error`, and the transformed item from `arr`. If `iterator` passes an error to this +callback, the main `callback` (for the `map` function) is immediately called with the error. + +Note, that since this function applies the `iterator` to each item in parallel, +there is no guarantee that the `iterator` functions will complete in order. +However, the results array will be in the same order as the original `arr`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + functions have finished, or an error occurs. Results is an array of the + transformed items from the `arr`. + +__Example__ + +```js +async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + +### mapSeries(arr, iterator, callback) + +The same as [`map`](#map), only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +--------------------------------------- + + +### mapLimit(arr, limit, iterator, callback) + +The same as [`map`](#map), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + calls have finished, or an error occurs. The result is an array of the + transformed items from the original `arr`. + +__Example__ + +```js +async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + + +### filter(arr, iterator, callback) + +__Alias:__ `select` + +Returns a new array of all the values in `arr` which pass an async truth test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. This operation is +performed in parallel, but the results array will be in the same order as the +original. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The `iterator` is passed a `callback(truthValue)`, which must be called with a + boolean argument once it has completed. +* `callback(results)` - A callback which is called after all the `iterator` + functions have finished. + +__Example__ + +```js +async.filter(['file1','file2','file3'], fs.exists, function(results){ + // results now equals an array of the existing files +}); +``` + +--------------------------------------- + + + +### filterSeries(arr, iterator, callback) + +__Alias:__ `selectSeries` + +The same as [`filter`](#filter) only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + +--------------------------------------- + + +### reject(arr, iterator, callback) + +The opposite of [`filter`](#filter). Removes values that pass an `async` truth test. + +--------------------------------------- + + +### rejectSeries(arr, iterator, callback) + +The same as [`reject`](#reject), only the `iterator` is applied to each item in `arr` +in series. + + +--------------------------------------- + + +### reduce(arr, memo, iterator, callback) + +__Aliases:__ `inject`, `foldl` + +Reduces `arr` into a single value using an async `iterator` to return +each successive step. `memo` is the initial state of the reduction. +This function only operates in series. + +For performance reasons, it may make sense to split a call to this function into +a parallel map, and then use the normal `Array.prototype.reduce` on the results. +This function is for situations where each step in the reduction needs to be async; +if you can get the data before reducing it, then it's probably a good idea to do so. + +__Arguments__ + +* `arr` - An array to iterate over. +* `memo` - The initial state of the reduction. +* `iterator(memo, item, callback)` - A function applied to each item in the + array to produce the next step in the reduction. The `iterator` is passed a + `callback(err, reduction)` which accepts an optional error as its first + argument, and the state of the reduction as the second. If an error is + passed to the callback, the reduction is stopped and the main `callback` is + immediately called with the error. +* `callback(err, result)` - A callback which is called after all the `iterator` + functions have finished. Result is the reduced value. + +__Example__ + +```js +async.reduce([1,2,3], 0, function(memo, item, callback){ + // pointless async: + process.nextTick(function(){ + callback(null, memo + item) + }); +}, function(err, result){ + // result is now equal to the last value of memo, which is 6 +}); +``` + +--------------------------------------- + + +### reduceRight(arr, memo, iterator, callback) + +__Alias:__ `foldr` + +Same as [`reduce`](#reduce), only operates on `arr` in reverse order. + + +--------------------------------------- + + +### detect(arr, iterator, callback) + +Returns the first value in `arr` that passes an async truth test. The +`iterator` is applied in parallel, meaning the first iterator to return `true` will +fire the detect `callback` with that result. That means the result might not be +the first item in the original `arr` (in terms of order) that passes the test. + +If order within the original `arr` is important, then look at [`detectSeries`](#detectSeries). + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The iterator is passed a `callback(truthValue)` which must be called with a + boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the `iterator` functions have finished. Result will be + the first item in the array that passes the truth test (iterator) or the + value `undefined` if none passed. + +__Example__ + +```js +async.detect(['file1','file2','file3'], fs.exists, function(result){ + // result now equals the first file in the list that exists +}); +``` + +--------------------------------------- + + +### detectSeries(arr, iterator, callback) + +The same as [`detect`](#detect), only the `iterator` is applied to each item in `arr` +in series. This means the result is always the first in the original `arr` (in +terms of array order) that passes the truth test. + + +--------------------------------------- + + +### sortBy(arr, iterator, callback) + +Sorts a list by the results of running each `arr` value through an async `iterator`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, sortValue)` which must be called once it + has completed with an error (which can be `null`) and a value to use as the sort + criteria. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is the items from + the original `arr` sorted by the values returned by the `iterator` calls. + +__Example__ + +```js +async.sortBy(['file1','file2','file3'], function(file, callback){ + fs.stat(file, function(err, stats){ + callback(err, stats.mtime); + }); +}, function(err, results){ + // results is now the original array of files sorted by + // modified date +}); +``` + +__Sort Order__ + +By modifying the callback parameter the sorting order can be influenced: + +```js +//ascending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x); +}, function(err,result){ + //result callback +} ); + +//descending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x*-1); //<- x*-1 instead of x, turns the order around +}, function(err,result){ + //result callback +} ); +``` + +--------------------------------------- + + +### some(arr, iterator, callback) + +__Alias:__ `any` + +Returns `true` if at least one element in the `arr` satisfies an async test. +_The callback for each iterator call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. Once any iterator +call returns `true`, the main `callback` is immediately called. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the iterator functions have finished. Result will be + either `true` or `false` depending on the values of the async tests. + +__Example__ + +```js +async.some(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then at least one of the files exists +}); +``` + +--------------------------------------- + + +### every(arr, iterator, callback) + +__Alias:__ `all` + +Returns `true` if every element in `arr` satisfies an async test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called after all the `iterator` + functions have finished. Result will be either `true` or `false` depending on + the values of the async tests. + +__Example__ + +```js +async.every(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then every file exists +}); +``` + +--------------------------------------- + + +### concat(arr, iterator, callback) + +Applies `iterator` to each item in `arr`, concatenating the results. Returns the +concatenated list. The `iterator`s are called in parallel, and the results are +concatenated as they return. There is no guarantee that the results array will +be returned in the original order of `arr` passed to the `iterator` function. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, results)` which must be called once it + has completed with an error (which can be `null`) and an array of results. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is an array containing + the concatenated results of the `iterator` function. + +__Example__ + +```js +async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){ + // files is now a list of filenames that exist in the 3 directories +}); +``` + +--------------------------------------- + + +### concatSeries(arr, iterator, callback) + +Same as [`concat`](#concat), but executes in series instead of parallel. + + +## Control Flow + + +### series(tasks, [callback]) + +Run the functions in the `tasks` array in series, each one running once the previous +function has completed. If any functions in the series pass an error to its +callback, no more functions are run, and `callback` is immediately called with the value of the error. +Otherwise, `callback` receives an array of results when `tasks` have completed. + +It is also possible to use an object instead of an array. Each property will be +run as a function, and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`series`](#series). + +**Note** that while many implementations preserve the order of object properties, the +[ECMAScript Language Specifcation](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) +explicitly states that + +> The mechanics and order of enumerating the properties is not specified. + +So if you rely on the order in which your series of functions are executed, and want +this to work on all platforms, consider using an array. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +__Example__ + +```js +async.series([ + function(callback){ + // do some stuff ... + callback(null, 'one'); + }, + function(callback){ + // do some more stuff ... + callback(null, 'two'); + } +], +// optional callback +function(err, results){ + // results is now equal to ['one', 'two'] +}); + + +// an example using an object instead of an array +async.series({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equal to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallel(tasks, [callback]) + +Run the `tasks` array of functions in parallel, without waiting until the previous +function has completed. If any of the functions pass an error to its +callback, the main `callback` is immediately called with the value of the error. +Once the `tasks` have completed, the results are passed to the final `callback` as an +array. + +It is also possible to use an object instead of an array. Each property will be +run as a function and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`parallel`](#parallel). + + +__Arguments__ + +* `tasks` - An array or object containing functions to run. Each function is passed + a `callback(err, result)` which it must call on completion with an error `err` + (which can be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the task callbacks. + +__Example__ + +```js +async.parallel([ + function(callback){ + setTimeout(function(){ + callback(null, 'one'); + }, 200); + }, + function(callback){ + setTimeout(function(){ + callback(null, 'two'); + }, 100); + } +], +// optional callback +function(err, results){ + // the results array will equal ['one','two'] even though + // the second function had a shorter timeout. +}); + + +// an example using an object instead of an array +async.parallel({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equals to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallelLimit(tasks, limit, [callback]) + +The same as [`parallel`](#parallel), only `tasks` are executed in parallel +with a maximum of `limit` tasks executing at any time. + +Note that the `tasks` are not executed in batches, so there is no guarantee that +the first `limit` tasks will complete before any others are started. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `limit` - The maximum number of `tasks` to run at any time. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +--------------------------------------- + + +### whilst(test, fn, callback) + +Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +__Arguments__ + +* `test()` - synchronous truth test to perform before each execution of `fn`. +* `fn(callback)` - A function which is called each time `test` passes. The function is + passed a `callback(err)`, which must be called once it has completed with an + optional `err` argument. +* `callback(err)` - A callback which is called after the test fails and repeated + execution of `fn` has stopped. + +__Example__ + +```js +var count = 0; + +async.whilst( + function () { return count < 5; }, + function (callback) { + count++; + setTimeout(callback, 1000); + }, + function (err) { + // 5 seconds have passed + } +); +``` + +--------------------------------------- + + +### doWhilst(fn, test, callback) + +The post-check version of [`whilst`](#whilst). To reflect the difference in +the order of operations, the arguments `test` and `fn` are switched. + +`doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + +--------------------------------------- + + +### until(test, fn, callback) + +Repeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +The inverse of [`whilst`](#whilst). + +--------------------------------------- + + +### doUntil(fn, test, callback) + +Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`. + +--------------------------------------- + + +### forever(fn, errback) + +Calls the asynchronous function `fn` with a callback parameter that allows it to +call itself again, in series, indefinitely. + +If an error is passed to the callback then `errback` is called with the +error, and execution stops, otherwise it will never be called. + +```js +async.forever( + function(next) { + // next is suitable for passing to things that need a callback(err [, whatever]); + // it will result in this function being called again. + }, + function(err) { + // if next is called with a value in its first parameter, it will appear + // in here as 'err', and execution will stop. + } +); +``` + +--------------------------------------- + + +### waterfall(tasks, [callback]) + +Runs the `tasks` array of functions in series, each passing their results to the next in +the array. However, if any of the `tasks` pass an error to their own callback, the +next function is not executed, and the main `callback` is immediately called with +the error. + +__Arguments__ + +* `tasks` - An array of functions to run, each function is passed a + `callback(err, result1, result2, ...)` it must call on completion. The first + argument is an error (which can be `null`) and any further arguments will be + passed as arguments in order to the next task. +* `callback(err, [results])` - An optional callback to run once all the functions + have completed. This will be passed the results of the last task's callback. + + + +__Example__ + +```js +async.waterfall([ + function(callback){ + callback(null, 'one', 'two'); + }, + function(arg1, arg2, callback){ + // arg1 now equals 'one' and arg2 now equals 'two' + callback(null, 'three'); + }, + function(arg1, callback){ + // arg1 now equals 'three' + callback(null, 'done'); + } +], function (err, result) { + // result now equals 'done' +}); +``` + +--------------------------------------- + +### compose(fn1, fn2...) + +Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions `f()`, `g()`, and `h()` would produce the result of +`f(g(h()))`, only this version uses callbacks to obtain the return values. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* `functions...` - the asynchronous functions to compose + + +__Example__ + +```js +function add1(n, callback) { + setTimeout(function () { + callback(null, n + 1); + }, 10); +} + +function mul3(n, callback) { + setTimeout(function () { + callback(null, n * 3); + }, 10); +} + +var add1mul3 = async.compose(mul3, add1); + +add1mul3(4, function (err, result) { + // result now equals 15 +}); +``` + +--------------------------------------- + +### seq(fn1, fn2...) + +Version of the compose function that is more natural to read. +Each following function consumes the return value of the latter function. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* functions... - the asynchronous functions to compose + + +__Example__ + +```js +// Requires lodash (or underscore), express3 and dresende's orm2. +// Part of an app, that fetches cats of the logged user. +// This example uses `seq` function to avoid overnesting and error +// handling clutter. +app.get('/cats', function(request, response) { + function handleError(err, data, callback) { + if (err) { + console.error(err); + response.json({ status: 'error', message: err.message }); + } + else { + callback(data); + } + } + var User = request.models.User; + async.seq( + _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) + handleError, + function(user, fn) { + user.getCats(fn); // 'getCats' has signature (callback(err, data)) + }, + handleError, + function(cats) { + response.json({ status: 'ok', message: 'Cats found', data: cats }); + } + )(req.session.user_id); + } +}); +``` + +--------------------------------------- + +### applyEach(fns, args..., callback) + +Applies the provided arguments to each function in the array, calling +`callback` after all functions have completed. If you only provide the first +argument, then it will return a function which lets you pass in the +arguments as if it were a single function call. + +__Arguments__ + +* `fns` - the asynchronous functions to all call with the same arguments +* `args...` - any number of separate arguments to pass to the function +* `callback` - the final argument should be the callback, called when all + functions have completed processing + + +__Example__ + +```js +async.applyEach([enableSearch, updateSchema], 'bucket', callback); + +// partial application example: +async.each( + buckets, + async.applyEach([enableSearch, updateSchema]), + callback +); +``` + +--------------------------------------- + + +### applyEachSeries(arr, iterator, callback) + +The same as [`applyEach`](#applyEach) only the functions are applied in series. + +--------------------------------------- + + +### queue(worker, concurrency) + +Creates a `queue` object with the specified `concurrency`. Tasks added to the +`queue` are processed in parallel (up to the `concurrency` limit). If all +`worker`s are in progress, the task is queued until one becomes available. +Once a `worker` completes a `task`, that `task`'s callback is called. + +__Arguments__ + +* `worker(task, callback)` - An asynchronous function for processing a queued + task, which must call its `callback(err)` argument when finished, with an + optional `error` as an argument. +* `concurrency` - An `integer` for determining how many `worker` functions should be + run in parallel. + +__Queue objects__ + +The `queue` object returned by this function has the following properties and +methods: + +* `length()` - a function returning the number of items waiting to be processed. +* `started` - a function returning whether or not any items have been pushed and processed by the queue +* `running()` - a function returning the number of items currently being processed. +* `idle()` - a function returning false if there are items waiting or being processed, or true if not. +* `concurrency` - an integer for determining how many `worker` functions should be + run in parallel. This property can be changed after a `queue` is created to + alter the concurrency on-the-fly. +* `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once + the `worker` has finished processing the task. Instead of a single task, a `tasks` array + can be submitted. The respective callback is used for every task in the list. +* `unshift(task, [callback])` - add a new task to the front of the `queue`. +* `saturated` - a callback that is called when the `queue` length hits the `concurrency` limit, + and further tasks will be queued. +* `empty` - a callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`. +* `paused` - a boolean for determining whether the queue is in a paused state +* `pause()` - a function that pauses the processing of tasks until `resume()` is called. +* `resume()` - a function that resumes the processing of queued tasks when the queue is paused. +* `kill()` - a function that empties remaining tasks from the queue forcing it to go idle. + +__Example__ + +```js +// create a queue object with concurrency 2 + +var q = async.queue(function (task, callback) { + console.log('hello ' + task.name); + callback(); +}, 2); + + +// assign a callback +q.drain = function() { + console.log('all items have been processed'); +} + +// add some items to the queue + +q.push({name: 'foo'}, function (err) { + console.log('finished processing foo'); +}); +q.push({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); + +// add some items to the queue (batch-wise) + +q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) { + console.log('finished processing bar'); +}); + +// add some items to the front of the queue + +q.unshift({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); +``` + + +--------------------------------------- + + +### priorityQueue(worker, concurrency) + +The same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects: + +* `push(task, priority, [callback])` - `priority` should be a number. If an array of + `tasks` is given, all tasks will be assigned the same priority. +* The `unshift` method was removed. + +--------------------------------------- + + +### cargo(worker, [payload]) + +Creates a `cargo` object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the `payload` limit). If the +`worker` is in progress, the task is queued until it becomes available. Once +the `worker` has completed some tasks, each callback of those tasks is called. +Check out [this animation](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) for how `cargo` and `queue` work. + +While [queue](#queue) passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished. + +__Arguments__ + +* `worker(tasks, callback)` - An asynchronous function for processing an array of + queued tasks, which must call its `callback(err)` argument when finished, with + an optional `err` argument. +* `payload` - An optional `integer` for determining how many tasks should be + processed per round; if omitted, the default is unlimited. + +__Cargo objects__ + +The `cargo` object returned by this function has the following properties and +methods: + +* `length()` - A function returning the number of items waiting to be processed. +* `payload` - An `integer` for determining how many tasks should be + process per round. This property can be changed after a `cargo` is created to + alter the payload on-the-fly. +* `push(task, [callback])` - Adds `task` to the `queue`. The callback is called + once the `worker` has finished processing the task. Instead of a single task, an array of `tasks` + can be submitted. The respective callback is used for every task in the list. +* `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued. +* `empty` - A callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`. + +__Example__ + +```js +// create a cargo object with payload 2 + +var cargo = async.cargo(function (tasks, callback) { + for(var i=0; i +### auto(tasks, [callback]) + +Determines the best order for running the functions in `tasks`, based on their +requirements. Each function can optionally depend on other functions being completed +first, and each function is run as soon as its requirements are satisfied. + +If any of the functions pass an error to their callback, it will not +complete (so any other functions depending on it will not run), and the main +`callback` is immediately called with the error. Functions also receive an +object containing the results of functions which have completed so far. + +Note, all functions are called with a `results` object as a second argument, +so it is unsafe to pass functions in the `tasks` object which cannot handle the +extra argument. + +For example, this snippet of code: + +```js +async.auto({ + readData: async.apply(fs.readFile, 'data.txt', 'utf-8') +}, callback); +``` + +will have the effect of calling `readFile` with the results object as the last +argument, which will fail: + +```js +fs.readFile('data.txt', 'utf-8', cb, {}); +``` + +Instead, wrap the call to `readFile` in a function which does not forward the +`results` object: + +```js +async.auto({ + readData: function(cb, results){ + fs.readFile('data.txt', 'utf-8', cb); + } +}, callback); +``` + +__Arguments__ + +* `tasks` - An object. Each of its properties is either a function or an array of + requirements, with the function itself the last item in the array. The object's key + of a property serves as the name of the task defined by that property, + i.e. can be used when specifying requirements for other tasks. + The function receives two arguments: (1) a `callback(err, result)` which must be + called when finished, passing an `error` (which can be `null`) and the result of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions. +* `callback(err, results)` - An optional callback which is called when all the + tasks have been completed. It receives the `err` argument if any `tasks` + pass an error to their callback. Results are always returned; however, if + an error occurs, no further `tasks` will be performed, and the results + object will only contain partial results. + + +__Example__ + +```js +async.auto({ + get_data: function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + make_folder: function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + }, + write_file: ['get_data', 'make_folder', function(callback, results){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, 'filename'); + }], + email_link: ['write_file', function(callback, results){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + // results.write_file contains the filename returned by write_file. + callback(null, {'file':results.write_file, 'email':'user@example.com'}); + }] +}, function(err, results) { + console.log('err = ', err); + console.log('results = ', results); +}); +``` + +This is a fairly trivial example, but to do this using the basic parallel and +series functions would look like this: + +```js +async.parallel([ + function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + } +], +function(err, results){ + async.series([ + function(callback){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + results.push('filename'); + callback(null); + }, + function(callback){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + callback(null, {'file':results.pop(), 'email':'user@example.com'}); + } + ]); +}); +``` + +For a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding +new tasks much easier (and the code more readable). + + +--------------------------------------- + + +### retry([times = 5], task, [callback]) + +Attempts to get a successful response from `task` no more than `times` times before +returning an error. If the task is successful, the `callback` will be passed the result +of the successfull task. If all attemps fail, the callback will be passed the error and +result (if any) of the final attempt. + +__Arguments__ + +* `times` - An integer indicating how many times to attempt the `task` before giving up. Defaults to 5. +* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)` + which must be called when finished, passing `err` (which can be `null`) and the `result` of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions (if nested inside another control flow). +* `callback(err, results)` - An optional callback which is called when the + task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`. + +The [`retry`](#retry) function can be used as a stand-alone control flow by passing a +callback, as shown below: + +```js +async.retry(3, apiMethod, function(err, result) { + // do something with the result +}); +``` + +It can also be embeded within other control flow functions to retry individual methods +that are not as reliable, like this: + +```js +async.auto({ + users: api.getUsers.bind(api), + payments: async.retry(3, api.getPayments.bind(api)) +}, function(err, results) { + // do something with the results +}); +``` + + +--------------------------------------- + + +### iterator(tasks) + +Creates an iterator function which calls the next function in the `tasks` array, +returning a continuation to call the next one after that. It's also possible to +“peek” at the next iterator with `iterator.next()`. + +This function is used internally by the `async` module, but can be useful when +you want to manually control the flow of functions in series. + +__Arguments__ + +* `tasks` - An array of functions to run. + +__Example__ + +```js +var iterator = async.iterator([ + function(){ sys.p('one'); }, + function(){ sys.p('two'); }, + function(){ sys.p('three'); } +]); + +node> var iterator2 = iterator(); +'one' +node> var iterator3 = iterator2(); +'two' +node> iterator3(); +'three' +node> var nextfn = iterator2.next(); +node> nextfn(); +'three' +``` + +--------------------------------------- + + +### apply(function, arguments..) + +Creates a continuation function with some arguments already applied. + +Useful as a shorthand when combined with other control flow functions. Any arguments +passed to the returned function are added to the arguments originally passed +to apply. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to automatically apply when the + continuation is called. + +__Example__ + +```js +// using apply + +async.parallel([ + async.apply(fs.writeFile, 'testfile1', 'test1'), + async.apply(fs.writeFile, 'testfile2', 'test2'), +]); + + +// the same process without using apply + +async.parallel([ + function(callback){ + fs.writeFile('testfile1', 'test1', callback); + }, + function(callback){ + fs.writeFile('testfile2', 'test2', callback); + } +]); +``` + +It's possible to pass any number of additional arguments when calling the +continuation: + +```js +node> var fn = async.apply(sys.puts, 'one'); +node> fn('two', 'three'); +one +two +three +``` + +--------------------------------------- + + +### nextTick(callback) + +Calls `callback` on a later loop around the event loop. In Node.js this just +calls `process.nextTick`; in the browser it falls back to `setImmediate(callback)` +if available, otherwise `setTimeout(callback, 0)`, which means other higher priority +events may precede the execution of `callback`. + +This is used internally for browser-compatibility purposes. + +__Arguments__ + +* `callback` - The function to call on a later loop around the event loop. + +__Example__ + +```js +var call_order = []; +async.nextTick(function(){ + call_order.push('two'); + // call_order now equals ['one','two'] +}); +call_order.push('one') +``` + + +### times(n, callback) + +Calls the `callback` function `n` times, and accumulates results in the same manner +you would use with [`map`](#map). + +__Arguments__ + +* `n` - The number of times to run the function. +* `callback` - The function to call `n` times. + +__Example__ + +```js +// Pretend this is some complicated async factory +var createUser = function(id, callback) { + callback(null, { + id: 'user' + id + }) +} +// generate 5 users +async.times(5, function(n, next){ + createUser(n, function(err, user) { + next(err, user) + }) +}, function(err, users) { + // we should now have 5 users +}); +``` + + +### timesSeries(n, callback) + +The same as [`times`](#times), only the iterator is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +## Utils + + +### memoize(fn, [hasher]) + +Caches the results of an `async` function. When creating a hash to store function +results against, the callback is omitted from the hash and an optional hash +function can be used. + +The cache of results is exposed as the `memo` property of the function returned +by `memoize`. + +__Arguments__ + +* `fn` - The function to proxy and cache results from. +* `hasher` - Tn optional function for generating a custom hash for storing + results. It has all the arguments applied to it apart from the callback, and + must be synchronous. + +__Example__ + +```js +var slow_fn = function (name, callback) { + // do something + callback(null, result); +}; +var fn = async.memoize(slow_fn); + +// fn can now be used as if it were slow_fn +fn('some name', function () { + // callback +}); +``` + + +### unmemoize(fn) + +Undoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized +form. Handy for testing. + +__Arguments__ + +* `fn` - the memoized function + + +### log(function, arguments) + +Logs the result of an `async` function to the `console`. Only works in Node.js or +in browsers that support `console.log` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.log` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, 'hello ' + name); + }, 1000); +}; +``` +```js +node> async.log(hello, 'world'); +'hello world' +``` + +--------------------------------------- + + +### dir(function, arguments) + +Logs the result of an `async` function to the `console` using `console.dir` to +display the properties of the resulting object. Only works in Node.js or +in browsers that support `console.dir` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.dir` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, {hello: name}); + }, 1000); +}; +``` +```js +node> async.dir(hello, 'world'); +{hello: 'world'} +``` + +--------------------------------------- + + +### noConflict() + +Changes the value of `async` back to its original value, returning a reference to the +`async` object. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/component.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/component.json new file mode 100644 index 0000000..bbb0115 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/component.json @@ -0,0 +1,11 @@ +{ + "name": "async", + "repo": "caolan/async", + "description": "Higher-order functions and common patterns for asynchronous code", + "version": "0.1.23", + "keywords": [], + "dependencies": {}, + "development": {}, + "main": "lib/async.js", + "scripts": [ "lib/async.js" ] +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/lib/async.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/lib/async.js new file mode 100755 index 0000000..01e8afc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/async/lib/async.js @@ -0,0 +1,1123 @@ +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */ +/*jshint onevar: false, indent:4 */ +/*global setImmediate: false, setTimeout: false, console: false */ +(function () { + + var async = {}; + + // global on the server, window in the browser + var root, previous_async; + + root = this; + if (root != null) { + previous_async = root.async; + } + + async.noConflict = function () { + root.async = previous_async; + return async; + }; + + function only_once(fn) { + var called = false; + return function() { + if (called) throw new Error("Callback was already called."); + called = true; + fn.apply(root, arguments); + } + } + + //// cross-browser compatiblity functions //// + + var _toString = Object.prototype.toString; + + var _isArray = Array.isArray || function (obj) { + return _toString.call(obj) === '[object Array]'; + }; + + var _each = 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 = []; + _each(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); + } + _each(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; + }; + + //// exported async module functions //// + + //// nextTick implementation with browser-compatible fallback //// + if (typeof process === 'undefined' || !(process.nextTick)) { + if (typeof setImmediate === 'function') { + async.nextTick = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + async.setImmediate = async.nextTick; + } + else { + async.nextTick = function (fn) { + setTimeout(fn, 0); + }; + async.setImmediate = async.nextTick; + } + } + else { + async.nextTick = process.nextTick; + if (typeof setImmediate !== 'undefined') { + async.setImmediate = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + } + else { + async.setImmediate = async.nextTick; + } + } + + async.each = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + _each(arr, function (x) { + iterator(x, only_once(done) ); + }); + function done(err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(); + } + } + } + }; + async.forEach = async.each; + + async.eachSeries = function (arr, iterator, callback) { + callback = callback || function () {}; + 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(); + }; + async.forEachSeries = async.eachSeries; + + async.eachLimit = function (arr, limit, iterator, callback) { + var fn = _eachLimit(limit); + fn.apply(null, [arr, iterator, callback]); + }; + async.forEachLimit = async.eachLimit; + + var _eachLimit = function (limit) { + + return function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length || limit <= 0) { + return callback(); + } + var completed = 0; + var started = 0; + var running = 0; + + (function replenish () { + if (completed >= arr.length) { + return callback(); + } + + while (running < limit && started < arr.length) { + started += 1; + running += 1; + iterator(arr[started - 1], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + running -= 1; + if (completed >= arr.length) { + callback(); + } + else { + replenish(); + } + } + }); + } + })(); + }; + }; + + + var doParallel = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.each].concat(args)); + }; + }; + var doParallelLimit = function(limit, fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [_eachLimit(limit)].concat(args)); + }; + }; + var doSeries = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.eachSeries].concat(args)); + }; + }; + + + var _asyncMap = function (eachfn, arr, iterator, callback) { + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + if (!callback) { + eachfn(arr, function (x, callback) { + iterator(x.value, function (err) { + callback(err); + }); + }); + } else { + var results = []; + 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); + async.mapLimit = function (arr, limit, iterator, callback) { + return _mapLimit(limit)(arr, iterator, callback); + }; + + var _mapLimit = function(limit) { + return doParallelLimit(limit, _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.eachSeries(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); + main_callback = function () {}; + } + else { + callback(); + } + }); + }, function (err) { + main_callback(); + }); + }; + async.detect = doParallel(_detect); + async.detectSeries = doSeries(_detect); + + async.some = function (arr, iterator, main_callback) { + async.each(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.each(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); + var remainingTasks = keys.length + if (!remainingTasks) { + return callback(); + } + + var results = {}; + + 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 () { + remainingTasks-- + _each(listeners.slice(0), function (fn) { + fn(); + }); + }; + + addListener(function () { + if (!remainingTasks) { + var theCallback = callback; + // prevent final callback from calling itself if it errors + callback = function () {}; + + theCallback(null, results); + } + }); + + _each(keys, function (k) { + var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]]; + var taskCallback = function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + if (err) { + var safeResults = {}; + _each(_keys(results), function(rkey) { + safeResults[rkey] = results[rkey]; + }); + safeResults[k] = args; + callback(err, safeResults); + // stop subsequent errors hitting callback multiple times + callback = function () {}; + } + else { + results[k] = args; + async.setImmediate(taskComplete); + } + }; + var requires = task.slice(0, Math.abs(task.length - 1)) || []; + var ready = function () { + return _reduce(requires, function (a, x) { + return (a && results.hasOwnProperty(x)); + }, true) && !results.hasOwnProperty(k); + }; + if (ready()) { + task[task.length - 1](taskCallback, results); + } + else { + var listener = function () { + if (ready()) { + removeListener(listener); + task[task.length - 1](taskCallback, results); + } + }; + addListener(listener); + } + }); + }; + + async.retry = function(times, task, callback) { + var DEFAULT_TIMES = 5; + var attempts = []; + // Use defaults if times not passed + if (typeof times === 'function') { + callback = task; + task = times; + times = DEFAULT_TIMES; + } + // Make sure times is a number + times = parseInt(times, 10) || DEFAULT_TIMES; + var wrappedTask = function(wrappedCallback, wrappedResults) { + var retryAttempt = function(task, finalAttempt) { + return function(seriesCallback) { + task(function(err, result){ + seriesCallback(!err || finalAttempt, {err: err, result: result}); + }, wrappedResults); + }; + }; + while (times) { + attempts.push(retryAttempt(task, !(times-=1))); + } + async.series(attempts, function(done, data){ + data = data[data.length - 1]; + (wrappedCallback || callback)(data.err, data.result); + }); + } + // If a callback is passed, run this as a controll flow + return callback ? wrappedTask() : wrappedTask + }; + + async.waterfall = function (tasks, callback) { + callback = callback || function () {}; + if (!_isArray(tasks)) { + var err = new Error('First argument to waterfall must be an array of functions'); + return callback(err); + } + if (!tasks.length) { + return callback(); + } + var wrapIterator = function (iterator) { + return function (err) { + if (err) { + callback.apply(null, arguments); + 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.setImmediate(function () { + iterator.apply(null, args); + }); + } + }; + }; + wrapIterator(async.iterator(tasks))(); + }; + + var _parallel = function(eachfn, tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + eachfn.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); + }); + } + }, callback); + } + else { + var results = {}; + eachfn.each(_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.parallel = function (tasks, callback) { + _parallel({ map: async.map, each: async.each }, tasks, callback); + }; + + async.parallelLimit = function(tasks, limit, callback) { + _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); + }; + + async.series = function (tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + 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); + }); + } + }, callback); + } + else { + var results = {}; + async.eachSeries(_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.doWhilst = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (test.apply(null, args)) { + async.doWhilst(iterator, test, 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.doUntil = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (!test.apply(null, args)) { + async.doUntil(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.queue = function (worker, concurrency) { + if (concurrency === undefined) { + concurrency = 1; + } + function _insert(q, data, pos, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + callback: typeof callback === 'function' ? callback : null + }; + + if (pos) { + q.tasks.unshift(item); + } else { + q.tasks.push(item); + } + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + var workers = 0; + var q = { + tasks: [], + concurrency: concurrency, + saturated: null, + empty: null, + drain: null, + started: false, + paused: false, + push: function (data, callback) { + _insert(q, data, false, callback); + }, + kill: function () { + q.drain = null; + q.tasks = []; + }, + unshift: function (data, callback) { + _insert(q, data, true, callback); + }, + process: function () { + if (!q.paused && workers < q.concurrency && q.tasks.length) { + var task = q.tasks.shift(); + if (q.empty && q.tasks.length === 0) { + q.empty(); + } + workers += 1; + var next = function () { + workers -= 1; + if (task.callback) { + task.callback.apply(task, arguments); + } + if (q.drain && q.tasks.length + workers === 0) { + q.drain(); + } + q.process(); + }; + var cb = only_once(next); + worker(task.data, cb); + } + }, + length: function () { + return q.tasks.length; + }, + running: function () { + return workers; + }, + idle: function() { + return q.tasks.length + workers === 0; + }, + pause: function () { + if (q.paused === true) { return; } + q.paused = true; + q.process(); + }, + resume: function () { + if (q.paused === false) { return; } + q.paused = false; + q.process(); + } + }; + return q; + }; + + async.priorityQueue = function (worker, concurrency) { + + function _compareTasks(a, b){ + return a.priority - b.priority; + }; + + function _binarySearch(sequence, item, compare) { + var beg = -1, + end = sequence.length - 1; + while (beg < end) { + var mid = beg + ((end - beg + 1) >>> 1); + if (compare(item, sequence[mid]) >= 0) { + beg = mid; + } else { + end = mid - 1; + } + } + return beg; + } + + function _insert(q, data, priority, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + priority: priority, + callback: typeof callback === 'function' ? callback : null + }; + + q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item); + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + // Start with a normal queue + var q = async.queue(worker, concurrency); + + // Override push to accept second parameter representing priority + q.push = function (data, priority, callback) { + _insert(q, data, priority, callback); + }; + + // Remove unshift function + delete q.unshift; + + return q; + }; + + async.cargo = function (worker, payload) { + var working = false, + tasks = []; + + var cargo = { + tasks: tasks, + payload: payload, + saturated: null, + empty: null, + drain: null, + drained: true, + push: function (data, callback) { + if (!_isArray(data)) { + data = [data]; + } + _each(data, function(task) { + tasks.push({ + data: task, + callback: typeof callback === 'function' ? callback : null + }); + cargo.drained = false; + if (cargo.saturated && tasks.length === payload) { + cargo.saturated(); + } + }); + async.setImmediate(cargo.process); + }, + process: function process() { + if (working) return; + if (tasks.length === 0) { + if(cargo.drain && !cargo.drained) cargo.drain(); + cargo.drained = true; + return; + } + + var ts = typeof payload === 'number' + ? tasks.splice(0, payload) + : tasks.splice(0, tasks.length); + + var ds = _map(ts, function (task) { + return task.data; + }); + + if(cargo.empty) cargo.empty(); + working = true; + worker(ds, function () { + working = false; + + var args = arguments; + _each(ts, function (data) { + if (data.callback) { + data.callback.apply(null, args); + } + }); + + process(); + }); + }, + length: function () { + return tasks.length; + }, + running: function () { + return working; + } + }; + return cargo; + }; + + 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]) { + _each(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 = {}; + var queues = {}; + hasher = hasher || function (x) { + return x; + }; + var memoized = function () { + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + var key = hasher.apply(null, args); + if (key in memo) { + async.nextTick(function () { + callback.apply(null, memo[key]); + }); + } + else if (key in queues) { + queues[key].push(callback); + } + else { + queues[key] = [callback]; + fn.apply(null, args.concat([function () { + memo[key] = arguments; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, arguments); + } + }])); + } + }; + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + }; + + async.unmemoize = function (fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; + }; + + async.times = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.map(counter, iterator, callback); + }; + + async.timesSeries = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.mapSeries(counter, iterator, callback); + }; + + async.seq = function (/* functions... */) { + var fns = arguments; + return function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + async.reduce(fns, args, function (newargs, fn, cb) { + fn.apply(that, newargs.concat([function () { + var err = arguments[0]; + var nextargs = Array.prototype.slice.call(arguments, 1); + cb(err, nextargs); + }])) + }, + function (err, results) { + callback.apply(that, [err].concat(results)); + }); + }; + }; + + async.compose = function (/* functions... */) { + return async.seq.apply(null, Array.prototype.reverse.call(arguments)); + }; + + var _applyEach = function (eachfn, fns /*args...*/) { + var go = function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + return eachfn(fns, function (fn, cb) { + fn.apply(that, args.concat([cb])); + }, + callback); + }; + if (arguments.length > 2) { + var args = Array.prototype.slice.call(arguments, 2); + return go.apply(this, args); + } + else { + return go; + } + }; + async.applyEach = doParallel(_applyEach); + async.applyEachSeries = doSeries(_applyEach); + + async.forever = function (fn, callback) { + function next(err) { + if (err) { + if (callback) { + return callback(err); + } + throw err; + } + fn(next); + } + next(); + }; + + // Node.js + if (typeof module !== 'undefined' && module.exports) { + module.exports = async; + } + // AMD / RequireJS + else if (typeof define !== 'undefined' && define.amd) { + define([], function () { + return async; + }); + } + // included directly via + + +Node-webkit-based module test + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/nw-pre-gyp/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/nw-pre-gyp/package.json new file mode 100644 index 0000000..71d03f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/nw-pre-gyp/package.json @@ -0,0 +1,9 @@ +{ +"main": "index.html", +"name": "nw-pre-gyp-module-test", +"description": "Node-webkit-based module test.", +"version": "0.0.1", +"window": { + "show": false +} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/s3_setup.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/s3_setup.js new file mode 100644 index 0000000..5bc42e9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/s3_setup.js @@ -0,0 +1,27 @@ +"use strict"; + +module.exports = exports; + +var url = require('url'); + +var URI_REGEX="^(.*)\.(s3(?:-.*)?)\.amazonaws\.com$"; + +module.exports.detect = function(to,config) { + var uri = url.parse(to); + var hostname_matches = uri.hostname.match(URI_REGEX); + config.prefix = (!uri.pathname || uri.pathname == '/') ? '' : uri.pathname.replace('/',''); + if(!hostname_matches) { + return; + } + if (!config.bucket) { + config.bucket = hostname_matches[1]; + } + if (!config.region) { + var s3_domain = hostname_matches[2]; + if (s3_domain.slice(0,3) == 's3-' && + s3_domain.length >= 3) { + // it appears the region is explicit in the url + config.region = s3_domain.replace('s3-',''); + } + } +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js new file mode 100644 index 0000000..292a4a7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js @@ -0,0 +1,276 @@ +"use strict"; + +module.exports = exports; + +var path = require('path'); +var semver = require('semver'); +var url = require('url'); + +var abi_crosswalk; + +// This is used for unit testing to provide a fake +// ABI crosswalk that emulates one that is not updated +// for the current version +if (process.env.NODE_PRE_GYP_ABI_CROSSWALK) { + abi_crosswalk = require(process.env.NODE_PRE_GYP_ABI_CROSSWALK); +} else { + abi_crosswalk = require('./abi_crosswalk.json'); +} + +function get_node_webkit_abi(runtime, target_version) { + if (!runtime) { + throw new Error("get_node_webkit_abi requires valid runtime arg"); + } + if (typeof target_version === 'undefined') { + // erroneous CLI call + throw new Error("Empty target version is not supported if node-webkit is the target."); + } + return runtime + '-v' + target_version; +} +module.exports.get_node_webkit_abi = get_node_webkit_abi; + +function get_node_abi(runtime, versions) { + if (!runtime) { + throw new Error("get_node_abi requires valid runtime arg"); + } + if (!versions) { + throw new Error("get_node_abi requires valid process.versions object"); + } + var sem_ver = semver.parse(versions.node); + if (sem_ver.major === 0 && sem_ver.minor % 2) { // odd series + // https://github.com/mapbox/node-pre-gyp/issues/124 + return runtime+'-v'+versions.node; + } else { + // process.versions.modules added in >= v0.10.4 and v0.11.7 + // https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e + return versions.modules ? runtime+'-v' + (+versions.modules) : + 'v8-' + versions.v8.split('.').slice(0,2).join('.'); + } +} +module.exports.get_node_abi = get_node_abi; + +function get_runtime_abi(runtime, target_version) { + if (!runtime) { + throw new Error("get_runtime_abi requires valid runtime arg"); + } + if (runtime === 'node-webkit') { + return get_node_webkit_abi(runtime, target_version || process.versions['node-webkit']); + } else { + if (runtime != 'node') { + throw new Error("Unknown Runtime: '" + runtime + "'"); + } + if (!target_version) { + return get_node_abi(runtime,process.versions); + } else { + var cross_obj; + // abi_crosswalk generated with ./scripts/abi_crosswalk.js + if (abi_crosswalk[target_version]) { + cross_obj = abi_crosswalk[target_version]; + } else { + var target_parts = target_version.split('.').map(function(i) { return +i; }); + if (target_parts.length != 3) { // parse failed + throw new Error("Unknown target version: " + target_version); + } + /* + The below code tries to infer the last known ABI compatible version + that we have recorded in the abi_crosswalk.json when an exact match + is not possible. The reasons for this to exist are complicated: + + - We support passing --target to be able to allow developers to package binaries for versions of node + that are not the same one as they are running. This might also be used in combination with the + --target_arch or --target_platform flags to also package binaries for alternative platforms + - When --target is passed we can't therefore determine the ABI (process.versions.modules) from the node + version that is running in memory + - So, therefore node-pre-gyp keeps an "ABI crosswalk" (lib/util/abi_crosswalk.json) to be able to look + this info up for all versions + - But we cannot easily predict what the future ABI will be for released versions + - And node-pre-gyp needs to be a `bundledDependency` in apps that depend on it in order to work correctly + by being fully available at install time. + - So, the speed of node releases and the bundled nature of node-pre-gyp mean that a new node-pre-gyp release + need to happen for every node.js/io.js/node-webkit/nw.js/atom-shell/etc release that might come online if + you want the `--target` flag to keep working for the latest version + - Which is impractical ^^ + - Hence the below code guesses about future ABI to make the need to update node-pre-gyp less demanding. + + In practice then you can have a dependency of your app like `node-sqlite3` that bundles a `node-pre-gyp` that + only knows about node v0.10.33 in the `abi_crosswalk.json` but target node v0.10.34 (which is assumed to be + ABI compatible with v0.10.33). + + TODO: use semver module instead of custom version parsing + */ + var major = target_parts[0]; + var minor = target_parts[1]; + var patch = target_parts[2]; + // io.js: yeah if node.js ever releases 1.x this will break + // but that is unlikely to happen: https://github.com/iojs/io.js/pull/253#issuecomment-69432616 + if (major === 1) { + // look for last release that is the same major version + // e.g. we assume io.js 1.x is ABI compatible with >= 1.0.0 + while (true) { + if (minor > 0) --minor; + if (patch > 0) --patch; + var new_iojs_target = '' + major + '.' + minor + '.' + patch; + if (abi_crosswalk[new_iojs_target]) { + cross_obj = abi_crosswalk[new_iojs_target]; + console.log('Warning: node-pre-gyp could not find exact match for ' + target_version); + console.log('Warning: but node-pre-gyp successfully choose ' + new_iojs_target + ' as ABI compatible target'); + break; + } + if (minor === 0 && patch === 0) { + break; + } + } + } else if (major === 0) { // node.js + if (target_parts[1] % 2 === 0) { // for stable/even node.js series + // look for the last release that is the same minor release + // e.g. we assume node 0.10.x is ABI compatible with >= 0.10.0 + while (--patch > 0) { + var new_node_target = '' + major + '.' + minor + '.' + patch; + if (abi_crosswalk[new_node_target]) { + cross_obj = abi_crosswalk[new_node_target]; + console.log('Warning: node-pre-gyp could not find exact match for ' + target_version); + console.log('Warning: but node-pre-gyp successfully choose ' + new_node_target + ' as ABI compatible target'); + break; + } + } + } + } + } + if (!cross_obj) { + throw new Error("Unsupported target version: " + target_version); + } + // emulate process.versions + var versions_obj = { + node: target_version, + v8: cross_obj.v8+'.0', + // abi_crosswalk uses 1 for node versions lacking process.versions.modules + // process.versions.modules added in >= v0.10.4 and v0.11.7 + modules: cross_obj.node_abi > 1 ? cross_obj.node_abi : undefined + }; + return get_node_abi(runtime, versions_obj); + } + } +} +module.exports.get_runtime_abi = get_runtime_abi; + +var required_parameters = [ + 'module_name', + 'module_path', + 'host' +]; + +function validate_config(package_json) { + var msg = package_json.name + ' package.json is not node-pre-gyp ready:\n'; + var missing = []; + if (!package_json.main) { + missing.push('main'); + } + if (!package_json.version) { + missing.push('version'); + } + if (!package_json.name) { + missing.push('name'); + } + if (!package_json.binary) { + missing.push('binary'); + } + var o = package_json.binary; + required_parameters.forEach(function(p) { + if (missing.indexOf('binary') > -1) { + missing.pop('binary'); + } + if (!o || o[p] === undefined) { + missing.push('binary.' + p); + } + }); + if (missing.length >= 1) { + throw new Error(msg+"package.json must declare these properties: \n" + missing.join('\n')); + } + if (o) { + // enforce https over http + var protocol = url.parse(o.host).protocol; + if (protocol === 'http:') { + throw new Error("'host' protocol ("+protocol+") is invalid - only 'https:' is accepted"); + } + } +} + +module.exports.validate_config = validate_config; + +function eval_template(template,opts) { + Object.keys(opts).forEach(function(key) { + var pattern = '{'+key+'}'; + while (template.indexOf(pattern) > -1) { + template = template.replace(pattern,opts[key]); + } + }); + return template; +} + +// url.resolve needs single trailing slash +// to behave correctly, otherwise a double slash +// may end up in the url which breaks requests +// and a lacking slash may not lead to proper joining +function fix_slashes(pathname) { + if (pathname.slice(-1) != '/') { + return pathname + '/'; + } + return pathname; +} + +// remove double slashes +// note: path.normalize will not work because +// it will convert forward to back slashes +function drop_double_slashes(pathname) { + return pathname.replace(/\/\//g,'/'); +} + +var default_package_name = '{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz'; +var default_remote_path = ''; + +module.exports.evaluate = function(package_json,options) { + options = options || {}; + validate_config(package_json); + var v = package_json.version; + var module_version = semver.parse(v); + var runtime = options.runtime || (process.versions['node-webkit'] ? 'node-webkit' : 'node'); + var opts = { + name: package_json.name, + configuration: Boolean(options.debug) ? 'Debug' : 'Release', + debug: options.debug, + module_name: package_json.binary.module_name, + version: module_version.version, + prerelease: module_version.prerelease.length ? module_version.prerelease.join('.') : '', + build: module_version.build.length ? module_version.build.join('.') : '', + major: module_version.major, + minor: module_version.minor, + patch: module_version.patch, + runtime: runtime, + node_abi: get_runtime_abi(runtime,options.target), + target: options.target || '', + platform: options.target_platform || process.platform, + target_platform: options.target_platform || process.platform, + arch: options.target_arch || process.arch, + target_arch: options.target_arch || process.arch, + module_main: package_json.main, + toolset : options.toolset || '' // address https://github.com/mapbox/node-pre-gyp/issues/119 + }; + opts.host = fix_slashes(eval_template(package_json.binary.host,opts)); + opts.module_path = eval_template(package_json.binary.module_path,opts); + // now we resolve the module_path to ensure it is absolute so that binding.gyp variables work predictably + if (options.module_root) { + // resolve relative to known module root: works for pre-binding require + opts.module_path = path.join(options.module_root,opts.module_path); + } else { + // resolve relative to current working directory: works for node-pre-gyp commands + opts.module_path = path.resolve(opts.module_path); + } + opts.module = path.join(opts.module_path,opts.module_name + '.node'); + opts.remote_path = package_json.binary.remote_path ? drop_double_slashes(fix_slashes(eval_template(package_json.binary.remote_path,opts))) : default_remote_path; + var package_name = package_json.binary.package_name ? package_json.binary.package_name : default_package_name; + opts.package_name = eval_template(package_name,opts); + opts.staged_tarball = path.join('build/stage',opts.remote_path,opts.package_name); + opts.hosted_path = url.resolve(opts.host,opts.remote_path); + opts.hosted_tarball = url.resolve(opts.hosted_path,opts.package_name); + return opts; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/mkdirp b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/mkdirp new file mode 120000 index 0000000..017896c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/mkdirp @@ -0,0 +1 @@ +../mkdirp/bin/cmd.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/nopt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/nopt new file mode 120000 index 0000000..6b6566e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/nopt @@ -0,0 +1 @@ +../nopt/bin/nopt.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rc new file mode 120000 index 0000000..a3f6fc7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rc @@ -0,0 +1 @@ +../rc/index.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rimraf b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rimraf new file mode 120000 index 0000000..4cd49a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/rimraf @@ -0,0 +1 @@ +../rimraf/bin.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/semver b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/semver new file mode 120000 index 0000000..317eb29 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/.bin/semver @@ -0,0 +1 @@ +../semver/bin/semver \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.npmignore new file mode 100644 index 0000000..9303c34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.npmignore @@ -0,0 +1,2 @@ +node_modules/ +npm-debug.log \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.travis.yml new file mode 100644 index 0000000..c693a93 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.6 + - 0.8 + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/LICENSE new file mode 100644 index 0000000..432d1ae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/LICENSE @@ -0,0 +1,21 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/cmd.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/cmd.js new file mode 100755 index 0000000..d95de15 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/cmd.js @@ -0,0 +1,33 @@ +#!/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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/usage.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/usage.txt new file mode 100644 index 0000000..f952aa2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/bin/usage.txt @@ -0,0 +1,12 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/examples/pow.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/examples/pow.js new file mode 100644 index 0000000..e692421 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/examples/pow.js @@ -0,0 +1,6 @@ +var mkdirp = require('mkdirp'); + +mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) console.error(err) + else console.log('pow!') +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/index.js new file mode 100644 index 0000000..a1742b2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/index.js @@ -0,0 +1,97 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/.travis.yml new file mode 100644 index 0000000..cc4dba2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/LICENSE new file mode 100644 index 0000000..ee27ba4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/example/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/example/parse.js new file mode 100644 index 0000000..abff3e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/example/parse.js @@ -0,0 +1,2 @@ +var argv = require('../')(process.argv.slice(2)); +console.dir(argv); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/index.js new file mode 100644 index 0000000..584f551 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/index.js @@ -0,0 +1,187 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/package.json new file mode 100644 index 0000000..09e9ec4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/package.json @@ -0,0 +1,67 @@ +{ + "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", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/readme.markdown b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/readme.markdown new file mode 100644 index 0000000..c256353 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/readme.markdown @@ -0,0 +1,73 @@ +# minimist + +parse argument options + +This module is the guts of optimist's argument parser without all the +fanciful decoration. + +[](http://ci.testling.com/substack/minimist) + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dash.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dash.js new file mode 100644 index 0000000..8b034b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dash.js @@ -0,0 +1,24 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/default_bool.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/default_bool.js new file mode 100644 index 0000000..f0041ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/default_bool.js @@ -0,0 +1,20 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dotted.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dotted.js new file mode 100644 index 0000000..ef0ae34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/dotted.js @@ -0,0 +1,16 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/long.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/long.js new file mode 100644 index 0000000..5d3a1e0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/long.js @@ -0,0 +1,31 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse.js new file mode 100644 index 0000000..8a90646 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse.js @@ -0,0 +1,318 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js new file mode 100644 index 0000000..21851b0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/parse_modified.js @@ -0,0 +1,9 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/short.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/short.js new file mode 100644 index 0000000..d513a1c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/short.js @@ -0,0 +1,67 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/whitespace.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/whitespace.js new file mode 100644 index 0000000..8a52a58 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/test/whitespace.js @@ -0,0 +1,8 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/package.json new file mode 100644 index 0000000..f3adb5b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/package.json @@ -0,0 +1,58 @@ +{ + "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": "git+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 <0.6.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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/readme.markdown b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/readme.markdown new file mode 100644 index 0000000..3cc1315 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/readme.markdown @@ -0,0 +1,100 @@ +# mkdirp + +Like `mkdir -p`, but in node.js! + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/chmod.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/chmod.js new file mode 100644 index 0000000..520dcb8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/chmod.js @@ -0,0 +1,38 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/clobber.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/clobber.js new file mode 100644 index 0000000..0eb7099 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/clobber.js @@ -0,0 +1,37 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/mkdirp.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/mkdirp.js new file mode 100644 index 0000000..3b624dd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/mkdirp.js @@ -0,0 +1,26 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs.js new file mode 100644 index 0000000..f1fbeca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs.js @@ -0,0 +1,27 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs_sync.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs_sync.js new file mode 100644 index 0000000..224b506 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/opts_fs_sync.js @@ -0,0 +1,25 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm.js new file mode 100644 index 0000000..2c97590 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm.js @@ -0,0 +1,30 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm_sync.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm_sync.js new file mode 100644 index 0000000..327e54b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/perm_sync.js @@ -0,0 +1,34 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/race.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/race.js new file mode 100644 index 0000000..7c295f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/race.js @@ -0,0 +1,40 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/rel.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/rel.js new file mode 100644 index 0000000..d1f175c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/rel.js @@ -0,0 +1,30 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return.js new file mode 100644 index 0000000..bce68e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return.js @@ -0,0 +1,25 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return_sync.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return_sync.js new file mode 100644 index 0000000..7c222d3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/return_sync.js @@ -0,0 +1,24 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/root.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/root.js new file mode 100644 index 0000000..97ad7a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/root.js @@ -0,0 +1,18 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/sync.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/sync.js new file mode 100644 index 0000000..88fa432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/sync.js @@ -0,0 +1,30 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask.js new file mode 100644 index 0000000..82c393a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask.js @@ -0,0 +1,26 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask_sync.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask_sync.js new file mode 100644 index 0000000..e537fbe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/mkdirp/test/umask_sync.js @@ -0,0 +1,30 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/LICENSE new file mode 100644 index 0000000..05a4010 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/LICENSE @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/README.md new file mode 100644 index 0000000..5aba088 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/README.md @@ -0,0 +1,209 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/bin/nopt.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/bin/nopt.js new file mode 100755 index 0000000..3232d4c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/bin/nopt.js @@ -0,0 +1,54 @@ +#!/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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/examples/my-program.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/examples/my-program.js new file mode 100755 index 0000000..142447e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/examples/my-program.js @@ -0,0 +1,30 @@ +#!/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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js new file mode 100644 index 0000000..5309a00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js @@ -0,0 +1,414 @@ +// 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md new file mode 100644 index 0000000..2f30261 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md @@ -0,0 +1,3 @@ + To get started, sign the + Contributor License Agreement. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/LICENSE new file mode 100644 index 0000000..05a4010 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/LICENSE @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/README.md new file mode 100644 index 0000000..99746fe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/README.md @@ -0,0 +1,23 @@ +# 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/abbrev.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/abbrev.js new file mode 100644 index 0000000..69cfeac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/abbrev.js @@ -0,0 +1,62 @@ + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/package.json new file mode 100644 index 0000000..26bbc67 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/package.json @@ -0,0 +1,45 @@ +{ + "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.0.0 <2.0.0", + "_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" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/test.js new file mode 100644 index 0000000..d5a7303 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev/test.js @@ -0,0 +1,47 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/package.json new file mode 100644 index 0000000..5ffec0d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/package.json @@ -0,0 +1,56 @@ +{ + "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 <3.1.0", + "_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" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js new file mode 100644 index 0000000..2f9088c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js @@ -0,0 +1,251 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/.npmrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/.npmrc new file mode 100644 index 0000000..ca0bc48 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/.npmrc @@ -0,0 +1,2 @@ +save-prefix = ~ +proprietary-attribs = false diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/LICENSE new file mode 100644 index 0000000..0c44ae7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/LICENSE @@ -0,0 +1,27 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md new file mode 100644 index 0000000..a57cf42 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md @@ -0,0 +1,195 @@ +# npmlog + +The logger util that npm uses. + +This logger is very basic. It does the logging for npm. It supports +custom levels and colored output. + +By default, logs are written to stderr. If you want to send log messages +to outputs other than streams, then you can change the `log.stream` +member, or you can just listen to the events that it emits, and do +whatever you want with them. + +# Basic Usage + +``` +var log = require('npmlog') + +// additional stuff ---------------------------+ +// message ----------+ | +// prefix ----+ | | +// level -+ | | | +// v v v v + log.info('fyi', 'I have a kitty cat: %j', myKittyCat) +``` + +## log.level + +* {String} + +The level to display logs at. Any logs at or above this level will be +displayed. The special level `silent` will prevent anything from being +displayed ever. + +## log.record + +* {Array} + +An array of all the log messages that have been entered. + +## log.maxRecordSize + +* {Number} + +The maximum number of records to keep. If log.record gets bigger than +10% over this value, then it is sliced down to 90% of this value. + +The reason for the 10% window is so that it doesn't have to resize a +large array on every log entry. + +## log.prefixStyle + +* {Object} + +A style object that specifies how prefixes are styled. (See below) + +## log.headingStyle + +* {Object} + +A style object that specifies how the heading is styled. (See below) + +## log.heading + +* {String} Default: "" + +If set, a heading that is printed at the start of every line. + +## log.stream + +* {Stream} Default: `process.stderr` + +The stream where output is written. + +## log.enableColor() + +Force colors to be used on all messages, regardless of the output +stream. + +## log.disableColor() + +Disable colors on all messages. + +## log.enableProgress() + +Enable the display of log activity spinner and progress bar + +## log.disableProgress() + +Disable the display of a progress bar + +## log.enableUnicode() + +Force the unicode theme to be used for the progress bar. + +## log.disableUnicode() + +Disable the use of unicode in the progress bar. + +## log.setGaugeTemplate(template) + +Overrides the default gauge template. + +## log.pause() + +Stop emitting messages to the stream, but do not drop them. + +## log.resume() + +Emit all buffered messages that were written while paused. + +## log.log(level, prefix, message, ...) + +* `level` {String} The level to emit the message at +* `prefix` {String} A string prefix. Set to "" to skip. +* `message...` Arguments to `util.format` + +Emit a log message at the specified level. + +## log\[level](prefix, message, ...) + +For example, + +* log.silly(prefix, message, ...) +* log.verbose(prefix, message, ...) +* log.info(prefix, message, ...) +* log.http(prefix, message, ...) +* log.warn(prefix, message, ...) +* log.error(prefix, message, ...) + +Like `log.log(level, prefix, message, ...)`. In this way, each level is +given a shorthand, so you can do `log.info(prefix, message)`. + +## log.addLevel(level, n, style, disp) + +* `level` {String} Level indicator +* `n` {Number} The numeric level +* `style` {Object} Object with fg, bg, inverse, etc. +* `disp` {String} Optional replacement for `level` in the output. + +Sets up a new level with a shorthand function and so forth. + +Note that if the number is `Infinity`, then setting the level to that +will cause all log messages to be suppressed. If the number is +`-Infinity`, then the only way to show it is to enable all log messages. + +## log.newItem(name, todo, weight) + +* `name` {String} Optional; progress item name. +* `todo` {Number} Optional; total amount of work to be done. Default 0. +* `weight` {Number} Optional; the weight of this item relative to others. Default 1. + +This adds a new `are-we-there-yet` item tracker to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `Tracker` object. + +## log.newStream(name, todo, weight) + +This adds a new `are-we-there-yet` stream tracker to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `TrackerStream` object. + +## log.newGroup(name, weight) + +This adds a new `are-we-there-yet` tracker group to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `TrackerGroup` object. + +# Events + +Events are all emitted with the message object. + +* `log` Emitted for all messages +* `log.` Emitted for all messages with the `` level. +* `` Messages with prefixes also emit their prefix as an event. + +# Style Objects + +Style objects can have the following fields: + +* `fg` {String} Color for the foreground text +* `bg` {String} Color for the background +* `bold`, `inverse`, `underline` {Boolean} Set the associated property +* `bell` {Boolean} Make a noise (This is pretty annoying, probably.) + +# Message Objects + +Every log event is emitted with a message object, and the `log.record` +list contains all of them that have been created. They have the +following fields: + +* `id` {Number} +* `level` {String} +* `prefix` {String} +* `message` {String} Result of `util.format()` +* `messageRaw` {Array} Arguments to `util.format()` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md~ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md~ new file mode 100644 index 0000000..4a056f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/README.md~ @@ -0,0 +1,191 @@ +# npmlog + +The logger util that npm uses. + +This logger is very basic. It does the logging for npm. It supports +custom levels and colored output. + +By default, logs are written to stderr. If you want to send log messages +to outputs other than streams, then you can change the `log.stream` +member, or you can just listen to the events that it emits, and do +whatever you want with them. + +# Basic Usage + +``` +var log = require('npmlog') + +// additional stuff ---------------------------+ +// message ----------+ | +// prefix ----+ | | +// level -+ | | | +// v v v v + log.info('fyi', 'I have a kitty cat: %j', myKittyCat) +``` + +## log.level + +* {String} + +The level to display logs at. Any logs at or above this level will be +displayed. The special level `silent` will prevent anything from being +displayed ever. + +## log.record + +* {Array} + +An array of all the log messages that have been entered. + +## log.maxRecordSize + +* {Number} + +The maximum number of records to keep. If log.record gets bigger than +10% over this value, then it is sliced down to 90% of this value. + +The reason for the 10% window is so that it doesn't have to resize a +large array on every log entry. + +## log.prefixStyle + +* {Object} + +A style object that specifies how prefixes are styled. (See below) + +## log.headingStyle + +* {Object} + +A style object that specifies how the heading is styled. (See below) + +## log.heading + +* {String} Default: "" + +If set, a heading that is printed at the start of every line. + +## log.stream + +* {Stream} Default: `process.stderr` + +The stream where output is written. + +## log.enableColor() + +Force colors to be used on all messages, regardless of the output +stream. + +## log.disableColor() + +Disable colors on all messages. + +## log.enableProgress() + +Enable the display of log activity spinner and progress bar + +## log.disableProgress() + +Disable the display of a progress bar + +## log.enableUnicode() + +Force the unicode theme to be used for the progress bar. + +## log.disableUnicode() + +Disable the use of unicode in the progress bar. + +## log.pause() + +Stop emitting messages to the stream, but do not drop them. + +## log.resume() + +Emit all buffered messages that were written while paused. + +## log.log(level, prefix, message, ...) + +* `level` {String} The level to emit the message at +* `prefix` {String} A string prefix. Set to "" to skip. +* `message...` Arguments to `util.format` + +Emit a log message at the specified level. + +## log\[level](prefix, message, ...) + +For example, + +* log.silly(prefix, message, ...) +* log.verbose(prefix, message, ...) +* log.info(prefix, message, ...) +* log.http(prefix, message, ...) +* log.warn(prefix, message, ...) +* log.error(prefix, message, ...) + +Like `log.log(level, prefix, message, ...)`. In this way, each level is +given a shorthand, so you can do `log.info(prefix, message)`. + +## log.addLevel(level, n, style, disp) + +* `level` {String} Level indicator +* `n` {Number} The numeric level +* `style` {Object} Object with fg, bg, inverse, etc. +* `disp` {String} Optional replacement for `level` in the output. + +Sets up a new level with a shorthand function and so forth. + +Note that if the number is `Infinity`, then setting the level to that +will cause all log messages to be suppressed. If the number is +`-Infinity`, then the only way to show it is to enable all log messages. + +## log.newItem(name, todo, weight) + +* `name` {String} Optional; progress item name. +* `todo` {Number} Optional; total amount of work to be done. Default 0. +* `weight` {Number} Optional; the weight of this item relative to others. Default 1. + +This adds a new `are-we-there-yet` item tracker to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `Tracker` object. + +## log.newStream(name, todo, weight) + +This adds a new `are-we-there-yet` stream tracker to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `TrackerStream` object. + +## log.newGroup(name, weight) + +This adds a new `are-we-there-yet` tracker group to the progress tracker. The +object returned has the `log[level]` methods but is otherwise an +`are-we-there-yet` `TrackerGroup` object. + +# Events + +Events are all emitted with the message object. + +* `log` Emitted for all messages +* `log.` Emitted for all messages with the `` level. +* `` Messages with prefixes also emit their prefix as an event. + +# Style Objects + +Style objects can have the following fields: + +* `fg` {String} Color for the foreground text +* `bg` {String} Color for the background +* `bold`, `inverse`, `underline` {Boolean} Set the associated property +* `bell` {Boolean} Make a noise (This is pretty annoying, probably.) + +# Message Objects + +Every log event is emitted with a message object, and the `log.record` +list contains all of them that have been created. They have the +following fields: + +* `id` {Number} +* `level` {String} +* `prefix` {String} +* `message` {String} Result of `util.format()` +* `messageRaw` {Array} Arguments to `util.format()` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/example.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/example.js new file mode 100644 index 0000000..c009fb1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/example.js @@ -0,0 +1,39 @@ +var log = require('./log.js') + +log.heading = 'npm' + +console.error('log.level=silly') +log.level = 'silly' +log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) +log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) +log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) +log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) +log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) +log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) +log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) + +console.error('log.level=silent') +log.level = 'silent' +log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) +log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) +log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) +log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) +log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) +log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) +log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) + +console.error('log.level=info') +log.level = 'info' +log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) +log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) +log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) +log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) +log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) +log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) +log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) +log.error('404', 'This is a longer\n'+ + 'message, with some details\n'+ + 'and maybe a stack.\n'+ + new Error('a 404 error').stack) +log.addLevel('noise', 10000, {beep: true}) +log.noise(false, 'LOUD NOISES') diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js new file mode 100644 index 0000000..067f6ff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js @@ -0,0 +1,247 @@ +'use strict' +var Progress = require('are-we-there-yet') +var Gauge = require('gauge') +var EE = require('events').EventEmitter +var log = exports = module.exports = new EE +var util = require('util') + +var ansi = require('ansi') +log.cursor = ansi(process.stderr) +log.stream = process.stderr + +// by default, let ansi decide based on tty-ness. +var colorEnabled = undefined +log.enableColor = function () { + colorEnabled = true + this.cursor.enabled = true +} +log.disableColor = function () { + colorEnabled = false + this.cursor.enabled = false +} + +// default level +log.level = 'info' + +log.gauge = new Gauge(log.cursor) +log.tracker = new Progress.TrackerGroup() + +// no progress bars unless asked +log.progressEnabled = false + +var gaugeTheme = undefined + +log.enableUnicode = function () { + gaugeTheme = gauge.unicode + log.gauge.setTheme(gaugeTheme) +} + +log.disableUnicode = function () { + gaugeTheme = gauge.ascii + log.gauge.setTheme(gaugeTheme) +} + +var gaugeTemplate = undefined +log.setGaugeTemplate = function (template) { + gaugeTemplate = template + log.gauge.setTemplate(gaugeTemplate) +} + +log.enableProgress = function () { + if (this.progressEnabled) return + this.progressEnabled = true + if (this._pause) return + this.tracker.on('change', this.showProgress) + this.gauge.enable() + this.showProgress() +} + +log.disableProgress = function () { + if (!this.progressEnabled) return + this.clearProgress() + this.progressEnabled = false + this.tracker.removeListener('change', this.showProgress) + this.gauge.disable() +} + +var trackerConstructors = ['newGroup', 'newItem', 'newStream'] + +var mixinLog = function (tracker) { + // mixin the public methods from log into the tracker + // (except: conflicts and one's we handle specially) + Object.keys(log).forEach(function (P) { + if (P[0] === '_') return + if (trackerConstructors.filter(function (C) { return C === P }).length) return + if (tracker[P]) return + if (typeof log[P] !== 'function') return + var func = log[P] + tracker[P] = function () { + return func.apply(log, arguments) + } + }) + // if the new tracker is a group, make sure any subtrackers get + // mixed in too + if (tracker instanceof Progress.TrackerGroup) { + trackerConstructors.forEach(function (C) { + var func = tracker[C] + tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } + }) + } + return tracker +} + +// Add tracker constructors to the top level log object +trackerConstructors.forEach(function (C) { + log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } +}) + +log.clearProgress = function () { + if (!this.progressEnabled) return + this.gauge.hide() +} + +log.showProgress = function (name) { + if (!this.progressEnabled) return + this.gauge.show(name, this.tracker.completed()) +}.bind(log) // bind for use in tracker's on-change listener + +// temporarily stop emitting, but don't drop +log.pause = function () { + this._paused = true +} + +log.resume = function () { + if (!this._paused) return + this._paused = false + + var b = this._buffer + this._buffer = [] + b.forEach(function (m) { + this.emitLog(m) + }, this) + if (this.progressEnabled) this.enableProgress() +} + +log._buffer = [] + +var id = 0 +log.record = [] +log.maxRecordSize = 10000 +log.log = function (lvl, prefix, message) { + var l = this.levels[lvl] + if (l === undefined) { + return this.emit('error', new Error(util.format( + 'Undefined log level: %j', lvl))) + } + + var a = new Array(arguments.length - 2) + var stack = null + for (var i = 2; i < arguments.length; i ++) { + var arg = a[i-2] = arguments[i] + + // resolve stack traces to a plain string. + if (typeof arg === 'object' && arg && + (arg instanceof Error) && arg.stack) { + arg.stack = stack = arg.stack + '' + } + } + if (stack) a.unshift(stack + '\n') + message = util.format.apply(util, a) + + var m = { id: id++, + level: lvl, + prefix: String(prefix || ''), + message: message, + messageRaw: a } + + this.emit('log', m) + this.emit('log.' + lvl, m) + if (m.prefix) this.emit(m.prefix, m) + + this.record.push(m) + var mrs = this.maxRecordSize + var n = this.record.length - mrs + if (n > mrs / 10) { + var newSize = Math.floor(mrs * 0.9) + this.record = this.record.slice(-1 * newSize) + } + + this.emitLog(m) +}.bind(log) + +log.emitLog = function (m) { + if (this._paused) { + this._buffer.push(m) + return + } + if (this.progressEnabled) this.gauge.pulse(m.prefix) + var l = this.levels[m.level] + if (l === undefined) return + if (l < this.levels[this.level]) return + if (l > 0 && !isFinite(l)) return + + var style = log.style[m.level] + var disp = log.disp[m.level] || m.level + this.clearProgress() + m.message.split(/\r?\n/).forEach(function (line) { + if (this.heading) { + this.write(this.heading, this.headingStyle) + this.write(' ') + } + this.write(disp, log.style[m.level]) + var p = m.prefix || '' + if (p) this.write(' ') + this.write(p, this.prefixStyle) + this.write(' ' + line + '\n') + }, this) + this.showProgress() +} + +log.write = function (msg, style) { + if (!this.cursor) return + if (this.stream !== this.cursor.stream) { + this.cursor = ansi(this.stream, { enabled: colorEnabled }) + var options = {} + if (gaugeTheme != null) options.theme = gaugeTheme + if (gaugeTemplate != null) options.template = gaugeTemplate + this.gauge = new Gauge(options, this.cursor) + } + + style = style || {} + if (style.fg) this.cursor.fg[style.fg]() + if (style.bg) this.cursor.bg[style.bg]() + if (style.bold) this.cursor.bold() + if (style.underline) this.cursor.underline() + if (style.inverse) this.cursor.inverse() + if (style.beep) this.cursor.beep() + this.cursor.write(msg).reset() +} + +log.addLevel = function (lvl, n, style, disp) { + if (!disp) disp = lvl + this.levels[lvl] = n + this.style[lvl] = style + if (!this[lvl]) this[lvl] = function () { + var a = new Array(arguments.length + 1) + a[0] = lvl + for (var i = 0; i < arguments.length; i ++) { + a[i + 1] = arguments[i] + } + return this.log.apply(this, a) + }.bind(this) + this.disp[lvl] = disp +} + +log.prefixStyle = { fg: 'magenta' } +log.headingStyle = { fg: 'white', bg: 'black' } + +log.style = {} +log.levels = {} +log.disp = {} +log.addLevel('silly', -Infinity, { inverse: true }, 'sill') +log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb') +log.addLevel('info', 2000, { fg: 'green' }) +log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) +log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') +log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') +log.addLevel('silent', Infinity) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js~ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js~ new file mode 100644 index 0000000..20781f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/log.js~ @@ -0,0 +1,240 @@ +'use strict' +var Progress = require('are-we-there-yet') +var Gauge = require('gauge') +var EE = require('events').EventEmitter +var log = exports = module.exports = new EE +var util = require('util') + +var ansi = require('ansi') +log.cursor = ansi(process.stderr) +log.stream = process.stderr + +// by default, let ansi decide based on tty-ness. +var colorEnabled = undefined +log.enableColor = function () { + colorEnabled = true + this.cursor.enabled = true +} +log.disableColor = function () { + colorEnabled = false + this.cursor.enabled = false +} + +// default level +log.level = 'info' + +log.gauge = new Gauge(log.cursor) +log.tracker = new Progress.TrackerGroup() + +// no progress bars unless asked +log.progressEnabled = false + +var unicodeEnabled = undefined +log.enableUnicode = function () { + unicodeEnabled = true + log.gauge.setTheme(Gauge.unicode) +} +log.disableUnicode = function () { + unicodeEnabled = false + log.gauge.setTheme(Gauge.ascii) +} + +log.enableProgress = function () { + if (this.progressEnabled) return + this.progressEnabled = true + if (this._pause) return + this.tracker.on('change', this.showProgress) + this.gauge.enable() + this.showProgress() +} + +log.disableProgress = function () { + if (!this.progressEnabled) return + this.clearProgress() + this.progressEnabled = false + this.tracker.removeListener('change', this.showProgress) + this.gauge.disable() +} + +var trackerConstructors = ['newGroup', 'newItem', 'newStream'] + +var mixinLog = function (tracker) { + // mixin the public methods from log into the tracker + // (except: conflicts and one's we handle specially) + Object.keys(log).forEach(function (P) { + if (P[0] === '_') return + if (trackerConstructors.filter(function (C) { return C === P }).length) return + if (tracker[P]) return + if (typeof log[P] !== 'function') return + var func = log[P] + tracker[P] = function () { + return func.apply(log, arguments) + } + }) + // if the new tracker is a group, make sure any subtrackers get + // mixed in too + if (tracker instanceof Progress.TrackerGroup) { + trackerConstructors.forEach(function (C) { + var func = tracker[C] + tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } + }) + } + return tracker +} + +// Add tracker constructors to the top level log object +trackerConstructors.forEach(function (C) { + log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } +}) + +log.clearProgress = function () { + if (!this.progressEnabled) return + this.gauge.hide() +} + +log.showProgress = function (name) { + if (!this.progressEnabled) return + this.gauge.show(name, this.tracker.completed()) +}.bind(log) // bind for use in tracker's on-change listener + +// temporarily stop emitting, but don't drop +log.pause = function () { + this._paused = true +} + +log.resume = function () { + if (!this._paused) return + this._paused = false + + var b = this._buffer + this._buffer = [] + b.forEach(function (m) { + this.emitLog(m) + }, this) + if (this.progressEnabled) this.enableProgress() +} + +log._buffer = [] + +var id = 0 +log.record = [] +log.maxRecordSize = 10000 +log.log = function (lvl, prefix, message) { + var l = this.levels[lvl] + if (l === undefined) { + return this.emit('error', new Error(util.format( + 'Undefined log level: %j', lvl))) + } + + var a = new Array(arguments.length - 2) + var stack = null + for (var i = 2; i < arguments.length; i ++) { + var arg = a[i-2] = arguments[i] + + // resolve stack traces to a plain string. + if (typeof arg === 'object' && arg && + (arg instanceof Error) && arg.stack) { + arg.stack = stack = arg.stack + '' + } + } + if (stack) a.unshift(stack + '\n') + message = util.format.apply(util, a) + + var m = { id: id++, + level: lvl, + prefix: String(prefix || ''), + message: message, + messageRaw: a } + + this.emit('log', m) + this.emit('log.' + lvl, m) + if (m.prefix) this.emit(m.prefix, m) + + this.record.push(m) + var mrs = this.maxRecordSize + var n = this.record.length - mrs + if (n > mrs / 10) { + var newSize = Math.floor(mrs * 0.9) + this.record = this.record.slice(-1 * newSize) + } + + this.emitLog(m) +}.bind(log) + +log.emitLog = function (m) { + if (this._paused) { + this._buffer.push(m) + return + } + if (this.progressEnabled) this.gauge.pulse(m.prefix) + var l = this.levels[m.level] + if (l === undefined) return + if (l < this.levels[this.level]) return + if (l > 0 && !isFinite(l)) return + + var style = log.style[m.level] + var disp = log.disp[m.level] || m.level + this.clearProgress() + m.message.split(/\r?\n/).forEach(function (line) { + if (this.heading) { + this.write(this.heading, this.headingStyle) + this.write(' ') + } + this.write(disp, log.style[m.level]) + var p = m.prefix || '' + if (p) this.write(' ') + this.write(p, this.prefixStyle) + this.write(' ' + line + '\n') + }, this) + this.showProgress() +} + +log.write = function (msg, style) { + if (!this.cursor) return + if (this.stream !== this.cursor.stream) { + this.cursor = ansi(this.stream, { enabled: colorEnabled }) + var options = {} + if (unicodeEnabled != null) { + options.theme = unicodeEnabled ? Gauge.unicode : Gauge.ascii + } + this.gauge = new Gauge(options, this.cursor) + } + + style = style || {} + if (style.fg) this.cursor.fg[style.fg]() + if (style.bg) this.cursor.bg[style.bg]() + if (style.bold) this.cursor.bold() + if (style.underline) this.cursor.underline() + if (style.inverse) this.cursor.inverse() + if (style.beep) this.cursor.beep() + this.cursor.write(msg).reset() +} + +log.addLevel = function (lvl, n, style, disp) { + if (!disp) disp = lvl + this.levels[lvl] = n + this.style[lvl] = style + if (!this[lvl]) this[lvl] = function () { + var a = new Array(arguments.length + 1) + a[0] = lvl + for (var i = 0; i < arguments.length; i ++) { + a[i + 1] = arguments[i] + } + return this.log.apply(this, a) + }.bind(this) + this.disp[lvl] = disp +} + +log.prefixStyle = { fg: 'magenta' } +log.headingStyle = { fg: 'white', bg: 'black' } + +log.style = {} +log.levels = {} +log.disp = {} +log.addLevel('silly', -Infinity, { inverse: true }, 'sill') +log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb') +log.addLevel('info', 2000, { fg: 'green' }) +log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) +log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') +log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') +log.addLevel('silent', Infinity) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.jshintrc new file mode 100644 index 0000000..248c542 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.jshintrc @@ -0,0 +1,4 @@ +{ + "laxcomma": true, + "asi": true +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/History.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/History.md new file mode 100644 index 0000000..f4a9fe3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/History.md @@ -0,0 +1,16 @@ + +0.3.0 / 2014-05-09 +================== + + * package: remove "test" script and "devDependencies" + * package: remove "engines" section + * pacakge: remove "bin" section + * package: beautify + * examples: remove `starwars` example (#15) + * Documented goto, horizontalAbsolute, and eraseLine methods in README.md (#12, @Jammerwoch) + * add `.jshintrc` file + +< 0.3.0 +======= + + * Prehistoric diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/README.md new file mode 100644 index 0000000..6ce1940 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/README.md @@ -0,0 +1,98 @@ +ansi.js +========= +### Advanced ANSI formatting tool for Node.js + +`ansi.js` is a module for Node.js that provides an easy-to-use API for +writing ANSI escape codes to `Stream` instances. ANSI escape codes are used to do +fancy things in a terminal window, like render text in colors, delete characters, +lines, the entire window, or hide and show the cursor, and lots more! + +#### Features: + + * 256 color support for the terminal! + * Make a beep sound from your terminal! + * Works with *any* writable `Stream` instance. + * Allows you to move the cursor anywhere on the terminal window. + * Allows you to delete existing contents from the terminal window. + * Allows you to hide and show the cursor. + * Converts CSS color codes and RGB values into ANSI escape codes. + * Low-level; you are in control of when escape codes are used, it's not abstracted. + + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install ansi +``` + + +Example +------- + +``` js +var ansi = require('ansi') + , cursor = ansi(process.stdout) + +// You can chain your calls forever: +cursor + .red() // Set font color to red + .bg.grey() // Set background color to grey + .write('Hello World!') // Write 'Hello World!' to stdout + .bg.reset() // Reset the bgcolor before writing the trailing \n, + // to avoid Terminal glitches + .write('\n') // And a final \n to wrap things up + +// Rendering modes are persistent: +cursor.hex('#660000').bold().underline() + +// You can use the regular logging functions, text will be green: +console.log('This is blood red, bold text') + +// To reset just the foreground color: +cursor.fg.reset() + +console.log('This will still be bold') + +// to go to a location (x,y) on the console +// note: 1-indexed, not 0-indexed: +cursor.goto(10, 5).write('Five down, ten over') + +// to clear the current line: +cursor.horizontalAbsolute(0).eraseLine().write('Starting again') + +// to go to a different column on the current line: +cursor.horizontalAbsolute(5).write('column five') + +// Clean up after yourself! +cursor.reset() +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/beep/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/beep/index.js new file mode 100755 index 0000000..c1ec929 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/beep/index.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +/** + * Invokes the terminal "beep" sound once per second on every exact second. + */ + +process.title = 'beep' + +var cursor = require('../../')(process.stdout) + +function beep () { + cursor.beep() + setTimeout(beep, 1000 - (new Date()).getMilliseconds()) +} + +setTimeout(beep, 1000 - (new Date()).getMilliseconds()) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/clear/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/clear/index.js new file mode 100755 index 0000000..6ac21ff --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/clear/index.js @@ -0,0 +1,15 @@ +#!/usr/bin/env node + +/** + * Like GNU ncurses "clear" command. + * https://github.com/mscdex/node-ncurses/blob/master/deps/ncurses/progs/clear.c + */ + +process.title = 'clear' + +function lf () { return '\n' } + +require('../../')(process.stdout) + .write(Array.apply(null, Array(process.stdout.getWindowSize()[1])).map(lf).join('')) + .eraseData(2) + .goto(1, 1) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/cursorPosition.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/cursorPosition.js new file mode 100755 index 0000000..50f9644 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/cursorPosition.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +var tty = require('tty') +var cursor = require('../')(process.stdout) + +// listen for the queryPosition report on stdin +process.stdin.resume() +raw(true) + +process.stdin.once('data', function (b) { + var match = /\[(\d+)\;(\d+)R$/.exec(b.toString()) + if (match) { + var xy = match.slice(1, 3).reverse().map(Number) + console.error(xy) + } + + // cleanup and close stdin + raw(false) + process.stdin.pause() +}) + + +// send the query position request code to stdout +cursor.queryPosition() + +function raw (mode) { + if (process.stdin.setRawMode) { + process.stdin.setRawMode(mode) + } else { + tty.setRawMode(mode) + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/progress/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/progress/index.js new file mode 100644 index 0000000..d28dbda --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/examples/progress/index.js @@ -0,0 +1,87 @@ +#!/usr/bin/env node + +var assert = require('assert') + , ansi = require('../../') + +function Progress (stream, width) { + this.cursor = ansi(stream) + this.delta = this.cursor.newlines + this.width = width | 0 || 10 + this.open = '[' + this.close = ']' + this.complete = '█' + this.incomplete = '_' + + // initial render + this.progress = 0 +} + +Object.defineProperty(Progress.prototype, 'progress', { + get: get + , set: set + , configurable: true + , enumerable: true +}) + +function get () { + return this._progress +} + +function set (v) { + this._progress = Math.max(0, Math.min(v, 100)) + + var w = this.width - this.complete.length - this.incomplete.length + , n = w * (this._progress / 100) | 0 + , i = w - n + , com = c(this.complete, n) + , inc = c(this.incomplete, i) + , delta = this.cursor.newlines - this.delta + + assert.equal(com.length + inc.length, w) + + if (delta > 0) { + this.cursor.up(delta) + this.delta = this.cursor.newlines + } + + this.cursor + .horizontalAbsolute(0) + .eraseLine(2) + .fg.white() + .write(this.open) + .fg.grey() + .bold() + .write(com) + .resetBold() + .write(inc) + .fg.white() + .write(this.close) + .fg.reset() + .write('\n') +} + +function c (char, length) { + return Array.apply(null, Array(length)).map(function () { + return char + }).join('') +} + + + + +// Usage +var width = parseInt(process.argv[2], 10) || process.stdout.getWindowSize()[0] / 2 + , p = new Progress(process.stdout, width) + +;(function tick () { + p.progress += Math.random() * 5 + p.cursor + .eraseLine(2) + .write('Progress: ') + .bold().write(p.progress.toFixed(2)) + .write('%') + .resetBold() + .write('\n') + if (p.progress < 100) + setTimeout(tick, 100) +})() diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/lib/ansi.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/lib/ansi.js new file mode 100644 index 0000000..52fc8ec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/ansi/lib/ansi.js @@ -0,0 +1,405 @@ + +/** + * References: + * + * - http://en.wikipedia.org/wiki/ANSI_escape_code + * - http://www.termsys.demon.co.uk/vtansi.htm + * + */ + +/** + * Module dependencies. + */ + +var emitNewlineEvents = require('./newlines') + , prefix = '\x1b[' // For all escape codes + , suffix = 'm' // Only for color codes + +/** + * The ANSI escape sequences. + */ + +var codes = { + up: 'A' + , down: 'B' + , forward: 'C' + , back: 'D' + , nextLine: 'E' + , previousLine: 'F' + , horizontalAbsolute: 'G' + , eraseData: 'J' + , eraseLine: 'K' + , scrollUp: 'S' + , scrollDown: 'T' + , savePosition: 's' + , restorePosition: 'u' + , queryPosition: '6n' + , hide: '?25l' + , show: '?25h' +} + +/** + * Rendering ANSI codes. + */ + +var styles = { + bold: 1 + , italic: 3 + , underline: 4 + , inverse: 7 +} + +/** + * The negating ANSI code for the rendering modes. + */ + +var reset = { + bold: 22 + , italic: 23 + , underline: 24 + , inverse: 27 +} + +/** + * The standard, styleable ANSI colors. + */ + +var colors = { + white: 37 + , black: 30 + , blue: 34 + , cyan: 36 + , green: 32 + , magenta: 35 + , red: 31 + , yellow: 33 + , grey: 90 + , brightBlack: 90 + , brightRed: 91 + , brightGreen: 92 + , brightYellow: 93 + , brightBlue: 94 + , brightMagenta: 95 + , brightCyan: 96 + , brightWhite: 97 +} + + +/** + * Creates a Cursor instance based off the given `writable stream` instance. + */ + +function ansi (stream, options) { + if (stream._ansicursor) { + return stream._ansicursor + } else { + return stream._ansicursor = new Cursor(stream, options) + } +} +module.exports = exports = ansi + +/** + * The `Cursor` class. + */ + +function Cursor (stream, options) { + if (!(this instanceof Cursor)) { + return new Cursor(stream, options) + } + if (typeof stream != 'object' || typeof stream.write != 'function') { + throw new Error('a valid Stream instance must be passed in') + } + + // the stream to use + this.stream = stream + + // when 'enabled' is false then all the functions are no-ops except for write() + this.enabled = options && options.enabled + if (typeof this.enabled === 'undefined') { + this.enabled = stream.isTTY + } + this.enabled = !!this.enabled + + // then `buffering` is true, then `write()` calls are buffered in + // memory until `flush()` is invoked + this.buffering = !!(options && options.buffering) + this._buffer = [] + + // controls the foreground and background colors + this.fg = this.foreground = new Colorer(this, 0) + this.bg = this.background = new Colorer(this, 10) + + // defaults + this.Bold = false + this.Italic = false + this.Underline = false + this.Inverse = false + + // keep track of the number of "newlines" that get encountered + this.newlines = 0 + emitNewlineEvents(stream) + stream.on('newline', function () { + this.newlines++ + }.bind(this)) +} +exports.Cursor = Cursor + +/** + * Helper function that calls `write()` on the underlying Stream. + * Returns `this` instead of the write() return value to keep + * the chaining going. + */ + +Cursor.prototype.write = function (data) { + if (this.buffering) { + this._buffer.push(arguments) + } else { + this.stream.write.apply(this.stream, arguments) + } + return this +} + +/** + * Buffer `write()` calls into memory. + * + * @api public + */ + +Cursor.prototype.buffer = function () { + this.buffering = true + return this +} + +/** + * Write out the in-memory buffer. + * + * @api public + */ + +Cursor.prototype.flush = function () { + this.buffering = false + var str = this._buffer.map(function (args) { + if (args.length != 1) throw new Error('unexpected args length! ' + args.length); + return args[0]; + }).join(''); + this._buffer.splice(0); // empty + this.write(str); + return this +} + + +/** + * The `Colorer` class manages both the background and foreground colors. + */ + +function Colorer (cursor, base) { + this.current = null + this.cursor = cursor + this.base = base +} +exports.Colorer = Colorer + +/** + * Write an ANSI color code, ensuring that the same code doesn't get rewritten. + */ + +Colorer.prototype._setColorCode = function setColorCode (code) { + var c = String(code) + if (this.current === c) return + this.cursor.enabled && this.cursor.write(prefix + c + suffix) + this.current = c + return this +} + + +/** + * Set up the positional ANSI codes. + */ + +Object.keys(codes).forEach(function (name) { + var code = String(codes[name]) + Cursor.prototype[name] = function () { + var c = code + if (arguments.length > 0) { + c = toArray(arguments).map(Math.round).join(';') + code + } + this.enabled && this.write(prefix + c) + return this + } +}) + +/** + * Set up the functions for the rendering ANSI codes. + */ + +Object.keys(styles).forEach(function (style) { + var name = style[0].toUpperCase() + style.substring(1) + , c = styles[style] + , r = reset[style] + + Cursor.prototype[style] = function () { + if (this[name]) return + this.enabled && this.write(prefix + c + suffix) + this[name] = true + return this + } + + Cursor.prototype['reset' + name] = function () { + if (!this[name]) return + this.enabled && this.write(prefix + r + suffix) + this[name] = false + return this + } +}) + +/** + * Setup the functions for the standard colors. + */ + +Object.keys(colors).forEach(function (color) { + var code = colors[color] + + Colorer.prototype[color] = function () { + this._setColorCode(this.base + code) + return this.cursor + } + + Cursor.prototype[color] = function () { + return this.foreground[color]() + } +}) + +/** + * Makes a beep sound! + */ + +Cursor.prototype.beep = function () { + this.enabled && this.write('\x07') + return this +} + +/** + * Moves cursor to specific position + */ + +Cursor.prototype.goto = function (x, y) { + x = x | 0 + y = y | 0 + this.enabled && this.write(prefix + y + ';' + x + 'H') + return this +} + +/** + * Resets the color. + */ + +Colorer.prototype.reset = function () { + this._setColorCode(this.base + 39) + return this.cursor +} + +/** + * Resets all ANSI formatting on the stream. + */ + +Cursor.prototype.reset = function () { + this.enabled && this.write(prefix + '0' + suffix) + this.Bold = false + this.Italic = false + this.Underline = false + this.Inverse = false + this.foreground.current = null + this.background.current = null + return this +} + +/** + * Sets the foreground color with the given RGB values. + * The closest match out of the 216 colors is picked. + */ + +Colorer.prototype.rgb = function (r, g, b) { + var base = this.base + 38 + , code = rgb(r, g, b) + this._setColorCode(base + ';5;' + code) + return this.cursor +} + +/** + * Same as `cursor.fg.rgb(r, g, b)`. + */ + +Cursor.prototype.rgb = function (r, g, b) { + return this.foreground.rgb(r, g, b) +} + +/** + * Accepts CSS color codes for use with ANSI escape codes. + * For example: `#FF000` would be bright red. + */ + +Colorer.prototype.hex = function (color) { + return this.rgb.apply(this, hex(color)) +} + +/** + * Same as `cursor.fg.hex(color)`. + */ + +Cursor.prototype.hex = function (color) { + return this.foreground.hex(color) +} + + +// UTIL FUNCTIONS // + +/** + * Translates a 255 RGB value to a 0-5 ANSI RGV value, + * then returns the single ANSI color code to use. + */ + +function rgb (r, g, b) { + var red = r / 255 * 5 + , green = g / 255 * 5 + , blue = b / 255 * 5 + return rgb5(red, green, blue) +} + +/** + * Turns rgb 0-5 values into a single ANSI color code to use. + */ + +function rgb5 (r, g, b) { + var red = Math.round(r) + , green = Math.round(g) + , blue = Math.round(b) + return 16 + (red*36) + (green*6) + blue +} + +/** + * Accepts a hex CSS color code string (# is optional) and + * translates it into an Array of 3 RGB 0-255 values, which + * can then be used with rgb(). + */ + +function hex (color) { + var c = color[0] === '#' ? color.substring(1) : color + , r = c.substring(0, 2) + , g = c.substring(2, 4) + , b = c.substring(4, 6) + return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)] +} + +/** + * Turns an array-like object into a real array. + */ + +function toArray (a) { + var i = 0 + , l = a.length + , rtn = [] + for (; i 0) { + var len = data.length + , i = 0 + // now try to calculate any deltas + if (typeof data == 'string') { + for (; i=0.3.0 <0.4.0", + "_npmVersion": "1.4.9", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "maintainers": [ + { + "name": "TooTallNate", + "email": "nathan@tootallnate.net" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + } + ], + "dist": { + "shasum": "74b2f1f187c8553c7f95015bcb76009fb43d38e0", + "tarball": "http://registry.npmjs.org/ansi/-/ansi-0.3.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore new file mode 100644 index 0000000..926ddf6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore @@ -0,0 +1,3 @@ +*~ +.#* +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md new file mode 100644 index 0000000..52f9f9a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md @@ -0,0 +1,183 @@ +are-we-there-yet +---------------- + +Track complex hiearchies of asynchronous task completion statuses. This is +intended to give you a way of recording and reporting the progress of the big +recursive fan-out and gather type workflows that are so common in async. + +What you do with this completion data is up to you, but the most common use case is to +feed it to one of the many progress bar modules. + +Most progress bar modules include a rudamentary version of this, but my +needs were more complex. + +Usage +===== + +```javascript +var TrackerGroup = require("are-we-there-yet").TrackerGroup + +var top = new TrackerGroup("program") + +var single = top.newItem("one thing", 100) +single.completeWork(20) + +console.log(top.completed()) // 0.2 + +fs.stat("file", function(er, stat) { + if (er) throw er + var stream = top.newStream("file", stat.size) + console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete + // and 50% * 20% == 10% + fs.createReadStream("file").pipe(stream).on("data", function (chunk) { + // do stuff with chunk + }) + top.on("change", function (name) { + // called each time a chunk is read from "file" + // top.completed() will start at 0.1 and fill up to 0.6 as the file is read + }) +}) +``` + +Shared Methods +============== + +All tracker objects described below have the following methods, they, along +with the event comprise the interface for consumers of tracker objects. + +* var completed = tracker.completed() + +Returns the ratio of completed work to work to be done. Range of 0 to 1. + +* tracker.finish() + +Marks the tracker as completed. With a TrackerGroup this marks all of its +components as completed. + +Marks all of the components of this tracker as finished, which in turn means +that `tracker.completed()` for this will now be 1. + +This will result in one or more `change` events being emitted. + +Events +====== + +All tracker objects emit `change` events with an argument of the name of the +thing changing. + +TrackerGroup +============ + +* var tracker = new TrackerGroup(**name**) + + * **name** *(optional)* - The name of this tracker group, used in change + notifications if the component updating didn't have a name. Defaults to undefined. + +Creates a new empty tracker aggregation group. These are trackers whose +completion status is determined by the completion status of other trackers. + +* tracker.addUnit(**otherTracker**, **weight**) + + * **otherTracker** - Any of the other are-we-there-yet tracker objects + * **weight** *(optional)* - The weight to give the tracker, defaults to 1. + +Adds the **otherTracker** to this aggregation group. The weight determines +how long you expect this tracker to take to complete in proportion to other +units. So for instance, if you add one tracker with a weight of 1 and +another with a weight of 2, you're saying the second will take twice as long +to complete as the first. As such, the first will account for 33% of the +completion of this tracker and the second will account for the other 67%. + +Returns **otherTracker**. + +* var subGroup = tracker.newGroup(**name**, **weight**) + +The above is exactly equivalent to: + +```javascript + var subGroup = tracker.addUnit(new TrackerGroup(name), weight) +``` + +* var subItem = tracker.newItem(**name**, **todo**, **weight**) + +The above is exactly equivalent to: + +```javascript + var subItem = tracker.addUnit(new Tracker(name, todo), weight) +``` + +* var subStream = tracker.newStream(**name**, **todo**, **weight**) + +The above is exactly equivalent to: + +```javascript + var subStream = tracker.addUnit(new TrackerStream(name, todo), weight) +``` + +* console.log( tracker.debug() ) + +Returns a tree showing the completion of this tracker group and all of its +children, including recursively entering all of the children. + +Tracker +======= + +* var tracker = new Tracker(**name**, **todo**) + + * **name** *(optional)* The name of this counter to report in change + events. Defaults to undefined. + * **todo** *(optional)* The amount of work todo (a number). Defaults to 0. + +Ordinarily these are constructed as a part of a tracker group (via `newItem`) but they c + +* var completed = tracker.completed() + +Returns the ratio of completed work to work to be done. Range of 0 to 1. If +total work to be done is 0 then it will return 0. + +* tracker.addWork(**todo**) + + * **todo** A number to add to the amount of work to be done. + +Increases the amount of work to be done, thus decreasing the completion +percentage. Triggers a `change` event. + +* tracker.completeWork(**completed**) + + * **completed** A number to add to the work complete + +Increase the amount of work complete, thus increasing the completion percentage. +Will never increase the work completed past the amount of work todo. That is, +percentages > 100% are not allowed. Triggers a `change` event. + +* tracker.finish() + +Marks this tracker as finished, tracker.completed() will now be 1. Triggers +a `change` event. + +TrackerStream +============= + +* var tracker = new TrackerStream(**name**, **size**, **options**) + + * **name** *(optional)* The name of this counter to report in change + events. Defaults to undefined. + * **size** *(optional)* The number of bytes being sent through this stream. + * **options** *(optional)* A hash of stream options + +The tracker stream object is a pass through stream that updates an internal +tracker object each time a block passes through. It's intended to track +downloads, file extraction and other related activities. You use it by piping +your data source into it and then using it as your data source. + +If your data has a length attribute then that's used as the amount of work +completed when the chunk is passed through. If it does not (eg, object +streams) then each chunk counts as completing 1 unit of work, so your size +should be the total number of objects being streamed. + +* tracker.addWork(**todo**) + + * **todo** Increase the expected overall size by **todo** bytes. + +Increases the amount of work to be done, thus decreasing the completion +percentage. Triggers a `change` event. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js new file mode 100644 index 0000000..22f47ac --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js @@ -0,0 +1,130 @@ +"use strict" +var stream = require("readable-stream"); +var EventEmitter = require("events").EventEmitter +var util = require("util") +var delegate = require("delegates") + +var TrackerGroup = exports.TrackerGroup = function (name) { + EventEmitter.call(this) + this.name = name + this.trackGroup = [] + var self = this + this.totalWeight = 0 + var noteChange = this.noteChange = function (name) { + self.emit("change", name || this.name) + }.bind(this) + this.trackGroup.forEach(function(unit) { + unit.on("change", noteChange) + }) +} +util.inherits(TrackerGroup, EventEmitter) + +TrackerGroup.prototype.completed = function () { + if (this.trackGroup.length==0) return 0 + var valPerWeight = 1 / this.totalWeight + var completed = 0 + this.trackGroup.forEach(function(T) { + completed += valPerWeight * T.weight * T.completed() + }) + return completed +} + +TrackerGroup.prototype.addUnit = function (unit, weight, noChange) { + unit.weight = weight || 1 + this.totalWeight += unit.weight + this.trackGroup.push(unit) + unit.on("change", this.noteChange) + if (! noChange) this.emit("change", this.name) + return unit +} + +TrackerGroup.prototype.newGroup = function (name, weight) { + return this.addUnit(new TrackerGroup(name), weight) +} + +TrackerGroup.prototype.newItem = function (name, todo, weight) { + return this.addUnit(new Tracker(name, todo), weight) +} + +TrackerGroup.prototype.newStream = function (name, todo, weight) { + return this.addUnit(new TrackerStream(name, todo), weight) +} + +TrackerGroup.prototype.finish = function () { + if (! this.trackGroup.length) { this.addUnit(new Tracker(), 1, true) } + var self = this + this.trackGroup.forEach(function(T) { + T.removeListener("change", self.noteChange) + T.finish() + }) + this.emit("change", this.name) +} + +var buffer = " " +TrackerGroup.prototype.debug = function (depth) { + depth = depth || 0 + var indent = depth ? buffer.substr(0,depth) : "" + var output = indent + (this.name||"top") + ": " + this.completed() + "\n" + this.trackGroup.forEach(function(T) { + if (T instanceof TrackerGroup) { + output += T.debug(depth + 1) + } + else { + output += indent + " " + T.name + ": " + T.completed() + "\n" + } + }) + return output +} + +var Tracker = exports.Tracker = function (name,todo) { + EventEmitter.call(this) + this.name = name + this.workDone = 0 + this.workTodo = todo || 0 +} +util.inherits(Tracker, EventEmitter) + +Tracker.prototype.completed = function () { + return this.workTodo==0 ? 0 : this.workDone / this.workTodo +} + +Tracker.prototype.addWork = function (work) { + this.workTodo += work + this.emit("change", this.name) +} + +Tracker.prototype.completeWork = function (work) { + this.workDone += work + if (this.workDone > this.workTodo) this.workDone = this.workTodo + this.emit("change", this.name) +} + +Tracker.prototype.finish = function () { + this.workTodo = this.workDone = 1 + this.emit("change", this.name) +} + + +var TrackerStream = exports.TrackerStream = function (name, size, options) { + stream.Transform.call(this, options) + this.tracker = new Tracker(name, size) + this.name = name + var self = this + this.tracker.on("change", function (name) { self.emit("change", name) }) +} +util.inherits(TrackerStream, stream.Transform) + +TrackerStream.prototype._transform = function (data, encoding, cb) { + this.tracker.completeWork(data.length ? data.length : 1) + this.push(data) + cb() +} + +TrackerStream.prototype._flush = function (cb) { + this.tracker.finish() + cb() +} + +delegate(TrackerStream.prototype, "tracker") + .method("completed") + .method("addWork") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore @@ -0,0 +1 @@ +node_modules/ diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md new file mode 100644 index 0000000..aee31a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md @@ -0,0 +1,16 @@ + +0.1.0 / 2014-10-17 +================== + + * adds `.fluent()` to api + +0.0.3 / 2014-01-13 +================== + + * fix receiver for .method() + +0.0.2 / 2014-01-13 +================== + + * Object.defineProperty() sucks + * Initial commit diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile new file mode 100644 index 0000000..a9dcfd5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile @@ -0,0 +1,8 @@ + +test: + @./node_modules/.bin/mocha \ + --require should \ + --reporter spec \ + --bail + +.PHONY: test \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md new file mode 100644 index 0000000..ab8cf4a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md @@ -0,0 +1,94 @@ + +# delegates + + Node method and accessor delegation utilty. + +## Installation + +``` +$ npm install delegates +``` + +## Example + +```js +var delegate = require('delegates'); + +... + +delegate(proto, 'request') + .method('acceptsLanguages') + .method('acceptsEncodings') + .method('acceptsCharsets') + .method('accepts') + .method('is') + .access('querystring') + .access('idempotent') + .access('socket') + .access('length') + .access('query') + .access('search') + .access('status') + .access('method') + .access('path') + .access('body') + .access('host') + .access('url') + .getter('subdomains') + .getter('protocol') + .getter('header') + .getter('stale') + .getter('fresh') + .getter('secure') + .getter('ips') + .getter('ip') +``` + +# API + +## Delegate(proto, prop) + +Creates a delegator instance used to configure using the `prop` on the given +`proto` object. (which is usually a prototype) + +## Delegate#method(name) + +Allows the given method `name` to be accessed on the host. + +## Delegate#getter(name) + +Creates a "getter" for the property with the given `name` on the delegated +object. + +## Delegate#setter(name) + +Creates a "setter" for the property with the given `name` on the delegated +object. + +## Delegate#access(name) + +Creates an "accessor" (ie: both getter *and* setter) for the property with the +given `name` on the delegated object. + +## Delegate#fluent(name) + +A unique type of "accessor" that works for a "fluent" API. When called as a +getter, the method returns the expected value. However, if the method is called +with a value, it will return itself so it can be chained. For example: + +```js +delegate(proto, 'request') + .fluent('query') + +// getter +var q = request.query(); + +// setter (chainable) +request + .query({ a: 1 }) + .query({ b: 2 }); +``` + +# License + + MIT diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js new file mode 100644 index 0000000..17c222d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js @@ -0,0 +1,121 @@ + +/** + * Expose `Delegator`. + */ + +module.exports = Delegator; + +/** + * Initialize a delegator. + * + * @param {Object} proto + * @param {String} target + * @api public + */ + +function Delegator(proto, target) { + if (!(this instanceof Delegator)) return new Delegator(proto, target); + this.proto = proto; + this.target = target; + this.methods = []; + this.getters = []; + this.setters = []; + this.fluents = []; +} + +/** + * Delegate method `name`. + * + * @param {String} name + * @return {Delegator} self + * @api public + */ + +Delegator.prototype.method = function(name){ + var proto = this.proto; + var target = this.target; + this.methods.push(name); + + proto[name] = function(){ + return this[target][name].apply(this[target], arguments); + }; + + return this; +}; + +/** + * Delegator accessor `name`. + * + * @param {String} name + * @return {Delegator} self + * @api public + */ + +Delegator.prototype.access = function(name){ + return this.getter(name).setter(name); +}; + +/** + * Delegator getter `name`. + * + * @param {String} name + * @return {Delegator} self + * @api public + */ + +Delegator.prototype.getter = function(name){ + var proto = this.proto; + var target = this.target; + this.getters.push(name); + + proto.__defineGetter__(name, function(){ + return this[target][name]; + }); + + return this; +}; + +/** + * Delegator setter `name`. + * + * @param {String} name + * @return {Delegator} self + * @api public + */ + +Delegator.prototype.setter = function(name){ + var proto = this.proto; + var target = this.target; + this.setters.push(name); + + proto.__defineSetter__(name, function(val){ + return this[target][name] = val; + }); + + return this; +}; + +/** + * Delegator fluent accessor + * + * @param {String} name + * @return {Delegator} self + * @api public + */ + +Delegator.prototype.fluent = function (name) { + var proto = this.proto; + var target = this.target; + this.fluents.push(name); + + proto[name] = function(val){ + if ('undefined' != typeof val) { + this[target][name] = val; + return this; + } else { + return this[target][name]; + } + }; + + return this; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json new file mode 100644 index 0000000..e22f637 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json @@ -0,0 +1,47 @@ +{ + "name": "delegates", + "version": "0.1.0", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/node-delegates" + }, + "description": "delegate methods and accessors to another property", + "keywords": [ + "delegate", + "delegation" + ], + "dependencies": {}, + "devDependencies": { + "mocha": "*", + "should": "*" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/visionmedia/node-delegates/issues" + }, + "homepage": "https://github.com/visionmedia/node-delegates", + "_id": "delegates@0.1.0", + "_shasum": "b4b57be11a1653517a04b27f0949bdc327dfe390", + "_from": "delegates@>=0.1.0 <0.2.0", + "_npmVersion": "1.4.9", + "_npmUser": { + "name": "dominicbarnes", + "email": "dominic@dbarnes.info" + }, + "maintainers": [ + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + }, + { + "name": "dominicbarnes", + "email": "dominic@dbarnes.info" + } + ], + "dist": { + "shasum": "b4b57be11a1653517a04b27f0949bdc327dfe390", + "tarball": "http://registry.npmjs.org/delegates/-/delegates-0.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/delegates/-/delegates-0.1.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js new file mode 100644 index 0000000..7b6e3d4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js @@ -0,0 +1,94 @@ + +var assert = require('assert'); +var delegate = require('..'); + +describe('.method(name)', function(){ + it('should delegate methods', function(){ + var obj = {}; + + obj.request = { + foo: function(bar){ + assert(this == obj.request); + return bar; + } + }; + + delegate(obj, 'request').method('foo'); + + obj.foo('something').should.equal('something'); + }) +}) + +describe('.getter(name)', function(){ + it('should delegate getters', function(){ + var obj = {}; + + obj.request = { + get type() { + return 'text/html'; + } + } + + delegate(obj, 'request').getter('type'); + + obj.type.should.equal('text/html'); + }) +}) + +describe('.setter(name)', function(){ + it('should delegate setters', function(){ + var obj = {}; + + obj.request = { + get type() { + return this._type.toUpperCase(); + }, + + set type(val) { + this._type = val; + } + } + + delegate(obj, 'request').setter('type'); + + obj.type = 'hey'; + obj.request.type.should.equal('HEY'); + }) +}) + +describe('.access(name)', function(){ + it('should delegate getters and setters', function(){ + var obj = {}; + + obj.request = { + get type() { + return this._type.toUpperCase(); + }, + + set type(val) { + this._type = val; + } + } + + delegate(obj, 'request').access('type'); + + obj.type = 'hey'; + obj.type.should.equal('HEY'); + }) +}) + +describe('.fluent(name)', function () { + it('should delegate in a fluent fashion', function () { + var obj = { + settings: { + env: 'development' + } + }; + + delegate(obj, 'settings').fluent('env'); + + obj.env().should.equal('development'); + obj.env('production').should.equal(obj); + obj.settings.env.should.equal('production'); + }) +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/.npmignore new file mode 100644 index 0000000..38344f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/.npmignore @@ -0,0 +1,5 @@ +build/ +test/ +examples/ +fs.js +zlib.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/LICENSE new file mode 100644 index 0000000..e3d4e69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/README.md new file mode 100644 index 0000000..e46b823 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/README.md @@ -0,0 +1,15 @@ +# readable-stream + +***Node-core streams for userland*** + +[](https://nodei.co/npm/readable-stream/) +[](https://nodei.co/npm/readable-stream/) + +This package is a mirror of the Streams2 and Streams3 implementations in Node-core. + +If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core. + +**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12. + +**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"` + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/duplex.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/duplex.js new file mode 100644 index 0000000..ca807af --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/float.patch b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/float.patch new file mode 100644 index 0000000..b984607 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/float.patch @@ -0,0 +1,923 @@ +diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js +index c5a741c..a2e0d8e 100644 +--- a/lib/_stream_duplex.js ++++ b/lib/_stream_duplex.js +@@ -26,8 +26,8 @@ + + module.exports = Duplex; + var util = require('util'); +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('./_stream_readable'); ++var Writable = require('./_stream_writable'); + + util.inherits(Duplex, Readable); + +diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js +index a5e9864..330c247 100644 +--- a/lib/_stream_passthrough.js ++++ b/lib/_stream_passthrough.js +@@ -25,7 +25,7 @@ + + module.exports = PassThrough; + +-var Transform = require('_stream_transform'); ++var Transform = require('./_stream_transform'); + var util = require('util'); + util.inherits(PassThrough, Transform); + +diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js +index 0c3fe3e..90a8298 100644 +--- a/lib/_stream_readable.js ++++ b/lib/_stream_readable.js +@@ -23,10 +23,34 @@ module.exports = Readable; + Readable.ReadableState = ReadableState; + + var EE = require('events').EventEmitter; ++if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { ++ return emitter.listeners(type).length; ++}; ++ ++if (!global.setImmediate) global.setImmediate = function setImmediate(fn) { ++ return setTimeout(fn, 0); ++}; ++if (!global.clearImmediate) global.clearImmediate = function clearImmediate(i) { ++ return clearTimeout(i); ++}; ++ + var Stream = require('stream'); + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + var StringDecoder; +-var debug = util.debuglog('stream'); ++var debug; ++if (util.debuglog) ++ debug = util.debuglog('stream'); ++else try { ++ debug = require('debuglog')('stream'); ++} catch (er) { ++ debug = function() {}; ++} + + util.inherits(Readable, Stream); + +@@ -380,7 +404,7 @@ function chunkInvalid(state, chunk) { + + + function onEofChunk(stream, state) { +- if (state.decoder && !state.ended) { ++ if (state.decoder && !state.ended && state.decoder.end) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); +diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js +index b1f9fcc..b0caf57 100644 +--- a/lib/_stream_transform.js ++++ b/lib/_stream_transform.js +@@ -64,8 +64,14 @@ + + module.exports = Transform; + +-var Duplex = require('_stream_duplex'); ++var Duplex = require('./_stream_duplex'); + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + util.inherits(Transform, Duplex); + + +diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js +index ba2e920..f49288b 100644 +--- a/lib/_stream_writable.js ++++ b/lib/_stream_writable.js +@@ -27,6 +27,12 @@ module.exports = Writable; + Writable.WritableState = WritableState; + + var util = require('util'); ++if (!util.isUndefined) { ++ var utilIs = require('core-util-is'); ++ for (var f in utilIs) { ++ util[f] = utilIs[f]; ++ } ++} + var Stream = require('stream'); + + util.inherits(Writable, Stream); +@@ -119,7 +125,7 @@ function WritableState(options, stream) { + function Writable(options) { + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. +- if (!(this instanceof Writable) && !(this instanceof Stream.Duplex)) ++ if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex'))) + return new Writable(options); + + this._writableState = new WritableState(options, this); +diff --git a/test/simple/test-stream-big-push.js b/test/simple/test-stream-big-push.js +index e3787e4..8cd2127 100644 +--- a/test/simple/test-stream-big-push.js ++++ b/test/simple/test-stream-big-push.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + var str = 'asdfasdfasdfasdfasdf'; + + var r = new stream.Readable({ +diff --git a/test/simple/test-stream-end-paused.js b/test/simple/test-stream-end-paused.js +index bb73777..d40efc7 100644 +--- a/test/simple/test-stream-end-paused.js ++++ b/test/simple/test-stream-end-paused.js +@@ -25,7 +25,7 @@ var gotEnd = false; + + // Make sure we don't miss the end event for paused 0-length streams + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var stream = new Readable(); + var calledRead = false; + stream._read = function() { +diff --git a/test/simple/test-stream-pipe-after-end.js b/test/simple/test-stream-pipe-after-end.js +index b46ee90..0be8366 100644 +--- a/test/simple/test-stream-pipe-after-end.js ++++ b/test/simple/test-stream-pipe-after-end.js +@@ -22,8 +22,8 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var util = require('util'); + + util.inherits(TestReadable, Readable); +diff --git a/test/simple/test-stream-pipe-cleanup.js b/test/simple/test-stream-pipe-cleanup.js +deleted file mode 100644 +index f689358..0000000 +--- a/test/simple/test-stream-pipe-cleanup.js ++++ /dev/null +@@ -1,122 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +-// This test asserts that Stream.prototype.pipe does not leave listeners +-// hanging on the source or dest. +- +-var common = require('../common'); +-var stream = require('stream'); +-var assert = require('assert'); +-var util = require('util'); +- +-function Writable() { +- this.writable = true; +- this.endCalls = 0; +- stream.Stream.call(this); +-} +-util.inherits(Writable, stream.Stream); +-Writable.prototype.end = function() { +- this.endCalls++; +-}; +- +-Writable.prototype.destroy = function() { +- this.endCalls++; +-}; +- +-function Readable() { +- this.readable = true; +- stream.Stream.call(this); +-} +-util.inherits(Readable, stream.Stream); +- +-function Duplex() { +- this.readable = true; +- Writable.call(this); +-} +-util.inherits(Duplex, Writable); +- +-var i = 0; +-var limit = 100; +- +-var w = new Writable(); +- +-var r; +- +-for (i = 0; i < limit; i++) { +- r = new Readable(); +- r.pipe(w); +- r.emit('end'); +-} +-assert.equal(0, r.listeners('end').length); +-assert.equal(limit, w.endCalls); +- +-w.endCalls = 0; +- +-for (i = 0; i < limit; i++) { +- r = new Readable(); +- r.pipe(w); +- r.emit('close'); +-} +-assert.equal(0, r.listeners('close').length); +-assert.equal(limit, w.endCalls); +- +-w.endCalls = 0; +- +-r = new Readable(); +- +-for (i = 0; i < limit; i++) { +- w = new Writable(); +- r.pipe(w); +- w.emit('close'); +-} +-assert.equal(0, w.listeners('close').length); +- +-r = new Readable(); +-w = new Writable(); +-var d = new Duplex(); +-r.pipe(d); // pipeline A +-d.pipe(w); // pipeline B +-assert.equal(r.listeners('end').length, 2); // A.onend, A.cleanup +-assert.equal(r.listeners('close').length, 2); // A.onclose, A.cleanup +-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup +-assert.equal(d.listeners('close').length, 3); // A.cleanup, B.onclose, B.cleanup +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 1); // B.cleanup +- +-r.emit('end'); +-assert.equal(d.endCalls, 1); +-assert.equal(w.endCalls, 0); +-assert.equal(r.listeners('end').length, 0); +-assert.equal(r.listeners('close').length, 0); +-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup +-assert.equal(d.listeners('close').length, 2); // B.onclose, B.cleanup +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 1); // B.cleanup +- +-d.emit('end'); +-assert.equal(d.endCalls, 1); +-assert.equal(w.endCalls, 1); +-assert.equal(r.listeners('end').length, 0); +-assert.equal(r.listeners('close').length, 0); +-assert.equal(d.listeners('end').length, 0); +-assert.equal(d.listeners('close').length, 0); +-assert.equal(w.listeners('end').length, 0); +-assert.equal(w.listeners('close').length, 0); +diff --git a/test/simple/test-stream-pipe-error-handling.js b/test/simple/test-stream-pipe-error-handling.js +index c5d724b..c7d6b7d 100644 +--- a/test/simple/test-stream-pipe-error-handling.js ++++ b/test/simple/test-stream-pipe-error-handling.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var Stream = require('stream').Stream; ++var Stream = require('../../').Stream; + + (function testErrorListenerCatches() { + var source = new Stream(); +diff --git a/test/simple/test-stream-pipe-event.js b/test/simple/test-stream-pipe-event.js +index cb9d5fe..56f8d61 100644 +--- a/test/simple/test-stream-pipe-event.js ++++ b/test/simple/test-stream-pipe-event.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common'); +-var stream = require('stream'); ++var stream = require('../../'); + var assert = require('assert'); + var util = require('util'); + +diff --git a/test/simple/test-stream-push-order.js b/test/simple/test-stream-push-order.js +index f2e6ec2..a5c9bf9 100644 +--- a/test/simple/test-stream-push-order.js ++++ b/test/simple/test-stream-push-order.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var assert = require('assert'); + + var s = new Readable({ +diff --git a/test/simple/test-stream-push-strings.js b/test/simple/test-stream-push-strings.js +index 06f43dc..1701a9a 100644 +--- a/test/simple/test-stream-push-strings.js ++++ b/test/simple/test-stream-push-strings.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var util = require('util'); + + util.inherits(MyStream, Readable); +diff --git a/test/simple/test-stream-readable-event.js b/test/simple/test-stream-readable-event.js +index ba6a577..a8e6f7b 100644 +--- a/test/simple/test-stream-readable-event.js ++++ b/test/simple/test-stream-readable-event.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + (function first() { + // First test, not reading when the readable is added. +diff --git a/test/simple/test-stream-readable-flow-recursion.js b/test/simple/test-stream-readable-flow-recursion.js +index 2891ad6..11689ba 100644 +--- a/test/simple/test-stream-readable-flow-recursion.js ++++ b/test/simple/test-stream-readable-flow-recursion.js +@@ -27,7 +27,7 @@ var assert = require('assert'); + // more data continuously, but without triggering a nextTick + // warning or RangeError. + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + // throw an error if we trigger a nextTick warning. + process.throwDeprecation = true; +diff --git a/test/simple/test-stream-unshift-empty-chunk.js b/test/simple/test-stream-unshift-empty-chunk.js +index 0c96476..7827538 100644 +--- a/test/simple/test-stream-unshift-empty-chunk.js ++++ b/test/simple/test-stream-unshift-empty-chunk.js +@@ -24,7 +24,7 @@ var assert = require('assert'); + + // This test verifies that stream.unshift(Buffer(0)) or + // stream.unshift('') does not set state.reading=false. +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + var r = new Readable(); + var nChunks = 10; +diff --git a/test/simple/test-stream-unshift-read-race.js b/test/simple/test-stream-unshift-read-race.js +index 83fd9fa..17c18aa 100644 +--- a/test/simple/test-stream-unshift-read-race.js ++++ b/test/simple/test-stream-unshift-read-race.js +@@ -29,7 +29,7 @@ var assert = require('assert'); + // 3. push() after the EOF signaling null is an error. + // 4. _read() is not called after pushing the EOF null chunk. + +-var stream = require('stream'); ++var stream = require('../../'); + var hwm = 10; + var r = stream.Readable({ highWaterMark: hwm }); + var chunks = 10; +@@ -51,7 +51,14 @@ r._read = function(n) { + + function push(fast) { + assert(!pushedNull, 'push() after null push'); +- var c = pos >= data.length ? null : data.slice(pos, pos + n); ++ var c; ++ if (pos >= data.length) ++ c = null; ++ else { ++ if (n + pos > data.length) ++ n = data.length - pos; ++ c = data.slice(pos, pos + n); ++ } + pushedNull = c === null; + if (fast) { + pos += n; +diff --git a/test/simple/test-stream-writev.js b/test/simple/test-stream-writev.js +index 5b49e6e..b5321f3 100644 +--- a/test/simple/test-stream-writev.js ++++ b/test/simple/test-stream-writev.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var stream = require('stream'); ++var stream = require('../../'); + + var queue = []; + for (var decode = 0; decode < 2; decode++) { +diff --git a/test/simple/test-stream2-basic.js b/test/simple/test-stream2-basic.js +index 3814bf0..248c1be 100644 +--- a/test/simple/test-stream2-basic.js ++++ b/test/simple/test-stream2-basic.js +@@ -21,7 +21,7 @@ + + + var common = require('../common.js'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-compatibility.js b/test/simple/test-stream2-compatibility.js +index 6cdd4e9..f0fa84b 100644 +--- a/test/simple/test-stream2-compatibility.js ++++ b/test/simple/test-stream2-compatibility.js +@@ -21,7 +21,7 @@ + + + var common = require('../common.js'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-finish-pipe.js b/test/simple/test-stream2-finish-pipe.js +index 39b274f..006a19b 100644 +--- a/test/simple/test-stream2-finish-pipe.js ++++ b/test/simple/test-stream2-finish-pipe.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var stream = require('stream'); ++var stream = require('../../'); + var Buffer = require('buffer').Buffer; + + var r = new stream.Readable(); +diff --git a/test/simple/test-stream2-fs.js b/test/simple/test-stream2-fs.js +deleted file mode 100644 +index e162406..0000000 +--- a/test/simple/test-stream2-fs.js ++++ /dev/null +@@ -1,72 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +- +-var common = require('../common.js'); +-var R = require('_stream_readable'); +-var assert = require('assert'); +- +-var fs = require('fs'); +-var FSReadable = fs.ReadStream; +- +-var path = require('path'); +-var file = path.resolve(common.fixturesDir, 'x1024.txt'); +- +-var size = fs.statSync(file).size; +- +-var expectLengths = [1024]; +- +-var util = require('util'); +-var Stream = require('stream'); +- +-util.inherits(TestWriter, Stream); +- +-function TestWriter() { +- Stream.apply(this); +- this.buffer = []; +- this.length = 0; +-} +- +-TestWriter.prototype.write = function(c) { +- this.buffer.push(c.toString()); +- this.length += c.length; +- return true; +-}; +- +-TestWriter.prototype.end = function(c) { +- if (c) this.buffer.push(c.toString()); +- this.emit('results', this.buffer); +-} +- +-var r = new FSReadable(file); +-var w = new TestWriter(); +- +-w.on('results', function(res) { +- console.error(res, w.length); +- assert.equal(w.length, size); +- var l = 0; +- assert.deepEqual(res.map(function (c) { +- return c.length; +- }), expectLengths); +- console.log('ok'); +-}); +- +-r.pipe(w); +diff --git a/test/simple/test-stream2-httpclient-response-end.js b/test/simple/test-stream2-httpclient-response-end.js +deleted file mode 100644 +index 15cffc2..0000000 +--- a/test/simple/test-stream2-httpclient-response-end.js ++++ /dev/null +@@ -1,52 +0,0 @@ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// 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. +- +-var common = require('../common.js'); +-var assert = require('assert'); +-var http = require('http'); +-var msg = 'Hello'; +-var readable_event = false; +-var end_event = false; +-var server = http.createServer(function(req, res) { +- res.writeHead(200, {'Content-Type': 'text/plain'}); +- res.end(msg); +-}).listen(common.PORT, function() { +- http.get({port: common.PORT}, function(res) { +- var data = ''; +- res.on('readable', function() { +- console.log('readable event'); +- readable_event = true; +- data += res.read(); +- }); +- res.on('end', function() { +- console.log('end event'); +- end_event = true; +- assert.strictEqual(msg, data); +- server.close(); +- }); +- }); +-}); +- +-process.on('exit', function() { +- assert(readable_event); +- assert(end_event); +-}); +- +diff --git a/test/simple/test-stream2-large-read-stall.js b/test/simple/test-stream2-large-read-stall.js +index 2fbfbca..667985b 100644 +--- a/test/simple/test-stream2-large-read-stall.js ++++ b/test/simple/test-stream2-large-read-stall.js +@@ -30,7 +30,7 @@ var PUSHSIZE = 20; + var PUSHCOUNT = 1000; + var HWM = 50; + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var r = new Readable({ + highWaterMark: HWM + }); +@@ -39,23 +39,23 @@ var rs = r._readableState; + r._read = push; + + r.on('readable', function() { +- console.error('>> readable'); ++ //console.error('>> readable'); + do { +- console.error(' > read(%d)', READSIZE); ++ //console.error(' > read(%d)', READSIZE); + var ret = r.read(READSIZE); +- console.error(' < %j (%d remain)', ret && ret.length, rs.length); ++ //console.error(' < %j (%d remain)', ret && ret.length, rs.length); + } while (ret && ret.length === READSIZE); + +- console.error('<< after read()', +- ret && ret.length, +- rs.needReadable, +- rs.length); ++ //console.error('<< after read()', ++ // ret && ret.length, ++ // rs.needReadable, ++ // rs.length); + }); + + var endEmitted = false; + r.on('end', function() { + endEmitted = true; +- console.error('end'); ++ //console.error('end'); + }); + + var pushes = 0; +@@ -64,11 +64,11 @@ function push() { + return; + + if (pushes++ === PUSHCOUNT) { +- console.error(' push(EOF)'); ++ //console.error(' push(EOF)'); + return r.push(null); + } + +- console.error(' push #%d', pushes); ++ //console.error(' push #%d', pushes); + if (r.push(new Buffer(PUSHSIZE))) + setTimeout(push); + } +diff --git a/test/simple/test-stream2-objects.js b/test/simple/test-stream2-objects.js +index 3e6931d..ff47d89 100644 +--- a/test/simple/test-stream2-objects.js ++++ b/test/simple/test-stream2-objects.js +@@ -21,8 +21,8 @@ + + + var common = require('../common.js'); +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var assert = require('assert'); + + // tiny node-tap lookalike. +diff --git a/test/simple/test-stream2-pipe-error-handling.js b/test/simple/test-stream2-pipe-error-handling.js +index cf7531c..e3f3e4e 100644 +--- a/test/simple/test-stream2-pipe-error-handling.js ++++ b/test/simple/test-stream2-pipe-error-handling.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + + (function testErrorListenerCatches() { + var count = 1000; +diff --git a/test/simple/test-stream2-pipe-error-once-listener.js b/test/simple/test-stream2-pipe-error-once-listener.js +index 5e8e3cb..53b2616 100755 +--- a/test/simple/test-stream2-pipe-error-once-listener.js ++++ b/test/simple/test-stream2-pipe-error-once-listener.js +@@ -24,7 +24,7 @@ var common = require('../common.js'); + var assert = require('assert'); + + var util = require('util'); +-var stream = require('stream'); ++var stream = require('../../'); + + + var Read = function() { +diff --git a/test/simple/test-stream2-push.js b/test/simple/test-stream2-push.js +index b63edc3..eb2b0e9 100644 +--- a/test/simple/test-stream2-push.js ++++ b/test/simple/test-stream2-push.js +@@ -20,7 +20,7 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var stream = require('stream'); ++var stream = require('../../'); + var Readable = stream.Readable; + var Writable = stream.Writable; + var assert = require('assert'); +diff --git a/test/simple/test-stream2-read-sync-stack.js b/test/simple/test-stream2-read-sync-stack.js +index e8a7305..9740a47 100644 +--- a/test/simple/test-stream2-read-sync-stack.js ++++ b/test/simple/test-stream2-read-sync-stack.js +@@ -21,7 +21,7 @@ + + var common = require('../common'); + var assert = require('assert'); +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + var r = new Readable(); + var N = 256 * 1024; + +diff --git a/test/simple/test-stream2-readable-empty-buffer-no-eof.js b/test/simple/test-stream2-readable-empty-buffer-no-eof.js +index cd30178..4b1659d 100644 +--- a/test/simple/test-stream2-readable-empty-buffer-no-eof.js ++++ b/test/simple/test-stream2-readable-empty-buffer-no-eof.js +@@ -22,10 +22,9 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('stream').Readable; ++var Readable = require('../../').Readable; + + test1(); +-test2(); + + function test1() { + var r = new Readable(); +@@ -88,31 +87,3 @@ function test1() { + console.log('ok'); + }); + } +- +-function test2() { +- var r = new Readable({ encoding: 'base64' }); +- var reads = 5; +- r._read = function(n) { +- if (!reads--) +- return r.push(null); // EOF +- else +- return r.push(new Buffer('x')); +- }; +- +- var results = []; +- function flow() { +- var chunk; +- while (null !== (chunk = r.read())) +- results.push(chunk + ''); +- } +- r.on('readable', flow); +- r.on('end', function() { +- results.push('EOF'); +- }); +- flow(); +- +- process.on('exit', function() { +- assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]); +- console.log('ok'); +- }); +-} +diff --git a/test/simple/test-stream2-readable-from-list.js b/test/simple/test-stream2-readable-from-list.js +index 7c96ffe..04a96f5 100644 +--- a/test/simple/test-stream2-readable-from-list.js ++++ b/test/simple/test-stream2-readable-from-list.js +@@ -21,7 +21,7 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var fromList = require('_stream_readable')._fromList; ++var fromList = require('../../lib/_stream_readable')._fromList; + + // tiny node-tap lookalike. + var tests = []; +diff --git a/test/simple/test-stream2-readable-legacy-drain.js b/test/simple/test-stream2-readable-legacy-drain.js +index 675da8e..51fd3d5 100644 +--- a/test/simple/test-stream2-readable-legacy-drain.js ++++ b/test/simple/test-stream2-readable-legacy-drain.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Stream = require('stream'); ++var Stream = require('../../'); + var Readable = Stream.Readable; + + var r = new Readable(); +diff --git a/test/simple/test-stream2-readable-non-empty-end.js b/test/simple/test-stream2-readable-non-empty-end.js +index 7314ae7..c971898 100644 +--- a/test/simple/test-stream2-readable-non-empty-end.js ++++ b/test/simple/test-stream2-readable-non-empty-end.js +@@ -21,7 +21,7 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var Readable = require('_stream_readable'); ++var Readable = require('../../lib/_stream_readable'); + + var len = 0; + var chunks = new Array(10); +diff --git a/test/simple/test-stream2-readable-wrap-empty.js b/test/simple/test-stream2-readable-wrap-empty.js +index 2e5cf25..fd8a3dc 100644 +--- a/test/simple/test-stream2-readable-wrap-empty.js ++++ b/test/simple/test-stream2-readable-wrap-empty.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); ++var Readable = require('../../lib/_stream_readable'); + var EE = require('events').EventEmitter; + + var oldStream = new EE(); +diff --git a/test/simple/test-stream2-readable-wrap.js b/test/simple/test-stream2-readable-wrap.js +index 90eea01..6b177f7 100644 +--- a/test/simple/test-stream2-readable-wrap.js ++++ b/test/simple/test-stream2-readable-wrap.js +@@ -22,8 +22,8 @@ + var common = require('../common'); + var assert = require('assert'); + +-var Readable = require('_stream_readable'); +-var Writable = require('_stream_writable'); ++var Readable = require('../../lib/_stream_readable'); ++var Writable = require('../../lib/_stream_writable'); + var EE = require('events').EventEmitter; + + var testRuns = 0, completedRuns = 0; +diff --git a/test/simple/test-stream2-set-encoding.js b/test/simple/test-stream2-set-encoding.js +index 5d2c32a..685531b 100644 +--- a/test/simple/test-stream2-set-encoding.js ++++ b/test/simple/test-stream2-set-encoding.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var R = require('_stream_readable'); ++var R = require('../../lib/_stream_readable'); + var util = require('util'); + + // tiny node-tap lookalike. +diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js +index 9c9ddd8..a0cacc6 100644 +--- a/test/simple/test-stream2-transform.js ++++ b/test/simple/test-stream2-transform.js +@@ -21,8 +21,8 @@ + + var assert = require('assert'); + var common = require('../common.js'); +-var PassThrough = require('_stream_passthrough'); +-var Transform = require('_stream_transform'); ++var PassThrough = require('../../').PassThrough; ++var Transform = require('../../').Transform; + + // tiny node-tap lookalike. + var tests = []; +diff --git a/test/simple/test-stream2-unpipe-drain.js b/test/simple/test-stream2-unpipe-drain.js +index d66dc3c..365b327 100644 +--- a/test/simple/test-stream2-unpipe-drain.js ++++ b/test/simple/test-stream2-unpipe-drain.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + var crypto = require('crypto'); + + var util = require('util'); +diff --git a/test/simple/test-stream2-unpipe-leak.js b/test/simple/test-stream2-unpipe-leak.js +index 99f8746..17c92ae 100644 +--- a/test/simple/test-stream2-unpipe-leak.js ++++ b/test/simple/test-stream2-unpipe-leak.js +@@ -22,7 +22,7 @@ + + var common = require('../common.js'); + var assert = require('assert'); +-var stream = require('stream'); ++var stream = require('../../'); + + var chunk = new Buffer('hallo'); + +diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js +index 704100c..209c3a6 100644 +--- a/test/simple/test-stream2-writable.js ++++ b/test/simple/test-stream2-writable.js +@@ -20,8 +20,8 @@ + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var common = require('../common.js'); +-var W = require('_stream_writable'); +-var D = require('_stream_duplex'); ++var W = require('../../').Writable; ++var D = require('../../').Duplex; + var assert = require('assert'); + + var util = require('util'); +diff --git a/test/simple/test-stream3-pause-then-read.js b/test/simple/test-stream3-pause-then-read.js +index b91bde3..2f72c15 100644 +--- a/test/simple/test-stream3-pause-then-read.js ++++ b/test/simple/test-stream3-pause-then-read.js +@@ -22,7 +22,7 @@ + var common = require('../common'); + var assert = require('assert'); + +-var stream = require('stream'); ++var stream = require('../../'); + var Readable = stream.Readable; + var Writable = stream.Writable; + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_duplex.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 0000000..b513d61 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,89 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +module.exports = Duplex; + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; +} +/**/ + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +forEach(objectKeys(Writable.prototype), function(method) { + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; +}); + +function Duplex(options) { + if (!(this instanceof Duplex)) + return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) + this.readable = false; + + if (options && options.writable === false) + this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) + this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) + return; + + // no more data can be written. + // But allow more writes to happen in this tick. + process.nextTick(this.end.bind(this)); +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_passthrough.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_passthrough.js new file mode 100644 index 0000000..895ca50 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_passthrough.js @@ -0,0 +1,46 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) + return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 0000000..19ab358 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,951 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = require('events').EventEmitter; + +/**/ +if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +var Stream = require('stream'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var StringDecoder; + + +/**/ +var debug = require('util'); +if (debug && debug.debuglog) { + debug = debug.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + + +util.inherits(Readable, Stream); + +function ReadableState(options, stream) { + var Duplex = require('./_stream_duplex'); + + options = options || {}; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.readableObjectMode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + var Duplex = require('./_stream_duplex'); + + if (!(this instanceof Readable)) + return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function(chunk, encoding) { + var state = this._readableState; + + if (util.isString(chunk) && !state.objectMode) { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function(chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (util.isNullOrUndefined(chunk)) { + state.reading = false; + if (!state.ended) + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + if (state.decoder && !addToFront && !encoding) + chunk = state.decoder.write(chunk); + + if (!addToFront) + state.reading = false; + + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + + if (state.needReadable) + emitReadable(stream); + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + + + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && + (state.needReadable || + state.length < state.highWaterMark || + state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 128MB +var MAX_HWM = 0x800000; +function roundUpToNextPowerOf2(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + for (var p = 1; p < 32; p <<= 1) n |= n >> p; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) + return 0; + + if (state.objectMode) + return n === 0 ? 0 : 1; + + if (isNaN(n) || util.isNull(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } + + if (n <= 0) + return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) + state.highWaterMark = roundUpToNextPowerOf2(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else + return state.length; + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function(n) { + debug('read', n); + var state = this._readableState; + var nOrig = n; + + if (!util.isNumber(n) || n > 0) + state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && + state.needReadable && + (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } + + if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) + state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (doRead && !state.reading) + n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) + ret = fromList(n, state); + else + ret = null; + + if (util.isNull(ret)) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) + state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) + endReadable(this); + + if (!util.isNull(ret)) + this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && + !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + + +function onEofChunk(stream, state) { + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) + process.nextTick(function() { + emitReadable_(stream); + }); + else + emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(function() { + maybeReadMore_(stream, state); + }); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && + state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + else + len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function(n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function(dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && + dest !== process.stdout && + dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) + process.nextTick(endFn); + else + src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && + (!dest._writableState || dest._writableState.needDrain)) + ondrain(); + } + + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + debug('false write response, pause', + src._readableState.awaitDrain); + src._readableState.awaitDrain++; + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EE.listenerCount(dest, 'error') === 0) + dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) + dest.on('error', onerror); + else if (isArray(dest._events.error)) + dest._events.error.unshift(onerror); + else + dest._events.error = [onerror, dest._events.error]; + + + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + + +Readable.prototype.unpipe = function(dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) + return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) + return this; + + if (!dest) + dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) + dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) + dests[i].emit('unpipe', this); + return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) + return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function(ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && this.readable) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + var self = this; + process.nextTick(function() { + debug('readable nexttick read 0'); + self.read(0); + }); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function() { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + if (!state.reading) { + debug('resume read 0'); + this.read(0); + } + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(function() { + resume_(stream, state); + }); + } +} + +function resume_(stream, state) { + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) + stream.read(0); +} + +Readable.prototype.pause = function() { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function(stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function() { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function(chunk) { + debug('wrapped data'); + if (state.decoder) + chunk = state.decoder.write(chunk); + if (!chunk || !state.objectMode && !chunk.length) + return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { + this[i] = function(method) { return function() { + return stream[method].apply(stream, arguments); + }}(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function(ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function(n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + + + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) + return null; + + if (length === 0) + ret = null; + else if (objectMode) + ret = list.shift(); + else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) + ret = list.join(''); + else + ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) + ret = ''; + else + ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) + ret += buf.slice(0, cpy); + else + buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) + list[0] = buf.slice(cpy); + else + list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) + throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + process.nextTick(function() { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } + }); + } +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf (xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_transform.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 0000000..905c5e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,209 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + + +function TransformState(options, stream) { + this.afterTransform = function(er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) + return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (!util.isNullOrUndefined(data)) + stream.push(data); + + if (cb) + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + + +function Transform(options) { + if (!(this instanceof Transform)) + return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(options, this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + this.once('prefinish', function() { + if (util.isFunction(this._flush)) + this._flush(function(er) { + done(stream, er); + }); + else + done(stream); + }); +} + +Transform.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function(chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || + rs.needReadable || + rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function(n) { + var ts = this._transformState; + + if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + + +function done(stream, er) { + if (er) + return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) + throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) + throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_writable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 0000000..db8539c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,477 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, cb), and it'll handle all +// the drain event emission and buffering. + +module.exports = Writable; + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Writable.WritableState = WritableState; + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Stream = require('stream'); + +util.inherits(Writable, Stream); + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; +} + +function WritableState(options, stream) { + var Duplex = require('./_stream_duplex'); + + options = options || {}; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.writableObjectMode; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function(er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.buffer = []; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; +} + +function Writable(options) { + var Duplex = require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) + return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function() { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + + +function writeAfterEnd(stream, state, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && + !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); + valid = false; + } + return valid; +} + +Writable.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (util.isFunction(encoding)) { + cb = encoding; + encoding = null; + } + + if (util.isBuffer(chunk)) + encoding = 'buffer'; + else if (!encoding) + encoding = state.defaultEncoding; + + if (!util.isFunction(cb)) + cb = function() {}; + + if (state.ended) + writeAfterEnd(this, state, cb); + else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function() { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function() { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && + !state.corked && + !state.finished && + !state.bufferProcessing && + state.buffer.length) + clearBuffer(this, state); + } +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && + state.decodeStrings !== false && + util.isString(chunk)) { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + if (util.isBuffer(chunk)) + encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) + state.needDrain = true; + + if (state.writing || state.corked) + state.buffer.push(new WriteReq(chunk, encoding, cb)); + else + doWrite(stream, state, false, len, chunk, encoding, cb); + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) + stream._writev(chunk, state.onwrite); + else + stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + if (sync) + process.nextTick(function() { + state.pendingcb--; + cb(er); + }); + else { + state.pendingcb--; + cb(er); + } + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) + onwriteError(stream, state, sync, er, cb); + else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(stream, state); + + if (!finished && + !state.corked && + !state.bufferProcessing && + state.buffer.length) { + clearBuffer(stream, state); + } + + if (sync) { + process.nextTick(function() { + afterWrite(stream, state, finished, cb); + }); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) + onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + + if (stream._writev && state.buffer.length > 1) { + // Fast case, write everything using _writev() + var cbs = []; + for (var c = 0; c < state.buffer.length; c++) + cbs.push(state.buffer[c].callback); + + // count the one we are adding, as well. + // TODO(isaacs) clean this up + state.pendingcb++; + doWrite(stream, state, true, state.length, state.buffer, '', function(err) { + for (var i = 0; i < cbs.length; i++) { + state.pendingcb--; + cbs[i](err); + } + }); + + // Clear buffer + state.buffer = []; + } else { + // Slow case, write chunks one-by-one + for (var c = 0; c < state.buffer.length; c++) { + var entry = state.buffer[c]; + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + c++; + break; + } + } + + if (c < state.buffer.length) + state.buffer = state.buffer.slice(c); + else + state.buffer.length = 0; + } + + state.bufferProcessing = false; +} + +Writable.prototype._write = function(chunk, encoding, cb) { + cb(new Error('not implemented')); + +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + + if (util.isFunction(chunk)) { + cb = chunk; + chunk = null; + encoding = null; + } else if (util.isFunction(encoding)) { + cb = encoding; + encoding = null; + } + + if (!util.isNullOrUndefined(chunk)) + this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) + endWritable(this, state, cb); +}; + + +function needFinish(stream, state) { + return (state.ending && + state.length === 0 && + !state.finished && + !state.writing); +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(stream, state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else + prefinish(stream, state); + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) + process.nextTick(cb); + else + stream.once('finish', cb); + } + state.ended = true; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/README.md new file mode 100644 index 0000000..5a76b41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/README.md @@ -0,0 +1,3 @@ +# core-util-is + +The `util.is*` functions introduced in Node v0.12. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/float.patch b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/float.patch new file mode 100644 index 0000000..a06d5c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/float.patch @@ -0,0 +1,604 @@ +diff --git a/lib/util.js b/lib/util.js +index a03e874..9074e8e 100644 +--- a/lib/util.js ++++ b/lib/util.js +@@ -19,430 +19,6 @@ + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + +-var formatRegExp = /%[sdj%]/g; +-exports.format = function(f) { +- if (!isString(f)) { +- var objects = []; +- for (var i = 0; i < arguments.length; i++) { +- objects.push(inspect(arguments[i])); +- } +- return objects.join(' '); +- } +- +- var i = 1; +- var args = arguments; +- var len = args.length; +- var str = String(f).replace(formatRegExp, function(x) { +- if (x === '%%') return '%'; +- if (i >= len) return x; +- switch (x) { +- case '%s': return String(args[i++]); +- case '%d': return Number(args[i++]); +- case '%j': +- try { +- return JSON.stringify(args[i++]); +- } catch (_) { +- return '[Circular]'; +- } +- default: +- return x; +- } +- }); +- for (var x = args[i]; i < len; x = args[++i]) { +- if (isNull(x) || !isObject(x)) { +- str += ' ' + x; +- } else { +- str += ' ' + inspect(x); +- } +- } +- return str; +-}; +- +- +-// Mark that a method should not be used. +-// Returns a modified function which warns once by default. +-// If --no-deprecation is set, then it is a no-op. +-exports.deprecate = function(fn, msg) { +- // Allow for deprecating things in the process of starting up. +- if (isUndefined(global.process)) { +- return function() { +- return exports.deprecate(fn, msg).apply(this, arguments); +- }; +- } +- +- if (process.noDeprecation === true) { +- return fn; +- } +- +- var warned = false; +- function deprecated() { +- if (!warned) { +- if (process.throwDeprecation) { +- throw new Error(msg); +- } else if (process.traceDeprecation) { +- console.trace(msg); +- } else { +- console.error(msg); +- } +- warned = true; +- } +- return fn.apply(this, arguments); +- } +- +- return deprecated; +-}; +- +- +-var debugs = {}; +-var debugEnviron; +-exports.debuglog = function(set) { +- if (isUndefined(debugEnviron)) +- debugEnviron = process.env.NODE_DEBUG || ''; +- set = set.toUpperCase(); +- if (!debugs[set]) { +- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { +- var pid = process.pid; +- debugs[set] = function() { +- var msg = exports.format.apply(exports, arguments); +- console.error('%s %d: %s', set, pid, msg); +- }; +- } else { +- debugs[set] = function() {}; +- } +- } +- return debugs[set]; +-}; +- +- +-/** +- * Echos the value of a value. Trys to print the value out +- * in the best way possible given the different types. +- * +- * @param {Object} obj The object to print out. +- * @param {Object} opts Optional options object that alters the output. +- */ +-/* legacy: obj, showHidden, depth, colors*/ +-function inspect(obj, opts) { +- // default options +- var ctx = { +- seen: [], +- stylize: stylizeNoColor +- }; +- // legacy... +- if (arguments.length >= 3) ctx.depth = arguments[2]; +- if (arguments.length >= 4) ctx.colors = arguments[3]; +- if (isBoolean(opts)) { +- // legacy... +- ctx.showHidden = opts; +- } else if (opts) { +- // got an "options" object +- exports._extend(ctx, opts); +- } +- // set default options +- if (isUndefined(ctx.showHidden)) ctx.showHidden = false; +- if (isUndefined(ctx.depth)) ctx.depth = 2; +- if (isUndefined(ctx.colors)) ctx.colors = false; +- if (isUndefined(ctx.customInspect)) ctx.customInspect = true; +- if (ctx.colors) ctx.stylize = stylizeWithColor; +- return formatValue(ctx, obj, ctx.depth); +-} +-exports.inspect = inspect; +- +- +-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +-inspect.colors = { +- 'bold' : [1, 22], +- 'italic' : [3, 23], +- 'underline' : [4, 24], +- 'inverse' : [7, 27], +- 'white' : [37, 39], +- 'grey' : [90, 39], +- 'black' : [30, 39], +- 'blue' : [34, 39], +- 'cyan' : [36, 39], +- 'green' : [32, 39], +- 'magenta' : [35, 39], +- 'red' : [31, 39], +- 'yellow' : [33, 39] +-}; +- +-// Don't use 'blue' not visible on cmd.exe +-inspect.styles = { +- 'special': 'cyan', +- 'number': 'yellow', +- 'boolean': 'yellow', +- 'undefined': 'grey', +- 'null': 'bold', +- 'string': 'green', +- 'date': 'magenta', +- // "name": intentionally not styling +- 'regexp': 'red' +-}; +- +- +-function stylizeWithColor(str, styleType) { +- var style = inspect.styles[styleType]; +- +- if (style) { +- return '\u001b[' + inspect.colors[style][0] + 'm' + str + +- '\u001b[' + inspect.colors[style][1] + 'm'; +- } else { +- return str; +- } +-} +- +- +-function stylizeNoColor(str, styleType) { +- return str; +-} +- +- +-function arrayToHash(array) { +- var hash = {}; +- +- array.forEach(function(val, idx) { +- hash[val] = true; +- }); +- +- return hash; +-} +- +- +-function formatValue(ctx, value, recurseTimes) { +- // Provide a hook for user-specified inspect functions. +- // Check that value is an object with an inspect function on it +- if (ctx.customInspect && +- value && +- isFunction(value.inspect) && +- // Filter out the util module, it's inspect function is special +- value.inspect !== exports.inspect && +- // Also filter out any prototype objects using the circular check. +- !(value.constructor && value.constructor.prototype === value)) { +- var ret = value.inspect(recurseTimes, ctx); +- if (!isString(ret)) { +- ret = formatValue(ctx, ret, recurseTimes); +- } +- return ret; +- } +- +- // Primitive types cannot have properties +- var primitive = formatPrimitive(ctx, value); +- if (primitive) { +- return primitive; +- } +- +- // Look up the keys of the object. +- var keys = Object.keys(value); +- var visibleKeys = arrayToHash(keys); +- +- if (ctx.showHidden) { +- keys = Object.getOwnPropertyNames(value); +- } +- +- // Some type of object without properties can be shortcutted. +- if (keys.length === 0) { +- if (isFunction(value)) { +- var name = value.name ? ': ' + value.name : ''; +- return ctx.stylize('[Function' + name + ']', 'special'); +- } +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } +- if (isDate(value)) { +- return ctx.stylize(Date.prototype.toString.call(value), 'date'); +- } +- if (isError(value)) { +- return formatError(value); +- } +- } +- +- var base = '', array = false, braces = ['{', '}']; +- +- // Make Array say that they are Array +- if (isArray(value)) { +- array = true; +- braces = ['[', ']']; +- } +- +- // Make functions say that they are functions +- if (isFunction(value)) { +- var n = value.name ? ': ' + value.name : ''; +- base = ' [Function' + n + ']'; +- } +- +- // Make RegExps say that they are RegExps +- if (isRegExp(value)) { +- base = ' ' + RegExp.prototype.toString.call(value); +- } +- +- // Make dates with properties first say the date +- if (isDate(value)) { +- base = ' ' + Date.prototype.toUTCString.call(value); +- } +- +- // Make error with message first say the error +- if (isError(value)) { +- base = ' ' + formatError(value); +- } +- +- if (keys.length === 0 && (!array || value.length == 0)) { +- return braces[0] + base + braces[1]; +- } +- +- if (recurseTimes < 0) { +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } else { +- return ctx.stylize('[Object]', 'special'); +- } +- } +- +- ctx.seen.push(value); +- +- var output; +- if (array) { +- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); +- } else { +- output = keys.map(function(key) { +- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); +- }); +- } +- +- ctx.seen.pop(); +- +- return reduceToSingleString(output, base, braces); +-} +- +- +-function formatPrimitive(ctx, value) { +- if (isUndefined(value)) +- return ctx.stylize('undefined', 'undefined'); +- if (isString(value)) { +- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') +- .replace(/'/g, "\\'") +- .replace(/\\"/g, '"') + '\''; +- return ctx.stylize(simple, 'string'); +- } +- if (isNumber(value)) { +- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, +- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . +- if (value === 0 && 1 / value < 0) +- return ctx.stylize('-0', 'number'); +- return ctx.stylize('' + value, 'number'); +- } +- if (isBoolean(value)) +- return ctx.stylize('' + value, 'boolean'); +- // For some reason typeof null is "object", so special case here. +- if (isNull(value)) +- return ctx.stylize('null', 'null'); +-} +- +- +-function formatError(value) { +- return '[' + Error.prototype.toString.call(value) + ']'; +-} +- +- +-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { +- var output = []; +- for (var i = 0, l = value.length; i < l; ++i) { +- if (hasOwnProperty(value, String(i))) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- String(i), true)); +- } else { +- output.push(''); +- } +- } +- keys.forEach(function(key) { +- if (!key.match(/^\d+$/)) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- key, true)); +- } +- }); +- return output; +-} +- +- +-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { +- var name, str, desc; +- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; +- if (desc.get) { +- if (desc.set) { +- str = ctx.stylize('[Getter/Setter]', 'special'); +- } else { +- str = ctx.stylize('[Getter]', 'special'); +- } +- } else { +- if (desc.set) { +- str = ctx.stylize('[Setter]', 'special'); +- } +- } +- if (!hasOwnProperty(visibleKeys, key)) { +- name = '[' + key + ']'; +- } +- if (!str) { +- if (ctx.seen.indexOf(desc.value) < 0) { +- if (isNull(recurseTimes)) { +- str = formatValue(ctx, desc.value, null); +- } else { +- str = formatValue(ctx, desc.value, recurseTimes - 1); +- } +- if (str.indexOf('\n') > -1) { +- if (array) { +- str = str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n').substr(2); +- } else { +- str = '\n' + str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n'); +- } +- } +- } else { +- str = ctx.stylize('[Circular]', 'special'); +- } +- } +- if (isUndefined(name)) { +- if (array && key.match(/^\d+$/)) { +- return str; +- } +- name = JSON.stringify('' + key); +- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { +- name = name.substr(1, name.length - 2); +- name = ctx.stylize(name, 'name'); +- } else { +- name = name.replace(/'/g, "\\'") +- .replace(/\\"/g, '"') +- .replace(/(^"|"$)/g, "'"); +- name = ctx.stylize(name, 'string'); +- } +- } +- +- return name + ': ' + str; +-} +- +- +-function reduceToSingleString(output, base, braces) { +- var numLinesEst = 0; +- var length = output.reduce(function(prev, cur) { +- numLinesEst++; +- if (cur.indexOf('\n') >= 0) numLinesEst++; +- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; +- }, 0); +- +- if (length > 60) { +- return braces[0] + +- (base === '' ? '' : base + '\n ') + +- ' ' + +- output.join(',\n ') + +- ' ' + +- braces[1]; +- } +- +- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +-} +- +- + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { +@@ -522,166 +98,10 @@ function isPrimitive(arg) { + exports.isPrimitive = isPrimitive; + + function isBuffer(arg) { +- return arg instanceof Buffer; ++ return Buffer.isBuffer(arg); + } + exports.isBuffer = isBuffer; + + function objectToString(o) { + return Object.prototype.toString.call(o); +-} +- +- +-function pad(n) { +- return n < 10 ? '0' + n.toString(10) : n.toString(10); +-} +- +- +-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', +- 'Oct', 'Nov', 'Dec']; +- +-// 26 Feb 16:19:34 +-function timestamp() { +- var d = new Date(); +- var time = [pad(d.getHours()), +- pad(d.getMinutes()), +- pad(d.getSeconds())].join(':'); +- return [d.getDate(), months[d.getMonth()], time].join(' '); +-} +- +- +-// log is just a thin wrapper to console.log that prepends a timestamp +-exports.log = function() { +- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +-}; +- +- +-/** +- * Inherit the prototype methods from one constructor into another. +- * +- * The Function.prototype.inherits from lang.js rewritten as a standalone +- * function (not on Function.prototype). NOTE: If this file is to be loaded +- * during bootstrapping this function needs to be rewritten using some native +- * functions as prototype setup using normal JavaScript does not work as +- * expected during bootstrapping (see mirror.js in r114903). +- * +- * @param {function} ctor Constructor function which needs to inherit the +- * prototype. +- * @param {function} superCtor Constructor function to inherit prototype from. +- */ +-exports.inherits = function(ctor, superCtor) { +- ctor.super_ = superCtor; +- ctor.prototype = Object.create(superCtor.prototype, { +- constructor: { +- value: ctor, +- enumerable: false, +- writable: true, +- configurable: true +- } +- }); +-}; +- +-exports._extend = function(origin, add) { +- // Don't do anything if add isn't an object +- if (!add || !isObject(add)) return origin; +- +- var keys = Object.keys(add); +- var i = keys.length; +- while (i--) { +- origin[keys[i]] = add[keys[i]]; +- } +- return origin; +-}; +- +-function hasOwnProperty(obj, prop) { +- return Object.prototype.hasOwnProperty.call(obj, prop); +-} +- +- +-// Deprecated old stuff. +- +-exports.p = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- console.error(exports.inspect(arguments[i])); +- } +-}, 'util.p: Use console.error() instead'); +- +- +-exports.exec = exports.deprecate(function() { +- return require('child_process').exec.apply(this, arguments); +-}, 'util.exec is now called `child_process.exec`.'); +- +- +-exports.print = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(String(arguments[i])); +- } +-}, 'util.print: Use console.log instead'); +- +- +-exports.puts = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(arguments[i] + '\n'); +- } +-}, 'util.puts: Use console.log instead'); +- +- +-exports.debug = exports.deprecate(function(x) { +- process.stderr.write('DEBUG: ' + x + '\n'); +-}, 'util.debug: Use console.error instead'); +- +- +-exports.error = exports.deprecate(function(x) { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stderr.write(arguments[i] + '\n'); +- } +-}, 'util.error: Use console.error instead'); +- +- +-exports.pump = exports.deprecate(function(readStream, writeStream, callback) { +- var callbackCalled = false; +- +- function call(a, b, c) { +- if (callback && !callbackCalled) { +- callback(a, b, c); +- callbackCalled = true; +- } +- } +- +- readStream.addListener('data', function(chunk) { +- if (writeStream.write(chunk) === false) readStream.pause(); +- }); +- +- writeStream.addListener('drain', function() { +- readStream.resume(); +- }); +- +- readStream.addListener('end', function() { +- writeStream.end(); +- }); +- +- readStream.addListener('close', function() { +- call(); +- }); +- +- readStream.addListener('error', function(err) { +- writeStream.end(); +- call(err); +- }); +- +- writeStream.addListener('error', function(err) { +- readStream.destroy(); +- call(err); +- }); +-}, 'util.pump(): Use readableStream.pipe() instead'); +- +- +-var uv; +-exports._errnoException = function(err, syscall) { +- if (isUndefined(uv)) uv = process.binding('uv'); +- var errname = uv.errname(err); +- var e = new Error(syscall + ' ' + errname); +- e.code = errname; +- e.errno = errname; +- e.syscall = syscall; +- return e; +-}; ++} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/lib/util.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/lib/util.js new file mode 100644 index 0000000..9074e8e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/lib/util.js @@ -0,0 +1,107 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return Buffer.isBuffer(arg); +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json new file mode 100644 index 0000000..c7fbad8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json @@ -0,0 +1,54 @@ +{ + "name": "core-util-is", + "version": "1.0.1", + "description": "The `util.is*` functions introduced in Node v0.12.", + "main": "lib/util.js", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/core-util-is.git" + }, + "keywords": [ + "util", + "isBuffer", + "isArray", + "isNumber", + "isString", + "isRegExp", + "isThis", + "isThat", + "polyfill" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/isaacs/core-util-is/issues" + }, + "readme": "# core-util-is\n\nThe `util.is*` functions introduced in Node v0.12.\n", + "readmeFilename": "README.md", + "homepage": "https://github.com/isaacs/core-util-is", + "_id": "core-util-is@1.0.1", + "dist": { + "shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", + "tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" + }, + "_from": "core-util-is@>=1.0.0 <1.1.0", + "_npmVersion": "1.3.23", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "directories": {}, + "_shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", + "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz", + "scripts": {} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/util.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/util.js new file mode 100644 index 0000000..007fa10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/util.js @@ -0,0 +1,106 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return arg instanceof Buffer; +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/LICENSE new file mode 100644 index 0000000..dea3013 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/README.md new file mode 100644 index 0000000..b1c5665 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits.js new file mode 100644 index 0000000..29f5e24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits.js @@ -0,0 +1 @@ +module.exports = require('util').inherits diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits_browser.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits_browser.js new file mode 100644 index 0000000..c1e78a7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/inherits_browser.js @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/package.json new file mode 100644 index 0000000..4714dd6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/package.json @@ -0,0 +1,50 @@ +{ + "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.git" + }, + "license": "ISC", + "scripts": { + "test": "node test" + }, + "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@>=2.0.1 <2.1.0", + "_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", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/isaacs/inherits" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/test.js new file mode 100644 index 0000000..fc53012 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/test.js @@ -0,0 +1,25 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/README.md new file mode 100644 index 0000000..052a62b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/README.md @@ -0,0 +1,54 @@ + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/build/build.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/build/build.js new file mode 100644 index 0000000..ec58596 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/build/build.js @@ -0,0 +1,209 @@ + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/component.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/component.json new file mode 100644 index 0000000..9e31b68 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/component.json @@ -0,0 +1,19 @@ +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/index.js new file mode 100644 index 0000000..5f5ad45 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/index.js @@ -0,0 +1,3 @@ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/package.json new file mode 100644 index 0000000..19228ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/isarray/package.json @@ -0,0 +1,53 @@ +{ + "name": "isarray", + "description": "Array#isArray for older browsers", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "homepage": "https://github.com/juliangruber/isarray", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "*" + }, + "keywords": [ + "browser", + "isarray", + "array" + ], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT", + "_id": "isarray@0.0.1", + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "_from": "isarray@0.0.1", + "_npmVersion": "1.2.18", + "_npmUser": { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "directories": {}, + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/.npmignore new file mode 100644 index 0000000..206320c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/.npmignore @@ -0,0 +1,2 @@ +build +test diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/LICENSE new file mode 100644 index 0000000..6de584a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/LICENSE @@ -0,0 +1,20 @@ +Copyright Joyent, Inc. and other Node contributors. + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/README.md new file mode 100644 index 0000000..4d2aa00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/README.md @@ -0,0 +1,7 @@ +**string_decoder.js** (`require('string_decoder')`) from Node.js core + +Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details. + +Version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.** + +The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/index.js new file mode 100644 index 0000000..b00e54f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/index.js @@ -0,0 +1,221 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var Buffer = require('buffer').Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/package.json new file mode 100644 index 0000000..0364d54 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/string_decoder/package.json @@ -0,0 +1,54 @@ +{ + "name": "string_decoder", + "version": "0.10.31", + "description": "The string_decoder module from Node core", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "tap": "~0.4.8" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/rvagg/string_decoder.git" + }, + "homepage": "https://github.com/rvagg/string_decoder", + "keywords": [ + "string", + "decoder", + "browser", + "browserify" + ], + "license": "MIT", + "gitHead": "d46d4fd87cf1d06e031c23f1ba170ca7d4ade9a0", + "bugs": { + "url": "https://github.com/rvagg/string_decoder/issues" + }, + "_id": "string_decoder@0.10.31", + "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "_from": "string_decoder@>=0.10.0 <0.11.0", + "_npmVersion": "1.4.23", + "_npmUser": { + "name": "rvagg", + "email": "rod@vagg.org" + }, + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "dist": { + "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "tarball": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/package.json new file mode 100644 index 0000000..fca8832 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/package.json @@ -0,0 +1,70 @@ +{ + "name": "readable-stream", + "version": "1.1.13", + "description": "Streams3, a user-land copy of the stream library from Node.js v0.11.x", + "main": "readable.js", + "dependencies": { + "core-util-is": "~1.0.0", + "isarray": "0.0.1", + "string_decoder": "~0.10.x", + "inherits": "~2.0.1" + }, + "devDependencies": { + "tap": "~0.2.6" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/readable-stream.git" + }, + "keywords": [ + "readable", + "stream", + "pipe" + ], + "browser": { + "util": false + }, + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "gitHead": "3b672fd7ae92acf5b4ffdbabf74b372a0a56b051", + "bugs": { + "url": "https://github.com/isaacs/readable-stream/issues" + }, + "homepage": "https://github.com/isaacs/readable-stream", + "_id": "readable-stream@1.1.13", + "_shasum": "f6eef764f514c89e2b9e23146a75ba106756d23e", + "_from": "readable-stream@>=1.1.13 <2.0.0", + "_npmVersion": "1.4.23", + "_npmUser": { + "name": "rvagg", + "email": "rod@vagg.org" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "dist": { + "shasum": "f6eef764f514c89e2b9e23146a75ba106756d23e", + "tarball": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/passthrough.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/passthrough.js new file mode 100644 index 0000000..27e8d8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/readable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/readable.js new file mode 100644 index 0000000..09b8bf5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/readable.js @@ -0,0 +1,7 @@ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = require('stream'); +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/transform.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/transform.js new file mode 100644 index 0000000..5d482f0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/writable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/writable.js new file mode 100644 index 0000000..e1e9efd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json new file mode 100644 index 0000000..6c981da --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json @@ -0,0 +1,50 @@ +{ + "name": "are-we-there-yet", + "version": "1.0.4", + "description": "Keep track of the overall completion of many dispirate processes", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/iarna/are-we-there-yet.git" + }, + "author": { + "name": "Rebecca Turner", + "url": "http://re-becca.org" + }, + "license": "ISC", + "bugs": { + "url": "https://github.com/iarna/are-we-there-yet/issues" + }, + "homepage": "https://github.com/iarna/are-we-there-yet", + "devDependencies": { + "tap": "^0.4.13" + }, + "dependencies": { + "delegates": "^0.1.0", + "readable-stream": "^1.1.13" + }, + "gitHead": "7ce414849b81ab83935a935275def01914821bde", + "_id": "are-we-there-yet@1.0.4", + "_shasum": "527fe389f7bcba90806106b99244eaa07e886f85", + "_from": "are-we-there-yet@>=1.0.0 <1.1.0", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "iarna", + "email": "me@re-becca.org" + }, + "maintainers": [ + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "dist": { + "shasum": "527fe389f7bcba90806106b99244eaa07e886f85", + "tarball": "http://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js new file mode 100644 index 0000000..18c31c3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js @@ -0,0 +1,56 @@ +"use strict" +var test = require("tap").test +var Tracker = require("../index.js").Tracker + +var timeoutError = new Error("timeout") +var testEvent = function (obj,event,next) { + var timeout = setTimeout(function(){ + obj.removeListener(event, eventHandler) + next(timeoutError) + }, 10) + var eventHandler = function () { + var args = Array.prototype.slice.call(arguments) + args.unshift(null) + clearTimeout(timeout) + next.apply(null, args) + } + obj.once(event, eventHandler) +} + +test("Tracker", function (t) { + t.plan(10) + + var name = "test" + var track = new Tracker(name) + + t.is(track.completed(), 0, "Nothing todo is 0 completion") + + var todo = 100 + track = new Tracker(name, todo) + t.is(track.completed(), 0, "Nothing done is 0 completion") + + testEvent(track, "change", afterCompleteWork) + track.completeWork(100) + function afterCompleteWork(er, onChangeName) { + t.is(er, null, "completeWork: on change event fired") + t.is(onChangeName, name, "completeWork: on change emits the correct name") + } + t.is(track.completed(), 1, "completeWork: 100% completed") + + testEvent(track, "change", afterAddWork) + track.addWork(100) + function afterAddWork(er, onChangeName) { + t.is(er, null, "addWork: on change event fired") + t.is(onChangeName, name, "addWork: on change emits the correct name") + } + t.is(track.completed(), 0.5, "addWork: 50% completed") + + + track.completeWork(200) + t.is(track.completed(), 1, "completeWork: Over completion is still only 100% complete") + + track = new Tracker(name, todo) + track.completeWork(50) + track.finish() + t.is(track.completed(), 1, "finish: Explicitly finishing moves to 100%") +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js new file mode 100644 index 0000000..a64e121 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js @@ -0,0 +1,87 @@ +"use strict" +var test = require("tap").test +var Tracker = require("../index.js").Tracker +var TrackerGroup = require("../index.js").TrackerGroup + +var timeoutError = new Error("timeout") +var testEvent = function (obj,event,next) { + var timeout = setTimeout(function(){ + obj.removeListener(event, eventHandler) + next(timeoutError) + }, 10) + var eventHandler = function () { + var args = Array.prototype.slice.call(arguments) + args.unshift(null) + clearTimeout(timeout) + next.apply(null, args) + } + obj.once(event, eventHandler) +} + +test("TrackerGroup", function (t) { + var name = "test" + + var track = new TrackerGroup(name) + t.is(track.completed(), 0, "Nothing todo is 0 completion") + testEvent(track, "change", afterFinishEmpty) + track.finish() + var a, b + function afterFinishEmpty(er, onChangeName) { + t.is(er, null, "finishEmpty: on change event fired") + t.is(onChangeName, name, "finishEmpty: on change emits the correct name") + t.is(track.completed(), 1, "finishEmpty: Finishing an empty group actually finishes it") + + track = new TrackerGroup(name) + a = track.newItem("a", 10, 1) + b = track.newItem("b", 10, 1) + t.is(track.completed(), 0, "Initially empty") + testEvent(track, "change", afterCompleteWork) + a.completeWork(5) + } + function afterCompleteWork(er, onChangeName) { + t.is(er, null, "on change event fired") + t.is(onChangeName, "a", "on change emits the correct name") + t.is(track.completed(), 0.25, "Complete half of one is a quarter overall") + testEvent(track, "change", afterFinishAll) + track.finish() + } + function afterFinishAll(er, onChangeName) { + t.is(er, null, "finishAll: on change event fired") + t.is(onChangeName, name, "finishAll: on change emits the correct name") + t.is(track.completed(), 1, "Finishing everything ") + + track = new TrackerGroup(name) + a = track.newItem("a", 10, 2) + b = track.newItem("b", 10, 1) + t.is(track.completed(), 0, "weighted: Initially empty") + testEvent(track, "change", afterWeightedCompleteWork) + a.completeWork(5) + } + function afterWeightedCompleteWork(er, onChangeName) { + t.is(er, null, "weighted: on change event fired") + t.is(onChangeName, "a", "weighted: on change emits the correct name") + t.is(Math.round(track.completed()*100), 33, "weighted: Complete half of double weighted") + testEvent(track, "change", afterWeightedFinishAll) + track.finish() + } + function afterWeightedFinishAll(er, onChangeName) { + t.is(er, null, "weightedFinishAll: on change event fired") + t.is(onChangeName, name, "weightedFinishAll: on change emits the correct name") + t.is(track.completed(), 1, "weightedFinishaAll: Finishing everything ") + + track = new TrackerGroup(name) + a = track.newGroup("a", 10) + b = track.newGroup("b", 10) + var a1 = a.newItem("a.1",10) + a1.completeWork(5) + t.is(track.completed(), 0.25, "nested: Initially quarter done") + testEvent(track, "change", afterNestedComplete) + b.finish() + } + function afterNestedComplete(er, onChangeName) { + t.is(er, null, "nestedComplete: on change event fired") + t.is(onChangeName, "b", "nestedComplete: on change emits the correct name") + t.is(track.completed(), 0.75, "nestedComplete: Finishing everything ") + t.end() + } +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js new file mode 100644 index 0000000..72b6043 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js @@ -0,0 +1,65 @@ +"use strict" +var test = require("tap").test +var util = require("util") +var stream = require("readable-stream") +var TrackerStream = require("../index.js").TrackerStream + +var timeoutError = new Error("timeout") +var testEvent = function (obj,event,next) { + var timeout = setTimeout(function(){ + obj.removeListener(event, eventHandler) + next(timeoutError) + }, 10) + var eventHandler = function () { + var args = Array.prototype.slice.call(arguments) + args.unshift(null) + clearTimeout(timeout) + next.apply(null, args) + } + obj.once(event, eventHandler) +} + +var Sink = function () { + stream.Writable.apply(this,arguments) +} +util.inherits(Sink, stream.Writable) +Sink.prototype._write = function (data, encoding, cb) { + cb() +} + +test("TrackerStream", function (t) { + t.plan(9) + + var name = "test" + var track = new TrackerStream(name) + + t.is(track.completed(), 0, "Nothing todo is 0 completion") + + var todo = 10 + track = new TrackerStream(name, todo) + t.is(track.completed(), 0, "Nothing done is 0 completion") + + track.pipe(new Sink()) + + testEvent(track, "change", afterCompleteWork) + track.write("0123456789") + function afterCompleteWork(er, onChangeName) { + t.is(er, null, "write: on change event fired") + t.is(onChangeName, name, "write: on change emits the correct name") + t.is(track.completed(), 1, "write: 100% completed") + + testEvent(track, "change", afterAddWork) + track.addWork(10) + } + function afterAddWork(er, onChangeName) { + t.is(er, null, "addWork: on change event fired") + t.is(track.completed(), 0.5, "addWork: 50% completed") + + testEvent(track, "change", afterAllWork) + track.write("ABCDEFGHIJKLMNOPQRST") + } + function afterAllWork(er) { + t.is(er, null, "allWork: on change event fired") + t.is(track.completed(), 1, "allWork: 100% completed") + } +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/.npmignore new file mode 100644 index 0000000..df22a16 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/.npmignore @@ -0,0 +1,32 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +# Editor cruft +*~ +.#* diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/LICENSE new file mode 100644 index 0000000..e756052 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2014, Rebecca Turner + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md new file mode 100644 index 0000000..fb9eb0a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md @@ -0,0 +1,161 @@ +gauge +===== + +A nearly stateless terminal based horizontal guage / progress bar. + +```javascript +var Gauge = require("gauge") + +var gauge = new Gauge() + +gauge.show("test", 0.20) + +gauge.pulse("this") + +gauge.hide() +``` + + + + +### `var gauge = new Gauge([options], [ansiStream])` + +* **options** – *(optional)* An option object. (See [below] for details.) +* **ansiStream** – *(optional)* A stream that's been blessed by the [ansi] + module to include various commands for controlling the cursor in a terminal. + +[ansi]: https://www.npmjs.com/package/ansi +[below]: #theme-objects + +Constructs a new gauge. Gauges are drawn on a single line, and are not drawn +if the current terminal isn't a tty. + +The **options** object can have the following properties, all of which are +optional: + +* maxUpdateFrequency: defaults to 50 msec, the gauge will not be drawn more + than once in this period of time. This applies to `show` and `pulse` + calls, but if you `hide` and then `show` the gauge it will draw it + regardless of time since last draw. +* theme: defaults to Gauge.unicode` if the terminal supports + unicode according to [has-unicode], otherwise it defaults to `Gauge.ascii`. + Details on the [theme object](#theme-objects) are documented elsewhere. +* template: see [documentation elsewhere](#template-objects) for + defaults and details. + +[has-unicode]: https://www.npmjs.com/package/has-unicode + +If **ansiStream** isn't passed in, then one will be constructed from stderr +with `ansi(process.stderr)`. + +### `gauge.show([name, [completed]])` + +* **name** – *(optional)* The name of the current thing contributing to progress. Defaults to the last value used, or "". +* **completed** – *(optional)* The portion completed as a value between 0 and 1. Defaults to the last value used, or 0. + +If `process.stdout.isTTY` is false then this does nothing. If completed is 0 +and `gauge.pulse` has never been called, then similarly nothing will be printed. + +If `maxUpdateFrequency` msec haven't passed since the last call to `show` or +`pulse` then similarly, nothing will be printed. (Actually, the update is +deferred until `maxUpdateFrequency` msec have passed and if nothing else has +happened, the gauge update will happen.) + +### `gauge.hide()` + +Removes the gauge from the terminal. + +### `gauge.pulse([name])` + +* **name** – *(optional)* The specific thing that triggered this pulse + +Spins the spinner in the gauge to show output. If **name** is included then +it will be combined with the last name passed to `gauge.show` using the +subsection property of the theme (typically a right facing arrow). + +### `gauge.disable()` + +Hides the gauge and ignores further calls to `show` or `pulse`. + +### `gauge.enable()` + +Shows the gauge and resumes updating when `show` or `pulse` is called. + +### `gauge.setTheme(theme)` + +Change the active theme, will be displayed with the next show or pulse + +### `gauge.setTemplate(template)` + +Change the active template, will be displayed with the next show or pulse + +### Theme Objects + +There are two theme objects available as a part of the module, `Gauge.unicode` and `Gauge.ascii`. +Theme objects have the follow properties: + +| Property | Unicode | ASCII | +| ---------- | ------- | ----- | +| startgroup | ╢ | \| | +| endgroup | ╟ | \| | +| complete | █ | # | +| incomplete | ░ | - | +| spinner | ▀▐▄▌ | -\\\|/ | +| subsection | → | -> | + +*startgroup*, *endgroup* and *subsection* can be as many characters as you want. + +*complete* and *incomplete* should be a single character width each. + +*spinner* is a list of characters to use in turn when displaying an activity +spinner. The Gauge will spin as many characters as you give here. + +### Template Objects + +A template is an array of objects and strings that, after being evaluated, +will be turned into the gauge line. The default template is: + +```javascript +[ + {type: "name", separated: true, maxLength: 25, minWidth: 25, align: "left"}, + {type: "spinner", separated: true}, + {type: "startgroup"}, + {type: "completionbar"}, + {type: "endgroup"} +] +``` + +The various template elements can either be **plain strings**, in which case they will +be be included verbatum in the output. + +If the template element is an object, it can have the following keys: + +* *type* can be: + * `name` – The most recent name passed to `show`; if this is in response to a + `pulse` then the name passed to `pulse` will be appended along with the + subsection property from the theme. + * `spinner` – If you've ever called `pulse` this will be one of the characters + from the spinner property of the theme. + * `startgroup` – The `startgroup` property from the theme. + * `completionbar` – This progress bar itself + * `endgroup` – The `endgroup` property from the theme. +* *separated* – If true, the element will be separated with spaces from things on + either side (and margins count as space, so it won't be indented), but only + if its included. +* *maxLength* – The maximum length for this element. If its value is longer it + will be truncated. +* *minLength* – The minimum length for this element. If its value is shorter it + will be padded according to the *align* value. +* *align* – (Default: left) Possible values "left", "right" and "center". Works + as you'd expect from word processors. +* *length* – Provides a single value for both *minLength* and *maxLength*. If both + *length* and *minLength or *maxLength* are specifed then the latter take precedence. + +### Tracking Completion + +If you have more than one thing going on that you want to track completion +of, you may find the related [are-we-there-yet] helpful. It's `change` +event can be wired up to the `show` method to get a more traditional +progress bar interface. + +[are-we-there-yet]: https://www.npmjs.com/package/are-we-there-yet diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md~ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md~ new file mode 100644 index 0000000..eec841b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/README.md~ @@ -0,0 +1,153 @@ +gauge +===== + +A nearly stateless terminal based horizontal guage / progress bar. + +```javascript +var Gauge = require("gauge") + +var gauge = new Gauge() + +gauge.show("test", 0.20) + +gauge.pulse("this") + +gauge.hide() +``` + + + + +### `var gauge = new Gauge([options], [ansiStream])` + +* **options** – *(optional)* An option object. (See [below] for details.) +* **ansiStream** – *(optional)* A stream that's been blessed by the [ansi] + module to include various commands for controlling the cursor in a terminal. + +[ansi]: https://www.npmjs.com/package/ansi +[below]: #theme-objects + +Constructs a new gauge. Gauges are drawn on a single line, and are not drawn +if the current terminal isn't a tty. + +The **options** object can have the following properties, all of which are +optional: + +* maxUpdateFrequency: defaults to 50 msec, the gauge will not be drawn more + than once in this period of time. This applies to `show` and `pulse` + calls, but if you `hide` and then `show` the gauge it will draw it + regardless of time since last draw. +* theme: defaults to Gauge.unicode` if the terminal supports + unicode according to [has-unicode], otherwise it defaults to `Gauge.ascii`. + Details on the [theme object](#theme-objects) are documented elsewhere. +* template: see [documentation elsewhere](#template-objects) for + defaults and details. + +[has-unicode]: https://www.npmjs.com/package/has-unicode + +If **ansiStream** isn't passed in, then one will be constructed from stderr +with `ansi(process.stderr)`. + +### `gauge.show([name, [completed]])` + +* **name** – *(optional)* The name of the current thing contributing to progress. Defaults to the last value used, or "". +* **completed** – *(optional)* The portion completed as a value between 0 and 1. Defaults to the last value used, or 0. + +If `process.stdout.isTTY` is false then this does nothing. If completed is 0 +and `gauge.pulse` has never been called, then similarly nothing will be printed. + +If `maxUpdateFrequency` msec haven't passed since the last call to `show` or +`pulse` then similarly, nothing will be printed. (Actually, the update is +deferred until `maxUpdateFrequency` msec have passed and if nothing else has +happened, the gauge update will happen.) + +### `gauge.hide()` + +Removes the gauge from the terminal. + +### `gauge.pulse([name])` + +* **name** – *(optional)* The specific thing that triggered this pulse + +Spins the spinner in the gauge to show output. If **name** is included then +it will be combined with the last name passed to `gauge.show` using the +subsection property of the theme (typically a right facing arrow). + +### `gauge.disable()` + +Hides the gauge and ignores further calls to `show` or `pulse`. + +### `gauge.enable()` + +Shows the gauge and resumes updating when `show` or `pulse` is called. + +### Theme Objects + +There are two theme objects available as a part of the module, `Gauge.unicode` and `Gauge.ascii`. +Theme objects have the follow properties: + +| Property | Unicode | ASCII | +| ---------- | ------- | ----- | +| startgroup | ╢ | \| | +| endgroup | ╟ | \| | +| complete | █ | # | +| incomplete | ░ | - | +| spinner | ▀▐▄▌ | -\\\|/ | +| subsection | → | -> | + +*startgroup*, *endgroup* and *subsection* can be as many characters as you want. + +*complete* and *incomplete* should be a single character width each. + +*spinner* is a list of characters to use in turn when displaying an activity +spinner. The Gauge will spin as many characters as you give here. + +### Template Objects + +A template is an array of objects and strings that, after being evaluated, +will be turned into the gauge line. The default template is: + +```javascript +[ + {type: "name", separated: true, maxLength: 25, minWidth: 25, align: "left"}, + {type: "spinner", separated: true}, + {type: "startgroup"}, + {type: "completionbar"}, + {type: "endgroup"} +] +``` + +The various template elements can either be **plain strings**, in which case they will +be be included verbatum in the output. + +If the template element is an object, it can have the following keys: + +* *type* can be: + * `name` – The most recent name passed to `show`; if this is in response to a + `pulse` then the name passed to `pulse` will be appended along with the + subsection property from the theme. + * `spinner` – If you've ever called `pulse` this will be one of the characters + from the spinner property of the theme. + * `startgroup` – The `startgroup` property from the theme. + * `completionbar` – This progress bar itself + * `endgroup` – The `endgroup` property from the theme. +* *separated* – If true, the element will be separated with spaces from things on + either side (and margins count as space, so it won't be indented), but only + if its included. +* *maxLength* – The maximum length for this element. If its value is longer it + will be truncated. +* *minLength* – The minimum length for this element. If its value is shorter it + will be padded according to the *align* value. +* *align* – (Default: left) Possible values "left", "right" and "center". Works + as you'd expect from word processors. +* *length* – Provides a single value for both *minLength* and *maxLength*. If both + *length* and *minLength or *maxLength* are specifed then the latter take precedence. + +### Tracking Completion + +If you have more than one thing going on that you want to track completion +of, you may find the related [are-we-there-yet] helpful. It's `change` +event can be wired up to the `show` method to get a more traditional +progress bar interface. + +[are-we-there-yet]: https://www.npmjs.com/package/are-we-there-yet diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/example.png b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/example.png new file mode 100644 index 0000000..2667cac Binary files /dev/null and b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/example.png differ diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/.npmignore new file mode 100644 index 0000000..7e17cf1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/.npmignore @@ -0,0 +1,32 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +# Editor temp files +*~ +.#* diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/LICENSE new file mode 100644 index 0000000..d42e25e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2014, Rebecca Turner + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md new file mode 100644 index 0000000..e9d3cc3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md @@ -0,0 +1,40 @@ +has-unicode +=========== + +Try to guess if your terminal supports unicode + +```javascript +var hasUnicode = require("has-unicode") + +if (hasUnicode()) { + // the terminal probably has unicode support +} +``` +```javascript +var hasUnicode = require("has-unicode").tryHarder +hasUnicode(function(unicodeSupported) { + if (unicodeSupported) { + // the terminal probably has unicode support + } +}) +``` + +## Detecting Unicode + +What we actually detect is UTF-8 support, as that's what Node itself supports. +If you have a UTF-16 locale then you won't be detected as unicode capable. + +### Windows + +Since at least Windows 7, `cmd` and `powershell` have been unicode capable. +As such, we report any Windows installation as unicode capable. + + +### Unix Like Operating Systems + +We look at the environment variables `LC_ALL`, `LC_CTYPE`, and `LANG` in +that order. For `LC_ALL` and `LANG`, it looks for `.UTF-8` in the value. +For `LC_CTYPE` it looks to see if the value is `UTF-8`. This is sufficient +for most POSIX systems. While locale data can be put in `/etc/locale.conf` +as well, AFAIK it's always copied into the environment. + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md~ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md~ new file mode 100644 index 0000000..e712b70 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/README.md~ @@ -0,0 +1,4 @@ +has-unicode +=========== + +Try to guess if your terminal supports unicode diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/index.js new file mode 100644 index 0000000..edceb70 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/index.js @@ -0,0 +1,18 @@ +"use strict" +var os = require("os") +var child_process = require("child_process") + +var hasUnicode = module.exports = function () { + // Supported Win32 platforms (>XP) support unicode in the console, though + // font support isn't fantastic. + if (os.type() == "Windows_NT") { return true } + + var isUTF8 = /[.]UTF-8/ + if (isUTF8.test(process.env.LC_ALL) + || process.env.LC_CTYPE == 'UTF-8' + || isUTF8.test(process.env.LANG)) { + return true + } + + return false +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/package.json new file mode 100644 index 0000000..7126e01 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/package.json @@ -0,0 +1,52 @@ +{ + "name": "has-unicode", + "version": "1.0.0", + "description": "Try to guess if your terminal supports unicode", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/iarna/has-unicode" + }, + "keywords": [ + "unicode", + "terminal" + ], + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "license": "ISC", + "bugs": { + "url": "https://github.com/iarna/has-unicode/issues" + }, + "homepage": "https://github.com/iarna/has-unicode", + "devDependencies": { + "require-inject": "^1.1.1", + "tap": "^0.4.13" + }, + "gitHead": "a8c3dcf3be5f0c8f8e26a3e7ffea7da24344a006", + "_id": "has-unicode@1.0.0", + "_shasum": "bac5c44e064c2ffc3b8fcbd8c71afe08f9afc8cc", + "_from": "has-unicode@>=1.0.0 <2.0.0", + "_npmVersion": "2.1.11", + "_nodeVersion": "0.10.33", + "_npmUser": { + "name": "iarna", + "email": "me@re-becca.org" + }, + "maintainers": [ + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "dist": { + "shasum": "bac5c44e064c2ffc3b8fcbd8c71afe08f9afc8cc", + "tarball": "http://registry.npmjs.org/has-unicode/-/has-unicode-1.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-1.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/test/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/test/index.js new file mode 100644 index 0000000..2394c14 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode/test/index.js @@ -0,0 +1,26 @@ +"use strict" +var test = require("tap").test +var requireInject = require("require-inject") + +test("Windows", function (t) { + t.plan(1) + var hasUnicode = requireInject("../index.js", { + os: { type: function () { return "Windows_NT" } } + }) + t.is(hasUnicode(), true, "Windows is assumed to be unicode aware") +}) +test("Unix Env", function (t) { + t.plan(3) + var hasUnicode = requireInject("../index.js", { + os: { type: function () { return "Linux" } }, + child_process: { exec: function (cmd,cb) { cb(new Error("not available")) } } + }) + process.env.LANG = "en_US.UTF-8" + process.env.LC_ALL = null + t.is(hasUnicode(), true, "Linux with a UTF8 language") + process.env.LANG = null + process.env.LC_ALL = "en_US.UTF-8" + t.is(hasUnicode(), true, "Linux with UTF8 locale") + process.env.LC_ALL = null + t.is(hasUnicode(), false, "Linux without UTF8 language or locale") +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/README.md new file mode 100644 index 0000000..9b4891c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/README.md @@ -0,0 +1,20 @@ +# lodash.pad v3.1.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.pad` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.pad +``` + +In Node.js/io.js: + +```js +var pad = require('lodash.pad'); +``` + +See the [documentation](https://lodash.com/docs#pad) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.pad) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/index.js new file mode 100644 index 0000000..d08251b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/index.js @@ -0,0 +1,57 @@ +/** + * lodash 3.1.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.2 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'), + createPadding = require('lodash._createpadding'); + +/** Native method references. */ +var ceil = Math.ceil, + floor = Math.floor; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Pads `string` on the left and right sides if it is shorter than `length`. + * Padding characters are truncated if they can't be evenly divided by `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.pad('abc', 8); + * // => ' abc ' + * + * _.pad('abc', 8, '_-'); + * // => '_-abc_-_' + * + * _.pad('abc', 3); + * // => 'abc' + */ +function pad(string, length, chars) { + string = baseToString(string); + length = +length; + + var strLength = string.length; + if (strLength >= length || !nativeIsFinite(length)) { + return string; + } + var mid = (length - strLength) / 2, + leftLength = floor(mid), + rightLength = ceil(mid); + + chars = createPadding('', rightLength, chars); + return chars.slice(0, leftLength) + string + chars; +} + +module.exports = pad; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/README.md new file mode 100644 index 0000000..ad04ea9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/README.md @@ -0,0 +1,20 @@ +# lodash._basetostring v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseToString` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._basetostring +``` + +In Node.js/io.js: + +```js +var baseToString = require('lodash._basetostring'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash._basetostring) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/index.js new file mode 100644 index 0000000..71ac885 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/index.js @@ -0,0 +1,25 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** + * Converts `value` to a string if it is not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + if (typeof value == 'string') { + return value; + } + return value == null ? '' : (value + ''); +} + +module.exports = baseToString; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/package.json new file mode 100644 index 0000000..af64867 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._basetostring/package.json @@ -0,0 +1,71 @@ +{ + "name": "lodash._basetostring", + "version": "3.0.0", + "description": "The modern build of lodash’s internal `baseToString` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._basetostring@3.0.0", + "_shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "_from": "lodash._basetostring@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "tarball": "http://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/README.md new file mode 100644 index 0000000..0e1c731 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/README.md @@ -0,0 +1,20 @@ +# lodash._createpadding v3.6.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `createPadding` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._createpadding +``` + +In Node.js/io.js: + +```js +var createPadding = require('lodash._createpadding'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.6.0-npm-packages/lodash._createpadding) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/index.js new file mode 100644 index 0000000..72890bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/index.js @@ -0,0 +1,39 @@ +/** + * lodash 3.6.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.2 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var repeat = require('lodash.repeat'); + +/** Native method references. */ +var ceil = Math.ceil; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Creates the padding required for `string` based on the given `length`. + * The `chars` string is truncated if the number of characters exceeds `length`. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ +function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + + if (strLength >= length || !nativeIsFinite(length)) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : (chars + ''); + return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); +} + +module.exports = createPadding; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md new file mode 100644 index 0000000..d2796e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md @@ -0,0 +1,20 @@ +# lodash.repeat v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.repeat` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.repeat +``` + +In Node.js/io.js: + +```js +var repeat = require('lodash.repeat'); +``` + +See the [documentation](https://lodash.com/docs#repeat) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.repeat) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js new file mode 100644 index 0000000..68e1008 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js @@ -0,0 +1,57 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'); + +/** Native method references. */ +var floor = Math.floor; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ +function repeat(string, n) { + var result = ''; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = floor(n / 2); + string += string; + } while (n); + + return result; +} + +module.exports = repeat; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json new file mode 100644 index 0000000..d19e39a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json @@ -0,0 +1,80 @@ +{ + "name": "lodash.repeat", + "version": "3.0.0", + "description": "The modern build of lodash’s `_.repeat` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.repeat@3.0.0", + "_shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "_from": "lodash.repeat@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "tarball": "http://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/package.json new file mode 100644 index 0000000..5b8361e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/node_modules/lodash._createpadding/package.json @@ -0,0 +1,74 @@ +{ + "name": "lodash._createpadding", + "version": "3.6.0", + "description": "The modern build of lodash’s internal `createPadding` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash.repeat": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._createpadding@3.6.0", + "_shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "_from": "lodash._createpadding@>=3.0.0 <4.0.0", + "_npmVersion": "2.7.3", + "_nodeVersion": "0.12.0", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "tarball": "http://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/package.json new file mode 100644 index 0000000..6813157 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.pad/package.json @@ -0,0 +1,97 @@ +{ + "name": "lodash.pad", + "version": "3.1.0", + "description": "The modern build of lodash’s `_.pad` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0", + "lodash._createpadding": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.pad@3.1.0", + "_shasum": "9f18b1f3749a95e197b5ff2ae752ea9851ada965", + "_from": "lodash.pad@>=3.0.0 <4.0.0", + "_npmVersion": "2.7.3", + "_nodeVersion": "0.12.0", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + { + "name": "d10", + "email": "demoneaux@gmail.com" + }, + { + "name": "kitcambridge", + "email": "github@kitcambridge.be" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + }, + { + "name": "phated", + "email": "blaine@iceddev.com" + } + ], + "dist": { + "shasum": "9f18b1f3749a95e197b5ff2ae752ea9851ada965", + "tarball": "http://registry.npmjs.org/lodash.pad/-/lodash.pad-3.1.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-3.1.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/README.md new file mode 100644 index 0000000..641b4d6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/README.md @@ -0,0 +1,20 @@ +# lodash.padleft v3.1.1 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.padLeft` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.padleft +``` + +In Node.js/io.js: + +```js +var padLeft = require('lodash.padleft'); +``` + +See the [documentation](https://lodash.com/docs#padLeft) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.padleft) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/index.js new file mode 100644 index 0000000..2abb69a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/index.js @@ -0,0 +1,50 @@ +/** + * lodash 3.1.1 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'), + createPadding = require('lodash._createpadding'); + +/** + * Creates a function for `_.padLeft` or `_.padRight`. + * + * @private + * @param {boolean} [fromRight] Specify padding from the right. + * @returns {Function} Returns the new pad function. + */ +function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string); + }; +} + +/** + * Pads `string` on the left side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padLeft('abc', 6); + * // => ' abc' + * + * _.padLeft('abc', 6, '_-'); + * // => '_-_abc' + * + * _.padLeft('abc', 3); + * // => 'abc' + */ +var padLeft = createPadDir(); + +module.exports = padLeft; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/README.md new file mode 100644 index 0000000..ad04ea9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/README.md @@ -0,0 +1,20 @@ +# lodash._basetostring v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseToString` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._basetostring +``` + +In Node.js/io.js: + +```js +var baseToString = require('lodash._basetostring'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash._basetostring) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/index.js new file mode 100644 index 0000000..71ac885 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/index.js @@ -0,0 +1,25 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** + * Converts `value` to a string if it is not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + if (typeof value == 'string') { + return value; + } + return value == null ? '' : (value + ''); +} + +module.exports = baseToString; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/package.json new file mode 100644 index 0000000..af64867 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._basetostring/package.json @@ -0,0 +1,71 @@ +{ + "name": "lodash._basetostring", + "version": "3.0.0", + "description": "The modern build of lodash’s internal `baseToString` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._basetostring@3.0.0", + "_shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "_from": "lodash._basetostring@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "tarball": "http://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/README.md new file mode 100644 index 0000000..0e1c731 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/README.md @@ -0,0 +1,20 @@ +# lodash._createpadding v3.6.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `createPadding` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._createpadding +``` + +In Node.js/io.js: + +```js +var createPadding = require('lodash._createpadding'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.6.0-npm-packages/lodash._createpadding) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/index.js new file mode 100644 index 0000000..72890bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/index.js @@ -0,0 +1,39 @@ +/** + * lodash 3.6.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.2 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var repeat = require('lodash.repeat'); + +/** Native method references. */ +var ceil = Math.ceil; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Creates the padding required for `string` based on the given `length`. + * The `chars` string is truncated if the number of characters exceeds `length`. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ +function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + + if (strLength >= length || !nativeIsFinite(length)) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : (chars + ''); + return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); +} + +module.exports = createPadding; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md new file mode 100644 index 0000000..d2796e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md @@ -0,0 +1,20 @@ +# lodash.repeat v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.repeat` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.repeat +``` + +In Node.js/io.js: + +```js +var repeat = require('lodash.repeat'); +``` + +See the [documentation](https://lodash.com/docs#repeat) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.repeat) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js new file mode 100644 index 0000000..68e1008 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js @@ -0,0 +1,57 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'); + +/** Native method references. */ +var floor = Math.floor; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ +function repeat(string, n) { + var result = ''; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = floor(n / 2); + string += string; + } while (n); + + return result; +} + +module.exports = repeat; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json new file mode 100644 index 0000000..d19e39a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json @@ -0,0 +1,80 @@ +{ + "name": "lodash.repeat", + "version": "3.0.0", + "description": "The modern build of lodash’s `_.repeat` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.repeat@3.0.0", + "_shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "_from": "lodash.repeat@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "tarball": "http://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/package.json new file mode 100644 index 0000000..5b8361e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/node_modules/lodash._createpadding/package.json @@ -0,0 +1,74 @@ +{ + "name": "lodash._createpadding", + "version": "3.6.0", + "description": "The modern build of lodash’s internal `createPadding` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash.repeat": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._createpadding@3.6.0", + "_shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "_from": "lodash._createpadding@>=3.0.0 <4.0.0", + "_npmVersion": "2.7.3", + "_nodeVersion": "0.12.0", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "tarball": "http://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/package.json new file mode 100644 index 0000000..b8e25f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padleft/package.json @@ -0,0 +1,97 @@ +{ + "name": "lodash.padleft", + "version": "3.1.1", + "description": "The modern build of lodash’s `_.padLeft` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/lodash/lodash.git" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0", + "lodash._createpadding": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.padleft@3.1.1", + "_shasum": "150151f1e0245edba15d50af2d71f1d5cff46530", + "_from": "lodash.padleft@>=3.0.0 <4.0.0", + "_npmVersion": "2.9.0", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + { + "name": "d10", + "email": "demoneaux@gmail.com" + }, + { + "name": "kitcambridge", + "email": "github@kitcambridge.be" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + }, + { + "name": "phated", + "email": "blaine@iceddev.com" + } + ], + "dist": { + "shasum": "150151f1e0245edba15d50af2d71f1d5cff46530", + "tarball": "http://registry.npmjs.org/lodash.padleft/-/lodash.padleft-3.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.padleft/-/lodash.padleft-3.1.1.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/README.md new file mode 100644 index 0000000..bcd6e57 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/README.md @@ -0,0 +1,20 @@ +# lodash.padright v3.1.1 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.padRight` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.padright +``` + +In Node.js/io.js: + +```js +var padRight = require('lodash.padright'); +``` + +See the [documentation](https://lodash.com/docs#padRight) or [package source](https://github.com/lodash/lodash/blob/3.1.1-npm-packages/lodash.padright) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/index.js new file mode 100644 index 0000000..6de81c4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/index.js @@ -0,0 +1,50 @@ +/** + * lodash 3.1.1 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.3 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'), + createPadding = require('lodash._createpadding'); + +/** + * Creates a function for `_.padLeft` or `_.padRight`. + * + * @private + * @param {boolean} [fromRight] Specify padding from the right. + * @returns {Function} Returns the new pad function. + */ +function createPadDir(fromRight) { + return function(string, length, chars) { + string = baseToString(string); + return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string); + }; +} + +/** + * Pads `string` on the right side if it is shorter than `length`. Padding + * characters are truncated if they exceed `length`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to pad. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padded string. + * @example + * + * _.padRight('abc', 6); + * // => 'abc ' + * + * _.padRight('abc', 6, '_-'); + * // => 'abc_-_' + * + * _.padRight('abc', 3); + * // => 'abc' + */ +var padRight = createPadDir(true); + +module.exports = padRight; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/README.md new file mode 100644 index 0000000..ad04ea9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/README.md @@ -0,0 +1,20 @@ +# lodash._basetostring v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseToString` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._basetostring +``` + +In Node.js/io.js: + +```js +var baseToString = require('lodash._basetostring'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash._basetostring) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/index.js new file mode 100644 index 0000000..71ac885 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/index.js @@ -0,0 +1,25 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ + +/** + * Converts `value` to a string if it is not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + if (typeof value == 'string') { + return value; + } + return value == null ? '' : (value + ''); +} + +module.exports = baseToString; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/package.json new file mode 100644 index 0000000..af64867 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._basetostring/package.json @@ -0,0 +1,71 @@ +{ + "name": "lodash._basetostring", + "version": "3.0.0", + "description": "The modern build of lodash’s internal `baseToString` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._basetostring@3.0.0", + "_shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "_from": "lodash._basetostring@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "75a9a4aaaa2b2a8761111ff5431e7d83c1daf0e2", + "tarball": "http://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/LICENSE.txt new file mode 100644 index 0000000..9cd87e5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/README.md new file mode 100644 index 0000000..0e1c731 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/README.md @@ -0,0 +1,20 @@ +# lodash._createpadding v3.6.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `createPadding` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash._createpadding +``` + +In Node.js/io.js: + +```js +var createPadding = require('lodash._createpadding'); +``` + +See the [package source](https://github.com/lodash/lodash/blob/3.6.0-npm-packages/lodash._createpadding) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/index.js new file mode 100644 index 0000000..72890bd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/index.js @@ -0,0 +1,39 @@ +/** + * lodash 3.6.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.8.2 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var repeat = require('lodash.repeat'); + +/** Native method references. */ +var ceil = Math.ceil; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Creates the padding required for `string` based on the given `length`. + * The `chars` string is truncated if the number of characters exceeds `length`. + * + * @private + * @param {string} string The string to create padding for. + * @param {number} [length=0] The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the pad for `string`. + */ +function createPadding(string, length, chars) { + var strLength = string.length; + length = +length; + + if (strLength >= length || !nativeIsFinite(length)) { + return ''; + } + var padLength = length - strLength; + chars = chars == null ? ' ' : (chars + ''); + return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); +} + +module.exports = createPadding; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt new file mode 100644 index 0000000..1776432 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2015 The Dojo Foundation +Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md new file mode 100644 index 0000000..d2796e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/README.md @@ -0,0 +1,20 @@ +# lodash.repeat v3.0.0 + +The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.repeat` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. + +## Installation + +Using npm: + +```bash +$ {sudo -H} npm i -g npm +$ npm i --save lodash.repeat +``` + +In Node.js/io.js: + +```js +var repeat = require('lodash.repeat'); +``` + +See the [documentation](https://lodash.com/docs#repeat) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.repeat) for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js new file mode 100644 index 0000000..68e1008 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/index.js @@ -0,0 +1,57 @@ +/** + * lodash 3.0.0 (Custom Build) + * Build: `lodash modern modularize exports="npm" -o ./` + * Copyright 2012-2015 The Dojo Foundation + * Based on Underscore.js 1.7.0 + * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + * Available under MIT license + */ +var baseToString = require('lodash._basetostring'); + +/** Native method references. */ +var floor = Math.floor; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsFinite = global.isFinite; + +/** + * Repeats the given string `n` times. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to repeat. + * @param {number} [n=0] The number of times to repeat the string. + * @returns {string} Returns the repeated string. + * @example + * + * _.repeat('*', 3); + * // => '***' + * + * _.repeat('abc', 2); + * // => 'abcabc' + * + * _.repeat('abc', 0); + * // => '' + */ +function repeat(string, n) { + var result = ''; + string = baseToString(string); + n = +n; + if (n < 1 || !string || !nativeIsFinite(n)) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = floor(n / 2); + string += string; + } while (n); + + return result; +} + +module.exports = repeat; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json new file mode 100644 index 0000000..d19e39a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/node_modules/lodash.repeat/package.json @@ -0,0 +1,80 @@ +{ + "name": "lodash.repeat", + "version": "3.0.0", + "description": "The modern build of lodash’s `_.repeat` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.repeat@3.0.0", + "_shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "_from": "lodash.repeat@>=3.0.0 <4.0.0", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c340f4136c99dc5b2e397b3fd50cffbd172a94b0", + "tarball": "http://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/package.json new file mode 100644 index 0000000..5b8361e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/node_modules/lodash._createpadding/package.json @@ -0,0 +1,74 @@ +{ + "name": "lodash._createpadding", + "version": "3.6.0", + "description": "The modern build of lodash’s internal `createPadding` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/lodash/lodash" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash.repeat": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash._createpadding@3.6.0", + "_shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "_from": "lodash._createpadding@>=3.0.0 <4.0.0", + "_npmVersion": "2.7.3", + "_nodeVersion": "0.12.0", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + } + ], + "dist": { + "shasum": "c466850dd1a05e6bfec54fd0cf0db28b68332d5e", + "tarball": "http://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash._createpadding/-/lodash._createpadding-3.6.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/package.json new file mode 100644 index 0000000..b8ab0fb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/node_modules/lodash.padright/package.json @@ -0,0 +1,97 @@ +{ + "name": "lodash.padright", + "version": "3.1.1", + "description": "The modern build of lodash’s `_.padRight` as a module.", + "homepage": "https://lodash.com/", + "icon": "https://lodash.com/icon.svg", + "license": "MIT", + "keywords": [ + "lodash", + "lodash-modularized", + "stdlib", + "util" + ], + "author": { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + "contributors": [ + { + "name": "John-David Dalton", + "email": "john.david.dalton@gmail.com", + "url": "http://allyoucanleet.com/" + }, + { + "name": "Benjamin Tan", + "email": "demoneaux@gmail.com", + "url": "https://d10.github.io/" + }, + { + "name": "Blaine Bublitz", + "email": "blaine@iceddev.com", + "url": "http://www.iceddev.com/" + }, + { + "name": "Kit Cambridge", + "email": "github@kitcambridge.be", + "url": "http://kitcambridge.be/" + }, + { + "name": "Mathias Bynens", + "email": "mathias@qiwi.be", + "url": "https://mathiasbynens.be/" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/lodash/lodash.git" + }, + "scripts": { + "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" + }, + "dependencies": { + "lodash._basetostring": "^3.0.0", + "lodash._createpadding": "^3.0.0" + }, + "bugs": { + "url": "https://github.com/lodash/lodash/issues" + }, + "_id": "lodash.padright@3.1.1", + "_shasum": "79f7770baaa39738c040aeb5465e8d88f2aacec0", + "_from": "lodash.padright@>=3.0.0 <4.0.0", + "_npmVersion": "2.9.0", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + "maintainers": [ + { + "name": "jdalton", + "email": "john.david.dalton@gmail.com" + }, + { + "name": "d10", + "email": "demoneaux@gmail.com" + }, + { + "name": "kitcambridge", + "email": "github@kitcambridge.be" + }, + { + "name": "mathias", + "email": "mathias@qiwi.be" + }, + { + "name": "phated", + "email": "blaine@iceddev.com" + } + ], + "dist": { + "shasum": "79f7770baaa39738c040aeb5465e8d88f2aacec0", + "tarball": "http://registry.npmjs.org/lodash.padright/-/lodash.padright-3.1.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/lodash.padright/-/lodash.padright-3.1.1.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/package.json new file mode 100644 index 0000000..8e2f331 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/package.json @@ -0,0 +1,59 @@ +{ + "name": "gauge", + "version": "1.2.0", + "description": "A terminal based horizontal guage", + "main": "progress-bar.js", + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/iarna/gauge" + }, + "keywords": [ + "progressbar", + "progress", + "gauge" + ], + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "license": "ISC", + "bugs": { + "url": "https://github.com/iarna/gauge/issues" + }, + "homepage": "https://github.com/iarna/gauge", + "dependencies": { + "ansi": "^0.3.0", + "has-unicode": "^1.0.0", + "lodash.pad": "^3.0.0", + "lodash.padleft": "^3.0.0", + "lodash.padright": "^3.0.0" + }, + "devDependencies": { + "tap": "^0.4.13" + }, + "gitHead": "db15c35374816b3fc3b9e1e54866f31ed7f4a733", + "_id": "gauge@1.2.0", + "_shasum": "3094ab1285633f799814388fc8f2de67b4c012c5", + "_from": "gauge@>=1.2.0 <1.3.0", + "_npmVersion": "2.6.0", + "_nodeVersion": "1.1.0", + "_npmUser": { + "name": "iarna", + "email": "me@re-becca.org" + }, + "maintainers": [ + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "dist": { + "shasum": "3094ab1285633f799814388fc8f2de67b4c012c5", + "tarball": "http://registry.npmjs.org/gauge/-/gauge-1.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/gauge/-/gauge-1.2.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js new file mode 100644 index 0000000..39dbf2a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js @@ -0,0 +1,209 @@ +"use strict" +var hasUnicode = require("has-unicode") +var ansi = require("ansi") +var align = { + center: require("lodash.pad"), + left: require("lodash.padright"), + right: require("lodash.padleft") +} +var defaultStream = process.stderr +function isTTY() { + return process.stderr.isTTY +} +function getWritableTTYColumns() { + // One less than the actual as writing to the final column wraps the line + return process.stderr.columns - 1 +} + +var ProgressBar = module.exports = function (options, cursor) { + if (! options) options = {} + if (! cursor && options.write) { + cursor = options + options = {} + } + if (! cursor) { + cursor = ansi(defaultStream) + } + this.cursor = cursor + this.showing = false + this.theme = options.theme || (hasUnicode() ? ProgressBar.unicode : ProgressBar.ascii) + this.template = options.template || [ + {type: "name", separated: true, length: 25}, + {type: "spinner", separated: true}, + {type: "startgroup"}, + {type: "completionbar"}, + {type: "endgroup"} + ] + this.updatefreq = options.maxUpdateFrequency || 50 + this.lastName = "" + this.lastCompleted = 0 + this.spun = 0 + this.last = new Date(0) +} +ProgressBar.prototype = {} + +ProgressBar.unicode = { + startgroup: "╢", + endgroup: "╟", + complete: "█", + incomplete: "░", + spinner: "▀▐▄▌", + subsection: "→" +} + +ProgressBar.ascii = { + startgroup: "|", + endgroup: "|", + complete: "#", + incomplete: "-", + spinner: "-\\|/", + subsection: "->" +} + +ProgressBar.prototype.setTheme = function(theme) { + this.theme = theme +} + +ProgressBar.prototype.setTemplate = function(template) { + this.template = template +} + +ProgressBar.prototype.disable = function() { + this.hide() + this.disabled = true +} + +ProgressBar.prototype.enable = function() { + this.disabled = false + this.show() +} + +ProgressBar.prototype.hide = function() { + if (!isTTY()) return + if (this.disabled) return + this.cursor.show() + if (this.showing) this.cursor.up(1) + this.cursor.horizontalAbsolute(0).eraseLine() + this.showing = false +} + +var repeat = function (str, count) { + var out = "" + for (var ii=0; ii P | |----|\n' ], + [ 'show' ] ]) +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/package.json new file mode 100644 index 0000000..da9bcd6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/package.json @@ -0,0 +1,57 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "name": "npmlog", + "description": "logger for npm", + "version": "1.2.0", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/npmlog.git" + }, + "main": "log.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": { + "ansi": "~0.3.0", + "are-we-there-yet": "~1.0.0", + "gauge": "~1.2.0" + }, + "devDependencies": { + "tap": "" + }, + "license": "BSD", + "gitHead": "1fe2892a8b9dacb775d4fb365315865f421f4ca9", + "bugs": { + "url": "https://github.com/isaacs/npmlog/issues" + }, + "homepage": "https://github.com/isaacs/npmlog", + "_id": "npmlog@1.2.0", + "_shasum": "b512f18ae8696a0192ada78ba00c06dbbd91bafb", + "_from": "npmlog@>=1.2.0 <1.3.0", + "_npmVersion": "2.6.0", + "_nodeVersion": "1.1.0", + "_npmUser": { + "name": "iarna", + "email": "me@re-becca.org" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "dist": { + "shasum": "b512f18ae8696a0192ada78ba00c06dbbd91bafb", + "tarball": "http://registry.npmjs.org/npmlog/-/npmlog-1.2.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.0.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/basic.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/basic.js new file mode 100644 index 0000000..1afcabd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/basic.js @@ -0,0 +1,228 @@ +var tap = require('tap') +var log = require('../') + +var result = [] +var logEvents = [] +var logInfoEvents = [] +var logPrefixEvents = [] + +var util = require('util') + +var resultExpect = +[ '\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[7msill\u001b[0m \u001b[0m\u001b[35msilly prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[34m\u001b[40mverb\u001b[0m \u001b[0m\u001b[35mverbose prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[32minfo\u001b[0m \u001b[0m\u001b[35minfo prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[32m\u001b[40mhttp\u001b[0m \u001b[0m\u001b[35mhttp prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[30m\u001b[43mWARN\u001b[0m \u001b[0m\u001b[35mwarn prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35merror prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[32minfo\u001b[0m \u001b[0m\u001b[35minfo prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[32m\u001b[40mhttp\u001b[0m \u001b[0m\u001b[35mhttp prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[30m\u001b[43mWARN\u001b[0m \u001b[0m\u001b[35mwarn prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35merror prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m This is a longer\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m message, with some details\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m and maybe a stack.\n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m \n', + '\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u0007noise\u001b[0m\u001b[35m\u001b[0m LOUD NOISES\n', + '\u001b[0m' ] + +var logPrefixEventsExpect = +[ { id: 2, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 9, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 16, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] } ] + +// should be the same. +var logInfoEventsExpect = logPrefixEventsExpect + +var logEventsExpect = +[ { id: 0, + level: 'silly', + prefix: 'silly prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 1, + level: 'verbose', + prefix: 'verbose prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 2, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 3, + level: 'http', + prefix: 'http prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 4, + level: 'warn', + prefix: 'warn prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 5, + level: 'error', + prefix: 'error prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 6, + level: 'silent', + prefix: 'silent prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 7, + level: 'silly', + prefix: 'silly prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 8, + level: 'verbose', + prefix: 'verbose prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 9, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 10, + level: 'http', + prefix: 'http prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 11, + level: 'warn', + prefix: 'warn prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 12, + level: 'error', + prefix: 'error prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 13, + level: 'silent', + prefix: 'silent prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 14, + level: 'silly', + prefix: 'silly prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 15, + level: 'verbose', + prefix: 'verbose prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 16, + level: 'info', + prefix: 'info prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 17, + level: 'http', + prefix: 'http prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 18, + level: 'warn', + prefix: 'warn prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 19, + level: 'error', + prefix: 'error prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 20, + level: 'silent', + prefix: 'silent prefix', + message: 'x = {"foo":{"bar":"baz"}}', + messageRaw: [ 'x = %j', { foo: { bar: 'baz' } } ] }, + { id: 21, + level: 'error', + prefix: '404', + message: 'This is a longer\nmessage, with some details\nand maybe a stack.\n', + messageRaw: [ 'This is a longer\nmessage, with some details\nand maybe a stack.\n' ] }, + { id: 22, + level: 'noise', + prefix: false, + message: 'LOUD NOISES', + messageRaw: [ 'LOUD NOISES' ] } ] + +var Stream = require('stream').Stream +var s = new Stream() +s.write = function (m) { + result.push(m) +} + +s.writable = true +s.isTTY = true +s.end = function () {} + +log.stream = s + +log.heading = 'npm' + + +tap.test('basic', function (t) { + log.on('log', logEvents.push.bind(logEvents)) + log.on('log.info', logInfoEvents.push.bind(logInfoEvents)) + log.on('info prefix', logPrefixEvents.push.bind(logPrefixEvents)) + + console.error('log.level=silly') + log.level = 'silly' + log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) + log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) + log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) + log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) + log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) + log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) + log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) + + console.error('log.level=silent') + log.level = 'silent' + log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) + log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) + log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) + log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) + log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) + log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) + log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) + + console.error('log.level=info') + log.level = 'info' + log.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}}) + log.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}}) + log.info('info prefix', 'x = %j', {foo:{bar:'baz'}}) + log.http('http prefix', 'x = %j', {foo:{bar:'baz'}}) + log.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}}) + log.error('error prefix', 'x = %j', {foo:{bar:'baz'}}) + log.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}}) + log.error('404', 'This is a longer\n'+ + 'message, with some details\n'+ + 'and maybe a stack.\n') + log.addLevel('noise', 10000, {beep: true}) + log.noise(false, 'LOUD NOISES') + + t.deepEqual(result.join('').trim(), resultExpect.join('').trim(), 'result') + t.deepEqual(log.record, logEventsExpect, 'record') + t.deepEqual(logEvents, logEventsExpect, 'logEvents') + t.deepEqual(logInfoEvents, logInfoEventsExpect, 'logInfoEvents') + t.deepEqual(logPrefixEvents, logPrefixEventsExpect, 'logPrefixEvents') + + t.end() +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/progress.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/progress.js new file mode 100644 index 0000000..97b13de --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/npmlog/test/progress.js @@ -0,0 +1,114 @@ +'use strict' + +var test = require('tap').test +var log = require('../log.js') + +var actions = [] +log.gauge = { + enable: function () { + actions.push(['enable']) + }, + disable: function () { + actions.push(['disable']) + }, + hide: function () { + actions.push(['hide']) + }, + show: function (name, completed) { + actions.push(['show', name, completed]) + }, + pulse: function (name) { + actions.push(['pulse', name]) + } +} + +function didActions(t, msg, output) { + var tests = [] + for (var ii = 0; ii < output.length; ++ ii) { + for (var jj = 0; jj < output[ii].length; ++ jj) { + tests.push({cmd: ii, arg: jj}) + } + } + t.is(actions.length, output.length, msg) + tests.forEach(function (test) { + t.is(actions[test.cmd] ? actions[test.cmd][test.arg] : null, + output[test.cmd][test.arg], + msg + ': ' + output[test.cmd] + (test.arg ? ' arg #'+test.arg : '')) + }) + actions = [] +} + + +test('enableProgress', function (t) { + t.plan(6) + log.enableProgress() + didActions(t, 'enableProgress', [ [ 'enable' ], [ 'show', undefined, 0 ] ]) + log.enableProgress() + didActions(t, 'enableProgress again', []) +}) + +test('disableProgress', function (t) { + t.plan(4) + log.disableProgress() + didActions(t, 'disableProgress', [ [ 'hide' ], [ 'disable' ] ]) + log.disableProgress() + didActions(t, 'disableProgress again', []) +}) + +test('showProgress', function (t) { + t.plan(5) + log.showProgress('foo') + didActions(t, 'showProgress disabled', []) + log.enableProgress() + actions = [] + log.showProgress('foo') + didActions(t, 'showProgress', [ [ 'show', 'foo', 0 ] ]) +}) + +test('clearProgress', function (t) { + t.plan(3) + log.clearProgress() + didActions(t, 'clearProgress', [ [ 'hide' ] ]) + log.disableProgress() + actions = [] + log.clearProgress() + didActions(t, 'clearProgress disabled', [ ]) +}) + +test("newItem", function (t) { + t.plan(12) + log.enableProgress() + actions = [] + var a = log.newItem("test", 10) + didActions(t, "newItem", [ [ 'show', undefined, 0 ] ]) + a.completeWork(5) + didActions(t, "newItem:completeWork", [ [ 'show', 'test', 0.5 ] ]) + a.finish() + didActions(t, "newItem:finish", [ [ 'show', 'test', 1 ] ]) +}) + +// test that log objects proxy through. And test that completion status filters up +test("newGroup", function (t) { + t.plan(23) + var a = log.newGroup("newGroup") + didActions(t, "newGroup", [ [ 'show', undefined, 0.5 ] ]) + a.warn("test", "this is a test") + didActions(t, "newGroup:warn", [ [ 'pulse', 'test' ], [ 'hide' ], [ 'show', undefined, 0.5 ] ]) + var b = a.newItem("newGroup2", 10) + didActions(t, "newGroup:newItem", [ [ 'show', 'newGroup', 0.5 ] ]) + b.completeWork(5) + didActions(t, "newGroup:completeWork", [ [ 'show', 'newGroup2', 0.75 ] ]) + a.finish() + didActions(t, "newGroup:finish", [ [ 'show', 'newGroup', 1 ] ]) +}) + +test("newStream", function (t) { + t.plan(13) + var a = log.newStream("newStream", 10) + didActions(t, "newStream", [ [ 'show', undefined, 0.6666666666666666 ] ]) + a.write("abcde") + didActions(t, "newStream", [ [ 'show', 'newStream', 0.8333333333333333 ] ]) + a.write("fghij") + didActions(t, "newStream", [ [ 'show', 'newStream', 1 ] ]) + t.is(log.tracker.completed(), 1, "Overall completion") +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/.npmignore new file mode 100644 index 0000000..13abef4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/.npmignore @@ -0,0 +1,3 @@ +node_modules +node_modules/* +npm_debug.log diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.APACHE2 b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.APACHE2 new file mode 100644 index 0000000..6366c04 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.APACHE2 @@ -0,0 +1,15 @@ +Apache License, Version 2.0 + +Copyright (c) 2011 Dominic Tarr + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.BSD b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.BSD new file mode 100644 index 0000000..96bb796 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.BSD @@ -0,0 +1,26 @@ +Copyright (c) 2013, Dominic Tarr +All rights reserved. + +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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.MIT b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.MIT new file mode 100644 index 0000000..6eafbd7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/LICENSE.MIT @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/README.md new file mode 100644 index 0000000..61e728b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/README.md @@ -0,0 +1,149 @@ +# rc + +The non-configurable configuration loader for lazy people. + +## Usage + +The only option is to pass rc the name of your app, and your default configuration. + +```javascript +var conf = require('rc')(appname, { + //defaults go here. + port: 2468, + + //defaults which are objects will be merged, not replaced + views: { + engine: 'jade' + } +}); +``` + +`rc` will return your configuration options merged with the defaults you specify. +If you pass in a predefined defaults object, it will be mutated: + +```javascript +var conf = {}; +require('rc')(appname, conf); +``` + +If `rc` finds any config files for your app, the returned config object will have +a `configs` array containing their paths: + +```javascript +var appCfg = require('rc')(appname, conf); +appCfg.configs[0] // /etc/appnamerc +appCfg.configs[1] // /home/dominictarr/.config/appname +appCfg.config // same as appCfg.configs[appCfg.configs.length - 1] +``` + +## Standards + +Given your application name (`appname`), rc will look in all the obvious places for configuration. + + * command line arguments (parsed by minimist) + * environment variables prefixed with `${appname}_` + * or use "\_\_" to indicate nested properties _(e.g. `appname_foo__bar__baz` => `foo.bar.baz`)_ + * if you passed an option `--config file` then from that file + * a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc. + * `$HOME/.${appname}rc` + * `$HOME/.${appname}/config` + * `$HOME/.config/${appname}` + * `$HOME/.config/${appname}/config` + * `/etc/${appname}rc` + * `/etc/${appname}/config` + * the defaults object you passed in. + +All configuration sources that were found will be flattened into one object, +so that sources **earlier** in this list override later ones. + + +## Configuration File Formats + +Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. The example configurations below are equivalent: + + +#### Formatted as `ini` + +``` +; You can include comments in `ini` format if you want. + +dependsOn=0.10.0 + + +; `rc` has built-in support for ini sections, see? + +[commands] + www = ./commands/www + console = ./commands/repl + + +; You can even do nested sections + +[generators.options] + engine = ejs + +[generators.modules] + new = generate-new + engine = generate-backend + +``` + +#### Formatted as `json` + +```json +{ + // You can even comment your JSON, if you want + "dependsOn": "0.10.0", + "commands": { + "www": "./commands/www", + "console": "./commands/repl" + }, + "generators": { + "options": { + "engine": "ejs" + }, + "modules": { + "new": "generate-new", + "backend": "generate-backend" + } + } +} +``` + +Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments). + +> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings. + + + +## Advanced Usage + +#### Pass in your own `argv` + +You may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12). + +```javascript +require('rc')(appname, defaults, customArgvParser); +``` + +## Pass in your own parser + +If you have a special need to use a non-standard parser, +you can do so by passing in the parser as the 4th argument. +(leave the 3rd as null to get the default args parser) + +```javascript +require('rc')(appname, defaults, null, parser); +``` + +This may also be used to force a more strict format, +such as strict, valid JSON only. + +## Note on Performance + +`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler) + + +## License + +BSD / MIT / Apache2 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/browser.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/browser.js new file mode 100644 index 0000000..8c230c5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/browser.js @@ -0,0 +1,7 @@ + +// when this is loaded into the browser, +// just use the defaults... + +module.exports = function (name, defaults) { + return defaults +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/index.js new file mode 100755 index 0000000..31fb515 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/index.js @@ -0,0 +1,60 @@ +#! /usr/bin/env node +var cc = require('./lib/utils') +var join = require('path').join +var deepExtend = require('deep-extend') +var etc = '/etc' +var win = process.platform === "win32" +var home = win + ? process.env.USERPROFILE + : process.env.HOME + +module.exports = function (name, defaults, argv, parse) { + if('string' !== typeof name) + throw new Error('rc(name): name *must* be string') + if(!argv) + argv = require('minimist')(process.argv.slice(2)) + defaults = ( + 'string' === typeof defaults + ? cc.json(defaults) : defaults + ) || {} + + parse = parse || cc.parse + + var env = cc.env(name + '_') + + var configs = [defaults] + var configFiles = [] + function addConfigFile (file) { + if (configFiles.indexOf(file) >= 0) return + var fileConfig = cc.file(file) + if (fileConfig) { + configs.push(parse(fileConfig)) + configFiles.push(file) + } + } + + // which files do we look at? + if (!win) + [join(etc, name, 'config'), + join(etc, name + 'rc')].forEach(addConfigFile) + if (home) + [join(home, '.config', name, 'config'), + join(home, '.config', name), + join(home, '.' + name, 'config'), + join(home, '.' + name + 'rc')].forEach(addConfigFile) + addConfigFile(cc.find('.'+name+'rc')) + if (env.config) addConfigFile(env.config) + if (argv.config) addConfigFile(argv.config) + + return deepExtend.apply(null, configs.concat([ + env, + argv, + configFiles.length ? {configs: configFiles, config: configFiles[configFiles.length - 1]} : null, + ])) +} + +if(!module.parent) { + console.log( + JSON.stringify(module.exports(process.argv[2]), false, 2) + ) +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/lib/utils.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/lib/utils.js new file mode 100644 index 0000000..e65e7ec --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/lib/utils.js @@ -0,0 +1,101 @@ +var fs = require('fs') +var ini = require('ini') +var path = require('path') +var stripJsonComments = require('strip-json-comments') + +var parse = exports.parse = function (content, file) { + + //if it ends in .json or starts with { then it must be json. + //must be done this way, because ini accepts everything. + //can't just try and parse it and let it throw if it's not ini. + //everything is ini. even json with a systax error. + + if((file && /\.json$/.test(file)) || /^\s*{/.test(content)) + return JSON.parse(stripJsonComments(content)) + return ini.parse(content) + +} + +var file = exports.file = function () { + var args = [].slice.call(arguments).filter(function (arg) { return arg != null }) + + //path.join breaks if it's a not a string, so just skip this. + for(var i in args) + if('string' !== typeof args[i]) + return + + var file = path.join.apply(null, args) + var content + try { + return fs.readFileSync(file,'utf-8') + } catch (err) { + return + } +} + +var json = exports.json = function () { + var content = file.apply(null, arguments) + return content ? parse(content) : null +} + +var env = exports.env = function (prefix, env) { + env = env || process.env + var obj = {} + var l = prefix.length + for(var k in env) { + if((k.indexOf(prefix)) === 0) { + + var keypath = k.substring(l).split('__') + + // Trim empty strings from keypath array + var _emptyStringIndex + while ((_emptyStringIndex=keypath.indexOf('')) > -1) { + keypath.splice(_emptyStringIndex, 1) + } + + var cursor = obj + keypath.forEach(function _buildSubObj(_subkey,i){ + + // (check for _subkey first so we ignore empty strings) + if (!_subkey) + return + + // If this is the last key, just stuff the value in there + // Assigns actual value from env variable to final key + // (unless it's just an empty string- in that case use the last valid key) + if (i === keypath.length-1) + cursor[_subkey] = env[k] + + + // Build sub-object if nothing already exists at the keypath + if (cursor[_subkey] === undefined) + cursor[_subkey] = {} + + // Increment cursor used to track the object at the current depth + cursor = cursor[_subkey] + + }) + + } + + } + + return obj +} + +var find = exports.find = function () { + var rel = path.join.apply(null, [].slice.call(arguments)) + + function find(start, rel) { + var file = path.join(start, rel) + try { + fs.statSync(file) + return file + } catch (err) { + if(path.dirname(start) !== start) // root + return find(path.dirname(start), rel) + } + } + return find(process.cwd(), rel) +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/LICENSE new file mode 100644 index 0000000..e950236 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Viacheslav Lotsmanov + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/README.md new file mode 100644 index 0000000..0457c52 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/README.md @@ -0,0 +1,52 @@ +Node.JS module “Deep Extend” +============================ + +Recursive object extending. + +Install +----- + + npm install deep-extend + +Usage +----- + + var deepExtend = require('deep-extend'); + var obj1 = { + a: 1, + b: 2, + d: { + a: 1, + b: [], + c: { test1: 123, test2: 321 } + }, + f: 5, + g: 123 + }; + var obj2 = { + b: 3, + c: 5, + d: { + b: { first: 'one', second: 'two' }, + c: { test2: 222 } + }, + e: { one: 1, two: 2 }, + f: [], + g: (void 0) + }; + + deepExtend(obj1, obj2); + + console.log(obj1); + /* + { a: 1, + b: 3, + d: + { a: 1, + b: { first: 'one', second: 'two' }, + c: { test1: 123, test2: 222 } }, + f: [], + c: 5, + e: { one: 1, two: 2 }, + g: undefined } + */ diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/index.js new file mode 100644 index 0000000..c1f8dae --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/index.js @@ -0,0 +1,90 @@ +/*! + * Node.JS module "Deep Extend" + * @description Recursive object extending. + * @author Viacheslav Lotsmanov (unclechu) + * @license MIT + * + * The MIT License (MIT) + * + * Copyright (c) 2013 Viacheslav Lotsmanov + * + * 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. + */ + +/** + * Extening object that entered in first argument. + * Returns extended object or false if have no target object or incorrect type. + * If you wish to clone object, simply use that: + * deepExtend({}, yourObj_1, [yourObj_N]) - first arg is new empty object + */ +var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) { + if (arguments.length < 1 || typeof arguments[0] !== 'object') { + return false; + } + + if (arguments.length < 2) return arguments[0]; + + var target = arguments[0]; + + // convert arguments to array and cut off target object + var args = Array.prototype.slice.call(arguments, 1); + + var key, val, src, clone, tmpBuf; + + args.forEach(function (obj) { + if (typeof obj !== 'object') return; + + for (key in obj) { + if ( ! (key in obj)) continue; + + src = target[key]; + val = obj[key]; + + if (val === target) continue; + + if (typeof val !== 'object' || val === null) { + target[key] = val; + continue; + } else if (val instanceof Buffer) { + tmpBuf = new Buffer(val.length); + val.copy(tmpBuf); + target[key] = tmpBuf; + continue; + } else if (val instanceof Date) { + target[key] = new Date(val.getTime()); + continue; + } + + if (typeof src !== 'object' || src === null) { + clone = (Array.isArray(val)) ? [] : {}; + target[key] = deepExtend(clone, val); + continue; + } + + if (Array.isArray(val)) { + clone = (Array.isArray(src)) ? src : []; + } else { + clone = (!Array.isArray(src)) ? src : {}; + } + + target[key] = deepExtend(clone, val); + } + }); + + return target; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/package.json new file mode 100644 index 0000000..4affa15 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/package.json @@ -0,0 +1,58 @@ +{ + "name": "deep-extend", + "description": "Recursive object extending.", + "license": "MIT", + "version": "0.2.11", + "homepage": "https://github.com/unclechu/node-deep-extend", + "repository": { + "type": "git", + "url": "git://github.com/unclechu/node-deep-extend.git" + }, + "author": { + "name": "Viacheslav Lotsmanov", + "email": "lotsmanov89@gmail.com", + "url": "unclechu" + }, + "contributors": [ + { + "name": "Romain Prieto", + "url": "https://github.com/rprieto" + } + ], + "main": "index", + "engines": { + "node": ">=0.4" + }, + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "mocha": "~1.19.0", + "should": "~3.3.2" + }, + "directories": { + "test": "./test" + }, + "bugs": { + "url": "https://github.com/unclechu/node-deep-extend/issues" + }, + "_id": "deep-extend@0.2.11", + "dist": { + "shasum": "7a16ba69729132340506170494bc83f7076fe08f", + "tarball": "http://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz" + }, + "_from": "deep-extend@>=0.2.5 <0.3.0", + "_npmVersion": "1.4.6", + "_npmUser": { + "name": "unclechu", + "email": "lotsmanov89@gmail.com" + }, + "maintainers": [ + { + "name": "unclechu", + "email": "lotsmanov89@gmail.com" + } + ], + "_shasum": "7a16ba69729132340506170494bc83f7076fe08f", + "_resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/index.spec.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/index.spec.js new file mode 100644 index 0000000..38974a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/index.spec.js @@ -0,0 +1,57 @@ +var should = require('should'); +var extend = require('../index'); + +describe('deep-extend', function() { + + it('can extend on 1 level', function() { + var a = { hello: 1 }; + var b = { world: 2 }; + extend(a, b); + a.should.eql({ + hello: 1, + world: 2 + }); + }); + + it('can extend on 2 levels', function() { + var a = { person: { name: 'John' } }; + var b = { person: { age: 30 } }; + extend(a, b); + a.should.eql({ + person: { name: 'John', age: 30 } + }); + }); + + it('can extend with Buffer values', function() { + var a = { hello: 1 }; + var b = { value: new Buffer('world') }; + extend(a, b); + a.should.eql({ + hello: 1, + value: new Buffer('world') + }); + }); + + it('Buffer is cloned', function () { + var a = { }; + var b = { value: new Buffer('foo') }; + extend(a, b); + a.value.write('bar'); + a.value.toString().should.eql('bar'); + b.value.toString().should.eql('foo'); + }); + + it('Date objects', function () { + var a = { d: new Date() }; + var b = extend({}, a); + b.d.should.instanceOf(Date); + }); + + it('Date object is cloned', function () { + var a = { d: new Date() }; + var b = extend({}, a); + b.d.setTime( (new Date()).getTime() + 100000 ); + b.d.getTime().should.not.eql( a.d.getTime() ); + }); + +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/mocha.opts b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/mocha.opts new file mode 100644 index 0000000..5ada47b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/test/mocha.opts @@ -0,0 +1 @@ +--reporter spec diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/LICENSE new file mode 100644 index 0000000..19129e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/LICENSE @@ -0,0 +1,15 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/README.md new file mode 100644 index 0000000..33df258 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/README.md @@ -0,0 +1,102 @@ +An ini format parser and serializer for node. + +Sections are treated as nested objects. Items before the first +heading are saved on the object directly. + +## Usage + +Consider an ini-file `config.ini` that looks like this: + + ; this comment is being ignored + scope = global + + [database] + user = dbuser + password = dbpassword + database = use_this_database + + [paths.default] + datadir = /var/lib/data + array[] = first value + array[] = second value + array[] = third value + +You can read, manipulate and write the ini-file like so: + + var fs = require('fs') + , ini = require('ini') + + var config = ini.parse(fs.readFileSync('./config.ini', 'utf-8')) + + config.scope = 'local' + config.database.database = 'use_another_database' + config.paths.default.tmpdir = '/tmp' + delete config.paths.default.datadir + config.paths.default.array.push('fourth value') + + fs.writeFileSync('./config_modified.ini', ini.stringify(config, { section: 'section' })) + +This will result in a file called `config_modified.ini` being written +to the filesystem with the following content: + + [section] + scope=local + [section.database] + user=dbuser + password=dbpassword + database=use_another_database + [section.paths.default] + tmpdir=/tmp + array[]=first value + array[]=second value + array[]=third value + array[]=fourth value + + +## API + +### decode(inistring) + +Decode the ini-style formatted `inistring` into a nested object. + +### parse(inistring) + +Alias for `decode(inistring)` + +### encode(object, [options]) + +Encode the object `object` into an ini-style formatted string. If the +optional parameter `section` is given, then all top-level properties +of the object are put into this section and the `section`-string is +prepended to all sub-sections, see the usage example above. + +The `options` object may contain the following: + +* `section` A string which will be the first `section` in the encoded + ini data. Defaults to none. +* `whitespace` Boolean to specify whether to put whitespace around the + `=` character. By default, whitespace is omitted, to be friendly to + some persnickety old parsers that don't tolerate it well. But some + find that it's more human-readable and pretty with the whitespace. + +For backwards compatibility reasons, if a `string` options is passed +in, then it is assumed to be the `section` value. + +### stringify(object, [options]) + +Alias for `encode(object, [options])` + +### safe(val) + +Escapes the string `val` such that it is safe to be used as a key or +value in an ini-file. Basically escapes quotes. For example + + ini.safe('"unsafe string"') + +would result in + + "\"unsafe string\"" + +### unsafe(val) + +Unescapes the string `val` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/ini.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/ini.js new file mode 100644 index 0000000..ddf5bd9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/ini.js @@ -0,0 +1,190 @@ + +exports.parse = exports.decode = decode +exports.stringify = exports.encode = encode + +exports.safe = safe +exports.unsafe = unsafe + +var eol = process.platform === "win32" ? "\r\n" : "\n" + +function encode (obj, opt) { + var children = [] + , out = "" + + if (typeof opt === "string") { + opt = { + section: opt, + whitespace: false + } + } else { + opt = opt || {} + opt.whitespace = opt.whitespace === true + } + + var separator = opt.whitespace ? " = " : "=" + + Object.keys(obj).forEach(function (k, _, __) { + var val = obj[k] + if (val && Array.isArray(val)) { + val.forEach(function(item) { + out += safe(k + "[]") + separator + safe(item) + "\n" + }) + } + else if (val && typeof val === "object") { + children.push(k) + } else { + out += safe(k) + separator + safe(val) + eol + } + }) + + if (opt.section && out.length) { + out = "[" + safe(opt.section) + "]" + eol + out + } + + children.forEach(function (k, _, __) { + var nk = dotSplit(k).join('\\.') + var section = (opt.section ? opt.section + "." : "") + nk + var child = encode(obj[k], { + section: section, + whitespace: opt.whitespace + }) + if (out.length && child.length) { + out += eol + } + out += child + }) + + return out +} + +function dotSplit (str) { + return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002') + .replace(/\\\./g, '\u0001') + .split(/\./).map(function (part) { + return part.replace(/\1/g, '\\.') + .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') + }) +} + +function decode (str) { + var out = {} + , p = out + , section = null + , state = "START" + // section |key = value + , re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i + , lines = str.split(/[\r\n]+/g) + , section = null + + lines.forEach(function (line, _, __) { + if (!line || line.match(/^\s*[;#]/)) return + var match = line.match(re) + if (!match) return + if (match[1] !== undefined) { + section = unsafe(match[1]) + p = out[section] = out[section] || {} + return + } + var key = unsafe(match[2]) + , value = match[3] ? unsafe((match[4] || "")) : true + switch (value) { + case 'true': + case 'false': + case 'null': value = JSON.parse(value) + } + + // Convert keys with '[]' suffix to an array + if (key.length > 2 && key.slice(-2) === "[]") { + key = key.substring(0, key.length - 2) + if (!p[key]) { + p[key] = [] + } + else if (!Array.isArray(p[key])) { + p[key] = [p[key]] + } + } + + // safeguard against resetting a previously defined + // array by accidentally forgetting the brackets + if (Array.isArray(p[key])) { + p[key].push(value) + } + else { + p[key] = value + } + }) + + // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} + // use a filter to return the keys that have to be deleted. + Object.keys(out).filter(function (k, _, __) { + if (!out[k] || typeof out[k] !== "object" || Array.isArray(out[k])) return false + // see if the parent section is also an object. + // if so, add it to that, and mark this one for deletion + var parts = dotSplit(k) + , p = out + , l = parts.pop() + , nl = l.replace(/\\\./g, '.') + parts.forEach(function (part, _, __) { + if (!p[part] || typeof p[part] !== "object") p[part] = {} + p = p[part] + }) + if (p === out && nl === l) return false + p[nl] = out[k] + return true + }).forEach(function (del, _, __) { + delete out[del] + }) + + return out +} + +function isQuoted (val) { + return (val.charAt(0) === "\"" && val.slice(-1) === "\"") + || (val.charAt(0) === "'" && val.slice(-1) === "'") +} + +function safe (val) { + return ( typeof val !== "string" + || val.match(/[=\r\n]/) + || val.match(/^\[/) + || (val.length > 1 + && isQuoted(val)) + || val !== val.trim() ) + ? JSON.stringify(val) + : val.replace(/;/g, '\\;').replace(/#/g, "\\#") +} + +function unsafe (val, doUnesc) { + val = (val || "").trim() + if (isQuoted(val)) { + // remove the single quotes before calling JSON.parse + if (val.charAt(0) === "'") { + val = val.substr(1, val.length - 2); + } + try { val = JSON.parse(val) } catch (_) {} + } else { + // walk the val to find the first not-escaped ; character + var esc = false + var unesc = ""; + for (var i = 0, l = val.length; i < l; i++) { + var c = val.charAt(i) + if (esc) { + if ("\\;#".indexOf(c) !== -1) + unesc += c + else + unesc += "\\" + c + esc = false + } else if (";#".indexOf(c) !== -1) { + break + } else if (c === "\\") { + esc = true + } else { + unesc += c + } + } + if (esc) + unesc += "\\" + return unesc + } + return val +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/package.json new file mode 100644 index 0000000..2fa68a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/package.json @@ -0,0 +1,52 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "name": "ini", + "description": "An ini encoder/decoder for node", + "version": "1.3.3", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/ini.git" + }, + "main": "ini.js", + "scripts": { + "test": "tap test/*.js" + }, + "engines": { + "node": "*" + }, + "dependencies": {}, + "devDependencies": { + "tap": "~0.4.0" + }, + "license": "ISC", + "gitHead": "566268f1fb8dd3c0f7d968091de7b7fb2b97b483", + "bugs": { + "url": "https://github.com/isaacs/ini/issues" + }, + "homepage": "https://github.com/isaacs/ini", + "_id": "ini@1.3.3", + "_shasum": "c07e34aef1de06aff21d413b458e52b21533a11e", + "_from": "ini@>=1.3.0 <1.4.0", + "_npmVersion": "2.5.1", + "_nodeVersion": "1.1.0", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "dist": { + "shasum": "c07e34aef1de06aff21d413b458e52b21533a11e", + "tarball": "http://registry.npmjs.org/ini/-/ini-1.3.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ini/-/ini-1.3.3.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/bar.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/bar.js new file mode 100644 index 0000000..cb16176 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/bar.js @@ -0,0 +1,23 @@ +//test that parse(stringify(obj) deepEqu + +var ini = require('../') +var test = require('tap').test + +var data = { + 'number': {count: 10}, + 'string': {drink: 'white russian'}, + 'boolean': {isTrue: true}, + 'nested boolean': {theDude: {abides: true, rugCount: 1}} +} + + +test('parse(stringify(x)) deepEqual x', function (t) { + + for (var k in data) { + var s = ini.stringify(data[k]) + console.log(s, data[k]) + t.deepEqual(ini.parse(s), data[k]) + } + + t.end() +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/fixtures/foo.ini b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/fixtures/foo.ini new file mode 100644 index 0000000..fc2080f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/fixtures/foo.ini @@ -0,0 +1,65 @@ +o = p + + a with spaces = b c + +; wrap in quotes to JSON-decode and preserve spaces +" xa n p " = "\"\r\nyoyoyo\r\r\n" + +; wrap in quotes to get a key with a bracket, not a section. +"[disturbing]" = hey you never know + +; Test single quotes +s = 'something' + +; Test mixing quotes + +s1 = "something' + +; Test double quotes +s2 = "something else" + +; Test arrays +zr[] = deedee +ar[] = one +ar[] = three +; This should be included in the array +ar = this is included + +; Test resetting of a value (and not turn it into an array) +br = cold +br = warm + +eq = "eq=eq" + +; a section +[a] +av = a val +e = { o: p, a: { av: a val, b: { c: { e: "this [value]" } } } } +j = "{ o: "p", a: { av: "a val", b: { c: { e: "this [value]" } } } }" +"[]" = a square? + +; Nested array +cr[] = four +cr[] = eight + +; nested child without middle parent +; should create otherwise-empty a.b +[a.b.c] +e = 1 +j = 2 + +; dots in the section name should be literally interpreted +[x\.y\.z] +x.y.z = xyz + +[x\.y\.z.a\.b\.c] +a.b.c = abc + +; this next one is not a comment! it's escaped! +nocomment = this\; this is not a comment + +# Support the use of the number sign (#) as an alternative to the semicolon for indicating comments. +# http://en.wikipedia.org/wiki/INI_file#Comments + +# this next one is not a comment! it's escaped! +noHashComment = this\# this is not a comment diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/foo.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/foo.js new file mode 100644 index 0000000..58102d1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/ini/test/foo.js @@ -0,0 +1,107 @@ +var i = require("../") + , tap = require("tap") + , test = tap.test + , fs = require("fs") + , path = require("path") + , fixture = path.resolve(__dirname, "./fixtures/foo.ini") + , data = fs.readFileSync(fixture, "utf8") + , d + , expectE = 'o=p\n' + + 'a with spaces=b c\n' + + '" xa n p "="\\"\\r\\nyoyoyo\\r\\r\\n"\n' + + '"[disturbing]"=hey you never know\n' + + 's=something\n' + + 's1=\"something\'\n' + + 's2=something else\n' + + 'zr[]=deedee\n' + + 'ar[]=one\n' + + 'ar[]=three\n' + + 'ar[]=this is included\n' + + 'br=warm\n' + + 'eq=\"eq=eq\"\n' + + '\n' + + '[a]\n' + + 'av=a val\n' + + 'e={ o: p, a: ' + + '{ av: a val, b: { c: { e: "this [value]" ' + + '} } } }\nj="\\"{ o: \\"p\\", a: { av:' + + ' \\"a val\\", b: { c: { e: \\"this [value]' + + '\\" } } } }\\""\n"[]"=a square?\n' + + 'cr[]=four\ncr[]=eight\n\n' + +'[a.b.c]\ne=1\n' + + 'j=2\n\n[x\\.y\\.z]\nx.y.z=xyz\n\n' + + '[x\\.y\\.z.a\\.b\\.c]\na.b.c=abc\n' + + 'nocomment=this\\; this is not a comment\n' + + 'noHashComment=this\\# this is not a comment\n' + , expectD = + { o: 'p', + 'a with spaces': 'b c', + " xa n p ":'"\r\nyoyoyo\r\r\n', + '[disturbing]': 'hey you never know', + 's': 'something', + 's1' : '\"something\'', + 's2': 'something else', + 'zr': ['deedee'], + 'ar': ['one', 'three', 'this is included'], + 'br': 'warm', + 'eq': 'eq=eq', + a: + { av: 'a val', + e: '{ o: p, a: { av: a val, b: { c: { e: "this [value]" } } } }', + j: '"{ o: "p", a: { av: "a val", b: { c: { e: "this [value]" } } } }"', + "[]": "a square?", + cr: ['four', 'eight'], + b: { c: { e: '1', j: '2' } } }, + 'x.y.z': { + 'x.y.z': 'xyz', + 'a.b.c': { + 'a.b.c': 'abc', + 'nocomment': 'this\; this is not a comment', + noHashComment: 'this\# this is not a comment' + } + } + } + , expectF = '[prefix.log]\n' + + 'type=file\n\n' + + '[prefix.log.level]\n' + + 'label=debug\n' + + 'value=10\n' + , expectG = '[log]\n' + + 'type = file\n\n' + + '[log.level]\n' + + 'label = debug\n' + + 'value = 10\n' + +test("decode from file", function (t) { + var d = i.decode(data) + t.deepEqual(d, expectD) + t.end() +}) + +test("encode from data", function (t) { + var e = i.encode(expectD) + t.deepEqual(e, expectE) + + var obj = {log: { type:'file', level: {label:'debug', value:10} } } + e = i.encode(obj) + t.notEqual(e.slice(0, 1), '\n', 'Never a blank first line') + t.notEqual(e.slice(-2), '\n\n', 'Never a blank final line') + + t.end() +}) + +test("encode with option", function (t) { + var obj = {log: { type:'file', level: {label:'debug', value:10} } } + e = i.encode(obj, {section: 'prefix'}) + + t.equal(e, expectF) + t.end() +}) + +test("encode with whitespace", function (t) { + var obj = {log: { type:'file', level: {label:'debug', value:10} } } + e = i.encode(obj, {whitespace: true}) + + t.equal(e, expectG) + t.end() +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/.travis.yml new file mode 100644 index 0000000..cc4dba2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/LICENSE new file mode 100644 index 0000000..ee27ba4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/example/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/example/parse.js new file mode 100644 index 0000000..abff3e8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/example/parse.js @@ -0,0 +1,2 @@ +var argv = require('../')(process.argv.slice(2)); +console.dir(argv); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/index.js new file mode 100644 index 0000000..71fb830 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/index.js @@ -0,0 +1,187 @@ +module.exports = function (args, opts) { + if (!opts) opts = {}; + + var flags = { bools : {}, strings : {} }; + + [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { + flags.bools[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; + })); + }); + }); + + [].concat(opts.string).filter(Boolean).forEach(function (key) { + flags.strings[key] = true; + if (aliases[key]) { + flags.strings[aliases[key]] = true; + } + }); + + 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); +} + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/package.json new file mode 100644 index 0000000..b13c34d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/package.json @@ -0,0 +1,67 @@ +{ + "name": "minimist", + "version": "0.0.10", + "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.10", + "dist": { + "shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf", + "tarball": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" + }, + "_from": "minimist@>=0.0.7 <0.1.0", + "_npmVersion": "1.4.3", + "_npmUser": { + "name": "substack", + "email": "mail@substack.net" + }, + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "directories": {}, + "_shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf", + "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/readme.markdown b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/readme.markdown new file mode 100644 index 0000000..c256353 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/readme.markdown @@ -0,0 +1,73 @@ +# minimist + +parse argument options + +This module is the guts of optimist's argument parser without all the +fanciful decoration. + +[](http://ci.testling.com/substack/minimist) + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/bool.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/bool.js new file mode 100644 index 0000000..749e083 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/bool.js @@ -0,0 +1,119 @@ +var parse = require('../'); +var test = require('tape'); + +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('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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dash.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dash.js new file mode 100644 index 0000000..8b034b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dash.js @@ -0,0 +1,24 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/default_bool.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/default_bool.js new file mode 100644 index 0000000..f0041ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/default_bool.js @@ -0,0 +1,20 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dotted.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dotted.js new file mode 100644 index 0000000..d8b3e85 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/dotted.js @@ -0,0 +1,22 @@ +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(); +}); + +test('dotted default with no alias', function (t) { + var argv = parse('', {default: {'a.b': 11}}); + t.equal(argv.a.b, 11); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/long.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/long.js new file mode 100644 index 0000000..5d3a1e0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/long.js @@ -0,0 +1,31 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/num.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/num.js new file mode 100644 index 0000000..2cc77f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/num.js @@ -0,0 +1,36 @@ +var parse = require('../'); +var test = require('tape'); + +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('already a number', function (t) { + var argv = parse([ '-x', 1234, 789 ]); + t.deepEqual(argv, { x : 1234, _ : [ 789 ] }); + t.deepEqual(typeof argv.x, 'number'); + t.deepEqual(typeof argv._[0], 'number'); + t.end(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse.js new file mode 100644 index 0000000..7b4a2a1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse.js @@ -0,0 +1,197 @@ +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('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('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('string and alias', function(t) { + var x = parse([ '--str', '000123' ], { + string: 's', + alias: { s: 'str' } + }); + + t.equal(x.str, '000123'); + t.equal(typeof x.str, 'string'); + t.equal(x.s, '000123'); + t.equal(typeof x.s, 'string'); + + var y = parse([ '-s', '000123' ], { + string: 'str', + alias: { str: 's' } + }); + + t.equal(y.str, '000123'); + t.equal(typeof y.str, 'string'); + t.equal(y.s, '000123'); + t.equal(typeof y.s, 'string'); + 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(); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse_modified.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse_modified.js new file mode 100644 index 0000000..21851b0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/parse_modified.js @@ -0,0 +1,9 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/short.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/short.js new file mode 100644 index 0000000..d513a1c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/short.js @@ -0,0 +1,67 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/whitespace.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/whitespace.js new file mode 100644 index 0000000..8a52a58 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/whitespace.js @@ -0,0 +1,8 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/cli.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/cli.js new file mode 100755 index 0000000..ac4da48 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/cli.js @@ -0,0 +1,41 @@ +#!/usr/bin/env node +'use strict'; +var fs = require('fs'); +var strip = require('./strip-json-comments'); +var input = process.argv[2]; + + +function getStdin(cb) { + var ret = ''; + + process.stdin.setEncoding('utf8'); + + process.stdin.on('data', function (data) { + ret += data; + }); + + process.stdin.on('end', function () { + cb(ret); + }); +} + +if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { + console.log('strip-json-comments > '); + console.log('or'); + console.log('cat | strip-json-comments > '); + return; +} + +if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { + console.log(require('./package').version); + return; +} + +if (input) { + process.stdout.write(strip(fs.readFileSync(input, 'utf8'))); + return; +} + +getStdin(function (data) { + process.stdout.write(strip(data)); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/package.json new file mode 100644 index 0000000..410c4a4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/package.json @@ -0,0 +1,76 @@ +{ + "name": "strip-json-comments", + "version": "0.1.3", + "description": "Strip comments from JSON. Lets you use comments in your JSON files!", + "keywords": [ + "json", + "strip", + "remove", + "delete", + "trim", + "comments", + "multiline", + "parse", + "config", + "configuration", + "conf", + "settings", + "util", + "env", + "environment", + "cli", + "bin" + ], + "license": "MIT", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "files": [ + "cli.js", + "strip-json-comments.js" + ], + "main": "strip-json-comments", + "bin": { + "strip-json-comments": "cli.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/sindresorhus/strip-json-comments" + }, + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">=0.8.0" + }, + "gitHead": "cbd5aede7ccbe5d5a9065b1d47070fd99ad579af", + "bugs": { + "url": "https://github.com/sindresorhus/strip-json-comments/issues" + }, + "homepage": "https://github.com/sindresorhus/strip-json-comments", + "_id": "strip-json-comments@0.1.3", + "_shasum": "164c64e370a8a3cc00c9e01b539e569823f0ee54", + "_from": "strip-json-comments@>=0.1.0 <0.2.0", + "_npmVersion": "1.4.13", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "dist": { + "shasum": "164c64e370a8a3cc00c9e01b539e569823f0ee54", + "tarball": "http://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/readme.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/readme.md new file mode 100644 index 0000000..ad6a178 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/readme.md @@ -0,0 +1,74 @@ +# strip-json-comments [](https://travis-ci.org/sindresorhus/strip-json-comments) + +> Strip comments from JSON. Lets you use comments in your JSON files! + +This is now possible: + +```js +{ + // rainbows + "unicorn": /* ❤ */ "cake" +} +``` + +It will remove single-line comments `//` and mult-line comments `/**/`. + +Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin and a [require hook](https://github.com/uTest/autostrip-json-comments). + + +*There's already [json-comments](https://npmjs.org/package/json-comments), but it's only for Node.js and uses a naive regex to strip comments which fails on simple cases like `{"a":"//"}`. This module however parses out the comments.* + + +## Install + +```sh +$ npm install --save strip-json-comments +``` + +```sh +$ bower install --save strip-json-comments +``` + +```sh +$ component install sindresorhus/strip-json-comments +``` + + +## Usage + +```js +var json = '{/*rainbows*/"unicorn":"cake"}'; +JSON.parse(stripJsonComments(json)); +//=> {unicorn: 'cake'} +``` + + +## API + +### stripJsonComments(input) + +#### input + +Type: `string` + +Accepts a string with JSON and returns a string without comments. + + +## CLI + +```sh +$ npm install --global strip-json-comments +``` + +```sh +$ strip-json-comments --help + +strip-json-comments > +# or +cat | strip-json-comments > +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/strip-json-comments.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/strip-json-comments.js new file mode 100644 index 0000000..2e7fdef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/node_modules/strip-json-comments/strip-json-comments.js @@ -0,0 +1,64 @@ +/*! + strip-json-comments + Strip comments from JSON. Lets you use comments in your JSON files! + https://github.com/sindresorhus/strip-json-comments + by Sindre Sorhus + MIT License +*/ +(function () { + 'use strict'; + + function stripJsonComments(str) { + var currentChar; + var nextChar; + var insideString = false; + var insideComment = false; + var ret = ''; + + for (var i = 0; i < str.length; i++) { + currentChar = str[i]; + nextChar = str[i + 1]; + + if (!insideComment && str[i - 1] !== '\\' && currentChar === '"') { + insideString = !insideString; + } + + if (insideString) { + ret += currentChar; + continue; + } + + if (!insideComment && currentChar + nextChar === '//') { + insideComment = 'single'; + i++; + } else if (insideComment === 'single' && currentChar + nextChar === '\r\n') { + insideComment = false; + i++; + } else if (insideComment === 'single' && currentChar === '\n') { + insideComment = false; + } else if (!insideComment && currentChar + nextChar === '/*') { + insideComment = 'multi'; + i++; + continue; + } else if (insideComment === 'multi' && currentChar + nextChar === '*/') { + insideComment = false; + i++; + continue; + } + + if (insideComment) { + continue; + } + + ret += currentChar; + } + + return ret; + } + + if (typeof module !== 'undefined' && module.exports) { + module.exports = stripJsonComments; + } else { + window.stripJsonComments = stripJsonComments; + } +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/package.json new file mode 100644 index 0000000..7d00ed1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/package.json @@ -0,0 +1,65 @@ +{ + "name": "rc", + "version": "1.0.1", + "description": "hardwired configuration loader", + "main": "index.js", + "browserify": "browser.js", + "scripts": { + "test": "set -e; node test/test.js; node test/ini.js; node test/nested-env-vars.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/dominictarr/rc.git" + }, + "keywords": [ + "config", + "rc", + "unix", + "defaults" + ], + "bin": { + "rc": "./index.js" + }, + "author": { + "name": "Dominic Tarr", + "email": "dominic.tarr@gmail.com", + "url": "dominictarr.com" + }, + "licenses": [ + "BSD", + "MIT", + "Apache2" + ], + "dependencies": { + "minimist": "~0.0.7", + "deep-extend": "~0.2.5", + "strip-json-comments": "0.1.x", + "ini": "~1.3.0" + }, + "gitHead": "e5aec73dfea4ab8dcaba58732e51e1b39991bcd2", + "bugs": { + "url": "https://github.com/dominictarr/rc/issues" + }, + "homepage": "https://github.com/dominictarr/rc", + "_id": "rc@1.0.1", + "_shasum": "f919c25e804cb0aa60f6fd92d929fc86b45013e8", + "_from": "rc@>=1.0.1 <1.1.0", + "_npmVersion": "2.4.1", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "dominictarr", + "email": "dominic.tarr@gmail.com" + }, + "maintainers": [ + { + "name": "dominictarr", + "email": "dominic.tarr@gmail.com" + } + ], + "dist": { + "shasum": "f919c25e804cb0aa60f6fd92d929fc86b45013e8", + "tarball": "http://registry.npmjs.org/rc/-/rc-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/rc/-/rc-1.0.1.tgz" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/ini.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/ini.js new file mode 100644 index 0000000..e6857f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/ini.js @@ -0,0 +1,16 @@ +var cc =require('../lib/utils') +var INI = require('ini') +var assert = require('assert') + +function test(obj) { + + var _json, _ini + var json = cc.parse (_json = JSON.stringify(obj)) + var ini = cc.parse (_ini = INI.stringify(obj)) + console.log(_ini, _json) + assert.deepEqual(json, ini) +} + + +test({hello: true}) + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/nested-env-vars.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/nested-env-vars.js new file mode 100644 index 0000000..314979f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/nested-env-vars.js @@ -0,0 +1,39 @@ + +var n = 'rc'+Math.random() +var assert = require('assert') + + +// Basic usage +process.env[n+'_someOpt__a'] = 42 +process.env[n+'_someOpt__x__'] = 99 +process.env[n+'_someOpt__a__b'] = 186 +process.env[n+'_someOpt__x__y'] = 1862 +process.env[n+'_someOpt__z'] = 186577 + +// Should ignore empty strings from orphaned '__' +process.env[n+'_someOpt__z__x__'] = 18629 +process.env[n+'_someOpt__w__w__'] = 18629 + +// Leading '__' should ignore everything up to 'z' +process.env[n+'___z__i__'] = 9999 + +var config = require('../')(n, { + option: true +}) + +console.log('\n\n------ nested-env-vars ------\n',config) + +assert.equal(config.option, true) +assert.equal(config.someOpt.a, 42) +assert.equal(config.someOpt.x, 99) +// Should not override `a` once it's been set +assert.equal(config.someOpt.a/*.b*/, 42) +// Should not override `x` once it's been set +assert.equal(config.someOpt.x/*.y*/, 99) +assert.equal(config.someOpt.z, 186577) +// Should not override `z` once it's been set +assert.equal(config.someOpt.z/*.x*/, 186577) +assert.equal(config.someOpt.w.w, 18629) +assert.equal(config.z.i, 9999) + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/test.js new file mode 100644 index 0000000..4f63351 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/test/test.js @@ -0,0 +1,59 @@ + +var n = 'rc'+Math.random() +var assert = require('assert') + +process.env[n+'_envOption'] = 42 + +var config = require('../')(n, { + option: true +}) + +console.log(config) + +assert.equal(config.option, true) +assert.equal(config.envOption, 42) + +var customArgv = require('../')(n, { + option: true +}, { // nopt-like argv + option: false, + envOption: 24, + argv: { + remain: [], + cooked: ['--no-option', '--envOption', '24'], + original: ['--no-option', '--envOption=24'] + } +}) + +console.log(customArgv) + +assert.equal(customArgv.option, false) +assert.equal(customArgv.envOption, 24) + +var fs = require('fs') +var path = require('path') +var jsonrc = path.resolve('.' + n + 'rc'); + +fs.writeFileSync(jsonrc, [ + '{', + '// json overrides default', + '"option": false,', + '/* env overrides json */', + '"envOption": 24', + '}' +].join('\n')); + +var commentedJSON = require('../')(n, { + option: true +}) + +fs.unlinkSync(jsonrc); + +console.log(commentedJSON) + +assert.equal(commentedJSON.option, false) +assert.equal(commentedJSON.envOption, 42) + +assert.equal(commentedJSON.config, jsonrc) +assert.equal(commentedJSON.configs.length, 1) +assert.equal(commentedJSON.configs[0], jsonrc) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.eslintrc new file mode 100644 index 0000000..8538b41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.eslintrc @@ -0,0 +1,39 @@ +{ + "env": { + "node": true + }, + "rules": { + // 2-space indentation + "indent": [2, 2], + // Disallow semi-colons, unless needed to disambiguate statement + "semi": [2, "never"], + // Require strings to use single quotes + "quotes": [2, "single"], + // Require curly braces for all control statements + "curly": 2, + // Disallow using variables and functions before they've been defined + "no-use-before-define": 2, + // Allow any case for variable naming + "camelcase": 0, + // Disallow unused variables, except as function arguments + "no-unused-vars": [2, {"args":"none"}], + // Allow leading underscores for method names + // REASON: we use underscores to denote private methods + "no-underscore-dangle": 0, + // Allow multi spaces around operators since they are + // used for alignment. This is not consistent in the + // code. + "no-multi-spaces": 0, + // Style rule is: most objects use { beforeColon: false, afterColon: true }, unless aligning which uses: + // + // { + // beforeColon : true, + // afterColon : true + // } + // + // eslint can't handle this, so the check is disabled. + "key-spacing": 0, + // Allow shadowing vars in outer scope (needs discussion) + "no-shadow": 0 + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.npmignore new file mode 100644 index 0000000..53fc9ef --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.npmignore @@ -0,0 +1,3 @@ +coverage +tests +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.travis.yml new file mode 100644 index 0000000..bd0f638 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +node_js: + - "io.js" + - "0.12" + - "0.10" +after_script: ./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape tests/test-*.js --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js --verbose +webhooks: + urls: https://webhooks.gitter.im/e/237280ed4796c19cc626 + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: false # default: false +sudo: false diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CHANGELOG.md new file mode 100644 index 0000000..1c01d08 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CHANGELOG.md @@ -0,0 +1,467 @@ +## Change Log + +### v2.55.0 (2015/04/05) +- [#1520](https://github.com/request/request/pull/1520) Refactor defaults (@simov) +- [#1525](https://github.com/request/request/pull/1525) Delete request headers with undefined value. (@froatsnook) +- [#1521](https://github.com/request/request/pull/1521) Add promise tests (@simov) +- [#1518](https://github.com/request/request/pull/1518) Fix defaults (@simov) +- [#1515](https://github.com/request/request/pull/1515) Allow static invoking of convenience methods (@simov) +- [#1505](https://github.com/request/request/pull/1505) Fix multipart boundary extraction regexp (@simov) +- [#1510](https://github.com/request/request/pull/1510) Fix basic auth form data (@simov) + +### v2.54.0 (2015/03/24) +- [#1501](https://github.com/request/request/pull/1501) HTTP Archive 1.2 support (@ahmadnassri) +- [#1486](https://github.com/request/request/pull/1486) Add a test for the forever agent (@akshayp) +- [#1500](https://github.com/request/request/pull/1500) Adding handling for no auth method and null bearer (@philberg) +- [#1498](https://github.com/request/request/pull/1498) Add table of contents in readme (@simov) +- [#1477](https://github.com/request/request/pull/1477) Add support for qs options via qsOptions key (@simov) +- [#1496](https://github.com/request/request/pull/1496) Parameters encoded to base 64 should be decoded as UTF-8, not ASCII. (@albanm) +- [#1494](https://github.com/request/request/pull/1494) Update eslint (@froatsnook) +- [#1474](https://github.com/request/request/pull/1474) Require Colon in Basic Auth (@erykwalder) +- [#1481](https://github.com/request/request/pull/1481) Fix baseUrl and redirections. (@burningtree) +- [#1469](https://github.com/request/request/pull/1469) Feature/base url (@froatsnook) +- [#1459](https://github.com/request/request/pull/1459) Add option to time request/response cycle (including rollup of redirects) (@aaron-em) +- [#1468](https://github.com/request/request/pull/1468) Re-enable io.js/node 0.12 build (@simov, @BBB) +- [#1442](https://github.com/request/request/pull/1442) Fixed the issue with strictSSL tests on 0.12 & io.js by explicitly setting a cipher that matches the cert. (@BBB, @nicolasmccurdy, @simov, @0x4139) +- [#1460](https://github.com/request/request/pull/1460) localAddress or proxy config is lost when redirecting (@simov, @0x4139) +- [#1453](https://github.com/request/request/pull/1453) Test on Node.js 0.12 and io.js with allowed failures (@nicolasmccurdy) +- [#1426](https://github.com/request/request/pull/1426) Fixing tests to pass on io.js and node 0.12 (only test-https.js stiff failing) (@mikeal) +- [#1446](https://github.com/request/request/pull/1446) Missing HTTP referer header with redirects Fixes #1038 (@simov, @guimonz) +- [#1428](https://github.com/request/request/pull/1428) Deprecate Node v0.8.x (@nylen) +- [#1436](https://github.com/request/request/pull/1436) Add ability to set a requester without setting default options (@tikotzky) +- [#1435](https://github.com/request/request/pull/1435) dry up verb methods (@sethpollack) +- [#1423](https://github.com/request/request/pull/1423) Allow fully qualified multipart content-type header (@simov) +- [#1430](https://github.com/request/request/pull/1430) Fix recursive requester (@tikotzky) +- [#1429](https://github.com/request/request/pull/1429) Throw error when making HEAD request with a body (@tikotzky) +- [#1419](https://github.com/request/request/pull/1419) Add note that the project is broken in 0.12.x (@nylen) +- [#1413](https://github.com/request/request/pull/1413) Fix basic auth (@simov) +- [#1397](https://github.com/request/request/pull/1397) Improve pipe-from-file tests (@nylen) + +### v2.53.0 (2015/02/02) +- [#1396](https://github.com/request/request/pull/1396) Do not rfc3986 escape JSON bodies (@nylen, @simov) +- [#1392](https://github.com/request/request/pull/1392) Improve `timeout` option description (@watson) + +### v2.52.0 (2015/02/02) +- [#1383](https://github.com/request/request/pull/1383) Add missing HTTPS options that were not being passed to tunnel (@brichard19) (@nylen, @brichard19) +- [#1388](https://github.com/request/request/pull/1388) Upgrade mime-types package version (@roderickhsiao) +- [#1389](https://github.com/request/request/pull/1389) Revise Setup Tunnel Function (@seanstrom) +- [#1374](https://github.com/request/request/pull/1374) Allow explicitly disabling tunneling for proxied https destinations (@nylen) +- [#1376](https://github.com/request/request/pull/1376) Use karma-browserify for tests. Add browser test coverage reporter. (@eiriksm) +- [#1366](https://github.com/request/request/pull/1366) Refactor OAuth into separate module (@simov) +- [#1373](https://github.com/request/request/pull/1373) Rewrite tunnel test to be pure Node.js (@nylen) +- [#1371](https://github.com/request/request/pull/1371) Upgrade test reporter (@nylen) +- [#1360](https://github.com/request/request/pull/1360) Refactor basic, bearer, digest auth logic into separate class (@simov) +- [#1354](https://github.com/request/request/pull/1354) Remove circular dependency from debugging code (@nylen) +- [#1351](https://github.com/request/request/pull/1351) Move digest auth into private prototype method (@simov) +- [#1352](https://github.com/request/request/pull/1352) Update hawk dependency to ~2.3.0 (@mridgway) +- [#1353](https://github.com/request/request/pull/1353) Correct travis-ci badge (@dogancelik) +- [#1349](https://github.com/request/request/pull/1349) Make sure we return on errored browser requests. (@eiriksm) +- [#1346](https://github.com/request/request/pull/1346) getProxyFromURI Extraction Refactor (@seanstrom) +- [#1337](https://github.com/request/request/pull/1337) Standardize test ports on 6767 (@nylen) +- [#1341](https://github.com/request/request/pull/1341) Emit FormData error events as Request error events (@nylen, @rwky) +- [#1343](https://github.com/request/request/pull/1343) Clean up readme badges, and add Travis and Coveralls badges (@nylen) +- [#1345](https://github.com/request/request/pull/1345) Update README.md (@Aaron-Hartwig) +- [#1338](https://github.com/request/request/pull/1338) Always wait for server.close() callback in tests (@nylen) +- [#1342](https://github.com/request/request/pull/1342) Add mock https server and redo start of browser tests for this purpose. (@eiriksm) +- [#1339](https://github.com/request/request/pull/1339) Improve auth docs (@nylen) +- [#1335](https://github.com/request/request/pull/1335) Add support for OAuth plaintext signature method (@simov) +- [#1332](https://github.com/request/request/pull/1332) Add clean script to remove test-browser.js after the tests run (@seanstrom) +- [#1327](https://github.com/request/request/pull/1327) Fix errors generating coverage reports. (@nylen) +- [#1330](https://github.com/request/request/pull/1330) Return empty buffer upon empty response body and encoding is set to null (@seanstrom) +- [#1326](https://github.com/request/request/pull/1326) Use faster container-based infrastructure on Travis (@nylen) +- [#1315](https://github.com/request/request/pull/1315) Implement rfc3986 option (@simov) +- [#1314](https://github.com/request/request/pull/1314) Detect urlencoded form data header via regex (@simov) +- [#1317](https://github.com/request/request/pull/1317) Improve OAuth1.0 server side flow example (@simov) + +### v2.51.0 (2014/12/10) +- [#1310](https://github.com/request/request/pull/1310) Revert changes introduced in https://github.com/request/request/pull/1282 (@simov) + +### v2.50.0 (2014/12/09) +- [#1308](https://github.com/request/request/pull/1308) Add browser test to keep track of browserify compability. (@eiriksm) +- [#1299](https://github.com/request/request/pull/1299) Add optional support for jsonReviver (@poislagarde) +- [#1277](https://github.com/request/request/pull/1277) Add Coveralls configuration (@simov) +- [#1307](https://github.com/request/request/pull/1307) Upgrade form-data, add back browserify compability. Fixes #455. (@eiriksm) +- [#1305](https://github.com/request/request/pull/1305) Fix typo in README.md (@LewisJEllis) +- [#1288](https://github.com/request/request/pull/1288) Update README.md to explain custom file use case (@cliffcrosland) + +### v2.49.0 (2014/11/28) +- [#1295](https://github.com/request/request/pull/1295) fix(proxy): no-proxy false positive (@oliamb) +- [#1292](https://github.com/request/request/pull/1292) Upgrade `caseless` to 0.8.1 (@mmalecki) +- [#1276](https://github.com/request/request/pull/1276) Set transfer encoding for multipart/related to chunked by default (@simov) +- [#1275](https://github.com/request/request/pull/1275) Fix multipart content-type headers detection (@simov) +- [#1269](https://github.com/request/request/pull/1269) adds streams example for review (@tbuchok) +- [#1238](https://github.com/request/request/pull/1238) Add examples README.md (@simov) + +### v2.48.0 (2014/11/12) +- [#1263](https://github.com/request/request/pull/1263) Fixed a syntax error / typo in README.md (@xna2) +- [#1253](https://github.com/request/request/pull/1253) Add multipart chunked flag (@simov, @nylen) +- [#1251](https://github.com/request/request/pull/1251) Clarify that defaults() does not modify global defaults (@nylen) +- [#1250](https://github.com/request/request/pull/1250) Improve documentation for pool and maxSockets options (@nylen) +- [#1237](https://github.com/request/request/pull/1237) Documenting error handling when using streams (@vmattos) +- [#1244](https://github.com/request/request/pull/1244) Finalize changelog command (@nylen) +- [#1241](https://github.com/request/request/pull/1241) Fix typo (@alexanderGugel) +- [#1223](https://github.com/request/request/pull/1223) Show latest version number instead of "upcoming" in changelog (@nylen) +- [#1236](https://github.com/request/request/pull/1236) Document how to use custom CA in README (#1229) (@hypesystem) +- [#1228](https://github.com/request/request/pull/1228) Support for oauth with RSA-SHA1 signing (@nylen) +- [#1216](https://github.com/request/request/pull/1216) Made json and multipart options coexist (@nylen, @simov) +- [#1225](https://github.com/request/request/pull/1225) Allow header white/exclusive lists in any case. (@RReverser) + +### v2.47.0 (2014/10/26) +- [#1222](https://github.com/request/request/pull/1222) Move from mikeal/request to request/request (@nylen) +- [#1220](https://github.com/request/request/pull/1220) update qs dependency to 2.3.1 (@FredKSchott) +- [#1212](https://github.com/request/request/pull/1212) Improve tests/test-timeout.js (@nylen) +- [#1219](https://github.com/request/request/pull/1219) remove old globalAgent workaround for node 0.4 (@request) +- [#1214](https://github.com/request/request/pull/1214) Remove cruft left over from optional dependencies (@nylen) +- [#1215](https://github.com/request/request/pull/1215) Add proxyHeaderExclusiveList option for proxy-only headers. (@RReverser) +- [#1211](https://github.com/request/request/pull/1211) Allow 'Host' header instead of 'host' and remember case across redirects (@nylen) +- [#1208](https://github.com/request/request/pull/1208) Improve release script (@nylen) +- [#1213](https://github.com/request/request/pull/1213) Support for custom cookie store (@nylen, @mitsuru) +- [#1197](https://github.com/request/request/pull/1197) Clean up some code around setting the agent (@FredKSchott) +- [#1209](https://github.com/request/request/pull/1209) Improve multipart form append test (@simov) +- [#1207](https://github.com/request/request/pull/1207) Update changelog (@nylen) +- [#1185](https://github.com/request/request/pull/1185) Stream multipart/related bodies (@simov) + +### v2.46.0 (2014/10/23) +- [#1198](https://github.com/request/request/pull/1198) doc for TLS/SSL protocol options (@shawnzhu) +- [#1200](https://github.com/request/request/pull/1200) Add a Gitter chat badge to README.md (@gitter-badger) +- [#1196](https://github.com/request/request/pull/1196) Upgrade taper test reporter to v0.3.0 (@nylen) +- [#1199](https://github.com/request/request/pull/1199) Fix lint error: undeclared var i (@nylen) +- [#1191](https://github.com/request/request/pull/1191) Move self.proxy decision logic out of init and into a helper (@FredKSchott) +- [#1190](https://github.com/request/request/pull/1190) Move _buildRequest() logic back into init (@FredKSchott) +- [#1186](https://github.com/request/request/pull/1186) Support Smarter Unix URL Scheme (@FredKSchott) +- [#1178](https://github.com/request/request/pull/1178) update form documentation for new usage (@FredKSchott) +- [#1180](https://github.com/request/request/pull/1180) Enable no-mixed-requires linting rule (@nylen) +- [#1184](https://github.com/request/request/pull/1184) Don't forward authorization header across redirects to different hosts (@nylen) +- [#1183](https://github.com/request/request/pull/1183) Correct README about pre and postamble CRLF using multipart and not mult... (@netpoetica) +- [#1179](https://github.com/request/request/pull/1179) Lint tests directory (@nylen) +- [#1169](https://github.com/request/request/pull/1169) add metadata for form-data file field (@dotcypress) +- [#1173](https://github.com/request/request/pull/1173) remove optional dependencies (@seanstrom) +- [#1165](https://github.com/request/request/pull/1165) Cleanup event listeners and remove function creation from init (@FredKSchott) +- [#1174](https://github.com/request/request/pull/1174) update the request.cookie docs to have a valid cookie example (@seanstrom) +- [#1168](https://github.com/request/request/pull/1168) create a detach helper and use detach helper in replace of nextTick (@seanstrom) +- [#1171](https://github.com/request/request/pull/1171) in post can send form data and use callback (@MiroRadenovic) +- [#1159](https://github.com/request/request/pull/1159) accept charset for x-www-form-urlencoded content-type (@seanstrom) +- [#1157](https://github.com/request/request/pull/1157) Update README.md: body with json=true (@Rob--W) +- [#1164](https://github.com/request/request/pull/1164) Disable tests/test-timeout.js on Travis (@nylen) +- [#1153](https://github.com/request/request/pull/1153) Document how to run a single test (@nylen) +- [#1144](https://github.com/request/request/pull/1144) adds documentation for the "response" event within the streaming section (@tbuchok) +- [#1162](https://github.com/request/request/pull/1162) Update eslintrc file to no longer allow past errors (@FredKSchott) +- [#1155](https://github.com/request/request/pull/1155) Support/use self everywhere (@seanstrom) +- [#1161](https://github.com/request/request/pull/1161) fix no-use-before-define lint warnings (@emkay) +- [#1156](https://github.com/request/request/pull/1156) adding curly brackets to get rid of lint errors (@emkay) +- [#1151](https://github.com/request/request/pull/1151) Fix localAddress test on OS X (@nylen) +- [#1145](https://github.com/request/request/pull/1145) documentation: fix outdated reference to setCookieSync old name in README (@FredKSchott) +- [#1131](https://github.com/request/request/pull/1131) Update pool documentation (@FredKSchott) +- [#1143](https://github.com/request/request/pull/1143) Rewrite all tests to use tape (@nylen) +- [#1137](https://github.com/request/request/pull/1137) Add ability to specifiy querystring lib in options. (@jgrund) +- [#1138](https://github.com/request/request/pull/1138) allow hostname and port in place of host on uri (@cappslock) +- [#1134](https://github.com/request/request/pull/1134) Fix multiple redirects and `self.followRedirect` (@blakeembrey) +- [#1130](https://github.com/request/request/pull/1130) documentation fix: add note about npm test for contributing (@FredKSchott) +- [#1120](https://github.com/request/request/pull/1120) Support/refactor request setup tunnel (@seanstrom) +- [#1129](https://github.com/request/request/pull/1129) linting fix: convert double quote strings to use single quotes (@FredKSchott) +- [#1124](https://github.com/request/request/pull/1124) linting fix: remove unneccesary semi-colons (@FredKSchott) + +### v2.45.0 (2014/10/06) +- [#1128](https://github.com/request/request/pull/1128) Add test for setCookie regression (@nylen) +- [#1127](https://github.com/request/request/pull/1127) added tests around using objects as values in a query string (@bcoe) +- [#1103](https://github.com/request/request/pull/1103) Support/refactor request constructor (@nylen, @seanstrom) +- [#1119](https://github.com/request/request/pull/1119) add basic linting to request library (@FredKSchott) +- [#1121](https://github.com/request/request/pull/1121) Revert "Explicitly use sync versions of cookie functions" (@nylen) +- [#1118](https://github.com/request/request/pull/1118) linting fix: Restructure bad empty if statement (@FredKSchott) +- [#1117](https://github.com/request/request/pull/1117) Fix a bad check for valid URIs (@FredKSchott) +- [#1113](https://github.com/request/request/pull/1113) linting fix: space out operators (@FredKSchott) +- [#1116](https://github.com/request/request/pull/1116) Fix typo in `noProxyHost` definition (@FredKSchott) +- [#1114](https://github.com/request/request/pull/1114) linting fix: Added a `new` operator that was missing when creating and throwing a new error (@FredKSchott) +- [#1096](https://github.com/request/request/pull/1096) No_proxy support (@samcday) +- [#1107](https://github.com/request/request/pull/1107) linting-fix: remove unused variables (@FredKSchott) +- [#1112](https://github.com/request/request/pull/1112) linting fix: Make return values consistent and more straitforward (@FredKSchott) +- [#1111](https://github.com/request/request/pull/1111) linting fix: authPieces was getting redeclared (@FredKSchott) +- [#1105](https://github.com/request/request/pull/1105) Use strict mode in request (@FredKSchott) +- [#1110](https://github.com/request/request/pull/1110) linting fix: replace lazy '==' with more strict '===' (@FredKSchott) +- [#1109](https://github.com/request/request/pull/1109) linting fix: remove function call from if-else conditional statement (@FredKSchott) +- [#1102](https://github.com/request/request/pull/1102) Fix to allow setting a `requester` on recursive calls to `request.defaults` (@tikotzky) +- [#1095](https://github.com/request/request/pull/1095) Tweaking engines in package.json (@pdehaan) +- [#1082](https://github.com/request/request/pull/1082) Forward the socket event from the httpModule request (@seanstrom) +- [#972](https://github.com/request/request/pull/972) Clarify gzip handling in the README (@kevinoid) +- [#1089](https://github.com/request/request/pull/1089) Mention that encoding defaults to utf8, not Buffer (@stuartpb) +- [#1088](https://github.com/request/request/pull/1088) Fix cookie example in README.md and make it more clear (@pipi32167) +- [#1027](https://github.com/request/request/pull/1027) Add support for multipart form data in request options. (@crocket) +- [#1076](https://github.com/request/request/pull/1076) use Request.abort() to abort the request when the request has timed-out (@seanstrom) +- [#1068](https://github.com/request/request/pull/1068) add optional postamble required by .NET multipart requests (@netpoetica) + +### v2.43.0 (2014/09/18) +- [#1057](https://github.com/request/request/pull/1057) Defaults should not overwrite defined options (@davidwood) +- [#1046](https://github.com/request/request/pull/1046) Propagate datastream errors, useful in case gzip fails. (@ZJONSSON, @Janpot) +- [#1063](https://github.com/request/request/pull/1063) copy the input headers object #1060 (@finnp) +- [#1031](https://github.com/request/request/pull/1031) Explicitly use sync versions of cookie functions (@ZJONSSON) +- [#1056](https://github.com/request/request/pull/1056) Fix redirects when passing url.parse(x) as URL to convenience method (@nylen) + +### v2.42.0 (2014/09/04) +- [#1053](https://github.com/request/request/pull/1053) Fix #1051 Parse auth properly when using non-tunneling proxy (@isaacs) + +### v2.41.0 (2014/09/04) +- [#1050](https://github.com/request/request/pull/1050) Pass whitelisted headers to tunneling proxy. Organize all tunneling logic. (@isaacs, @Feldhacker) +- [#1035](https://github.com/request/request/pull/1035) souped up nodei.co badge (@rvagg) +- [#1048](https://github.com/request/request/pull/1048) Aws is now possible over a proxy (@steven-aerts) +- [#1039](https://github.com/request/request/pull/1039) extract out helper functions to a helper file (@seanstrom) +- [#1021](https://github.com/request/request/pull/1021) Support/refactor indexjs (@seanstrom) +- [#1033](https://github.com/request/request/pull/1033) Improve and document debug options (@nylen) +- [#1034](https://github.com/request/request/pull/1034) Fix readme headings (@nylen) +- [#1030](https://github.com/request/request/pull/1030) Allow recursive request.defaults (@tikotzky) +- [#1029](https://github.com/request/request/pull/1029) Fix a couple of typos (@nylen) +- [#675](https://github.com/request/request/pull/675) Checking for SSL fault on connection before reading SSL properties (@VRMink) +- [#989](https://github.com/request/request/pull/989) Added allowRedirect function. Should return true if redirect is allowed or false otherwise (@doronin) +- [#1025](https://github.com/request/request/pull/1025) [fixes #1023] Set self._ended to true once response has ended (@mridgway) +- [#1020](https://github.com/request/request/pull/1020) Add back removed debug metadata (@FredKSchott) +- [#1008](https://github.com/request/request/pull/1008) Moving to module instead of cutomer buffer concatenation. (@mikeal) +- [#770](https://github.com/request/request/pull/770) Added dependency badge for README file; (@timgluz) +- [#1016](https://github.com/request/request/pull/1016) toJSON no longer results in an infinite loop, returns simple objects (@FredKSchott) +- [#1018](https://github.com/request/request/pull/1018) Remove pre-0.4.4 HTTPS fix (@mmalecki) +- [#1006](https://github.com/request/request/pull/1006) Migrate to caseless, fixes #1001 (@mikeal) +- [#995](https://github.com/request/request/pull/995) Fix parsing array of objects (@sjonnet19) +- [#999](https://github.com/request/request/pull/999) Fix fallback for browserify for optional modules. (@eiriksm) +- [#996](https://github.com/request/request/pull/996) Wrong oauth signature when multiple same param keys exist [updated] (@bengl) + +### v2.40.0 (2014/08/06) +- [#992](https://github.com/request/request/pull/992) Fix security vulnerability. Update qs (@poeticninja) +- [#988](https://github.com/request/request/pull/988) “--” -> “—” (@upisfree) +- [#987](https://github.com/request/request/pull/987) Show optional modules as being loaded by the module that reqeusted them (@iarna) + +### v2.39.0 (2014/07/24) +- [#976](https://github.com/request/request/pull/976) Update README.md (@pvoznenko) + +### v2.38.0 (2014/07/22) +- [#952](https://github.com/request/request/pull/952) Adding support to client certificate with proxy use case (@ofirshaked) +- [#884](https://github.com/request/request/pull/884) Documented tough-cookie installation. (@wbyoung) +- [#935](https://github.com/request/request/pull/935) Correct repository url (@fritx) +- [#963](https://github.com/request/request/pull/963) Update changelog (@nylen) +- [#960](https://github.com/request/request/pull/960) Support gzip with encoding on node pre-v0.9.4 (@kevinoid) +- [#953](https://github.com/request/request/pull/953) Add async Content-Length computation when using form-data (@LoicMahieu) +- [#844](https://github.com/request/request/pull/844) Add support for HTTP[S]_PROXY environment variables. Fixes #595. (@jvmccarthy) +- [#946](https://github.com/request/request/pull/946) defaults: merge headers (@aj0strow) + +### v2.37.0 (2014/07/07) +- [#957](https://github.com/request/request/pull/957) Silence EventEmitter memory leak warning #311 (@watson) +- [#955](https://github.com/request/request/pull/955) check for content-length header before setting it in nextTick (@camilleanne) +- [#951](https://github.com/request/request/pull/951) Add support for gzip content decoding (@kevinoid) +- [#949](https://github.com/request/request/pull/949) Manually enter querystring in form option (@charlespwd) +- [#944](https://github.com/request/request/pull/944) Make request work with browserify (@eiriksm) +- [#943](https://github.com/request/request/pull/943) New mime module (@eiriksm) +- [#927](https://github.com/request/request/pull/927) Bump version of hawk dep. (@samccone) +- [#907](https://github.com/request/request/pull/907) append secureOptions to poolKey (@medovob) + +### v2.35.0 (2014/05/17) +- [#901](https://github.com/request/request/pull/901) Fixes #555 (@pigulla) +- [#897](https://github.com/request/request/pull/897) merge with default options (@vohof) +- [#891](https://github.com/request/request/pull/891) fixes 857 - options object is mutated by calling request (@lalitkapoor) +- [#869](https://github.com/request/request/pull/869) Pipefilter test (@tgohn) +- [#866](https://github.com/request/request/pull/866) Fix typo (@dandv) +- [#861](https://github.com/request/request/pull/861) Add support for RFC 6750 Bearer Tokens (@phedny) +- [#809](https://github.com/request/request/pull/809) upgrade tunnel-proxy to 0.4.0 (@ksato9700) +- [#850](https://github.com/request/request/pull/850) Fix word consistency in readme (@0xNobody) +- [#810](https://github.com/request/request/pull/810) add some exposition to mpu example in README.md (@mikermcneil) +- [#840](https://github.com/request/request/pull/840) improve error reporting for invalid protocols (@FND) +- [#821](https://github.com/request/request/pull/821) added secureOptions back (@nw) +- [#815](https://github.com/request/request/pull/815) Create changelog based on pull requests (@lalitkapoor) + +### v2.34.0 (2014/02/18) +- [#516](https://github.com/request/request/pull/516) UNIX Socket URL Support (@lyuzashi) +- [#801](https://github.com/request/request/pull/801) 794 ignore cookie parsing and domain errors (@lalitkapoor) +- [#802](https://github.com/request/request/pull/802) Added the Apache license to the package.json. (@keskival) +- [#793](https://github.com/request/request/pull/793) Adds content-length calculation when submitting forms using form-data li... (@Juul) +- [#785](https://github.com/request/request/pull/785) Provide ability to override content-type when `json` option used (@vvo) +- [#781](https://github.com/request/request/pull/781) simpler isReadStream function (@joaojeronimo) + +### v2.32.0 (2014/01/16) +- [#767](https://github.com/request/request/pull/767) Use tough-cookie CookieJar sync API (@stash) +- [#764](https://github.com/request/request/pull/764) Case-insensitive authentication scheme (@bobyrizov) +- [#763](https://github.com/request/request/pull/763) Upgrade tough-cookie to 0.10.0 (@stash) +- [#744](https://github.com/request/request/pull/744) Use Cookie.parse (@lalitkapoor) +- [#757](https://github.com/request/request/pull/757) require aws-sign2 (@mafintosh) + +### v2.31.0 (2014/01/08) +- [#645](https://github.com/request/request/pull/645) update twitter api url to v1.1 (@mick) +- [#746](https://github.com/request/request/pull/746) README: Markdown code highlight (@weakish) +- [#745](https://github.com/request/request/pull/745) updating setCookie example to make it clear that the callback is required (@emkay) +- [#742](https://github.com/request/request/pull/742) Add note about JSON output body type (@iansltx) +- [#741](https://github.com/request/request/pull/741) README example is using old cookie jar api (@emkay) +- [#736](https://github.com/request/request/pull/736) Fix callback arguments documentation (@mmalecki) + +### v2.30.0 (2013/12/13) +- [#732](https://github.com/request/request/pull/732) JSHINT: Creating global 'for' variable. Should be 'for (var ...'. (@Fritz-Lium) +- [#730](https://github.com/request/request/pull/730) better HTTP DIGEST support (@dai-shi) +- [#728](https://github.com/request/request/pull/728) Fix TypeError when calling request.cookie (@scarletmeow) + +### v2.29.0 (2013/12/06) +- [#727](https://github.com/request/request/pull/727) fix requester bug (@jchris) + +### v2.28.0 (2013/12/04) +- [#724](https://github.com/request/request/pull/724) README.md: add custom HTTP Headers example. (@tcort) +- [#719](https://github.com/request/request/pull/719) Made a comment gender neutral. (@oztu) +- [#715](https://github.com/request/request/pull/715) Request.multipart no longer crashes when header 'Content-type' present (@pastaclub) +- [#710](https://github.com/request/request/pull/710) Fixing listing in callback part of docs. (@lukasz-zak) +- [#696](https://github.com/request/request/pull/696) Edited README.md for formatting and clarity of phrasing (@Zearin) +- [#694](https://github.com/request/request/pull/694) Typo in README (@VRMink) +- [#690](https://github.com/request/request/pull/690) Handle blank password in basic auth. (@diversario) +- [#682](https://github.com/request/request/pull/682) Optional dependencies (@Turbo87) +- [#683](https://github.com/request/request/pull/683) Travis CI support (@Turbo87) +- [#674](https://github.com/request/request/pull/674) change cookie module,to tough-cookie.please check it . (@sxyizhiren) +- [#666](https://github.com/request/request/pull/666) make `ciphers` and `secureProtocol` to work in https request (@richarddong) +- [#656](https://github.com/request/request/pull/656) Test case for #304. (@diversario) +- [#662](https://github.com/request/request/pull/662) option.tunnel to explicitly disable tunneling (@seanmonstar) +- [#659](https://github.com/request/request/pull/659) fix failure when running with NODE_DEBUG=request, and a test for that (@jrgm) +- [#630](https://github.com/request/request/pull/630) Send random cnonce for HTTP Digest requests (@wprl) + +### v2.27.0 (2013/08/15) +- [#619](https://github.com/request/request/pull/619) decouple things a bit (@joaojeronimo) + +### v2.26.0 (2013/08/07) +- [#613](https://github.com/request/request/pull/613) Fixes #583, moved initialization of self.uri.pathname (@lexander) +- [#605](https://github.com/request/request/pull/605) Only include ":" + pass in Basic Auth if it's defined (fixes #602) (@bendrucker) + +### v2.24.0 (2013/07/23) +- [#596](https://github.com/request/request/pull/596) Global agent is being used when pool is specified (@Cauldrath) +- [#594](https://github.com/request/request/pull/594) Emit complete event when there is no callback (@RomainLK) +- [#601](https://github.com/request/request/pull/601) Fixed a small typo (@michalstanko) + +### v2.23.0 (2013/07/23) +- [#589](https://github.com/request/request/pull/589) Prevent setting headers after they are sent (@geek) +- [#587](https://github.com/request/request/pull/587) Global cookie jar disabled by default (@threepointone) + +### v2.22.0 (2013/07/05) +- [#544](https://github.com/request/request/pull/544) Update http-signature version. (@davidlehn) +- [#581](https://github.com/request/request/pull/581) Fix spelling of "ignoring." (@bigeasy) +- [#568](https://github.com/request/request/pull/568) use agentOptions to create agent when specified in request (@SamPlacette) +- [#564](https://github.com/request/request/pull/564) Fix redirections (@criloz) +- [#541](https://github.com/request/request/pull/541) The exported request function doesn't have an auth method (@tschaub) +- [#542](https://github.com/request/request/pull/542) Expose Request class (@regality) + +### v2.21.0 (2013/04/30) +- [#536](https://github.com/request/request/pull/536) Allow explicitly empty user field for basic authentication. (@mikeando) +- [#532](https://github.com/request/request/pull/532) fix typo (@fredericosilva) +- [#497](https://github.com/request/request/pull/497) Added redirect event (@Cauldrath) +- [#503](https://github.com/request/request/pull/503) Fix basic auth for passwords that contain colons (@tonistiigi) +- [#521](https://github.com/request/request/pull/521) Improving test-localAddress.js (@noway421) +- [#529](https://github.com/request/request/pull/529) dependencies versions bump (@jodaka) + +### v2.17.0 (2013/04/22) +- [#523](https://github.com/request/request/pull/523) Updating dependencies (@noway421) +- [#520](https://github.com/request/request/pull/520) Fixing test-tunnel.js (@noway421) +- [#519](https://github.com/request/request/pull/519) Update internal path state on post-creation QS changes (@jblebrun) +- [#510](https://github.com/request/request/pull/510) Add HTTP Signature support. (@davidlehn) +- [#502](https://github.com/request/request/pull/502) Fix POST (and probably other) requests that are retried after 401 Unauthorized (@nylen) +- [#508](https://github.com/request/request/pull/508) Honor the .strictSSL option when using proxies (tunnel-agent) (@jhs) +- [#512](https://github.com/request/request/pull/512) Make password optional to support the format: http://username@hostname/ (@pajato1) +- [#513](https://github.com/request/request/pull/513) add 'localAddress' support (@yyfrankyy) +- [#498](https://github.com/request/request/pull/498) Moving response emit above setHeaders on destination streams (@kenperkins) +- [#490](https://github.com/request/request/pull/490) Empty response body (3-rd argument) must be passed to callback as an empty string (@Olegas) +- [#479](https://github.com/request/request/pull/479) Changing so if Accept header is explicitly set, sending json does not ov... (@RoryH) +- [#475](https://github.com/request/request/pull/475) Use `unescape` from `querystring` (@shimaore) +- [#473](https://github.com/request/request/pull/473) V0.10 compat (@isaacs) +- [#471](https://github.com/request/request/pull/471) Using querystring library from visionmedia (@kbackowski) +- [#461](https://github.com/request/request/pull/461) Strip the UTF8 BOM from a UTF encoded response (@kppullin) +- [#460](https://github.com/request/request/pull/460) hawk 0.10.0 (@hueniverse) +- [#462](https://github.com/request/request/pull/462) if query params are empty, then request path shouldn't end with a '?' (merges cleanly now) (@jaipandya) +- [#456](https://github.com/request/request/pull/456) hawk 0.9.0 (@hueniverse) +- [#429](https://github.com/request/request/pull/429) Copy options before adding callback. (@nrn) +- [#454](https://github.com/request/request/pull/454) Destroy the response if present when destroying the request (clean merge) (@mafintosh) +- [#310](https://github.com/request/request/pull/310) Twitter Oauth Stuff Out of Date; Now Updated (@joemccann) +- [#413](https://github.com/request/request/pull/413) rename googledoodle.png to .jpg (@nfriedly) +- [#448](https://github.com/request/request/pull/448) Convenience method for PATCH (@mloar) +- [#444](https://github.com/request/request/pull/444) protect against double callbacks on error path (@spollack) +- [#433](https://github.com/request/request/pull/433) Added support for HTTPS cert & key (@mmalecki) +- [#430](https://github.com/request/request/pull/430) Respect specified {Host,host} headers, not just {host} (@andrewschaaf) +- [#415](https://github.com/request/request/pull/415) Fixed a typo. (@jerem) +- [#338](https://github.com/request/request/pull/338) Add more auth options, including digest support (@nylen) +- [#403](https://github.com/request/request/pull/403) Optimize environment lookup to happen once only (@mmalecki) +- [#398](https://github.com/request/request/pull/398) Add more reporting to tests (@mmalecki) +- [#388](https://github.com/request/request/pull/388) Ensure "safe" toJSON doesn't break EventEmitters (@othiym23) +- [#381](https://github.com/request/request/pull/381) Resolving "Invalid signature. Expected signature base string: " (@landeiro) +- [#380](https://github.com/request/request/pull/380) Fixes missing host header on retried request when using forever agent (@mac-) +- [#376](https://github.com/request/request/pull/376) Headers lost on redirect (@kapetan) +- [#375](https://github.com/request/request/pull/375) Fix for missing oauth_timestamp parameter (@jplock) +- [#374](https://github.com/request/request/pull/374) Correct Host header for proxy tunnel CONNECT (@youurayy) +- [#370](https://github.com/request/request/pull/370) Twitter reverse auth uses x_auth_mode not x_auth_type (@drudge) +- [#369](https://github.com/request/request/pull/369) Don't remove x_auth_mode for Twitter reverse auth (@drudge) +- [#344](https://github.com/request/request/pull/344) Make AWS auth signing find headers correctly (@nlf) +- [#363](https://github.com/request/request/pull/363) rfc3986 on base_uri, now passes tests (@jeffmarshall) +- [#362](https://github.com/request/request/pull/362) Running `rfc3986` on `base_uri` in `oauth.hmacsign` instead of just `encodeURIComponent` (@jeffmarshall) +- [#361](https://github.com/request/request/pull/361) Don't create a Content-Length header if we already have it set (@danjenkins) +- [#360](https://github.com/request/request/pull/360) Delete self._form along with everything else on redirect (@jgautier) +- [#355](https://github.com/request/request/pull/355) stop sending erroneous headers on redirected requests (@azylman) +- [#332](https://github.com/request/request/pull/332) Fix #296 - Only set Content-Type if body exists (@Marsup) +- [#343](https://github.com/request/request/pull/343) Allow AWS to work in more situations, added a note in the README on its usage (@nlf) +- [#320](https://github.com/request/request/pull/320) request.defaults() doesn't need to wrap jar() (@StuartHarris) +- [#322](https://github.com/request/request/pull/322) Fix + test for piped into request bumped into redirect. #321 (@alexindigo) +- [#326](https://github.com/request/request/pull/326) Do not try to remove listener from an undefined connection (@strk) +- [#318](https://github.com/request/request/pull/318) Pass servername to tunneling secure socket creation (@isaacs) +- [#317](https://github.com/request/request/pull/317) Workaround for #313 (@isaacs) +- [#293](https://github.com/request/request/pull/293) Allow parser errors to bubble up to request (@mscdex) +- [#290](https://github.com/request/request/pull/290) A test for #289 (@isaacs) +- [#280](https://github.com/request/request/pull/280) Like in node.js print options if NODE_DEBUG contains the word request (@Filirom1) +- [#207](https://github.com/request/request/pull/207) Fix #206 Change HTTP/HTTPS agent when redirecting between protocols (@isaacs) +- [#214](https://github.com/request/request/pull/214) documenting additional behavior of json option (@jphaas) +- [#272](https://github.com/request/request/pull/272) Boundary begins with CRLF? (@elspoono) +- [#284](https://github.com/request/request/pull/284) Remove stray `console.log()` call in multipart generator. (@bcherry) +- [#241](https://github.com/request/request/pull/241) Composability updates suggested by issue #239 (@polotek) +- [#282](https://github.com/request/request/pull/282) OAuth Authorization header contains non-"oauth_" parameters (@jplock) +- [#279](https://github.com/request/request/pull/279) fix tests with boundary by injecting boundry from header (@benatkin) +- [#273](https://github.com/request/request/pull/273) Pipe back pressure issue (@mafintosh) +- [#268](https://github.com/request/request/pull/268) I'm not OCD seriously (@TehShrike) +- [#263](https://github.com/request/request/pull/263) Bug in OAuth key generation for sha1 (@nanodocumet) +- [#265](https://github.com/request/request/pull/265) uncaughtException when redirected to invalid URI (@naholyr) +- [#262](https://github.com/request/request/pull/262) JSON test should check for equality (@timshadel) +- [#261](https://github.com/request/request/pull/261) Setting 'pool' to 'false' does NOT disable Agent pooling (@timshadel) +- [#249](https://github.com/request/request/pull/249) Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods (@sethbridges) +- [#255](https://github.com/request/request/pull/255) multipart allow body === '' ( the empty string ) (@Filirom1) +- [#260](https://github.com/request/request/pull/260) fixed just another leak of 'i' (@sreuter) +- [#246](https://github.com/request/request/pull/246) Fixing the set-cookie header (@jeromegn) +- [#243](https://github.com/request/request/pull/243) Dynamic boundary (@zephrax) +- [#240](https://github.com/request/request/pull/240) don't error when null is passed for options (@polotek) +- [#211](https://github.com/request/request/pull/211) Replace all occurrences of special chars in RFC3986 (@chriso) +- [#224](https://github.com/request/request/pull/224) Multipart content-type change (@janjongboom) +- [#217](https://github.com/request/request/pull/217) need to use Authorization (titlecase) header with Tumblr OAuth (@visnup) +- [#203](https://github.com/request/request/pull/203) Fix cookie and redirect bugs and add auth support for HTTPS tunnel (@milewise) +- [#199](https://github.com/request/request/pull/199) Tunnel (@isaacs) +- [#198](https://github.com/request/request/pull/198) Bugfix on forever usage of util.inherits (@isaacs) +- [#197](https://github.com/request/request/pull/197) Make ForeverAgent work with HTTPS (@isaacs) +- [#193](https://github.com/request/request/pull/193) Fixes GH-119 (@goatslacker) +- [#188](https://github.com/request/request/pull/188) Add abort support to the returned request (@itay) +- [#176](https://github.com/request/request/pull/176) Querystring option (@csainty) +- [#182](https://github.com/request/request/pull/182) Fix request.defaults to support (uri, options, callback) api (@twilson63) +- [#180](https://github.com/request/request/pull/180) Modified the post, put, head and del shortcuts to support uri optional param (@twilson63) +- [#179](https://github.com/request/request/pull/179) fix to add opts in .pipe(stream, opts) (@substack) +- [#177](https://github.com/request/request/pull/177) Issue #173 Support uri as first and optional config as second argument (@twilson63) +- [#170](https://github.com/request/request/pull/170) can't create a cookie in a wrapped request (defaults) (@fabianonunes) +- [#168](https://github.com/request/request/pull/168) Picking off an EasyFix by adding some missing mimetypes. (@serby) +- [#161](https://github.com/request/request/pull/161) Fix cookie jar/headers.cookie collision (#125) (@papandreou) +- [#162](https://github.com/request/request/pull/162) Fix issue #159 (@dpetukhov) +- [#90](https://github.com/request/request/pull/90) add option followAllRedirects to follow post/put redirects (@jroes) +- [#148](https://github.com/request/request/pull/148) Retry Agent (@thejh) +- [#146](https://github.com/request/request/pull/146) Multipart should respect content-type if previously set (@apeace) +- [#144](https://github.com/request/request/pull/144) added "form" option to readme (@petejkim) +- [#133](https://github.com/request/request/pull/133) Fixed cookies parsing (@afanasy) +- [#135](https://github.com/request/request/pull/135) host vs hostname (@iangreenleaf) +- [#132](https://github.com/request/request/pull/132) return the body as a Buffer when encoding is set to null (@jahewson) +- [#112](https://github.com/request/request/pull/112) Support using a custom http-like module (@jhs) +- [#104](https://github.com/request/request/pull/104) Cookie handling contains bugs (@janjongboom) +- [#121](https://github.com/request/request/pull/121) Another patch for cookie handling regression (@jhurliman) +- [#117](https://github.com/request/request/pull/117) Remove the global `i` (@3rd-Eden) +- [#110](https://github.com/request/request/pull/110) Update to Iris Couch URL (@jhs) +- [#86](https://github.com/request/request/pull/86) Can't post binary to multipart requests (@developmentseed) +- [#105](https://github.com/request/request/pull/105) added test for proxy option. (@dominictarr) +- [#102](https://github.com/request/request/pull/102) Implemented cookies - closes issue 82: https://github.com/mikeal/request/issues/82 (@alessioalex) +- [#97](https://github.com/request/request/pull/97) Typo in previous pull causes TypeError in non-0.5.11 versions (@isaacs) +- [#96](https://github.com/request/request/pull/96) Authless parsed url host support (@isaacs) +- [#81](https://github.com/request/request/pull/81) Enhance redirect handling (@danmactough) +- [#78](https://github.com/request/request/pull/78) Don't try to do strictSSL for non-ssl connections (@isaacs) +- [#76](https://github.com/request/request/pull/76) Bug when a request fails and a timeout is set (@Marsup) +- [#70](https://github.com/request/request/pull/70) add test script to package.json (@isaacs) +- [#73](https://github.com/request/request/pull/73) Fix #71 Respect the strictSSL flag (@isaacs) +- [#69](https://github.com/request/request/pull/69) Flatten chunked requests properly (@isaacs) +- [#67](https://github.com/request/request/pull/67) fixed global variable leaks (@aheckmann) +- [#66](https://github.com/request/request/pull/66) Do not overwrite established content-type headers for read stream deliver (@voodootikigod) +- [#53](https://github.com/request/request/pull/53) Parse json: Issue #51 (@benatkin) +- [#45](https://github.com/request/request/pull/45) Added timeout option (@mbrevoort) +- [#35](https://github.com/request/request/pull/35) The "end" event isn't emitted for some responses (@voxpelli) +- [#31](https://github.com/request/request/pull/31) Error on piping a request to a destination (@tobowers) \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CONTRIBUTING.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CONTRIBUTING.md new file mode 100644 index 0000000..06b1968 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/CONTRIBUTING.md @@ -0,0 +1,44 @@ +# This is an OPEN Open Source Project + +----------------------------------------- + +## What? + +Individuals making significant and valuable contributions are given +commit-access to the project to contribute as they see fit. This project is +more like an open wiki than a standard guarded open source project. + +## Rules + +There are a few basic ground-rules for contributors: + +1. **No `--force` pushes** or modifying the Git history in any way. +1. **Non-master branches** ought to be used for ongoing work. +1. **External API changes and significant modifications** ought to be subject + to an **internal pull-request** to solicit feedback from other contributors. +1. Internal pull-requests to solicit feedback are *encouraged* for any other + non-trivial contribution but left to the discretion of the contributor. +1. For significant changes wait a full 24 hours before merging so that active + contributors who are distributed throughout the world have a chance to weigh + in. +1. Contributors should attempt to adhere to the prevailing code-style. +1. Run `npm test` locally before submitting your PR, to catch any easy to miss + style & testing issues. To diagnose test failures, there are two ways to + run a single test file: + - `node_modules/.bin/taper tests/test-file.js` - run using the default + [`taper`](https://github.com/nylen/taper) test reporter. + - `node tests/test-file.js` - view the raw + [tap](https://testanything.org/) output. + + +## Releases + +Declaring formal releases remains the prerogative of the project maintainer. + +## Changes to this arrangement + +This is an experiment and feedback is welcome! This document may also be +subject to pull-requests or changes by contributors where you believe you have +something valuable to add or change. + +----------------------------------------- diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/LICENSE new file mode 100644 index 0000000..a4a9aee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/README.md new file mode 100644 index 0000000..2abc9e1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/README.md @@ -0,0 +1,1031 @@ + +# Request - Simplified HTTP client + +[](https://nodei.co/npm/request/) + +[](https://travis-ci.org/request/request) +[](https://coveralls.io/r/request/request) +[](https://gitter.im/request/request?utm_source=badge) + + +## Super simple to use + +Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default. + +```js +var request = require('request'); +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body) // Show the HTML for the Google homepage. + } +}) +``` + + +## Table of contents + +- [Streaming](#streaming) +- [Forms](#forms) +- [HTTP Authentication](#http-authentication) +- [Custom HTTP Headers](#custom-http-headers) +- [OAuth Signing](#oauth-signing) +- [Proxies](#proxies) +- [Unix Domain Sockets](#unix-domain-sockets) +- [TLS/SSL Protocol](#tlsssl-protocol) +- [Support for HAR 1.2](#support-for-har-12) +- [**All Available Options**](#requestoptions-callback) + +Request also offers [convenience methods](#convenience-methods) like +`request.defaults` and `request.post`, and there are +lots of [usage examples](#examples) and several +[debugging techniques](#debugging). + + +--- + + +## Streaming + +You can stream any response to a file stream. + +```js +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')) +``` + +You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types (in this case `application/json`) and use the proper `content-type` in the PUT request (if the headers don’t already provide one). + +```js +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')) +``` + +Request can also `pipe` to itself. When doing so, `content-type` and `content-length` are preserved in the PUT headers. + +```js +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')) +``` + +Request emits a "response" event when a response is received. The `response` argument will be an instance of [http.IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage). + +```js +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode) // 200 + console.log(response.headers['content-type']) // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')) +``` + +To easily handle errors when streaming requests, listen to the `error` event before piping: + +```js +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err) + }) + .pipe(fs.createWriteStream('doodle.png')) +``` + +Now let’s get fancy. + +```js +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')) + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp) + } + } +}) +``` + +You can also `pipe()` from `http.ServerRequest` instances, as well as to `http.ServerResponse` instances. The HTTP method, headers, and entity-body data will be sent. Which means that, if you don't really care about security, you can do: + +```js +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png') + req.pipe(x) + x.pipe(resp) + } +}) +``` + +And since `pipe()` returns the destination stream in ≥ Node 0.5.x you can do one line proxying. :) + +```js +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp) +``` + +Also, none of this new functionality conflicts with requests previous features, it just expands them. + +```js +var r = request.defaults({'proxy':'http://localproxy.com'}) + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp) + } +}) +``` + +You can still use intermediate proxies, the requests will still follow HTTP forwards, etc. + +[back to top](#table-of-contents) + + +--- + + +## Forms + +`request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API. + + +#### application/x-www-form-urlencoded (URL-Encoded Forms) + +URL-encoded forms are simple. + +```js +request.post('http://service.com/upload', {form:{key:'value'}}) +// or +request.post('http://service.com/upload').form({key:'value'}) +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }) +``` + + +#### multipart/form-data (Multipart Form Uploads) + +For `multipart/form-data` we use the [form-data](https://github.com/felixge/node-form-data) library by [@felixge](https://github.com/felixge). For the most cases, you can pass your upload form data via the `formData` option. + + +```js +var formData = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: formData}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); +``` + +For advanced cases, you can access the form-data object itself via `r.form()`. This can be modified until the request is fired on the next cycle of the event-loop. (Note that this calling `form()` will clear the currently set form data for that request.) + +```js +// NOTE: Advanced use-case, for normal use see 'formData' usage above +var r = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) { // ... + +var form = r.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); +``` +See the [form-data README](https://github.com/felixge/node-form-data) for more information & examples. + + +#### multipart/related + +Some variations in different HTTP implementations require a newline/CRLF before, after, or both before and after the boundary of a `multipart/related` request (using the multipart option). This has been observed in the .NET WebAPI version 4.0. You can turn on a boundary preambleCRLF or postamble by passing them as `true` to your request options. + +```js + request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json' + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ], + // alternatively pass an object containing additional options + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }) +``` + +[back to top](#table-of-contents) + + +--- + + +## HTTP Authentication + +```js +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); +``` + +If passed as an option, `auth` should be a hash containing values: + +- `user` || `username` +- `pass` || `password` +- `sendImmediately` (optional) +- `bearer` (optional) + +The method form takes parameters +`auth(username, password, sendImmediately, bearer)`. + +`sendImmediately` defaults to `true`, which causes a basic or bearer +authentication header to be sent. If `sendImmediately` is `false`, then +`request` will retry with a proper authentication header after receiving a +`401` response from the server (which must contain a `WWW-Authenticate` header +indicating the required authentication method). + +Note that you can also specify basic authentication using the URL itself, as +detailed in [RFC 1738](http://www.ietf.org/rfc/rfc1738.txt). Simply pass the +`user:password` before the host with an `@` sign: + +```js +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); +``` + +Digest authentication is supported, but it only works with `sendImmediately` +set to `false`; otherwise `request` will send basic authentication on the +initial request, which will probably cause the request to fail. + +Bearer authentication is supported, and is activated when the `bearer` value is +available. The value may be either a `String` or a `Function` returning a +`String`. Using a function to supply the bearer token is particularly useful if +used in conjuction with `defaults` to allow a single function to supply the +last known token at the time of sending a request, or to compute one on the fly. + +[back to top](#table-of-contents) + + +--- + + +## Custom HTTP Headers + +HTTP Headers, such as `User-Agent`, can be set in the `options` object. +In the example below, we call the github API to find out the number +of stars and forks for the request repository. This requires a +custom `User-Agent` header as well as https. + +```js +var request = require('request'); + +var options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); +``` + +[back to top](#table-of-contents) + + +--- + + +## OAuth Signing + +[OAuth version 1.0](https://tools.ietf.org/html/rfc5849) is supported. The +default signing algorithm is +[HMAC-SHA1](https://tools.ietf.org/html/rfc5849#section-3.4.2): + +```js +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +var qs = require('querystring') + , oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body) + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}) + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, json:true}, function (e, r, user) { + console.log(user) + }) + }) +}) +``` + +For [RSA-SHA1 signing](https://tools.ietf.org/html/rfc5849#section-3.4.3), make +the following changes to the OAuth options object: +* Pass `signature_method : 'RSA-SHA1'` +* Instead of `consumer_secret`, specify a `private_key` string in + [PEM format](http://how2ssl.com/articles/working_with_pem_files/) + +For [PLAINTEXT signing](http://oauth.net/core/1.0/#anchor22), make +the following changes to the OAuth options object: +* Pass `signature_method : 'PLAINTEXT'` + +To send OAuth parameters via query params or in a post body as described in The +[Consumer Request Parameters](http://oauth.net/core/1.0/#consumer_req_param) +section of the oauth1 spec: +* Pass `transport_method : 'query'` or `transport_method : 'body'` in the OAuth + options object. +* `transport_method` defaults to `'header'` + +[back to top](#table-of-contents) + + +--- + + +## Proxies + +If you specify a `proxy` option, then the request (and any subsequent +redirects) will be sent via a connection to the proxy server. + +If your endpoint is an `https` url, and you are using a proxy, then +request will send a `CONNECT` request to the proxy server *first*, and +then use the supplied connection to connect to the endpoint. + +That is, first it will make a request like: + +``` +HTTP/1.1 CONNECT endpoint-server.com:80 +Host: proxy-server.com +User-Agent: whatever user agent you specify +``` + +and then the proxy server make a TCP connection to `endpoint-server` +on port `80`, and return a response that looks like: + +``` +HTTP/1.1 200 OK +``` + +At this point, the connection is left open, and the client is +communicating directly with the `endpoint-server.com` machine. + +See [the wikipedia page on HTTP Tunneling](http://en.wikipedia.org/wiki/HTTP_tunnel) +for more information. + +By default, when proxying `http` traffic, request will simply make a +standard proxied `http` request. This is done by making the `url` +section of the initial line of the request a fully qualified url to +the endpoint. + +For example, it will make a single request that looks like: + +``` +HTTP/1.1 GET http://endpoint-server.com/some-url +Host: proxy-server.com +Other-Headers: all go here + +request body or whatever +``` + +Because a pure "http over http" tunnel offers no additional security +or other features, it is generally simpler to go with a +straightforward HTTP proxy in this case. However, if you would like +to force a tunneling proxy, you may set the `tunnel` option to `true`. + +You can also make a standard proxied `http` request by explicitly setting +`tunnel : false`, but **note that this will allow the proxy to see the traffic +to/from the destination server**. + +If you are using a tunneling proxy, you may set the +`proxyHeaderWhiteList` to share certain headers with the proxy. + +You can also set the `proxyHeaderExclusiveList` to share certain +headers only with the proxy and not with destination host. + +By default, this set is: + +``` +accept +accept-charset +accept-encoding +accept-language +accept-ranges +cache-control +content-encoding +content-language +content-length +content-location +content-md5 +content-range +content-type +connection +date +expect +max-forwards +pragma +proxy-authorization +referer +te +transfer-encoding +user-agent +via +``` + +Note that, when using a tunneling proxy, the `proxy-authorization` +header and any headers from custom `proxyHeaderExclusiveList` are +*never* sent to the endpoint server, but only to the proxy server. + + +### Controlling proxy behaviour using environment variables + +The following environment variables are respected by `request`: + + * `HTTP_PROXY` / `http_proxy` + * `HTTPS_PROXY` / `https_proxy` + * `NO_PROXY` / `no_proxy` + +When `HTTP_PROXY` / `http_proxy` are set, they will be used to proxy non-SSL requests that do not have an explicit `proxy` configuration option present. Similarly, `HTTPS_PROXY` / `https_proxy` will be respected for SSL requests that do not have an explicit `proxy` configuration option. It is valid to define a proxy in one of the environment variables, but then override it for a specific request, using the `proxy` configuration option. Furthermore, the `proxy` configuration option can be explicitly set to false / null to opt out of proxying altogether for that request. + +`request` is also aware of the `NO_PROXY`/`no_proxy` environment variables. These variables provide a granular way to opt out of proxying, on a per-host basis. It should contain a comma separated list of hosts to opt out of proxying. It is also possible to opt of proxying when a particular destination port is used. Finally, the variable may be set to `*` to opt out of the implicit proxy configuration of the other environment variables. + +Here's some examples of valid `no_proxy` values: + + * `google.com` - don't proxy HTTP/HTTPS requests to Google. + * `google.com:443` - don't proxy HTTPS requests to Google, but *do* proxy HTTP requests to Google. + * `google.com:443, yahoo.com:80` - don't proxy HTTPS requests to Google, and don't proxy HTTP requests to Yahoo! + * `*` - ignore `https_proxy`/`http_proxy` environment variables altogether. + +[back to top](#table-of-contents) + + +--- + + +## UNIX Domain Sockets + +`request` supports making requests to [UNIX Domain Sockets](http://en.wikipedia.org/wiki/Unix_domain_socket). To make one, use the following URL scheme: + +```js +/* Pattern */ 'http://unix:SOCKET:PATH' +/* Example */ request.get('http://unix:/absolute/path/to/unix.socket:/request/path') +``` + +Note: The `SOCKET` path is assumed to be absolute to the root of the host file system. + +[back to top](#table-of-contents) + + +--- + + +## TLS/SSL Protocol + +TLS/SSL Protocol options, such as `cert`, `key` and `passphrase`, can be +set in the `agentOptions` property of the `options` object. +In the example below, we call an API requires client side SSL certificate +(in PEM format) with passphrase protected private key (in PEM format) and disable the SSLv3 protocol: + +```js +var fs = require('fs') + , path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , request = require('request'); + +var options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); +``` + +It is able to force using SSLv3 only by specifying `secureProtocol`: + +```js +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); +``` + +It is possible to accept other certificates than those signed by generally allowed Certificate Authorities (CAs). +This can be useful, for example, when using self-signed certificates. +To allow a different certificate, you can specify the signing CA by adding the contents of the CA's certificate file to the `agentOptions`: + +```js +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); +``` + +[back to top](#table-of-contents) + + +--- + +## Support for HAR 1.2 + +The `options.har` property will override the values: `url`, `method`, `qs`, `headers`, `form`, `formData`, `body`, `json`, as well as construct multipart data and read files from disk when `request.postData.params[].fileName` is present without a matching `value`. + +a validation step will check if the HAR Request format matches the latest spec (v1.2) and will skip parsing if not matching. + +```js + var request = require('request') + request({ + // will be ignored + method: 'GET' + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har' + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }) + + // a POST request will be sent to http://www.mockbin.com + // with body an application/x-www-form-urlencoded body: + // foo=bar&hello=world +``` + +[back to top](#table-of-contents) + + +--- + +## request(options, callback) + +The first argument can be either a `url` or an `options` object. The only required option is `uri`; all others are optional. + +- `uri` || `url` - fully qualified uri or a parsed url object from `url.parse()` +- `baseUrl` - fully qualified uri string used as the base url. Most useful with `request.defaults`, for example when you want to do many requests to the same domain. If `baseUrl` is `https://example.com/api/`, then requesting `/end/point?test=true` will fetch `https://example.com/api/end/point?test=true`. When `baseUrl` is given, `uri` must also be a string. +- `method` - http method (default: `"GET"`) +- `headers` - http headers (default: `{}`) + +--- + +- `qs` - object containing querystring values to be appended to the `uri` +- `qsParseOptions` - object containing options to pass to the [qs.parse](https://github.com/hapijs/qs#parsing-objects) method or [querystring.parse](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_parse_str_sep_eq_options) method +- `qsStringifyOptions` - object containing options to pass to the [qs.stringify](https://github.com/hapijs/qs#stringifying) method or to the [querystring.stringify](https://nodejs.org/docs/v0.12.0/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) method. For example, to change the way arrays are converted to query strings pass the `arrayFormat` option with one of `indices|brackets|repeat` +- `useQuerystring` - If true, use `querystring` to stringify and parse + querystrings, otherwise use `qs` (default: `false`). Set this option to + `true` if you need arrays to be serialized as `foo=bar&foo=baz` instead of the + default `foo[0]=bar&foo[1]=baz`. + +--- + +- `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer` or `String`, unless `json` is `true`. If `json` is `true`, then `body` must be a JSON-serializable object. +- `form` - when passed an object or a querystring, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded` header. When passed no options, a `FormData` instance is returned (and is piped to request). See "Forms" section above. +- `formData` - Data to pass for a `multipart/form-data` request. See + [Forms](#forms) section above. +- `multipart` - array of objects which contain their own headers and `body` + attributes. Sends a `multipart/related` request. See [Forms](#forms) section + above. + - Alternatively you can pass in an object `{chunked: false, data: []}` where + `chunked` is used to specify whether the request is sent in + [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding) + In non-chunked requests, data items with body streams are not allowed. +- `preambleCRLF` - append a newline/CRLF before the boundary of your `multipart/form-data` request. +- `postambleCRLF` - append a newline/CRLF at the end of the boundary of your `multipart/form-data` request. +- `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON. +- `jsonReviver` - a [reviver function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) that will be passed to `JSON.parse()` when parsing a JSON response body. + +--- + +- `auth` - A hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above. +- `oauth` - Options for OAuth HMAC-SHA1 signing. See documentation above. +- `hawk` - Options for [Hawk signing](https://github.com/hueniverse/hawk). The `credentials` key must contain the necessary signing info, [see hawk docs for details](https://github.com/hueniverse/hawk#usage-example). +- `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`. Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services) +- `httpSignature` - Options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options. + +--- + +- `followRedirect` - follow HTTP 3xx responses as redirects (default: `true`). This property can also be implemented as function which gets `response` object as a single argument and should return `true` if redirects should continue or `false` otherwise. +- `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects (default: `false`) +- `maxRedirects` - the maximum number of redirects to follow (default: `10`) + +--- + +- `encoding` - Encoding to be used on `setEncoding` of response data. If `null`, the `body` is returned as a `Buffer`. Anything else **(including the default value of `undefined`)** will be passed as the [encoding](http://nodejs.org/api/buffer.html#buffer_buffer) parameter to `toString()` (meaning this is effectively `utf8` by default). +- `gzip` - If `true`, add an `Accept-Encoding` header to request compressed content encodings from the server (if not already present) and decode supported content encodings in the response. **Note:** Automatic decoding of the response content is performed on the body data returned through `request` (both through the `request` stream and passed to the callback function) but is not performed on the `response` stream (available from the `response` event) which is the unmodified `http.IncomingMessage` object which may contain compressed data. See example below. +- `jar` - If `true` and `tough-cookie` is installed, remember cookies for future use (or define your custom cookie jar; see examples section) + +--- + +- `pool` - An object describing which agents to use for the request. If this option is omitted the request will use the global agent (as long as [your options allow for it](request.js#L747)). Otherwise, request will search the pool for your custom agent. If no custom agent is found, a new agent will be created and added to the pool. + - A `maxSockets` property can also be provided on the `pool` object to set the max number of sockets for all agents created (ex: `pool: {maxSockets: Infinity}`). + - Note that if you are sending multiple requests in a loop and creating + multiple new `pool` objects, `maxSockets` will not work as intended. To + work around this, either use [`request.defaults`](#requestdefaultsoptions) + with your pool options or create the pool object with the `maxSockets` + property outside of the loop. +- `timeout` - Integer containing the number of milliseconds to wait for a + request to respond before aborting the request. Note that if the underlying + TCP connection cannot be established, the OS-wide TCP connection timeout will + overrule the `timeout` option ([the default in Linux is around 20 seconds](http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout)). +- `localAddress` - Local interface to bind for network connections. +- `proxy` - An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the `url` parameter (by embedding the auth info in the `uri`) +- `strictSSL` - If `true`, requires SSL certificates be valid. **Note:** to use your own certificate authority, you need to specify an agent that was created with that CA as an option. +- `agentOptions` - Object containing user agent options. See documentation above. **Note:** [see tls API doc for TLS/SSL options](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback). +- `tunnel` - controls the behavior of + [HTTP `CONNECT` tunneling](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_tunneling) + as follows: + - `undefined` (default) - `true` if the destination is `https` or a previous + request in the redirect chain used a tunneling proxy, `false` otherwise + - `true` - always tunnel to the destination by making a `CONNECT` request to + the proxy + - `false` - request the destination as a `GET` request. +- `proxyHeaderWhiteList` - A whitelist of headers to send to a + tunneling proxy. +- `proxyHeaderExclusiveList` - A whitelist of headers to send + exclusively to a tunneling proxy and not to destination. +- `removeRefererHeader` - removes the referer header when a redirect happens (default: `false`). + +--- + +- `time` - If `true`, the request-response cycle (including all redirects) is timed at millisecond resolution, and the result provided on the response's `elapsedTime` property. + +--- + +- `har` - A [HAR 1.2 Request Object](http://www.softwareishard.com/blog/har-12-spec/#request), will be processed from HAR format into options overwriting matching values *(see the [HAR 1.2 section](#support-for-har-1.2) for details)* + +The callback argument gets 3 arguments: + +1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object) +2. An [`http.IncomingMessage`](http://nodejs.org/api/http.html#http_http_incomingmessage) object +3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied) + +[back to top](#table-of-contents) + + +--- + +## Convenience methods + +There are also shorthand methods for different HTTP METHODs and some other conveniences. + + +### request.defaults(options) + +This method **returns a wrapper** around the normal request API that defaults +to whatever options you pass to it. + +**Note:** `request.defaults()` **does not** modify the global request API; +instead, it **returns a wrapper** that has your default settings applied to it. + +**Note:** You can call `.defaults()` on the wrapper that is returned from +`request.defaults` to add/override defaults that were previously defaulted. + +For example: +```js +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {x-token: 'my-token'} +}) + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}) +``` + +### request.put + +Same as `request()`, but defaults to `method: "PUT"`. + +```js +request.put(url) +``` + +### request.patch + +Same as `request()`, but defaults to `method: "PATCH"`. + +```js +request.patch(url) +``` + +### request.post + +Same as `request()`, but defaults to `method: "POST"`. + +```js +request.post(url) +``` + +### request.head + +Same as `request()`, but defaults to `method: "HEAD"`. + +```js +request.head(url) +``` + +### request.del + +Same as `request()`, but defaults to `method: "DELETE"`. + +```js +request.del(url) +``` + +### request.get + +Same as `request()` (for uniformity). + +```js +request.get(url) +``` +### request.cookie + +Function that creates a new cookie. + +```js +request.cookie('key1=value1') +``` +### request.jar() + +Function that creates a new cookie jar. + +```js +request.jar() +``` + +[back to top](#table-of-contents) + + +--- + + +## Debugging + +There are at least three ways to debug the operation of `request`: + +1. Launch the node process like `NODE_DEBUG=request node script.js` + (`lib,request,otherlib` works too). + +2. Set `require('request').debug = true` at any time (this does the same thing + as #1). + +3. Use the [request-debug module](https://github.com/nylen/request-debug) to + view request and response headers and bodies. + +[back to top](#table-of-contents) + + +--- + + +## Examples: + +```js + var request = require('request') + , rand = Math.floor(Math.random()*100000000).toString() + ; + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ) +``` + +For backwards-compatibility, response compression is not supported by default. +To accept gzip-compressed responses, set the `gzip` option to `true`. Note +that the body data passed through `request` is automatically decompressed +while the response object is unmodified and will contain compressed data if +the server sent a compressed response. + +```js + var request = require('request') + request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }) +``` + +Cookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set `jar` to `true` (either in `defaults` or `options`) and install `tough-cookie`. + +```js +var request = request.defaults({jar: true}) +request('http://www.google.com', function () { + request('http://images.google.com') +}) +``` + +To use a custom cookie jar (instead of `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`) + +```js +var j = request.jar() +var request = request.defaults({jar:j}) +request('http://www.google.com', function () { + request('http://images.google.com') +}) +``` + +OR + +```js +var j = request.jar(); +var cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com') +}) +``` + +To use a custom cookie store (such as a +[`FileCookieStore`](https://github.com/mitsuru/tough-cookie-filestore) +which supports saving to and restoring from JSON files), pass it as a parameter +to `request.jar()`: + +```js +var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +var j = request.jar(new FileCookieStore('cookies.json')); +request = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com') +}) +``` + +The cookie store must be a +[`tough-cookie`](https://github.com/goinstant/tough-cookie) +store and it must support synchronous operations; see the +[`CookieStore` API docs](https://github.com/goinstant/tough-cookie/#cookiestore-api) +for details. + +To inspect your cookie jar after a request: + +```js +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(uri); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(uri); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}) +``` + +[back to top](#table-of-contents) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/disabled.appveyor.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/disabled.appveyor.yml new file mode 100644 index 0000000..238f3d6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/disabled.appveyor.yml @@ -0,0 +1,36 @@ +# http://www.appveyor.com/docs/appveyor-yml + +# Fix line endings in Windows. (runs before repo cloning) +init: + - git config --global core.autocrlf input + +# Test against these versions of Node.js. +environment: + matrix: + - nodejs_version: "0.10" + - nodejs_version: "0.8" + - nodejs_version: "0.11" + +# Allow failing jobs for bleeding-edge Node.js versions. +matrix: + allow_failures: + - nodejs_version: "0.11" + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node 0.STABLE.latest + - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) + # Typical npm stuff. + - npm install + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - ps: "npm test # PowerShell" # Pass comment to PS for easier debugging + - cmd: npm test + +# Don't actually build. +build: off + +# Set build version format here instead of in the admin panel. +version: "{build}" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/examples/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/examples/README.md new file mode 100644 index 0000000..526d71b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/examples/README.md @@ -0,0 +1,115 @@ + +# Authentication + +## OAuth + +### OAuth1.0 Refresh Token + +- http://oauth.googlecode.com/svn/spec/ext/session/1.0/drafts/1/spec.html#anchor4 +- https://developer.yahoo.com/oauth/guide/oauth-refreshaccesstoken.html + +```js +request.post('https://api.login.yahoo.com/oauth/v2/get_token', { + oauth: { + consumer_key: '...', + consumer_secret: '...', + token: '...', + token_secret: '...', + session_handle: '...' + } +}, function (err, res, body) { + var result = require('querystring').parse(body) + // assert.equal(typeof result, 'object') +}) +``` + +### OAuth2 Refresh Token + +- https://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-6 + +```js +request.post('https://accounts.google.com/o/oauth2/token', { + form: { + grant_type: 'refresh_token', + client_id: '...', + client_secret: '...', + refresh_token: '...' + }, + json: true +}, function (err, res, body) { + // assert.equal(typeof body, 'object') +}) +``` + +# Multipart + +## multipart/form-data + +### Flickr Image Upload + +- https://www.flickr.com/services/api/upload.api.html + +```js +request.post('https://up.flickr.com/services/upload', { + oauth: { + consumer_key: '...', + consumer_secret: '...', + token: '...', + token_secret: '...' + }, + // all meta data should be included here for proper signing + qs: { + title: 'My cat is awesome', + description: 'Sent on ' + new Date(), + is_public: 1 + }, + // again the same meta data + the actual photo + formData: { + title: 'My cat is awesome', + description: 'Sent on ' + new Date(), + is_public: 1, + photo:fs.createReadStream('cat.png') + }, + json: true +}, function (err, res, body) { + // assert.equal(typeof body, 'object') +}) +``` + +# Streams + +## `POST` data + +Use Request as a Writable stream to easily `POST` Readable streams (like files, other HTTP requests, or otherwise). + +TL;DR: Pipe a Readable Stream onto Request via: + +``` +READABLE.pipe(request.post(URL)); +``` + +A more detailed example: + +```js +var fs = require('fs') + , path = require('path') + , http = require('http') + , request = require('request') + , TMP_FILE_PATH = path.join(path.sep, 'tmp', 'foo') +; + +// write a temporary file: +fs.writeFileSync(TMP_FILE_PATH, 'foo bar baz quk\n'); + +http.createServer(function(req, res) { + console.log('the server is receiving data!\n'); + req + .on('end', res.end.bind(res)) + .pipe(process.stdout) + ; +}).listen(3000).unref(); + +fs.createReadStream(TMP_FILE_PATH) + .pipe(request.post('http://127.0.0.1:3000')) +; +``` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/index.js new file mode 100755 index 0000000..3474840 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/index.js @@ -0,0 +1,154 @@ +// Copyright 2010-2012 Mikeal Rogers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict' + +var extend = require('util')._extend + , cookies = require('./lib/cookies') + , helpers = require('./lib/helpers') + +var isFunction = helpers.isFunction + , paramsHaveRequestBody = helpers.paramsHaveRequestBody + + +// organize params for patch, post, put, head, del +function initParams(uri, options, callback) { + if (typeof options === 'function') { + callback = options + } + + var params = {} + if (typeof options === 'object') { + params = extend({}, options) + params = extend(params, {uri: uri}) + } else if (typeof uri === 'string') { + params = extend({}, {uri: uri}) + } else { + params = extend({}, uri) + } + + params.callback = callback + return params +} + +function request (uri, options, callback) { + if (typeof uri === 'undefined') { + throw new Error('undefined is not a valid uri or options object.') + } + + var params = initParams(uri, options, callback) + + if (params.method === 'HEAD' && paramsHaveRequestBody(params)) { + throw new Error('HTTP HEAD requests MUST NOT include a request body.') + } + + return new request.Request(params) +} + +var verbs = ['get', 'head', 'post', 'put', 'patch', 'del'] + +verbs.forEach(function(verb) { + var method = verb === 'del' ? 'DELETE' : verb.toUpperCase() + request[verb] = function (uri, options, callback) { + var params = initParams(uri, options, callback) + params.method = method + return request(params, params.callback) + } +}) + +request.jar = function (store) { + return cookies.jar(store) +} + +request.cookie = function (str) { + return cookies.parse(str) +} + +function wrapRequestMethod (method, options, requester) { + + return function (uri, opts, callback) { + var params = initParams(uri, opts, callback) + + var headerlessOptions = extend({}, options) + delete headerlessOptions.headers + params = extend(headerlessOptions, params) + + if (options.headers) { + var headers = extend({}, options.headers) + params.headers = extend(headers, params.headers) + } + + if (typeof method === 'string') { + params.method = (method === 'del' ? 'DELETE' : method.toUpperCase()) + method = request[method] + } + + if (isFunction(requester)) { + method = requester + } + + return method(params, params.callback) + } +} + +request.defaults = function (options, requester) { + var self = this + + if (typeof options === 'function') { + requester = options + options = {} + } + + var defaults = wrapRequestMethod(self, options, requester) + + var verbs = ['get', 'head', 'post', 'put', 'patch', 'del'] + verbs.forEach(function(verb) { + defaults[verb] = wrapRequestMethod(verb, options, requester) + }) + + defaults.cookie = wrapRequestMethod(self.cookie, options, requester) + defaults.jar = self.jar + defaults.defaults = self.defaults + return defaults +} + +request.forever = function (agentOptions, optionsArg) { + var options = {} + if (optionsArg) { + options = extend({}, optionsArg) + } + if (agentOptions) { + options.agentOptions = agentOptions + } + + options.forever = true + return request.defaults(options) +} + +// Exports + +module.exports = request +request.Request = require('./request') +request.initParams = initParams + +// Backwards compatibility for request.debug +Object.defineProperty(request, 'debug', { + enumerable : true, + get : function() { + return request.Request.debug + }, + set : function(debug) { + request.Request.debug = debug + } +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/auth.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/auth.js new file mode 100644 index 0000000..13c3ac8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/auth.js @@ -0,0 +1,153 @@ +'use strict' + +var caseless = require('caseless') + , uuid = require('node-uuid') + , helpers = require('./helpers') + +var md5 = helpers.md5 + , toBase64 = helpers.toBase64 + + +function Auth (request) { + // define all public properties here + this.request = request + this.hasAuth = false + this.sentAuth = false + this.bearerToken = null + this.user = null + this.pass = null +} + +Auth.prototype.basic = function (user, pass, sendImmediately) { + var self = this + if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) { + throw new Error('auth() received invalid user or password') + } + self.user = user + self.pass = pass + self.hasAuth = true + var header = user + ':' + (pass || '') + if (sendImmediately || typeof sendImmediately === 'undefined') { + var authHeader = 'Basic ' + toBase64(header) + self.sentAuth = true + return authHeader + } +} + +Auth.prototype.bearer = function (bearer, sendImmediately) { + var self = this + self.bearerToken = bearer + self.hasAuth = true + if (sendImmediately || typeof sendImmediately === 'undefined') { + if (typeof bearer === 'function') { + bearer = bearer() + } + var authHeader = 'Bearer ' + (bearer || '') + self.sentAuth = true + return authHeader + } +} + +Auth.prototype.digest = function (method, path, authHeader) { + // TODO: More complete implementation of RFC 2617. + // - check challenge.algorithm + // - support algorithm="MD5-sess" + // - handle challenge.domain + // - support qop="auth-int" only + // - handle Authentication-Info (not necessarily?) + // - check challenge.stale (not necessarily?) + // - increase nc (not necessarily?) + // For reference: + // http://tools.ietf.org/html/rfc2617#section-3 + // https://github.com/bagder/curl/blob/master/lib/http_digest.c + + var self = this + + var challenge = {} + var re = /([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi + for (;;) { + var match = re.exec(authHeader) + if (!match) { + break + } + challenge[match[1]] = match[2] || match[3] + } + + var ha1 = md5(self.user + ':' + challenge.realm + ':' + self.pass) + var ha2 = md5(method + ':' + path) + var qop = /(^|,)\s*auth\s*($|,)/.test(challenge.qop) && 'auth' + var nc = qop && '00000001' + var cnonce = qop && uuid().replace(/-/g, '') + var digestResponse = qop + ? md5(ha1 + ':' + challenge.nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + ha2) + : md5(ha1 + ':' + challenge.nonce + ':' + ha2) + var authValues = { + username: self.user, + realm: challenge.realm, + nonce: challenge.nonce, + uri: path, + qop: qop, + response: digestResponse, + nc: nc, + cnonce: cnonce, + algorithm: challenge.algorithm, + opaque: challenge.opaque + } + + authHeader = [] + for (var k in authValues) { + if (authValues[k]) { + if (k === 'qop' || k === 'nc' || k === 'algorithm') { + authHeader.push(k + '=' + authValues[k]) + } else { + authHeader.push(k + '="' + authValues[k] + '"') + } + } + } + authHeader = 'Digest ' + authHeader.join(', ') + self.sentAuth = true + return authHeader +} + +Auth.prototype.onRequest = function (user, pass, sendImmediately, bearer) { + var self = this + , request = self.request + + var authHeader + if (bearer === undefined && user === undefined) { + throw new Error('no auth mechanism defined') + } else if (bearer !== undefined) { + authHeader = self.bearer(bearer, sendImmediately) + } else { + authHeader = self.basic(user, pass, sendImmediately) + } + if (authHeader) { + request.setHeader('authorization', authHeader) + } +} + +Auth.prototype.onResponse = function (response) { + var self = this + , request = self.request + + if (!self.hasAuth || self.sentAuth) { return null } + + var c = caseless(response.headers) + + var authHeader = c.get('www-authenticate') + var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase() + // debug('reauth', authVerb) + + switch (authVerb) { + case 'basic': + return self.basic(self.user, self.pass, true) + + case 'bearer': + return self.bearer(self.bearerToken, true) + + case 'digest': + return self.digest(request.method, request.path, authHeader) + } +} + +exports.Auth = Auth diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/cookies.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/cookies.js new file mode 100644 index 0000000..adde7c6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/cookies.js @@ -0,0 +1,39 @@ +'use strict' + +var tough = require('tough-cookie') + +var Cookie = tough.Cookie + , CookieJar = tough.CookieJar + + +exports.parse = function(str) { + if (str && str.uri) { + str = str.uri + } + if (typeof str !== 'string') { + throw new Error('The cookie function only accepts STRING as param') + } + return Cookie.parse(str) +} + +// Adapt the sometimes-Async api of tough.CookieJar to our requirements +function RequestJar(store) { + var self = this + self._jar = new CookieJar(store) +} +RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) { + var self = this + return self._jar.setCookieSync(cookieOrStr, uri, options || {}) +} +RequestJar.prototype.getCookieString = function(uri) { + var self = this + return self._jar.getCookieStringSync(uri) +} +RequestJar.prototype.getCookies = function(uri) { + var self = this + return self._jar.getCookiesSync(uri) +} + +exports.jar = function(store) { + return new RequestJar(store) +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/copy.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/copy.js new file mode 100644 index 0000000..ad162a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/copy.js @@ -0,0 +1,10 @@ +'use strict' + +module.exports = +function copy (obj) { + var o = {} + Object.keys(obj).forEach(function (i) { + o[i] = obj[i] + }) + return o +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/getProxyFromURI.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/getProxyFromURI.js new file mode 100644 index 0000000..c2013a6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/getProxyFromURI.js @@ -0,0 +1,79 @@ +'use strict' + +function formatHostname(hostname) { + // canonicalize the hostname, so that 'oogle.com' won't match 'google.com' + return hostname.replace(/^\.*/, '.').toLowerCase() +} + +function parseNoProxyZone(zone) { + zone = zone.trim().toLowerCase() + + var zoneParts = zone.split(':', 2) + , zoneHost = formatHostname(zoneParts[0]) + , zonePort = zoneParts[1] + , hasPort = zone.indexOf(':') > -1 + + return {hostname: zoneHost, port: zonePort, hasPort: hasPort} +} + +function uriInNoProxy(uri, noProxy) { + var port = uri.port || (uri.protocol === 'https:' ? '443' : '80') + , hostname = formatHostname(uri.hostname) + , noProxyList = noProxy.split(',') + + // iterate through the noProxyList until it finds a match. + return noProxyList.map(parseNoProxyZone).some(function(noProxyZone) { + var isMatchedAt = hostname.indexOf(noProxyZone.hostname) + , hostnameMatched = ( + isMatchedAt > -1 && + (isMatchedAt === hostname.length - noProxyZone.hostname.length) + ) + + if (noProxyZone.hasPort) { + return (port === noProxyZone.port) && hostnameMatched + } + + return hostnameMatched + }) +} + +function getProxyFromURI(uri) { + // Decide the proper request proxy to use based on the request URI object and the + // environmental variables (NO_PROXY, HTTP_PROXY, etc.) + // respect NO_PROXY environment variables (see: http://lynx.isc.org/current/breakout/lynx_help/keystrokes/environments.html) + + var noProxy = process.env.NO_PROXY || process.env.no_proxy || '' + + // if the noProxy is a wildcard then return null + + if (noProxy === '*') { + return null + } + + // if the noProxy is not empty and the uri is found return null + + if (noProxy !== '' && uriInNoProxy(uri, noProxy)) { + return null + } + + // Check for HTTP or HTTPS Proxy in environment Else default to null + + if (uri.protocol === 'http:') { + return process.env.HTTP_PROXY || + process.env.http_proxy || null + } + + if (uri.protocol === 'https:') { + return process.env.HTTPS_PROXY || + process.env.https_proxy || + process.env.HTTP_PROXY || + process.env.http_proxy || null + } + + // if none of that works, return null + // (What uri protocol are you using then?) + + return null +} + +module.exports = getProxyFromURI diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/har.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/har.js new file mode 100644 index 0000000..83453a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/har.js @@ -0,0 +1,205 @@ +'use strict' + +var fs = require('fs') +var qs = require('querystring') +var validate = require('har-validator') +var util = require('util') + +function Har (request) { + this.request = request +} + +Har.prototype.reducer = function (obj, pair) { + // new property ? + if (obj[pair.name] === undefined) { + obj[pair.name] = pair.value + return obj + } + + // existing? convert to array + var arr = [ + obj[pair.name], + pair.value + ] + + obj[pair.name] = arr + + return obj +} + +Har.prototype.prep = function (data) { + // construct utility properties + data.queryObj = {} + data.headersObj = {} + data.postData.jsonObj = false + data.postData.paramsObj = false + + // construct query objects + if (data.queryString && data.queryString.length) { + data.queryObj = data.queryString.reduce(this.reducer, {}) + } + + // construct headers objects + if (data.headers && data.headers.length) { + // loweCase header keys + data.headersObj = data.headers.reduceRight(function (headers, header) { + headers[header.name] = header.value + return headers + }, {}) + } + + // construct Cookie header + if (data.cookies && data.cookies.length) { + var cookies = data.cookies.map(function (cookie) { + return cookie.name + '=' + cookie.value + }) + + if (cookies.length) { + data.headersObj.cookie = cookies.join('; ') + } + } + + // prep body + switch (data.postData.mimeType) { + case 'multipart/mixed': + case 'multipart/related': + case 'multipart/form-data': + case 'multipart/alternative': + // reset values + data.postData.mimeType = 'multipart/form-data' + break + + case 'application/x-www-form-urlencoded': + if (!data.postData.params) { + data.postData.text = '' + } else { + data.postData.paramsObj = data.postData.params.reduce(this.reducer, {}) + + // always overwrite + data.postData.text = qs.stringify(data.postData.paramsObj) + } + break + + case 'text/json': + case 'text/x-json': + case 'application/json': + case 'application/x-json': + data.postData.mimeType = 'application/json' + + if (data.postData.text) { + try { + data.postData.jsonObj = JSON.parse(data.postData.text) + } catch (e) { + this.request.debug(e) + + // force back to text/plain + data.postData.mimeType = 'text/plain' + } + } + break + } + + return data +} + +Har.prototype.options = function (options) { + // skip if no har property defined + if (!options.har) { + return options + } + + var har = util._extend({}, options.har) + + // only process the first entry + if (har.log && har.log.entries) { + har = har.log.entries[0] + } + + // add optional properties to make validation successful + har.url = har.url || options.url || options.uri || options.baseUrl || '/' + har.httpVersion = har.httpVersion || 'HTTP/1.1' + har.queryString = har.queryString || [] + har.headers = har.headers || [] + har.cookies = har.cookies || [] + har.postData = har.postData || {} + har.postData.mimeType = har.postData.mimeType || 'application/octet-stream' + + har.bodySize = 0 + har.headersSize = 0 + har.postData.size = 0 + + if (!validate.request(har)) { + return options + } + + // clean up and get some utility properties + var req = this.prep(har) + + // construct new options + if (req.url) { + options.url = req.url + } + + if (req.method) { + options.method = req.method + } + + if (Object.keys(req.queryObj).length) { + options.qs = req.queryObj + } + + if (Object.keys(req.headersObj).length) { + options.headers = req.headersObj + } + + switch (req.postData.mimeType) { + case 'application/x-www-form-urlencoded': + options.form = req.postData.paramsObj + break + + case 'application/json': + if (req.postData.jsonObj) { + options.body = req.postData.jsonObj + options.json = true + } + break + + case 'multipart/form-data': + options.formData = {} + + req.postData.params.forEach(function (param) { + var attachment = {} + + if (!param.fileName && !param.fileName && !param.contentType) { + options.formData[param.name] = param.value + return + } + + // attempt to read from disk! + if (param.fileName && !param.value) { + attachment.value = fs.createReadStream(param.fileName) + } else if (param.value) { + attachment.value = param.value + } + + if (param.fileName) { + attachment.options = { + filename: param.fileName, + contentType: param.contentType ? param.contentType : null + } + } + + options.formData[param.name] = attachment + }) + break + + default: + if (req.postData.text) { + options.body = req.postData.text + } + } + + return options +} + +exports.Har = Har diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/helpers.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/helpers.js new file mode 100644 index 0000000..8530d40 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/helpers.js @@ -0,0 +1,55 @@ +'use strict' + +var jsonSafeStringify = require('json-stringify-safe') + , crypto = require('crypto') + +function deferMethod() { + if(typeof setImmediate === 'undefined') { + return process.nextTick + } + + return setImmediate +} + +function isFunction(value) { + return typeof value === 'function' +} + +function paramsHaveRequestBody(params) { + return ( + params.body || + params.requestBodyStream || + (params.json && typeof params.json !== 'boolean') || + params.multipart + ) +} + +function safeStringify (obj) { + var ret + try { + ret = JSON.stringify(obj) + } catch (e) { + ret = jsonSafeStringify(obj) + } + return ret +} + +function md5 (str) { + return crypto.createHash('md5').update(str).digest('hex') +} + +function isReadStream (rs) { + return rs.readable && rs.path && rs.mode +} + +function toBase64 (str) { + return (new Buffer(str || '', 'utf8')).toString('base64') +} + +exports.isFunction = isFunction +exports.paramsHaveRequestBody = paramsHaveRequestBody +exports.safeStringify = safeStringify +exports.md5 = md5 +exports.isReadStream = isReadStream +exports.toBase64 = toBase64 +exports.defer = deferMethod() diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/multipart.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/multipart.js new file mode 100644 index 0000000..905a54b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/multipart.js @@ -0,0 +1,109 @@ +'use strict' + +var uuid = require('node-uuid') + , CombinedStream = require('combined-stream') + , isstream = require('isstream') + + +function Multipart (request) { + this.request = request + this.boundary = uuid() + this.chunked = false + this.body = null +} + +Multipart.prototype.isChunked = function (options) { + var self = this + , chunked = false + , parts = options.data || options + + if (!parts.forEach) { + throw new Error('Argument error, options.multipart.') + } + + if (options.chunked !== undefined) { + chunked = options.chunked + } + + if (self.request.getHeader('transfer-encoding') === 'chunked') { + chunked = true + } + + if (!chunked) { + parts.forEach(function (part) { + if(typeof part.body === 'undefined') { + throw new Error('Body attribute missing in multipart.') + } + if (isstream(part.body)) { + chunked = true + } + }) + } + + return chunked +} + +Multipart.prototype.setHeaders = function (chunked) { + var self = this + + if (chunked && !self.request.hasHeader('transfer-encoding')) { + self.request.setHeader('transfer-encoding', 'chunked') + } + + var header = self.request.getHeader('content-type') + + if (!header || header.indexOf('multipart') === -1) { + self.request.setHeader('content-type', 'multipart/related; boundary=' + self.boundary) + } else { + if (header.indexOf('boundary') !== -1) { + self.boundary = header.replace(/.*boundary=([^\s;]+).*/, '$1') + } else { + self.request.setHeader('content-type', header + '; boundary=' + self.boundary) + } + } +} + +Multipart.prototype.build = function (parts, chunked) { + var self = this + var body = chunked ? new CombinedStream() : [] + + function add (part) { + return chunked ? body.append(part) : body.push(new Buffer(part)) + } + + if (self.request.preambleCRLF) { + add('\r\n') + } + + parts.forEach(function (part) { + var preamble = '--' + self.boundary + '\r\n' + Object.keys(part).forEach(function (key) { + if (key === 'body') { return } + preamble += key + ': ' + part[key] + '\r\n' + }) + preamble += '\r\n' + add(preamble) + add(part.body) + add('\r\n') + }) + add('--' + self.boundary + '--') + + if (self.request.postambleCRLF) { + add('\r\n') + } + + return body +} + +Multipart.prototype.onRequest = function (options) { + var self = this + + var chunked = self.isChunked(options) + , parts = options.data || options + + self.setHeaders(chunked) + self.chunked = chunked + self.body = self.build(parts, chunked) +} + +exports.Multipart = Multipart diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/oauth.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/oauth.js new file mode 100644 index 0000000..fc1cac6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/oauth.js @@ -0,0 +1,125 @@ +'use strict' + +var qs = require('qs') + , caseless = require('caseless') + , uuid = require('node-uuid') + , oauth = require('oauth-sign') + + +function OAuth (request) { + this.request = request +} + +OAuth.prototype.buildParams = function (_oauth, uri, method, query, form, qsLib) { + var oa = {} + for (var i in _oauth) { + oa['oauth_' + i] = _oauth[i] + } + if (!oa.oauth_version) { + oa.oauth_version = '1.0' + } + if (!oa.oauth_timestamp) { + oa.oauth_timestamp = Math.floor( Date.now() / 1000 ).toString() + } + if (!oa.oauth_nonce) { + oa.oauth_nonce = uuid().replace(/-/g, '') + } + if (!oa.oauth_signature_method) { + oa.oauth_signature_method = 'HMAC-SHA1' + } + + var consumer_secret_or_private_key = oa.oauth_consumer_secret || oa.oauth_private_key + delete oa.oauth_consumer_secret + delete oa.oauth_private_key + + var token_secret = oa.oauth_token_secret + delete oa.oauth_token_secret + + var realm = oa.oauth_realm + delete oa.oauth_realm + delete oa.oauth_transport_method + + var baseurl = uri.protocol + '//' + uri.host + uri.pathname + var params = qsLib.parse([].concat(query, form, qsLib.stringify(oa)).join('&')) + + oa.oauth_signature = oauth.sign( + oa.oauth_signature_method, + method, + baseurl, + params, + consumer_secret_or_private_key, + token_secret) + + if (realm) { + oa.realm = realm + } + + return oa +} + +OAuth.prototype.concatParams = function (oa, sep, wrap) { + wrap = wrap || '' + + var params = Object.keys(oa).filter(function (i) { + return i !== 'realm' && i !== 'oauth_signature' + }).sort() + + if (oa.realm) { + params.splice(0, 1, 'realm') + } + params.push('oauth_signature') + + return params.map(function (i) { + return i + '=' + wrap + oauth.rfc3986(oa[i]) + wrap + }).join(sep) +} + +OAuth.prototype.onRequest = function (_oauth) { + var self = this + , request = self.request + + var uri = request.uri || {} + , method = request.method || '' + , headers = caseless(request.headers) + , body = request.body || '' + , qsLib = request.qsLib || qs + + var form + , query + , contentType = headers.get('content-type') || '' + , formContentType = 'application/x-www-form-urlencoded' + , transport = _oauth.transport_method || 'header' + + if (contentType.slice(0, formContentType.length) === formContentType) { + contentType = formContentType + form = body + } + if (uri.query) { + query = uri.query + } + if (transport === 'body' && (method !== 'POST' || contentType !== formContentType)) { + throw new Error('oauth: transport_method of \'body\' requires \'POST\' ' + + 'and content-type \'' + formContentType + '\'') + } + + var oa = this.buildParams(_oauth, uri, method, query, form, qsLib) + + switch (transport) { + case 'header': + request.setHeader('Authorization', 'OAuth ' + this.concatParams(oa, ',', '"')) + break + + case 'query': + request.path = (query ? '&' : '?') + this.concatParams(oa, '&') + break + + case 'body': + request.body = (form ? form + '&' : '') + this.concatParams(oa, '&') + break + + default: + throw new Error('oauth: transport_method invalid') + } +} + +exports.OAuth = OAuth diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/redirect.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/redirect.js new file mode 100644 index 0000000..7dd6c25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/lib/redirect.js @@ -0,0 +1,154 @@ +'use strict' + +var url = require('url') +var isUrl = /^https?:/ + +function Redirect (request) { + this.request = request + this.followRedirect = true + this.followRedirects = true + this.followAllRedirects = false + this.allowRedirect = function () {return true} + this.maxRedirects = 10 + this.redirects = [] + this.redirectsFollowed = 0 + this.removeRefererHeader = false +} + +Redirect.prototype.onRequest = function () { + var self = this + , request = self.request + + if (request.maxRedirects !== undefined) { + self.maxRedirects = request.maxRedirects + } + if (typeof request.followRedirect === 'function') { + self.allowRedirect = request.followRedirect + } + if (request.followRedirect !== undefined) { + self.followRedirects = !!request.followRedirect + } + if (request.followAllRedirects !== undefined) { + self.followAllRedirects = request.followAllRedirects + } + if (self.followRedirects || self.followAllRedirects) { + self.redirects = self.redirects || [] + } + if (request.removeRefererHeader !== undefined) { + self.removeRefererHeader = request.removeRefererHeader + } +} + +Redirect.prototype.redirectTo = function (response) { + var self = this + , request = self.request + + var redirectTo = null + if (response.statusCode >= 300 && response.statusCode < 400 && response.caseless.has('location')) { + var location = response.caseless.get('location') + // debug('redirect', location) + + if (self.followAllRedirects) { + redirectTo = location + } else if (self.followRedirects) { + switch (request.method) { + case 'PATCH': + case 'PUT': + case 'POST': + case 'DELETE': + // Do not follow redirects + break + default: + redirectTo = location + break + } + } + } else if (response.statusCode === 401) { + var authHeader = request._auth.onResponse(response) + if (authHeader) { + request.setHeader('authorization', authHeader) + redirectTo = request.uri + } + } + return redirectTo +} + +Redirect.prototype.onResponse = function (response) { + var self = this + , request = self.request + + var redirectTo = self.redirectTo(response) + if (!redirectTo || !self.allowRedirect.call(request, response)) { + return false + } + + + // debug('redirect to', redirectTo) + + // ignore any potential response body. it cannot possibly be useful + // to us at this point. + if (request._paused) { + response.resume() + } + + if (self.redirectsFollowed >= self.maxRedirects) { + request.emit('error', new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + request.uri.href)) + return false + } + self.redirectsFollowed += 1 + + if (!isUrl.test(redirectTo)) { + redirectTo = url.resolve(request.uri.href, redirectTo) + } + + var uriPrev = request.uri + request.uri = url.parse(redirectTo) + + // handle the case where we change protocol from https to http or vice versa + if (request.uri.protocol !== uriPrev.protocol) { + request._updateProtocol() + } + + self.redirects.push( + { statusCode : response.statusCode + , redirectUri: redirectTo + } + ) + if (self.followAllRedirects && response.statusCode !== 401 && response.statusCode !== 307) { + request.method = 'GET' + } + // request.method = 'GET' // Force all redirects to use GET || commented out fixes #215 + delete request.src + delete request.req + delete request.agent + delete request._started + if (response.statusCode !== 401 && response.statusCode !== 307) { + // Remove parameters from the previous response, unless this is the second request + // for a server that requires digest authentication. + delete request.body + delete request._form + if (request.headers) { + request.removeHeader('host') + request.removeHeader('content-type') + request.removeHeader('content-length') + if (request.uri.hostname !== request.originalHost.split(':')[0]) { + // Remove authorization if changing hostnames (but not if just + // changing ports or protocols). This matches the behavior of curl: + // https://github.com/bagder/curl/blob/6beb0eee/lib/http.c#L710 + request.removeHeader('authorization') + } + } + } + + if (!self.removeRefererHeader) { + request.setHeader('referer', request.uri.href) + } + + request.emit('redirect') + + request.init() + + return true +} + +exports.Redirect = Redirect diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/LICENSE new file mode 100644 index 0000000..a4a9aee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/README.md new file mode 100644 index 0000000..763564e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/README.md @@ -0,0 +1,4 @@ +aws-sign +======== + +AWS signing. Originally pulled from LearnBoost/knox, maintained as vendor in request, now a standalone module. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/index.js new file mode 100644 index 0000000..576e49d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/index.js @@ -0,0 +1,202 @@ + +/*! + * knox - auth + * Copyright(c) 2010 LearnBoost + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var crypto = require('crypto') + , parse = require('url').parse + ; + +/** + * Valid keys. + */ + +var keys = + [ 'acl' + , 'location' + , 'logging' + , 'notification' + , 'partNumber' + , 'policy' + , 'requestPayment' + , 'torrent' + , 'uploadId' + , 'uploads' + , 'versionId' + , 'versioning' + , 'versions' + , 'website' + ] + +/** + * Return an "Authorization" header value with the given `options` + * in the form of "AWS :" + * + * @param {Object} options + * @return {String} + * @api private + */ + +function authorization (options) { + return 'AWS ' + options.key + ':' + sign(options) +} + +module.exports = authorization +module.exports.authorization = authorization + +/** + * Simple HMAC-SHA1 Wrapper + * + * @param {Object} options + * @return {String} + * @api private + */ + +function hmacSha1 (options) { + return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64') +} + +module.exports.hmacSha1 = hmacSha1 + +/** + * Create a base64 sha1 HMAC for `options`. + * + * @param {Object} options + * @return {String} + * @api private + */ + +function sign (options) { + options.message = stringToSign(options) + return hmacSha1(options) +} +module.exports.sign = sign + +/** + * Create a base64 sha1 HMAC for `options`. + * + * Specifically to be used with S3 presigned URLs + * + * @param {Object} options + * @return {String} + * @api private + */ + +function signQuery (options) { + options.message = queryStringToSign(options) + return hmacSha1(options) +} +module.exports.signQuery= signQuery + +/** + * Return a string for sign() with the given `options`. + * + * Spec: + * + * \n + * \n + * \n + * \n + * [headers\n] + * + * + * @param {Object} options + * @return {String} + * @api private + */ + +function stringToSign (options) { + var headers = options.amazonHeaders || '' + if (headers) headers += '\n' + var r = + [ options.verb + , options.md5 + , options.contentType + , options.date ? options.date.toUTCString() : '' + , headers + options.resource + ] + return r.join('\n') +} +module.exports.queryStringToSign = stringToSign + +/** + * Return a string for sign() with the given `options`, but is meant exclusively + * for S3 presigned URLs + * + * Spec: + * + * \n + * + * + * @param {Object} options + * @return {String} + * @api private + */ + +function queryStringToSign (options){ + return 'GET\n\n\n' + options.date + '\n' + options.resource +} +module.exports.queryStringToSign = queryStringToSign + +/** + * Perform the following: + * + * - ignore non-amazon headers + * - lowercase fields + * - sort lexicographically + * - trim whitespace between ":" + * - join with newline + * + * @param {Object} headers + * @return {String} + * @api private + */ + +function canonicalizeHeaders (headers) { + var buf = [] + , fields = Object.keys(headers) + ; + for (var i = 0, len = fields.length; i < len; ++i) { + var field = fields[i] + , val = headers[field] + , field = field.toLowerCase() + ; + if (0 !== field.indexOf('x-amz')) continue + buf.push(field + ':' + val) + } + return buf.sort().join('\n') +} +module.exports.canonicalizeHeaders = canonicalizeHeaders + +/** + * Perform the following: + * + * - ignore non sub-resources + * - sort lexicographically + * + * @param {String} resource + * @return {String} + * @api private + */ + +function canonicalizeResource (resource) { + var url = parse(resource, true) + , path = url.pathname + , buf = [] + ; + + Object.keys(url.query).forEach(function(key){ + if (!~keys.indexOf(key)) return + var val = '' == url.query[key] ? '' : '=' + encodeURIComponent(url.query[key]) + buf.push(key + val) + }) + + return path + (buf.length ? '?' + buf.sort().join('&') : '') +} +module.exports.canonicalizeResource = canonicalizeResource diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/package.json new file mode 100644 index 0000000..fe03beb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/package.json @@ -0,0 +1,47 @@ +{ + "author": { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com", + "url": "http://www.futurealoof.com" + }, + "name": "aws-sign2", + "description": "AWS signing. Originally pulled from LearnBoost/knox, maintained as vendor in request, now a standalone module.", + "version": "0.5.0", + "repository": { + "url": "git+https://github.com/mikeal/aws-sign.git" + }, + "main": "index.js", + "dependencies": {}, + "devDependencies": {}, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "readme": "aws-sign\n========\n\nAWS signing. Originally pulled from LearnBoost/knox, maintained as vendor in request, now a standalone module.\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/mikeal/aws-sign/issues" + }, + "_id": "aws-sign2@0.5.0", + "dist": { + "shasum": "c57103f7a17fc037f02d7c2e64b602ea223f7d63", + "tarball": "http://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz" + }, + "_from": "aws-sign2@>=0.5.0 <0.6.0", + "_npmVersion": "1.3.2", + "_npmUser": { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + } + ], + "directories": {}, + "_shasum": "c57103f7a17fc037f02d7c2e64b602ea223f7d63", + "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz", + "homepage": "https://github.com/mikeal/aws-sign", + "scripts": {} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.jshintrc new file mode 100644 index 0000000..c8ef3ca --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.jshintrc @@ -0,0 +1,59 @@ +{ + "predef": [ ] + , "bitwise": false + , "camelcase": false + , "curly": false + , "eqeqeq": false + , "forin": false + , "immed": false + , "latedef": false + , "noarg": true + , "noempty": true + , "nonew": true + , "plusplus": false + , "quotmark": true + , "regexp": false + , "undef": true + , "unused": true + , "strict": false + , "trailing": true + , "maxlen": 120 + , "asi": true + , "boss": true + , "debug": true + , "eqnull": true + , "esnext": true + , "evil": true + , "expr": true + , "funcscope": false + , "globalstrict": false + , "iterator": false + , "lastsemic": true + , "laxbreak": true + , "laxcomma": true + , "loopfunc": true + , "multistr": false + , "onecase": false + , "proto": false + , "regexdash": false + , "scripturl": true + , "smarttabs": false + , "shadow": false + , "sub": true + , "supernew": false + , "validthis": true + , "browser": true + , "couch": false + , "devel": false + , "dojo": false + , "mootools": false + , "node": true + , "nonstandard": true + , "prototypejs": false + , "rhino": false + , "worker": true + , "wsh": false + , "nomen": false + , "onevar": false + , "passfail": false +} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.npmignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.npmignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.travis.yml new file mode 100644 index 0000000..7ddb9c9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - 0.8 + - "0.10" +branches: + only: + - master +notifications: + email: + - rod@vagg.org +script: npm test \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/LICENSE.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/LICENSE.md new file mode 100644 index 0000000..ccb2479 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/LICENSE.md @@ -0,0 +1,13 @@ +The MIT License (MIT) +===================== + +Copyright (c) 2014 bl contributors +---------------------------------- + +*bl contributors listed at * + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/README.md new file mode 100644 index 0000000..6b7fb6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/README.md @@ -0,0 +1,198 @@ +# bl *(BufferList)* + +**A Node.js Buffer list collector, reader and streamer thingy.** + +[](https://nodei.co/npm/bl/) +[](https://nodei.co/npm/bl/) + +**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them! + +The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently. + +```js +const BufferList = require('bl') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append('hi') // bl will also accept & convert Strings +bl.append(new Buffer('j')) +bl.append(new Buffer([ 0x3, 0x4 ])) + +console.log(bl.length) // 12 + +console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij' +console.log(bl.slice(3, 10).toString('ascii')) // 'defghij' +console.log(bl.slice(3, 6).toString('ascii')) // 'def' +console.log(bl.slice(3, 8).toString('ascii')) // 'defgh' +console.log(bl.slice(5, 10).toString('ascii')) // 'fghij' + +// or just use toString! +console.log(bl.toString()) // 'abcdefghij\u0003\u0004' +console.log(bl.toString('ascii', 3, 8)) // 'defgh' +console.log(bl.toString('ascii', 5, 10)) // 'fghij' + +// other standard Buffer readables +console.log(bl.readUInt16BE(10)) // 0x0304 +console.log(bl.readUInt16LE(10)) // 0x0403 +``` + +Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**: + +```js +const bl = require('bl') + , fs = require('fs') + +fs.createReadStream('README.md') + .pipe(bl(function (err, data) { // note 'new' isn't strictly required + // `data` is a complete Buffer object containing the full data + console.log(data.toString()) + })) +``` + +Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream. + +Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!): +```js +const hyperquest = require('hyperquest') + , bl = require('bl') + , url = 'https://raw.github.com/rvagg/bl/master/README.md' + +hyperquest(url).pipe(bl(function (err, data) { + console.log(data.toString()) +})) +``` + +Or, use it as a readable stream to recompose a list of Buffers to an output source: + +```js +const BufferList = require('bl') + , fs = require('fs') + +var bl = new BufferList() +bl.append(new Buffer('abcd')) +bl.append(new Buffer('efg')) +bl.append(new Buffer('hi')) +bl.append(new Buffer('j')) + +bl.pipe(fs.createWriteStream('gibberish.txt')) +``` + +## API + + * new BufferList([ callback ]) + * bl.length + * bl.append(buffer) + * bl.get(index) + * bl.slice([ start[, end ] ]) + * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) + * bl.duplicate() + * bl.consume(bytes) + * bl.toString([encoding, [ start, [ end ]]]) + * bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + * Streams + +-------------------------------------------------------- + +### new BufferList([ callback | buffer | buffer array ]) +The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream. + +Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object. + +`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with: + +```js +var bl = require('bl') +var myinstance = bl() + +// equivilant to: + +var BufferList = require('bl') +var myinstance = new BufferList() +``` + +-------------------------------------------------------- + +### bl.length +Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list. + +-------------------------------------------------------- + +### bl.append(buffer) +`append(buffer)` adds an additional buffer or BufferList to the internal list. + +-------------------------------------------------------- + +### bl.get(index) +`get()` will return the byte at the specified index. + +-------------------------------------------------------- + +### bl.slice([ start, [ end ] ]) +`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively. + +If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer. + +-------------------------------------------------------- + +### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ]) +`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively. + +-------------------------------------------------------- + +### bl.duplicate() +`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example: + +```js +var bl = new BufferList() + +bl.append('hello') +bl.append(' world') +bl.append('\n') + +bl.duplicate().pipe(process.stdout, { end: false }) + +console.log(bl.toString()) +``` + +-------------------------------------------------------- + +### bl.consume(bytes) +`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data. + +-------------------------------------------------------- + +### bl.toString([encoding, [ start, [ end ]]]) +`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information. + +-------------------------------------------------------- + +### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8() + +All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently. + +See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work. + +-------------------------------------------------------- + +### Streams +**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance. + +-------------------------------------------------------- + +## Contributors + +**bl** is brought to you by the following hackers: + + * [Rod Vagg](https://github.com/rvagg) + * [Matteo Collina](https://github.com/mcollina) + * [Jarett Cruger](https://github.com/jcrugzz) + +======= + + +## License & copyright + +Copyright (c) 2013-2014 bl contributors (listed above). + +bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/bl.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/bl.js new file mode 100644 index 0000000..7a2f997 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/bl.js @@ -0,0 +1,216 @@ +var DuplexStream = require('readable-stream/duplex') + , util = require('util') + +function BufferList (callback) { + if (!(this instanceof BufferList)) + return new BufferList(callback) + + this._bufs = [] + this.length = 0 + + if (typeof callback == 'function') { + this._callback = callback + + var piper = function (err) { + if (this._callback) { + this._callback(err) + this._callback = null + } + }.bind(this) + + this.on('pipe', function (src) { + src.on('error', piper) + }) + this.on('unpipe', function (src) { + src.removeListener('error', piper) + }) + } + else if (Buffer.isBuffer(callback)) + this.append(callback) + else if (Array.isArray(callback)) { + callback.forEach(function (b) { + Buffer.isBuffer(b) && this.append(b) + }.bind(this)) + } + + DuplexStream.call(this) +} + +util.inherits(BufferList, DuplexStream) + +BufferList.prototype._offset = function (offset) { + var tot = 0, i = 0, _t + for (; i < this._bufs.length; i++) { + _t = tot + this._bufs[i].length + if (offset < _t) + return [ i, offset - tot ] + tot = _t + } +} + +BufferList.prototype.append = function (buf) { + var isBuffer = Buffer.isBuffer(buf) || + buf instanceof BufferList + + this._bufs.push(isBuffer ? buf : new Buffer(buf)) + this.length += buf.length + return this +} + +BufferList.prototype._write = function (buf, encoding, callback) { + this.append(buf) + if (callback) + callback() +} + +BufferList.prototype._read = function (size) { + if (!this.length) + return this.push(null) + size = Math.min(size, this.length) + this.push(this.slice(0, size)) + this.consume(size) +} + +BufferList.prototype.end = function (chunk) { + DuplexStream.prototype.end.call(this, chunk) + + if (this._callback) { + this._callback(null, this.slice()) + this._callback = null + } +} + +BufferList.prototype.get = function (index) { + return this.slice(index, index + 1)[0] +} + +BufferList.prototype.slice = function (start, end) { + return this.copy(null, 0, start, end) +} + +BufferList.prototype.copy = function (dst, dstStart, srcStart, srcEnd) { + if (typeof srcStart != 'number' || srcStart < 0) + srcStart = 0 + if (typeof srcEnd != 'number' || srcEnd > this.length) + srcEnd = this.length + if (srcStart >= this.length) + return dst || new Buffer(0) + if (srcEnd <= 0) + return dst || new Buffer(0) + + var copy = !!dst + , off = this._offset(srcStart) + , len = srcEnd - srcStart + , bytes = len + , bufoff = (copy && dstStart) || 0 + , start = off[1] + , l + , i + + // copy/slice everything + if (srcStart === 0 && srcEnd == this.length) { + if (!copy) // slice, just return a full concat + return Buffer.concat(this._bufs) + + // copy, need to copy individual buffers + for (i = 0; i < this._bufs.length; i++) { + this._bufs[i].copy(dst, bufoff) + bufoff += this._bufs[i].length + } + + return dst + } + + // easy, cheap case where it's a subset of one of the buffers + if (bytes <= this._bufs[off[0]].length - start) { + return copy + ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes) + : this._bufs[off[0]].slice(start, start + bytes) + } + + if (!copy) // a slice, we need something to copy in to + dst = new Buffer(len) + + for (i = off[0]; i < this._bufs.length; i++) { + l = this._bufs[i].length - start + + if (bytes > l) { + this._bufs[i].copy(dst, bufoff, start) + } else { + this._bufs[i].copy(dst, bufoff, start, start + bytes) + break + } + + bufoff += l + bytes -= l + + if (start) + start = 0 + } + + return dst +} + +BufferList.prototype.toString = function (encoding, start, end) { + return this.slice(start, end).toString(encoding) +} + +BufferList.prototype.consume = function (bytes) { + while (this._bufs.length) { + if (bytes > this._bufs[0].length) { + bytes -= this._bufs[0].length + this.length -= this._bufs[0].length + this._bufs.shift() + } else { + this._bufs[0] = this._bufs[0].slice(bytes) + this.length -= bytes + break + } + } + return this +} + +BufferList.prototype.duplicate = function () { + var i = 0 + , copy = new BufferList() + + for (; i < this._bufs.length; i++) + copy.append(this._bufs[i]) + + return copy +} + +BufferList.prototype.destroy = function () { + this._bufs.length = 0; + this.length = 0; + this.push(null); +} + +;(function () { + var methods = { + 'readDoubleBE' : 8 + , 'readDoubleLE' : 8 + , 'readFloatBE' : 4 + , 'readFloatLE' : 4 + , 'readInt32BE' : 4 + , 'readInt32LE' : 4 + , 'readUInt32BE' : 4 + , 'readUInt32LE' : 4 + , 'readInt16BE' : 2 + , 'readInt16LE' : 2 + , 'readUInt16BE' : 2 + , 'readUInt16LE' : 2 + , 'readInt8' : 1 + , 'readUInt8' : 1 + } + + for (var m in methods) { + (function (m) { + BufferList.prototype[m] = function (offset) { + return this.slice(offset, offset + methods[m])[m](0) + } + }(m)) + } +}()) + +module.exports = BufferList diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore new file mode 100644 index 0000000..38344f8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore @@ -0,0 +1,5 @@ +build/ +test/ +examples/ +fs.js +zlib.js \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE new file mode 100644 index 0000000..e3d4e69 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md new file mode 100644 index 0000000..3fb3e80 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md @@ -0,0 +1,15 @@ +# readable-stream + +***Node-core streams for userland*** + +[](https://nodei.co/npm/readable-stream/) +[](https://nodei.co/npm/readable-stream/) + +This package is a mirror of the Streams2 and Streams3 implementations in Node-core. + +If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core. + +**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12. + +**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"` + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js new file mode 100644 index 0000000..ca807af --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_duplex.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js new file mode 100644 index 0000000..b513d61 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js @@ -0,0 +1,89 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +module.exports = Duplex; + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; +} +/**/ + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +forEach(objectKeys(Writable.prototype), function(method) { + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; +}); + +function Duplex(options) { + if (!(this instanceof Duplex)) + return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) + this.readable = false; + + if (options && options.writable === false) + this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) + this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) + return; + + // no more data can be written. + // But allow more writes to happen in this tick. + process.nextTick(this.end.bind(this)); +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js new file mode 100644 index 0000000..895ca50 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_passthrough.js @@ -0,0 +1,46 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) + return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js new file mode 100644 index 0000000..6307220 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_readable.js @@ -0,0 +1,982 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = require('events').EventEmitter; + +/**/ +if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +var Stream = require('stream'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var StringDecoder; + +util.inherits(Readable, Stream); + +function ReadableState(options, stream) { + options = options || {}; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = false; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // In streams that never have any data, and do push(null) right away, + // the consumer can miss the 'end' event if they do some I/O before + // consuming the stream. So, we don't emit('end') until some reading + // happens. + this.calledRead = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, becuase any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + if (!(this instanceof Readable)) + return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function(chunk, encoding) { + var state = this._readableState; + + if (typeof chunk === 'string' && !state.objectMode) { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function(chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null || chunk === undefined) { + state.reading = false; + if (!state.ended) + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + if (state.decoder && !addToFront && !encoding) + chunk = state.decoder.write(chunk); + + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) { + state.buffer.unshift(chunk); + } else { + state.reading = false; + state.buffer.push(chunk); + } + + if (state.needReadable) + emitReadable(stream); + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + + + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && + (state.needReadable || + state.length < state.highWaterMark || + state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; +}; + +// Don't raise the hwm > 128MB +var MAX_HWM = 0x800000; +function roundUpToNextPowerOf2(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + for (var p = 1; p < 32; p <<= 1) n |= n >> p; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) + return 0; + + if (state.objectMode) + return n === 0 ? 0 : 1; + + if (n === null || isNaN(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } + + if (n <= 0) + return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) + state.highWaterMark = roundUpToNextPowerOf2(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else + return state.length; + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function(n) { + var state = this._readableState; + state.calledRead = true; + var nOrig = n; + var ret; + + if (typeof n !== 'number' || n > 0) + state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && + state.needReadable && + (state.length >= state.highWaterMark || state.ended)) { + emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + ret = null; + + // In cases where the decoder did not receive enough data + // to produce a full chunk, then immediately received an + // EOF, state.buffer will contain [, ]. + // howMuchToRead will see this and coerce the amount to + // read to zero (because it's looking at the length of the + // first in state.buffer), and we'll end up here. + // + // This can only happen via state.decoder -- no other venue + // exists for pushing a zero-length chunk into state.buffer + // and triggering this behavior. In this case, we return our + // remaining data and end the stream, if appropriate. + if (state.length > 0 && state.decoder) { + ret = fromList(n, state); + state.length -= ret.length; + } + + if (state.length === 0) + endReadable(this); + + return ret; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + + // if we currently have less than the highWaterMark, then also read some + if (state.length - n <= state.highWaterMark) + doRead = true; + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) + doRead = false; + + if (doRead) { + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) + state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read called its callback synchronously, then `reading` + // will be false, and we need to re-evaluate how much data we + // can return to the user. + if (doRead && !state.reading) + n = howMuchToRead(nOrig, state); + + if (n > 0) + ret = fromList(n, state); + else + ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) + state.needReadable = true; + + // If we happened to read() exactly the remaining amount in the + // buffer, and the EOF has been seen at this point, then make sure + // that we emit 'end' on the very next tick. + if (state.ended && !state.endEmitted && state.length === 0) + endReadable(this); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!Buffer.isBuffer(chunk) && + 'string' !== typeof chunk && + chunk !== null && + chunk !== undefined && + !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + + +function onEofChunk(stream, state) { + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // if we've ended and we have some data left, then emit + // 'readable' now to make sure it gets picked up. + if (state.length > 0) + emitReadable(stream); + else + endReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (state.emittedReadable) + return; + + state.emittedReadable = true; + if (state.sync) + process.nextTick(function() { + emitReadable_(stream); + }); + else + emitReadable_(stream); +} + +function emitReadable_(stream) { + stream.emit('readable'); +} + + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(function() { + maybeReadMore_(stream, state); + }); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && + state.length < state.highWaterMark) { + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + else + len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function(n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function(dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && + dest !== process.stdout && + dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) + process.nextTick(endFn); + else + src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + if (readable !== src) return; + cleanup(); + } + + function onend() { + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + function cleanup() { + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (!dest._writableState || dest._writableState.needDrain) + ondrain(); + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + unpipe(); + dest.removeListener('error', onerror); + if (EE.listenerCount(dest, 'error') === 0) + dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) + dest.on('error', onerror); + else if (isArray(dest._events.error)) + dest._events.error.unshift(onerror); + else + dest._events.error = [onerror, dest._events.error]; + + + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + // the handler that waits for readable events after all + // the data gets sucked out in flow. + // This would be easier to follow with a .once() handler + // in flow(), but that is too slow. + this.on('readable', pipeOnReadable); + + state.flowing = true; + process.nextTick(function() { + flow(src); + }); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function() { + var dest = this; + var state = src._readableState; + state.awaitDrain--; + if (state.awaitDrain === 0) + flow(src); + }; +} + +function flow(src) { + var state = src._readableState; + var chunk; + state.awaitDrain = 0; + + function write(dest, i, list) { + var written = dest.write(chunk); + if (false === written) { + state.awaitDrain++; + } + } + + while (state.pipesCount && null !== (chunk = src.read())) { + + if (state.pipesCount === 1) + write(state.pipes, 0, null); + else + forEach(state.pipes, write); + + src.emit('data', chunk); + + // if anyone needs a drain, then we have to wait for that. + if (state.awaitDrain > 0) + return; + } + + // if every destination was unpiped, either before entering this + // function, or in the while loop, then stop flowing. + // + // NB: This is a pretty rare edge case. + if (state.pipesCount === 0) { + state.flowing = false; + + // if there were data event listeners added, then switch to old mode. + if (EE.listenerCount(src, 'data') > 0) + emitDataEvents(src); + return; + } + + // at this point, no one needed a drain, so we just ran out of data + // on the next readable event, start it over again. + state.ranOut = true; +} + +function pipeOnReadable() { + if (this._readableState.ranOut) { + this._readableState.ranOut = false; + flow(this); + } +} + + +Readable.prototype.unpipe = function(dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) + return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) + return this; + + if (!dest) + dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + this.removeListener('readable', pipeOnReadable); + state.flowing = false; + if (dest) + dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + this.removeListener('readable', pipeOnReadable); + state.flowing = false; + + for (var i = 0; i < len; i++) + dests[i].emit('unpipe', this); + return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) + return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function(ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data' && !this._readableState.flowing) + emitDataEvents(this); + + if (ev === 'readable' && this.readable) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + this.read(0); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function() { + emitDataEvents(this); + this.read(0); + this.emit('resume'); +}; + +Readable.prototype.pause = function() { + emitDataEvents(this, true); + this.emit('pause'); +}; + +function emitDataEvents(stream, startPaused) { + var state = stream._readableState; + + if (state.flowing) { + // https://github.com/isaacs/readable-stream/issues/16 + throw new Error('Cannot switch to old mode now.'); + } + + var paused = startPaused || false; + var readable = false; + + // convert to an old-style stream. + stream.readable = true; + stream.pipe = Stream.prototype.pipe; + stream.on = stream.addListener = Stream.prototype.on; + + stream.on('readable', function() { + readable = true; + + var c; + while (!paused && (null !== (c = stream.read()))) + stream.emit('data', c); + + if (c === null) { + readable = false; + stream._readableState.needReadable = true; + } + }); + + stream.pause = function() { + paused = true; + this.emit('pause'); + }; + + stream.resume = function() { + paused = false; + if (readable) + process.nextTick(function() { + stream.emit('readable'); + }); + else + this.read(0); + this.emit('resume'); + }; + + // now make it start, just in case it hadn't already. + stream.emit('readable'); +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function(stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function() { + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function(chunk) { + if (state.decoder) + chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + //if (state.objectMode && util.isNullOrUndefined(chunk)) + if (state.objectMode && (chunk === null || chunk === undefined)) + return; + else if (!state.objectMode && (!chunk || !chunk.length)) + return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (typeof stream[i] === 'function' && + typeof this[i] === 'undefined') { + this[i] = function(method) { return function() { + return stream[method].apply(stream, arguments); + }}(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function(ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function(n) { + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + + + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) + return null; + + if (length === 0) + ret = null; + else if (objectMode) + ret = list.shift(); + else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) + ret = list.join(''); + else + ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) + ret = ''; + else + ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) + ret += buf.slice(0, cpy); + else + buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) + list[0] = buf.slice(cpy); + else + list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) + throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted && state.calledRead) { + state.ended = true; + process.nextTick(function() { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } + }); + } +} + +function forEach (xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf (xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js new file mode 100644 index 0000000..eb188df --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_transform.js @@ -0,0 +1,210 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + + +function TransformState(options, stream) { + this.afterTransform = function(er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) + return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) + stream.push(data); + + if (cb) + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + + +function Transform(options) { + if (!(this instanceof Transform)) + return new Transform(options); + + Duplex.call(this, options); + + var ts = this._transformState = new TransformState(options, this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + this.once('finish', function() { + if ('function' === typeof this._flush) + this._flush(function(er) { + done(stream, er); + }); + else + done(stream); + }); +} + +Transform.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function(chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || + rs.needReadable || + rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function(n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + + +function done(stream, er) { + if (er) + return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var rs = stream._readableState; + var ts = stream._transformState; + + if (ws.length) + throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) + throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js new file mode 100644 index 0000000..4bdaa4f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_writable.js @@ -0,0 +1,386 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, cb), and it'll handle all +// the drain event emission and buffering. + +module.exports = Writable; + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Writable.WritableState = WritableState; + + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Stream = require('stream'); + +util.inherits(Writable, Stream); + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; +} + +function WritableState(options, stream) { + options = options || {}; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + // cast to ints. + this.highWaterMark = ~~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, becuase any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function(er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.buffer = []; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; +} + +function Writable(options) { + var Duplex = require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) + return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function() { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + + +function writeAfterEnd(stream, state, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + if (!Buffer.isBuffer(chunk) && + 'string' !== typeof chunk && + chunk !== null && + chunk !== undefined && + !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + process.nextTick(function() { + cb(er); + }); + valid = false; + } + return valid; +} + +Writable.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) + encoding = 'buffer'; + else if (!encoding) + encoding = state.defaultEncoding; + + if (typeof cb !== 'function') + cb = function() {}; + + if (state.ended) + writeAfterEnd(this, state, cb); + else if (validChunk(this, state, chunk, cb)) + ret = writeOrBuffer(this, state, chunk, encoding, cb); + + return ret; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && + state.decodeStrings !== false && + typeof chunk === 'string') { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + if (Buffer.isBuffer(chunk)) + encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) + state.needDrain = true; + + if (state.writing) + state.buffer.push(new WriteReq(chunk, encoding, cb)); + else + doWrite(stream, state, len, chunk, encoding, cb); + + return ret; +} + +function doWrite(stream, state, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + if (sync) + process.nextTick(function() { + cb(er); + }); + else + cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) + onwriteError(stream, state, sync, er, cb); + else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(stream, state); + + if (!finished && !state.bufferProcessing && state.buffer.length) + clearBuffer(stream, state); + + if (sync) { + process.nextTick(function() { + afterWrite(stream, state, finished, cb); + }); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) + onwriteDrain(stream, state); + cb(); + if (finished) + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + + for (var c = 0; c < state.buffer.length; c++) { + var entry = state.buffer[c]; + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, len, chunk, encoding, cb); + + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + c++; + break; + } + } + + state.bufferProcessing = false; + if (c < state.buffer.length) + state.buffer = state.buffer.slice(c); + else + state.buffer.length = 0; +} + +Writable.prototype._write = function(chunk, encoding, cb) { + cb(new Error('not implemented')); +}; + +Writable.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (typeof chunk !== 'undefined' && chunk !== null) + this.write(chunk, encoding); + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) + endWritable(this, state, cb); +}; + + +function needFinish(stream, state) { + return (state.ending && + state.length === 0 && + !state.finished && + !state.writing); +} + +function finishMaybe(stream, state) { + var need = needFinish(stream, state); + if (need) { + state.finished = true; + stream.emit('finish'); + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) + process.nextTick(cb); + else + stream.once('finish', cb); + } + state.ended = true; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/README.md new file mode 100644 index 0000000..5a76b41 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/README.md @@ -0,0 +1,3 @@ +# core-util-is + +The `util.is*` functions introduced in Node v0.12. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/float.patch b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/float.patch new file mode 100644 index 0000000..a06d5c0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/float.patch @@ -0,0 +1,604 @@ +diff --git a/lib/util.js b/lib/util.js +index a03e874..9074e8e 100644 +--- a/lib/util.js ++++ b/lib/util.js +@@ -19,430 +19,6 @@ + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + +-var formatRegExp = /%[sdj%]/g; +-exports.format = function(f) { +- if (!isString(f)) { +- var objects = []; +- for (var i = 0; i < arguments.length; i++) { +- objects.push(inspect(arguments[i])); +- } +- return objects.join(' '); +- } +- +- var i = 1; +- var args = arguments; +- var len = args.length; +- var str = String(f).replace(formatRegExp, function(x) { +- if (x === '%%') return '%'; +- if (i >= len) return x; +- switch (x) { +- case '%s': return String(args[i++]); +- case '%d': return Number(args[i++]); +- case '%j': +- try { +- return JSON.stringify(args[i++]); +- } catch (_) { +- return '[Circular]'; +- } +- default: +- return x; +- } +- }); +- for (var x = args[i]; i < len; x = args[++i]) { +- if (isNull(x) || !isObject(x)) { +- str += ' ' + x; +- } else { +- str += ' ' + inspect(x); +- } +- } +- return str; +-}; +- +- +-// Mark that a method should not be used. +-// Returns a modified function which warns once by default. +-// If --no-deprecation is set, then it is a no-op. +-exports.deprecate = function(fn, msg) { +- // Allow for deprecating things in the process of starting up. +- if (isUndefined(global.process)) { +- return function() { +- return exports.deprecate(fn, msg).apply(this, arguments); +- }; +- } +- +- if (process.noDeprecation === true) { +- return fn; +- } +- +- var warned = false; +- function deprecated() { +- if (!warned) { +- if (process.throwDeprecation) { +- throw new Error(msg); +- } else if (process.traceDeprecation) { +- console.trace(msg); +- } else { +- console.error(msg); +- } +- warned = true; +- } +- return fn.apply(this, arguments); +- } +- +- return deprecated; +-}; +- +- +-var debugs = {}; +-var debugEnviron; +-exports.debuglog = function(set) { +- if (isUndefined(debugEnviron)) +- debugEnviron = process.env.NODE_DEBUG || ''; +- set = set.toUpperCase(); +- if (!debugs[set]) { +- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { +- var pid = process.pid; +- debugs[set] = function() { +- var msg = exports.format.apply(exports, arguments); +- console.error('%s %d: %s', set, pid, msg); +- }; +- } else { +- debugs[set] = function() {}; +- } +- } +- return debugs[set]; +-}; +- +- +-/** +- * Echos the value of a value. Trys to print the value out +- * in the best way possible given the different types. +- * +- * @param {Object} obj The object to print out. +- * @param {Object} opts Optional options object that alters the output. +- */ +-/* legacy: obj, showHidden, depth, colors*/ +-function inspect(obj, opts) { +- // default options +- var ctx = { +- seen: [], +- stylize: stylizeNoColor +- }; +- // legacy... +- if (arguments.length >= 3) ctx.depth = arguments[2]; +- if (arguments.length >= 4) ctx.colors = arguments[3]; +- if (isBoolean(opts)) { +- // legacy... +- ctx.showHidden = opts; +- } else if (opts) { +- // got an "options" object +- exports._extend(ctx, opts); +- } +- // set default options +- if (isUndefined(ctx.showHidden)) ctx.showHidden = false; +- if (isUndefined(ctx.depth)) ctx.depth = 2; +- if (isUndefined(ctx.colors)) ctx.colors = false; +- if (isUndefined(ctx.customInspect)) ctx.customInspect = true; +- if (ctx.colors) ctx.stylize = stylizeWithColor; +- return formatValue(ctx, obj, ctx.depth); +-} +-exports.inspect = inspect; +- +- +-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +-inspect.colors = { +- 'bold' : [1, 22], +- 'italic' : [3, 23], +- 'underline' : [4, 24], +- 'inverse' : [7, 27], +- 'white' : [37, 39], +- 'grey' : [90, 39], +- 'black' : [30, 39], +- 'blue' : [34, 39], +- 'cyan' : [36, 39], +- 'green' : [32, 39], +- 'magenta' : [35, 39], +- 'red' : [31, 39], +- 'yellow' : [33, 39] +-}; +- +-// Don't use 'blue' not visible on cmd.exe +-inspect.styles = { +- 'special': 'cyan', +- 'number': 'yellow', +- 'boolean': 'yellow', +- 'undefined': 'grey', +- 'null': 'bold', +- 'string': 'green', +- 'date': 'magenta', +- // "name": intentionally not styling +- 'regexp': 'red' +-}; +- +- +-function stylizeWithColor(str, styleType) { +- var style = inspect.styles[styleType]; +- +- if (style) { +- return '\u001b[' + inspect.colors[style][0] + 'm' + str + +- '\u001b[' + inspect.colors[style][1] + 'm'; +- } else { +- return str; +- } +-} +- +- +-function stylizeNoColor(str, styleType) { +- return str; +-} +- +- +-function arrayToHash(array) { +- var hash = {}; +- +- array.forEach(function(val, idx) { +- hash[val] = true; +- }); +- +- return hash; +-} +- +- +-function formatValue(ctx, value, recurseTimes) { +- // Provide a hook for user-specified inspect functions. +- // Check that value is an object with an inspect function on it +- if (ctx.customInspect && +- value && +- isFunction(value.inspect) && +- // Filter out the util module, it's inspect function is special +- value.inspect !== exports.inspect && +- // Also filter out any prototype objects using the circular check. +- !(value.constructor && value.constructor.prototype === value)) { +- var ret = value.inspect(recurseTimes, ctx); +- if (!isString(ret)) { +- ret = formatValue(ctx, ret, recurseTimes); +- } +- return ret; +- } +- +- // Primitive types cannot have properties +- var primitive = formatPrimitive(ctx, value); +- if (primitive) { +- return primitive; +- } +- +- // Look up the keys of the object. +- var keys = Object.keys(value); +- var visibleKeys = arrayToHash(keys); +- +- if (ctx.showHidden) { +- keys = Object.getOwnPropertyNames(value); +- } +- +- // Some type of object without properties can be shortcutted. +- if (keys.length === 0) { +- if (isFunction(value)) { +- var name = value.name ? ': ' + value.name : ''; +- return ctx.stylize('[Function' + name + ']', 'special'); +- } +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } +- if (isDate(value)) { +- return ctx.stylize(Date.prototype.toString.call(value), 'date'); +- } +- if (isError(value)) { +- return formatError(value); +- } +- } +- +- var base = '', array = false, braces = ['{', '}']; +- +- // Make Array say that they are Array +- if (isArray(value)) { +- array = true; +- braces = ['[', ']']; +- } +- +- // Make functions say that they are functions +- if (isFunction(value)) { +- var n = value.name ? ': ' + value.name : ''; +- base = ' [Function' + n + ']'; +- } +- +- // Make RegExps say that they are RegExps +- if (isRegExp(value)) { +- base = ' ' + RegExp.prototype.toString.call(value); +- } +- +- // Make dates with properties first say the date +- if (isDate(value)) { +- base = ' ' + Date.prototype.toUTCString.call(value); +- } +- +- // Make error with message first say the error +- if (isError(value)) { +- base = ' ' + formatError(value); +- } +- +- if (keys.length === 0 && (!array || value.length == 0)) { +- return braces[0] + base + braces[1]; +- } +- +- if (recurseTimes < 0) { +- if (isRegExp(value)) { +- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); +- } else { +- return ctx.stylize('[Object]', 'special'); +- } +- } +- +- ctx.seen.push(value); +- +- var output; +- if (array) { +- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); +- } else { +- output = keys.map(function(key) { +- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); +- }); +- } +- +- ctx.seen.pop(); +- +- return reduceToSingleString(output, base, braces); +-} +- +- +-function formatPrimitive(ctx, value) { +- if (isUndefined(value)) +- return ctx.stylize('undefined', 'undefined'); +- if (isString(value)) { +- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') +- .replace(/'/g, "\\'") +- .replace(/\\"/g, '"') + '\''; +- return ctx.stylize(simple, 'string'); +- } +- if (isNumber(value)) { +- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, +- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . +- if (value === 0 && 1 / value < 0) +- return ctx.stylize('-0', 'number'); +- return ctx.stylize('' + value, 'number'); +- } +- if (isBoolean(value)) +- return ctx.stylize('' + value, 'boolean'); +- // For some reason typeof null is "object", so special case here. +- if (isNull(value)) +- return ctx.stylize('null', 'null'); +-} +- +- +-function formatError(value) { +- return '[' + Error.prototype.toString.call(value) + ']'; +-} +- +- +-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { +- var output = []; +- for (var i = 0, l = value.length; i < l; ++i) { +- if (hasOwnProperty(value, String(i))) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- String(i), true)); +- } else { +- output.push(''); +- } +- } +- keys.forEach(function(key) { +- if (!key.match(/^\d+$/)) { +- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, +- key, true)); +- } +- }); +- return output; +-} +- +- +-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { +- var name, str, desc; +- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; +- if (desc.get) { +- if (desc.set) { +- str = ctx.stylize('[Getter/Setter]', 'special'); +- } else { +- str = ctx.stylize('[Getter]', 'special'); +- } +- } else { +- if (desc.set) { +- str = ctx.stylize('[Setter]', 'special'); +- } +- } +- if (!hasOwnProperty(visibleKeys, key)) { +- name = '[' + key + ']'; +- } +- if (!str) { +- if (ctx.seen.indexOf(desc.value) < 0) { +- if (isNull(recurseTimes)) { +- str = formatValue(ctx, desc.value, null); +- } else { +- str = formatValue(ctx, desc.value, recurseTimes - 1); +- } +- if (str.indexOf('\n') > -1) { +- if (array) { +- str = str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n').substr(2); +- } else { +- str = '\n' + str.split('\n').map(function(line) { +- return ' ' + line; +- }).join('\n'); +- } +- } +- } else { +- str = ctx.stylize('[Circular]', 'special'); +- } +- } +- if (isUndefined(name)) { +- if (array && key.match(/^\d+$/)) { +- return str; +- } +- name = JSON.stringify('' + key); +- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { +- name = name.substr(1, name.length - 2); +- name = ctx.stylize(name, 'name'); +- } else { +- name = name.replace(/'/g, "\\'") +- .replace(/\\"/g, '"') +- .replace(/(^"|"$)/g, "'"); +- name = ctx.stylize(name, 'string'); +- } +- } +- +- return name + ': ' + str; +-} +- +- +-function reduceToSingleString(output, base, braces) { +- var numLinesEst = 0; +- var length = output.reduce(function(prev, cur) { +- numLinesEst++; +- if (cur.indexOf('\n') >= 0) numLinesEst++; +- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; +- }, 0); +- +- if (length > 60) { +- return braces[0] + +- (base === '' ? '' : base + '\n ') + +- ' ' + +- output.join(',\n ') + +- ' ' + +- braces[1]; +- } +- +- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +-} +- +- + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { +@@ -522,166 +98,10 @@ function isPrimitive(arg) { + exports.isPrimitive = isPrimitive; + + function isBuffer(arg) { +- return arg instanceof Buffer; ++ return Buffer.isBuffer(arg); + } + exports.isBuffer = isBuffer; + + function objectToString(o) { + return Object.prototype.toString.call(o); +-} +- +- +-function pad(n) { +- return n < 10 ? '0' + n.toString(10) : n.toString(10); +-} +- +- +-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', +- 'Oct', 'Nov', 'Dec']; +- +-// 26 Feb 16:19:34 +-function timestamp() { +- var d = new Date(); +- var time = [pad(d.getHours()), +- pad(d.getMinutes()), +- pad(d.getSeconds())].join(':'); +- return [d.getDate(), months[d.getMonth()], time].join(' '); +-} +- +- +-// log is just a thin wrapper to console.log that prepends a timestamp +-exports.log = function() { +- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +-}; +- +- +-/** +- * Inherit the prototype methods from one constructor into another. +- * +- * The Function.prototype.inherits from lang.js rewritten as a standalone +- * function (not on Function.prototype). NOTE: If this file is to be loaded +- * during bootstrapping this function needs to be rewritten using some native +- * functions as prototype setup using normal JavaScript does not work as +- * expected during bootstrapping (see mirror.js in r114903). +- * +- * @param {function} ctor Constructor function which needs to inherit the +- * prototype. +- * @param {function} superCtor Constructor function to inherit prototype from. +- */ +-exports.inherits = function(ctor, superCtor) { +- ctor.super_ = superCtor; +- ctor.prototype = Object.create(superCtor.prototype, { +- constructor: { +- value: ctor, +- enumerable: false, +- writable: true, +- configurable: true +- } +- }); +-}; +- +-exports._extend = function(origin, add) { +- // Don't do anything if add isn't an object +- if (!add || !isObject(add)) return origin; +- +- var keys = Object.keys(add); +- var i = keys.length; +- while (i--) { +- origin[keys[i]] = add[keys[i]]; +- } +- return origin; +-}; +- +-function hasOwnProperty(obj, prop) { +- return Object.prototype.hasOwnProperty.call(obj, prop); +-} +- +- +-// Deprecated old stuff. +- +-exports.p = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- console.error(exports.inspect(arguments[i])); +- } +-}, 'util.p: Use console.error() instead'); +- +- +-exports.exec = exports.deprecate(function() { +- return require('child_process').exec.apply(this, arguments); +-}, 'util.exec is now called `child_process.exec`.'); +- +- +-exports.print = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(String(arguments[i])); +- } +-}, 'util.print: Use console.log instead'); +- +- +-exports.puts = exports.deprecate(function() { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stdout.write(arguments[i] + '\n'); +- } +-}, 'util.puts: Use console.log instead'); +- +- +-exports.debug = exports.deprecate(function(x) { +- process.stderr.write('DEBUG: ' + x + '\n'); +-}, 'util.debug: Use console.error instead'); +- +- +-exports.error = exports.deprecate(function(x) { +- for (var i = 0, len = arguments.length; i < len; ++i) { +- process.stderr.write(arguments[i] + '\n'); +- } +-}, 'util.error: Use console.error instead'); +- +- +-exports.pump = exports.deprecate(function(readStream, writeStream, callback) { +- var callbackCalled = false; +- +- function call(a, b, c) { +- if (callback && !callbackCalled) { +- callback(a, b, c); +- callbackCalled = true; +- } +- } +- +- readStream.addListener('data', function(chunk) { +- if (writeStream.write(chunk) === false) readStream.pause(); +- }); +- +- writeStream.addListener('drain', function() { +- readStream.resume(); +- }); +- +- readStream.addListener('end', function() { +- writeStream.end(); +- }); +- +- readStream.addListener('close', function() { +- call(); +- }); +- +- readStream.addListener('error', function(err) { +- writeStream.end(); +- call(err); +- }); +- +- writeStream.addListener('error', function(err) { +- readStream.destroy(); +- call(err); +- }); +-}, 'util.pump(): Use readableStream.pipe() instead'); +- +- +-var uv; +-exports._errnoException = function(err, syscall) { +- if (isUndefined(uv)) uv = process.binding('uv'); +- var errname = uv.errname(err); +- var e = new Error(syscall + ' ' + errname); +- e.code = errname; +- e.errno = errname; +- e.syscall = syscall; +- return e; +-}; ++} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js new file mode 100644 index 0000000..9074e8e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js @@ -0,0 +1,107 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return Buffer.isBuffer(arg); +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json new file mode 100644 index 0000000..c7fbad8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json @@ -0,0 +1,54 @@ +{ + "name": "core-util-is", + "version": "1.0.1", + "description": "The `util.is*` functions introduced in Node v0.12.", + "main": "lib/util.js", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/core-util-is.git" + }, + "keywords": [ + "util", + "isBuffer", + "isArray", + "isNumber", + "isString", + "isRegExp", + "isThis", + "isThat", + "polyfill" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/isaacs/core-util-is/issues" + }, + "readme": "# core-util-is\n\nThe `util.is*` functions introduced in Node v0.12.\n", + "readmeFilename": "README.md", + "homepage": "https://github.com/isaacs/core-util-is", + "_id": "core-util-is@1.0.1", + "dist": { + "shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", + "tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" + }, + "_from": "core-util-is@>=1.0.0 <1.1.0", + "_npmVersion": "1.3.23", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "directories": {}, + "_shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", + "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz", + "scripts": {} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js new file mode 100644 index 0000000..007fa10 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js @@ -0,0 +1,106 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return arg instanceof Buffer; +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/LICENSE new file mode 100644 index 0000000..dea3013 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/README.md new file mode 100644 index 0000000..b1c5665 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits.js new file mode 100644 index 0000000..29f5e24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits.js @@ -0,0 +1 @@ +module.exports = require('util').inherits diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits_browser.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits_browser.js new file mode 100644 index 0000000..c1e78a7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/inherits_browser.js @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/package.json new file mode 100644 index 0000000..4714dd6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/package.json @@ -0,0 +1,50 @@ +{ + "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.git" + }, + "license": "ISC", + "scripts": { + "test": "node test" + }, + "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@>=2.0.1 <2.1.0", + "_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", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/isaacs/inherits" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/test.js new file mode 100644 index 0000000..fc53012 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/test.js @@ -0,0 +1,25 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/README.md new file mode 100644 index 0000000..052a62b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/README.md @@ -0,0 +1,54 @@ + +# isarray + +`Array#isArray` for older browsers. + +## Usage + +```js +var isArray = require('isarray'); + +console.log(isArray([])); // => true +console.log(isArray({})); // => false +``` + +## Installation + +With [npm](http://npmjs.org) do + +```bash +$ npm install isarray +``` + +Then bundle for the browser with +[browserify](https://github.com/substack/browserify). + +With [component](http://component.io) do + +```bash +$ component install juliangruber/isarray +``` + +## 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/build/build.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/build/build.js new file mode 100644 index 0000000..ec58596 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/build/build.js @@ -0,0 +1,209 @@ + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("isarray/index.js", function(exports, require, module){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +}); +require.alias("isarray/index.js", "isarray/index.js"); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/component.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/component.json new file mode 100644 index 0000000..9e31b68 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/component.json @@ -0,0 +1,19 @@ +{ + "name" : "isarray", + "description" : "Array#isArray for older browsers", + "version" : "0.0.1", + "repository" : "juliangruber/isarray", + "homepage": "https://github.com/juliangruber/isarray", + "main" : "index.js", + "scripts" : [ + "index.js" + ], + "dependencies" : {}, + "keywords": ["browser","isarray","array"], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/index.js new file mode 100644 index 0000000..5f5ad45 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/index.js @@ -0,0 +1,3 @@ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json new file mode 100644 index 0000000..19228ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/isarray/package.json @@ -0,0 +1,53 @@ +{ + "name": "isarray", + "description": "Array#isArray for older browsers", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/juliangruber/isarray.git" + }, + "homepage": "https://github.com/juliangruber/isarray", + "main": "index.js", + "scripts": { + "test": "tap test/*.js" + }, + "dependencies": {}, + "devDependencies": { + "tap": "*" + }, + "keywords": [ + "browser", + "isarray", + "array" + ], + "author": { + "name": "Julian Gruber", + "email": "mail@juliangruber.com", + "url": "http://juliangruber.com" + }, + "license": "MIT", + "_id": "isarray@0.0.1", + "dist": { + "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "tarball": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "_from": "isarray@0.0.1", + "_npmVersion": "1.2.18", + "_npmUser": { + "name": "juliangruber", + "email": "julian@juliangruber.com" + }, + "maintainers": [ + { + "name": "juliangruber", + "email": "julian@juliangruber.com" + } + ], + "directories": {}, + "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "bugs": { + "url": "https://github.com/juliangruber/isarray/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/.npmignore new file mode 100644 index 0000000..206320c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/.npmignore @@ -0,0 +1,2 @@ +build +test diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/LICENSE new file mode 100644 index 0000000..6de584a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/LICENSE @@ -0,0 +1,20 @@ +Copyright Joyent, Inc. and other Node contributors. + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/README.md new file mode 100644 index 0000000..4d2aa00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/README.md @@ -0,0 +1,7 @@ +**string_decoder.js** (`require('string_decoder')`) from Node.js core + +Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details. + +Version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.** + +The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version. \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/index.js new file mode 100644 index 0000000..b00e54f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/index.js @@ -0,0 +1,221 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// 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. + +var Buffer = require('buffer').Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json new file mode 100644 index 0000000..0364d54 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/string_decoder/package.json @@ -0,0 +1,54 @@ +{ + "name": "string_decoder", + "version": "0.10.31", + "description": "The string_decoder module from Node core", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "tap": "~0.4.8" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/rvagg/string_decoder.git" + }, + "homepage": "https://github.com/rvagg/string_decoder", + "keywords": [ + "string", + "decoder", + "browser", + "browserify" + ], + "license": "MIT", + "gitHead": "d46d4fd87cf1d06e031c23f1ba170ca7d4ade9a0", + "bugs": { + "url": "https://github.com/rvagg/string_decoder/issues" + }, + "_id": "string_decoder@0.10.31", + "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "_from": "string_decoder@>=0.10.0 <0.11.0", + "_npmVersion": "1.4.23", + "_npmUser": { + "name": "rvagg", + "email": "rod@vagg.org" + }, + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "dist": { + "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", + "tarball": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/package.json new file mode 100644 index 0000000..765bd04 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/package.json @@ -0,0 +1,70 @@ +{ + "name": "readable-stream", + "version": "1.0.33", + "description": "Streams2, a user-land copy of the stream library from Node.js v0.10.x", + "main": "readable.js", + "dependencies": { + "core-util-is": "~1.0.0", + "isarray": "0.0.1", + "string_decoder": "~0.10.x", + "inherits": "~2.0.1" + }, + "devDependencies": { + "tap": "~0.2.6" + }, + "scripts": { + "test": "tap test/simple/*.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/readable-stream.git" + }, + "keywords": [ + "readable", + "stream", + "pipe" + ], + "browser": { + "util": false + }, + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "MIT", + "gitHead": "0bf97a117c5646556548966409ebc57a6dda2638", + "bugs": { + "url": "https://github.com/isaacs/readable-stream/issues" + }, + "homepage": "https://github.com/isaacs/readable-stream", + "_id": "readable-stream@1.0.33", + "_shasum": "3a360dd66c1b1d7fd4705389860eda1d0f61126c", + "_from": "readable-stream@>=1.0.26 <1.1.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "rvagg", + "email": "rod@vagg.org" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "dist": { + "shasum": "3a360dd66c1b1d7fd4705389860eda1d0f61126c", + "tarball": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/passthrough.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/passthrough.js new file mode 100644 index 0000000..27e8d8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/passthrough.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_passthrough.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/readable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/readable.js new file mode 100644 index 0000000..8b5337b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/readable.js @@ -0,0 +1,8 @@ +var Stream = require('stream'); // hack to fix a circular dependency issue when used with browserify +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = Stream; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/transform.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/transform.js new file mode 100644 index 0000000..5d482f0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/transform.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_transform.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/writable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/writable.js new file mode 100644 index 0000000..e1e9efd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/writable.js @@ -0,0 +1 @@ +module.exports = require("./lib/_stream_writable.js") diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/package.json new file mode 100644 index 0000000..ff8c53b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/package.json @@ -0,0 +1,62 @@ +{ + "name": "bl", + "version": "0.9.4", + "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", + "main": "bl.js", + "scripts": { + "test": "node test/test.js | faucet", + "test-local": "brtapsauce-local test/basic-test.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rvagg/bl.git" + }, + "homepage": "https://github.com/rvagg/bl", + "authors": [ + "Rod Vagg (https://github.com/rvagg)", + "Matteo Collina (https://github.com/mcollina)", + "Jarett Cruger (https://github.com/jcrugzz)" + ], + "keywords": [ + "buffer", + "buffers", + "stream", + "awesomesauce" + ], + "license": "MIT", + "dependencies": { + "readable-stream": "~1.0.26" + }, + "devDependencies": { + "tape": "~2.12.3", + "hash_file": "~0.1.1", + "faucet": "~0.0.1", + "brtapsauce": "~0.3.0" + }, + "gitHead": "e7f90703c5f90ca26f60455ea6ad0b6be4a9feee", + "bugs": { + "url": "https://github.com/rvagg/bl/issues" + }, + "_id": "bl@0.9.4", + "_shasum": "4702ddf72fbe0ecd82787c00c113aea1935ad0e7", + "_from": "bl@>=0.9.0 <0.10.0", + "_npmVersion": "2.1.18", + "_nodeVersion": "1.0.3", + "_npmUser": { + "name": "rvagg", + "email": "rod@vagg.org" + }, + "maintainers": [ + { + "name": "rvagg", + "email": "rod@vagg.org" + } + ], + "dist": { + "shasum": "4702ddf72fbe0ecd82787c00c113aea1935ad0e7", + "tarball": "http://registry.npmjs.org/bl/-/bl-0.9.4.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/bl/-/bl-0.9.4.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/basic-test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/basic-test.js new file mode 100644 index 0000000..75116a3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/basic-test.js @@ -0,0 +1,541 @@ +var tape = require('tape') + , crypto = require('crypto') + , fs = require('fs') + , hash = require('hash_file') + , BufferList = require('../') + + , encodings = + ('hex utf8 utf-8 ascii binary base64' + + (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ') + +tape('single bytes from single buffer', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + + t.equal(bl.length, 4) + + t.equal(bl.get(0), 97) + t.equal(bl.get(1), 98) + t.equal(bl.get(2), 99) + t.equal(bl.get(3), 100) + + t.end() +}) + +tape('single bytes from multiple buffers', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.get(0), 97) + t.equal(bl.get(1), 98) + t.equal(bl.get(2), 99) + t.equal(bl.get(3), 100) + t.equal(bl.get(4), 101) + t.equal(bl.get(5), 102) + t.equal(bl.get(6), 103) + t.equal(bl.get(7), 104) + t.equal(bl.get(8), 105) + t.equal(bl.get(9), 106) + t.end() +}) + +tape('multi bytes from single buffer', function (t) { + var bl = new BufferList() + bl.append(new Buffer('abcd')) + + t.equal(bl.length, 4) + + t.equal(bl.slice(0, 4).toString('ascii'), 'abcd') + t.equal(bl.slice(0, 3).toString('ascii'), 'abc') + t.equal(bl.slice(1, 4).toString('ascii'), 'bcd') + + t.end() +}) + +tape('multiple bytes from multiple buffers', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') + t.equal(bl.slice(3, 10).toString('ascii'), 'defghij') + t.equal(bl.slice(3, 6).toString('ascii'), 'def') + t.equal(bl.slice(3, 8).toString('ascii'), 'defgh') + t.equal(bl.slice(5, 10).toString('ascii'), 'fghij') + + t.end() +}) + +tape('multiple bytes from multiple buffer lists', function (t) { + var bl = new BufferList() + + bl.append(new BufferList([new Buffer('abcd'), new Buffer('efg')])) + bl.append(new BufferList([new Buffer('hi'), new Buffer('j')])) + + t.equal(bl.length, 10) + + t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') + t.equal(bl.slice(3, 10).toString('ascii'), 'defghij') + t.equal(bl.slice(3, 6).toString('ascii'), 'def') + t.equal(bl.slice(3, 8).toString('ascii'), 'defgh') + t.equal(bl.slice(5, 10).toString('ascii'), 'fghij') + + t.end() +}) + +tape('consuming from multiple buffers', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.length, 10) + + t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij') + + bl.consume(3) + t.equal(bl.length, 7) + t.equal(bl.slice(0, 7).toString('ascii'), 'defghij') + + bl.consume(2) + t.equal(bl.length, 5) + t.equal(bl.slice(0, 5).toString('ascii'), 'fghij') + + bl.consume(1) + t.equal(bl.length, 4) + t.equal(bl.slice(0, 4).toString('ascii'), 'ghij') + + bl.consume(1) + t.equal(bl.length, 3) + t.equal(bl.slice(0, 3).toString('ascii'), 'hij') + + bl.consume(2) + t.equal(bl.length, 1) + t.equal(bl.slice(0, 1).toString('ascii'), 'j') + + t.end() +}) + +tape('test readUInt8 / readInt8', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt8(2), 0x3) + t.equal(bl.readInt8(2), 0x3) + t.equal(bl.readUInt8(3), 0x4) + t.equal(bl.readInt8(3), 0x4) + t.equal(bl.readUInt8(4), 0x23) + t.equal(bl.readInt8(4), 0x23) + t.equal(bl.readUInt8(5), 0x42) + t.equal(bl.readInt8(5), 0x42) + t.end() +}) + +tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt16BE(2), 0x0304) + t.equal(bl.readUInt16LE(2), 0x0403) + t.equal(bl.readInt16BE(2), 0x0304) + t.equal(bl.readInt16LE(2), 0x0403) + t.equal(bl.readUInt16BE(3), 0x0423) + t.equal(bl.readUInt16LE(3), 0x2304) + t.equal(bl.readInt16BE(3), 0x0423) + t.equal(bl.readInt16LE(3), 0x2304) + t.equal(bl.readUInt16BE(4), 0x2342) + t.equal(bl.readUInt16LE(4), 0x4223) + t.equal(bl.readInt16BE(4), 0x2342) + t.equal(bl.readInt16LE(4), 0x4223) + t.end() +}) + +tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x3 + buf2[2] = 0x4 + buf3[0] = 0x23 + buf3[1] = 0x42 + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readUInt32BE(2), 0x03042342) + t.equal(bl.readUInt32LE(2), 0x42230403) + t.equal(bl.readInt32BE(2), 0x03042342) + t.equal(bl.readInt32LE(2), 0x42230403) + t.end() +}) + +tape('test readFloatLE / readFloatBE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(3) + , bl = new BufferList() + + buf2[1] = 0x00 + buf2[2] = 0x00 + buf3[0] = 0x80 + buf3[1] = 0x3f + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readFloatLE(2), 0x01) + t.end() +}) + +tape('test readDoubleLE / readDoubleBE', function (t) { + var buf1 = new Buffer(1) + , buf2 = new Buffer(3) + , buf3 = new Buffer(10) + , bl = new BufferList() + + buf2[1] = 0x55 + buf2[2] = 0x55 + buf3[0] = 0x55 + buf3[1] = 0x55 + buf3[2] = 0x55 + buf3[3] = 0x55 + buf3[4] = 0xd5 + buf3[5] = 0x3f + + bl.append(buf1) + bl.append(buf2) + bl.append(buf3) + + t.equal(bl.readDoubleLE(2), 0.3333333333333333) + t.end() +}) + +tape('test toString', function (t) { + var bl = new BufferList() + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + + t.equal(bl.toString('ascii', 0, 10), 'abcdefghij') + t.equal(bl.toString('ascii', 3, 10), 'defghij') + t.equal(bl.toString('ascii', 3, 6), 'def') + t.equal(bl.toString('ascii', 3, 8), 'defgh') + t.equal(bl.toString('ascii', 5, 10), 'fghij') + + t.end() +}) + +tape('test toString encoding', function (t) { + var bl = new BufferList() + , b = new Buffer('abcdefghij\xff\x00') + + bl.append(new Buffer('abcd')) + bl.append(new Buffer('efg')) + bl.append(new Buffer('hi')) + bl.append(new Buffer('j')) + bl.append(new Buffer('\xff\x00')) + + encodings.forEach(function (enc) { + t.equal(bl.toString(enc), b.toString(enc), enc) + }) + + t.end() +}) + +!process.browser && tape('test stream', function (t) { + var random = crypto.randomBytes(65534) + , rndhash = hash(random, 'md5') + , md5sum = crypto.createHash('md5') + , bl = new BufferList(function (err, buf) { + t.ok(Buffer.isBuffer(buf)) + t.ok(err === null) + t.equal(rndhash, hash(bl.slice(), 'md5')) + t.equal(rndhash, hash(buf, 'md5')) + + bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat')) + .on('close', function () { + var s = fs.createReadStream('/tmp/bl_test_rnd_out.dat') + s.on('data', md5sum.update.bind(md5sum)) + s.on('end', function() { + t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!') + t.end() + }) + }) + + }) + + fs.writeFileSync('/tmp/bl_test_rnd.dat', random) + fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl) +}) + +tape('instantiation with Buffer', function (t) { + var buf = crypto.randomBytes(1024) + , buf2 = crypto.randomBytes(1024) + , b = BufferList(buf) + + t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer') + b = BufferList([ buf, buf2 ]) + t.equal(b.slice().toString('hex'), Buffer.concat([ buf, buf2 ]).toString('hex'), 'same buffer') + t.end() +}) + +tape('test String appendage', function (t) { + var bl = new BufferList() + , b = new Buffer('abcdefghij\xff\x00') + + bl.append('abcd') + bl.append('efg') + bl.append('hi') + bl.append('j') + bl.append('\xff\x00') + + encodings.forEach(function (enc) { + t.equal(bl.toString(enc), b.toString(enc)) + }) + + t.end() +}) + +tape('write nothing, should get empty buffer', function (t) { + t.plan(3) + BufferList(function (err, data) { + t.notOk(err, 'no error') + t.ok(Buffer.isBuffer(data), 'got a buffer') + t.equal(0, data.length, 'got a zero-length buffer') + t.end() + }).end() +}) + +tape('unicode string', function (t) { + t.plan(2) + var inp1 = '\u2600' + , inp2 = '\u2603' + , exp = inp1 + ' and ' + inp2 + , bl = BufferList() + bl.write(inp1) + bl.write(' and ') + bl.write(inp2) + t.equal(exp, bl.toString()) + t.equal(new Buffer(exp).toString('hex'), bl.toString('hex')) +}) + +tape('should emit finish', function (t) { + var source = BufferList() + , dest = BufferList() + + source.write('hello') + source.pipe(dest) + + dest.on('finish', function () { + t.equal(dest.toString('utf8'), 'hello') + t.end() + }) +}) + +tape('basic copy', function (t) { + var buf = crypto.randomBytes(1024) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.copy(buf2) + t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer') + t.end() +}) + +tape('copy after many appends', function (t) { + var buf = crypto.randomBytes(512) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.append(buf) + b.copy(buf2) + t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer') + t.end() +}) + +tape('copy at a precise position', function (t) { + var buf = crypto.randomBytes(1004) + , buf2 = new Buffer(1024) + , b = BufferList(buf) + + b.copy(buf2, 20) + t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer') + t.end() +}) + +tape('copy starting from a precise location', function (t) { + var buf = crypto.randomBytes(10) + , buf2 = new Buffer(5) + , b = BufferList(buf) + + b.copy(buf2, 0, 5) + t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer') + t.end() +}) + +tape('copy in an interval', function (t) { + var rnd = crypto.randomBytes(10) + , b = BufferList(rnd) // put the random bytes there + , actual = new Buffer(3) + , expected = new Buffer(3) + + rnd.copy(expected, 0, 5, 8) + b.copy(actual, 0, 5, 8) + + t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer') + t.end() +}) + +tape('copy an interval between two buffers', function (t) { + var buf = crypto.randomBytes(10) + , buf2 = new Buffer(10) + , b = BufferList(buf) + + b.append(buf) + b.copy(buf2, 0, 5, 15) + + t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer') + t.end() +}) + +tape('duplicate', function (t) { + t.plan(2) + + var bl = new BufferList('abcdefghij\xff\x00') + , dup = bl.duplicate() + + t.equal(bl.prototype, dup.prototype) + t.equal(bl.toString('hex'), dup.toString('hex')) +}) + +tape('destroy no pipe', function (t) { + t.plan(2) + + var bl = new BufferList('alsdkfja;lsdkfja;lsdk') + bl.destroy() + + t.equal(bl._bufs.length, 0) + t.equal(bl.length, 0) +}) + +!process.browser && tape('destroy with pipe before read end', function (t) { + t.plan(2) + + var bl = new BufferList() + fs.createReadStream(__dirname + '/sauce.js') + .pipe(bl) + + bl.destroy() + + t.equal(bl._bufs.length, 0) + t.equal(bl.length, 0) + +}) + +!process.browser && tape('destroy with pipe before read end with race', function (t) { + t.plan(2) + + var bl = new BufferList() + fs.createReadStream(__dirname + '/sauce.js') + .pipe(bl) + + setTimeout(function () { + bl.destroy() + setTimeout(function () { + t.equal(bl._bufs.length, 0) + t.equal(bl.length, 0) + }, 500) + }, 500) +}) + +!process.browser && tape('destroy with pipe after read end', function (t) { + t.plan(2) + + var bl = new BufferList() + fs.createReadStream(__dirname + '/sauce.js') + .on('end', onEnd) + .pipe(bl) + + function onEnd () { + bl.destroy() + + t.equal(bl._bufs.length, 0) + t.equal(bl.length, 0) + } +}) + +!process.browser && tape('destroy with pipe while writing to a destination', function (t) { + t.plan(4) + + var bl = new BufferList() + , ds = new BufferList() + + fs.createReadStream(__dirname + '/sauce.js') + .on('end', onEnd) + .pipe(bl) + + function onEnd () { + bl.pipe(ds) + + setTimeout(function () { + bl.destroy() + + t.equals(bl._bufs.length, 0) + t.equals(bl.length, 0) + + ds.destroy() + + t.equals(bl._bufs.length, 0) + t.equals(bl.length, 0) + + }, 100) + } +}) + +!process.browser && tape('handle error', function (t) { + t.plan(2) + fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) { + t.ok(err instanceof Error, 'has error') + t.notOk(data, 'no data') + })) +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/sauce.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/sauce.js new file mode 100644 index 0000000..a6d2862 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/sauce.js @@ -0,0 +1,38 @@ +#!/usr/bin/env node + +const user = process.env.SAUCE_USER + , key = process.env.SAUCE_KEY + , path = require('path') + , brtapsauce = require('brtapsauce') + , testFile = path.join(__dirname, 'basic-test.js') + + , capabilities = [ + { browserName: 'chrome' , platform: 'Windows XP', version: '' } + , { browserName: 'firefox' , platform: 'Windows 8' , version: '' } + , { browserName: 'firefox' , platform: 'Windows XP', version: '4' } + , { browserName: 'internet explorer' , platform: 'Windows 8' , version: '10' } + , { browserName: 'internet explorer' , platform: 'Windows 7' , version: '9' } + , { browserName: 'internet explorer' , platform: 'Windows 7' , version: '8' } + , { browserName: 'internet explorer' , platform: 'Windows XP', version: '7' } + , { browserName: 'internet explorer' , platform: 'Windows XP', version: '6' } + , { browserName: 'safari' , platform: 'Windows 7' , version: '5' } + , { browserName: 'safari' , platform: 'OS X 10.8' , version: '6' } + , { browserName: 'opera' , platform: 'Windows 7' , version: '' } + , { browserName: 'opera' , platform: 'Windows 7' , version: '11' } + , { browserName: 'ipad' , platform: 'OS X 10.8' , version: '6' } + , { browserName: 'android' , platform: 'Linux' , version: '4.0', 'device-type': 'tablet' } + ] + +if (!user) + throw new Error('Must set a SAUCE_USER env var') +if (!key) + throw new Error('Must set a SAUCE_KEY env var') + +brtapsauce({ + name : 'Traversty' + , user : user + , key : key + , brsrc : testFile + , capabilities : capabilities + , options : { timeout: 60 * 6 } +}) \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/test.js new file mode 100644 index 0000000..aa9b487 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/test/test.js @@ -0,0 +1,9 @@ +require('./basic-test') + +if (!process.env.SAUCE_KEY || !process.env.SAUCE_USER) + return console.log('SAUCE_KEY and/or SAUCE_USER not set, not running sauce tests') + +if (!/v0\.10/.test(process.version)) + return console.log('Not Node v0.10.x, not running sauce tests') + +require('./sauce.js') \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/README.md new file mode 100644 index 0000000..e5077a2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/README.md @@ -0,0 +1,45 @@ +## Caseless -- wrap an object to set and get property with caseless semantics but also preserve caseing. + +This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manner while also preserving the caseing of headers the first time they are set. + +## Usage + +```javascript +var headers = {} + , c = caseless(headers) + ; +c.set('a-Header', 'asdf') +c.get('a-header') === 'asdf' +``` + +## has(key) + +Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with. + +```javascript +c.has('a-header') === 'a-Header' +``` + +## set(key, value[, clobber=true]) + +Set is fairly straight forward except that if the header exists and clobber is disabled it will add `','+value` to the existing header. + +```javascript +c.set('a-Header', 'fdas') +c.set('a-HEADER', 'more', false) +c.get('a-header') === 'fdsa,more' +``` + +## swap(key) + +Swaps the casing of a header with the new one that is passed in. + +```javascript +var headers = {} + , c = caseless(headers) + ; +c.set('a-Header', 'fdas') +c.swap('a-HEADER') +c.has('a-header') === 'a-HEADER' +headers === {'a-HEADER': 'fdas'} +``` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/index.js new file mode 100644 index 0000000..ba711f6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/index.js @@ -0,0 +1,65 @@ +function Caseless (dict) { + this.dict = dict || {} +} +Caseless.prototype.set = function (name, value, clobber) { + if (typeof name === 'object') { + for (var i in name) { + this.set(i, name[i], value) + } + } else { + if (typeof clobber === 'undefined') clobber = true + var has = this.has(name) + + if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value + else this.dict[has || name] = value + return has + } +} +Caseless.prototype.has = function (name) { + var keys = Object.keys(this.dict) + , name = name.toLowerCase() + ; + for (var i=0;i=0.9.0 <0.10.0", + "_npmVersion": "1.4.14", + "_npmUser": { + "name": "nylen", + "email": "jnylen@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + { + "name": "nylen", + "email": "jnylen@gmail.com" + } + ], + "dist": { + "shasum": "b7b65ce6bf1413886539cfd533f0b30effa9cf88", + "tarball": "http://registry.npmjs.org/caseless/-/caseless-0.9.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.9.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/test.js new file mode 100644 index 0000000..084bbaf --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/test.js @@ -0,0 +1,40 @@ +var tape = require('tape') + , caseless = require('./') + ; + +tape('set get has', function (t) { + var headers = {} + , c = caseless(headers) + ; + t.plan(17) + c.set('a-Header', 'asdf') + t.equal(c.get('a-header'), 'asdf') + t.equal(c.has('a-header'), 'a-Header') + t.ok(!c.has('nothing')) + // old bug where we used the wrong regex + t.ok(!c.has('a-hea')) + c.set('a-header', 'fdsa') + t.equal(c.get('a-header'), 'fdsa') + t.equal(c.get('a-Header'), 'fdsa') + c.set('a-HEADER', 'more', false) + t.equal(c.get('a-header'), 'fdsa,more') + + t.deepEqual(headers, {'a-Header': 'fdsa,more'}) + c.swap('a-HEADER') + t.deepEqual(headers, {'a-HEADER': 'fdsa,more'}) + + c.set('deleteme', 'foobar') + t.ok(c.has('deleteme')) + t.ok(c.del('deleteme')) + t.notOk(c.has('deleteme')) + t.notOk(c.has('idonotexist')) + t.ok(c.del('idonotexist')) + + c.set('tva', 'test1') + c.set('tva-header', 'test2') + t.equal(c.has('tva'), 'tva') + t.notOk(c.has('header')) + + t.equal(c.get('tva'), 'test1') + +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/License b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/License new file mode 100644 index 0000000..4804b7a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/License @@ -0,0 +1,19 @@ +Copyright (c) 2011 Debuggable Limited + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/Readme.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/Readme.md new file mode 100644 index 0000000..8043cb4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/Readme.md @@ -0,0 +1,132 @@ +# combined-stream [](https://travis-ci.org/felixge/node-combined-stream) + +A stream that emits multiple other streams one after another. + +## Installation + +``` bash +npm install combined-stream +``` + +## Usage + +Here is a simple example that shows how you can use combined-stream to combine +two files into one: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create(); +combinedStream.append(fs.createReadStream('file1.txt')); +combinedStream.append(fs.createReadStream('file2.txt')); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +While the example above works great, it will pause all source streams until +they are needed. If you don't want that to happen, you can set `pauseStreams` +to `false`: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create({pauseStreams: false}); +combinedStream.append(fs.createReadStream('file1.txt')); +combinedStream.append(fs.createReadStream('file2.txt')); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +However, what if you don't have all the source streams yet, or you don't want +to allocate the resources (file descriptors, memory, etc.) for them right away? +Well, in that case you can simply provide a callback that supplies the stream +by calling a `next()` function: + +``` javascript +var CombinedStream = require('combined-stream'); +var fs = require('fs'); + +var combinedStream = CombinedStream.create(); +combinedStream.append(function(next) { + next(fs.createReadStream('file1.txt')); +}); +combinedStream.append(function(next) { + next(fs.createReadStream('file2.txt')); +}); + +combinedStream.pipe(fs.createWriteStream('combined.txt')); +``` + +## API + +### CombinedStream.create([options]) + +Returns a new combined stream object. Available options are: + +* `maxDataSize` +* `pauseStreams` + +The effect of those options is described below. + +### combinedStream.pauseStreams = `true` + +Whether to apply back pressure to the underlaying streams. If set to `false`, +the underlaying streams will never be paused. If set to `true`, the +underlaying streams will be paused right after being appended, as well as when +`delayedStream.pipe()` wants to throttle. + +### combinedStream.maxDataSize = `2 * 1024 * 1024` + +The maximum amount of bytes (or characters) to buffer for all source streams. +If this value is exceeded, `combinedStream` emits an `'error'` event. + +### combinedStream.dataSize = `0` + +The amount of bytes (or characters) currently buffered by `combinedStream`. + +### combinedStream.append(stream) + +Appends the given `stream` to the combinedStream object. If `pauseStreams` is +set to `true, this stream will also be paused right away. + +`streams` can also be a function that takes one parameter called `next`. `next` +is a function that must be invoked in order to provide the `next` stream, see +example above. + +Regardless of how the `stream` is appended, combined-stream always attaches an +`'error'` listener to it, so you don't have to do that manually. + +Special case: `stream` can also be a String or Buffer. + +### combinedStream.write(data) + +You should not call this, `combinedStream` takes care of piping the appended +streams into itself for you. + +### combinedStream.resume() + +Causes `combinedStream` to start drain the streams it manages. The function is +idempotent, and also emits a `'resume'` event each time which usually goes to +the stream that is currently being drained. + +### combinedStream.pause(); + +If `combinedStream.pauseStreams` is set to `false`, this does nothing. +Otherwise a `'pause'` event is emitted, this goes to the stream that is +currently being drained, so you can use it to apply back pressure. + +### combinedStream.end(); + +Sets `combinedStream.writable` to false, emits an `'end'` event, and removes +all streams from the queue. + +### combinedStream.destroy(); + +Same as `combinedStream.end()`, except it emits a `'close'` event instead of +`'end'`. + +## License + +combined-stream is licensed under the MIT license. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/lib/combined_stream.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/lib/combined_stream.js new file mode 100644 index 0000000..6b5c21b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/lib/combined_stream.js @@ -0,0 +1,188 @@ +var util = require('util'); +var Stream = require('stream').Stream; +var DelayedStream = require('delayed-stream'); + +module.exports = CombinedStream; +function CombinedStream() { + this.writable = false; + this.readable = true; + this.dataSize = 0; + this.maxDataSize = 2 * 1024 * 1024; + this.pauseStreams = true; + + this._released = false; + this._streams = []; + this._currentStream = null; +} +util.inherits(CombinedStream, Stream); + +CombinedStream.create = function(options) { + var combinedStream = new this(); + + options = options || {}; + for (var option in options) { + combinedStream[option] = options[option]; + } + + return combinedStream; +}; + +CombinedStream.isStreamLike = function(stream) { + return (typeof stream !== 'function') + && (typeof stream !== 'string') + && (typeof stream !== 'boolean') + && (typeof stream !== 'number') + && (!Buffer.isBuffer(stream)); +}; + +CombinedStream.prototype.append = function(stream) { + var isStreamLike = CombinedStream.isStreamLike(stream); + + if (isStreamLike) { + if (!(stream instanceof DelayedStream)) { + var newStream = DelayedStream.create(stream, { + maxDataSize: Infinity, + pauseStream: this.pauseStreams, + }); + stream.on('data', this._checkDataSize.bind(this)); + stream = newStream; + } + + this._handleErrors(stream); + + if (this.pauseStreams) { + stream.pause(); + } + } + + this._streams.push(stream); + return this; +}; + +CombinedStream.prototype.pipe = function(dest, options) { + Stream.prototype.pipe.call(this, dest, options); + this.resume(); + return dest; +}; + +CombinedStream.prototype._getNext = function() { + this._currentStream = null; + var stream = this._streams.shift(); + + + if (typeof stream == 'undefined') { + this.end(); + return; + } + + if (typeof stream !== 'function') { + this._pipeNext(stream); + return; + } + + var getStream = stream; + getStream(function(stream) { + var isStreamLike = CombinedStream.isStreamLike(stream); + if (isStreamLike) { + stream.on('data', this._checkDataSize.bind(this)); + this._handleErrors(stream); + } + + this._pipeNext(stream); + }.bind(this)); +}; + +CombinedStream.prototype._pipeNext = function(stream) { + this._currentStream = stream; + + var isStreamLike = CombinedStream.isStreamLike(stream); + if (isStreamLike) { + stream.on('end', this._getNext.bind(this)); + stream.pipe(this, {end: false}); + return; + } + + var value = stream; + this.write(value); + this._getNext(); +}; + +CombinedStream.prototype._handleErrors = function(stream) { + var self = this; + stream.on('error', function(err) { + self._emitError(err); + }); +}; + +CombinedStream.prototype.write = function(data) { + this.emit('data', data); +}; + +CombinedStream.prototype.pause = function() { + if (!this.pauseStreams) { + return; + } + + if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause(); + this.emit('pause'); +}; + +CombinedStream.prototype.resume = function() { + if (!this._released) { + this._released = true; + this.writable = true; + this._getNext(); + } + + if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume(); + this.emit('resume'); +}; + +CombinedStream.prototype.end = function() { + this._reset(); + this.emit('end'); +}; + +CombinedStream.prototype.destroy = function() { + this._reset(); + this.emit('close'); +}; + +CombinedStream.prototype._reset = function() { + this.writable = false; + this._streams = []; + this._currentStream = null; +}; + +CombinedStream.prototype._checkDataSize = function() { + this._updateDataSize(); + if (this.dataSize <= this.maxDataSize) { + return; + } + + var message = + 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'; + this._emitError(new Error(message)); +}; + +CombinedStream.prototype._updateDataSize = function() { + this.dataSize = 0; + + var self = this; + this._streams.forEach(function(stream) { + if (!stream.dataSize) { + return; + } + + self.dataSize += stream.dataSize; + }); + + if (this._currentStream && this._currentStream.dataSize) { + this.dataSize += this._currentStream.dataSize; + } +}; + +CombinedStream.prototype._emitError = function(err) { + this._reset(); + this.emit('error', err); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/.npmignore new file mode 100644 index 0000000..2fedb26 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/.npmignore @@ -0,0 +1,2 @@ +*.un~ +/node_modules/* diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/License b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/License new file mode 100644 index 0000000..4804b7a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/License @@ -0,0 +1,19 @@ +Copyright (c) 2011 Debuggable Limited + +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Makefile b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Makefile new file mode 100644 index 0000000..b4ff85a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Makefile @@ -0,0 +1,7 @@ +SHELL := /bin/bash + +test: + @./test/run.js + +.PHONY: test + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Readme.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Readme.md new file mode 100644 index 0000000..5cb5b35 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/Readme.md @@ -0,0 +1,154 @@ +# delayed-stream + +Buffers events from a stream until you are ready to handle them. + +## Installation + +``` bash +npm install delayed-stream +``` + +## Usage + +The following example shows how to write a http echo server that delays its +response by 1000 ms. + +``` javascript +var DelayedStream = require('delayed-stream'); +var http = require('http'); + +http.createServer(function(req, res) { + var delayed = DelayedStream.create(req); + + setTimeout(function() { + res.writeHead(200); + delayed.pipe(res); + }, 1000); +}); +``` + +If you are not using `Stream#pipe`, you can also manually release the buffered +events by calling `delayedStream.resume()`: + +``` javascript +var delayed = DelayedStream.create(req); + +setTimeout(function() { + // Emit all buffered events and resume underlaying source + delayed.resume(); +}, 1000); +``` + +## Implementation + +In order to use this meta stream properly, here are a few things you should +know about the implementation. + +### Event Buffering / Proxying + +All events of the `source` stream are hijacked by overwriting the `source.emit` +method. Until node implements a catch-all event listener, this is the only way. + +However, delayed-stream still continues to emit all events it captures on the +`source`, regardless of whether you have released the delayed stream yet or +not. + +Upon creation, delayed-stream captures all `source` events and stores them in +an internal event buffer. Once `delayedStream.release()` is called, all +buffered events are emitted on the `delayedStream`, and the event buffer is +cleared. After that, delayed-stream merely acts as a proxy for the underlaying +source. + +### Error handling + +Error events on `source` are buffered / proxied just like any other events. +However, `delayedStream.create` attaches a no-op `'error'` listener to the +`source`. This way you only have to handle errors on the `delayedStream` +object, rather than in two places. + +### Buffer limits + +delayed-stream provides a `maxDataSize` property that can be used to limit +the amount of data being buffered. In order to protect you from bad `source` +streams that don't react to `source.pause()`, this feature is enabled by +default. + +## API + +### DelayedStream.create(source, [options]) + +Returns a new `delayedStream`. Available options are: + +* `pauseStream` +* `maxDataSize` + +The description for those properties can be found below. + +### delayedStream.source + +The `source` stream managed by this object. This is useful if you are +passing your `delayedStream` around, and you still want to access properties +on the `source` object. + +### delayedStream.pauseStream = true + +Whether to pause the underlaying `source` when calling +`DelayedStream.create()`. Modifying this property afterwards has no effect. + +### delayedStream.maxDataSize = 1024 * 1024 + +The amount of data to buffer before emitting an `error`. + +If the underlaying source is emitting `Buffer` objects, the `maxDataSize` +refers to bytes. + +If the underlaying source is emitting JavaScript strings, the size refers to +characters. + +If you know what you are doing, you can set this property to `Infinity` to +disable this feature. You can also modify this property during runtime. + +### delayedStream.maxDataSize = 1024 * 1024 + +The amount of data to buffer before emitting an `error`. + +If the underlaying source is emitting `Buffer` objects, the `maxDataSize` +refers to bytes. + +If the underlaying source is emitting JavaScript strings, the size refers to +characters. + +If you know what you are doing, you can set this property to `Infinity` to +disable this feature. + +### delayedStream.dataSize = 0 + +The amount of data buffered so far. + +### delayedStream.readable + +An ECMA5 getter that returns the value of `source.readable`. + +### delayedStream.resume() + +If the `delayedStream` has not been released so far, `delayedStream.release()` +is called. + +In either case, `source.resume()` is called. + +### delayedStream.pause() + +Calls `source.pause()`. + +### delayedStream.pipe(dest) + +Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`. + +### delayedStream.release() + +Emits and clears all events that have been buffered up so far. This does not +resume the underlaying source, use `delayedStream.resume()` instead. + +## License + +delayed-stream is licensed under the MIT license. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js new file mode 100644 index 0000000..7c10d48 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js @@ -0,0 +1,99 @@ +var Stream = require('stream').Stream; +var util = require('util'); + +module.exports = DelayedStream; +function DelayedStream() { + this.source = null; + this.dataSize = 0; + this.maxDataSize = 1024 * 1024; + this.pauseStream = true; + + this._maxDataSizeExceeded = false; + this._released = false; + this._bufferedEvents = []; +} +util.inherits(DelayedStream, Stream); + +DelayedStream.create = function(source, options) { + var delayedStream = new this(); + + options = options || {}; + for (var option in options) { + delayedStream[option] = options[option]; + } + + delayedStream.source = source; + + var realEmit = source.emit; + source.emit = function() { + delayedStream._handleEmit(arguments); + return realEmit.apply(source, arguments); + }; + + source.on('error', function() {}); + if (delayedStream.pauseStream) { + source.pause(); + } + + return delayedStream; +}; + +DelayedStream.prototype.__defineGetter__('readable', function() { + return this.source.readable; +}); + +DelayedStream.prototype.resume = function() { + if (!this._released) { + this.release(); + } + + this.source.resume(); +}; + +DelayedStream.prototype.pause = function() { + this.source.pause(); +}; + +DelayedStream.prototype.release = function() { + this._released = true; + + this._bufferedEvents.forEach(function(args) { + this.emit.apply(this, args); + }.bind(this)); + this._bufferedEvents = []; +}; + +DelayedStream.prototype.pipe = function() { + var r = Stream.prototype.pipe.apply(this, arguments); + this.resume(); + return r; +}; + +DelayedStream.prototype._handleEmit = function(args) { + if (this._released) { + this.emit.apply(this, args); + return; + } + + if (args[0] === 'data') { + this.dataSize += args[1].length; + this._checkIfMaxDataSizeExceeded(); + } + + this._bufferedEvents.push(args); +}; + +DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() { + if (this._maxDataSizeExceeded) { + return; + } + + if (this.dataSize <= this.maxDataSize) { + return; + } + + this._maxDataSizeExceeded = true; + var message = + 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.' + this.emit('error', new Error(message)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json new file mode 100644 index 0000000..cbafd00 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/package.json @@ -0,0 +1,42 @@ +{ + "author": { + "name": "Felix Geisendörfer", + "email": "felix@debuggable.com", + "url": "http://debuggable.com/" + }, + "name": "delayed-stream", + "description": "Buffers events from a stream until you are ready to handle them.", + "version": "0.0.5", + "homepage": "https://github.com/felixge/node-delayed-stream", + "repository": { + "type": "git", + "url": "git://github.com/felixge/node-delayed-stream.git" + }, + "main": "./lib/delayed_stream", + "engines": { + "node": ">=0.4.0" + }, + "dependencies": {}, + "devDependencies": { + "fake": "0.2.0", + "far": "0.0.1" + }, + "_id": "delayed-stream@0.0.5", + "_engineSupported": true, + "_npmVersion": "1.0.3", + "_nodeVersion": "v0.4.9-pre", + "_defaultsLoaded": true, + "dist": { + "shasum": "d4b1f43a93e8296dfe02694f4680bc37a313c73f", + "tarball": "http://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" + }, + "scripts": {}, + "directories": {}, + "_shasum": "d4b1f43a93e8296dfe02694f4680bc37a313c73f", + "_from": "delayed-stream@0.0.5", + "_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", + "bugs": { + "url": "https://github.com/felixge/node-delayed-stream/issues" + }, + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/common.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/common.js new file mode 100644 index 0000000..4d71b8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/common.js @@ -0,0 +1,6 @@ +var common = module.exports; + +common.DelayedStream = require('..'); +common.assert = require('assert'); +common.fake = require('fake'); +common.PORT = 49252; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js new file mode 100644 index 0000000..9ecad5b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js @@ -0,0 +1,38 @@ +var common = require('../common'); +var assert = common.assert; +var DelayedStream = common.DelayedStream; +var http = require('http'); + +var UPLOAD = new Buffer(10 * 1024 * 1024); + +var server = http.createServer(function(req, res) { + var delayed = DelayedStream.create(req, {maxDataSize: UPLOAD.length}); + + setTimeout(function() { + res.writeHead(200); + delayed.pipe(res); + }, 10); +}); +server.listen(common.PORT, function() { + var request = http.request({ + method: 'POST', + port: common.PORT, + }); + + request.write(UPLOAD); + request.end(); + + request.on('response', function(res) { + var received = 0; + res + .on('data', function(chunk) { + received += chunk.length; + }) + .on('end', function() { + assert.equal(received, UPLOAD.length); + server.close(); + }); + }); +}); + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js new file mode 100644 index 0000000..6f417f3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js @@ -0,0 +1,21 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testAutoPause() { + var source = new Stream(); + + fake.expect(source, 'pause', 1); + var delayedStream = DelayedStream.create(source); + fake.verify(); +})(); + +(function testDisableAutoPause() { + var source = new Stream(); + fake.expect(source, 'pause', 0); + + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + fake.verify(); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js new file mode 100644 index 0000000..b50c397 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js @@ -0,0 +1,14 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testDelayEventsUntilResume() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + + fake.expect(source, 'pause'); + delayedStream.pause(); + fake.verify(); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js new file mode 100644 index 0000000..fc4047e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js @@ -0,0 +1,48 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testDelayEventsUntilResume() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + + // delayedStream must not emit until we resume + fake.expect(delayedStream, 'emit', 0); + + // but our original source must emit + var params = []; + source.on('foo', function(param) { + params.push(param); + }); + + source.emit('foo', 1); + source.emit('foo', 2); + + // Make sure delayedStream did not emit, and source did + assert.deepEqual(params, [1, 2]); + fake.verify(); + + // After resume, delayedStream must playback all events + fake + .stub(delayedStream, 'emit') + .times(Infinity) + .withArg(1, 'newListener'); + fake.expect(delayedStream, 'emit', ['foo', 1]); + fake.expect(delayedStream, 'emit', ['foo', 2]); + fake.expect(source, 'resume'); + + delayedStream.resume(); + fake.verify(); + + // Calling resume again will delegate to source + fake.expect(source, 'resume'); + delayedStream.resume(); + fake.verify(); + + // Emitting more events directly leads to them being emitted + fake.expect(delayedStream, 'emit', ['foo', 3]); + source.emit('foo', 3); + fake.verify(); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js new file mode 100644 index 0000000..a9d35e7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js @@ -0,0 +1,15 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testHandleSourceErrors() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + + // We deal with this by attaching a no-op listener to 'error' on the source + // when creating a new DelayedStream. This way error events on the source + // won't throw. + source.emit('error', new Error('something went wrong')); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js new file mode 100644 index 0000000..7638a2b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js @@ -0,0 +1,18 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testMaxDataSize() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {maxDataSize: 1024, pauseStream: false}); + + source.emit('data', new Buffer(1024)); + + fake + .expect(delayedStream, 'emit') + .withArg(1, 'error'); + source.emit('data', new Buffer(1)); + fake.verify(); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js new file mode 100644 index 0000000..7d312ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js @@ -0,0 +1,13 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testPipeReleases() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + + fake.expect(delayedStream, 'resume'); + delayedStream.pipe(new Stream()); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js new file mode 100644 index 0000000..d436163 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js @@ -0,0 +1,13 @@ +var common = require('../common'); +var assert = common.assert; +var fake = common.fake.create(); +var DelayedStream = common.DelayedStream; +var Stream = require('stream').Stream; + +(function testProxyReadableProperty() { + var source = new Stream(); + var delayedStream = DelayedStream.create(source, {pauseStream: false}); + + source.readable = fake.value('source.readable'); + assert.strictEqual(delayedStream.readable, source.readable); +})(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/run.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/run.js new file mode 100755 index 0000000..0bb8e82 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/node_modules/delayed-stream/test/run.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node +var far = require('far').create(); + +far.add(__dirname); +far.include(/test-.*\.js$/); + +far.execute(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/package.json new file mode 100644 index 0000000..a44fef9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/combined-stream/package.json @@ -0,0 +1,60 @@ +{ + "author": { + "name": "Felix Geisendörfer", + "email": "felix@debuggable.com", + "url": "http://debuggable.com/" + }, + "name": "combined-stream", + "description": "A stream that emits multiple other streams one after another.", + "version": "0.0.7", + "homepage": "https://github.com/felixge/node-combined-stream", + "repository": { + "type": "git", + "url": "git://github.com/felixge/node-combined-stream.git" + }, + "main": "./lib/combined_stream", + "scripts": { + "test": "node test/run.js" + }, + "engines": { + "node": ">= 0.8" + }, + "dependencies": { + "delayed-stream": "0.0.5" + }, + "devDependencies": { + "far": "~0.0.7" + }, + "bugs": { + "url": "https://github.com/felixge/node-combined-stream/issues" + }, + "_id": "combined-stream@0.0.7", + "dist": { + "shasum": "0137e657baa5a7541c57ac37ac5fc07d73b4dc1f", + "tarball": "http://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz" + }, + "_from": "combined-stream@>=0.0.5 <0.1.0", + "_npmVersion": "1.4.3", + "_npmUser": { + "name": "felixge", + "email": "felix@debuggable.com" + }, + "maintainers": [ + { + "name": "felixge", + "email": "felix@debuggable.com" + }, + { + "name": "celer", + "email": "celer@scrypt.net" + }, + { + "name": "alexindigo", + "email": "iam@alexindigo.com" + } + ], + "directories": {}, + "_shasum": "0137e657baa5a7541c57ac37ac5fc07d73b4dc1f", + "_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/LICENSE new file mode 100644 index 0000000..a4a9aee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/README.md new file mode 100644 index 0000000..9d5b663 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/README.md @@ -0,0 +1,4 @@ +forever-agent +============= + +HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/index.js new file mode 100644 index 0000000..416c7ab --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/index.js @@ -0,0 +1,138 @@ +module.exports = ForeverAgent +ForeverAgent.SSL = ForeverAgentSSL + +var util = require('util') + , Agent = require('http').Agent + , net = require('net') + , tls = require('tls') + , AgentSSL = require('https').Agent + +function getConnectionName(host, port) { + var name = '' + if (typeof host === 'string') { + name = host + ':' + port + } else { + // For node.js v012.0 and iojs-v1.5.1, host is an object. And any existing localAddress is part of the connection name. + name = host.host + ':' + host.port + ':' + (host.localAddress ? (host.localAddress + ':') : ':') + } + return name +} + +function ForeverAgent(options) { + var self = this + self.options = options || {} + self.requests = {} + self.sockets = {} + self.freeSockets = {} + self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets + self.minSockets = self.options.minSockets || ForeverAgent.defaultMinSockets + self.on('free', function(socket, host, port) { + var name = getConnectionName(host, port) + + if (self.requests[name] && self.requests[name].length) { + self.requests[name].shift().onSocket(socket) + } else if (self.sockets[name].length < self.minSockets) { + if (!self.freeSockets[name]) self.freeSockets[name] = [] + self.freeSockets[name].push(socket) + + // if an error happens while we don't use the socket anyway, meh, throw the socket away + var onIdleError = function() { + socket.destroy() + } + socket._onIdleError = onIdleError + socket.on('error', onIdleError) + } else { + // If there are no pending requests just destroy the + // socket and it will get removed from the pool. This + // gets us out of timeout issues and allows us to + // default to Connection:keep-alive. + socket.destroy() + } + }) + +} +util.inherits(ForeverAgent, Agent) + +ForeverAgent.defaultMinSockets = 5 + + +ForeverAgent.prototype.createConnection = net.createConnection +ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest +ForeverAgent.prototype.addRequest = function(req, host, port) { + var name = getConnectionName(host, port) + + if (typeof host !== 'string') { + var options = host + port = options.port + host = options.host + } + + if (this.freeSockets[name] && this.freeSockets[name].length > 0 && !req.useChunkedEncodingByDefault) { + var idleSocket = this.freeSockets[name].pop() + idleSocket.removeListener('error', idleSocket._onIdleError) + delete idleSocket._onIdleError + req._reusedSocket = true + req.onSocket(idleSocket) + } else { + this.addRequestNoreuse(req, host, port) + } +} + +ForeverAgent.prototype.removeSocket = function(s, name, host, port) { + if (this.sockets[name]) { + var index = this.sockets[name].indexOf(s) + if (index !== -1) { + this.sockets[name].splice(index, 1) + } + } else if (this.sockets[name] && this.sockets[name].length === 0) { + // don't leak + delete this.sockets[name] + delete this.requests[name] + } + + if (this.freeSockets[name]) { + var index = this.freeSockets[name].indexOf(s) + if (index !== -1) { + this.freeSockets[name].splice(index, 1) + if (this.freeSockets[name].length === 0) { + delete this.freeSockets[name] + } + } + } + + if (this.requests[name] && this.requests[name].length) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(name, host, port).emit('free') + } +} + +function ForeverAgentSSL (options) { + ForeverAgent.call(this, options) +} +util.inherits(ForeverAgentSSL, ForeverAgent) + +ForeverAgentSSL.prototype.createConnection = createConnectionSSL +ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest + +function createConnectionSSL (port, host, options) { + if (typeof port === 'object') { + options = port; + } else if (typeof host === 'object') { + options = host; + } else if (typeof options === 'object') { + options = options; + } else { + options = {}; + } + + if (typeof port === 'number') { + options.port = port; + } + + if (typeof host === 'string') { + options.host = host; + } + + return tls.connect(options); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/package.json new file mode 100644 index 0000000..ef074a5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/package.json @@ -0,0 +1,56 @@ +{ + "author": { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com", + "url": "http://www.futurealoof.com" + }, + "name": "forever-agent", + "description": "HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.", + "version": "0.6.1", + "license": "Apache-2.0", + "repository": { + "url": "git+https://github.com/mikeal/forever-agent.git" + }, + "main": "index.js", + "dependencies": {}, + "devDependencies": {}, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "gitHead": "1b3b6163f2b3c2c4122bbfa288c1325c0df9871d", + "bugs": { + "url": "https://github.com/mikeal/forever-agent/issues" + }, + "homepage": "https://github.com/mikeal/forever-agent", + "_id": "forever-agent@0.6.1", + "scripts": {}, + "_shasum": "fbc71f0c41adeb37f96c577ad1ed42d8fdacca91", + "_from": "forever-agent@>=0.6.0 <0.7.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "simov", + "email": "simeonvelichkov@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + { + "name": "nylen", + "email": "jnylen@gmail.com" + }, + { + "name": "simov", + "email": "simeonvelichkov@gmail.com" + } + ], + "dist": { + "shasum": "fbc71f0c41adeb37f96c577ad1ed42d8fdacca91", + "tarball": "http://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/License b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/License new file mode 100644 index 0000000..c7ff12a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/License @@ -0,0 +1,19 @@ +Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors + + 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/Readme.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/Readme.md new file mode 100644 index 0000000..c8a1a55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/Readme.md @@ -0,0 +1,175 @@ +# Form-Data [](https://travis-ci.org/felixge/node-form-data) [](https://gemnasium.com/felixge/node-form-data) + +A module to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications. + +The API of this module is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd]. + +[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface +[streams2-thing]: http://nodejs.org/api/stream.html#stream_compatibility_with_older_node_versions + +## Install + +``` +npm install form-data +``` + +## Usage + +In this example we are constructing a form with 3 fields that contain a string, +a buffer and a file stream. + +``` javascript +var FormData = require('form-data'); +var fs = require('fs'); + +var form = new FormData(); +form.append('my_field', 'my value'); +form.append('my_buffer', new Buffer(10)); +form.append('my_file', fs.createReadStream('/foo/bar.jpg')); +``` + +Also you can use http-response stream: + +``` javascript +var FormData = require('form-data'); +var http = require('http'); + +var form = new FormData(); + +http.request('http://nodejs.org/images/logo.png', function(response) { + form.append('my_field', 'my value'); + form.append('my_buffer', new Buffer(10)); + form.append('my_logo', response); +}); +``` + +Or @mikeal's request stream: + +``` javascript +var FormData = require('form-data'); +var request = require('request'); + +var form = new FormData(); + +form.append('my_field', 'my value'); +form.append('my_buffer', new Buffer(10)); +form.append('my_logo', request('http://nodejs.org/images/logo.png')); +``` + +In order to submit this form to a web application, call ```submit(url, [callback])``` method: + +``` javascript +form.submit('http://example.org/', function(err, res) { + // res – response object (http.IncomingMessage) // + res.resume(); // for node-0.10.x +}); + +``` + +For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods. + +### Alternative submission methods + +You can use node's http client interface: + +``` javascript +var http = require('http'); + +var request = http.request({ + method: 'post', + host: 'example.org', + path: '/upload', + headers: form.getHeaders() +}); + +form.pipe(request); + +request.on('response', function(res) { + console.log(res.statusCode); +}); +``` + +Or if you would prefer the `'Content-Length'` header to be set for you: + +``` javascript +form.submit('example.org/upload', function(err, res) { + console.log(res.statusCode); +}); +``` + +To use custom headers and pre-known length in parts: + +``` javascript +var CRLF = '\r\n'; +var form = new FormData(); + +var options = { + header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF, + knownLength: 1 +}; + +form.append('my_buffer', buffer, options); + +form.submit('http://example.com/', function(err, res) { + if (err) throw err; + console.log('Done'); +}); +``` + +Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually: + +``` javascript +someModule.stream(function(err, stdout, stderr) { + if (err) throw err; + + var form = new FormData(); + + form.append('file', stdout, { + filename: 'unicycle.jpg', + contentType: 'image/jpg', + knownLength: 19806 + }); + + form.submit('http://example.com/', function(err, res) { + if (err) throw err; + console.log('Done'); + }); +}); +``` + +For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter: + +``` javascript +form.submit({ + host: 'example.com', + path: '/probably.php?extra=params', + auth: 'username:password' +}, function(err, res) { + console.log(res.statusCode); +}); +``` + +In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`: + +``` javascript +form.submit({ + host: 'example.com', + path: '/surelynot.php', + headers: {'x-test-header': 'test-header-value'} +}, function(err, res) { + console.log(res.statusCode); +}); +``` + +## Notes + +- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround. +- If it feels like FormData hangs after submit and you're on ```node-0.10```, please check [Compatibility with Older Node Versions][streams2-thing] + +## TODO + +- Add new streams (0.10) support and try really hard not to break it for 0.8.x. + +## License + +Form-Data is licensed under the MIT license. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/lib/form_data.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/lib/form_data.js new file mode 100644 index 0000000..5b33f55 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/lib/form_data.js @@ -0,0 +1,351 @@ +var CombinedStream = require('combined-stream'); +var util = require('util'); +var path = require('path'); +var http = require('http'); +var https = require('https'); +var parseUrl = require('url').parse; +var fs = require('fs'); +var mime = require('mime-types'); +var async = require('async'); + +module.exports = FormData; +function FormData() { + this._overheadLength = 0; + this._valueLength = 0; + this._lengthRetrievers = []; + + CombinedStream.call(this); +} +util.inherits(FormData, CombinedStream); + +FormData.LINE_BREAK = '\r\n'; + +FormData.prototype.append = function(field, value, options) { + options = options || {}; + + var append = CombinedStream.prototype.append.bind(this); + + // all that streamy business can't handle numbers + if (typeof value == 'number') value = ''+value; + + // https://github.com/felixge/node-form-data/issues/38 + if (util.isArray(value)) { + // Please convert your array into string + // the way web server expects it + this._error(new Error('Arrays are not supported.')); + return; + } + + var header = this._multiPartHeader(field, value, options); + var footer = this._multiPartFooter(field, value, options); + + append(header); + append(value); + append(footer); + + // pass along options.knownLength + this._trackLength(header, value, options); +}; + +FormData.prototype._trackLength = function(header, value, options) { + var valueLength = 0; + + // used w/ getLengthSync(), when length is known. + // e.g. for streaming directly from a remote server, + // w/ a known file a size, and not wanting to wait for + // incoming file to finish to get its size. + if (options.knownLength != null) { + valueLength += +options.knownLength; + } else if (Buffer.isBuffer(value)) { + valueLength = value.length; + } else if (typeof value === 'string') { + valueLength = Buffer.byteLength(value); + } + + this._valueLength += valueLength; + + // @check why add CRLF? does this account for custom/multiple CRLFs? + this._overheadLength += + Buffer.byteLength(header) + + + FormData.LINE_BREAK.length; + + // empty or either doesn't have path or not an http response + if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) )) { + return; + } + + // no need to bother with the length + if (!options.knownLength) + this._lengthRetrievers.push(function(next) { + + if (value.hasOwnProperty('fd')) { + + // take read range into a account + // `end` = Infinity –> read file till the end + // + // TODO: Looks like there is bug in Node fs.createReadStream + // it doesn't respect `end` options without `start` options + // Fix it when node fixes it. + // https://github.com/joyent/node/issues/7819 + if (value.end != undefined && value.end != Infinity && value.start != undefined) { + + // when end specified + // no need to calculate range + // inclusive, starts with 0 + next(null, value.end+1 - (value.start ? value.start : 0)); + + // not that fast snoopy + } else { + // still need to fetch file size from fs + fs.stat(value.path, function(err, stat) { + + var fileSize; + + if (err) { + next(err); + return; + } + + // update final size based on the range options + fileSize = stat.size - (value.start ? value.start : 0); + next(null, fileSize); + }); + } + + // or http response + } else if (value.hasOwnProperty('httpVersion')) { + next(null, +value.headers['content-length']); + + // or request stream http://github.com/mikeal/request + } else if (value.hasOwnProperty('httpModule')) { + // wait till response come back + value.on('response', function(response) { + value.pause(); + next(null, +response.headers['content-length']); + }); + value.resume(); + + // something else + } else { + next('Unknown stream'); + } + }); +}; + +FormData.prototype._multiPartHeader = function(field, value, options) { + var boundary = this.getBoundary(); + var header = ''; + + // custom header specified (as string)? + // it becomes responsible for boundary + // (e.g. to handle extra CRLFs on .NET servers) + if (options.header != null) { + header = options.header; + } else { + header += '--' + boundary + FormData.LINE_BREAK + + 'Content-Disposition: form-data; name="' + field + '"'; + + // fs- and request- streams have path property + // or use custom filename and/or contentType + // TODO: Use request's response mime-type + if (options.filename || value.path) { + header += + '; filename="' + path.basename(options.filename || value.path) + '"' + FormData.LINE_BREAK + + 'Content-Type: ' + (options.contentType || mime.lookup(options.filename || value.path)); + + // http response has not + } else if (value.readable && value.hasOwnProperty('httpVersion')) { + header += + '; filename="' + path.basename(value.client._httpMessage.path) + '"' + FormData.LINE_BREAK + + 'Content-Type: ' + value.headers['content-type']; + } + + header += FormData.LINE_BREAK + FormData.LINE_BREAK; + } + + return header; +}; + +FormData.prototype._multiPartFooter = function(field, value, options) { + return function(next) { + var footer = FormData.LINE_BREAK; + + var lastPart = (this._streams.length === 0); + if (lastPart) { + footer += this._lastBoundary(); + } + + next(footer); + }.bind(this); +}; + +FormData.prototype._lastBoundary = function() { + return '--' + this.getBoundary() + '--'; +}; + +FormData.prototype.getHeaders = function(userHeaders) { + var formHeaders = { + 'content-type': 'multipart/form-data; boundary=' + this.getBoundary() + }; + + for (var header in userHeaders) { + formHeaders[header.toLowerCase()] = userHeaders[header]; + } + + return formHeaders; +} + +FormData.prototype.getCustomHeaders = function(contentType) { + contentType = contentType ? contentType : 'multipart/form-data'; + + var formHeaders = { + 'content-type': contentType + '; boundary=' + this.getBoundary(), + 'content-length': this.getLengthSync() + }; + + return formHeaders; +} + +FormData.prototype.getBoundary = function() { + if (!this._boundary) { + this._generateBoundary(); + } + + return this._boundary; +}; + +FormData.prototype._generateBoundary = function() { + // This generates a 50 character boundary similar to those used by Firefox. + // They are optimized for boyer-moore parsing. + var boundary = '--------------------------'; + for (var i = 0; i < 24; i++) { + boundary += Math.floor(Math.random() * 10).toString(16); + } + + this._boundary = boundary; +}; + +// Note: getLengthSync DOESN'T calculate streams length +// As workaround one can calculate file size manually +// and add it as knownLength option +FormData.prototype.getLengthSync = function(debug) { + var knownLength = this._overheadLength + this._valueLength; + + // Don't get confused, there are 3 "internal" streams for each keyval pair + // so it basically checks if there is any value added to the form + if (this._streams.length) { + knownLength += this._lastBoundary().length; + } + + // https://github.com/felixge/node-form-data/issues/40 + if (this._lengthRetrievers.length) { + // Some async length retrivers are present + // therefore synchronous length calculation is false. + // Please use getLength(callback) to get proper length + this._error(new Error('Cannot calculate proper length in synchronous way.')); + } + + return knownLength; +}; + +FormData.prototype.getLength = function(cb) { + var knownLength = this._overheadLength + this._valueLength; + + if (this._streams.length) { + knownLength += this._lastBoundary().length; + } + + if (!this._lengthRetrievers.length) { + process.nextTick(cb.bind(this, null, knownLength)); + return; + } + + async.parallel(this._lengthRetrievers, function(err, values) { + if (err) { + cb(err); + return; + } + + values.forEach(function(length) { + knownLength += length; + }); + + cb(null, knownLength); + }); +}; + +FormData.prototype.submit = function(params, cb) { + + var request + , options + , defaults = { + method : 'post' + }; + + // parse provided url if it's string + // or treat it as options object + if (typeof params == 'string') { + params = parseUrl(params); + + options = populate({ + port: params.port, + path: params.pathname, + host: params.hostname + }, defaults); + } + else // use custom params + { + options = populate(params, defaults); + // if no port provided use default one + if (!options.port) { + options.port = options.protocol == 'https:' ? 443 : 80; + } + } + + // put that good code in getHeaders to some use + options.headers = this.getHeaders(params.headers); + + // https if specified, fallback to http in any other case + if (params.protocol == 'https:') { + request = https.request(options); + } else { + request = http.request(options); + } + + // get content length and fire away + this.getLength(function(err, length) { + + // TODO: Add chunked encoding when no length (if err) + + // add content length + request.setHeader('Content-Length', length); + + this.pipe(request); + if (cb) { + request.on('error', cb); + request.on('response', cb.bind(this, null)); + } + }.bind(this)); + + return request; +}; + +FormData.prototype._error = function(err) { + if (this.error) return; + + this.error = err; + this.pause(); + this.emit('error', err); +}; + +/* + * Santa's little helpers + */ + +// populates missing values +function populate(dst, src) { + for (var prop in src) { + if (!dst[prop]) dst[prop] = src[prop]; + } + return dst; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml new file mode 100644 index 0000000..6e5919d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/LICENSE new file mode 100644 index 0000000..8f29698 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010-2014 Caolan McMahon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/README.md new file mode 100644 index 0000000..0bea531 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/README.md @@ -0,0 +1,1646 @@ +# Async.js + +[](https://travis-ci.org/caolan/async) + + +Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with [Node.js](http://nodejs.org), it can also be used directly in the +browser. Also supports [component](https://github.com/component/component). + +Async provides around 20 functions that include the usual 'functional' +suspects (`map`, `reduce`, `filter`, `each`…) as well as some common patterns +for asynchronous control flow (`parallel`, `series`, `waterfall`…). All these +functions assume you follow the Node.js convention of providing a single +callback as the last argument of your `async` function. + + +## Quick Examples + +```javascript +async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file +}); + +async.filter(['file1','file2','file3'], fs.exists, function(results){ + // results now equals an array of the existing files +}); + +async.parallel([ + function(){ ... }, + function(){ ... } +], callback); + +async.series([ + function(){ ... }, + function(){ ... } +]); +``` + +There are many more functions available so take a look at the docs below for a +full list. This module aims to be comprehensive, so if you feel anything is +missing please create a GitHub issue for it. + +## Common Pitfalls + +### Binding a context to an iterator + +This section is really about `bind`, not about `async`. If you are wondering how to +make `async` execute your iterators in a given context, or are confused as to why +a method of another library isn't working as an iterator, study this example: + +```js +// Here is a simple object with an (unnecessarily roundabout) squaring method +var AsyncSquaringLibrary = { + squareExponent: 2, + square: function(number, callback){ + var result = Math.pow(number, this.squareExponent); + setTimeout(function(){ + callback(null, result); + }, 200); + } +}; + +async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){ + // result is [NaN, NaN, NaN] + // This fails because the `this.squareExponent` expression in the square + // function is not evaluated in the context of AsyncSquaringLibrary, and is + // therefore undefined. +}); + +async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){ + // result is [1, 4, 9] + // With the help of bind we can attach a context to the iterator before + // passing it to async. Now the square function will be executed in its + // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent` + // will be as expected. +}); +``` + +## Download + +The source is available for download from +[GitHub](http://github.com/caolan/async). +Alternatively, you can install using Node Package Manager (`npm`): + + npm install async + +__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed + +## In the Browser + +So far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. + +Usage: + +```html + + +``` + +## Documentation + +### Collections + +* [`each`](#each) +* [`eachSeries`](#eachSeries) +* [`eachLimit`](#eachLimit) +* [`map`](#map) +* [`mapSeries`](#mapSeries) +* [`mapLimit`](#mapLimit) +* [`filter`](#filter) +* [`filterSeries`](#filterSeries) +* [`reject`](#reject) +* [`rejectSeries`](#rejectSeries) +* [`reduce`](#reduce) +* [`reduceRight`](#reduceRight) +* [`detect`](#detect) +* [`detectSeries`](#detectSeries) +* [`sortBy`](#sortBy) +* [`some`](#some) +* [`every`](#every) +* [`concat`](#concat) +* [`concatSeries`](#concatSeries) + +### Control Flow + +* [`series`](#seriestasks-callback) +* [`parallel`](#parallel) +* [`parallelLimit`](#parallellimittasks-limit-callback) +* [`whilst`](#whilst) +* [`doWhilst`](#doWhilst) +* [`until`](#until) +* [`doUntil`](#doUntil) +* [`forever`](#forever) +* [`waterfall`](#waterfall) +* [`compose`](#compose) +* [`seq`](#seq) +* [`applyEach`](#applyEach) +* [`applyEachSeries`](#applyEachSeries) +* [`queue`](#queue) +* [`priorityQueue`](#priorityQueue) +* [`cargo`](#cargo) +* [`auto`](#auto) +* [`retry`](#retry) +* [`iterator`](#iterator) +* [`apply`](#apply) +* [`nextTick`](#nextTick) +* [`times`](#times) +* [`timesSeries`](#timesSeries) + +### Utils + +* [`memoize`](#memoize) +* [`unmemoize`](#unmemoize) +* [`log`](#log) +* [`dir`](#dir) +* [`noConflict`](#noConflict) + + +## Collections + + + +### each(arr, iterator, callback) + +Applies the function `iterator` to each item in `arr`, in parallel. +The `iterator` is called with an item from the list, and a callback for when it +has finished. If the `iterator` passes an error to its `callback`, the main +`callback` (for the `each` function) is immediately called with the error. + +Note, that since this function applies `iterator` to each item in parallel, +there is no guarantee that the iterator functions will complete in order. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occured, the `callback` should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Examples__ + + +```js +// assuming openFiles is an array of file names and saveFile is a function +// to save the modified contents of that file: + +async.each(openFiles, saveFile, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +```js +// assuming openFiles is an array of file names + +async.each(openFiles, function( file, callback) { + + // Perform operation on file here. + console.log('Processing file ' + file); + + if( file.length > 32 ) { + console.log('This file name is too long'); + callback('File name too long'); + } else { + // Do work to process file here + console.log('File processed'); + callback(); + } +}, function(err){ + // if any of the file processing produced an error, err would equal that error + if( err ) { + // One of the iterations produced an error. + // All processing will now stop. + console.log('A file failed to process'); + } else { + console.log('All files have been processed successfully'); + } +}); +``` + +--------------------------------------- + + + +### eachSeries(arr, iterator, callback) + +The same as [`each`](#each), only `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +This means the `iterator` functions will complete in order. + + +--------------------------------------- + + + +### eachLimit(arr, limit, iterator, callback) + +The same as [`each`](#each), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items in `arr` are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err)` which must be called once it has + completed. If no error has occured, the callback should be run without + arguments or with an explicit `null` argument. +* `callback(err)` - A callback which is called when all `iterator` functions + have finished, or an error occurs. + +__Example__ + +```js +// Assume documents is an array of JSON objects and requestApi is a +// function that interacts with a rate-limited REST api. + +async.eachLimit(documents, 20, requestApi, function(err){ + // if any of the saves produced an error, err would equal that error +}); +``` + +--------------------------------------- + + +### map(arr, iterator, callback) + +Produces a new array of values by mapping each value in `arr` through +the `iterator` function. The `iterator` is called with an item from `arr` and a +callback for when it has finished processing. Each of these callback takes 2 arguments: +an `error`, and the transformed item from `arr`. If `iterator` passes an error to this +callback, the main `callback` (for the `map` function) is immediately called with the error. + +Note, that since this function applies the `iterator` to each item in parallel, +there is no guarantee that the `iterator` functions will complete in order. +However, the results array will be in the same order as the original `arr`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + functions have finished, or an error occurs. Results is an array of the + transformed items from the `arr`. + +__Example__ + +```js +async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + +### mapSeries(arr, iterator, callback) + +The same as [`map`](#map), only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +--------------------------------------- + + +### mapLimit(arr, limit, iterator, callback) + +The same as [`map`](#map), only no more than `limit` `iterator`s will be simultaneously +running at any time. + +Note that the items are not processed in batches, so there is no guarantee that +the first `limit` `iterator` functions will complete before any others are started. + +__Arguments__ + +* `arr` - An array to iterate over. +* `limit` - The maximum number of `iterator`s to run at any time. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, transformed)` which must be called once + it has completed with an error (which can be `null`) and a transformed item. +* `callback(err, results)` - A callback which is called when all `iterator` + calls have finished, or an error occurs. The result is an array of the + transformed items from the original `arr`. + +__Example__ + +```js +async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){ + // results is now an array of stats for each file +}); +``` + +--------------------------------------- + + + +### filter(arr, iterator, callback) + +__Alias:__ `select` + +Returns a new array of all the values in `arr` which pass an async truth test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. This operation is +performed in parallel, but the results array will be in the same order as the +original. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The `iterator` is passed a `callback(truthValue)`, which must be called with a + boolean argument once it has completed. +* `callback(results)` - A callback which is called after all the `iterator` + functions have finished. + +__Example__ + +```js +async.filter(['file1','file2','file3'], fs.exists, function(results){ + // results now equals an array of the existing files +}); +``` + +--------------------------------------- + + + +### filterSeries(arr, iterator, callback) + +__Alias:__ `selectSeries` + +The same as [`filter`](#filter) only the `iterator` is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + +--------------------------------------- + + +### reject(arr, iterator, callback) + +The opposite of [`filter`](#filter). Removes values that pass an `async` truth test. + +--------------------------------------- + + +### rejectSeries(arr, iterator, callback) + +The same as [`reject`](#reject), only the `iterator` is applied to each item in `arr` +in series. + + +--------------------------------------- + + +### reduce(arr, memo, iterator, callback) + +__Aliases:__ `inject`, `foldl` + +Reduces `arr` into a single value using an async `iterator` to return +each successive step. `memo` is the initial state of the reduction. +This function only operates in series. + +For performance reasons, it may make sense to split a call to this function into +a parallel map, and then use the normal `Array.prototype.reduce` on the results. +This function is for situations where each step in the reduction needs to be async; +if you can get the data before reducing it, then it's probably a good idea to do so. + +__Arguments__ + +* `arr` - An array to iterate over. +* `memo` - The initial state of the reduction. +* `iterator(memo, item, callback)` - A function applied to each item in the + array to produce the next step in the reduction. The `iterator` is passed a + `callback(err, reduction)` which accepts an optional error as its first + argument, and the state of the reduction as the second. If an error is + passed to the callback, the reduction is stopped and the main `callback` is + immediately called with the error. +* `callback(err, result)` - A callback which is called after all the `iterator` + functions have finished. Result is the reduced value. + +__Example__ + +```js +async.reduce([1,2,3], 0, function(memo, item, callback){ + // pointless async: + process.nextTick(function(){ + callback(null, memo + item) + }); +}, function(err, result){ + // result is now equal to the last value of memo, which is 6 +}); +``` + +--------------------------------------- + + +### reduceRight(arr, memo, iterator, callback) + +__Alias:__ `foldr` + +Same as [`reduce`](#reduce), only operates on `arr` in reverse order. + + +--------------------------------------- + + +### detect(arr, iterator, callback) + +Returns the first value in `arr` that passes an async truth test. The +`iterator` is applied in parallel, meaning the first iterator to return `true` will +fire the detect `callback` with that result. That means the result might not be +the first item in the original `arr` (in terms of order) that passes the test. + +If order within the original `arr` is important, then look at [`detectSeries`](#detectSeries). + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in `arr`. + The iterator is passed a `callback(truthValue)` which must be called with a + boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the `iterator` functions have finished. Result will be + the first item in the array that passes the truth test (iterator) or the + value `undefined` if none passed. + +__Example__ + +```js +async.detect(['file1','file2','file3'], fs.exists, function(result){ + // result now equals the first file in the list that exists +}); +``` + +--------------------------------------- + + +### detectSeries(arr, iterator, callback) + +The same as [`detect`](#detect), only the `iterator` is applied to each item in `arr` +in series. This means the result is always the first in the original `arr` (in +terms of array order) that passes the truth test. + + +--------------------------------------- + + +### sortBy(arr, iterator, callback) + +Sorts a list by the results of running each `arr` value through an async `iterator`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, sortValue)` which must be called once it + has completed with an error (which can be `null`) and a value to use as the sort + criteria. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is the items from + the original `arr` sorted by the values returned by the `iterator` calls. + +__Example__ + +```js +async.sortBy(['file1','file2','file3'], function(file, callback){ + fs.stat(file, function(err, stats){ + callback(err, stats.mtime); + }); +}, function(err, results){ + // results is now the original array of files sorted by + // modified date +}); +``` + +__Sort Order__ + +By modifying the callback parameter the sorting order can be influenced: + +```js +//ascending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x); +}, function(err,result){ + //result callback +} ); + +//descending order +async.sortBy([1,9,3,5], function(x, callback){ + callback(err, x*-1); //<- x*-1 instead of x, turns the order around +}, function(err,result){ + //result callback +} ); +``` + +--------------------------------------- + + +### some(arr, iterator, callback) + +__Alias:__ `any` + +Returns `true` if at least one element in the `arr` satisfies an async test. +_The callback for each iterator call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. Once any iterator +call returns `true`, the main `callback` is immediately called. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called as soon as any iterator returns + `true`, or after all the iterator functions have finished. Result will be + either `true` or `false` depending on the values of the async tests. + +__Example__ + +```js +async.some(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then at least one of the files exists +}); +``` + +--------------------------------------- + + +### every(arr, iterator, callback) + +__Alias:__ `all` + +Returns `true` if every element in `arr` satisfies an async test. +_The callback for each `iterator` call only accepts a single argument of `true` or +`false`; it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like `fs.exists`. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A truth test to apply to each item in the array + in parallel. The iterator is passed a callback(truthValue) which must be + called with a boolean argument once it has completed. +* `callback(result)` - A callback which is called after all the `iterator` + functions have finished. Result will be either `true` or `false` depending on + the values of the async tests. + +__Example__ + +```js +async.every(['file1','file2','file3'], fs.exists, function(result){ + // if result is true then every file exists +}); +``` + +--------------------------------------- + + +### concat(arr, iterator, callback) + +Applies `iterator` to each item in `arr`, concatenating the results. Returns the +concatenated list. The `iterator`s are called in parallel, and the results are +concatenated as they return. There is no guarantee that the results array will +be returned in the original order of `arr` passed to the `iterator` function. + +__Arguments__ + +* `arr` - An array to iterate over. +* `iterator(item, callback)` - A function to apply to each item in `arr`. + The iterator is passed a `callback(err, results)` which must be called once it + has completed with an error (which can be `null`) and an array of results. +* `callback(err, results)` - A callback which is called after all the `iterator` + functions have finished, or an error occurs. Results is an array containing + the concatenated results of the `iterator` function. + +__Example__ + +```js +async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){ + // files is now a list of filenames that exist in the 3 directories +}); +``` + +--------------------------------------- + + +### concatSeries(arr, iterator, callback) + +Same as [`concat`](#concat), but executes in series instead of parallel. + + +## Control Flow + + +### series(tasks, [callback]) + +Run the functions in the `tasks` array in series, each one running once the previous +function has completed. If any functions in the series pass an error to its +callback, no more functions are run, and `callback` is immediately called with the value of the error. +Otherwise, `callback` receives an array of results when `tasks` have completed. + +It is also possible to use an object instead of an array. Each property will be +run as a function, and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`series`](#series). + +**Note** that while many implementations preserve the order of object properties, the +[ECMAScript Language Specifcation](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) +explicitly states that + +> The mechanics and order of enumerating the properties is not specified. + +So if you rely on the order in which your series of functions are executed, and want +this to work on all platforms, consider using an array. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +__Example__ + +```js +async.series([ + function(callback){ + // do some stuff ... + callback(null, 'one'); + }, + function(callback){ + // do some more stuff ... + callback(null, 'two'); + } +], +// optional callback +function(err, results){ + // results is now equal to ['one', 'two'] +}); + + +// an example using an object instead of an array +async.series({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equal to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallel(tasks, [callback]) + +Run the `tasks` array of functions in parallel, without waiting until the previous +function has completed. If any of the functions pass an error to its +callback, the main `callback` is immediately called with the value of the error. +Once the `tasks` have completed, the results are passed to the final `callback` as an +array. + +It is also possible to use an object instead of an array. Each property will be +run as a function and the results will be passed to the final `callback` as an object +instead of an array. This can be a more readable way of handling results from +[`parallel`](#parallel). + + +__Arguments__ + +* `tasks` - An array or object containing functions to run. Each function is passed + a `callback(err, result)` which it must call on completion with an error `err` + (which can be `null`) and an optional `result` value. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the task callbacks. + +__Example__ + +```js +async.parallel([ + function(callback){ + setTimeout(function(){ + callback(null, 'one'); + }, 200); + }, + function(callback){ + setTimeout(function(){ + callback(null, 'two'); + }, 100); + } +], +// optional callback +function(err, results){ + // the results array will equal ['one','two'] even though + // the second function had a shorter timeout. +}); + + +// an example using an object instead of an array +async.parallel({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +}, +function(err, results) { + // results is now equals to: {one: 1, two: 2} +}); +``` + +--------------------------------------- + + +### parallelLimit(tasks, limit, [callback]) + +The same as [`parallel`](#parallel), only `tasks` are executed in parallel +with a maximum of `limit` tasks executing at any time. + +Note that the `tasks` are not executed in batches, so there is no guarantee that +the first `limit` tasks will complete before any others are started. + +__Arguments__ + +* `tasks` - An array or object containing functions to run, each function is passed + a `callback(err, result)` it must call on completion with an error `err` (which can + be `null`) and an optional `result` value. +* `limit` - The maximum number of `tasks` to run at any time. +* `callback(err, results)` - An optional callback to run once all the functions + have completed. This function gets a results array (or object) containing all + the result arguments passed to the `task` callbacks. + +--------------------------------------- + + +### whilst(test, fn, callback) + +Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +__Arguments__ + +* `test()` - synchronous truth test to perform before each execution of `fn`. +* `fn(callback)` - A function which is called each time `test` passes. The function is + passed a `callback(err)`, which must be called once it has completed with an + optional `err` argument. +* `callback(err)` - A callback which is called after the test fails and repeated + execution of `fn` has stopped. + +__Example__ + +```js +var count = 0; + +async.whilst( + function () { return count < 5; }, + function (callback) { + count++; + setTimeout(callback, 1000); + }, + function (err) { + // 5 seconds have passed + } +); +``` + +--------------------------------------- + + +### doWhilst(fn, test, callback) + +The post-check version of [`whilst`](#whilst). To reflect the difference in +the order of operations, the arguments `test` and `fn` are switched. + +`doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + +--------------------------------------- + + +### until(test, fn, callback) + +Repeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped, +or an error occurs. + +The inverse of [`whilst`](#whilst). + +--------------------------------------- + + +### doUntil(fn, test, callback) + +Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`. + +--------------------------------------- + + +### forever(fn, errback) + +Calls the asynchronous function `fn` with a callback parameter that allows it to +call itself again, in series, indefinitely. + +If an error is passed to the callback then `errback` is called with the +error, and execution stops, otherwise it will never be called. + +```js +async.forever( + function(next) { + // next is suitable for passing to things that need a callback(err [, whatever]); + // it will result in this function being called again. + }, + function(err) { + // if next is called with a value in its first parameter, it will appear + // in here as 'err', and execution will stop. + } +); +``` + +--------------------------------------- + + +### waterfall(tasks, [callback]) + +Runs the `tasks` array of functions in series, each passing their results to the next in +the array. However, if any of the `tasks` pass an error to their own callback, the +next function is not executed, and the main `callback` is immediately called with +the error. + +__Arguments__ + +* `tasks` - An array of functions to run, each function is passed a + `callback(err, result1, result2, ...)` it must call on completion. The first + argument is an error (which can be `null`) and any further arguments will be + passed as arguments in order to the next task. +* `callback(err, [results])` - An optional callback to run once all the functions + have completed. This will be passed the results of the last task's callback. + + + +__Example__ + +```js +async.waterfall([ + function(callback){ + callback(null, 'one', 'two'); + }, + function(arg1, arg2, callback){ + // arg1 now equals 'one' and arg2 now equals 'two' + callback(null, 'three'); + }, + function(arg1, callback){ + // arg1 now equals 'three' + callback(null, 'done'); + } +], function (err, result) { + // result now equals 'done' +}); +``` + +--------------------------------------- + +### compose(fn1, fn2...) + +Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions `f()`, `g()`, and `h()` would produce the result of +`f(g(h()))`, only this version uses callbacks to obtain the return values. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* `functions...` - the asynchronous functions to compose + + +__Example__ + +```js +function add1(n, callback) { + setTimeout(function () { + callback(null, n + 1); + }, 10); +} + +function mul3(n, callback) { + setTimeout(function () { + callback(null, n * 3); + }, 10); +} + +var add1mul3 = async.compose(mul3, add1); + +add1mul3(4, function (err, result) { + // result now equals 15 +}); +``` + +--------------------------------------- + +### seq(fn1, fn2...) + +Version of the compose function that is more natural to read. +Each following function consumes the return value of the latter function. + +Each function is executed with the `this` binding of the composed function. + +__Arguments__ + +* functions... - the asynchronous functions to compose + + +__Example__ + +```js +// Requires lodash (or underscore), express3 and dresende's orm2. +// Part of an app, that fetches cats of the logged user. +// This example uses `seq` function to avoid overnesting and error +// handling clutter. +app.get('/cats', function(request, response) { + function handleError(err, data, callback) { + if (err) { + console.error(err); + response.json({ status: 'error', message: err.message }); + } + else { + callback(data); + } + } + var User = request.models.User; + async.seq( + _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) + handleError, + function(user, fn) { + user.getCats(fn); // 'getCats' has signature (callback(err, data)) + }, + handleError, + function(cats) { + response.json({ status: 'ok', message: 'Cats found', data: cats }); + } + )(req.session.user_id); + } +}); +``` + +--------------------------------------- + +### applyEach(fns, args..., callback) + +Applies the provided arguments to each function in the array, calling +`callback` after all functions have completed. If you only provide the first +argument, then it will return a function which lets you pass in the +arguments as if it were a single function call. + +__Arguments__ + +* `fns` - the asynchronous functions to all call with the same arguments +* `args...` - any number of separate arguments to pass to the function +* `callback` - the final argument should be the callback, called when all + functions have completed processing + + +__Example__ + +```js +async.applyEach([enableSearch, updateSchema], 'bucket', callback); + +// partial application example: +async.each( + buckets, + async.applyEach([enableSearch, updateSchema]), + callback +); +``` + +--------------------------------------- + + +### applyEachSeries(arr, iterator, callback) + +The same as [`applyEach`](#applyEach) only the functions are applied in series. + +--------------------------------------- + + +### queue(worker, concurrency) + +Creates a `queue` object with the specified `concurrency`. Tasks added to the +`queue` are processed in parallel (up to the `concurrency` limit). If all +`worker`s are in progress, the task is queued until one becomes available. +Once a `worker` completes a `task`, that `task`'s callback is called. + +__Arguments__ + +* `worker(task, callback)` - An asynchronous function for processing a queued + task, which must call its `callback(err)` argument when finished, with an + optional `error` as an argument. +* `concurrency` - An `integer` for determining how many `worker` functions should be + run in parallel. + +__Queue objects__ + +The `queue` object returned by this function has the following properties and +methods: + +* `length()` - a function returning the number of items waiting to be processed. +* `started` - a function returning whether or not any items have been pushed and processed by the queue +* `running()` - a function returning the number of items currently being processed. +* `idle()` - a function returning false if there are items waiting or being processed, or true if not. +* `concurrency` - an integer for determining how many `worker` functions should be + run in parallel. This property can be changed after a `queue` is created to + alter the concurrency on-the-fly. +* `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once + the `worker` has finished processing the task. Instead of a single task, a `tasks` array + can be submitted. The respective callback is used for every task in the list. +* `unshift(task, [callback])` - add a new task to the front of the `queue`. +* `saturated` - a callback that is called when the `queue` length hits the `concurrency` limit, + and further tasks will be queued. +* `empty` - a callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`. +* `paused` - a boolean for determining whether the queue is in a paused state +* `pause()` - a function that pauses the processing of tasks until `resume()` is called. +* `resume()` - a function that resumes the processing of queued tasks when the queue is paused. +* `kill()` - a function that empties remaining tasks from the queue forcing it to go idle. + +__Example__ + +```js +// create a queue object with concurrency 2 + +var q = async.queue(function (task, callback) { + console.log('hello ' + task.name); + callback(); +}, 2); + + +// assign a callback +q.drain = function() { + console.log('all items have been processed'); +} + +// add some items to the queue + +q.push({name: 'foo'}, function (err) { + console.log('finished processing foo'); +}); +q.push({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); + +// add some items to the queue (batch-wise) + +q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) { + console.log('finished processing bar'); +}); + +// add some items to the front of the queue + +q.unshift({name: 'bar'}, function (err) { + console.log('finished processing bar'); +}); +``` + + +--------------------------------------- + + +### priorityQueue(worker, concurrency) + +The same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects: + +* `push(task, priority, [callback])` - `priority` should be a number. If an array of + `tasks` is given, all tasks will be assigned the same priority. +* The `unshift` method was removed. + +--------------------------------------- + + +### cargo(worker, [payload]) + +Creates a `cargo` object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the `payload` limit). If the +`worker` is in progress, the task is queued until it becomes available. Once +the `worker` has completed some tasks, each callback of those tasks is called. +Check out [this animation](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) for how `cargo` and `queue` work. + +While [queue](#queue) passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished. + +__Arguments__ + +* `worker(tasks, callback)` - An asynchronous function for processing an array of + queued tasks, which must call its `callback(err)` argument when finished, with + an optional `err` argument. +* `payload` - An optional `integer` for determining how many tasks should be + processed per round; if omitted, the default is unlimited. + +__Cargo objects__ + +The `cargo` object returned by this function has the following properties and +methods: + +* `length()` - A function returning the number of items waiting to be processed. +* `payload` - An `integer` for determining how many tasks should be + process per round. This property can be changed after a `cargo` is created to + alter the payload on-the-fly. +* `push(task, [callback])` - Adds `task` to the `queue`. The callback is called + once the `worker` has finished processing the task. Instead of a single task, an array of `tasks` + can be submitted. The respective callback is used for every task in the list. +* `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued. +* `empty` - A callback that is called when the last item from the `queue` is given to a `worker`. +* `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`. + +__Example__ + +```js +// create a cargo object with payload 2 + +var cargo = async.cargo(function (tasks, callback) { + for(var i=0; i +### auto(tasks, [callback]) + +Determines the best order for running the functions in `tasks`, based on their +requirements. Each function can optionally depend on other functions being completed +first, and each function is run as soon as its requirements are satisfied. + +If any of the functions pass an error to their callback, it will not +complete (so any other functions depending on it will not run), and the main +`callback` is immediately called with the error. Functions also receive an +object containing the results of functions which have completed so far. + +Note, all functions are called with a `results` object as a second argument, +so it is unsafe to pass functions in the `tasks` object which cannot handle the +extra argument. + +For example, this snippet of code: + +```js +async.auto({ + readData: async.apply(fs.readFile, 'data.txt', 'utf-8') +}, callback); +``` + +will have the effect of calling `readFile` with the results object as the last +argument, which will fail: + +```js +fs.readFile('data.txt', 'utf-8', cb, {}); +``` + +Instead, wrap the call to `readFile` in a function which does not forward the +`results` object: + +```js +async.auto({ + readData: function(cb, results){ + fs.readFile('data.txt', 'utf-8', cb); + } +}, callback); +``` + +__Arguments__ + +* `tasks` - An object. Each of its properties is either a function or an array of + requirements, with the function itself the last item in the array. The object's key + of a property serves as the name of the task defined by that property, + i.e. can be used when specifying requirements for other tasks. + The function receives two arguments: (1) a `callback(err, result)` which must be + called when finished, passing an `error` (which can be `null`) and the result of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions. +* `callback(err, results)` - An optional callback which is called when all the + tasks have been completed. It receives the `err` argument if any `tasks` + pass an error to their callback. Results are always returned; however, if + an error occurs, no further `tasks` will be performed, and the results + object will only contain partial results. + + +__Example__ + +```js +async.auto({ + get_data: function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + make_folder: function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + }, + write_file: ['get_data', 'make_folder', function(callback, results){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, 'filename'); + }], + email_link: ['write_file', function(callback, results){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + // results.write_file contains the filename returned by write_file. + callback(null, {'file':results.write_file, 'email':'user@example.com'}); + }] +}, function(err, results) { + console.log('err = ', err); + console.log('results = ', results); +}); +``` + +This is a fairly trivial example, but to do this using the basic parallel and +series functions would look like this: + +```js +async.parallel([ + function(callback){ + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + function(callback){ + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + } +], +function(err, results){ + async.series([ + function(callback){ + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + results.push('filename'); + callback(null); + }, + function(callback){ + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + callback(null, {'file':results.pop(), 'email':'user@example.com'}); + } + ]); +}); +``` + +For a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding +new tasks much easier (and the code more readable). + + +--------------------------------------- + + +### retry([times = 5], task, [callback]) + +Attempts to get a successful response from `task` no more than `times` times before +returning an error. If the task is successful, the `callback` will be passed the result +of the successfull task. If all attemps fail, the callback will be passed the error and +result (if any) of the final attempt. + +__Arguments__ + +* `times` - An integer indicating how many times to attempt the `task` before giving up. Defaults to 5. +* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)` + which must be called when finished, passing `err` (which can be `null`) and the `result` of + the function's execution, and (2) a `results` object, containing the results of + the previously executed functions (if nested inside another control flow). +* `callback(err, results)` - An optional callback which is called when the + task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`. + +The [`retry`](#retry) function can be used as a stand-alone control flow by passing a +callback, as shown below: + +```js +async.retry(3, apiMethod, function(err, result) { + // do something with the result +}); +``` + +It can also be embeded within other control flow functions to retry individual methods +that are not as reliable, like this: + +```js +async.auto({ + users: api.getUsers.bind(api), + payments: async.retry(3, api.getPayments.bind(api)) +}, function(err, results) { + // do something with the results +}); +``` + + +--------------------------------------- + + +### iterator(tasks) + +Creates an iterator function which calls the next function in the `tasks` array, +returning a continuation to call the next one after that. It's also possible to +“peek” at the next iterator with `iterator.next()`. + +This function is used internally by the `async` module, but can be useful when +you want to manually control the flow of functions in series. + +__Arguments__ + +* `tasks` - An array of functions to run. + +__Example__ + +```js +var iterator = async.iterator([ + function(){ sys.p('one'); }, + function(){ sys.p('two'); }, + function(){ sys.p('three'); } +]); + +node> var iterator2 = iterator(); +'one' +node> var iterator3 = iterator2(); +'two' +node> iterator3(); +'three' +node> var nextfn = iterator2.next(); +node> nextfn(); +'three' +``` + +--------------------------------------- + + +### apply(function, arguments..) + +Creates a continuation function with some arguments already applied. + +Useful as a shorthand when combined with other control flow functions. Any arguments +passed to the returned function are added to the arguments originally passed +to apply. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to automatically apply when the + continuation is called. + +__Example__ + +```js +// using apply + +async.parallel([ + async.apply(fs.writeFile, 'testfile1', 'test1'), + async.apply(fs.writeFile, 'testfile2', 'test2'), +]); + + +// the same process without using apply + +async.parallel([ + function(callback){ + fs.writeFile('testfile1', 'test1', callback); + }, + function(callback){ + fs.writeFile('testfile2', 'test2', callback); + } +]); +``` + +It's possible to pass any number of additional arguments when calling the +continuation: + +```js +node> var fn = async.apply(sys.puts, 'one'); +node> fn('two', 'three'); +one +two +three +``` + +--------------------------------------- + + +### nextTick(callback) + +Calls `callback` on a later loop around the event loop. In Node.js this just +calls `process.nextTick`; in the browser it falls back to `setImmediate(callback)` +if available, otherwise `setTimeout(callback, 0)`, which means other higher priority +events may precede the execution of `callback`. + +This is used internally for browser-compatibility purposes. + +__Arguments__ + +* `callback` - The function to call on a later loop around the event loop. + +__Example__ + +```js +var call_order = []; +async.nextTick(function(){ + call_order.push('two'); + // call_order now equals ['one','two'] +}); +call_order.push('one') +``` + + +### times(n, callback) + +Calls the `callback` function `n` times, and accumulates results in the same manner +you would use with [`map`](#map). + +__Arguments__ + +* `n` - The number of times to run the function. +* `callback` - The function to call `n` times. + +__Example__ + +```js +// Pretend this is some complicated async factory +var createUser = function(id, callback) { + callback(null, { + id: 'user' + id + }) +} +// generate 5 users +async.times(5, function(n, next){ + createUser(n, function(err, user) { + next(err, user) + }) +}, function(err, users) { + // we should now have 5 users +}); +``` + + +### timesSeries(n, callback) + +The same as [`times`](#times), only the iterator is applied to each item in `arr` in +series. The next `iterator` is only called once the current one has completed. +The results array will be in the same order as the original. + + +## Utils + + +### memoize(fn, [hasher]) + +Caches the results of an `async` function. When creating a hash to store function +results against, the callback is omitted from the hash and an optional hash +function can be used. + +The cache of results is exposed as the `memo` property of the function returned +by `memoize`. + +__Arguments__ + +* `fn` - The function to proxy and cache results from. +* `hasher` - Tn optional function for generating a custom hash for storing + results. It has all the arguments applied to it apart from the callback, and + must be synchronous. + +__Example__ + +```js +var slow_fn = function (name, callback) { + // do something + callback(null, result); +}; +var fn = async.memoize(slow_fn); + +// fn can now be used as if it were slow_fn +fn('some name', function () { + // callback +}); +``` + + +### unmemoize(fn) + +Undoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized +form. Handy for testing. + +__Arguments__ + +* `fn` - the memoized function + + +### log(function, arguments) + +Logs the result of an `async` function to the `console`. Only works in Node.js or +in browsers that support `console.log` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.log` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, 'hello ' + name); + }, 1000); +}; +``` +```js +node> async.log(hello, 'world'); +'hello world' +``` + +--------------------------------------- + + +### dir(function, arguments) + +Logs the result of an `async` function to the `console` using `console.dir` to +display the properties of the resulting object. Only works in Node.js or +in browsers that support `console.dir` and `console.error` (such as FF and Chrome). +If multiple arguments are returned from the async function, `console.dir` is +called on each argument in order. + +__Arguments__ + +* `function` - The function you want to eventually apply all arguments to. +* `arguments...` - Any number of arguments to apply to the function. + +__Example__ + +```js +var hello = function(name, callback){ + setTimeout(function(){ + callback(null, {hello: name}); + }, 1000); +}; +``` +```js +node> async.dir(hello, 'world'); +{hello: 'world'} +``` + +--------------------------------------- + + +### noConflict() + +Changes the value of `async` back to its original value, returning a reference to the +`async` object. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/component.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/component.json new file mode 100644 index 0000000..bbb0115 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/component.json @@ -0,0 +1,11 @@ +{ + "name": "async", + "repo": "caolan/async", + "description": "Higher-order functions and common patterns for asynchronous code", + "version": "0.1.23", + "keywords": [], + "dependencies": {}, + "development": {}, + "main": "lib/async.js", + "scripts": [ "lib/async.js" ] +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js new file mode 100755 index 0000000..01e8afc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js @@ -0,0 +1,1123 @@ +/*! + * async + * https://github.com/caolan/async + * + * Copyright 2010-2014 Caolan McMahon + * Released under the MIT license + */ +/*jshint onevar: false, indent:4 */ +/*global setImmediate: false, setTimeout: false, console: false */ +(function () { + + var async = {}; + + // global on the server, window in the browser + var root, previous_async; + + root = this; + if (root != null) { + previous_async = root.async; + } + + async.noConflict = function () { + root.async = previous_async; + return async; + }; + + function only_once(fn) { + var called = false; + return function() { + if (called) throw new Error("Callback was already called."); + called = true; + fn.apply(root, arguments); + } + } + + //// cross-browser compatiblity functions //// + + var _toString = Object.prototype.toString; + + var _isArray = Array.isArray || function (obj) { + return _toString.call(obj) === '[object Array]'; + }; + + var _each = 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 = []; + _each(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); + } + _each(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; + }; + + //// exported async module functions //// + + //// nextTick implementation with browser-compatible fallback //// + if (typeof process === 'undefined' || !(process.nextTick)) { + if (typeof setImmediate === 'function') { + async.nextTick = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + async.setImmediate = async.nextTick; + } + else { + async.nextTick = function (fn) { + setTimeout(fn, 0); + }; + async.setImmediate = async.nextTick; + } + } + else { + async.nextTick = process.nextTick; + if (typeof setImmediate !== 'undefined') { + async.setImmediate = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + } + else { + async.setImmediate = async.nextTick; + } + } + + async.each = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + _each(arr, function (x) { + iterator(x, only_once(done) ); + }); + function done(err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(); + } + } + } + }; + async.forEach = async.each; + + async.eachSeries = function (arr, iterator, callback) { + callback = callback || function () {}; + 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(); + }; + async.forEachSeries = async.eachSeries; + + async.eachLimit = function (arr, limit, iterator, callback) { + var fn = _eachLimit(limit); + fn.apply(null, [arr, iterator, callback]); + }; + async.forEachLimit = async.eachLimit; + + var _eachLimit = function (limit) { + + return function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length || limit <= 0) { + return callback(); + } + var completed = 0; + var started = 0; + var running = 0; + + (function replenish () { + if (completed >= arr.length) { + return callback(); + } + + while (running < limit && started < arr.length) { + started += 1; + running += 1; + iterator(arr[started - 1], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + running -= 1; + if (completed >= arr.length) { + callback(); + } + else { + replenish(); + } + } + }); + } + })(); + }; + }; + + + var doParallel = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.each].concat(args)); + }; + }; + var doParallelLimit = function(limit, fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [_eachLimit(limit)].concat(args)); + }; + }; + var doSeries = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.eachSeries].concat(args)); + }; + }; + + + var _asyncMap = function (eachfn, arr, iterator, callback) { + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + if (!callback) { + eachfn(arr, function (x, callback) { + iterator(x.value, function (err) { + callback(err); + }); + }); + } else { + var results = []; + 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); + async.mapLimit = function (arr, limit, iterator, callback) { + return _mapLimit(limit)(arr, iterator, callback); + }; + + var _mapLimit = function(limit) { + return doParallelLimit(limit, _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.eachSeries(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); + main_callback = function () {}; + } + else { + callback(); + } + }); + }, function (err) { + main_callback(); + }); + }; + async.detect = doParallel(_detect); + async.detectSeries = doSeries(_detect); + + async.some = function (arr, iterator, main_callback) { + async.each(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.each(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); + var remainingTasks = keys.length + if (!remainingTasks) { + return callback(); + } + + var results = {}; + + 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 () { + remainingTasks-- + _each(listeners.slice(0), function (fn) { + fn(); + }); + }; + + addListener(function () { + if (!remainingTasks) { + var theCallback = callback; + // prevent final callback from calling itself if it errors + callback = function () {}; + + theCallback(null, results); + } + }); + + _each(keys, function (k) { + var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]]; + var taskCallback = function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + if (err) { + var safeResults = {}; + _each(_keys(results), function(rkey) { + safeResults[rkey] = results[rkey]; + }); + safeResults[k] = args; + callback(err, safeResults); + // stop subsequent errors hitting callback multiple times + callback = function () {}; + } + else { + results[k] = args; + async.setImmediate(taskComplete); + } + }; + var requires = task.slice(0, Math.abs(task.length - 1)) || []; + var ready = function () { + return _reduce(requires, function (a, x) { + return (a && results.hasOwnProperty(x)); + }, true) && !results.hasOwnProperty(k); + }; + if (ready()) { + task[task.length - 1](taskCallback, results); + } + else { + var listener = function () { + if (ready()) { + removeListener(listener); + task[task.length - 1](taskCallback, results); + } + }; + addListener(listener); + } + }); + }; + + async.retry = function(times, task, callback) { + var DEFAULT_TIMES = 5; + var attempts = []; + // Use defaults if times not passed + if (typeof times === 'function') { + callback = task; + task = times; + times = DEFAULT_TIMES; + } + // Make sure times is a number + times = parseInt(times, 10) || DEFAULT_TIMES; + var wrappedTask = function(wrappedCallback, wrappedResults) { + var retryAttempt = function(task, finalAttempt) { + return function(seriesCallback) { + task(function(err, result){ + seriesCallback(!err || finalAttempt, {err: err, result: result}); + }, wrappedResults); + }; + }; + while (times) { + attempts.push(retryAttempt(task, !(times-=1))); + } + async.series(attempts, function(done, data){ + data = data[data.length - 1]; + (wrappedCallback || callback)(data.err, data.result); + }); + } + // If a callback is passed, run this as a controll flow + return callback ? wrappedTask() : wrappedTask + }; + + async.waterfall = function (tasks, callback) { + callback = callback || function () {}; + if (!_isArray(tasks)) { + var err = new Error('First argument to waterfall must be an array of functions'); + return callback(err); + } + if (!tasks.length) { + return callback(); + } + var wrapIterator = function (iterator) { + return function (err) { + if (err) { + callback.apply(null, arguments); + 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.setImmediate(function () { + iterator.apply(null, args); + }); + } + }; + }; + wrapIterator(async.iterator(tasks))(); + }; + + var _parallel = function(eachfn, tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + eachfn.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); + }); + } + }, callback); + } + else { + var results = {}; + eachfn.each(_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.parallel = function (tasks, callback) { + _parallel({ map: async.map, each: async.each }, tasks, callback); + }; + + async.parallelLimit = function(tasks, limit, callback) { + _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); + }; + + async.series = function (tasks, callback) { + callback = callback || function () {}; + if (_isArray(tasks)) { + 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); + }); + } + }, callback); + } + else { + var results = {}; + async.eachSeries(_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.doWhilst = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (test.apply(null, args)) { + async.doWhilst(iterator, test, 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.doUntil = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + var args = Array.prototype.slice.call(arguments, 1); + if (!test.apply(null, args)) { + async.doUntil(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.queue = function (worker, concurrency) { + if (concurrency === undefined) { + concurrency = 1; + } + function _insert(q, data, pos, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + callback: typeof callback === 'function' ? callback : null + }; + + if (pos) { + q.tasks.unshift(item); + } else { + q.tasks.push(item); + } + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + var workers = 0; + var q = { + tasks: [], + concurrency: concurrency, + saturated: null, + empty: null, + drain: null, + started: false, + paused: false, + push: function (data, callback) { + _insert(q, data, false, callback); + }, + kill: function () { + q.drain = null; + q.tasks = []; + }, + unshift: function (data, callback) { + _insert(q, data, true, callback); + }, + process: function () { + if (!q.paused && workers < q.concurrency && q.tasks.length) { + var task = q.tasks.shift(); + if (q.empty && q.tasks.length === 0) { + q.empty(); + } + workers += 1; + var next = function () { + workers -= 1; + if (task.callback) { + task.callback.apply(task, arguments); + } + if (q.drain && q.tasks.length + workers === 0) { + q.drain(); + } + q.process(); + }; + var cb = only_once(next); + worker(task.data, cb); + } + }, + length: function () { + return q.tasks.length; + }, + running: function () { + return workers; + }, + idle: function() { + return q.tasks.length + workers === 0; + }, + pause: function () { + if (q.paused === true) { return; } + q.paused = true; + q.process(); + }, + resume: function () { + if (q.paused === false) { return; } + q.paused = false; + q.process(); + } + }; + return q; + }; + + async.priorityQueue = function (worker, concurrency) { + + function _compareTasks(a, b){ + return a.priority - b.priority; + }; + + function _binarySearch(sequence, item, compare) { + var beg = -1, + end = sequence.length - 1; + while (beg < end) { + var mid = beg + ((end - beg + 1) >>> 1); + if (compare(item, sequence[mid]) >= 0) { + beg = mid; + } else { + end = mid - 1; + } + } + return beg; + } + + function _insert(q, data, priority, callback) { + if (!q.started){ + q.started = true; + } + if (!_isArray(data)) { + data = [data]; + } + if(data.length == 0) { + // call drain immediately if there are no tasks + return async.setImmediate(function() { + if (q.drain) { + q.drain(); + } + }); + } + _each(data, function(task) { + var item = { + data: task, + priority: priority, + callback: typeof callback === 'function' ? callback : null + }; + + q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item); + + if (q.saturated && q.tasks.length === q.concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + // Start with a normal queue + var q = async.queue(worker, concurrency); + + // Override push to accept second parameter representing priority + q.push = function (data, priority, callback) { + _insert(q, data, priority, callback); + }; + + // Remove unshift function + delete q.unshift; + + return q; + }; + + async.cargo = function (worker, payload) { + var working = false, + tasks = []; + + var cargo = { + tasks: tasks, + payload: payload, + saturated: null, + empty: null, + drain: null, + drained: true, + push: function (data, callback) { + if (!_isArray(data)) { + data = [data]; + } + _each(data, function(task) { + tasks.push({ + data: task, + callback: typeof callback === 'function' ? callback : null + }); + cargo.drained = false; + if (cargo.saturated && tasks.length === payload) { + cargo.saturated(); + } + }); + async.setImmediate(cargo.process); + }, + process: function process() { + if (working) return; + if (tasks.length === 0) { + if(cargo.drain && !cargo.drained) cargo.drain(); + cargo.drained = true; + return; + } + + var ts = typeof payload === 'number' + ? tasks.splice(0, payload) + : tasks.splice(0, tasks.length); + + var ds = _map(ts, function (task) { + return task.data; + }); + + if(cargo.empty) cargo.empty(); + working = true; + worker(ds, function () { + working = false; + + var args = arguments; + _each(ts, function (data) { + if (data.callback) { + data.callback.apply(null, args); + } + }); + + process(); + }); + }, + length: function () { + return tasks.length; + }, + running: function () { + return working; + } + }; + return cargo; + }; + + 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]) { + _each(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 = {}; + var queues = {}; + hasher = hasher || function (x) { + return x; + }; + var memoized = function () { + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + var key = hasher.apply(null, args); + if (key in memo) { + async.nextTick(function () { + callback.apply(null, memo[key]); + }); + } + else if (key in queues) { + queues[key].push(callback); + } + else { + queues[key] = [callback]; + fn.apply(null, args.concat([function () { + memo[key] = arguments; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, arguments); + } + }])); + } + }; + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + }; + + async.unmemoize = function (fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; + }; + + async.times = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.map(counter, iterator, callback); + }; + + async.timesSeries = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.mapSeries(counter, iterator, callback); + }; + + async.seq = function (/* functions... */) { + var fns = arguments; + return function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + async.reduce(fns, args, function (newargs, fn, cb) { + fn.apply(that, newargs.concat([function () { + var err = arguments[0]; + var nextargs = Array.prototype.slice.call(arguments, 1); + cb(err, nextargs); + }])) + }, + function (err, results) { + callback.apply(that, [err].concat(results)); + }); + }; + }; + + async.compose = function (/* functions... */) { + return async.seq.apply(null, Array.prototype.reverse.call(arguments)); + }; + + var _applyEach = function (eachfn, fns /*args...*/) { + var go = function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + return eachfn(fns, function (fn, cb) { + fn.apply(that, args.concat([cb])); + }, + callback); + }; + if (arguments.length > 2) { + var args = Array.prototype.slice.call(arguments, 2); + return go.apply(this, args); + } + else { + return go; + } + }; + async.applyEach = doParallel(_applyEach); + async.applyEachSeries = doSeries(_applyEach); + + async.forever = function (fn, callback) { + function next(err) { + if (err) { + if (callback) { + return callback(err); + } + throw err; + } + fn(next); + } + next(); + }; + + // Node.js + if (typeof module !== 'undefined' && module.exports) { + module.exports = async; + } + // AMD / RequireJS + else if (typeof define !== 'undefined' && define.amd) { + define([], function () { + return async; + }); + } + // included directly via '); + expect(encoded).to.equal('\\x3cscript\\x3ealert\\x281\\x29\\x3c\\x2fscript\\x3e'); + done(); + }); + + it('encodes \' characters', function (done) { + + var encoded = Hoek.escapeJavaScript('something(\'param\')'); + expect(encoded).to.equal('something\\x28\\x27param\\x27\\x29'); + done(); + }); + + it('encodes large unicode characters with the correct padding', function (done) { + + var encoded = Hoek.escapeJavaScript(String.fromCharCode(500) + String.fromCharCode(1000)); + expect(encoded).to.equal('\\u0500\\u1000'); + done(); + }); + + it('doesn\'t throw an exception when passed null', function (done) { + + var encoded = Hoek.escapeJavaScript(null); + expect(encoded).to.equal(''); + done(); + }); +}); + +describe('escapeHtml()', function () { + + it('encodes / characters', function (done) { + + var encoded = Hoek.escapeHtml(''); + expect(encoded).to.equal('<script>alert(1)</script>'); + done(); + }); + + it('encodes < and > as named characters', function (done) { + + var encoded = Hoek.escapeHtml(' +``` + +Or in node.js: + +``` +npm install node-uuid +``` + +```javascript +var uuid = require('node-uuid'); +``` + +Then create some ids ... + +```javascript +// Generate a v1 (time-based) id +uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' + +// Generate a v4 (random) id +uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1' +``` + +## API + +### uuid.v1([`options` [, `buffer` [, `offset`]]]) + +Generate and return a RFC4122 v1 (timestamp-based) UUID. + +* `options` - (Object) Optional uuid state to apply. Properties may include: + + * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1. + * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used. + * `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used. + * `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2. + +* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. +* `offset` - (Number) Starting index in `buffer` at which to begin writing. + +Returns `buffer`, if specified, otherwise the string form of the UUID + +Notes: + +1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.) + +Example: Generate string UUID with fully-specified options + +```javascript +uuid.v1({ + node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], + clockseq: 0x1234, + msecs: new Date('2011-11-01').getTime(), + nsecs: 5678 +}); // -> "710b962e-041c-11e1-9234-0123456789ab" +``` + +Example: In-place generation of two binary IDs + +```javascript +// Generate two ids in an array +var arr = new Array(32); // -> [] +uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15] +uuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15] + +// Optionally use uuid.unparse() to get stringify the ids +uuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115' +uuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115' +``` + +### uuid.v4([`options` [, `buffer` [, `offset`]]]) + +Generate and return a RFC4122 v4 UUID. + +* `options` - (Object) Optional uuid state to apply. Properties may include: + + * `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values + * `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values. + +* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. +* `offset` - (Number) Starting index in `buffer` at which to begin writing. + +Returns `buffer`, if specified, otherwise the string form of the UUID + +Example: Generate string UUID with fully-specified options + +```javascript +uuid.v4({ + random: [ + 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea, + 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36 + ] +}); +// -> "109156be-c4fb-41ea-b1b4-efe1671c5836" +``` + +Example: Generate two IDs in a single buffer + +```javascript +var buffer = new Array(32); // (or 'new Buffer' in node.js) +uuid.v4(null, buffer, 0); +uuid.v4(null, buffer, 16); +``` + +### uuid.parse(id[, buffer[, offset]]) +### uuid.unparse(buffer[, offset]) + +Parse and unparse UUIDs + + * `id` - (String) UUID(-like) string + * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used + * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0 + +Example parsing and unparsing a UUID string + +```javascript +var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> +var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10' +``` + +### uuid.noConflict() + +(Browsers only) Set `uuid` property back to it's previous value. + +Returns the node-uuid object. + +Example: + +```javascript +var myUuid = uuid.noConflict(); +myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' +``` + +## Deprecated APIs + +Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version. + +### uuid([format [, buffer [, offset]]]) + +uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary). + +### uuid.BufferClass + +The class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API. + +## Command Line Interface + +To use the executable, it's probably best to install this library globally. + +`npm install -g node-uuid` + +Usage: + +``` +USAGE: uuid [version] [options] + + +options: + +--help Display this message and exit +``` + +`version` must be an RFC4122 version that is supported by this library, which is currently version 1 and version 4 (denoted by "v1" and "v4", respectively). `version` defaults to version 4 when not supplied. + +### Examples + +``` +> uuid +3a91f950-dec8-4688-ba14-5b7bbfc7a563 +``` + +``` +> uuid v1 +9d0b43e0-7696-11e3-964b-250efa37a98e +``` + +``` +> uuid v4 +6790ac7c-24ac-4f98-8464-42f6d98a53ae +``` + +## Testing + +In node.js + +``` +npm test +``` + +In Browser + +``` +open test/test.html +``` + +### Benchmarking + +Requires node.js + +``` +npm install uuid uuid-js +node benchmark/benchmark.js +``` + +For a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark) + +For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance). + +## Release notes + +### 1.4.0 + +* Improved module context detection +* Removed public RNG functions + +### 1.3.2 + +* Improve tests and handling of v1() options (Issue #24) +* Expose RNG option to allow for perf testing with different generators + +### 1.3.0 + +* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)! +* Support for node.js crypto API +* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/README.md new file mode 100644 index 0000000..aaeb2ea --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/README.md @@ -0,0 +1,53 @@ +# node-uuid Benchmarks + +### Results + +To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark + +### Run them yourself + +node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`. + +To prepare and run the benchmark issue; + +``` +npm install uuid uuid-js +node benchmark/benchmark.js +``` + +You'll see an output like this one: + +``` +# v4 +nodeuuid.v4(): 854700 uuids/second +nodeuuid.v4('binary'): 788643 uuids/second +nodeuuid.v4('binary', buffer): 1336898 uuids/second +uuid(): 479386 uuids/second +uuid('binary'): 582072 uuids/second +uuidjs.create(4): 312304 uuids/second + +# v1 +nodeuuid.v1(): 938086 uuids/second +nodeuuid.v1('binary'): 683060 uuids/second +nodeuuid.v1('binary', buffer): 1644736 uuids/second +uuidjs.create(1): 190621 uuids/second +``` + +* The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library. +* The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK. + +If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file: + +``` +for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done; +``` + +If you're interested in how performance varies between different node versions, you can issue the above command multiple times. + +You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot: + +``` +(cd benchmark/ && ./bench.sh) +``` + +This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu new file mode 100644 index 0000000..a342fbb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu @@ -0,0 +1,174 @@ +#!/opt/local/bin/gnuplot -persist +# +# +# G N U P L O T +# Version 4.4 patchlevel 3 +# last modified March 2011 +# System: Darwin 10.8.0 +# +# Copyright (C) 1986-1993, 1998, 2004, 2007-2010 +# Thomas Williams, Colin Kelley and many others +# +# gnuplot home: http://www.gnuplot.info +# faq, bugs, etc: type "help seeking-assistance" +# immediate help: type "help" +# plot window: hit 'h' +set terminal postscript eps noenhanced defaultplex \ + leveldefault color colortext \ + solid linewidth 1.2 butt noclip \ + palfuncparam 2000,0.003 \ + "Helvetica" 14 +set output 'bench.eps' +unset clip points +set clip one +unset clip two +set bar 1.000000 front +set border 31 front linetype -1 linewidth 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set timefmt x "%d/%m/%y,%H:%M" +set timefmt y "%d/%m/%y,%H:%M" +set timefmt z "%d/%m/%y,%H:%M" +set timefmt x2 "%d/%m/%y,%H:%M" +set timefmt y2 "%d/%m/%y,%H:%M" +set timefmt cb "%d/%m/%y,%H:%M" +set boxwidth +set style fill empty border +set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1 +set style circle radius graph 0.02, first 0, 0 +set dummy x,y +set format x "% g" +set format y "% g" +set format x2 "% g" +set format y2 "% g" +set format z "% g" +set format cb "% g" +set angles radians +unset grid +set key title "" +set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox +set key noinvert samplen 4 spacing 1 width 0 height 0 +set key maxcolumns 2 maxrows 0 +unset label +unset arrow +set style increment default +unset style line +set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0 +unset style arrow +set style histogram clustered gap 2 title offset character 0, 0, 0 +unset logscale +set offsets graph 0.05, 0.15, 0, 0 +set pointsize 1.5 +set pointintervalbox 1 +set encoding default +unset polar +unset parametric +unset decimalsign +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +unset contour +set clabel '%8.3g' +set mapping cartesian +set datafile separator whitespace +unset hidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set style data points +set style function lines +set xzeroaxis linetype -2 linewidth 1.000 +set yzeroaxis linetype -2 linewidth 1.000 +set zzeroaxis linetype -2 linewidth 1.000 +set x2zeroaxis linetype -2 linewidth 1.000 +set y2zeroaxis linetype -2 linewidth 1.000 +set ticslevel 0.5 +set mxtics default +set mytics default +set mztics default +set mx2tics default +set my2tics default +set mcbtics default +set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set xtics norangelimit +set xtics () +set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set ytics autofreq norangelimit +set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0 +set ztics autofreq norangelimit +set nox2tics +set noy2tics +set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set cbtics autofreq norangelimit +set title "" +set title offset character 0, 0, 0 font "" norotate +set timestamp bottom +set timestamp "" +set timestamp offset character 0, 0, 0 font "" norotate +set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) +set autoscale rfixmin +set autoscale rfixmax +set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] ) +set autoscale tfixmin +set autoscale tfixmax +set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale ufixmin +set autoscale ufixmax +set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale vfixmin +set autoscale vfixmax +set xlabel "" +set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate +set x2label "" +set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate +set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] ) +set autoscale xfixmin +set autoscale xfixmax +set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] ) +set autoscale x2fixmin +set autoscale x2fixmax +set ylabel "" +set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set y2label "" +set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] ) +set autoscale yfixmin +set autoscale yfixmax +set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] ) +set autoscale y2fixmin +set autoscale y2fixmax +set zlabel "" +set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate +set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale zfixmin +set autoscale zfixmax +set cblabel "" +set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) +set autoscale cbfixmin +set autoscale cbfixmax +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set pm3d explicit at s +set pm3d scansautomatic +set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean +set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB +set palette rgbformulae 7, 5, 15 +set colorbox default +set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault +set loadpath +set fontpath +set fit noerrorvariables +GNUTERM = "aqua" +plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2 +# EOF diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.sh b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.sh new file mode 100755 index 0000000..d870a0c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/bench.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# for a given node version run: +# for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done; + +PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte') +FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es) +INDICES=(2 3 2 3 2 2 2 2 2) +VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " ) +TMPJOIN="tmp_join" +OUTPUT="bench_results.txt" + +for I in ${!FILES[*]}; do + F=${FILES[$I]} + P=${PATTERNS[$I]} + INDEX=${INDICES[$I]} + echo "version $F" > $F + for V in $VERSIONS; do + (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F + done + if [ $I == 0 ]; then + cat $F > $TMPJOIN + else + join $TMPJOIN $F > $OUTPUT + cp $OUTPUT $TMPJOIN + fi + rm $F +done + +rm $TMPJOIN + +gnuplot bench.gnu +convert -density 200 -resize 800x560 -flatten bench.eps bench.png +rm bench.eps diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c new file mode 100644 index 0000000..dbfc75f --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c @@ -0,0 +1,34 @@ +/* +Test performance of native C UUID generation + +To Compile: cc -luuid benchmark-native.c -o benchmark-native +*/ + +#include +#include +#include +#include + +int main() { + uuid_t myid; + char buf[36+1]; + int i; + struct timeval t; + double start, finish; + + gettimeofday(&t, NULL); + start = t.tv_sec + t.tv_usec/1e6; + + int n = 2e5; + for (i = 0; i < n; i++) { + uuid_generate(myid); + uuid_unparse(myid, buf); + } + + gettimeofday(&t, NULL); + finish = t.tv_sec + t.tv_usec/1e6; + double dur = finish - start; + + printf("%d uuids/sec", (int)(n/dur)); + return 0; +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js new file mode 100644 index 0000000..40e6efb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js @@ -0,0 +1,84 @@ +try { + var nodeuuid = require('../uuid'); +} catch (e) { + console.error('node-uuid require failed - skipping tests'); +} + +try { + var uuid = require('uuid'); +} catch (e) { + console.error('uuid require failed - skipping tests'); +} + +try { + var uuidjs = require('uuid-js'); +} catch (e) { + console.error('uuid-js require failed - skipping tests'); +} + +var N = 5e5; + +function rate(msg, t) { + console.log(msg + ': ' + + (N / (Date.now() - t) * 1e3 | 0) + + ' uuids/second'); +} + +console.log('# v4'); + +// node-uuid - string form +if (nodeuuid) { + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4(); + rate('nodeuuid.v4() - using node.js crypto RNG', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG}); + rate('nodeuuid.v4() - using Math.random() RNG', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary'); + rate('nodeuuid.v4(\'binary\')', t); + + var buffer = new nodeuuid.BufferClass(16); + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer); + rate('nodeuuid.v4(\'binary\', buffer)', t); +} + +// libuuid - string form +if (uuid) { + for (var i = 0, t = Date.now(); i < N; i++) uuid(); + rate('uuid()', t); + + for (var i = 0, t = Date.now(); i < N; i++) uuid('binary'); + rate('uuid(\'binary\')', t); +} + +// uuid-js - string form +if (uuidjs) { + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4); + rate('uuidjs.create(4)', t); +} + +// 140byte.es +for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)}); +rate('140byte.es_v4', t); + +console.log(''); +console.log('# v1'); + +// node-uuid - v1 string form +if (nodeuuid) { + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1(); + rate('nodeuuid.v1()', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary'); + rate('nodeuuid.v1(\'binary\')', t); + + var buffer = new nodeuuid.BufferClass(16); + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer); + rate('nodeuuid.v1(\'binary\', buffer)', t); +} + +// uuid-js - v1 string form +if (uuidjs) { + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1); + rate('uuidjs.create(1)', t); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bin/uuid b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bin/uuid new file mode 100755 index 0000000..f732e99 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bin/uuid @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +var path = require('path'); +var uuid = require(path.join(__dirname, '..')); + +var arg = process.argv[2]; + +if ('--help' === arg) { + console.log('\n USAGE: uuid [version] [options]\n\n'); + console.log(' options:\n'); + console.log(' --help Display this message and exit\n'); + process.exit(0); +} + +if (null == arg) { + console.log(uuid()); + process.exit(0); +} + +if ('v1' !== arg && 'v4' !== arg) { + console.error('Version must be RFC4122 version 1 or version 4, denoted as "v1" or "v4"'); + process.exit(1); +} + +console.log(uuid[arg]()); +process.exit(0); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bower.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bower.json new file mode 100644 index 0000000..1656dc8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/bower.json @@ -0,0 +1,23 @@ +{ + "name": "node-uuid", + "version": "1.4.3", + "homepage": "https://github.com/broofa/node-uuid", + "authors": [ + "Robert Kieffer " + ], + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", + "main": "uuid.js", + "keywords": [ + "uuid", + "gid", + "rfc4122" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/component.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/component.json new file mode 100644 index 0000000..149f84b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/component.json @@ -0,0 +1,18 @@ +{ + "name": "node-uuid", + "repo": "broofa/node-uuid", + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", + "version": "1.4.3", + "author": "Robert Kieffer ", + "contributors": [ + {"name": "Christoph Tavan ", "github": "https://github.com/ctavan"} + ], + "keywords": ["uuid", "guid", "rfc4122"], + "dependencies": {}, + "development": {}, + "main": "uuid.js", + "scripts": [ + "uuid.js" + ], + "license": "MIT" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/package.json new file mode 100644 index 0000000..4aa7504 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/package.json @@ -0,0 +1,65 @@ +{ + "name": "node-uuid", + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", + "url": "http://github.com/broofa/node-uuid", + "keywords": [ + "uuid", + "guid", + "rfc4122" + ], + "author": { + "name": "Robert Kieffer", + "email": "robert@broofa.com" + }, + "contributors": [ + { + "name": "Christoph Tavan", + "email": "dev@tavan.de" + } + ], + "bin": { + "uuid": "./bin/uuid" + }, + "scripts": { + "test": "node test/test.js" + }, + "lib": ".", + "main": "./uuid.js", + "repository": { + "type": "git", + "url": "git+https://github.com/broofa/node-uuid.git" + }, + "version": "1.4.3", + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/broofa/node-uuid/master/LICENSE.md" + } + ], + "gitHead": "886463c660a095dfebfa69603921a8d156fdb12c", + "bugs": { + "url": "https://github.com/broofa/node-uuid/issues" + }, + "homepage": "https://github.com/broofa/node-uuid", + "_id": "node-uuid@1.4.3", + "_shasum": "319bb7a56e7cb63f00b5c0cd7851cd4b4ddf1df9", + "_from": "node-uuid@>=1.4.0 <1.5.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "broofa", + "email": "robert@broofa.com" + }, + "maintainers": [ + { + "name": "broofa", + "email": "robert@broofa.com" + } + ], + "dist": { + "shasum": "319bb7a56e7cb63f00b5c0cd7851cd4b4ddf1df9", + "tarball": "http://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/compare_v1.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/compare_v1.js new file mode 100644 index 0000000..05af822 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/compare_v1.js @@ -0,0 +1,63 @@ +var assert = require('assert'), + nodeuuid = require('../uuid'), + uuidjs = require('uuid-js'), + libuuid = require('uuid').generate, + util = require('util'), + exec = require('child_process').exec, + os = require('os'); + +// On Mac Os X / macports there's only the ossp-uuid package that provides uuid +// On Linux there's uuid-runtime which provides uuidgen +var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t'; + +function compare(ids) { + console.log(ids); + for (var i = 0; i < ids.length; i++) { + var id = ids[i].split('-'); + id = [id[2], id[1], id[0]].join(''); + ids[i] = id; + } + var sorted = ([].concat(ids)).sort(); + + if (sorted.toString() !== ids.toString()) { + console.log('Warning: sorted !== ids'); + } else { + console.log('everything in order!'); + } +} + +// Test time order of v1 uuids +var ids = []; +while (ids.length < 10e3) ids.push(nodeuuid.v1()); + +var max = 10; +console.log('node-uuid:'); +ids = []; +for (var i = 0; i < max; i++) ids.push(nodeuuid.v1()); +compare(ids); + +console.log(''); +console.log('uuidjs:'); +ids = []; +for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString()); +compare(ids); + +console.log(''); +console.log('libuuid:'); +ids = []; +var count = 0; +var last = function() { + compare(ids); +} +var cb = function(err, stdout, stderr) { + ids.push(stdout.substring(0, stdout.length-1)); + count++; + if (count < max) { + return next(); + } + last(); +}; +var next = function() { + exec(uuidCmd, cb); +}; +next(); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.html b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.html new file mode 100644 index 0000000..d80326e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.html @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.js new file mode 100644 index 0000000..2469225 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/test/test.js @@ -0,0 +1,228 @@ +if (!this.uuid) { + // node.js + uuid = require('../uuid'); +} + +// +// x-platform log/assert shims +// + +function _log(msg, type) { + type = type || 'log'; + + if (typeof(document) != 'undefined') { + document.write('' + msg.replace(/\n/g, '') + ''); + } + if (typeof(console) != 'undefined') { + var color = { + log: '\033[39m', + warn: '\033[33m', + error: '\033[31m' + }; + console[type](color[type] + msg + color.log); + } +} + +function log(msg) {_log(msg, 'log');} +function warn(msg) {_log(msg, 'warn');} +function error(msg) {_log(msg, 'error');} + +function assert(res, msg) { + if (!res) { + error('FAIL: ' + msg); + } else { + log('Pass: ' + msg); + } +} + +// +// Unit tests +// + +// Verify ordering of v1 ids created with explicit times +var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00 + +function compare(name, ids) { + ids = ids.map(function(id) { + return id.split('-').reverse().join('-'); + }).sort(); + var sorted = ([].concat(ids)).sort(); + + assert(sorted.toString() == ids.toString(), name + ' have expected order'); +} + +// Verify ordering of v1 ids created using default behavior +compare('uuids with current time', [ + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1() +]); + +// Verify ordering of v1 ids created with explicit times +compare('uuids with time option', [ + uuid.v1({msecs: TIME - 10*3600*1000}), + uuid.v1({msecs: TIME - 1}), + uuid.v1({msecs: TIME}), + uuid.v1({msecs: TIME + 1}), + uuid.v1({msecs: TIME + 28*24*3600*1000}) +]); + +assert( + uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}), + 'IDs created at same msec are different' +); + +// Verify throw if too many ids created +var thrown = false; +try { + uuid.v1({msecs: TIME, nsecs: 10000}); +} catch (e) { + thrown = true; +} +assert(thrown, 'Exception thrown when > 10K ids created in 1 ms'); + +// Verify clock regression bumps clockseq +var uidt = uuid.v1({msecs: TIME}); +var uidtb = uuid.v1({msecs: TIME - 1}); +assert( + parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1, + 'Clock regression by msec increments the clockseq' +); + +// Verify clock regression bumps clockseq +var uidtn = uuid.v1({msecs: TIME, nsecs: 10}); +var uidtnb = uuid.v1({msecs: TIME, nsecs: 9}); +assert( + parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1, + 'Clock regression by nsec increments the clockseq' +); + +// Verify explicit options produce expected id +var id = uuid.v1({ + msecs: 1321651533573, + nsecs: 5432, + clockseq: 0x385c, + node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ] +}); +assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id'); + +// Verify adjacent ids across a msec boundary are 1 time unit apart +var u0 = uuid.v1({msecs: TIME, nsecs: 9999}); +var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0}); + +var before = u0.split('-')[0], after = u1.split('-')[0]; +var dt = parseInt(after, 16) - parseInt(before, 16); +assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart'); + +// +// Test parse/unparse +// + +id = '00112233445566778899aabbccddeeff'; +assert(uuid.unparse(uuid.parse(id.substr(0,10))) == + '00112233-4400-0000-0000-000000000000', 'Short parse'); +assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) == + '00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse'); + +// +// Perf tests +// + +var generators = { + v1: uuid.v1, + v4: uuid.v4 +}; + +var UUID_FORMAT = { + v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i, + v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i +}; + +var N = 1e4; + +// Get %'age an actual value differs from the ideal value +function divergence(actual, ideal) { + return Math.round(100*100*(actual - ideal)/ideal)/100; +} + +function rate(msg, t) { + log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second'); +} + +for (var version in generators) { + var counts = {}, max = 0; + var generator = generators[version]; + var format = UUID_FORMAT[version]; + + log('\nSanity check ' + N + ' ' + version + ' uuids'); + for (var i = 0, ok = 0; i < N; i++) { + id = generator(); + if (!format.test(id)) { + throw Error(id + ' is not a valid UUID string'); + } + + if (id != uuid.unparse(uuid.parse(id))) { + assert(fail, id + ' is not a valid id'); + } + + // Count digits for our randomness check + if (version == 'v4') { + var digits = id.replace(/-/g, '').split(''); + for (var j = digits.length-1; j >= 0; j--) { + var c = digits[j]; + max = Math.max(max, counts[c] = (counts[c] || 0) + 1); + } + } + } + + // Check randomness for v4 UUIDs + if (version == 'v4') { + // Limit that we get worried about randomness. (Purely empirical choice, this!) + var limit = 2*100*Math.sqrt(1/N); + + log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)'); + + for (var i = 0; i < 16; i++) { + var c = i.toString(16); + var bar = '', n = counts[c], p = Math.round(n/max*100|0); + + // 1-3,5-8, and D-F: 1:16 odds over 30 digits + var ideal = N*30/16; + if (i == 4) { + // 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1 + 30/16); + } else if (i >= 8 && i <= 11) { + // 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1/4 + 30/16); + } else { + // Otherwise: 1:16 odds on 30 digits + ideal = N*30/16; + } + var d = divergence(n, ideal); + + // Draw bar using UTF squares (just for grins) + var s = n/max*50 | 0; + while (s--) bar += '='; + + assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)'); + } + } +} + +// Perf tests +for (var version in generators) { + log('\nPerformance testing ' + version + ' UUIDs'); + var generator = generators[version]; + var buf = new uuid.BufferClass(16); + + for (var i = 0, t = Date.now(); i < N; i++) generator(); + rate('uuid.' + version + '()', t); + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary'); + rate('uuid.' + version + '(\'binary\')', t); + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf); + rate('uuid.' + version + '(\'binary\', buffer)', t); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/uuid.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/uuid.js new file mode 100644 index 0000000..0a61769 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/uuid.js @@ -0,0 +1,247 @@ +// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php + +(function() { + var _global = this; + + // Unique ID creation requires a high quality random # generator. We feature + // detect to determine the best RNG source, normalizing to a function that + // returns 128-bits of randomness, since that's what's usually required + var _rng; + + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html + // + // Moderately fast, high quality + if (typeof(_global.require) == 'function') { + try { + var _rb = _global.require('crypto').randomBytes; + _rng = _rb && function() {return _rb(16);}; + } catch(e) {} + } + + if (!_rng && _global.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + _rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; + } + + if (!_rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + _rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; + } + + // Buffer class to use + var BufferClass = typeof(_global.Buffer) == 'function' ? _global.Buffer : Array; + + // Maps for number <-> hex string conversion + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } + + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; + } + + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; + } + + // **`v1()` - Generate time-based UUID** + // + // Inspired by https://github.com/LiosK/UUID.js + // and http://docs.python.org/library/uuid.html + + // random #'s we need to init node and clockseq + var _seedBytes = _rng(); + + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] + ]; + + // Per 4.2.2, randomize (14 bit) clockseq + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + + // Previous uuid creation time + var _lastMSecs = 0, _lastNSecs = 0; + + // See https://github.com/broofa/node-uuid for API details + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq != null ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs != null ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq == null) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); + } + + // **`v4()` - Generate random UUID** + + // See https://github.com/broofa/node-uuid for API details + function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new BufferClass(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); + } + + // Export public API + var uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + uuid.BufferClass = BufferClass; + + if (typeof(module) != 'undefined' && module.exports) { + // Publish as node.js module + module.exports = uuid; + } else if (typeof define === 'function' && define.amd) { + // Publish as AMD module + define(function() {return uuid;}); + + + } else { + // Publish as global (in browsers) + var _previousRoot = _global.uuid; + + // **`noConflict()` - (browser only) to reset global 'uuid' var** + uuid.noConflict = function() { + _global.uuid = _previousRoot; + return uuid; + }; + + _global.uuid = uuid; + } +}).call(this); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/LICENSE new file mode 100644 index 0000000..a4a9aee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/README.md new file mode 100644 index 0000000..34c4a85 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/README.md @@ -0,0 +1,4 @@ +oauth-sign +========== + +OAuth 1 signing. Formerly a vendor lib in mikeal/request, now a standalone module. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/index.js new file mode 100644 index 0000000..63b418c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/index.js @@ -0,0 +1,131 @@ +var crypto = require('crypto') + , qs = require('querystring') + ; + +function sha1 (key, body) { + return crypto.createHmac('sha1', key).update(body).digest('base64') +} + +function rsa (key, body) { + return crypto.createSign("RSA-SHA1").update(body).sign(key, 'base64'); +} + +function rfc3986 (str) { + return encodeURIComponent(str) + .replace(/!/g,'%21') + .replace(/\*/g,'%2A') + .replace(/\(/g,'%28') + .replace(/\)/g,'%29') + .replace(/'/g,'%27') + ; +} + +// Maps object to bi-dimensional array +// Converts { foo: 'A', bar: [ 'b', 'B' ]} to +// [ ['foo', 'A'], ['bar', 'b'], ['bar', 'B'] ] +function map (obj) { + var key, val, arr = [] + for (key in obj) { + val = obj[key] + if (Array.isArray(val)) + for (var i = 0; i < val.length; i++) + arr.push([key, val[i]]) + else + arr.push([key, val]) + } + return arr +} + +// Compare function for sort +function compare (a, b) { + return a > b ? 1 : a < b ? -1 : 0 +} + +function generateBase (httpMethod, base_uri, params) { + // adapted from https://dev.twitter.com/docs/auth/oauth and + // https://dev.twitter.com/docs/auth/creating-signature + + // Parameter normalization + // http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2 + var normalized = map(params) + // 1. First, the name and value of each parameter are encoded + .map(function (p) { + return [ rfc3986(p[0]), rfc3986(p[1] || '') ] + }) + // 2. The parameters are sorted by name, using ascending byte value + // ordering. If two or more parameters share the same name, they + // are sorted by their value. + .sort(function (a, b) { + return compare(a[0], b[0]) || compare(a[1], b[1]) + }) + // 3. The name of each parameter is concatenated to its corresponding + // value using an "=" character (ASCII code 61) as a separator, even + // if the value is empty. + .map(function (p) { return p.join('=') }) + // 4. The sorted name/value pairs are concatenated together into a + // single string by using an "&" character (ASCII code 38) as + // separator. + .join('&') + + var base = [ + rfc3986(httpMethod ? httpMethod.toUpperCase() : 'GET'), + rfc3986(base_uri), + rfc3986(normalized) + ].join('&') + + return base +} + +function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret) { + var base = generateBase(httpMethod, base_uri, params) + var key = [ + consumer_secret || '', + token_secret || '' + ].map(rfc3986).join('&') + + return sha1(key, base) +} + +function rsasign (httpMethod, base_uri, params, private_key, token_secret) { + var base = generateBase(httpMethod, base_uri, params) + var key = private_key || '' + + return rsa(key, base) +} + +function plaintext (consumer_secret, token_secret) { + var key = [ + consumer_secret || '', + token_secret || '' + ].map(rfc3986).join('&') + + return key +} + +function sign (signMethod, httpMethod, base_uri, params, consumer_secret, token_secret) { + var method + var skipArgs = 1 + + switch (signMethod) { + case 'RSA-SHA1': + method = rsasign + break + case 'HMAC-SHA1': + method = hmacsign + break + case 'PLAINTEXT': + method = plaintext + skipArgs = 4 + break + default: + throw new Error("Signature method not supported: " + signMethod) + } + + return method.apply(null, [].slice.call(arguments, skipArgs)) +} + +exports.hmacsign = hmacsign +exports.rsasign = rsasign +exports.plaintext = plaintext +exports.sign = sign +exports.rfc3986 = rfc3986 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/package.json new file mode 100644 index 0000000..02895e4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/package.json @@ -0,0 +1,53 @@ +{ + "author": { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com", + "url": "http://www.futurealoof.com" + }, + "name": "oauth-sign", + "description": "OAuth 1 signing. Formerly a vendor lib in mikeal/request, now a standalone module.", + "version": "0.6.0", + "repository": { + "url": "git+https://github.com/mikeal/oauth-sign.git" + }, + "main": "index.js", + "dependencies": {}, + "devDependencies": {}, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "scripts": { + "test": "node test.js" + }, + "gitHead": "f1b5d7714712ab7eec485cca9d18ae95db58aa6b", + "bugs": { + "url": "https://github.com/mikeal/oauth-sign/issues" + }, + "homepage": "https://github.com/mikeal/oauth-sign", + "_id": "oauth-sign@0.6.0", + "_shasum": "7dbeae44f6ca454e1f168451d630746735813ce3", + "_from": "oauth-sign@>=0.6.0 <0.7.0", + "_npmVersion": "1.4.14", + "_npmUser": { + "name": "nylen", + "email": "jnylen@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + { + "name": "nylen", + "email": "jnylen@gmail.com" + } + ], + "dist": { + "shasum": "7dbeae44f6ca454e1f168451d630746735813ce3", + "tarball": "http://registry.npmjs.org/oauth-sign/-/oauth-sign-0.6.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.6.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/test.js new file mode 100644 index 0000000..aea800b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/oauth-sign/test.js @@ -0,0 +1,74 @@ +var oauth = require('./index') + , hmacsign = oauth.hmacsign + , assert = require('assert') + , qs = require('querystring') + ; + +// Tests from Twitter documentation https://dev.twitter.com/docs/auth/oauth + +var reqsign = hmacsign('POST', 'https://api.twitter.com/oauth/request_token', + { oauth_callback: 'http://localhost:3005/the_dance/process_callback?service_provider_id=11' + , oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g' + , oauth_nonce: 'QP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk' + , oauth_signature_method: 'HMAC-SHA1' + , oauth_timestamp: '1272323042' + , oauth_version: '1.0' + }, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98") + +console.log(reqsign) +console.log('8wUi7m5HFQy76nowoCThusfgB+Q=') +assert.equal(reqsign, '8wUi7m5HFQy76nowoCThusfgB+Q=') + +var accsign = hmacsign('POST', 'https://api.twitter.com/oauth/access_token', + { oauth_consumer_key: 'GDdmIQH6jhtmLUypg82g' + , oauth_nonce: '9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8' + , oauth_signature_method: 'HMAC-SHA1' + , oauth_token: '8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc' + , oauth_timestamp: '1272323047' + , oauth_verifier: 'pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY' + , oauth_version: '1.0' + }, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA") + +console.log(accsign) +console.log('PUw/dHA4fnlJYM6RhXk5IU/0fCc=') +assert.equal(accsign, 'PUw/dHA4fnlJYM6RhXk5IU/0fCc=') + +var upsign = hmacsign('POST', 'http://api.twitter.com/1/statuses/update.json', + { oauth_consumer_key: "GDdmIQH6jhtmLUypg82g" + , oauth_nonce: "oElnnMTQIZvqvlfXM56aBLAf5noGD0AQR3Fmi7Q6Y" + , oauth_signature_method: "HMAC-SHA1" + , oauth_token: "819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw" + , oauth_timestamp: "1272325550" + , oauth_version: "1.0" + , status: 'setting up my twitter 私のさえずりを設定する' + }, "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98", "J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA") + +console.log(upsign) +console.log('yOahq5m0YjDDjfjxHaXEsW9D+X0=') +assert.equal(upsign, 'yOahq5m0YjDDjfjxHaXEsW9D+X0=') + +// example in rfc5849 +var params = qs.parse('b5=%3D%253D&a3=a&c%40=&a2=r%20b' + '&' + 'c2&a3=2+q') +params.oauth_consumer_key = '9djdj82h48djs9d2' +params.oauth_token = 'kkk9d7dh3k39sjv7' +params.oauth_nonce = '7d8f3e4a' +params.oauth_signature_method = 'HMAC-SHA1' +params.oauth_timestamp = '137131201' + +var rfc5849sign = hmacsign('POST', 'http://example.com/request', + params, "j49sk3j29djd", "dh893hdasih9") + +console.log(rfc5849sign) +console.log('r6/TJjbCOr97/+UU0NsvSne7s5g=') +assert.equal(rfc5849sign, 'r6/TJjbCOr97/+UU0NsvSne7s5g=') + + +// PLAINTEXT + +var plainSign = oauth.sign('PLAINTEXT', 'GET', 'http://dummy.com', {}, 'consumer_secret', 'token_secret') +console.log(plainSign) +assert.equal(plainSign, 'consumer_secret&token_secret') + +plainSign = oauth.plaintext('consumer_secret', 'token_secret') +console.log(plainSign) +assert.equal(plainSign, 'consumer_secret&token_secret') diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintignore @@ -0,0 +1 @@ +node_modules diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintrc new file mode 100644 index 0000000..997b3f7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.jshintrc @@ -0,0 +1,10 @@ +{ + "node": true, + + "curly": true, + "latedef": true, + "quotmark": true, + "undef": true, + "unused": true, + "trailing": true +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.npmignore new file mode 100644 index 0000000..7e1574d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.npmignore @@ -0,0 +1,18 @@ +.idea +*.iml +npm-debug.log +dump.rdb +node_modules +results.tap +results.xml +npm-shrinkwrap.json +config.json +.DS_Store +*/.DS_Store +*/*/.DS_Store +._* +*/._* +*/*/._* +coverage.* +lib-cov +complexity.md diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.travis.yml new file mode 100644 index 0000000..f502178 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.travis.yml @@ -0,0 +1,6 @@ +language: node_js + +node_js: + - 0.10 + - 0.12 + - iojs diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CHANGELOG.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CHANGELOG.md new file mode 100644 index 0000000..f5ee8b4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CHANGELOG.md @@ -0,0 +1,68 @@ + +## [**2.3.3**](https://github.com/hapijs/qs/issues?milestone=18&state=open) +- [**#59**](https://github.com/hapijs/qs/issues/59) make sure array indexes are >= 0, closes #57 +- [**#58**](https://github.com/hapijs/qs/issues/58) make qs usable for browser loader + +## [**2.3.2**](https://github.com/hapijs/qs/issues?milestone=17&state=closed) +- [**#55**](https://github.com/hapijs/qs/issues/55) allow merging a string into an object + +## [**2.3.1**](https://github.com/hapijs/qs/issues?milestone=16&state=closed) +- [**#52**](https://github.com/hapijs/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError". + +## [**2.3.0**](https://github.com/hapijs/qs/issues?milestone=15&state=closed) +- [**#50**](https://github.com/hapijs/qs/issues/50) add option to omit array indices, closes #46 + +## [**2.2.5**](https://github.com/hapijs/qs/issues?milestone=14&state=closed) +- [**#39**](https://github.com/hapijs/qs/issues/39) Is there an alternative to Buffer.isBuffer? +- [**#49**](https://github.com/hapijs/qs/issues/49) refactor utils.merge, fixes #45 +- [**#41**](https://github.com/hapijs/qs/issues/41) avoid browserifying Buffer, for #39 + +## [**2.2.4**](https://github.com/hapijs/qs/issues?milestone=13&state=closed) +- [**#38**](https://github.com/hapijs/qs/issues/38) how to handle object keys beginning with a number + +## [**2.2.3**](https://github.com/hapijs/qs/issues?milestone=12&state=closed) +- [**#37**](https://github.com/hapijs/qs/issues/37) parser discards first empty value in array +- [**#36**](https://github.com/hapijs/qs/issues/36) Update to lab 4.x + +## [**2.2.2**](https://github.com/hapijs/qs/issues?milestone=11&state=closed) +- [**#33**](https://github.com/hapijs/qs/issues/33) Error when plain object in a value +- [**#34**](https://github.com/hapijs/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty +- [**#24**](https://github.com/hapijs/qs/issues/24) Changelog? Semver? + +## [**2.2.1**](https://github.com/hapijs/qs/issues?milestone=10&state=closed) +- [**#32**](https://github.com/hapijs/qs/issues/32) account for circular references properly, closes #31 +- [**#31**](https://github.com/hapijs/qs/issues/31) qs.parse stackoverflow on circular objects + +## [**2.2.0**](https://github.com/hapijs/qs/issues?milestone=9&state=closed) +- [**#26**](https://github.com/hapijs/qs/issues/26) Don't use Buffer global if it's not present +- [**#30**](https://github.com/hapijs/qs/issues/30) Bug when merging non-object values into arrays +- [**#29**](https://github.com/hapijs/qs/issues/29) Don't call Utils.clone at the top of Utils.merge +- [**#23**](https://github.com/hapijs/qs/issues/23) Ability to not limit parameters? + +## [**2.1.0**](https://github.com/hapijs/qs/issues?milestone=8&state=closed) +- [**#22**](https://github.com/hapijs/qs/issues/22) Enable using a RegExp as delimiter + +## [**2.0.0**](https://github.com/hapijs/qs/issues?milestone=7&state=closed) +- [**#18**](https://github.com/hapijs/qs/issues/18) Why is there arrayLimit? +- [**#20**](https://github.com/hapijs/qs/issues/20) Configurable parametersLimit +- [**#21**](https://github.com/hapijs/qs/issues/21) make all limits optional, for #18, for #20 + +## [**1.2.2**](https://github.com/hapijs/qs/issues?milestone=6&state=closed) +- [**#19**](https://github.com/hapijs/qs/issues/19) Don't overwrite null values + +## [**1.2.1**](https://github.com/hapijs/qs/issues?milestone=5&state=closed) +- [**#16**](https://github.com/hapijs/qs/issues/16) ignore non-string delimiters +- [**#15**](https://github.com/hapijs/qs/issues/15) Close code block + +## [**1.2.0**](https://github.com/hapijs/qs/issues?milestone=4&state=closed) +- [**#12**](https://github.com/hapijs/qs/issues/12) Add optional delim argument +- [**#13**](https://github.com/hapijs/qs/issues/13) fix #11: flattened keys in array are now correctly parsed + +## [**1.1.0**](https://github.com/hapijs/qs/issues?milestone=3&state=closed) +- [**#7**](https://github.com/hapijs/qs/issues/7) Empty values of a POST array disappear after being submitted +- [**#9**](https://github.com/hapijs/qs/issues/9) Should not omit equals signs (=) when value is null +- [**#6**](https://github.com/hapijs/qs/issues/6) Minor grammar fix in README + +## [**1.0.2**](https://github.com/hapijs/qs/issues?milestone=2&state=closed) +- [**#5**](https://github.com/hapijs/qs/issues/5) array holes incorrectly copied into object on large index + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CONTRIBUTING.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CONTRIBUTING.md new file mode 100644 index 0000000..8928361 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CONTRIBUTING.md @@ -0,0 +1 @@ +Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/LICENSE new file mode 100755 index 0000000..d456948 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2014 Nathan LaFreniere and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of any contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND 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. + + * * * + +The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/Makefile b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/Makefile new file mode 100644 index 0000000..31cc899 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/Makefile @@ -0,0 +1,8 @@ +test: + @node node_modules/lab/bin/lab -a code -L +test-cov: + @node node_modules/lab/bin/lab -a code -t 100 -L +test-cov-html: + @node node_modules/lab/bin/lab -a code -L -r html -o coverage.html + +.PHONY: test test-cov test-cov-html diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/README.md new file mode 100755 index 0000000..2d7e7f5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/README.md @@ -0,0 +1,233 @@ +# qs + +A querystring parsing and stringifying library with some added security. + +[](http://travis-ci.org/hapijs/qs) + +Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf) + +The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring). + +## Usage + +```javascript +var Qs = require('qs'); + +var obj = Qs.parse('a=c'); // { a: 'c' } +var str = Qs.stringify(obj); // 'a=c' +``` + +### Parsing Objects + +```javascript +Qs.parse(string, [options]); +``` + +**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`. +For example, the string `'foo[bar]=baz'` converts to: + +```javascript +{ + foo: { + bar: 'baz' + } +} +``` + +URI encoded strings work too: + +```javascript +Qs.parse('a%5Bb%5D=c'); +// { a: { b: 'c' } } +``` + +You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`: + +```javascript +{ + foo: { + bar: { + baz: 'foobarbaz' + } + } +} +``` + +By default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like +`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be: + +```javascript +{ + a: { + b: { + c: { + d: { + e: { + f: { + '[g][h][i]': 'j' + } + } + } + } + } + } +} +``` + +This depth can be overridden by passing a `depth` option to `Qs.parse(string, [options])`: + +```javascript +Qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 }); +// { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } } +``` + +The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number. + +For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option: + +```javascript +Qs.parse('a=b&c=d', { parameterLimit: 1 }); +// { a: 'b' } +``` + +An optional delimiter can also be passed: + +```javascript +Qs.parse('a=b;c=d', { delimiter: ';' }); +// { a: 'b', c: 'd' } +``` + +Delimiters can be a regular expression too: + +```javascript +Qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); +// { a: 'b', c: 'd', e: 'f' } +``` + +### Parsing Arrays + +**qs** can also parse arrays using a similar `[]` notation: + +```javascript +Qs.parse('a[]=b&a[]=c'); +// { a: ['b', 'c'] } +``` + +You may specify an index as well: + +```javascript +Qs.parse('a[1]=c&a[0]=b'); +// { a: ['b', 'c'] } +``` + +Note that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number +to create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving +their order: + +```javascript +Qs.parse('a[1]=b&a[15]=c'); +// { a: ['b', 'c'] } +``` + +Note that an empty string is also a value, and will be preserved: + +```javascript +Qs.parse('a[]=&a[]=b'); +// { a: ['', 'b'] } +Qs.parse('a[0]=b&a[1]=&a[2]=c'); +// { a: ['b', '', 'c'] } +``` + +**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will +instead be converted to an object with the index as the key: + +```javascript +Qs.parse('a[100]=b'); +// { a: { '100': 'b' } } +``` + +This limit can be overridden by passing an `arrayLimit` option: + +```javascript +Qs.parse('a[1]=b', { arrayLimit: 0 }); +// { a: { '1': 'b' } } +``` + +To disable array parsing entirely, set `arrayLimit` to `-1`. + +If you mix notations, **qs** will merge the two items into an object: + +```javascript +Qs.parse('a[0]=b&a[b]=c'); +// { a: { '0': 'b', b: 'c' } } +``` + +You can also create arrays of objects: + +```javascript +Qs.parse('a[][b]=c'); +// { a: [{ b: 'c' }] } +``` + +### Stringifying + +```javascript +Qs.stringify(object, [options]); +``` + +When stringifying, **qs** always URI encodes output. Objects are stringified as you would expect: + +```javascript +Qs.stringify({ a: 'b' }); +// 'a=b' +Qs.stringify({ a: { b: 'c' } }); +// 'a%5Bb%5D=c' +``` + +Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage. + +When arrays are stringified, by default they are given explicit indices: + +```javascript +Qs.stringify({ a: ['b', 'c', 'd'] }); +// 'a[0]=b&a[1]=c&a[2]=d' +``` + +You may override this by setting the `indices` option to `false`: + +```javascript +Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }); +// 'a=b&a=c&a=d' +``` + +You may use the `arrayFormat` option to specify the format of the output array + +```javascript +Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) +// 'a[0]=b&a[1]=c' +Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) +// 'a[]=b&a[]=c' +Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) +// 'a=b&a=c' +``` + +Empty strings and null values will omit the value, but the equals sign (=) remains in place: + +```javascript +Qs.stringify({ a: '' }); +// 'a=' +``` + +Properties that are set to `undefined` will be omitted entirely: + +```javascript +Qs.stringify({ a: null, b: undefined }); +// 'a=' +``` + +The delimiter may be overridden with stringify as well: + +```javascript +Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }); +// 'a=b;c=d' +``` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/index.js new file mode 100644 index 0000000..2291cd8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/'); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/index.js new file mode 100755 index 0000000..0e09493 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/index.js @@ -0,0 +1,15 @@ +// Load modules + +var Stringify = require('./stringify'); +var Parse = require('./parse'); + + +// Declare internals + +var internals = {}; + + +module.exports = { + stringify: Stringify, + parse: Parse +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/parse.js new file mode 100755 index 0000000..55a0613 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/parse.js @@ -0,0 +1,161 @@ +// Load modules + +var Utils = require('./utils'); + + +// Declare internals + +var internals = { + delimiter: '&', + depth: 5, + arrayLimit: 20, + parameterLimit: 1000 +}; + + +internals.parseValues = function (str, options) { + + var obj = {}; + var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); + + for (var i = 0, il = parts.length; i < il; ++i) { + var part = parts[i]; + var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; + + if (pos === -1) { + obj[Utils.decode(part)] = ''; + } + else { + var key = Utils.decode(part.slice(0, pos)); + var val = Utils.decode(part.slice(pos + 1)); + + if (Object.prototype.hasOwnProperty(key)) { + continue; + } + + if (!obj.hasOwnProperty(key)) { + obj[key] = val; + } + else { + obj[key] = [].concat(obj[key]).concat(val); + } + } + } + + return obj; +}; + + +internals.parseObject = function (chain, val, options) { + + if (!chain.length) { + return val; + } + + var root = chain.shift(); + + var obj = {}; + if (root === '[]') { + obj = []; + obj = obj.concat(internals.parseObject(chain, val, options)); + } + else { + var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; + var index = parseInt(cleanRoot, 10); + var indexString = '' + index; + if (!isNaN(index) && + root !== cleanRoot && + indexString === cleanRoot && + index >= 0 && + index <= options.arrayLimit) { + + obj = []; + obj[index] = internals.parseObject(chain, val, options); + } + else { + obj[cleanRoot] = internals.parseObject(chain, val, options); + } + } + + return obj; +}; + + +internals.parseKeys = function (key, val, options) { + + if (!key) { + return; + } + + // The regex chunks + + var parent = /^([^\[\]]*)/; + var child = /(\[[^\[\]]*\])/g; + + // Get the parent + + var segment = parent.exec(key); + + // Don't allow them to overwrite object prototype properties + + if (Object.prototype.hasOwnProperty(segment[1])) { + return; + } + + // Stash the parent if it exists + + var keys = []; + if (segment[1]) { + keys.push(segment[1]); + } + + // Loop through children appending to the array until we hit depth + + var i = 0; + while ((segment = child.exec(key)) !== null && i < options.depth) { + + ++i; + if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + keys.push(segment[1]); + } + } + + // If there's a remainder, just add whatever is left + + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } + + return internals.parseObject(keys, val, options); +}; + + +module.exports = function (str, options) { + + if (str === '' || + str === null || + typeof str === 'undefined') { + + return {}; + } + + options = options || {}; + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; + + var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str; + var obj = {}; + + // Iterate over the keys and setup the new object + + var keys = Object.keys(tempObj); + for (var i = 0, il = keys.length; i < il; ++i) { + var key = keys[i]; + var newObj = internals.parseKeys(key, tempObj[key], options); + obj = Utils.merge(obj, newObj); + } + + return Utils.compact(obj); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/stringify.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/stringify.js new file mode 100755 index 0000000..3ce6cc1 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/stringify.js @@ -0,0 +1,97 @@ +// Load modules + +var Utils = require('./utils'); + + +// Declare internals + +var internals = { + delimiter: '&', + arrayPrefixGenerators: { + brackets: function (prefix, key) { + return prefix + '[]'; + }, + indices: function (prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function (prefix, key) { + return prefix; + } + } +}; + + +internals.stringify = function (obj, prefix, generateArrayPrefix) { + + if (Utils.isBuffer(obj)) { + obj = obj.toString(); + } + else if (obj instanceof Date) { + obj = obj.toISOString(); + } + else if (obj === null) { + obj = ''; + } + + if (typeof obj === 'string' || + typeof obj === 'number' || + typeof obj === 'boolean') { + + return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys = Object.keys(obj); + for (var i = 0, il = objKeys.length; i < il; ++i) { + var key = objKeys[i]; + if (Array.isArray(obj)) { + values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix)); + } + else { + values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix)); + } + } + + return values; +}; + + +module.exports = function (obj, options) { + + options = options || {}; + var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; + + var keys = []; + + if (typeof obj !== 'object' || + obj === null) { + + return ''; + } + + var arrayFormat; + if (options.arrayFormat in internals.arrayPrefixGenerators) { + arrayFormat = options.arrayFormat; + } + else if ('indices' in options) { + arrayFormat = options.indices ? 'indices' : 'repeat'; + } + else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat]; + + var objKeys = Object.keys(obj); + for (var i = 0, il = objKeys.length; i < il; ++i) { + var key = objKeys[i]; + keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix)); + } + + return keys.join(delimiter); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/utils.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/utils.js new file mode 100755 index 0000000..5240bd5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/utils.js @@ -0,0 +1,132 @@ +// Load modules + + +// Declare internals + +var internals = {}; + + +exports.arrayToObject = function (source) { + + var obj = {}; + for (var i = 0, il = source.length; i < il; ++i) { + if (typeof source[i] !== 'undefined') { + + obj[i] = source[i]; + } + } + + return obj; +}; + + +exports.merge = function (target, source) { + + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (Array.isArray(target)) { + target.push(source); + } + else { + target[source] = true; + } + + return target; + } + + if (typeof target !== 'object') { + target = [target].concat(source); + return target; + } + + if (Array.isArray(target) && + !Array.isArray(source)) { + + target = exports.arrayToObject(target); + } + + var keys = Object.keys(source); + for (var k = 0, kl = keys.length; k < kl; ++k) { + var key = keys[k]; + var value = source[key]; + + if (!target[key]) { + target[key] = value; + } + else { + target[key] = exports.merge(target[key], value); + } + } + + return target; +}; + + +exports.decode = function (str) { + + try { + return decodeURIComponent(str.replace(/\+/g, ' ')); + } catch (e) { + return str; + } +}; + + +exports.compact = function (obj, refs) { + + if (typeof obj !== 'object' || + obj === null) { + + return obj; + } + + refs = refs || []; + var lookup = refs.indexOf(obj); + if (lookup !== -1) { + return refs[lookup]; + } + + refs.push(obj); + + if (Array.isArray(obj)) { + var compacted = []; + + for (var i = 0, il = obj.length; i < il; ++i) { + if (typeof obj[i] !== 'undefined') { + compacted.push(obj[i]); + } + } + + return compacted; + } + + var keys = Object.keys(obj); + for (i = 0, il = keys.length; i < il; ++i) { + var key = keys[i]; + obj[key] = exports.compact(obj[key], refs); + } + + return obj; +}; + + +exports.isRegExp = function (obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + + +exports.isBuffer = function (obj) { + + if (obj === null || + typeof obj === 'undefined') { + + return false; + } + + return !!(obj.constructor && + obj.constructor.isBuffer && + obj.constructor.isBuffer(obj)); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/package.json new file mode 100644 index 0000000..f8c8647 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/package.json @@ -0,0 +1,59 @@ +{ + "name": "qs", + "version": "2.4.1", + "description": "A querystring parser that supports nesting and arrays, with a depth limit", + "homepage": "https://github.com/hapijs/qs", + "main": "index.js", + "dependencies": {}, + "devDependencies": { + "code": "1.x.x", + "lab": "5.x.x" + }, + "scripts": { + "test": "make test-cov" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hapijs/qs.git" + }, + "keywords": [ + "querystring", + "qs" + ], + "licenses": [ + { + "type": "BSD", + "url": "http://github.com/hapijs/qs/raw/master/LICENSE" + } + ], + "gitHead": "58c6540418954867822c1af3e45fb4c26708b07e", + "bugs": { + "url": "https://github.com/hapijs/qs/issues" + }, + "_id": "qs@2.4.1", + "_shasum": "68cbaea971013426a80c1404fad6b1a6b1175245", + "_from": "qs@>=2.4.0 <2.5.0", + "_npmVersion": "2.6.1", + "_nodeVersion": "0.10.36", + "_npmUser": { + "name": "nlf", + "email": "quitlahok@gmail.com" + }, + "maintainers": [ + { + "name": "nlf", + "email": "quitlahok@gmail.com" + }, + { + "name": "hueniverse", + "email": "eran@hueniverse.com" + } + ], + "dist": { + "shasum": "68cbaea971013426a80c1404fad6b1a6b1175245", + "tarball": "http://registry.npmjs.org/qs/-/qs-2.4.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/qs/-/qs-2.4.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/parse.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/parse.js new file mode 100755 index 0000000..f06788a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/parse.js @@ -0,0 +1,413 @@ +/* eslint no-extend-native:0 */ +// Load modules + +var Code = require('code'); +var Lab = require('lab'); +var Qs = require('../'); + + +// Declare internals + +var internals = {}; + + +// Test shortcuts + +var lab = exports.lab = Lab.script(); +var expect = Code.expect; +var describe = lab.experiment; +var it = lab.test; + + +describe('parse()', function () { + + it('parses a simple string', function (done) { + + expect(Qs.parse('0=foo')).to.deep.equal({ '0': 'foo' }); + expect(Qs.parse('foo=c++')).to.deep.equal({ foo: 'c ' }); + expect(Qs.parse('a[>=]=23')).to.deep.equal({ a: { '>=': '23' } }); + expect(Qs.parse('a[<=>]==23')).to.deep.equal({ a: { '<=>': '=23' } }); + expect(Qs.parse('a[==]=23')).to.deep.equal({ a: { '==': '23' } }); + expect(Qs.parse('foo')).to.deep.equal({ foo: '' }); + expect(Qs.parse('foo=bar')).to.deep.equal({ foo: 'bar' }); + expect(Qs.parse(' foo = bar = baz ')).to.deep.equal({ ' foo ': ' bar = baz ' }); + expect(Qs.parse('foo=bar=baz')).to.deep.equal({ foo: 'bar=baz' }); + expect(Qs.parse('foo=bar&bar=baz')).to.deep.equal({ foo: 'bar', bar: 'baz' }); + expect(Qs.parse('foo=bar&baz')).to.deep.equal({ foo: 'bar', baz: '' }); + expect(Qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World')).to.deep.equal({ + cht: 'p3', + chd: 't:60,40', + chs: '250x100', + chl: 'Hello|World' + }); + done(); + }); + + it('parses a single nested string', function (done) { + + expect(Qs.parse('a[b]=c')).to.deep.equal({ a: { b: 'c' } }); + done(); + }); + + it('parses a double nested string', function (done) { + + expect(Qs.parse('a[b][c]=d')).to.deep.equal({ a: { b: { c: 'd' } } }); + done(); + }); + + it('defaults to a depth of 5', function (done) { + + expect(Qs.parse('a[b][c][d][e][f][g][h]=i')).to.deep.equal({ a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } }); + done(); + }); + + it('only parses one level when depth = 1', function (done) { + + expect(Qs.parse('a[b][c]=d', { depth: 1 })).to.deep.equal({ a: { b: { '[c]': 'd' } } }); + expect(Qs.parse('a[b][c][d]=e', { depth: 1 })).to.deep.equal({ a: { b: { '[c][d]': 'e' } } }); + done(); + }); + + it('parses a simple array', function (done) { + + expect(Qs.parse('a=b&a=c')).to.deep.equal({ a: ['b', 'c'] }); + done(); + }); + + it('parses an explicit array', function (done) { + + expect(Qs.parse('a[]=b')).to.deep.equal({ a: ['b'] }); + expect(Qs.parse('a[]=b&a[]=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a[]=b&a[]=c&a[]=d')).to.deep.equal({ a: ['b', 'c', 'd'] }); + done(); + }); + + it('parses a mix of simple and explicit arrays', function (done) { + + expect(Qs.parse('a=b&a[]=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a[]=b&a=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a[0]=b&a=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a=b&a[0]=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a[1]=b&a=c')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a=b&a[1]=c')).to.deep.equal({ a: ['b', 'c'] }); + done(); + }); + + it('parses a nested array', function (done) { + + expect(Qs.parse('a[b][]=c&a[b][]=d')).to.deep.equal({ a: { b: ['c', 'd'] } }); + expect(Qs.parse('a[>=]=25')).to.deep.equal({ a: { '>=': '25' } }); + done(); + }); + + it('allows to specify array indices', function (done) { + + expect(Qs.parse('a[1]=c&a[0]=b&a[2]=d')).to.deep.equal({ a: ['b', 'c', 'd'] }); + expect(Qs.parse('a[1]=c&a[0]=b')).to.deep.equal({ a: ['b', 'c'] }); + expect(Qs.parse('a[1]=c')).to.deep.equal({ a: ['c'] }); + done(); + }); + + it('limits specific array indices to 20', function (done) { + + expect(Qs.parse('a[20]=a')).to.deep.equal({ a: ['a'] }); + expect(Qs.parse('a[21]=a')).to.deep.equal({ a: { '21': 'a' } }); + done(); + }); + + it('supports keys that begin with a number', function (done) { + + expect(Qs.parse('a[12b]=c')).to.deep.equal({ a: { '12b': 'c' } }); + done(); + }); + + it('supports encoded = signs', function (done) { + + expect(Qs.parse('he%3Dllo=th%3Dere')).to.deep.equal({ 'he=llo': 'th=ere' }); + done(); + }); + + it('is ok with url encoded strings', function (done) { + + expect(Qs.parse('a[b%20c]=d')).to.deep.equal({ a: { 'b c': 'd' } }); + expect(Qs.parse('a[b]=c%20d')).to.deep.equal({ a: { b: 'c d' } }); + done(); + }); + + it('allows brackets in the value', function (done) { + + expect(Qs.parse('pets=["tobi"]')).to.deep.equal({ pets: '["tobi"]' }); + expect(Qs.parse('operators=[">=", "<="]')).to.deep.equal({ operators: '[">=", "<="]' }); + done(); + }); + + it('allows empty values', function (done) { + + expect(Qs.parse('')).to.deep.equal({}); + expect(Qs.parse(null)).to.deep.equal({}); + expect(Qs.parse(undefined)).to.deep.equal({}); + done(); + }); + + it('transforms arrays to objects', function (done) { + + expect(Qs.parse('foo[0]=bar&foo[bad]=baz')).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } }); + expect(Qs.parse('foo[bad]=baz&foo[0]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); + expect(Qs.parse('foo[bad]=baz&foo[]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); + expect(Qs.parse('foo[]=bar&foo[bad]=baz')).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } }); + expect(Qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); + expect(Qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb')).to.deep.equal({foo: [ {a: 'a', b: 'b'}, {a: 'aa', b: 'bb'} ]}); + done(); + }); + + it('can add keys to objects', function (done) { + + expect(Qs.parse('a[b]=c&a=d')).to.deep.equal({ a: { b: 'c', d: true } }); + done(); + }); + + it('correctly prunes undefined values when converting an array to an object', function (done) { + + expect(Qs.parse('a[2]=b&a[99999999]=c')).to.deep.equal({ a: { '2': 'b', '99999999': 'c' } }); + done(); + }); + + it('supports malformed uri characters', function (done) { + + expect(Qs.parse('{%:%}')).to.deep.equal({ '{%:%}': '' }); + expect(Qs.parse('foo=%:%}')).to.deep.equal({ foo: '%:%}' }); + done(); + }); + + it('doesn\'t produce empty keys', function (done) { + + expect(Qs.parse('_r=1&')).to.deep.equal({ '_r': '1' }); + done(); + }); + + it('cannot override prototypes', function (done) { + + var obj = Qs.parse('hasOwnProperty=bad&toString=bad&bad[toString]=bad&constructor=bad'); + expect(typeof obj.toString).to.equal('function'); + expect(typeof obj.bad.toString).to.equal('function'); + expect(typeof obj.constructor).to.equal('function'); + done(); + }); + + it('cannot access Object prototype', function (done) { + + Qs.parse('constructor[prototype][bad]=bad'); + Qs.parse('bad[constructor][prototype][bad]=bad'); + expect(typeof Object.prototype.bad).to.equal('undefined'); + done(); + }); + + it('parses arrays of objects', function (done) { + + expect(Qs.parse('a[][b]=c')).to.deep.equal({ a: [{ b: 'c' }] }); + expect(Qs.parse('a[0][b]=c')).to.deep.equal({ a: [{ b: 'c' }] }); + done(); + }); + + it('allows for empty strings in arrays', function (done) { + + expect(Qs.parse('a[]=b&a[]=&a[]=c')).to.deep.equal({ a: ['b', '', 'c'] }); + expect(Qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]=')).to.deep.equal({ a: ['b', '', 'c', ''] }); + expect(Qs.parse('a[]=&a[]=b&a[]=c')).to.deep.equal({ a: ['', 'b', 'c'] }); + done(); + }); + + it('compacts sparse arrays', function (done) { + + expect(Qs.parse('a[10]=1&a[2]=2')).to.deep.equal({ a: ['2', '1'] }); + done(); + }); + + it('parses semi-parsed strings', function (done) { + + expect(Qs.parse({ 'a[b]': 'c' })).to.deep.equal({ a: { b: 'c' } }); + expect(Qs.parse({ 'a[b]': 'c', 'a[d]': 'e' })).to.deep.equal({ a: { b: 'c', d: 'e' } }); + done(); + }); + + it('parses buffers correctly', function (done) { + + var b = new Buffer('test'); + expect(Qs.parse({ a: b })).to.deep.equal({ a: b }); + done(); + }); + + it('continues parsing when no parent is found', function (done) { + + expect(Qs.parse('[]&a=b')).to.deep.equal({ '0': '', a: 'b' }); + expect(Qs.parse('[foo]=bar')).to.deep.equal({ foo: 'bar' }); + done(); + }); + + it('does not error when parsing a very long array', function (done) { + + var str = 'a[]=a'; + while (Buffer.byteLength(str) < 128 * 1024) { + str += '&' + str; + } + + expect(function () { + + Qs.parse(str); + }).to.not.throw(); + + done(); + }); + + it('should not throw when a native prototype has an enumerable property', { parallel: false }, function (done) { + + Object.prototype.crash = ''; + Array.prototype.crash = ''; + expect(Qs.parse.bind(null, 'a=b')).to.not.throw(); + expect(Qs.parse('a=b')).to.deep.equal({ a: 'b' }); + expect(Qs.parse.bind(null, 'a[][b]=c')).to.not.throw(); + expect(Qs.parse('a[][b]=c')).to.deep.equal({ a: [{ b: 'c' }] }); + delete Object.prototype.crash; + delete Array.prototype.crash; + done(); + }); + + it('parses a string with an alternative string delimiter', function (done) { + + expect(Qs.parse('a=b;c=d', { delimiter: ';' })).to.deep.equal({ a: 'b', c: 'd' }); + done(); + }); + + it('parses a string with an alternative RegExp delimiter', function (done) { + + expect(Qs.parse('a=b; c=d', { delimiter: /[;,] */ })).to.deep.equal({ a: 'b', c: 'd' }); + done(); + }); + + it('does not use non-splittable objects as delimiters', function (done) { + + expect(Qs.parse('a=b&c=d', { delimiter: true })).to.deep.equal({ a: 'b', c: 'd' }); + done(); + }); + + it('allows overriding parameter limit', function (done) { + + expect(Qs.parse('a=b&c=d', { parameterLimit: 1 })).to.deep.equal({ a: 'b' }); + done(); + }); + + it('allows setting the parameter limit to Infinity', function (done) { + + expect(Qs.parse('a=b&c=d', { parameterLimit: Infinity })).to.deep.equal({ a: 'b', c: 'd' }); + done(); + }); + + it('allows overriding array limit', function (done) { + + expect(Qs.parse('a[0]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '0': 'b' } }); + expect(Qs.parse('a[-1]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '-1': 'b' } }); + expect(Qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 })).to.deep.equal({ a: { '0': 'b', '1': 'c' } }); + done(); + }); + + it('parses an object', function (done) { + + var input = { + 'user[name]': {'pop[bob]': 3}, + 'user[email]': null + }; + + var expected = { + 'user': { + 'name': {'pop[bob]': 3}, + 'email': null + } + }; + + var result = Qs.parse(input); + + expect(result).to.deep.equal(expected); + done(); + }); + + it('parses an object and not child values', function (done) { + + var input = { + 'user[name]': {'pop[bob]': { 'test': 3 }}, + 'user[email]': null + }; + + var expected = { + 'user': { + 'name': {'pop[bob]': { 'test': 3 }}, + 'email': null + } + }; + + var result = Qs.parse(input); + + expect(result).to.deep.equal(expected); + done(); + }); + + it('does not blow up when Buffer global is missing', function (done) { + + var tempBuffer = global.Buffer; + delete global.Buffer; + var result = Qs.parse('a=b&c=d'); + global.Buffer = tempBuffer; + expect(result).to.deep.equal({ a: 'b', c: 'd' }); + done(); + }); + + it('does not crash when using invalid dot notation', function (done) { + + expect(Qs.parse('roomInfoList[0].childrenAges[0]=15&roomInfoList[0].numberOfAdults=2')).to.deep.equal({ roomInfoList: [['15', '2']] }); + done(); + }); + + it('does not crash when parsing circular references', function (done) { + + var a = {}; + a.b = a; + + var parsed; + + expect(function () { + + parsed = Qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a }); + }).to.not.throw(); + + expect(parsed).to.contain('foo'); + expect(parsed.foo).to.contain('bar', 'baz'); + expect(parsed.foo.bar).to.equal('baz'); + expect(parsed.foo.baz).to.deep.equal(a); + done(); + }); + + it('parses plain objects correctly', function (done) { + + var a = Object.create(null); + a.b = 'c'; + + expect(Qs.parse(a)).to.deep.equal({ b: 'c' }); + var result = Qs.parse({ a: a }); + expect(result).to.contain('a'); + expect(result.a).to.deep.equal(a); + done(); + }); + + it('parses dates correctly', function (done) { + + var now = new Date(); + expect(Qs.parse({ a: now })).to.deep.equal({ a: now }); + done(); + }); + + it('parses regular expressions correctly', function (done) { + + var re = /^test$/; + expect(Qs.parse({ a: re })).to.deep.equal({ a: re }); + done(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/stringify.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/stringify.js new file mode 100755 index 0000000..7bdec32 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/stringify.js @@ -0,0 +1,209 @@ +/* eslint no-extend-native:0 */ +// Load modules + +var Code = require('code'); +var Lab = require('lab'); +var Qs = require('../'); + + +// Declare internals + +var internals = {}; + + +// Test shortcuts + +var lab = exports.lab = Lab.script(); +var expect = Code.expect; +var describe = lab.experiment; +var it = lab.test; + + +describe('stringify()', function () { + + it('stringifies a querystring object', function (done) { + + expect(Qs.stringify({ a: 'b' })).to.equal('a=b'); + expect(Qs.stringify({ a: 1 })).to.equal('a=1'); + expect(Qs.stringify({ a: 1, b: 2 })).to.equal('a=1&b=2'); + done(); + }); + + it('stringifies a nested object', function (done) { + + expect(Qs.stringify({ a: { b: 'c' } })).to.equal('a%5Bb%5D=c'); + expect(Qs.stringify({ a: { b: { c: { d: 'e' } } } })).to.equal('a%5Bb%5D%5Bc%5D%5Bd%5D=e'); + done(); + }); + + it('stringifies an array value', function (done) { + + expect(Qs.stringify({ a: ['b', 'c', 'd'] })).to.equal('a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d'); + done(); + }); + + it('omits array indices when asked', function (done) { + + expect(Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false })).to.equal('a=b&a=c&a=d'); + done(); + }); + + it('stringifies a nested array value', function (done) { + + expect(Qs.stringify({ a: { b: ['c', 'd'] } })).to.equal('a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d'); + done(); + }); + + it('stringifies an object inside an array', function (done) { + + expect(Qs.stringify({ a: [{ b: 'c' }] })).to.equal('a%5B0%5D%5Bb%5D=c'); + expect(Qs.stringify({ a: [{ b: { c: [1] } }] })).to.equal('a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1'); + done(); + }); + + it('does not omit object keys when indices = false', function (done) { + + expect(Qs.stringify({ a: [{ b: 'c' }] }, { indices: false })).to.equal('a%5Bb%5D=c'); + done(); + }); + + it('uses indices notation for arrays when indices=true', function (done) { + + expect(Qs.stringify({ a: ['b', 'c'] }, { indices: true })).to.equal('a%5B0%5D=b&a%5B1%5D=c'); + done(); + }); + + it('uses indices notation for arrays when no arrayFormat is specified', function (done) { + + expect(Qs.stringify({ a: ['b', 'c'] })).to.equal('a%5B0%5D=b&a%5B1%5D=c'); + done(); + }); + + it('uses indices notation for arrays when no arrayFormat=indices', function (done) { + + expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })).to.equal('a%5B0%5D=b&a%5B1%5D=c'); + done(); + }); + + it('uses repeat notation for arrays when no arrayFormat=repeat', function (done) { + + expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })).to.equal('a=b&a=c'); + done(); + }); + + it('uses brackets notation for arrays when no arrayFormat=brackets', function (done) { + + expect(Qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })).to.equal('a%5B%5D=b&a%5B%5D=c'); + done(); + }); + + it('stringifies a complicated object', function (done) { + + expect(Qs.stringify({ a: { b: 'c', d: 'e' } })).to.equal('a%5Bb%5D=c&a%5Bd%5D=e'); + done(); + }); + + it('stringifies an empty value', function (done) { + + expect(Qs.stringify({ a: '' })).to.equal('a='); + expect(Qs.stringify({ a: '', b: '' })).to.equal('a=&b='); + expect(Qs.stringify({ a: null })).to.equal('a='); + expect(Qs.stringify({ a: { b: null } })).to.equal('a%5Bb%5D='); + done(); + }); + + it('stringifies an empty object', function (done) { + + var obj = Object.create(null); + obj.a = 'b'; + expect(Qs.stringify(obj)).to.equal('a=b'); + done(); + }); + + it('returns an empty string for invalid input', function (done) { + + expect(Qs.stringify(undefined)).to.equal(''); + expect(Qs.stringify(false)).to.equal(''); + expect(Qs.stringify(null)).to.equal(''); + expect(Qs.stringify('')).to.equal(''); + done(); + }); + + it('stringifies an object with an empty object as a child', function (done) { + + var obj = { + a: Object.create(null) + }; + + obj.a.b = 'c'; + expect(Qs.stringify(obj)).to.equal('a%5Bb%5D=c'); + done(); + }); + + it('drops keys with a value of undefined', function (done) { + + expect(Qs.stringify({ a: undefined })).to.equal(''); + expect(Qs.stringify({ a: { b: undefined, c: null } })).to.equal('a%5Bc%5D='); + done(); + }); + + it('url encodes values', function (done) { + + expect(Qs.stringify({ a: 'b c' })).to.equal('a=b%20c'); + done(); + }); + + it('stringifies a date', function (done) { + + var now = new Date(); + var str = 'a=' + encodeURIComponent(now.toISOString()); + expect(Qs.stringify({ a: now })).to.equal(str); + done(); + }); + + it('stringifies the weird object from qs', function (done) { + + expect(Qs.stringify({ 'my weird field': 'q1!2"\'w$5&7/z8)?' })).to.equal('my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F'); + done(); + }); + + it('skips properties that are part of the object prototype', function (done) { + + Object.prototype.crash = 'test'; + expect(Qs.stringify({ a: 'b'})).to.equal('a=b'); + expect(Qs.stringify({ a: { b: 'c' } })).to.equal('a%5Bb%5D=c'); + delete Object.prototype.crash; + done(); + }); + + it('stringifies boolean values', function (done) { + + expect(Qs.stringify({ a: true })).to.equal('a=true'); + expect(Qs.stringify({ a: { b: true } })).to.equal('a%5Bb%5D=true'); + expect(Qs.stringify({ b: false })).to.equal('b=false'); + expect(Qs.stringify({ b: { c: false } })).to.equal('b%5Bc%5D=false'); + done(); + }); + + it('stringifies buffer values', function (done) { + + expect(Qs.stringify({ a: new Buffer('test') })).to.equal('a=test'); + expect(Qs.stringify({ a: { b: new Buffer('test') } })).to.equal('a%5Bb%5D=test'); + done(); + }); + + it('stringifies an object using an alternative delimiter', function (done) { + + expect(Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' })).to.equal('a=b;c=d'); + done(); + }); + + it('doesn\'t blow up when Buffer global is missing', function (done) { + + var tempBuffer = global.Buffer; + delete global.Buffer; + expect(Qs.stringify({ a: 'b', c: 'd' })).to.equal('a=b&c=d'); + global.Buffer = tempBuffer; + done(); + }); +}); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.npmignore new file mode 100644 index 0000000..7dccd97 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.npmignore @@ -0,0 +1,15 @@ +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +node_modules +npm-debug.log \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.travis.yml new file mode 100644 index 0000000..f1d0f13 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.4 + - 0.6 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/LICENSE.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/LICENSE.txt new file mode 100644 index 0000000..eac1881 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/LICENSE.txt @@ -0,0 +1,4 @@ +Copyright 2012 Michael Hart (michael.hart.au@gmail.com) + +This project is free software released under the MIT license: +http://www.opensource.org/licenses/mit-license.php diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/README.md new file mode 100644 index 0000000..32fc982 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/README.md @@ -0,0 +1,38 @@ +# Decode streams into strings The Right Way(tm) + +```javascript +var fs = require('fs') +var zlib = require('zlib') +var strs = require('stringstream') + +var utf8Stream = fs.createReadStream('massiveLogFile.gz') + .pipe(zlib.createGunzip()) + .pipe(strs('utf8')) +``` + +No need to deal with `setEncoding()` weirdness, just compose streams +like they were supposed to be! + +Handles input and output encoding: + +```javascript +// Stream from utf8 to hex to base64... Why not, ay. +var hex64Stream = fs.createReadStream('myFile') + .pipe(strs('utf8', 'hex')) + .pipe(strs('hex', 'base64')) +``` + +Also deals with `base64` output correctly by aligning each emitted data +chunk so that there are no dangling `=` characters: + +```javascript +var stream = fs.createReadStream('myFile').pipe(strs('base64')) + +var base64Str = '' + +stream.on('data', function(data) { base64Str += data }) +stream.on('end', function() { + console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding() + console.log('Original file is: ' + new Buffer(base64Str, 'base64')) +}) +``` diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/example.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/example.js new file mode 100644 index 0000000..f82b85e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/example.js @@ -0,0 +1,27 @@ +var fs = require('fs') +var zlib = require('zlib') +var strs = require('stringstream') + +var utf8Stream = fs.createReadStream('massiveLogFile.gz') + .pipe(zlib.createGunzip()) + .pipe(strs('utf8')) + +utf8Stream.pipe(process.stdout) + +// Stream from utf8 to hex to base64... Why not, ay. +var hex64Stream = fs.createReadStream('myFile') + .pipe(strs('utf8', 'hex')) + .pipe(strs('hex', 'base64')) + +hex64Stream.pipe(process.stdout) + +// Deals with base64 correctly by aligning chunks +var stream = fs.createReadStream('myFile').pipe(strs('base64')) + +var base64Str = '' + +stream.on('data', function(data) { base64Str += data }) +stream.on('end', function() { + console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding() + console.log('Original file is: ' + new Buffer(base64Str, 'base64')) +}) diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/package.json new file mode 100644 index 0000000..400e27b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/package.json @@ -0,0 +1,49 @@ +{ + "name": "stringstream", + "version": "0.0.4", + "description": "Encode and decode streams into string streams", + "author": { + "name": "Michael Hart", + "email": "michael.hart.au@gmail.com", + "url": "http://github.com/mhart" + }, + "main": "stringstream.js", + "keywords": [ + "string", + "stream", + "base64", + "gzip" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/mhart/StringStream.git" + }, + "license": "MIT", + "readme": "# Decode streams into strings The Right Way(tm)\n\n```javascript\nvar fs = require('fs')\nvar zlib = require('zlib')\nvar strs = require('stringstream')\n\nvar utf8Stream = fs.createReadStream('massiveLogFile.gz')\n .pipe(zlib.createGunzip())\n .pipe(strs('utf8'))\n```\n\nNo need to deal with `setEncoding()` weirdness, just compose streams\nlike they were supposed to be!\n\nHandles input and output encoding:\n\n```javascript\n// Stream from utf8 to hex to base64... Why not, ay.\nvar hex64Stream = fs.createReadStream('myFile')\n .pipe(strs('utf8', 'hex'))\n .pipe(strs('hex', 'base64'))\n```\n\nAlso deals with `base64` output correctly by aligning each emitted data\nchunk so that there are no dangling `=` characters:\n\n```javascript\nvar stream = fs.createReadStream('myFile').pipe(strs('base64'))\n\nvar base64Str = ''\n\nstream.on('data', function(data) { base64Str += data })\nstream.on('end', function() {\n console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding()\n console.log('Original file is: ' + new Buffer(base64Str, 'base64'))\n})\n```\n", + "readmeFilename": "README.md", + "_id": "stringstream@0.0.4", + "dist": { + "shasum": "0f0e3423f942960b5692ac324a57dd093bc41a92", + "tarball": "http://registry.npmjs.org/stringstream/-/stringstream-0.0.4.tgz" + }, + "_npmVersion": "1.2.0", + "_npmUser": { + "name": "hichaelmart", + "email": "michael.hart.au@gmail.com" + }, + "maintainers": [ + { + "name": "hichaelmart", + "email": "michael.hart.au@gmail.com" + } + ], + "directories": {}, + "_shasum": "0f0e3423f942960b5692ac324a57dd093bc41a92", + "_from": "stringstream@>=0.0.4 <0.1.0", + "_resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.4.tgz", + "bugs": { + "url": "https://github.com/mhart/StringStream/issues" + }, + "homepage": "https://github.com/mhart/StringStream", + "scripts": {} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/stringstream.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/stringstream.js new file mode 100644 index 0000000..4ece127 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/stringstream.js @@ -0,0 +1,102 @@ +var util = require('util') +var Stream = require('stream') +var StringDecoder = require('string_decoder').StringDecoder + +module.exports = StringStream +module.exports.AlignedStringDecoder = AlignedStringDecoder + +function StringStream(from, to) { + if (!(this instanceof StringStream)) return new StringStream(from, to) + + Stream.call(this) + + if (from == null) from = 'utf8' + + this.readable = this.writable = true + this.paused = false + this.toEncoding = (to == null ? from : to) + this.fromEncoding = (to == null ? '' : from) + this.decoder = new AlignedStringDecoder(this.toEncoding) +} +util.inherits(StringStream, Stream) + +StringStream.prototype.write = function(data) { + if (!this.writable) { + var err = new Error('stream not writable') + err.code = 'EPIPE' + this.emit('error', err) + return false + } + if (this.fromEncoding) { + if (Buffer.isBuffer(data)) data = data.toString() + data = new Buffer(data, this.fromEncoding) + } + var string = this.decoder.write(data) + if (string.length) this.emit('data', string) + return !this.paused +} + +StringStream.prototype.flush = function() { + if (this.decoder.flush) { + var string = this.decoder.flush() + if (string.length) this.emit('data', string) + } +} + +StringStream.prototype.end = function() { + if (!this.writable && !this.readable) return + this.flush() + this.emit('end') + this.writable = this.readable = false + this.destroy() +} + +StringStream.prototype.destroy = function() { + this.decoder = null + this.writable = this.readable = false + this.emit('close') +} + +StringStream.prototype.pause = function() { + this.paused = true +} + +StringStream.prototype.resume = function () { + if (this.paused) this.emit('drain') + this.paused = false +} + +function AlignedStringDecoder(encoding) { + StringDecoder.call(this, encoding) + + switch (this.encoding) { + case 'base64': + this.write = alignedWrite + this.alignedBuffer = new Buffer(3) + this.alignedBytes = 0 + break + } +} +util.inherits(AlignedStringDecoder, StringDecoder) + +AlignedStringDecoder.prototype.flush = function() { + if (!this.alignedBuffer || !this.alignedBytes) return '' + var leftover = this.alignedBuffer.toString(this.encoding, 0, this.alignedBytes) + this.alignedBytes = 0 + return leftover +} + +function alignedWrite(buffer) { + var rem = (this.alignedBytes + buffer.length) % this.alignedBuffer.length + if (!rem && !this.alignedBytes) return buffer.toString(this.encoding) + + var returnBuffer = new Buffer(this.alignedBytes + buffer.length - rem) + + this.alignedBuffer.copy(returnBuffer, 0, 0, this.alignedBytes) + buffer.copy(returnBuffer, this.alignedBytes, 0, buffer.length - rem) + + buffer.copy(this.alignedBuffer, 0, buffer.length - rem, buffer.length) + this.alignedBytes = rem + + return returnBuffer.toString(this.encoding) +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.editorconfig b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.editorconfig new file mode 100644 index 0000000..e09b844 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.editorconfig @@ -0,0 +1,12 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.jshintrc new file mode 100644 index 0000000..fb11913 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.jshintrc @@ -0,0 +1,70 @@ +{ + "passfail" : false, + "maxerr" : 100, + + "browser" : false, + "node" : true, + "rhino" : false, + "couch" : false, + "wsh" : false, + + "jquery" : false, + "prototypejs" : false, + "mootools" : false, + "dojo" : false, + + "debug" : false, + "devel" : false, + + "esnext" : true, + "strict" : true, + "globalstrict" : true, + + "asi" : false, + "laxbreak" : false, + "bitwise" : true, + "boss" : false, + "curly" : true, + "eqeqeq" : false, + "eqnull" : true, + "evil" : false, + "expr" : false, + "forin" : false, + "immed" : true, + "lastsemic" : true, + "latedef" : false, + "loopfunc" : false, + "noarg" : true, + "regexp" : false, + "regexdash" : false, + "scripturl" : false, + "shadow" : false, + "supernew" : false, + "undef" : true, + "unused" : true, + + "newcap" : true, + "noempty" : true, + "nonew" : true, + "nomen" : false, + "onevar" : false, + "onecase" : true, + "plusplus" : false, + "proto" : false, + "sub" : true, + "trailing" : true, + "white" : false, + + "predef": [ + "describe", + "it", + "before", + "beforeEach", + "after", + "afterEach", + "expect", + "setTimeout", + "clearTimeout" + ], + "maxlen": 0 +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.npmignore new file mode 100644 index 0000000..5a8d2d8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.npmignore @@ -0,0 +1,4 @@ +.idea +node_modules/ +.*.sw[nmop] +npm-debug.log diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.travis.yml new file mode 100644 index 0000000..02059d0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: +- "0.10" +- "0.12" +- iojs +matrix: + fast_finish: true + allow_failures: + - node_js: 0.11 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/CONTRIBUTING.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/CONTRIBUTING.md new file mode 100644 index 0000000..7d37411 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing + +This is the contribution guide for tough-cookie. + +## CLA + +As with all Salesforce open-source projects, tough-cookie requires a Contributor License Agreement to be signed by you (or your company). + + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/LICENSE new file mode 100644 index 0000000..84e0cad --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/LICENSE @@ -0,0 +1,74 @@ +Copyright (c) 2015, Salesforce.com, Inc. +All rights reserved. + +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. + +3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + +=== + +The following exceptions apply: + +=== + +`pubSufTest()` of generate-pubsuffix.js is in the public domain. + + // Any copyright is dedicated to the Public Domain. + // http://creativecommons.org/publicdomain/zero/1.0/ + +=== + +`public-suffix.txt` was obtained from + +via . + +That file contains the usual Mozilla triple-license, for which this project uses it +under the terms of the MPL 1.1: + + // ***** BEGIN LICENSE BLOCK ***** + // Version: MPL 1.1/GPL 2.0/LGPL 2.1 + // + // The contents of this file are subject to the Mozilla Public License Version + // 1.1 (the "License"); you may not use this file except in compliance with + // the License. You may obtain a copy of the License at + // http://www.mozilla.org/MPL/ + // + // Software distributed under the License is distributed on an "AS IS" basis, + // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + // for the specific language governing rights and limitations under the + // License. + // + // The Original Code is the Public Suffix List. + // + // The Initial Developer of the Original Code is + // Jo Hermans . + // Portions created by the Initial Developer are Copyright (C) 2007 + // the Initial Developer. All Rights Reserved. + // + // Contributor(s): + // Ruben Arakelyan + // Gervase Markham + // Pamela Greene + // David Triendl + // Jothan Frakes + // The kind representatives of many TLD registries + // + // Alternatively, the contents of this file may be used under the terms of + // either the GNU General Public License Version 2 or later (the "GPL"), or + // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + // in which case the provisions of the GPL or the LGPL are applicable instead + // of those above. If you wish to allow use of your version of this file only + // under the terms of either the GPL or the LGPL, and not to allow others to + // use your version of this file under the terms of the MPL, indicate your + // decision by deleting the provisions above and replace them with the notice + // and other provisions required by the GPL or the LGPL. If you do not delete + // the provisions above, a recipient may use your version of this file under + // the terms of any one of the MPL, the GPL or the LGPL. + // + // ***** END LICENSE BLOCK ***** diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/README.md new file mode 100644 index 0000000..60e1fb3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/README.md @@ -0,0 +1,423 @@ +[RFC6265](https://tools.ietf.org/html/rfc6265) Cookies and CookieJar for Node.js + +[](https://travis-ci.org/SalesforceEng/tough-cookie) + +[](https://npmjs.org/package/tough-cookie) + + +# Synopsis + +``` javascript +var tough = require('tough-cookie'); // note: not 'cookie', 'cookies' or 'node-cookie' +var Cookie = tough.Cookie; +var cookie = Cookie.parse(header); +cookie.value = 'somethingdifferent'; +header = cookie.toString(); + +var cookiejar = new tough.CookieJar(); +cookiejar.setCookie(cookie, 'http://currentdomain.example.com/path', cb); +// ... +cookiejar.getCookies('http://example.com/otherpath',function(err,cookies) { + res.headers['cookie'] = cookies.join('; '); +}); +``` + +# Installation + +It's _so_ easy! + +`npm install tough-cookie` + +Requires `punycode`, which should get installed automatically for you. Note that node.js v0.6.2+ bundles punycode by default. + +Why the name? NPM modules `cookie`, `cookies` and `cookiejar` were already taken. + +# API + +tough +===== + +Functions on the module you get from `require('tough-cookie')`. All can be used as pure functions and don't need to be "bound". + +**Note**: prior to 1.0.x, several of these functions took a `strict` parameter. This has since been removed from the API as it was no longer necessary. + +parseDate(string) +----------------- + +Parse a cookie date string into a `Date`. Parses according to RFC6265 Section 5.1.1, not `Date.parse()`. + +formatDate(date) +---------------- + +Format a Date into a RFC1123 string (the RFC6265-recommended format). + +canonicalDomain(str) +-------------------- + +Transforms a domain-name into a canonical domain-name. The canonical domain-name is a trimmed, lowercased, stripped-of-leading-dot and optionally punycode-encoded domain-name (Section 5.1.2 of RFC6265). For the most part, this function is idempotent (can be run again on its output without ill effects). + +domainMatch(str,domStr[,canonicalize=true]) +------------------------------------------- + +Answers "does this real domain match the domain in a cookie?". The `str` is the "current" domain-name and the `domStr` is the "cookie" domain-name. Matches according to RFC6265 Section 5.1.3, but it helps to think of it as a "suffix match". + +The `canonicalize` parameter will run the other two paramters through `canonicalDomain` or not. + +defaultPath(path) +----------------- + +Given a current request/response path, gives the Path apropriate for storing in a cookie. This is basically the "directory" of a "file" in the path, but is specified by Section 5.1.4 of the RFC. + +The `path` parameter MUST be _only_ the pathname part of a URI (i.e. excludes the hostname, query, fragment, etc.). This is the `.pathname` property of node's `uri.parse()` output. + +pathMatch(reqPath,cookiePath) +----------------------------- + +Answers "does the request-path path-match a given cookie-path?" as per RFC6265 Section 5.1.4. Returns a boolean. + +This is essentially a prefix-match where `cookiePath` is a prefix of `reqPath`. + +parse(header) +---------------------------- + +alias for `Cookie.parse(header)` + +fromJSON(string) +---------------- + +alias for `Cookie.fromJSON(string)` + +getPublicSuffix(hostname) +------------------------- + +Returns the public suffix of this hostname. The public suffix is the shortest domain-name upon which a cookie can be set. Returns `null` if the hostname cannot have cookies set for it. + +For example: `www.example.com` and `www.subdomain.example.com` both have public suffix `example.com`. + +For further information, see http://publicsuffix.org/. This module derives its list from that site. + +cookieCompare(a,b) +------------------ + +For use with `.sort()`, sorts a list of cookies into the recommended order given in the RFC (Section 5.4 step 2). Longest `.path`s go first, then sorted oldest to youngest. + +``` javascript +var cookies = [ /* unsorted array of Cookie objects */ ]; +cookies = cookies.sort(cookieCompare); +``` + +permuteDomain(domain) +--------------------- + +Generates a list of all possible domains that `domainMatch()` the parameter. May be handy for implementing cookie stores. + + +permutePath(path) +----------------- + +Generates a list of all possible paths that `pathMatch()` the parameter. May be handy for implementing cookie stores. + +Cookie +====== + +Cookie.parse(header) +----------------------------------- + +Parses a single Cookie or Set-Cookie HTTP header into a `Cookie` object. Returns `undefined` if the string can't be parsed. + +Here's how to process the Set-Cookie header(s) on a node HTTP/HTTPS response: + +``` javascript +if (res.headers['set-cookie'] instanceof Array) + cookies = res.headers['set-cookie'].map(function (c) { return (Cookie.parse(c)); }); +else + cookies = [Cookie.parse(res.headers['set-cookie'])]; +``` + +Cookie.fromJSON(string) +----------------------- + +Convert a JSON string to a `Cookie` object. Does a `JSON.parse()` and converts the `.created`, `.lastAccessed` and `.expires` properties into `Date` objects. + +Properties +========== + + * _key_ - string - the name or key of the cookie (default "") + * _value_ - string - the value of the cookie (default "") + * _expires_ - `Date` - if set, the `Expires=` attribute of the cookie (defaults to the string `"Infinity"`). See `setExpires()` + * _maxAge_ - seconds - if set, the `Max-Age=` attribute _in seconds_ of the cookie. May also be set to strings `"Infinity"` and `"-Infinity"` for non-expiry and immediate-expiry, respectively. See `setMaxAge()` + * _domain_ - string - the `Domain=` attribute of the cookie + * _path_ - string - the `Path=` of the cookie + * _secure_ - boolean - the `Secure` cookie flag + * _httpOnly_ - boolean - the `HttpOnly` cookie flag + * _extensions_ - `Array` - any unrecognized cookie attributes as strings (even if equal-signs inside) + +After a cookie has been passed through `CookieJar.setCookie()` it will have the following additional attributes: + + * _hostOnly_ - boolean - is this a host-only cookie (i.e. no Domain field was set, but was instead implied) + * _pathIsDefault_ - boolean - if true, there was no Path field on the cookie and `defaultPath()` was used to derive one. + * _created_ - `Date` - when this cookie was added to the jar + * _lastAccessed_ - `Date` - last time the cookie got accessed. Will affect cookie cleaning once implemented. Using `cookiejar.getCookies(...)` will update this attribute. + +Construction([{options}]) +------------ + +Receives an options object that can contain any Cookie properties, uses the default for unspecified properties. + +.toString() +----------- + +encode to a Set-Cookie header value. The Expires cookie field is set using `formatDate()`, but is omitted entirely if `.expires` is `Infinity`. + +.cookieString() +--------------- + +encode to a Cookie header value (i.e. the `.key` and `.value` properties joined with '='). + +.setExpires(String) +------------------- + +sets the expiry based on a date-string passed through `parseDate()`. If parseDate returns `null` (i.e. can't parse this date string), `.expires` is set to `"Infinity"` (a string) is set. + +.setMaxAge(number) +------------------- + +sets the maxAge in seconds. Coerces `-Infinity` to `"-Infinity"` and `Infinity` to `"Infinity"` so it JSON serializes correctly. + +.expiryTime([now=Date.now()]) +----------------------------- + +.expiryDate([now=Date.now()]) +----------------------------- + +expiryTime() Computes the absolute unix-epoch milliseconds that this cookie expires. expiryDate() works similarly, except it returns a `Date` object. Note that in both cases the `now` parameter should be milliseconds. + +Max-Age takes precedence over Expires (as per the RFC). The `.created` attribute -- or, by default, the `now` paramter -- is used to offset the `.maxAge` attribute. + +If Expires (`.expires`) is set, that's returned. + +Otherwise, `expiryTime()` returns `Infinity` and `expiryDate()` returns a `Date` object for "Tue, 19 Jan 2038 03:14:07 GMT" (latest date that can be expressed by a 32-bit `time_t`; the common limit for most user-agents). + +.TTL([now=Date.now()]) +--------- + +compute the TTL relative to `now` (milliseconds). The same precedence rules as for `expiryTime`/`expiryDate` apply. + +The "number" `Infinity` is returned for cookies without an explicit expiry and `0` is returned if the cookie is expired. Otherwise a time-to-live in milliseconds is returned. + +.canonicalizedDoman() +--------------------- + +.cdomain() +---------- + +return the canonicalized `.domain` field. This is lower-cased and punycode (RFC3490) encoded if the domain has any non-ASCII characters. + +.validate() +----------- + +Status: *IN PROGRESS*. Works for a few things, but is by no means comprehensive. + +validates cookie attributes for semantic correctness. Useful for "lint" checking any Set-Cookie headers you generate. For now, it returns a boolean, but eventually could return a reason string -- you can future-proof with this construct: + +``` javascript +if (cookie.validate() === true) { + // it's tasty +} else { + // yuck! +} +``` + +CookieJar +========= + +Construction([store = new MemoryCookieStore()][, rejectPublicSuffixes]) +------------ + +Simply use `new CookieJar()`. If you'd like to use a custom store, pass that to the constructor otherwise a `MemoryCookieStore` will be created and used. + + +Attributes +---------- + + * _rejectPublicSuffixes_ - boolean - reject cookies with domains like "com" and "co.uk" (default: `true`) + +Since eventually this module would like to support database/remote/etc. CookieJars, continuation passing style is used for CookieJar methods. + +.setCookie(cookieOrString, currentUrl, [{options},] cb(err,cookie)) +------------------------------------------------------------------- + +Attempt to set the cookie in the cookie jar. If the operation fails, an error will be given to the callback `cb`, otherwise the cookie is passed through. The cookie will have updated `.created`, `.lastAccessed` and `.hostOnly` properties. + +The `options` object can be omitted and can have the following properties: + + * _http_ - boolean - default `true` - indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + * _secure_ - boolean - autodetect from url - indicates if this is a "Secure" API. If the currentUrl starts with `https:` or `wss:` then this is defaulted to `true`, otherwise `false`. + * _now_ - Date - default `new Date()` - what to use for the creation/access time of cookies + * _ignoreError_ - boolean - default `false` - silently ignore things like parse errors and invalid domains. CookieStore errors aren't ignored by this option. + +As per the RFC, the `.hostOnly` property is set if there was no "Domain=" parameter in the cookie string (or `.domain` was null on the Cookie object). The `.domain` property is set to the fully-qualified hostname of `currentUrl` in this case. Matching this cookie requires an exact hostname match (not a `domainMatch` as per usual). + +.setCookieSync(cookieOrString, currentUrl, [{options}]) +------------------------------------------------------- + +Synchronous version of `setCookie`; only works with synchronous stores (e.g. the default `MemoryCookieStore`). + +.storeCookie(cookie, [{options},] cb(err,cookie)) +------------------------------------------------- + +__REMOVED__ removed in lieu of the CookieStore API below + +.getCookies(currentUrl, [{options},] cb(err,cookies)) +----------------------------------------------------- + +Retrieve the list of cookies that can be sent in a Cookie header for the current url. + +If an error is encountered, that's passed as `err` to the callback, otherwise an `Array` of `Cookie` objects is passed. The array is sorted with `cookieCompare()` unless the `{sort:false}` option is given. + +The `options` object can be omitted and can have the following properties: + + * _http_ - boolean - default `true` - indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + * _secure_ - boolean - autodetect from url - indicates if this is a "Secure" API. If the currentUrl starts with `https:` or `wss:` then this is defaulted to `true`, otherwise `false`. + * _now_ - Date - default `new Date()` - what to use for the creation/access time of cookies + * _expire_ - boolean - default `true` - perform expiry-time checking of cookies and asynchronously remove expired cookies from the store. Using `false` will return expired cookies and **not** remove them from the store (which is useful for replaying Set-Cookie headers, potentially). + * _allPaths_ - boolean - default `false` - if `true`, do not scope cookies by path. The default uses RFC-compliant path scoping. **Note**: may not be supported by the CookieStore `fetchCookies` function (the default MemoryCookieStore supports it). + +The `.lastAccessed` property of the returned cookies will have been updated. + +.getCookiesSync(currentUrl, [{options}]) +---------------------------------------- + +Synchronous version of `getCookies`; only works with synchronous stores (e.g. the default `MemoryCookieStore`). + +.getCookieString(...) +--------------------- + +Accepts the same options as `.getCookies()` but passes a string suitable for a Cookie header rather than an array to the callback. Simply maps the `Cookie` array via `.cookieString()`. + +.getCookieStringSync(...) +------------------------- + +Synchronous version of `getCookieString`; only works with synchronous stores (e.g. the default `MemoryCookieStore`). + +.getSetCookieStrings(...) +------------------------- + +Returns an array of strings suitable for **Set-Cookie** headers. Accepts the same options as `.getCookies()`. Simply maps the cookie array via `.toString()`. + +.getSetCookieStringsSync(...) +----------------------------- + +Synchronous version of `getSetCookieStrings`; only works with synchronous stores (e.g. the default `MemoryCookieStore`). + +Store +===== + +Base class for CookieJar stores. + +# CookieStore API + +The storage model for each `CookieJar` instance can be replaced with a custom implementation. The default is `MemoryCookieStore` which can be found in the `lib/memstore.js` file. The API uses continuation-passing-style to allow for asynchronous stores. + +Stores should inherit from the base `Store` class, which is available as `require('tough-cookie').Store`. Stores are asynchronous by default, but if `store.synchronous` is set, then the `*Sync` methods on the CookieJar can be used. + +All `domain` parameters will have been normalized before calling. + +The Cookie store must have all of the following methods. + +store.findCookie(domain, path, key, cb(err,cookie)) +--------------------------------------------------- + +Retrieve a cookie with the given domain, path and key (a.k.a. name). The RFC maintains that exactly one of these cookies should exist in a store. If the store is using versioning, this means that the latest/newest such cookie should be returned. + +Callback takes an error and the resulting `Cookie` object. If no cookie is found then `null` MUST be passed instead (i.e. not an error). + +store.findCookies(domain, path, cb(err,cookies)) +------------------------------------------------ + +Locates cookies matching the given domain and path. This is most often called in the context of `cookiejar.getCookies()` above. + +If no cookies are found, the callback MUST be passed an empty array. + +The resulting list will be checked for applicability to the current request according to the RFC (domain-match, path-match, http-only-flag, secure-flag, expiry, etc.), so it's OK to use an optimistic search algorithm when implementing this method. However, the search algorithm used SHOULD try to find cookies that `domainMatch()` the domain and `pathMatch()` the path in order to limit the amount of checking that needs to be done. + +As of version 0.9.12, the `allPaths` option to `cookiejar.getCookies()` above will cause the path here to be `null`. If the path is `null`, path-matching MUST NOT be performed (i.e. domain-matching only). + +store.putCookie(cookie, cb(err)) +-------------------------------- + +Adds a new cookie to the store. The implementation SHOULD replace any existing cookie with the same `.domain`, `.path`, and `.key` properties -- depending on the nature of the implementation, it's possible that between the call to `fetchCookie` and `putCookie` that a duplicate `putCookie` can occur. + +The `cookie` object MUST NOT be modified; the caller will have already updated the `.creation` and `.lastAccessed` properties. + +Pass an error if the cookie cannot be stored. + +store.updateCookie(oldCookie, newCookie, cb(err)) +------------------------------------------------- + +Update an existing cookie. The implementation MUST update the `.value` for a cookie with the same `domain`, `.path` and `.key`. The implementation SHOULD check that the old value in the store is equivalent to `oldCookie` - how the conflict is resolved is up to the store. + +The `.lastAccessed` property will always be different between the two objects and `.created` will always be the same. Stores MAY ignore or defer the `.lastAccessed` change at the cost of affecting how cookies are sorted (or selected for deletion). + +Stores may wish to optimize changing the `.value` of the cookie in the store versus storing a new cookie. If the implementation doesn't define this method a stub that calls `putCookie(newCookie,cb)` will be added to the store object. + +The `newCookie` and `oldCookie` objects MUST NOT be modified. + +Pass an error if the newCookie cannot be stored. + +store.removeCookie(domain, path, key, cb(err)) +---------------------------------------------- + +Remove a cookie from the store (see notes on `findCookie` about the uniqueness constraint). + +The implementation MUST NOT pass an error if the cookie doesn't exist; only pass an error due to the failure to remove an existing cookie. + +store.removeCookies(domain, path, cb(err)) +------------------------------------------ + +Removes matching cookies from the store. The `path` paramter is optional, and if missing means all paths in a domain should be removed. + +Pass an error ONLY if removing any existing cookies failed. + +# TODO + + * _full_ RFC5890/RFC5891 canonicalization for domains in `cdomain()` + * the optional `punycode` requirement implements RFC3492, but RFC6265 requires RFC5891 + * better tests for `validate()`? + +# Copyright and License + +(tl;dr: BSD-3-Clause with some MPL/1.1) + +```text + Copyright (c) 2015, Salesforce.com, Inc. + All rights reserved. + + 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. + + 3. Neither the name of Salesforce.com nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. +``` + +Portions may be licensed under different licenses (in particular public-suffix.txt is MPL/1.1); please read the LICENSE file for full details. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js new file mode 100644 index 0000000..ba054f4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js @@ -0,0 +1,293 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var fs = require('fs'); +var assert = require('assert'); +var punycode = require('punycode'); + +fs.readFile('./public-suffix.txt', 'utf8', function(err,string) { + if (err) { + throw err; + } + var lines = string.split("\n"); + process.nextTick(function() { + processList(lines); + }); +}); + +var index = {}; + +var COMMENT = new RegExp('//.+'); +function processList(lines) { + while (lines.length) { + var line = lines.shift(); + line = line.replace(COMMENT,'').trim(); + if (!line) { + continue; + } + addToIndex(index,line); + } + + pubSufTest(); + + var w = fs.createWriteStream('./lib/pubsuffix.js',{ + flags: 'w', + encoding: 'utf8', + mode: parseInt('644',8) + }); + w.on('end', process.exit); + w.write("/****************************************************\n"); + w.write(" * AUTOMATICALLY GENERATED by generate-pubsuffix.js *\n"); + w.write(" * DO NOT EDIT! *\n"); + w.write(" ****************************************************/\n\n"); + + w.write('"use strict";\n\n'); + w.write("var punycode = require('punycode');\n\n"); + + w.write("module.exports.getPublicSuffix = "); + w.write(getPublicSuffix.toString()); + w.write(";\n\n"); + + w.write("// The following generated structure is used under the MPL version 1.1\n"); + w.write("// See public-suffix.txt for more information\n\n"); + w.write("var index = module.exports.index = Object.freeze(\n"); + w.write(JSON.stringify(index)); + w.write(");\n\n"); + w.write("// END of automatically generated file\n"); + + w.end(); +} + +function addToIndex(index,line) { + var prefix = ''; + if (line.replace(/^(!|\*\.)/)) { + prefix = RegExp.$1; + line = line.slice(prefix.length); + } + line = prefix + punycode.toASCII(line); + + if (line.substr(0,1) == '!') { + index[line.substr(1)] = false; + } else { + index[line] = true; + } +} + +// include the licence in the function since it gets written to pubsuffix.js +function getPublicSuffix(domain) { + /*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + if (!domain) { + return null; + } + if (domain.match(/^\./)) { + return null; + } + var asciiDomain = punycode.toASCII(domain); + var converted = false; + if (asciiDomain !== domain) { + domain = asciiDomain; + converted = true; + } + if (index[domain]) { + return null; + } + + domain = domain.toLowerCase(); + var parts = domain.split('.').reverse(); + + var suffix = ''; + var suffixLen = 0; + for (var i=0; i suffixLen) { + var publicSuffix = parts.slice(0,suffixLen+1).reverse().join('.'); + return converted ? punycode.toUnicode(publicSuffix) : publicSuffix; + } + + return null; +} + +function checkPublicSuffix(give,get) { + var got = getPublicSuffix(give); + assert.equal(got, get, give+' should be '+(get==null?'NULL':get)+' but got '+got); +} + +// pubSufTest() was converted to JavaScript from http://mxr.mozilla.org/mozilla-central/source/netwerk/test/unit/data/test_psl.txt?raw=1 +function pubSufTest() { + // For this function-scope and this function-scope ONLY: + // Any copyright is dedicated to the Public Domain. + // http://creativecommons.org/publicdomain/zero/1.0/ + + // NULL input. + checkPublicSuffix(null, null); + // Mixed case. + checkPublicSuffix('COM', null); + checkPublicSuffix('example.COM', 'example.com'); + checkPublicSuffix('WwW.example.COM', 'example.com'); + // Leading dot. + checkPublicSuffix('.com', null); + checkPublicSuffix('.example', null); + checkPublicSuffix('.example.com', null); + checkPublicSuffix('.example.example', null); + // Unlisted TLD. + checkPublicSuffix('example', null); + checkPublicSuffix('example.example', 'example.example'); + checkPublicSuffix('b.example.example', 'example.example'); + checkPublicSuffix('a.b.example.example', 'example.example'); + // Listed, but non-Internet, TLD. + //checkPublicSuffix('local', null); + //checkPublicSuffix('example.local', null); + //checkPublicSuffix('b.example.local', null); + //checkPublicSuffix('a.b.example.local', null); + // TLD with only 1 rule. + checkPublicSuffix('biz', null); + checkPublicSuffix('domain.biz', 'domain.biz'); + checkPublicSuffix('b.domain.biz', 'domain.biz'); + checkPublicSuffix('a.b.domain.biz', 'domain.biz'); + // TLD with some 2-level rules. + checkPublicSuffix('com', null); + checkPublicSuffix('example.com', 'example.com'); + checkPublicSuffix('b.example.com', 'example.com'); + checkPublicSuffix('a.b.example.com', 'example.com'); + checkPublicSuffix('uk.com', null); + checkPublicSuffix('example.uk.com', 'example.uk.com'); + checkPublicSuffix('b.example.uk.com', 'example.uk.com'); + checkPublicSuffix('a.b.example.uk.com', 'example.uk.com'); + checkPublicSuffix('test.ac', 'test.ac'); + // TLD with only 1 (wildcard) rule. + checkPublicSuffix('cy', null); + checkPublicSuffix('c.cy', null); + checkPublicSuffix('b.c.cy', 'b.c.cy'); + checkPublicSuffix('a.b.c.cy', 'b.c.cy'); + // More complex TLD. + checkPublicSuffix('jp', null); + checkPublicSuffix('test.jp', 'test.jp'); + checkPublicSuffix('www.test.jp', 'test.jp'); + checkPublicSuffix('ac.jp', null); + checkPublicSuffix('test.ac.jp', 'test.ac.jp'); + checkPublicSuffix('www.test.ac.jp', 'test.ac.jp'); + checkPublicSuffix('kyoto.jp', null); + checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp'); + checkPublicSuffix('ide.kyoto.jp', null); + checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp'); + checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp'); + checkPublicSuffix('c.kobe.jp', null); + checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp'); + checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp'); + checkPublicSuffix('city.kobe.jp', 'city.kobe.jp'); + checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp'); + // TLD with a wildcard rule and exceptions. + checkPublicSuffix('ck', null); + checkPublicSuffix('test.ck', null); + checkPublicSuffix('b.test.ck', 'b.test.ck'); + checkPublicSuffix('a.b.test.ck', 'b.test.ck'); + checkPublicSuffix('www.ck', 'www.ck'); + checkPublicSuffix('www.www.ck', 'www.ck'); + // US K12. + checkPublicSuffix('us', null); + checkPublicSuffix('test.us', 'test.us'); + checkPublicSuffix('www.test.us', 'test.us'); + checkPublicSuffix('ak.us', null); + checkPublicSuffix('test.ak.us', 'test.ak.us'); + checkPublicSuffix('www.test.ak.us', 'test.ak.us'); + checkPublicSuffix('k12.ak.us', null); + checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us'); + checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us'); + // IDN labels. + checkPublicSuffix('食狮.com.cn', '食狮.com.cn'); + checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn'); + checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn'); + checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn'); + checkPublicSuffix('公司.cn', null); + checkPublicSuffix('食狮.中国', '食狮.中国'); + checkPublicSuffix('www.食狮.中国', '食狮.中国'); + checkPublicSuffix('shishi.中国', 'shishi.中国'); + checkPublicSuffix('中国', null); + // Same as above, but punycoded. + checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn'); + checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn'); + checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn'); + checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn'); + checkPublicSuffix('xn--55qx5d.cn', null); + checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s'); + checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s'); + checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s'); + checkPublicSuffix('xn--fiqs8s', null); +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/cookie.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/cookie.js new file mode 100644 index 0000000..9ca9531 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/cookie.js @@ -0,0 +1,1137 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var net = require('net'); +var urlParse = require('url').parse; +var pubsuffix = require('./pubsuffix'); +var Store = require('./store').Store; + +var punycode; +try { + punycode = require('punycode'); +} catch(e) { + console.warn("cookie: can't load punycode; won't use punycode for domain normalization"); +} + +var DATE_DELIM = /[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/; + +// From RFC6265 S4.1.1 +// note that it excludes \x3B ";" +var COOKIE_OCTET = /[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]/; +var COOKIE_OCTETS = new RegExp('^'+COOKIE_OCTET.source+'$'); + +// Double quotes are part of the value (see: S4.1.1). +// '\r', '\n' and '\0' should be treated as a terminator in the "relaxed" mode +// (see: https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/parsed_cookie.cc#L60) +// '=' and ';' are attribute/values separators +// (see: https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/parsed_cookie.cc#L64) +var COOKIE_PAIR = /^([^=;]+)\s*=\s*(("?)[^\n\r\0]*\3)/; + +// RFC6265 S4.1.1 defines path value as 'any CHAR except CTLs or ";"' +// Note ';' is \x3B +var PATH_VALUE = /[\x20-\x3A\x3C-\x7E]+/; + +// Used for checking whether or not there is a trailing semi-colon +var TRAILING_SEMICOLON = /;+$/; + +var DAY_OF_MONTH = /^(\d{1,2})[^\d]*$/; +var TIME = /^(\d{1,2})[^\d]*:(\d{1,2})[^\d]*:(\d{1,2})[^\d]*$/; +var MONTH = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i; + +var MONTH_TO_NUM = { + jan:0, feb:1, mar:2, apr:3, may:4, jun:5, + jul:6, aug:7, sep:8, oct:9, nov:10, dec:11 +}; +var NUM_TO_MONTH = [ + 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' +]; +var NUM_TO_DAY = [ + 'Sun','Mon','Tue','Wed','Thu','Fri','Sat' +]; + +var YEAR = /^(\d{2}|\d{4})$/; // 2 to 4 digits + +var MAX_TIME = 2147483647000; // 31-bit max +var MIN_TIME = 0; // 31-bit min + +var cookiesCreated = 0; // Number of cookies created in runtime + + +// RFC6265 S5.1.1 date parser: +function parseDate(str) { + if (!str) { + return; + } + + /* RFC6265 S5.1.1: + * 2. Process each date-token sequentially in the order the date-tokens + * appear in the cookie-date + */ + var tokens = str.split(DATE_DELIM); + if (!tokens) { + return; + } + + var hour = null; + var minutes = null; + var seconds = null; + var day = null; + var month = null; + var year = null; + + for (var i=0; i 23 || minutes > 59 || seconds > 59) { + return; + } + + continue; + } + } + + /* 2.2. If the found-day-of-month flag is not set and the date-token matches + * the day-of-month production, set the found-day-of- month flag and set + * the day-of-month-value to the number denoted by the date-token. Skip + * the remaining sub-steps and continue to the next date-token. + */ + if (day === null) { + result = DAY_OF_MONTH.exec(token); + if (result) { + day = parseInt(result, 10); + /* RFC6265 S5.1.1.5: + * [fail if] the day-of-month-value is less than 1 or greater than 31 + */ + if(day < 1 || day > 31) { + return; + } + continue; + } + } + + /* 2.3. If the found-month flag is not set and the date-token matches the + * month production, set the found-month flag and set the month-value to + * the month denoted by the date-token. Skip the remaining sub-steps and + * continue to the next date-token. + */ + if (month === null) { + result = MONTH.exec(token); + if (result) { + month = MONTH_TO_NUM[result[1].toLowerCase()]; + continue; + } + } + + /* 2.4. If the found-year flag is not set and the date-token matches the year + * production, set the found-year flag and set the year-value to the number + * denoted by the date-token. Skip the remaining sub-steps and continue to + * the next date-token. + */ + if (year === null) { + result = YEAR.exec(token); + if (result) { + year = parseInt(result[0], 10); + /* From S5.1.1: + * 3. If the year-value is greater than or equal to 70 and less + * than or equal to 99, increment the year-value by 1900. + * 4. If the year-value is greater than or equal to 0 and less + * than or equal to 69, increment the year-value by 2000. + */ + if (70 <= year && year <= 99) { + year += 1900; + } else if (0 <= year && year <= 69) { + year += 2000; + } + + if (year < 1601) { + return; // 5. ... the year-value is less than 1601 + } + } + } + } + + if (seconds === null || day === null || month === null || year === null) { + return; // 5. ... at least one of the found-day-of-month, found-month, found- + // year, or found-time flags is not set, + } + + return new Date(Date.UTC(year, month, day, hour, minutes, seconds)); +} + +function formatDate(date) { + var d = date.getUTCDate(); d = d >= 10 ? d : '0'+d; + var h = date.getUTCHours(); h = h >= 10 ? h : '0'+h; + var m = date.getUTCMinutes(); m = m >= 10 ? m : '0'+m; + var s = date.getUTCSeconds(); s = s >= 10 ? s : '0'+s; + return NUM_TO_DAY[date.getUTCDay()] + ', ' + + d+' '+ NUM_TO_MONTH[date.getUTCMonth()] +' '+ date.getUTCFullYear() +' '+ + h+':'+m+':'+s+' GMT'; +} + +// S5.1.2 Canonicalized Host Names +function canonicalDomain(str) { + if (str == null) { + return null; + } + str = str.trim().replace(/^\./,''); // S4.1.2.3 & S5.2.3: ignore leading . + + // convert to IDN if any non-ASCII characters + if (punycode && /[^\u0001-\u007f]/.test(str)) { + str = punycode.toASCII(str); + } + + return str.toLowerCase(); +} + +// S5.1.3 Domain Matching +function domainMatch(str, domStr, canonicalize) { + if (str == null || domStr == null) { + return null; + } + if (canonicalize !== false) { + str = canonicalDomain(str); + domStr = canonicalDomain(domStr); + } + + /* + * "The domain string and the string are identical. (Note that both the + * domain string and the string will have been canonicalized to lower case at + * this point)" + */ + if (str == domStr) { + return true; + } + + /* "All of the following [three] conditions hold:" (order adjusted from the RFC) */ + + /* "* The string is a host name (i.e., not an IP address)." */ + if (net.isIP(str)) { + return false; + } + + /* "* The domain string is a suffix of the string" */ + var idx = str.indexOf(domStr); + if (idx <= 0) { + return false; // it's a non-match (-1) or prefix (0) + } + + // e.g "a.b.c".indexOf("b.c") === 2 + // 5 === 3+2 + if (str.length !== domStr.length + idx) { // it's not a suffix + return false; + } + + /* "* The last character of the string that is not included in the domain + * string is a %x2E (".") character." */ + if (str.substr(idx-1,1) !== '.') { + return false; + } + + return true; +} + + +// RFC6265 S5.1.4 Paths and Path-Match + +/* + * "The user agent MUST use an algorithm equivalent to the following algorithm + * to compute the default-path of a cookie:" + * + * Assumption: the path (and not query part or absolute uri) is passed in. + */ +function defaultPath(path) { + // "2. If the uri-path is empty or if the first character of the uri-path is not + // a %x2F ("/") character, output %x2F ("/") and skip the remaining steps. + if (!path || path.substr(0,1) !== "/") { + return "/"; + } + + // "3. If the uri-path contains no more than one %x2F ("/") character, output + // %x2F ("/") and skip the remaining step." + if (path === "/") { + return path; + } + + var rightSlash = path.lastIndexOf("/"); + if (rightSlash === 0) { + return "/"; + } + + // "4. Output the characters of the uri-path from the first character up to, + // but not including, the right-most %x2F ("/")." + return path.slice(0, rightSlash); +} + +/* + * "A request-path path-matches a given cookie-path if at least one of the + * following conditions holds:" + */ +function pathMatch(reqPath,cookiePath) { + // "o The cookie-path and the request-path are identical." + if (cookiePath === reqPath) { + return true; + } + + var idx = reqPath.indexOf(cookiePath); + if (idx === 0) { + // "o The cookie-path is a prefix of the request-path, and the last + // character of the cookie-path is %x2F ("/")." + if (cookiePath.substr(-1) === "/") { + return true; + } + + // " o The cookie-path is a prefix of the request-path, and the first + // character of the request-path that is not included in the cookie- path + // is a %x2F ("/") character." + if (reqPath.substr(cookiePath.length,1) === "/") { + return true; + } + } + + return false; +} + +function parse(str) { + str = str.trim(); + + // S4.1.1 Trailing semi-colons are not part of the specification. + var semiColonCheck = TRAILING_SEMICOLON.exec(str); + if (semiColonCheck) { + str = str.slice(0, semiColonCheck.index); + } + + // We use a regex to parse the "name-value-pair" part of S5.2 + var firstSemi = str.indexOf(';'); // S5.2 step 1 + var result = COOKIE_PAIR.exec(firstSemi === -1 ? str : str.substr(0,firstSemi)); + + // Rx satisfies the "the name string is empty" and "lacks a %x3D ("=")" + // constraints as well as trimming any whitespace. + if (!result) { + return; + } + + var c = new Cookie(); + c.key = result[1].trim(); + c.value = result[2].trim(); + + if (firstSemi === -1) { + return c; + } + + // S5.2.3 "unparsed-attributes consist of the remainder of the set-cookie-string + // (including the %x3B (";") in question)." plus later on in the same section + // "discard the first ";" and trim". + var unparsed = str.slice(firstSemi).replace(/^\s*;\s*/,'').trim(); + + // "If the unparsed-attributes string is empty, skip the rest of these + // steps." + if (unparsed.length === 0) { + return c; + } + + /* + * S5.2 says that when looping over the items "[p]rocess the attribute-name + * and attribute-value according to the requirements in the following + * subsections" for every item. Plus, for many of the individual attributes + * in S5.3 it says to use the "attribute-value of the last attribute in the + * cookie-attribute-list". Therefore, in this implementation, we overwrite + * the previous value. + */ + var cookie_avs = unparsed.split(/\s*;\s*/); + while (cookie_avs.length) { + var av = cookie_avs.shift(); + var av_sep = av.indexOf('='); + var av_key, av_value; + + if (av_sep === -1) { + av_key = av; + av_value = null; + } else { + av_key = av.substr(0,av_sep); + av_value = av.substr(av_sep+1); + } + + av_key = av_key.trim().toLowerCase(); + + if (av_value) { + av_value = av_value.trim(); + } + + switch(av_key) { + case 'expires': // S5.2.1 + if (av_value) { + var exp = parseDate(av_value); + // "If the attribute-value failed to parse as a cookie date, ignore the + // cookie-av." + if (exp) { + // over and underflow not realistically a concern: V8's getTime() seems to + // store something larger than a 32-bit time_t (even with 32-bit node) + c.expires = exp; + } + } + break; + + case 'max-age': // S5.2.2 + if (av_value) { + // "If the first character of the attribute-value is not a DIGIT or a "-" + // character ...[or]... If the remainder of attribute-value contains a + // non-DIGIT character, ignore the cookie-av." + if (/^-?[0-9]+$/.test(av_value)) { + var delta = parseInt(av_value, 10); + // "If delta-seconds is less than or equal to zero (0), let expiry-time + // be the earliest representable date and time." + c.setMaxAge(delta); + } + } + break; + + case 'domain': // S5.2.3 + // "If the attribute-value is empty, the behavior is undefined. However, + // the user agent SHOULD ignore the cookie-av entirely." + if (av_value) { + // S5.2.3 "Let cookie-domain be the attribute-value without the leading %x2E + // (".") character." + var domain = av_value.trim().replace(/^\./, ''); + if (domain) { + // "Convert the cookie-domain to lower case." + c.domain = domain.toLowerCase(); + } + } + break; + + case 'path': // S5.2.4 + /* + * "If the attribute-value is empty or if the first character of the + * attribute-value is not %x2F ("/"): + * Let cookie-path be the default-path. + * Otherwise: + * Let cookie-path be the attribute-value." + * + * We'll represent the default-path as null since it depends on the + * context of the parsing. + */ + c.path = av_value && av_value[0] === "/" ? av_value : null; + break; + + case 'secure': // S5.2.5 + /* + * "If the attribute-name case-insensitively matches the string "Secure", + * the user agent MUST append an attribute to the cookie-attribute-list + * with an attribute-name of Secure and an empty attribute-value." + */ + c.secure = true; + break; + + case 'httponly': // S5.2.6 -- effectively the same as 'secure' + c.httpOnly = true; + break; + + default: + c.extensions = c.extensions || []; + c.extensions.push(av); + break; + } + } + + // ensure a default date for sorting: + c.creation = new Date(); + //NOTE: add runtime index for the cookieCompare() to resolve the situation when Date's precision is not enough . + //Store initial UTC time as well, so we will be able to determine if we need to fallback to the Date object. + c._creationRuntimeIdx = ++cookiesCreated; + c._initialCreationTime = c.creation.getTime(); + return c; +} + +function fromJSON(str) { + if (!str) { + return null; + } + + var obj; + try { + obj = JSON.parse(str); + } catch (e) { + return null; + } + + var c = new Cookie(); + for (var i=0; i 1) { + var lindex = path.lastIndexOf('/'); + if (lindex === 0) { + break; + } + path = path.substr(0,lindex); + permutations.push(path); + } + permutations.push('/'); + return permutations; +} + +function getCookieContext(url) { + if(url instanceof Object) + return url; + + // NOTE: decodeURI will throw on malformed URIs (see GH-32). + // Therefore, we will just skip decoding for such URIs. + try { + url = decodeURI(url); + } + catch(err) { + // Silently swallow error + } + + return urlParse(url); +} + +function Cookie (opts) { + if (typeof opts !== "object") { + return; + } + Object.keys(opts).forEach(function (key) { + if (Cookie.prototype.hasOwnProperty(key)) { + this[key] = opts[key] || Cookie.prototype[key]; + } + }.bind(this)); +} + +Cookie.parse = parse; +Cookie.fromJSON = fromJSON; + +Cookie.prototype.key = ""; +Cookie.prototype.value = ""; + +// the order in which the RFC has them: +Cookie.prototype.expires = "Infinity"; // coerces to literal Infinity +Cookie.prototype.maxAge = null; // takes precedence over expires for TTL +Cookie.prototype.domain = null; +Cookie.prototype.path = null; +Cookie.prototype.secure = false; +Cookie.prototype.httpOnly = false; +Cookie.prototype.extensions = null; + +// set by the CookieJar: +Cookie.prototype.hostOnly = null; // boolean when set +Cookie.prototype.pathIsDefault = null; // boolean when set +Cookie.prototype.creation = null; // Date when set; defaulted by Cookie.parse +Cookie.prototype._initialCreationTime = null; // Used to determine if cookie.creation was modified +Cookie.prototype._creationRuntimeIdx = null; // Runtime index of the created cookie, used in cookieCompare() +Cookie.prototype.lastAccessed = null; // Date when set + +var cookieProperties = Object.freeze(Object.keys(Cookie.prototype).map(function(p) { + if (p instanceof Function) { + return; + } + return p; +})); +var numCookieProperties = cookieProperties.length; + +Cookie.prototype.inspect = function inspect() { + var now = Date.now(); + return 'Cookie="'+this.toString() + + '; hostOnly='+(this.hostOnly != null ? this.hostOnly : '?') + + '; aAge='+(this.lastAccessed ? (now-this.lastAccessed.getTime())+'ms' : '?') + + '; cAge='+(this.creation ? (now-this.creation.getTime())+'ms' : '?') + + '"'; +}; + +Cookie.prototype.validate = function validate() { + if (!COOKIE_OCTETS.test(this.value)) { + return false; + } + if (this.expires != Infinity && !(this.expires instanceof Date) && !parseDate(this.expires,true)) { + return false; + } + if (this.maxAge != null && this.maxAge <= 0) { + return false; // "Max-Age=" non-zero-digit *DIGIT + } + if (this.path != null && !PATH_VALUE.test(this.path)) { + return false; + } + + var cdomain = this.cdomain(); + if (cdomain) { + if (cdomain.match(/\.$/)) { + return false; // S4.1.2.3 suggests that this is bad. domainMatch() tests confirm this + } + var suffix = pubsuffix.getPublicSuffix(cdomain); + if (suffix == null) { // it's a public suffix + return false; + } + } + return true; +}; + +Cookie.prototype.setExpires = function setExpires(exp) { + if (exp instanceof Date) { + this.expires = exp; + } else { + this.expires = parseDate(exp) || "Infinity"; + } +}; + +Cookie.prototype.setMaxAge = function setMaxAge(age) { + if (age === Infinity || age === -Infinity) { + this.maxAge = age.toString(); // so JSON.stringify() works + } else { + this.maxAge = age; + } +}; + +// gives Cookie header format +Cookie.prototype.cookieString = function cookieString() { + var val = this.value; + if (val == null) { + val = ''; + } + return this.key+'='+val; +}; + +// gives Set-Cookie header format +Cookie.prototype.toString = function toString() { + var str = this.cookieString(); + + if (this.expires != Infinity) { + if (this.expires instanceof Date) { + str += '; Expires='+formatDate(this.expires); + } else { + str += '; Expires='+this.expires; + } + } + + if (this.maxAge != null && this.maxAge != Infinity) { + str += '; Max-Age='+this.maxAge; + } + + if (this.domain && !this.hostOnly) { + str += '; Domain='+this.domain; + } + if (this.path) { + str += '; Path='+this.path; + } + + if (this.secure) { + str += '; Secure'; + } + if (this.httpOnly) { + str += '; HttpOnly'; + } + if (this.extensions) { + this.extensions.forEach(function(ext) { + str += '; '+ext; + }); + } + + return str; +}; + +// TTL() partially replaces the "expiry-time" parts of S5.3 step 3 (setCookie() +// elsewhere) +// S5.3 says to give the "latest representable date" for which we use Infinity +// For "expired" we use 0 +Cookie.prototype.TTL = function TTL(now) { + /* RFC6265 S4.1.2.2 If a cookie has both the Max-Age and the Expires + * attribute, the Max-Age attribute has precedence and controls the + * expiration date of the cookie. + * (Concurs with S5.3 step 3) + */ + if (this.maxAge != null) { + return this.maxAge<=0 ? 0 : this.maxAge*1000; + } + + var expires = this.expires; + if (expires != Infinity) { + if (!(expires instanceof Date)) { + expires = parseDate(expires) || Infinity; + } + + if (expires == Infinity) { + return Infinity; + } + + return expires.getTime() - (now || Date.now()); + } + + return Infinity; +}; + +// expiryTime() replaces the "expiry-time" parts of S5.3 step 3 (setCookie() +// elsewhere) +Cookie.prototype.expiryTime = function expiryTime(now) { + if (this.maxAge != null) { + var relativeTo = this.creation || now || new Date(); + var age = (this.maxAge <= 0) ? -Infinity : this.maxAge*1000; + return relativeTo.getTime() + age; + } + + if (this.expires == Infinity) { + return Infinity; + } + return this.expires.getTime(); +}; + +// expiryDate() replaces the "expiry-time" parts of S5.3 step 3 (setCookie() +// elsewhere), except it returns a Date +Cookie.prototype.expiryDate = function expiryDate(now) { + var millisec = this.expiryTime(now); + if (millisec == Infinity) { + return new Date(MAX_TIME); + } else if (millisec == -Infinity) { + return new Date(MIN_TIME); + } else { + return new Date(millisec); + } +}; + +// This replaces the "persistent-flag" parts of S5.3 step 3 +Cookie.prototype.isPersistent = function isPersistent() { + return (this.maxAge != null || this.expires != Infinity); +}; + +// Mostly S5.1.2 and S5.2.3: +Cookie.prototype.cdomain = +Cookie.prototype.canonicalizedDomain = function canonicalizedDomain() { + if (this.domain == null) { + return null; + } + return canonicalDomain(this.domain); +}; + + +var memstore; +function CookieJar(store, rejectPublicSuffixes) { + if (rejectPublicSuffixes != null) { + this.rejectPublicSuffixes = rejectPublicSuffixes; + } + + if (!store) { + memstore = memstore || require('./memstore'); + store = new memstore.MemoryCookieStore(); + } + this.store = store; +} +CookieJar.prototype.store = null; +CookieJar.prototype.rejectPublicSuffixes = true; +var CAN_BE_SYNC = []; + +CAN_BE_SYNC.push('setCookie'); +CookieJar.prototype.setCookie = function(cookie, url, options, cb) { + var err; + var context = getCookieContext(url); + if (options instanceof Function) { + cb = options; + options = {}; + } + + var host = canonicalDomain(context.hostname); + + // S5.3 step 1 + if (!(cookie instanceof Cookie)) { + cookie = Cookie.parse(cookie); + } + if (!cookie) { + err = new Error("Cookie failed to parse"); + return cb(options.ignoreError ? null : err); + } + + // S5.3 step 2 + var now = options.now || new Date(); // will assign later to save effort in the face of errors + + // S5.3 step 3: NOOP; persistent-flag and expiry-time is handled by getCookie() + + // S5.3 step 4: NOOP; domain is null by default + + // S5.3 step 5: public suffixes + if (this.rejectPublicSuffixes && cookie.domain) { + var suffix = pubsuffix.getPublicSuffix(cookie.cdomain()); + if (suffix == null) { // e.g. "com" + err = new Error("Cookie has domain set to a public suffix"); + return cb(options.ignoreError ? null : err); + } + } + + // S5.3 step 6: + if (cookie.domain) { + if (!domainMatch(host, cookie.cdomain(), false)) { + err = new Error("Cookie not in this host's domain. Cookie:"+cookie.cdomain()+" Request:"+host); + return cb(options.ignoreError ? null : err); + } + + if (cookie.hostOnly == null) { // don't reset if already set + cookie.hostOnly = false; + } + + } else { + cookie.hostOnly = true; + cookie.domain = host; + } + + //S5.2.4 If the attribute-value is empty or if the first character of the + //attribute-value is not %x2F ("/"): + //Let cookie-path be the default-path. + if (!cookie.path || cookie.path[0] !== '/') { + cookie.path = defaultPath(context.pathname); + cookie.pathIsDefault = true; + } + + // S5.3 step 8: NOOP; secure attribute + // S5.3 step 9: NOOP; httpOnly attribute + + // S5.3 step 10 + if (options.http === false && cookie.httpOnly) { + err = new Error("Cookie is HttpOnly and this isn't an HTTP API"); + return cb(options.ignoreError ? null : err); + } + + var store = this.store; + + if (!store.updateCookie) { + store.updateCookie = function(oldCookie, newCookie, cb) { + this.putCookie(newCookie, cb); + }; + } + + function withCookie(err, oldCookie) { + if (err) { + return cb(err); + } + + var next = function(err) { + if (err) { + return cb(err); + } else { + cb(null, cookie); + } + }; + + if (oldCookie) { + // S5.3 step 11 - "If the cookie store contains a cookie with the same name, + // domain, and path as the newly created cookie:" + if (options.http === false && oldCookie.httpOnly) { // step 11.2 + err = new Error("old Cookie is HttpOnly and this isn't an HTTP API"); + return cb(options.ignoreError ? null : err); + } + cookie.creation = oldCookie.creation; // step 11.3 + cookie.lastAccessed = now; + // Step 11.4 (delete cookie) is implied by just setting the new one: + store.updateCookie(oldCookie, cookie, next); // step 12 + + } else { + cookie.creation = cookie.lastAccessed = now; + store.putCookie(cookie, next); // step 12 + } + } + + store.findCookie(cookie.domain, cookie.path, cookie.key, withCookie); +}; + +// RFC6365 S5.4 +CAN_BE_SYNC.push('getCookies'); +CookieJar.prototype.getCookies = function(url, options, cb) { + var context = getCookieContext(url); + if (options instanceof Function) { + cb = options; + options = {}; + } + + var host = canonicalDomain(context.hostname); + var path = context.pathname || '/'; + + var secure = options.secure; + if (secure == null && context.protocol && + (context.protocol == 'https:' || context.protocol == 'wss:')) + { + secure = true; + } + + var http = options.http; + if (http == null) { + http = true; + } + + var now = options.now || Date.now(); + var expireCheck = options.expire !== false; + var allPaths = !!options.allPaths; + var store = this.store; + + function matchingCookie(c) { + // "Either: + // The cookie's host-only-flag is true and the canonicalized + // request-host is identical to the cookie's domain. + // Or: + // The cookie's host-only-flag is false and the canonicalized + // request-host domain-matches the cookie's domain." + if (c.hostOnly) { + if (c.domain != host) { + return false; + } + } else { + if (!domainMatch(host, c.domain, false)) { + return false; + } + } + + // "The request-uri's path path-matches the cookie's path." + if (!allPaths && !pathMatch(path, c.path)) { + return false; + } + + // "If the cookie's secure-only-flag is true, then the request-uri's + // scheme must denote a "secure" protocol" + if (c.secure && !secure) { + return false; + } + + // "If the cookie's http-only-flag is true, then exclude the cookie if the + // cookie-string is being generated for a "non-HTTP" API" + if (c.httpOnly && !http) { + return false; + } + + // deferred from S5.3 + // non-RFC: allow retention of expired cookies by choice + if (expireCheck && c.expiryTime() <= now) { + store.removeCookie(c.domain, c.path, c.key, function(){}); // result ignored + return false; + } + + return true; + } + + store.findCookies(host, allPaths ? null : path, function(err,cookies) { + if (err) { + return cb(err); + } + + cookies = cookies.filter(matchingCookie); + + // sorting of S5.4 part 2 + if (options.sort !== false) { + cookies = cookies.sort(cookieCompare); + } + + // S5.4 part 3 + var now = new Date(); + cookies.forEach(function(c) { + c.lastAccessed = now; + }); + // TODO persist lastAccessed + + cb(null,cookies); + }); +}; + +CAN_BE_SYNC.push('getCookieString'); +CookieJar.prototype.getCookieString = function(/*..., cb*/) { + var args = Array.prototype.slice.call(arguments,0); + var cb = args.pop(); + var next = function(err,cookies) { + if (err) { + cb(err); + } else { + cb(null, cookies + .sort(cookieCompare) + .map(function(c){ + return c.cookieString(); + }) + .join('; ')); + } + }; + args.push(next); + this.getCookies.apply(this,args); +}; + +CAN_BE_SYNC.push('getSetCookieStrings'); +CookieJar.prototype.getSetCookieStrings = function(/*..., cb*/) { + var args = Array.prototype.slice.call(arguments,0); + var cb = args.pop(); + var next = function(err,cookies) { + if (err) { + cb(err); + } else { + cb(null, cookies.map(function(c){ + return c.toString(); + })); + } + }; + args.push(next); + this.getCookies.apply(this,args); +}; + +// Use a closure to provide a true imperative API for synchronous stores. +function syncWrap(method) { + return function() { + if (!this.store.synchronous) { + throw new Error('CookieJar store is not synchronous; use async API instead.'); + } + + var args = Array.prototype.slice.call(arguments); + var syncErr, syncResult; + args.push(function syncCb(err, result) { + syncErr = err; + syncResult = result; + }); + this[method].apply(this, args); + + if (syncErr) { + throw syncErr; + } + return syncResult; + }; +} + +// wrap all declared CAN_BE_SYNC methods in the sync wrapper +CAN_BE_SYNC.forEach(function(method) { + CookieJar.prototype[method+'Sync'] = syncWrap(method); +}); + +module.exports = { + CookieJar: CookieJar, + Cookie: Cookie, + Store: Store, + parseDate: parseDate, + formatDate: formatDate, + parse: parse, + fromJSON: fromJSON, + domainMatch: domainMatch, + defaultPath: defaultPath, + pathMatch: pathMatch, + getPublicSuffix: pubsuffix.getPublicSuffix, + cookieCompare: cookieCompare, + permuteDomain: permuteDomain, + permutePath: permutePath, + canonicalDomain: canonicalDomain +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/memstore.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/memstore.js new file mode 100644 index 0000000..ce3ee66 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/memstore.js @@ -0,0 +1,143 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var tough = require('./cookie'); +var Store = require('./store').Store; +var permuteDomain = tough.permuteDomain; +var pathMatch = tough.pathMatch; +var util = require('util'); + +function MemoryCookieStore() { + Store.call(this); + this.idx = {}; +} +util.inherits(MemoryCookieStore, Store); +exports.MemoryCookieStore = MemoryCookieStore; +MemoryCookieStore.prototype.idx = null; +MemoryCookieStore.prototype.synchronous = true; + +// force a default depth: +MemoryCookieStore.prototype.inspect = function() { + return "{ idx: "+util.inspect(this.idx, false, 2)+' }'; +}; + +MemoryCookieStore.prototype.findCookie = function(domain, path, key, cb) { + if (!this.idx[domain]) { + return cb(null,undefined); + } + if (!this.idx[domain][path]) { + return cb(null,undefined); + } + return cb(null,this.idx[domain][path][key]||null); +}; + +MemoryCookieStore.prototype.findCookies = function(domain, path, cb) { + var results = []; + if (!domain) { + return cb(null,[]); + } + + var pathMatcher; + if (!path) { + // null means "all paths" + pathMatcher = function matchAll(domainIndex) { + for (var curPath in domainIndex) { + var pathIndex = domainIndex[curPath]; + for (var key in pathIndex) { + results.push(pathIndex[key]); + } + } + }; + + } else { + pathMatcher = function matchRFC(domainIndex) { + //NOTE: we should use path-match algorithm from S5.1.4 here + //(see : https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/canonical_cookie.cc#L299) + Object.keys(domainIndex).forEach(function (cookiePath) { + if (pathMatch(path, cookiePath)) { + var pathIndex = domainIndex[cookiePath]; + + for (var key in pathIndex) { + results.push(pathIndex[key]); + } + } + }); + }; + } + + var domains = permuteDomain(domain) || [domain]; + var idx = this.idx; + domains.forEach(function(curDomain) { + var domainIndex = idx[curDomain]; + if (!domainIndex) { + return; + } + pathMatcher(domainIndex); + }); + + cb(null,results); +}; + +MemoryCookieStore.prototype.putCookie = function(cookie, cb) { + if (!this.idx[cookie.domain]) { + this.idx[cookie.domain] = {}; + } + if (!this.idx[cookie.domain][cookie.path]) { + this.idx[cookie.domain][cookie.path] = {}; + } + this.idx[cookie.domain][cookie.path][cookie.key] = cookie; + cb(null); +}; + +MemoryCookieStore.prototype.updateCookie = function updateCookie(oldCookie, newCookie, cb) { + // updateCookie() may avoid updating cookies that are identical. For example, + // lastAccessed may not be important to some stores and an equality + // comparison could exclude that field. + this.putCookie(newCookie,cb); +}; + +MemoryCookieStore.prototype.removeCookie = function removeCookie(domain, path, key, cb) { + if (this.idx[domain] && this.idx[domain][path] && this.idx[domain][path][key]) { + delete this.idx[domain][path][key]; + } + cb(null); +}; + +MemoryCookieStore.prototype.removeCookies = function removeCookies(domain, path, cb) { + if (this.idx[domain]) { + if (path) { + delete this.idx[domain][path]; + } else { + delete this.idx[domain]; + } + } + return cb(null); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js new file mode 100644 index 0000000..f07aa2b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js @@ -0,0 +1,98 @@ +/**************************************************** + * AUTOMATICALLY GENERATED by generate-pubsuffix.js * + * DO NOT EDIT! * + ****************************************************/ + +"use strict"; + +var punycode = require('punycode'); + +module.exports.getPublicSuffix = function getPublicSuffix(domain) { + /*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + if (!domain) { + return null; + } + if (domain.match(/^\./)) { + return null; + } + var asciiDomain = punycode.toASCII(domain); + var converted = false; + if (asciiDomain !== domain) { + domain = asciiDomain; + converted = true; + } + if (index[domain]) { + return null; + } + + domain = domain.toLowerCase(); + var parts = domain.split('.').reverse(); + + var suffix = ''; + var suffixLen = 0; + for (var i=0; i suffixLen) { + var publicSuffix = parts.slice(0,suffixLen+1).reverse().join('.'); + return converted ? punycode.toUnicode(publicSuffix) : publicSuffix; + } + + return null; +}; + +// The following generated structure is used under the MPL version 1.1 +// See public-suffix.txt for more information + +var index = module.exports.index = Object.freeze( +{"ac":true,"com.ac":true,"edu.ac":true,"gov.ac":true,"net.ac":true,"mil.ac":true,"org.ac":true,"ad":true,"nom.ad":true,"ae":true,"co.ae":true,"net.ae":true,"org.ae":true,"sch.ae":true,"ac.ae":true,"gov.ae":true,"mil.ae":true,"aero":true,"accident-investigation.aero":true,"accident-prevention.aero":true,"aerobatic.aero":true,"aeroclub.aero":true,"aerodrome.aero":true,"agents.aero":true,"aircraft.aero":true,"airline.aero":true,"airport.aero":true,"air-surveillance.aero":true,"airtraffic.aero":true,"air-traffic-control.aero":true,"ambulance.aero":true,"amusement.aero":true,"association.aero":true,"author.aero":true,"ballooning.aero":true,"broker.aero":true,"caa.aero":true,"cargo.aero":true,"catering.aero":true,"certification.aero":true,"championship.aero":true,"charter.aero":true,"civilaviation.aero":true,"club.aero":true,"conference.aero":true,"consultant.aero":true,"consulting.aero":true,"control.aero":true,"council.aero":true,"crew.aero":true,"design.aero":true,"dgca.aero":true,"educator.aero":true,"emergency.aero":true,"engine.aero":true,"engineer.aero":true,"entertainment.aero":true,"equipment.aero":true,"exchange.aero":true,"express.aero":true,"federation.aero":true,"flight.aero":true,"freight.aero":true,"fuel.aero":true,"gliding.aero":true,"government.aero":true,"groundhandling.aero":true,"group.aero":true,"hanggliding.aero":true,"homebuilt.aero":true,"insurance.aero":true,"journal.aero":true,"journalist.aero":true,"leasing.aero":true,"logistics.aero":true,"magazine.aero":true,"maintenance.aero":true,"marketplace.aero":true,"media.aero":true,"microlight.aero":true,"modelling.aero":true,"navigation.aero":true,"parachuting.aero":true,"paragliding.aero":true,"passenger-association.aero":true,"pilot.aero":true,"press.aero":true,"production.aero":true,"recreation.aero":true,"repbody.aero":true,"res.aero":true,"research.aero":true,"rotorcraft.aero":true,"safety.aero":true,"scientist.aero":true,"services.aero":true,"show.aero":true,"skydiving.aero":true,"software.aero":true,"student.aero":true,"taxi.aero":true,"trader.aero":true,"trading.aero":true,"trainer.aero":true,"union.aero":true,"workinggroup.aero":true,"works.aero":true,"af":true,"gov.af":true,"com.af":true,"org.af":true,"net.af":true,"edu.af":true,"ag":true,"com.ag":true,"org.ag":true,"net.ag":true,"co.ag":true,"nom.ag":true,"ai":true,"off.ai":true,"com.ai":true,"net.ai":true,"org.ai":true,"al":true,"com.al":true,"edu.al":true,"gov.al":true,"mil.al":true,"net.al":true,"org.al":true,"am":true,"an":true,"com.an":true,"net.an":true,"org.an":true,"edu.an":true,"ao":true,"ed.ao":true,"gv.ao":true,"og.ao":true,"co.ao":true,"pb.ao":true,"it.ao":true,"aq":true,"ar":true,"com.ar":true,"edu.ar":true,"gob.ar":true,"gov.ar":true,"int.ar":true,"mil.ar":true,"net.ar":true,"org.ar":true,"tur.ar":true,"arpa":true,"e164.arpa":true,"in-addr.arpa":true,"ip6.arpa":true,"iris.arpa":true,"uri.arpa":true,"urn.arpa":true,"as":true,"gov.as":true,"asia":true,"at":true,"ac.at":true,"co.at":true,"gv.at":true,"or.at":true,"au":true,"com.au":true,"net.au":true,"org.au":true,"edu.au":true,"gov.au":true,"asn.au":true,"id.au":true,"info.au":true,"conf.au":true,"oz.au":true,"act.au":true,"nsw.au":true,"nt.au":true,"qld.au":true,"sa.au":true,"tas.au":true,"vic.au":true,"wa.au":true,"act.edu.au":true,"nsw.edu.au":true,"nt.edu.au":true,"qld.edu.au":true,"sa.edu.au":true,"tas.edu.au":true,"vic.edu.au":true,"wa.edu.au":true,"qld.gov.au":true,"sa.gov.au":true,"tas.gov.au":true,"vic.gov.au":true,"wa.gov.au":true,"aw":true,"com.aw":true,"ax":true,"az":true,"com.az":true,"net.az":true,"int.az":true,"gov.az":true,"org.az":true,"edu.az":true,"info.az":true,"pp.az":true,"mil.az":true,"name.az":true,"pro.az":true,"biz.az":true,"ba":true,"org.ba":true,"net.ba":true,"edu.ba":true,"gov.ba":true,"mil.ba":true,"unsa.ba":true,"unbi.ba":true,"co.ba":true,"com.ba":true,"rs.ba":true,"bb":true,"biz.bb":true,"co.bb":true,"com.bb":true,"edu.bb":true,"gov.bb":true,"info.bb":true,"net.bb":true,"org.bb":true,"store.bb":true,"tv.bb":true,"*.bd":true,"be":true,"ac.be":true,"bf":true,"gov.bf":true,"bg":true,"a.bg":true,"b.bg":true,"c.bg":true,"d.bg":true,"e.bg":true,"f.bg":true,"g.bg":true,"h.bg":true,"i.bg":true,"j.bg":true,"k.bg":true,"l.bg":true,"m.bg":true,"n.bg":true,"o.bg":true,"p.bg":true,"q.bg":true,"r.bg":true,"s.bg":true,"t.bg":true,"u.bg":true,"v.bg":true,"w.bg":true,"x.bg":true,"y.bg":true,"z.bg":true,"0.bg":true,"1.bg":true,"2.bg":true,"3.bg":true,"4.bg":true,"5.bg":true,"6.bg":true,"7.bg":true,"8.bg":true,"9.bg":true,"bh":true,"com.bh":true,"edu.bh":true,"net.bh":true,"org.bh":true,"gov.bh":true,"bi":true,"co.bi":true,"com.bi":true,"edu.bi":true,"or.bi":true,"org.bi":true,"biz":true,"bj":true,"asso.bj":true,"barreau.bj":true,"gouv.bj":true,"bm":true,"com.bm":true,"edu.bm":true,"gov.bm":true,"net.bm":true,"org.bm":true,"*.bn":true,"bo":true,"com.bo":true,"edu.bo":true,"gov.bo":true,"gob.bo":true,"int.bo":true,"org.bo":true,"net.bo":true,"mil.bo":true,"tv.bo":true,"br":true,"adm.br":true,"adv.br":true,"agr.br":true,"am.br":true,"arq.br":true,"art.br":true,"ato.br":true,"b.br":true,"bio.br":true,"blog.br":true,"bmd.br":true,"cim.br":true,"cng.br":true,"cnt.br":true,"com.br":true,"coop.br":true,"ecn.br":true,"eco.br":true,"edu.br":true,"emp.br":true,"eng.br":true,"esp.br":true,"etc.br":true,"eti.br":true,"far.br":true,"flog.br":true,"fm.br":true,"fnd.br":true,"fot.br":true,"fst.br":true,"g12.br":true,"ggf.br":true,"gov.br":true,"imb.br":true,"ind.br":true,"inf.br":true,"jor.br":true,"jus.br":true,"leg.br":true,"lel.br":true,"mat.br":true,"med.br":true,"mil.br":true,"mp.br":true,"mus.br":true,"net.br":true,"*.nom.br":true,"not.br":true,"ntr.br":true,"odo.br":true,"org.br":true,"ppg.br":true,"pro.br":true,"psc.br":true,"psi.br":true,"qsl.br":true,"radio.br":true,"rec.br":true,"slg.br":true,"srv.br":true,"taxi.br":true,"teo.br":true,"tmp.br":true,"trd.br":true,"tur.br":true,"tv.br":true,"vet.br":true,"vlog.br":true,"wiki.br":true,"zlg.br":true,"bs":true,"com.bs":true,"net.bs":true,"org.bs":true,"edu.bs":true,"gov.bs":true,"bt":true,"com.bt":true,"edu.bt":true,"gov.bt":true,"net.bt":true,"org.bt":true,"bv":true,"bw":true,"co.bw":true,"org.bw":true,"by":true,"gov.by":true,"mil.by":true,"com.by":true,"of.by":true,"bz":true,"com.bz":true,"net.bz":true,"org.bz":true,"edu.bz":true,"gov.bz":true,"ca":true,"ab.ca":true,"bc.ca":true,"mb.ca":true,"nb.ca":true,"nf.ca":true,"nl.ca":true,"ns.ca":true,"nt.ca":true,"nu.ca":true,"on.ca":true,"pe.ca":true,"qc.ca":true,"sk.ca":true,"yk.ca":true,"gc.ca":true,"cat":true,"cc":true,"cd":true,"gov.cd":true,"cf":true,"cg":true,"ch":true,"ci":true,"org.ci":true,"or.ci":true,"com.ci":true,"co.ci":true,"edu.ci":true,"ed.ci":true,"ac.ci":true,"net.ci":true,"go.ci":true,"asso.ci":true,"xn--aroport-bya.ci":true,"int.ci":true,"presse.ci":true,"md.ci":true,"gouv.ci":true,"*.ck":true,"www.ck":false,"cl":true,"gov.cl":true,"gob.cl":true,"co.cl":true,"mil.cl":true,"cm":true,"co.cm":true,"com.cm":true,"gov.cm":true,"net.cm":true,"cn":true,"ac.cn":true,"com.cn":true,"edu.cn":true,"gov.cn":true,"net.cn":true,"org.cn":true,"mil.cn":true,"xn--55qx5d.cn":true,"xn--io0a7i.cn":true,"xn--od0alg.cn":true,"ah.cn":true,"bj.cn":true,"cq.cn":true,"fj.cn":true,"gd.cn":true,"gs.cn":true,"gz.cn":true,"gx.cn":true,"ha.cn":true,"hb.cn":true,"he.cn":true,"hi.cn":true,"hl.cn":true,"hn.cn":true,"jl.cn":true,"js.cn":true,"jx.cn":true,"ln.cn":true,"nm.cn":true,"nx.cn":true,"qh.cn":true,"sc.cn":true,"sd.cn":true,"sh.cn":true,"sn.cn":true,"sx.cn":true,"tj.cn":true,"xj.cn":true,"xz.cn":true,"yn.cn":true,"zj.cn":true,"hk.cn":true,"mo.cn":true,"tw.cn":true,"co":true,"arts.co":true,"com.co":true,"edu.co":true,"firm.co":true,"gov.co":true,"info.co":true,"int.co":true,"mil.co":true,"net.co":true,"nom.co":true,"org.co":true,"rec.co":true,"web.co":true,"com":true,"coop":true,"cr":true,"ac.cr":true,"co.cr":true,"ed.cr":true,"fi.cr":true,"go.cr":true,"or.cr":true,"sa.cr":true,"cu":true,"com.cu":true,"edu.cu":true,"org.cu":true,"net.cu":true,"gov.cu":true,"inf.cu":true,"cv":true,"cw":true,"com.cw":true,"edu.cw":true,"net.cw":true,"org.cw":true,"cx":true,"gov.cx":true,"*.cy":true,"cz":true,"de":true,"dj":true,"dk":true,"dm":true,"com.dm":true,"net.dm":true,"org.dm":true,"edu.dm":true,"gov.dm":true,"do":true,"art.do":true,"com.do":true,"edu.do":true,"gob.do":true,"gov.do":true,"mil.do":true,"net.do":true,"org.do":true,"sld.do":true,"web.do":true,"dz":true,"com.dz":true,"org.dz":true,"net.dz":true,"gov.dz":true,"edu.dz":true,"asso.dz":true,"pol.dz":true,"art.dz":true,"ec":true,"com.ec":true,"info.ec":true,"net.ec":true,"fin.ec":true,"k12.ec":true,"med.ec":true,"pro.ec":true,"org.ec":true,"edu.ec":true,"gov.ec":true,"gob.ec":true,"mil.ec":true,"edu":true,"ee":true,"edu.ee":true,"gov.ee":true,"riik.ee":true,"lib.ee":true,"med.ee":true,"com.ee":true,"pri.ee":true,"aip.ee":true,"org.ee":true,"fie.ee":true,"eg":true,"com.eg":true,"edu.eg":true,"eun.eg":true,"gov.eg":true,"mil.eg":true,"name.eg":true,"net.eg":true,"org.eg":true,"sci.eg":true,"*.er":true,"es":true,"com.es":true,"nom.es":true,"org.es":true,"gob.es":true,"edu.es":true,"et":true,"com.et":true,"gov.et":true,"org.et":true,"edu.et":true,"biz.et":true,"name.et":true,"info.et":true,"eu":true,"fi":true,"aland.fi":true,"*.fj":true,"*.fk":true,"fm":true,"fo":true,"fr":true,"com.fr":true,"asso.fr":true,"nom.fr":true,"prd.fr":true,"presse.fr":true,"tm.fr":true,"aeroport.fr":true,"assedic.fr":true,"avocat.fr":true,"avoues.fr":true,"cci.fr":true,"chambagri.fr":true,"chirurgiens-dentistes.fr":true,"experts-comptables.fr":true,"geometre-expert.fr":true,"gouv.fr":true,"greta.fr":true,"huissier-justice.fr":true,"medecin.fr":true,"notaires.fr":true,"pharmacien.fr":true,"port.fr":true,"veterinaire.fr":true,"ga":true,"gb":true,"gd":true,"ge":true,"com.ge":true,"edu.ge":true,"gov.ge":true,"org.ge":true,"mil.ge":true,"net.ge":true,"pvt.ge":true,"gf":true,"gg":true,"co.gg":true,"net.gg":true,"org.gg":true,"gh":true,"com.gh":true,"edu.gh":true,"gov.gh":true,"org.gh":true,"mil.gh":true,"gi":true,"com.gi":true,"ltd.gi":true,"gov.gi":true,"mod.gi":true,"edu.gi":true,"org.gi":true,"gl":true,"gm":true,"gn":true,"ac.gn":true,"com.gn":true,"edu.gn":true,"gov.gn":true,"org.gn":true,"net.gn":true,"gov":true,"gp":true,"com.gp":true,"net.gp":true,"mobi.gp":true,"edu.gp":true,"org.gp":true,"asso.gp":true,"gq":true,"gr":true,"com.gr":true,"edu.gr":true,"net.gr":true,"org.gr":true,"gov.gr":true,"gs":true,"gt":true,"com.gt":true,"edu.gt":true,"gob.gt":true,"ind.gt":true,"mil.gt":true,"net.gt":true,"org.gt":true,"*.gu":true,"gw":true,"gy":true,"co.gy":true,"com.gy":true,"net.gy":true,"hk":true,"com.hk":true,"edu.hk":true,"gov.hk":true,"idv.hk":true,"net.hk":true,"org.hk":true,"xn--55qx5d.hk":true,"xn--wcvs22d.hk":true,"xn--lcvr32d.hk":true,"xn--mxtq1m.hk":true,"xn--gmqw5a.hk":true,"xn--ciqpn.hk":true,"xn--gmq050i.hk":true,"xn--zf0avx.hk":true,"xn--io0a7i.hk":true,"xn--mk0axi.hk":true,"xn--od0alg.hk":true,"xn--od0aq3b.hk":true,"xn--tn0ag.hk":true,"xn--uc0atv.hk":true,"xn--uc0ay4a.hk":true,"hm":true,"hn":true,"com.hn":true,"edu.hn":true,"org.hn":true,"net.hn":true,"mil.hn":true,"gob.hn":true,"hr":true,"iz.hr":true,"from.hr":true,"name.hr":true,"com.hr":true,"ht":true,"com.ht":true,"shop.ht":true,"firm.ht":true,"info.ht":true,"adult.ht":true,"net.ht":true,"pro.ht":true,"org.ht":true,"med.ht":true,"art.ht":true,"coop.ht":true,"pol.ht":true,"asso.ht":true,"edu.ht":true,"rel.ht":true,"gouv.ht":true,"perso.ht":true,"hu":true,"co.hu":true,"info.hu":true,"org.hu":true,"priv.hu":true,"sport.hu":true,"tm.hu":true,"2000.hu":true,"agrar.hu":true,"bolt.hu":true,"casino.hu":true,"city.hu":true,"erotica.hu":true,"erotika.hu":true,"film.hu":true,"forum.hu":true,"games.hu":true,"hotel.hu":true,"ingatlan.hu":true,"jogasz.hu":true,"konyvelo.hu":true,"lakas.hu":true,"media.hu":true,"news.hu":true,"reklam.hu":true,"sex.hu":true,"shop.hu":true,"suli.hu":true,"szex.hu":true,"tozsde.hu":true,"utazas.hu":true,"video.hu":true,"id":true,"ac.id":true,"biz.id":true,"co.id":true,"desa.id":true,"go.id":true,"mil.id":true,"my.id":true,"net.id":true,"or.id":true,"sch.id":true,"web.id":true,"ie":true,"gov.ie":true,"*.il":true,"im":true,"ac.im":true,"co.im":true,"com.im":true,"ltd.co.im":true,"net.im":true,"org.im":true,"plc.co.im":true,"tt.im":true,"tv.im":true,"in":true,"co.in":true,"firm.in":true,"net.in":true,"org.in":true,"gen.in":true,"ind.in":true,"nic.in":true,"ac.in":true,"edu.in":true,"res.in":true,"gov.in":true,"mil.in":true,"info":true,"int":true,"eu.int":true,"io":true,"com.io":true,"iq":true,"gov.iq":true,"edu.iq":true,"mil.iq":true,"com.iq":true,"org.iq":true,"net.iq":true,"ir":true,"ac.ir":true,"co.ir":true,"gov.ir":true,"id.ir":true,"net.ir":true,"org.ir":true,"sch.ir":true,"xn--mgba3a4f16a.ir":true,"xn--mgba3a4fra.ir":true,"is":true,"net.is":true,"com.is":true,"edu.is":true,"gov.is":true,"org.is":true,"int.is":true,"it":true,"gov.it":true,"edu.it":true,"abr.it":true,"abruzzo.it":true,"aosta-valley.it":true,"aostavalley.it":true,"bas.it":true,"basilicata.it":true,"cal.it":true,"calabria.it":true,"cam.it":true,"campania.it":true,"emilia-romagna.it":true,"emiliaromagna.it":true,"emr.it":true,"friuli-v-giulia.it":true,"friuli-ve-giulia.it":true,"friuli-vegiulia.it":true,"friuli-venezia-giulia.it":true,"friuli-veneziagiulia.it":true,"friuli-vgiulia.it":true,"friuliv-giulia.it":true,"friulive-giulia.it":true,"friulivegiulia.it":true,"friulivenezia-giulia.it":true,"friuliveneziagiulia.it":true,"friulivgiulia.it":true,"fvg.it":true,"laz.it":true,"lazio.it":true,"lig.it":true,"liguria.it":true,"lom.it":true,"lombardia.it":true,"lombardy.it":true,"lucania.it":true,"mar.it":true,"marche.it":true,"mol.it":true,"molise.it":true,"piedmont.it":true,"piemonte.it":true,"pmn.it":true,"pug.it":true,"puglia.it":true,"sar.it":true,"sardegna.it":true,"sardinia.it":true,"sic.it":true,"sicilia.it":true,"sicily.it":true,"taa.it":true,"tos.it":true,"toscana.it":true,"trentino-a-adige.it":true,"trentino-aadige.it":true,"trentino-alto-adige.it":true,"trentino-altoadige.it":true,"trentino-s-tirol.it":true,"trentino-stirol.it":true,"trentino-sud-tirol.it":true,"trentino-sudtirol.it":true,"trentino-sued-tirol.it":true,"trentino-suedtirol.it":true,"trentinoa-adige.it":true,"trentinoaadige.it":true,"trentinoalto-adige.it":true,"trentinoaltoadige.it":true,"trentinos-tirol.it":true,"trentinostirol.it":true,"trentinosud-tirol.it":true,"trentinosudtirol.it":true,"trentinosued-tirol.it":true,"trentinosuedtirol.it":true,"tuscany.it":true,"umb.it":true,"umbria.it":true,"val-d-aosta.it":true,"val-daosta.it":true,"vald-aosta.it":true,"valdaosta.it":true,"valle-aosta.it":true,"valle-d-aosta.it":true,"valle-daosta.it":true,"valleaosta.it":true,"valled-aosta.it":true,"valledaosta.it":true,"vallee-aoste.it":true,"valleeaoste.it":true,"vao.it":true,"vda.it":true,"ven.it":true,"veneto.it":true,"ag.it":true,"agrigento.it":true,"al.it":true,"alessandria.it":true,"alto-adige.it":true,"altoadige.it":true,"an.it":true,"ancona.it":true,"andria-barletta-trani.it":true,"andria-trani-barletta.it":true,"andriabarlettatrani.it":true,"andriatranibarletta.it":true,"ao.it":true,"aosta.it":true,"aoste.it":true,"ap.it":true,"aq.it":true,"aquila.it":true,"ar.it":true,"arezzo.it":true,"ascoli-piceno.it":true,"ascolipiceno.it":true,"asti.it":true,"at.it":true,"av.it":true,"avellino.it":true,"ba.it":true,"balsan.it":true,"bari.it":true,"barletta-trani-andria.it":true,"barlettatraniandria.it":true,"belluno.it":true,"benevento.it":true,"bergamo.it":true,"bg.it":true,"bi.it":true,"biella.it":true,"bl.it":true,"bn.it":true,"bo.it":true,"bologna.it":true,"bolzano.it":true,"bozen.it":true,"br.it":true,"brescia.it":true,"brindisi.it":true,"bs.it":true,"bt.it":true,"bz.it":true,"ca.it":true,"cagliari.it":true,"caltanissetta.it":true,"campidano-medio.it":true,"campidanomedio.it":true,"campobasso.it":true,"carbonia-iglesias.it":true,"carboniaiglesias.it":true,"carrara-massa.it":true,"carraramassa.it":true,"caserta.it":true,"catania.it":true,"catanzaro.it":true,"cb.it":true,"ce.it":true,"cesena-forli.it":true,"cesenaforli.it":true,"ch.it":true,"chieti.it":true,"ci.it":true,"cl.it":true,"cn.it":true,"co.it":true,"como.it":true,"cosenza.it":true,"cr.it":true,"cremona.it":true,"crotone.it":true,"cs.it":true,"ct.it":true,"cuneo.it":true,"cz.it":true,"dell-ogliastra.it":true,"dellogliastra.it":true,"en.it":true,"enna.it":true,"fc.it":true,"fe.it":true,"fermo.it":true,"ferrara.it":true,"fg.it":true,"fi.it":true,"firenze.it":true,"florence.it":true,"fm.it":true,"foggia.it":true,"forli-cesena.it":true,"forlicesena.it":true,"fr.it":true,"frosinone.it":true,"ge.it":true,"genoa.it":true,"genova.it":true,"go.it":true,"gorizia.it":true,"gr.it":true,"grosseto.it":true,"iglesias-carbonia.it":true,"iglesiascarbonia.it":true,"im.it":true,"imperia.it":true,"is.it":true,"isernia.it":true,"kr.it":true,"la-spezia.it":true,"laquila.it":true,"laspezia.it":true,"latina.it":true,"lc.it":true,"le.it":true,"lecce.it":true,"lecco.it":true,"li.it":true,"livorno.it":true,"lo.it":true,"lodi.it":true,"lt.it":true,"lu.it":true,"lucca.it":true,"macerata.it":true,"mantova.it":true,"massa-carrara.it":true,"massacarrara.it":true,"matera.it":true,"mb.it":true,"mc.it":true,"me.it":true,"medio-campidano.it":true,"mediocampidano.it":true,"messina.it":true,"mi.it":true,"milan.it":true,"milano.it":true,"mn.it":true,"mo.it":true,"modena.it":true,"monza-brianza.it":true,"monza-e-della-brianza.it":true,"monza.it":true,"monzabrianza.it":true,"monzaebrianza.it":true,"monzaedellabrianza.it":true,"ms.it":true,"mt.it":true,"na.it":true,"naples.it":true,"napoli.it":true,"no.it":true,"novara.it":true,"nu.it":true,"nuoro.it":true,"og.it":true,"ogliastra.it":true,"olbia-tempio.it":true,"olbiatempio.it":true,"or.it":true,"oristano.it":true,"ot.it":true,"pa.it":true,"padova.it":true,"padua.it":true,"palermo.it":true,"parma.it":true,"pavia.it":true,"pc.it":true,"pd.it":true,"pe.it":true,"perugia.it":true,"pesaro-urbino.it":true,"pesarourbino.it":true,"pescara.it":true,"pg.it":true,"pi.it":true,"piacenza.it":true,"pisa.it":true,"pistoia.it":true,"pn.it":true,"po.it":true,"pordenone.it":true,"potenza.it":true,"pr.it":true,"prato.it":true,"pt.it":true,"pu.it":true,"pv.it":true,"pz.it":true,"ra.it":true,"ragusa.it":true,"ravenna.it":true,"rc.it":true,"re.it":true,"reggio-calabria.it":true,"reggio-emilia.it":true,"reggiocalabria.it":true,"reggioemilia.it":true,"rg.it":true,"ri.it":true,"rieti.it":true,"rimini.it":true,"rm.it":true,"rn.it":true,"ro.it":true,"roma.it":true,"rome.it":true,"rovigo.it":true,"sa.it":true,"salerno.it":true,"sassari.it":true,"savona.it":true,"si.it":true,"siena.it":true,"siracusa.it":true,"so.it":true,"sondrio.it":true,"sp.it":true,"sr.it":true,"ss.it":true,"suedtirol.it":true,"sv.it":true,"ta.it":true,"taranto.it":true,"te.it":true,"tempio-olbia.it":true,"tempioolbia.it":true,"teramo.it":true,"terni.it":true,"tn.it":true,"to.it":true,"torino.it":true,"tp.it":true,"tr.it":true,"trani-andria-barletta.it":true,"trani-barletta-andria.it":true,"traniandriabarletta.it":true,"tranibarlettaandria.it":true,"trapani.it":true,"trentino.it":true,"trento.it":true,"treviso.it":true,"trieste.it":true,"ts.it":true,"turin.it":true,"tv.it":true,"ud.it":true,"udine.it":true,"urbino-pesaro.it":true,"urbinopesaro.it":true,"va.it":true,"varese.it":true,"vb.it":true,"vc.it":true,"ve.it":true,"venezia.it":true,"venice.it":true,"verbania.it":true,"vercelli.it":true,"verona.it":true,"vi.it":true,"vibo-valentia.it":true,"vibovalentia.it":true,"vicenza.it":true,"viterbo.it":true,"vr.it":true,"vs.it":true,"vt.it":true,"vv.it":true,"je":true,"co.je":true,"net.je":true,"org.je":true,"*.jm":true,"jo":true,"com.jo":true,"org.jo":true,"net.jo":true,"edu.jo":true,"sch.jo":true,"gov.jo":true,"mil.jo":true,"name.jo":true,"jobs":true,"jp":true,"ac.jp":true,"ad.jp":true,"co.jp":true,"ed.jp":true,"go.jp":true,"gr.jp":true,"lg.jp":true,"ne.jp":true,"or.jp":true,"aichi.jp":true,"akita.jp":true,"aomori.jp":true,"chiba.jp":true,"ehime.jp":true,"fukui.jp":true,"fukuoka.jp":true,"fukushima.jp":true,"gifu.jp":true,"gunma.jp":true,"hiroshima.jp":true,"hokkaido.jp":true,"hyogo.jp":true,"ibaraki.jp":true,"ishikawa.jp":true,"iwate.jp":true,"kagawa.jp":true,"kagoshima.jp":true,"kanagawa.jp":true,"kochi.jp":true,"kumamoto.jp":true,"kyoto.jp":true,"mie.jp":true,"miyagi.jp":true,"miyazaki.jp":true,"nagano.jp":true,"nagasaki.jp":true,"nara.jp":true,"niigata.jp":true,"oita.jp":true,"okayama.jp":true,"okinawa.jp":true,"osaka.jp":true,"saga.jp":true,"saitama.jp":true,"shiga.jp":true,"shimane.jp":true,"shizuoka.jp":true,"tochigi.jp":true,"tokushima.jp":true,"tokyo.jp":true,"tottori.jp":true,"toyama.jp":true,"wakayama.jp":true,"yamagata.jp":true,"yamaguchi.jp":true,"yamanashi.jp":true,"xn--4pvxs.jp":true,"xn--vgu402c.jp":true,"xn--c3s14m.jp":true,"xn--f6qx53a.jp":true,"xn--8pvr4u.jp":true,"xn--uist22h.jp":true,"xn--djrs72d6uy.jp":true,"xn--mkru45i.jp":true,"xn--0trq7p7nn.jp":true,"xn--8ltr62k.jp":true,"xn--2m4a15e.jp":true,"xn--efvn9s.jp":true,"xn--32vp30h.jp":true,"xn--4it797k.jp":true,"xn--1lqs71d.jp":true,"xn--5rtp49c.jp":true,"xn--5js045d.jp":true,"xn--ehqz56n.jp":true,"xn--1lqs03n.jp":true,"xn--qqqt11m.jp":true,"xn--kbrq7o.jp":true,"xn--pssu33l.jp":true,"xn--ntsq17g.jp":true,"xn--uisz3g.jp":true,"xn--6btw5a.jp":true,"xn--1ctwo.jp":true,"xn--6orx2r.jp":true,"xn--rht61e.jp":true,"xn--rht27z.jp":true,"xn--djty4k.jp":true,"xn--nit225k.jp":true,"xn--rht3d.jp":true,"xn--klty5x.jp":true,"xn--kltx9a.jp":true,"xn--kltp7d.jp":true,"xn--uuwu58a.jp":true,"xn--zbx025d.jp":true,"xn--ntso0iqx3a.jp":true,"xn--elqq16h.jp":true,"xn--4it168d.jp":true,"xn--klt787d.jp":true,"xn--rny31h.jp":true,"xn--7t0a264c.jp":true,"xn--5rtq34k.jp":true,"xn--k7yn95e.jp":true,"xn--tor131o.jp":true,"xn--d5qv7z876c.jp":true,"*.kawasaki.jp":true,"*.kitakyushu.jp":true,"*.kobe.jp":true,"*.nagoya.jp":true,"*.sapporo.jp":true,"*.sendai.jp":true,"*.yokohama.jp":true,"city.kawasaki.jp":false,"city.kitakyushu.jp":false,"city.kobe.jp":false,"city.nagoya.jp":false,"city.sapporo.jp":false,"city.sendai.jp":false,"city.yokohama.jp":false,"aisai.aichi.jp":true,"ama.aichi.jp":true,"anjo.aichi.jp":true,"asuke.aichi.jp":true,"chiryu.aichi.jp":true,"chita.aichi.jp":true,"fuso.aichi.jp":true,"gamagori.aichi.jp":true,"handa.aichi.jp":true,"hazu.aichi.jp":true,"hekinan.aichi.jp":true,"higashiura.aichi.jp":true,"ichinomiya.aichi.jp":true,"inazawa.aichi.jp":true,"inuyama.aichi.jp":true,"isshiki.aichi.jp":true,"iwakura.aichi.jp":true,"kanie.aichi.jp":true,"kariya.aichi.jp":true,"kasugai.aichi.jp":true,"kira.aichi.jp":true,"kiyosu.aichi.jp":true,"komaki.aichi.jp":true,"konan.aichi.jp":true,"kota.aichi.jp":true,"mihama.aichi.jp":true,"miyoshi.aichi.jp":true,"nishio.aichi.jp":true,"nisshin.aichi.jp":true,"obu.aichi.jp":true,"oguchi.aichi.jp":true,"oharu.aichi.jp":true,"okazaki.aichi.jp":true,"owariasahi.aichi.jp":true,"seto.aichi.jp":true,"shikatsu.aichi.jp":true,"shinshiro.aichi.jp":true,"shitara.aichi.jp":true,"tahara.aichi.jp":true,"takahama.aichi.jp":true,"tobishima.aichi.jp":true,"toei.aichi.jp":true,"togo.aichi.jp":true,"tokai.aichi.jp":true,"tokoname.aichi.jp":true,"toyoake.aichi.jp":true,"toyohashi.aichi.jp":true,"toyokawa.aichi.jp":true,"toyone.aichi.jp":true,"toyota.aichi.jp":true,"tsushima.aichi.jp":true,"yatomi.aichi.jp":true,"akita.akita.jp":true,"daisen.akita.jp":true,"fujisato.akita.jp":true,"gojome.akita.jp":true,"hachirogata.akita.jp":true,"happou.akita.jp":true,"higashinaruse.akita.jp":true,"honjo.akita.jp":true,"honjyo.akita.jp":true,"ikawa.akita.jp":true,"kamikoani.akita.jp":true,"kamioka.akita.jp":true,"katagami.akita.jp":true,"kazuno.akita.jp":true,"kitaakita.akita.jp":true,"kosaka.akita.jp":true,"kyowa.akita.jp":true,"misato.akita.jp":true,"mitane.akita.jp":true,"moriyoshi.akita.jp":true,"nikaho.akita.jp":true,"noshiro.akita.jp":true,"odate.akita.jp":true,"oga.akita.jp":true,"ogata.akita.jp":true,"semboku.akita.jp":true,"yokote.akita.jp":true,"yurihonjo.akita.jp":true,"aomori.aomori.jp":true,"gonohe.aomori.jp":true,"hachinohe.aomori.jp":true,"hashikami.aomori.jp":true,"hiranai.aomori.jp":true,"hirosaki.aomori.jp":true,"itayanagi.aomori.jp":true,"kuroishi.aomori.jp":true,"misawa.aomori.jp":true,"mutsu.aomori.jp":true,"nakadomari.aomori.jp":true,"noheji.aomori.jp":true,"oirase.aomori.jp":true,"owani.aomori.jp":true,"rokunohe.aomori.jp":true,"sannohe.aomori.jp":true,"shichinohe.aomori.jp":true,"shingo.aomori.jp":true,"takko.aomori.jp":true,"towada.aomori.jp":true,"tsugaru.aomori.jp":true,"tsuruta.aomori.jp":true,"abiko.chiba.jp":true,"asahi.chiba.jp":true,"chonan.chiba.jp":true,"chosei.chiba.jp":true,"choshi.chiba.jp":true,"chuo.chiba.jp":true,"funabashi.chiba.jp":true,"futtsu.chiba.jp":true,"hanamigawa.chiba.jp":true,"ichihara.chiba.jp":true,"ichikawa.chiba.jp":true,"ichinomiya.chiba.jp":true,"inzai.chiba.jp":true,"isumi.chiba.jp":true,"kamagaya.chiba.jp":true,"kamogawa.chiba.jp":true,"kashiwa.chiba.jp":true,"katori.chiba.jp":true,"katsuura.chiba.jp":true,"kimitsu.chiba.jp":true,"kisarazu.chiba.jp":true,"kozaki.chiba.jp":true,"kujukuri.chiba.jp":true,"kyonan.chiba.jp":true,"matsudo.chiba.jp":true,"midori.chiba.jp":true,"mihama.chiba.jp":true,"minamiboso.chiba.jp":true,"mobara.chiba.jp":true,"mutsuzawa.chiba.jp":true,"nagara.chiba.jp":true,"nagareyama.chiba.jp":true,"narashino.chiba.jp":true,"narita.chiba.jp":true,"noda.chiba.jp":true,"oamishirasato.chiba.jp":true,"omigawa.chiba.jp":true,"onjuku.chiba.jp":true,"otaki.chiba.jp":true,"sakae.chiba.jp":true,"sakura.chiba.jp":true,"shimofusa.chiba.jp":true,"shirako.chiba.jp":true,"shiroi.chiba.jp":true,"shisui.chiba.jp":true,"sodegaura.chiba.jp":true,"sosa.chiba.jp":true,"tako.chiba.jp":true,"tateyama.chiba.jp":true,"togane.chiba.jp":true,"tohnosho.chiba.jp":true,"tomisato.chiba.jp":true,"urayasu.chiba.jp":true,"yachimata.chiba.jp":true,"yachiyo.chiba.jp":true,"yokaichiba.chiba.jp":true,"yokoshibahikari.chiba.jp":true,"yotsukaido.chiba.jp":true,"ainan.ehime.jp":true,"honai.ehime.jp":true,"ikata.ehime.jp":true,"imabari.ehime.jp":true,"iyo.ehime.jp":true,"kamijima.ehime.jp":true,"kihoku.ehime.jp":true,"kumakogen.ehime.jp":true,"masaki.ehime.jp":true,"matsuno.ehime.jp":true,"matsuyama.ehime.jp":true,"namikata.ehime.jp":true,"niihama.ehime.jp":true,"ozu.ehime.jp":true,"saijo.ehime.jp":true,"seiyo.ehime.jp":true,"shikokuchuo.ehime.jp":true,"tobe.ehime.jp":true,"toon.ehime.jp":true,"uchiko.ehime.jp":true,"uwajima.ehime.jp":true,"yawatahama.ehime.jp":true,"echizen.fukui.jp":true,"eiheiji.fukui.jp":true,"fukui.fukui.jp":true,"ikeda.fukui.jp":true,"katsuyama.fukui.jp":true,"mihama.fukui.jp":true,"minamiechizen.fukui.jp":true,"obama.fukui.jp":true,"ohi.fukui.jp":true,"ono.fukui.jp":true,"sabae.fukui.jp":true,"sakai.fukui.jp":true,"takahama.fukui.jp":true,"tsuruga.fukui.jp":true,"wakasa.fukui.jp":true,"ashiya.fukuoka.jp":true,"buzen.fukuoka.jp":true,"chikugo.fukuoka.jp":true,"chikuho.fukuoka.jp":true,"chikujo.fukuoka.jp":true,"chikushino.fukuoka.jp":true,"chikuzen.fukuoka.jp":true,"chuo.fukuoka.jp":true,"dazaifu.fukuoka.jp":true,"fukuchi.fukuoka.jp":true,"hakata.fukuoka.jp":true,"higashi.fukuoka.jp":true,"hirokawa.fukuoka.jp":true,"hisayama.fukuoka.jp":true,"iizuka.fukuoka.jp":true,"inatsuki.fukuoka.jp":true,"kaho.fukuoka.jp":true,"kasuga.fukuoka.jp":true,"kasuya.fukuoka.jp":true,"kawara.fukuoka.jp":true,"keisen.fukuoka.jp":true,"koga.fukuoka.jp":true,"kurate.fukuoka.jp":true,"kurogi.fukuoka.jp":true,"kurume.fukuoka.jp":true,"minami.fukuoka.jp":true,"miyako.fukuoka.jp":true,"miyama.fukuoka.jp":true,"miyawaka.fukuoka.jp":true,"mizumaki.fukuoka.jp":true,"munakata.fukuoka.jp":true,"nakagawa.fukuoka.jp":true,"nakama.fukuoka.jp":true,"nishi.fukuoka.jp":true,"nogata.fukuoka.jp":true,"ogori.fukuoka.jp":true,"okagaki.fukuoka.jp":true,"okawa.fukuoka.jp":true,"oki.fukuoka.jp":true,"omuta.fukuoka.jp":true,"onga.fukuoka.jp":true,"onojo.fukuoka.jp":true,"oto.fukuoka.jp":true,"saigawa.fukuoka.jp":true,"sasaguri.fukuoka.jp":true,"shingu.fukuoka.jp":true,"shinyoshitomi.fukuoka.jp":true,"shonai.fukuoka.jp":true,"soeda.fukuoka.jp":true,"sue.fukuoka.jp":true,"tachiarai.fukuoka.jp":true,"tagawa.fukuoka.jp":true,"takata.fukuoka.jp":true,"toho.fukuoka.jp":true,"toyotsu.fukuoka.jp":true,"tsuiki.fukuoka.jp":true,"ukiha.fukuoka.jp":true,"umi.fukuoka.jp":true,"usui.fukuoka.jp":true,"yamada.fukuoka.jp":true,"yame.fukuoka.jp":true,"yanagawa.fukuoka.jp":true,"yukuhashi.fukuoka.jp":true,"aizubange.fukushima.jp":true,"aizumisato.fukushima.jp":true,"aizuwakamatsu.fukushima.jp":true,"asakawa.fukushima.jp":true,"bandai.fukushima.jp":true,"date.fukushima.jp":true,"fukushima.fukushima.jp":true,"furudono.fukushima.jp":true,"futaba.fukushima.jp":true,"hanawa.fukushima.jp":true,"higashi.fukushima.jp":true,"hirata.fukushima.jp":true,"hirono.fukushima.jp":true,"iitate.fukushima.jp":true,"inawashiro.fukushima.jp":true,"ishikawa.fukushima.jp":true,"iwaki.fukushima.jp":true,"izumizaki.fukushima.jp":true,"kagamiishi.fukushima.jp":true,"kaneyama.fukushima.jp":true,"kawamata.fukushima.jp":true,"kitakata.fukushima.jp":true,"kitashiobara.fukushima.jp":true,"koori.fukushima.jp":true,"koriyama.fukushima.jp":true,"kunimi.fukushima.jp":true,"miharu.fukushima.jp":true,"mishima.fukushima.jp":true,"namie.fukushima.jp":true,"nango.fukushima.jp":true,"nishiaizu.fukushima.jp":true,"nishigo.fukushima.jp":true,"okuma.fukushima.jp":true,"omotego.fukushima.jp":true,"ono.fukushima.jp":true,"otama.fukushima.jp":true,"samegawa.fukushima.jp":true,"shimogo.fukushima.jp":true,"shirakawa.fukushima.jp":true,"showa.fukushima.jp":true,"soma.fukushima.jp":true,"sukagawa.fukushima.jp":true,"taishin.fukushima.jp":true,"tamakawa.fukushima.jp":true,"tanagura.fukushima.jp":true,"tenei.fukushima.jp":true,"yabuki.fukushima.jp":true,"yamato.fukushima.jp":true,"yamatsuri.fukushima.jp":true,"yanaizu.fukushima.jp":true,"yugawa.fukushima.jp":true,"anpachi.gifu.jp":true,"ena.gifu.jp":true,"gifu.gifu.jp":true,"ginan.gifu.jp":true,"godo.gifu.jp":true,"gujo.gifu.jp":true,"hashima.gifu.jp":true,"hichiso.gifu.jp":true,"hida.gifu.jp":true,"higashishirakawa.gifu.jp":true,"ibigawa.gifu.jp":true,"ikeda.gifu.jp":true,"kakamigahara.gifu.jp":true,"kani.gifu.jp":true,"kasahara.gifu.jp":true,"kasamatsu.gifu.jp":true,"kawaue.gifu.jp":true,"kitagata.gifu.jp":true,"mino.gifu.jp":true,"minokamo.gifu.jp":true,"mitake.gifu.jp":true,"mizunami.gifu.jp":true,"motosu.gifu.jp":true,"nakatsugawa.gifu.jp":true,"ogaki.gifu.jp":true,"sakahogi.gifu.jp":true,"seki.gifu.jp":true,"sekigahara.gifu.jp":true,"shirakawa.gifu.jp":true,"tajimi.gifu.jp":true,"takayama.gifu.jp":true,"tarui.gifu.jp":true,"toki.gifu.jp":true,"tomika.gifu.jp":true,"wanouchi.gifu.jp":true,"yamagata.gifu.jp":true,"yaotsu.gifu.jp":true,"yoro.gifu.jp":true,"annaka.gunma.jp":true,"chiyoda.gunma.jp":true,"fujioka.gunma.jp":true,"higashiagatsuma.gunma.jp":true,"isesaki.gunma.jp":true,"itakura.gunma.jp":true,"kanna.gunma.jp":true,"kanra.gunma.jp":true,"katashina.gunma.jp":true,"kawaba.gunma.jp":true,"kiryu.gunma.jp":true,"kusatsu.gunma.jp":true,"maebashi.gunma.jp":true,"meiwa.gunma.jp":true,"midori.gunma.jp":true,"minakami.gunma.jp":true,"naganohara.gunma.jp":true,"nakanojo.gunma.jp":true,"nanmoku.gunma.jp":true,"numata.gunma.jp":true,"oizumi.gunma.jp":true,"ora.gunma.jp":true,"ota.gunma.jp":true,"shibukawa.gunma.jp":true,"shimonita.gunma.jp":true,"shinto.gunma.jp":true,"showa.gunma.jp":true,"takasaki.gunma.jp":true,"takayama.gunma.jp":true,"tamamura.gunma.jp":true,"tatebayashi.gunma.jp":true,"tomioka.gunma.jp":true,"tsukiyono.gunma.jp":true,"tsumagoi.gunma.jp":true,"ueno.gunma.jp":true,"yoshioka.gunma.jp":true,"asaminami.hiroshima.jp":true,"daiwa.hiroshima.jp":true,"etajima.hiroshima.jp":true,"fuchu.hiroshima.jp":true,"fukuyama.hiroshima.jp":true,"hatsukaichi.hiroshima.jp":true,"higashihiroshima.hiroshima.jp":true,"hongo.hiroshima.jp":true,"jinsekikogen.hiroshima.jp":true,"kaita.hiroshima.jp":true,"kui.hiroshima.jp":true,"kumano.hiroshima.jp":true,"kure.hiroshima.jp":true,"mihara.hiroshima.jp":true,"miyoshi.hiroshima.jp":true,"naka.hiroshima.jp":true,"onomichi.hiroshima.jp":true,"osakikamijima.hiroshima.jp":true,"otake.hiroshima.jp":true,"saka.hiroshima.jp":true,"sera.hiroshima.jp":true,"seranishi.hiroshima.jp":true,"shinichi.hiroshima.jp":true,"shobara.hiroshima.jp":true,"takehara.hiroshima.jp":true,"abashiri.hokkaido.jp":true,"abira.hokkaido.jp":true,"aibetsu.hokkaido.jp":true,"akabira.hokkaido.jp":true,"akkeshi.hokkaido.jp":true,"asahikawa.hokkaido.jp":true,"ashibetsu.hokkaido.jp":true,"ashoro.hokkaido.jp":true,"assabu.hokkaido.jp":true,"atsuma.hokkaido.jp":true,"bibai.hokkaido.jp":true,"biei.hokkaido.jp":true,"bifuka.hokkaido.jp":true,"bihoro.hokkaido.jp":true,"biratori.hokkaido.jp":true,"chippubetsu.hokkaido.jp":true,"chitose.hokkaido.jp":true,"date.hokkaido.jp":true,"ebetsu.hokkaido.jp":true,"embetsu.hokkaido.jp":true,"eniwa.hokkaido.jp":true,"erimo.hokkaido.jp":true,"esan.hokkaido.jp":true,"esashi.hokkaido.jp":true,"fukagawa.hokkaido.jp":true,"fukushima.hokkaido.jp":true,"furano.hokkaido.jp":true,"furubira.hokkaido.jp":true,"haboro.hokkaido.jp":true,"hakodate.hokkaido.jp":true,"hamatonbetsu.hokkaido.jp":true,"hidaka.hokkaido.jp":true,"higashikagura.hokkaido.jp":true,"higashikawa.hokkaido.jp":true,"hiroo.hokkaido.jp":true,"hokuryu.hokkaido.jp":true,"hokuto.hokkaido.jp":true,"honbetsu.hokkaido.jp":true,"horokanai.hokkaido.jp":true,"horonobe.hokkaido.jp":true,"ikeda.hokkaido.jp":true,"imakane.hokkaido.jp":true,"ishikari.hokkaido.jp":true,"iwamizawa.hokkaido.jp":true,"iwanai.hokkaido.jp":true,"kamifurano.hokkaido.jp":true,"kamikawa.hokkaido.jp":true,"kamishihoro.hokkaido.jp":true,"kamisunagawa.hokkaido.jp":true,"kamoenai.hokkaido.jp":true,"kayabe.hokkaido.jp":true,"kembuchi.hokkaido.jp":true,"kikonai.hokkaido.jp":true,"kimobetsu.hokkaido.jp":true,"kitahiroshima.hokkaido.jp":true,"kitami.hokkaido.jp":true,"kiyosato.hokkaido.jp":true,"koshimizu.hokkaido.jp":true,"kunneppu.hokkaido.jp":true,"kuriyama.hokkaido.jp":true,"kuromatsunai.hokkaido.jp":true,"kushiro.hokkaido.jp":true,"kutchan.hokkaido.jp":true,"kyowa.hokkaido.jp":true,"mashike.hokkaido.jp":true,"matsumae.hokkaido.jp":true,"mikasa.hokkaido.jp":true,"minamifurano.hokkaido.jp":true,"mombetsu.hokkaido.jp":true,"moseushi.hokkaido.jp":true,"mukawa.hokkaido.jp":true,"muroran.hokkaido.jp":true,"naie.hokkaido.jp":true,"nakagawa.hokkaido.jp":true,"nakasatsunai.hokkaido.jp":true,"nakatombetsu.hokkaido.jp":true,"nanae.hokkaido.jp":true,"nanporo.hokkaido.jp":true,"nayoro.hokkaido.jp":true,"nemuro.hokkaido.jp":true,"niikappu.hokkaido.jp":true,"niki.hokkaido.jp":true,"nishiokoppe.hokkaido.jp":true,"noboribetsu.hokkaido.jp":true,"numata.hokkaido.jp":true,"obihiro.hokkaido.jp":true,"obira.hokkaido.jp":true,"oketo.hokkaido.jp":true,"okoppe.hokkaido.jp":true,"otaru.hokkaido.jp":true,"otobe.hokkaido.jp":true,"otofuke.hokkaido.jp":true,"otoineppu.hokkaido.jp":true,"oumu.hokkaido.jp":true,"ozora.hokkaido.jp":true,"pippu.hokkaido.jp":true,"rankoshi.hokkaido.jp":true,"rebun.hokkaido.jp":true,"rikubetsu.hokkaido.jp":true,"rishiri.hokkaido.jp":true,"rishirifuji.hokkaido.jp":true,"saroma.hokkaido.jp":true,"sarufutsu.hokkaido.jp":true,"shakotan.hokkaido.jp":true,"shari.hokkaido.jp":true,"shibecha.hokkaido.jp":true,"shibetsu.hokkaido.jp":true,"shikabe.hokkaido.jp":true,"shikaoi.hokkaido.jp":true,"shimamaki.hokkaido.jp":true,"shimizu.hokkaido.jp":true,"shimokawa.hokkaido.jp":true,"shinshinotsu.hokkaido.jp":true,"shintoku.hokkaido.jp":true,"shiranuka.hokkaido.jp":true,"shiraoi.hokkaido.jp":true,"shiriuchi.hokkaido.jp":true,"sobetsu.hokkaido.jp":true,"sunagawa.hokkaido.jp":true,"taiki.hokkaido.jp":true,"takasu.hokkaido.jp":true,"takikawa.hokkaido.jp":true,"takinoue.hokkaido.jp":true,"teshikaga.hokkaido.jp":true,"tobetsu.hokkaido.jp":true,"tohma.hokkaido.jp":true,"tomakomai.hokkaido.jp":true,"tomari.hokkaido.jp":true,"toya.hokkaido.jp":true,"toyako.hokkaido.jp":true,"toyotomi.hokkaido.jp":true,"toyoura.hokkaido.jp":true,"tsubetsu.hokkaido.jp":true,"tsukigata.hokkaido.jp":true,"urakawa.hokkaido.jp":true,"urausu.hokkaido.jp":true,"uryu.hokkaido.jp":true,"utashinai.hokkaido.jp":true,"wakkanai.hokkaido.jp":true,"wassamu.hokkaido.jp":true,"yakumo.hokkaido.jp":true,"yoichi.hokkaido.jp":true,"aioi.hyogo.jp":true,"akashi.hyogo.jp":true,"ako.hyogo.jp":true,"amagasaki.hyogo.jp":true,"aogaki.hyogo.jp":true,"asago.hyogo.jp":true,"ashiya.hyogo.jp":true,"awaji.hyogo.jp":true,"fukusaki.hyogo.jp":true,"goshiki.hyogo.jp":true,"harima.hyogo.jp":true,"himeji.hyogo.jp":true,"ichikawa.hyogo.jp":true,"inagawa.hyogo.jp":true,"itami.hyogo.jp":true,"kakogawa.hyogo.jp":true,"kamigori.hyogo.jp":true,"kamikawa.hyogo.jp":true,"kasai.hyogo.jp":true,"kasuga.hyogo.jp":true,"kawanishi.hyogo.jp":true,"miki.hyogo.jp":true,"minamiawaji.hyogo.jp":true,"nishinomiya.hyogo.jp":true,"nishiwaki.hyogo.jp":true,"ono.hyogo.jp":true,"sanda.hyogo.jp":true,"sannan.hyogo.jp":true,"sasayama.hyogo.jp":true,"sayo.hyogo.jp":true,"shingu.hyogo.jp":true,"shinonsen.hyogo.jp":true,"shiso.hyogo.jp":true,"sumoto.hyogo.jp":true,"taishi.hyogo.jp":true,"taka.hyogo.jp":true,"takarazuka.hyogo.jp":true,"takasago.hyogo.jp":true,"takino.hyogo.jp":true,"tamba.hyogo.jp":true,"tatsuno.hyogo.jp":true,"toyooka.hyogo.jp":true,"yabu.hyogo.jp":true,"yashiro.hyogo.jp":true,"yoka.hyogo.jp":true,"yokawa.hyogo.jp":true,"ami.ibaraki.jp":true,"asahi.ibaraki.jp":true,"bando.ibaraki.jp":true,"chikusei.ibaraki.jp":true,"daigo.ibaraki.jp":true,"fujishiro.ibaraki.jp":true,"hitachi.ibaraki.jp":true,"hitachinaka.ibaraki.jp":true,"hitachiomiya.ibaraki.jp":true,"hitachiota.ibaraki.jp":true,"ibaraki.ibaraki.jp":true,"ina.ibaraki.jp":true,"inashiki.ibaraki.jp":true,"itako.ibaraki.jp":true,"iwama.ibaraki.jp":true,"joso.ibaraki.jp":true,"kamisu.ibaraki.jp":true,"kasama.ibaraki.jp":true,"kashima.ibaraki.jp":true,"kasumigaura.ibaraki.jp":true,"koga.ibaraki.jp":true,"miho.ibaraki.jp":true,"mito.ibaraki.jp":true,"moriya.ibaraki.jp":true,"naka.ibaraki.jp":true,"namegata.ibaraki.jp":true,"oarai.ibaraki.jp":true,"ogawa.ibaraki.jp":true,"omitama.ibaraki.jp":true,"ryugasaki.ibaraki.jp":true,"sakai.ibaraki.jp":true,"sakuragawa.ibaraki.jp":true,"shimodate.ibaraki.jp":true,"shimotsuma.ibaraki.jp":true,"shirosato.ibaraki.jp":true,"sowa.ibaraki.jp":true,"suifu.ibaraki.jp":true,"takahagi.ibaraki.jp":true,"tamatsukuri.ibaraki.jp":true,"tokai.ibaraki.jp":true,"tomobe.ibaraki.jp":true,"tone.ibaraki.jp":true,"toride.ibaraki.jp":true,"tsuchiura.ibaraki.jp":true,"tsukuba.ibaraki.jp":true,"uchihara.ibaraki.jp":true,"ushiku.ibaraki.jp":true,"yachiyo.ibaraki.jp":true,"yamagata.ibaraki.jp":true,"yawara.ibaraki.jp":true,"yuki.ibaraki.jp":true,"anamizu.ishikawa.jp":true,"hakui.ishikawa.jp":true,"hakusan.ishikawa.jp":true,"kaga.ishikawa.jp":true,"kahoku.ishikawa.jp":true,"kanazawa.ishikawa.jp":true,"kawakita.ishikawa.jp":true,"komatsu.ishikawa.jp":true,"nakanoto.ishikawa.jp":true,"nanao.ishikawa.jp":true,"nomi.ishikawa.jp":true,"nonoichi.ishikawa.jp":true,"noto.ishikawa.jp":true,"shika.ishikawa.jp":true,"suzu.ishikawa.jp":true,"tsubata.ishikawa.jp":true,"tsurugi.ishikawa.jp":true,"uchinada.ishikawa.jp":true,"wajima.ishikawa.jp":true,"fudai.iwate.jp":true,"fujisawa.iwate.jp":true,"hanamaki.iwate.jp":true,"hiraizumi.iwate.jp":true,"hirono.iwate.jp":true,"ichinohe.iwate.jp":true,"ichinoseki.iwate.jp":true,"iwaizumi.iwate.jp":true,"iwate.iwate.jp":true,"joboji.iwate.jp":true,"kamaishi.iwate.jp":true,"kanegasaki.iwate.jp":true,"karumai.iwate.jp":true,"kawai.iwate.jp":true,"kitakami.iwate.jp":true,"kuji.iwate.jp":true,"kunohe.iwate.jp":true,"kuzumaki.iwate.jp":true,"miyako.iwate.jp":true,"mizusawa.iwate.jp":true,"morioka.iwate.jp":true,"ninohe.iwate.jp":true,"noda.iwate.jp":true,"ofunato.iwate.jp":true,"oshu.iwate.jp":true,"otsuchi.iwate.jp":true,"rikuzentakata.iwate.jp":true,"shiwa.iwate.jp":true,"shizukuishi.iwate.jp":true,"sumita.iwate.jp":true,"tanohata.iwate.jp":true,"tono.iwate.jp":true,"yahaba.iwate.jp":true,"yamada.iwate.jp":true,"ayagawa.kagawa.jp":true,"higashikagawa.kagawa.jp":true,"kanonji.kagawa.jp":true,"kotohira.kagawa.jp":true,"manno.kagawa.jp":true,"marugame.kagawa.jp":true,"mitoyo.kagawa.jp":true,"naoshima.kagawa.jp":true,"sanuki.kagawa.jp":true,"tadotsu.kagawa.jp":true,"takamatsu.kagawa.jp":true,"tonosho.kagawa.jp":true,"uchinomi.kagawa.jp":true,"utazu.kagawa.jp":true,"zentsuji.kagawa.jp":true,"akune.kagoshima.jp":true,"amami.kagoshima.jp":true,"hioki.kagoshima.jp":true,"isa.kagoshima.jp":true,"isen.kagoshima.jp":true,"izumi.kagoshima.jp":true,"kagoshima.kagoshima.jp":true,"kanoya.kagoshima.jp":true,"kawanabe.kagoshima.jp":true,"kinko.kagoshima.jp":true,"kouyama.kagoshima.jp":true,"makurazaki.kagoshima.jp":true,"matsumoto.kagoshima.jp":true,"minamitane.kagoshima.jp":true,"nakatane.kagoshima.jp":true,"nishinoomote.kagoshima.jp":true,"satsumasendai.kagoshima.jp":true,"soo.kagoshima.jp":true,"tarumizu.kagoshima.jp":true,"yusui.kagoshima.jp":true,"aikawa.kanagawa.jp":true,"atsugi.kanagawa.jp":true,"ayase.kanagawa.jp":true,"chigasaki.kanagawa.jp":true,"ebina.kanagawa.jp":true,"fujisawa.kanagawa.jp":true,"hadano.kanagawa.jp":true,"hakone.kanagawa.jp":true,"hiratsuka.kanagawa.jp":true,"isehara.kanagawa.jp":true,"kaisei.kanagawa.jp":true,"kamakura.kanagawa.jp":true,"kiyokawa.kanagawa.jp":true,"matsuda.kanagawa.jp":true,"minamiashigara.kanagawa.jp":true,"miura.kanagawa.jp":true,"nakai.kanagawa.jp":true,"ninomiya.kanagawa.jp":true,"odawara.kanagawa.jp":true,"oi.kanagawa.jp":true,"oiso.kanagawa.jp":true,"sagamihara.kanagawa.jp":true,"samukawa.kanagawa.jp":true,"tsukui.kanagawa.jp":true,"yamakita.kanagawa.jp":true,"yamato.kanagawa.jp":true,"yokosuka.kanagawa.jp":true,"yugawara.kanagawa.jp":true,"zama.kanagawa.jp":true,"zushi.kanagawa.jp":true,"aki.kochi.jp":true,"geisei.kochi.jp":true,"hidaka.kochi.jp":true,"higashitsuno.kochi.jp":true,"ino.kochi.jp":true,"kagami.kochi.jp":true,"kami.kochi.jp":true,"kitagawa.kochi.jp":true,"kochi.kochi.jp":true,"mihara.kochi.jp":true,"motoyama.kochi.jp":true,"muroto.kochi.jp":true,"nahari.kochi.jp":true,"nakamura.kochi.jp":true,"nankoku.kochi.jp":true,"nishitosa.kochi.jp":true,"niyodogawa.kochi.jp":true,"ochi.kochi.jp":true,"okawa.kochi.jp":true,"otoyo.kochi.jp":true,"otsuki.kochi.jp":true,"sakawa.kochi.jp":true,"sukumo.kochi.jp":true,"susaki.kochi.jp":true,"tosa.kochi.jp":true,"tosashimizu.kochi.jp":true,"toyo.kochi.jp":true,"tsuno.kochi.jp":true,"umaji.kochi.jp":true,"yasuda.kochi.jp":true,"yusuhara.kochi.jp":true,"amakusa.kumamoto.jp":true,"arao.kumamoto.jp":true,"aso.kumamoto.jp":true,"choyo.kumamoto.jp":true,"gyokuto.kumamoto.jp":true,"hitoyoshi.kumamoto.jp":true,"kamiamakusa.kumamoto.jp":true,"kashima.kumamoto.jp":true,"kikuchi.kumamoto.jp":true,"kosa.kumamoto.jp":true,"kumamoto.kumamoto.jp":true,"mashiki.kumamoto.jp":true,"mifune.kumamoto.jp":true,"minamata.kumamoto.jp":true,"minamioguni.kumamoto.jp":true,"nagasu.kumamoto.jp":true,"nishihara.kumamoto.jp":true,"oguni.kumamoto.jp":true,"ozu.kumamoto.jp":true,"sumoto.kumamoto.jp":true,"takamori.kumamoto.jp":true,"uki.kumamoto.jp":true,"uto.kumamoto.jp":true,"yamaga.kumamoto.jp":true,"yamato.kumamoto.jp":true,"yatsushiro.kumamoto.jp":true,"ayabe.kyoto.jp":true,"fukuchiyama.kyoto.jp":true,"higashiyama.kyoto.jp":true,"ide.kyoto.jp":true,"ine.kyoto.jp":true,"joyo.kyoto.jp":true,"kameoka.kyoto.jp":true,"kamo.kyoto.jp":true,"kita.kyoto.jp":true,"kizu.kyoto.jp":true,"kumiyama.kyoto.jp":true,"kyotamba.kyoto.jp":true,"kyotanabe.kyoto.jp":true,"kyotango.kyoto.jp":true,"maizuru.kyoto.jp":true,"minami.kyoto.jp":true,"minamiyamashiro.kyoto.jp":true,"miyazu.kyoto.jp":true,"muko.kyoto.jp":true,"nagaokakyo.kyoto.jp":true,"nakagyo.kyoto.jp":true,"nantan.kyoto.jp":true,"oyamazaki.kyoto.jp":true,"sakyo.kyoto.jp":true,"seika.kyoto.jp":true,"tanabe.kyoto.jp":true,"uji.kyoto.jp":true,"ujitawara.kyoto.jp":true,"wazuka.kyoto.jp":true,"yamashina.kyoto.jp":true,"yawata.kyoto.jp":true,"asahi.mie.jp":true,"inabe.mie.jp":true,"ise.mie.jp":true,"kameyama.mie.jp":true,"kawagoe.mie.jp":true,"kiho.mie.jp":true,"kisosaki.mie.jp":true,"kiwa.mie.jp":true,"komono.mie.jp":true,"kumano.mie.jp":true,"kuwana.mie.jp":true,"matsusaka.mie.jp":true,"meiwa.mie.jp":true,"mihama.mie.jp":true,"minamiise.mie.jp":true,"misugi.mie.jp":true,"miyama.mie.jp":true,"nabari.mie.jp":true,"shima.mie.jp":true,"suzuka.mie.jp":true,"tado.mie.jp":true,"taiki.mie.jp":true,"taki.mie.jp":true,"tamaki.mie.jp":true,"toba.mie.jp":true,"tsu.mie.jp":true,"udono.mie.jp":true,"ureshino.mie.jp":true,"watarai.mie.jp":true,"yokkaichi.mie.jp":true,"furukawa.miyagi.jp":true,"higashimatsushima.miyagi.jp":true,"ishinomaki.miyagi.jp":true,"iwanuma.miyagi.jp":true,"kakuda.miyagi.jp":true,"kami.miyagi.jp":true,"kawasaki.miyagi.jp":true,"kesennuma.miyagi.jp":true,"marumori.miyagi.jp":true,"matsushima.miyagi.jp":true,"minamisanriku.miyagi.jp":true,"misato.miyagi.jp":true,"murata.miyagi.jp":true,"natori.miyagi.jp":true,"ogawara.miyagi.jp":true,"ohira.miyagi.jp":true,"onagawa.miyagi.jp":true,"osaki.miyagi.jp":true,"rifu.miyagi.jp":true,"semine.miyagi.jp":true,"shibata.miyagi.jp":true,"shichikashuku.miyagi.jp":true,"shikama.miyagi.jp":true,"shiogama.miyagi.jp":true,"shiroishi.miyagi.jp":true,"tagajo.miyagi.jp":true,"taiwa.miyagi.jp":true,"tome.miyagi.jp":true,"tomiya.miyagi.jp":true,"wakuya.miyagi.jp":true,"watari.miyagi.jp":true,"yamamoto.miyagi.jp":true,"zao.miyagi.jp":true,"aya.miyazaki.jp":true,"ebino.miyazaki.jp":true,"gokase.miyazaki.jp":true,"hyuga.miyazaki.jp":true,"kadogawa.miyazaki.jp":true,"kawaminami.miyazaki.jp":true,"kijo.miyazaki.jp":true,"kitagawa.miyazaki.jp":true,"kitakata.miyazaki.jp":true,"kitaura.miyazaki.jp":true,"kobayashi.miyazaki.jp":true,"kunitomi.miyazaki.jp":true,"kushima.miyazaki.jp":true,"mimata.miyazaki.jp":true,"miyakonojo.miyazaki.jp":true,"miyazaki.miyazaki.jp":true,"morotsuka.miyazaki.jp":true,"nichinan.miyazaki.jp":true,"nishimera.miyazaki.jp":true,"nobeoka.miyazaki.jp":true,"saito.miyazaki.jp":true,"shiiba.miyazaki.jp":true,"shintomi.miyazaki.jp":true,"takaharu.miyazaki.jp":true,"takanabe.miyazaki.jp":true,"takazaki.miyazaki.jp":true,"tsuno.miyazaki.jp":true,"achi.nagano.jp":true,"agematsu.nagano.jp":true,"anan.nagano.jp":true,"aoki.nagano.jp":true,"asahi.nagano.jp":true,"azumino.nagano.jp":true,"chikuhoku.nagano.jp":true,"chikuma.nagano.jp":true,"chino.nagano.jp":true,"fujimi.nagano.jp":true,"hakuba.nagano.jp":true,"hara.nagano.jp":true,"hiraya.nagano.jp":true,"iida.nagano.jp":true,"iijima.nagano.jp":true,"iiyama.nagano.jp":true,"iizuna.nagano.jp":true,"ikeda.nagano.jp":true,"ikusaka.nagano.jp":true,"ina.nagano.jp":true,"karuizawa.nagano.jp":true,"kawakami.nagano.jp":true,"kiso.nagano.jp":true,"kisofukushima.nagano.jp":true,"kitaaiki.nagano.jp":true,"komagane.nagano.jp":true,"komoro.nagano.jp":true,"matsukawa.nagano.jp":true,"matsumoto.nagano.jp":true,"miasa.nagano.jp":true,"minamiaiki.nagano.jp":true,"minamimaki.nagano.jp":true,"minamiminowa.nagano.jp":true,"minowa.nagano.jp":true,"miyada.nagano.jp":true,"miyota.nagano.jp":true,"mochizuki.nagano.jp":true,"nagano.nagano.jp":true,"nagawa.nagano.jp":true,"nagiso.nagano.jp":true,"nakagawa.nagano.jp":true,"nakano.nagano.jp":true,"nozawaonsen.nagano.jp":true,"obuse.nagano.jp":true,"ogawa.nagano.jp":true,"okaya.nagano.jp":true,"omachi.nagano.jp":true,"omi.nagano.jp":true,"ookuwa.nagano.jp":true,"ooshika.nagano.jp":true,"otaki.nagano.jp":true,"otari.nagano.jp":true,"sakae.nagano.jp":true,"sakaki.nagano.jp":true,"saku.nagano.jp":true,"sakuho.nagano.jp":true,"shimosuwa.nagano.jp":true,"shinanomachi.nagano.jp":true,"shiojiri.nagano.jp":true,"suwa.nagano.jp":true,"suzaka.nagano.jp":true,"takagi.nagano.jp":true,"takamori.nagano.jp":true,"takayama.nagano.jp":true,"tateshina.nagano.jp":true,"tatsuno.nagano.jp":true,"togakushi.nagano.jp":true,"togura.nagano.jp":true,"tomi.nagano.jp":true,"ueda.nagano.jp":true,"wada.nagano.jp":true,"yamagata.nagano.jp":true,"yamanouchi.nagano.jp":true,"yasaka.nagano.jp":true,"yasuoka.nagano.jp":true,"chijiwa.nagasaki.jp":true,"futsu.nagasaki.jp":true,"goto.nagasaki.jp":true,"hasami.nagasaki.jp":true,"hirado.nagasaki.jp":true,"iki.nagasaki.jp":true,"isahaya.nagasaki.jp":true,"kawatana.nagasaki.jp":true,"kuchinotsu.nagasaki.jp":true,"matsuura.nagasaki.jp":true,"nagasaki.nagasaki.jp":true,"obama.nagasaki.jp":true,"omura.nagasaki.jp":true,"oseto.nagasaki.jp":true,"saikai.nagasaki.jp":true,"sasebo.nagasaki.jp":true,"seihi.nagasaki.jp":true,"shimabara.nagasaki.jp":true,"shinkamigoto.nagasaki.jp":true,"togitsu.nagasaki.jp":true,"tsushima.nagasaki.jp":true,"unzen.nagasaki.jp":true,"ando.nara.jp":true,"gose.nara.jp":true,"heguri.nara.jp":true,"higashiyoshino.nara.jp":true,"ikaruga.nara.jp":true,"ikoma.nara.jp":true,"kamikitayama.nara.jp":true,"kanmaki.nara.jp":true,"kashiba.nara.jp":true,"kashihara.nara.jp":true,"katsuragi.nara.jp":true,"kawai.nara.jp":true,"kawakami.nara.jp":true,"kawanishi.nara.jp":true,"koryo.nara.jp":true,"kurotaki.nara.jp":true,"mitsue.nara.jp":true,"miyake.nara.jp":true,"nara.nara.jp":true,"nosegawa.nara.jp":true,"oji.nara.jp":true,"ouda.nara.jp":true,"oyodo.nara.jp":true,"sakurai.nara.jp":true,"sango.nara.jp":true,"shimoichi.nara.jp":true,"shimokitayama.nara.jp":true,"shinjo.nara.jp":true,"soni.nara.jp":true,"takatori.nara.jp":true,"tawaramoto.nara.jp":true,"tenkawa.nara.jp":true,"tenri.nara.jp":true,"uda.nara.jp":true,"yamatokoriyama.nara.jp":true,"yamatotakada.nara.jp":true,"yamazoe.nara.jp":true,"yoshino.nara.jp":true,"aga.niigata.jp":true,"agano.niigata.jp":true,"gosen.niigata.jp":true,"itoigawa.niigata.jp":true,"izumozaki.niigata.jp":true,"joetsu.niigata.jp":true,"kamo.niigata.jp":true,"kariwa.niigata.jp":true,"kashiwazaki.niigata.jp":true,"minamiuonuma.niigata.jp":true,"mitsuke.niigata.jp":true,"muika.niigata.jp":true,"murakami.niigata.jp":true,"myoko.niigata.jp":true,"nagaoka.niigata.jp":true,"niigata.niigata.jp":true,"ojiya.niigata.jp":true,"omi.niigata.jp":true,"sado.niigata.jp":true,"sanjo.niigata.jp":true,"seiro.niigata.jp":true,"seirou.niigata.jp":true,"sekikawa.niigata.jp":true,"shibata.niigata.jp":true,"tagami.niigata.jp":true,"tainai.niigata.jp":true,"tochio.niigata.jp":true,"tokamachi.niigata.jp":true,"tsubame.niigata.jp":true,"tsunan.niigata.jp":true,"uonuma.niigata.jp":true,"yahiko.niigata.jp":true,"yoita.niigata.jp":true,"yuzawa.niigata.jp":true,"beppu.oita.jp":true,"bungoono.oita.jp":true,"bungotakada.oita.jp":true,"hasama.oita.jp":true,"hiji.oita.jp":true,"himeshima.oita.jp":true,"hita.oita.jp":true,"kamitsue.oita.jp":true,"kokonoe.oita.jp":true,"kuju.oita.jp":true,"kunisaki.oita.jp":true,"kusu.oita.jp":true,"oita.oita.jp":true,"saiki.oita.jp":true,"taketa.oita.jp":true,"tsukumi.oita.jp":true,"usa.oita.jp":true,"usuki.oita.jp":true,"yufu.oita.jp":true,"akaiwa.okayama.jp":true,"asakuchi.okayama.jp":true,"bizen.okayama.jp":true,"hayashima.okayama.jp":true,"ibara.okayama.jp":true,"kagamino.okayama.jp":true,"kasaoka.okayama.jp":true,"kibichuo.okayama.jp":true,"kumenan.okayama.jp":true,"kurashiki.okayama.jp":true,"maniwa.okayama.jp":true,"misaki.okayama.jp":true,"nagi.okayama.jp":true,"niimi.okayama.jp":true,"nishiawakura.okayama.jp":true,"okayama.okayama.jp":true,"satosho.okayama.jp":true,"setouchi.okayama.jp":true,"shinjo.okayama.jp":true,"shoo.okayama.jp":true,"soja.okayama.jp":true,"takahashi.okayama.jp":true,"tamano.okayama.jp":true,"tsuyama.okayama.jp":true,"wake.okayama.jp":true,"yakage.okayama.jp":true,"aguni.okinawa.jp":true,"ginowan.okinawa.jp":true,"ginoza.okinawa.jp":true,"gushikami.okinawa.jp":true,"haebaru.okinawa.jp":true,"higashi.okinawa.jp":true,"hirara.okinawa.jp":true,"iheya.okinawa.jp":true,"ishigaki.okinawa.jp":true,"ishikawa.okinawa.jp":true,"itoman.okinawa.jp":true,"izena.okinawa.jp":true,"kadena.okinawa.jp":true,"kin.okinawa.jp":true,"kitadaito.okinawa.jp":true,"kitanakagusuku.okinawa.jp":true,"kumejima.okinawa.jp":true,"kunigami.okinawa.jp":true,"minamidaito.okinawa.jp":true,"motobu.okinawa.jp":true,"nago.okinawa.jp":true,"naha.okinawa.jp":true,"nakagusuku.okinawa.jp":true,"nakijin.okinawa.jp":true,"nanjo.okinawa.jp":true,"nishihara.okinawa.jp":true,"ogimi.okinawa.jp":true,"okinawa.okinawa.jp":true,"onna.okinawa.jp":true,"shimoji.okinawa.jp":true,"taketomi.okinawa.jp":true,"tarama.okinawa.jp":true,"tokashiki.okinawa.jp":true,"tomigusuku.okinawa.jp":true,"tonaki.okinawa.jp":true,"urasoe.okinawa.jp":true,"uruma.okinawa.jp":true,"yaese.okinawa.jp":true,"yomitan.okinawa.jp":true,"yonabaru.okinawa.jp":true,"yonaguni.okinawa.jp":true,"zamami.okinawa.jp":true,"abeno.osaka.jp":true,"chihayaakasaka.osaka.jp":true,"chuo.osaka.jp":true,"daito.osaka.jp":true,"fujiidera.osaka.jp":true,"habikino.osaka.jp":true,"hannan.osaka.jp":true,"higashiosaka.osaka.jp":true,"higashisumiyoshi.osaka.jp":true,"higashiyodogawa.osaka.jp":true,"hirakata.osaka.jp":true,"ibaraki.osaka.jp":true,"ikeda.osaka.jp":true,"izumi.osaka.jp":true,"izumiotsu.osaka.jp":true,"izumisano.osaka.jp":true,"kadoma.osaka.jp":true,"kaizuka.osaka.jp":true,"kanan.osaka.jp":true,"kashiwara.osaka.jp":true,"katano.osaka.jp":true,"kawachinagano.osaka.jp":true,"kishiwada.osaka.jp":true,"kita.osaka.jp":true,"kumatori.osaka.jp":true,"matsubara.osaka.jp":true,"minato.osaka.jp":true,"minoh.osaka.jp":true,"misaki.osaka.jp":true,"moriguchi.osaka.jp":true,"neyagawa.osaka.jp":true,"nishi.osaka.jp":true,"nose.osaka.jp":true,"osakasayama.osaka.jp":true,"sakai.osaka.jp":true,"sayama.osaka.jp":true,"sennan.osaka.jp":true,"settsu.osaka.jp":true,"shijonawate.osaka.jp":true,"shimamoto.osaka.jp":true,"suita.osaka.jp":true,"tadaoka.osaka.jp":true,"taishi.osaka.jp":true,"tajiri.osaka.jp":true,"takaishi.osaka.jp":true,"takatsuki.osaka.jp":true,"tondabayashi.osaka.jp":true,"toyonaka.osaka.jp":true,"toyono.osaka.jp":true,"yao.osaka.jp":true,"ariake.saga.jp":true,"arita.saga.jp":true,"fukudomi.saga.jp":true,"genkai.saga.jp":true,"hamatama.saga.jp":true,"hizen.saga.jp":true,"imari.saga.jp":true,"kamimine.saga.jp":true,"kanzaki.saga.jp":true,"karatsu.saga.jp":true,"kashima.saga.jp":true,"kitagata.saga.jp":true,"kitahata.saga.jp":true,"kiyama.saga.jp":true,"kouhoku.saga.jp":true,"kyuragi.saga.jp":true,"nishiarita.saga.jp":true,"ogi.saga.jp":true,"omachi.saga.jp":true,"ouchi.saga.jp":true,"saga.saga.jp":true,"shiroishi.saga.jp":true,"taku.saga.jp":true,"tara.saga.jp":true,"tosu.saga.jp":true,"yoshinogari.saga.jp":true,"arakawa.saitama.jp":true,"asaka.saitama.jp":true,"chichibu.saitama.jp":true,"fujimi.saitama.jp":true,"fujimino.saitama.jp":true,"fukaya.saitama.jp":true,"hanno.saitama.jp":true,"hanyu.saitama.jp":true,"hasuda.saitama.jp":true,"hatogaya.saitama.jp":true,"hatoyama.saitama.jp":true,"hidaka.saitama.jp":true,"higashichichibu.saitama.jp":true,"higashimatsuyama.saitama.jp":true,"honjo.saitama.jp":true,"ina.saitama.jp":true,"iruma.saitama.jp":true,"iwatsuki.saitama.jp":true,"kamiizumi.saitama.jp":true,"kamikawa.saitama.jp":true,"kamisato.saitama.jp":true,"kasukabe.saitama.jp":true,"kawagoe.saitama.jp":true,"kawaguchi.saitama.jp":true,"kawajima.saitama.jp":true,"kazo.saitama.jp":true,"kitamoto.saitama.jp":true,"koshigaya.saitama.jp":true,"kounosu.saitama.jp":true,"kuki.saitama.jp":true,"kumagaya.saitama.jp":true,"matsubushi.saitama.jp":true,"minano.saitama.jp":true,"misato.saitama.jp":true,"miyashiro.saitama.jp":true,"miyoshi.saitama.jp":true,"moroyama.saitama.jp":true,"nagatoro.saitama.jp":true,"namegawa.saitama.jp":true,"niiza.saitama.jp":true,"ogano.saitama.jp":true,"ogawa.saitama.jp":true,"ogose.saitama.jp":true,"okegawa.saitama.jp":true,"omiya.saitama.jp":true,"otaki.saitama.jp":true,"ranzan.saitama.jp":true,"ryokami.saitama.jp":true,"saitama.saitama.jp":true,"sakado.saitama.jp":true,"satte.saitama.jp":true,"sayama.saitama.jp":true,"shiki.saitama.jp":true,"shiraoka.saitama.jp":true,"soka.saitama.jp":true,"sugito.saitama.jp":true,"toda.saitama.jp":true,"tokigawa.saitama.jp":true,"tokorozawa.saitama.jp":true,"tsurugashima.saitama.jp":true,"urawa.saitama.jp":true,"warabi.saitama.jp":true,"yashio.saitama.jp":true,"yokoze.saitama.jp":true,"yono.saitama.jp":true,"yorii.saitama.jp":true,"yoshida.saitama.jp":true,"yoshikawa.saitama.jp":true,"yoshimi.saitama.jp":true,"aisho.shiga.jp":true,"gamo.shiga.jp":true,"higashiomi.shiga.jp":true,"hikone.shiga.jp":true,"koka.shiga.jp":true,"konan.shiga.jp":true,"kosei.shiga.jp":true,"koto.shiga.jp":true,"kusatsu.shiga.jp":true,"maibara.shiga.jp":true,"moriyama.shiga.jp":true,"nagahama.shiga.jp":true,"nishiazai.shiga.jp":true,"notogawa.shiga.jp":true,"omihachiman.shiga.jp":true,"otsu.shiga.jp":true,"ritto.shiga.jp":true,"ryuoh.shiga.jp":true,"takashima.shiga.jp":true,"takatsuki.shiga.jp":true,"torahime.shiga.jp":true,"toyosato.shiga.jp":true,"yasu.shiga.jp":true,"akagi.shimane.jp":true,"ama.shimane.jp":true,"gotsu.shimane.jp":true,"hamada.shimane.jp":true,"higashiizumo.shimane.jp":true,"hikawa.shimane.jp":true,"hikimi.shimane.jp":true,"izumo.shimane.jp":true,"kakinoki.shimane.jp":true,"masuda.shimane.jp":true,"matsue.shimane.jp":true,"misato.shimane.jp":true,"nishinoshima.shimane.jp":true,"ohda.shimane.jp":true,"okinoshima.shimane.jp":true,"okuizumo.shimane.jp":true,"shimane.shimane.jp":true,"tamayu.shimane.jp":true,"tsuwano.shimane.jp":true,"unnan.shimane.jp":true,"yakumo.shimane.jp":true,"yasugi.shimane.jp":true,"yatsuka.shimane.jp":true,"arai.shizuoka.jp":true,"atami.shizuoka.jp":true,"fuji.shizuoka.jp":true,"fujieda.shizuoka.jp":true,"fujikawa.shizuoka.jp":true,"fujinomiya.shizuoka.jp":true,"fukuroi.shizuoka.jp":true,"gotemba.shizuoka.jp":true,"haibara.shizuoka.jp":true,"hamamatsu.shizuoka.jp":true,"higashiizu.shizuoka.jp":true,"ito.shizuoka.jp":true,"iwata.shizuoka.jp":true,"izu.shizuoka.jp":true,"izunokuni.shizuoka.jp":true,"kakegawa.shizuoka.jp":true,"kannami.shizuoka.jp":true,"kawanehon.shizuoka.jp":true,"kawazu.shizuoka.jp":true,"kikugawa.shizuoka.jp":true,"kosai.shizuoka.jp":true,"makinohara.shizuoka.jp":true,"matsuzaki.shizuoka.jp":true,"minamiizu.shizuoka.jp":true,"mishima.shizuoka.jp":true,"morimachi.shizuoka.jp":true,"nishiizu.shizuoka.jp":true,"numazu.shizuoka.jp":true,"omaezaki.shizuoka.jp":true,"shimada.shizuoka.jp":true,"shimizu.shizuoka.jp":true,"shimoda.shizuoka.jp":true,"shizuoka.shizuoka.jp":true,"susono.shizuoka.jp":true,"yaizu.shizuoka.jp":true,"yoshida.shizuoka.jp":true,"ashikaga.tochigi.jp":true,"bato.tochigi.jp":true,"haga.tochigi.jp":true,"ichikai.tochigi.jp":true,"iwafune.tochigi.jp":true,"kaminokawa.tochigi.jp":true,"kanuma.tochigi.jp":true,"karasuyama.tochigi.jp":true,"kuroiso.tochigi.jp":true,"mashiko.tochigi.jp":true,"mibu.tochigi.jp":true,"moka.tochigi.jp":true,"motegi.tochigi.jp":true,"nasu.tochigi.jp":true,"nasushiobara.tochigi.jp":true,"nikko.tochigi.jp":true,"nishikata.tochigi.jp":true,"nogi.tochigi.jp":true,"ohira.tochigi.jp":true,"ohtawara.tochigi.jp":true,"oyama.tochigi.jp":true,"sakura.tochigi.jp":true,"sano.tochigi.jp":true,"shimotsuke.tochigi.jp":true,"shioya.tochigi.jp":true,"takanezawa.tochigi.jp":true,"tochigi.tochigi.jp":true,"tsuga.tochigi.jp":true,"ujiie.tochigi.jp":true,"utsunomiya.tochigi.jp":true,"yaita.tochigi.jp":true,"aizumi.tokushima.jp":true,"anan.tokushima.jp":true,"ichiba.tokushima.jp":true,"itano.tokushima.jp":true,"kainan.tokushima.jp":true,"komatsushima.tokushima.jp":true,"matsushige.tokushima.jp":true,"mima.tokushima.jp":true,"minami.tokushima.jp":true,"miyoshi.tokushima.jp":true,"mugi.tokushima.jp":true,"nakagawa.tokushima.jp":true,"naruto.tokushima.jp":true,"sanagochi.tokushima.jp":true,"shishikui.tokushima.jp":true,"tokushima.tokushima.jp":true,"wajiki.tokushima.jp":true,"adachi.tokyo.jp":true,"akiruno.tokyo.jp":true,"akishima.tokyo.jp":true,"aogashima.tokyo.jp":true,"arakawa.tokyo.jp":true,"bunkyo.tokyo.jp":true,"chiyoda.tokyo.jp":true,"chofu.tokyo.jp":true,"chuo.tokyo.jp":true,"edogawa.tokyo.jp":true,"fuchu.tokyo.jp":true,"fussa.tokyo.jp":true,"hachijo.tokyo.jp":true,"hachioji.tokyo.jp":true,"hamura.tokyo.jp":true,"higashikurume.tokyo.jp":true,"higashimurayama.tokyo.jp":true,"higashiyamato.tokyo.jp":true,"hino.tokyo.jp":true,"hinode.tokyo.jp":true,"hinohara.tokyo.jp":true,"inagi.tokyo.jp":true,"itabashi.tokyo.jp":true,"katsushika.tokyo.jp":true,"kita.tokyo.jp":true,"kiyose.tokyo.jp":true,"kodaira.tokyo.jp":true,"koganei.tokyo.jp":true,"kokubunji.tokyo.jp":true,"komae.tokyo.jp":true,"koto.tokyo.jp":true,"kouzushima.tokyo.jp":true,"kunitachi.tokyo.jp":true,"machida.tokyo.jp":true,"meguro.tokyo.jp":true,"minato.tokyo.jp":true,"mitaka.tokyo.jp":true,"mizuho.tokyo.jp":true,"musashimurayama.tokyo.jp":true,"musashino.tokyo.jp":true,"nakano.tokyo.jp":true,"nerima.tokyo.jp":true,"ogasawara.tokyo.jp":true,"okutama.tokyo.jp":true,"ome.tokyo.jp":true,"oshima.tokyo.jp":true,"ota.tokyo.jp":true,"setagaya.tokyo.jp":true,"shibuya.tokyo.jp":true,"shinagawa.tokyo.jp":true,"shinjuku.tokyo.jp":true,"suginami.tokyo.jp":true,"sumida.tokyo.jp":true,"tachikawa.tokyo.jp":true,"taito.tokyo.jp":true,"tama.tokyo.jp":true,"toshima.tokyo.jp":true,"chizu.tottori.jp":true,"hino.tottori.jp":true,"kawahara.tottori.jp":true,"koge.tottori.jp":true,"kotoura.tottori.jp":true,"misasa.tottori.jp":true,"nanbu.tottori.jp":true,"nichinan.tottori.jp":true,"sakaiminato.tottori.jp":true,"tottori.tottori.jp":true,"wakasa.tottori.jp":true,"yazu.tottori.jp":true,"yonago.tottori.jp":true,"asahi.toyama.jp":true,"fuchu.toyama.jp":true,"fukumitsu.toyama.jp":true,"funahashi.toyama.jp":true,"himi.toyama.jp":true,"imizu.toyama.jp":true,"inami.toyama.jp":true,"johana.toyama.jp":true,"kamiichi.toyama.jp":true,"kurobe.toyama.jp":true,"nakaniikawa.toyama.jp":true,"namerikawa.toyama.jp":true,"nanto.toyama.jp":true,"nyuzen.toyama.jp":true,"oyabe.toyama.jp":true,"taira.toyama.jp":true,"takaoka.toyama.jp":true,"tateyama.toyama.jp":true,"toga.toyama.jp":true,"tonami.toyama.jp":true,"toyama.toyama.jp":true,"unazuki.toyama.jp":true,"uozu.toyama.jp":true,"yamada.toyama.jp":true,"arida.wakayama.jp":true,"aridagawa.wakayama.jp":true,"gobo.wakayama.jp":true,"hashimoto.wakayama.jp":true,"hidaka.wakayama.jp":true,"hirogawa.wakayama.jp":true,"inami.wakayama.jp":true,"iwade.wakayama.jp":true,"kainan.wakayama.jp":true,"kamitonda.wakayama.jp":true,"katsuragi.wakayama.jp":true,"kimino.wakayama.jp":true,"kinokawa.wakayama.jp":true,"kitayama.wakayama.jp":true,"koya.wakayama.jp":true,"koza.wakayama.jp":true,"kozagawa.wakayama.jp":true,"kudoyama.wakayama.jp":true,"kushimoto.wakayama.jp":true,"mihama.wakayama.jp":true,"misato.wakayama.jp":true,"nachikatsuura.wakayama.jp":true,"shingu.wakayama.jp":true,"shirahama.wakayama.jp":true,"taiji.wakayama.jp":true,"tanabe.wakayama.jp":true,"wakayama.wakayama.jp":true,"yuasa.wakayama.jp":true,"yura.wakayama.jp":true,"asahi.yamagata.jp":true,"funagata.yamagata.jp":true,"higashine.yamagata.jp":true,"iide.yamagata.jp":true,"kahoku.yamagata.jp":true,"kaminoyama.yamagata.jp":true,"kaneyama.yamagata.jp":true,"kawanishi.yamagata.jp":true,"mamurogawa.yamagata.jp":true,"mikawa.yamagata.jp":true,"murayama.yamagata.jp":true,"nagai.yamagata.jp":true,"nakayama.yamagata.jp":true,"nanyo.yamagata.jp":true,"nishikawa.yamagata.jp":true,"obanazawa.yamagata.jp":true,"oe.yamagata.jp":true,"oguni.yamagata.jp":true,"ohkura.yamagata.jp":true,"oishida.yamagata.jp":true,"sagae.yamagata.jp":true,"sakata.yamagata.jp":true,"sakegawa.yamagata.jp":true,"shinjo.yamagata.jp":true,"shirataka.yamagata.jp":true,"shonai.yamagata.jp":true,"takahata.yamagata.jp":true,"tendo.yamagata.jp":true,"tozawa.yamagata.jp":true,"tsuruoka.yamagata.jp":true,"yamagata.yamagata.jp":true,"yamanobe.yamagata.jp":true,"yonezawa.yamagata.jp":true,"yuza.yamagata.jp":true,"abu.yamaguchi.jp":true,"hagi.yamaguchi.jp":true,"hikari.yamaguchi.jp":true,"hofu.yamaguchi.jp":true,"iwakuni.yamaguchi.jp":true,"kudamatsu.yamaguchi.jp":true,"mitou.yamaguchi.jp":true,"nagato.yamaguchi.jp":true,"oshima.yamaguchi.jp":true,"shimonoseki.yamaguchi.jp":true,"shunan.yamaguchi.jp":true,"tabuse.yamaguchi.jp":true,"tokuyama.yamaguchi.jp":true,"toyota.yamaguchi.jp":true,"ube.yamaguchi.jp":true,"yuu.yamaguchi.jp":true,"chuo.yamanashi.jp":true,"doshi.yamanashi.jp":true,"fuefuki.yamanashi.jp":true,"fujikawa.yamanashi.jp":true,"fujikawaguchiko.yamanashi.jp":true,"fujiyoshida.yamanashi.jp":true,"hayakawa.yamanashi.jp":true,"hokuto.yamanashi.jp":true,"ichikawamisato.yamanashi.jp":true,"kai.yamanashi.jp":true,"kofu.yamanashi.jp":true,"koshu.yamanashi.jp":true,"kosuge.yamanashi.jp":true,"minami-alps.yamanashi.jp":true,"minobu.yamanashi.jp":true,"nakamichi.yamanashi.jp":true,"nanbu.yamanashi.jp":true,"narusawa.yamanashi.jp":true,"nirasaki.yamanashi.jp":true,"nishikatsura.yamanashi.jp":true,"oshino.yamanashi.jp":true,"otsuki.yamanashi.jp":true,"showa.yamanashi.jp":true,"tabayama.yamanashi.jp":true,"tsuru.yamanashi.jp":true,"uenohara.yamanashi.jp":true,"yamanakako.yamanashi.jp":true,"yamanashi.yamanashi.jp":true,"*.ke":true,"kg":true,"org.kg":true,"net.kg":true,"com.kg":true,"edu.kg":true,"gov.kg":true,"mil.kg":true,"*.kh":true,"ki":true,"edu.ki":true,"biz.ki":true,"net.ki":true,"org.ki":true,"gov.ki":true,"info.ki":true,"com.ki":true,"km":true,"org.km":true,"nom.km":true,"gov.km":true,"prd.km":true,"tm.km":true,"edu.km":true,"mil.km":true,"ass.km":true,"com.km":true,"coop.km":true,"asso.km":true,"presse.km":true,"medecin.km":true,"notaires.km":true,"pharmaciens.km":true,"veterinaire.km":true,"gouv.km":true,"kn":true,"net.kn":true,"org.kn":true,"edu.kn":true,"gov.kn":true,"kp":true,"com.kp":true,"edu.kp":true,"gov.kp":true,"org.kp":true,"rep.kp":true,"tra.kp":true,"kr":true,"ac.kr":true,"co.kr":true,"es.kr":true,"go.kr":true,"hs.kr":true,"kg.kr":true,"mil.kr":true,"ms.kr":true,"ne.kr":true,"or.kr":true,"pe.kr":true,"re.kr":true,"sc.kr":true,"busan.kr":true,"chungbuk.kr":true,"chungnam.kr":true,"daegu.kr":true,"daejeon.kr":true,"gangwon.kr":true,"gwangju.kr":true,"gyeongbuk.kr":true,"gyeonggi.kr":true,"gyeongnam.kr":true,"incheon.kr":true,"jeju.kr":true,"jeonbuk.kr":true,"jeonnam.kr":true,"seoul.kr":true,"ulsan.kr":true,"*.kw":true,"ky":true,"edu.ky":true,"gov.ky":true,"com.ky":true,"org.ky":true,"net.ky":true,"kz":true,"org.kz":true,"edu.kz":true,"net.kz":true,"gov.kz":true,"mil.kz":true,"com.kz":true,"la":true,"int.la":true,"net.la":true,"info.la":true,"edu.la":true,"gov.la":true,"per.la":true,"com.la":true,"org.la":true,"lb":true,"com.lb":true,"edu.lb":true,"gov.lb":true,"net.lb":true,"org.lb":true,"lc":true,"com.lc":true,"net.lc":true,"co.lc":true,"org.lc":true,"edu.lc":true,"gov.lc":true,"li":true,"lk":true,"gov.lk":true,"sch.lk":true,"net.lk":true,"int.lk":true,"com.lk":true,"org.lk":true,"edu.lk":true,"ngo.lk":true,"soc.lk":true,"web.lk":true,"ltd.lk":true,"assn.lk":true,"grp.lk":true,"hotel.lk":true,"lr":true,"com.lr":true,"edu.lr":true,"gov.lr":true,"org.lr":true,"net.lr":true,"ls":true,"co.ls":true,"org.ls":true,"lt":true,"gov.lt":true,"lu":true,"lv":true,"com.lv":true,"edu.lv":true,"gov.lv":true,"org.lv":true,"mil.lv":true,"id.lv":true,"net.lv":true,"asn.lv":true,"conf.lv":true,"ly":true,"com.ly":true,"net.ly":true,"gov.ly":true,"plc.ly":true,"edu.ly":true,"sch.ly":true,"med.ly":true,"org.ly":true,"id.ly":true,"ma":true,"co.ma":true,"net.ma":true,"gov.ma":true,"org.ma":true,"ac.ma":true,"press.ma":true,"mc":true,"tm.mc":true,"asso.mc":true,"md":true,"me":true,"co.me":true,"net.me":true,"org.me":true,"edu.me":true,"ac.me":true,"gov.me":true,"its.me":true,"priv.me":true,"mg":true,"org.mg":true,"nom.mg":true,"gov.mg":true,"prd.mg":true,"tm.mg":true,"edu.mg":true,"mil.mg":true,"com.mg":true,"mh":true,"mil":true,"mk":true,"com.mk":true,"org.mk":true,"net.mk":true,"edu.mk":true,"gov.mk":true,"inf.mk":true,"name.mk":true,"ml":true,"com.ml":true,"edu.ml":true,"gouv.ml":true,"gov.ml":true,"net.ml":true,"org.ml":true,"presse.ml":true,"*.mm":true,"mn":true,"gov.mn":true,"edu.mn":true,"org.mn":true,"mo":true,"com.mo":true,"net.mo":true,"org.mo":true,"edu.mo":true,"gov.mo":true,"mobi":true,"mp":true,"mq":true,"mr":true,"gov.mr":true,"ms":true,"com.ms":true,"edu.ms":true,"gov.ms":true,"net.ms":true,"org.ms":true,"mt":true,"com.mt":true,"edu.mt":true,"net.mt":true,"org.mt":true,"mu":true,"com.mu":true,"net.mu":true,"org.mu":true,"gov.mu":true,"ac.mu":true,"co.mu":true,"or.mu":true,"museum":true,"academy.museum":true,"agriculture.museum":true,"air.museum":true,"airguard.museum":true,"alabama.museum":true,"alaska.museum":true,"amber.museum":true,"ambulance.museum":true,"american.museum":true,"americana.museum":true,"americanantiques.museum":true,"americanart.museum":true,"amsterdam.museum":true,"and.museum":true,"annefrank.museum":true,"anthro.museum":true,"anthropology.museum":true,"antiques.museum":true,"aquarium.museum":true,"arboretum.museum":true,"archaeological.museum":true,"archaeology.museum":true,"architecture.museum":true,"art.museum":true,"artanddesign.museum":true,"artcenter.museum":true,"artdeco.museum":true,"arteducation.museum":true,"artgallery.museum":true,"arts.museum":true,"artsandcrafts.museum":true,"asmatart.museum":true,"assassination.museum":true,"assisi.museum":true,"association.museum":true,"astronomy.museum":true,"atlanta.museum":true,"austin.museum":true,"australia.museum":true,"automotive.museum":true,"aviation.museum":true,"axis.museum":true,"badajoz.museum":true,"baghdad.museum":true,"bahn.museum":true,"bale.museum":true,"baltimore.museum":true,"barcelona.museum":true,"baseball.museum":true,"basel.museum":true,"baths.museum":true,"bauern.museum":true,"beauxarts.museum":true,"beeldengeluid.museum":true,"bellevue.museum":true,"bergbau.museum":true,"berkeley.museum":true,"berlin.museum":true,"bern.museum":true,"bible.museum":true,"bilbao.museum":true,"bill.museum":true,"birdart.museum":true,"birthplace.museum":true,"bonn.museum":true,"boston.museum":true,"botanical.museum":true,"botanicalgarden.museum":true,"botanicgarden.museum":true,"botany.museum":true,"brandywinevalley.museum":true,"brasil.museum":true,"bristol.museum":true,"british.museum":true,"britishcolumbia.museum":true,"broadcast.museum":true,"brunel.museum":true,"brussel.museum":true,"brussels.museum":true,"bruxelles.museum":true,"building.museum":true,"burghof.museum":true,"bus.museum":true,"bushey.museum":true,"cadaques.museum":true,"california.museum":true,"cambridge.museum":true,"can.museum":true,"canada.museum":true,"capebreton.museum":true,"carrier.museum":true,"cartoonart.museum":true,"casadelamoneda.museum":true,"castle.museum":true,"castres.museum":true,"celtic.museum":true,"center.museum":true,"chattanooga.museum":true,"cheltenham.museum":true,"chesapeakebay.museum":true,"chicago.museum":true,"children.museum":true,"childrens.museum":true,"childrensgarden.museum":true,"chiropractic.museum":true,"chocolate.museum":true,"christiansburg.museum":true,"cincinnati.museum":true,"cinema.museum":true,"circus.museum":true,"civilisation.museum":true,"civilization.museum":true,"civilwar.museum":true,"clinton.museum":true,"clock.museum":true,"coal.museum":true,"coastaldefence.museum":true,"cody.museum":true,"coldwar.museum":true,"collection.museum":true,"colonialwilliamsburg.museum":true,"coloradoplateau.museum":true,"columbia.museum":true,"columbus.museum":true,"communication.museum":true,"communications.museum":true,"community.museum":true,"computer.museum":true,"computerhistory.museum":true,"xn--comunicaes-v6a2o.museum":true,"contemporary.museum":true,"contemporaryart.museum":true,"convent.museum":true,"copenhagen.museum":true,"corporation.museum":true,"xn--correios-e-telecomunicaes-ghc29a.museum":true,"corvette.museum":true,"costume.museum":true,"countryestate.museum":true,"county.museum":true,"crafts.museum":true,"cranbrook.museum":true,"creation.museum":true,"cultural.museum":true,"culturalcenter.museum":true,"culture.museum":true,"cyber.museum":true,"cymru.museum":true,"dali.museum":true,"dallas.museum":true,"database.museum":true,"ddr.museum":true,"decorativearts.museum":true,"delaware.museum":true,"delmenhorst.museum":true,"denmark.museum":true,"depot.museum":true,"design.museum":true,"detroit.museum":true,"dinosaur.museum":true,"discovery.museum":true,"dolls.museum":true,"donostia.museum":true,"durham.museum":true,"eastafrica.museum":true,"eastcoast.museum":true,"education.museum":true,"educational.museum":true,"egyptian.museum":true,"eisenbahn.museum":true,"elburg.museum":true,"elvendrell.museum":true,"embroidery.museum":true,"encyclopedic.museum":true,"england.museum":true,"entomology.museum":true,"environment.museum":true,"environmentalconservation.museum":true,"epilepsy.museum":true,"essex.museum":true,"estate.museum":true,"ethnology.museum":true,"exeter.museum":true,"exhibition.museum":true,"family.museum":true,"farm.museum":true,"farmequipment.museum":true,"farmers.museum":true,"farmstead.museum":true,"field.museum":true,"figueres.museum":true,"filatelia.museum":true,"film.museum":true,"fineart.museum":true,"finearts.museum":true,"finland.museum":true,"flanders.museum":true,"florida.museum":true,"force.museum":true,"fortmissoula.museum":true,"fortworth.museum":true,"foundation.museum":true,"francaise.museum":true,"frankfurt.museum":true,"franziskaner.museum":true,"freemasonry.museum":true,"freiburg.museum":true,"fribourg.museum":true,"frog.museum":true,"fundacio.museum":true,"furniture.museum":true,"gallery.museum":true,"garden.museum":true,"gateway.museum":true,"geelvinck.museum":true,"gemological.museum":true,"geology.museum":true,"georgia.museum":true,"giessen.museum":true,"glas.museum":true,"glass.museum":true,"gorge.museum":true,"grandrapids.museum":true,"graz.museum":true,"guernsey.museum":true,"halloffame.museum":true,"hamburg.museum":true,"handson.museum":true,"harvestcelebration.museum":true,"hawaii.museum":true,"health.museum":true,"heimatunduhren.museum":true,"hellas.museum":true,"helsinki.museum":true,"hembygdsforbund.museum":true,"heritage.museum":true,"histoire.museum":true,"historical.museum":true,"historicalsociety.museum":true,"historichouses.museum":true,"historisch.museum":true,"historisches.museum":true,"history.museum":true,"historyofscience.museum":true,"horology.museum":true,"house.museum":true,"humanities.museum":true,"illustration.museum":true,"imageandsound.museum":true,"indian.museum":true,"indiana.museum":true,"indianapolis.museum":true,"indianmarket.museum":true,"intelligence.museum":true,"interactive.museum":true,"iraq.museum":true,"iron.museum":true,"isleofman.museum":true,"jamison.museum":true,"jefferson.museum":true,"jerusalem.museum":true,"jewelry.museum":true,"jewish.museum":true,"jewishart.museum":true,"jfk.museum":true,"journalism.museum":true,"judaica.museum":true,"judygarland.museum":true,"juedisches.museum":true,"juif.museum":true,"karate.museum":true,"karikatur.museum":true,"kids.museum":true,"koebenhavn.museum":true,"koeln.museum":true,"kunst.museum":true,"kunstsammlung.museum":true,"kunstunddesign.museum":true,"labor.museum":true,"labour.museum":true,"lajolla.museum":true,"lancashire.museum":true,"landes.museum":true,"lans.museum":true,"xn--lns-qla.museum":true,"larsson.museum":true,"lewismiller.museum":true,"lincoln.museum":true,"linz.museum":true,"living.museum":true,"livinghistory.museum":true,"localhistory.museum":true,"london.museum":true,"losangeles.museum":true,"louvre.museum":true,"loyalist.museum":true,"lucerne.museum":true,"luxembourg.museum":true,"luzern.museum":true,"mad.museum":true,"madrid.museum":true,"mallorca.museum":true,"manchester.museum":true,"mansion.museum":true,"mansions.museum":true,"manx.museum":true,"marburg.museum":true,"maritime.museum":true,"maritimo.museum":true,"maryland.museum":true,"marylhurst.museum":true,"media.museum":true,"medical.museum":true,"medizinhistorisches.museum":true,"meeres.museum":true,"memorial.museum":true,"mesaverde.museum":true,"michigan.museum":true,"midatlantic.museum":true,"military.museum":true,"mill.museum":true,"miners.museum":true,"mining.museum":true,"minnesota.museum":true,"missile.museum":true,"missoula.museum":true,"modern.museum":true,"moma.museum":true,"money.museum":true,"monmouth.museum":true,"monticello.museum":true,"montreal.museum":true,"moscow.museum":true,"motorcycle.museum":true,"muenchen.museum":true,"muenster.museum":true,"mulhouse.museum":true,"muncie.museum":true,"museet.museum":true,"museumcenter.museum":true,"museumvereniging.museum":true,"music.museum":true,"national.museum":true,"nationalfirearms.museum":true,"nationalheritage.museum":true,"nativeamerican.museum":true,"naturalhistory.museum":true,"naturalhistorymuseum.museum":true,"naturalsciences.museum":true,"nature.museum":true,"naturhistorisches.museum":true,"natuurwetenschappen.museum":true,"naumburg.museum":true,"naval.museum":true,"nebraska.museum":true,"neues.museum":true,"newhampshire.museum":true,"newjersey.museum":true,"newmexico.museum":true,"newport.museum":true,"newspaper.museum":true,"newyork.museum":true,"niepce.museum":true,"norfolk.museum":true,"north.museum":true,"nrw.museum":true,"nuernberg.museum":true,"nuremberg.museum":true,"nyc.museum":true,"nyny.museum":true,"oceanographic.museum":true,"oceanographique.museum":true,"omaha.museum":true,"online.museum":true,"ontario.museum":true,"openair.museum":true,"oregon.museum":true,"oregontrail.museum":true,"otago.museum":true,"oxford.museum":true,"pacific.museum":true,"paderborn.museum":true,"palace.museum":true,"paleo.museum":true,"palmsprings.museum":true,"panama.museum":true,"paris.museum":true,"pasadena.museum":true,"pharmacy.museum":true,"philadelphia.museum":true,"philadelphiaarea.museum":true,"philately.museum":true,"phoenix.museum":true,"photography.museum":true,"pilots.museum":true,"pittsburgh.museum":true,"planetarium.museum":true,"plantation.museum":true,"plants.museum":true,"plaza.museum":true,"portal.museum":true,"portland.museum":true,"portlligat.museum":true,"posts-and-telecommunications.museum":true,"preservation.museum":true,"presidio.museum":true,"press.museum":true,"project.museum":true,"public.museum":true,"pubol.museum":true,"quebec.museum":true,"railroad.museum":true,"railway.museum":true,"research.museum":true,"resistance.museum":true,"riodejaneiro.museum":true,"rochester.museum":true,"rockart.museum":true,"roma.museum":true,"russia.museum":true,"saintlouis.museum":true,"salem.museum":true,"salvadordali.museum":true,"salzburg.museum":true,"sandiego.museum":true,"sanfrancisco.museum":true,"santabarbara.museum":true,"santacruz.museum":true,"santafe.museum":true,"saskatchewan.museum":true,"satx.museum":true,"savannahga.museum":true,"schlesisches.museum":true,"schoenbrunn.museum":true,"schokoladen.museum":true,"school.museum":true,"schweiz.museum":true,"science.museum":true,"scienceandhistory.museum":true,"scienceandindustry.museum":true,"sciencecenter.museum":true,"sciencecenters.museum":true,"science-fiction.museum":true,"sciencehistory.museum":true,"sciences.museum":true,"sciencesnaturelles.museum":true,"scotland.museum":true,"seaport.museum":true,"settlement.museum":true,"settlers.museum":true,"shell.museum":true,"sherbrooke.museum":true,"sibenik.museum":true,"silk.museum":true,"ski.museum":true,"skole.museum":true,"society.museum":true,"sologne.museum":true,"soundandvision.museum":true,"southcarolina.museum":true,"southwest.museum":true,"space.museum":true,"spy.museum":true,"square.museum":true,"stadt.museum":true,"stalbans.museum":true,"starnberg.museum":true,"state.museum":true,"stateofdelaware.museum":true,"station.museum":true,"steam.museum":true,"steiermark.museum":true,"stjohn.museum":true,"stockholm.museum":true,"stpetersburg.museum":true,"stuttgart.museum":true,"suisse.museum":true,"surgeonshall.museum":true,"surrey.museum":true,"svizzera.museum":true,"sweden.museum":true,"sydney.museum":true,"tank.museum":true,"tcm.museum":true,"technology.museum":true,"telekommunikation.museum":true,"television.museum":true,"texas.museum":true,"textile.museum":true,"theater.museum":true,"time.museum":true,"timekeeping.museum":true,"topology.museum":true,"torino.museum":true,"touch.museum":true,"town.museum":true,"transport.museum":true,"tree.museum":true,"trolley.museum":true,"trust.museum":true,"trustee.museum":true,"uhren.museum":true,"ulm.museum":true,"undersea.museum":true,"university.museum":true,"usa.museum":true,"usantiques.museum":true,"usarts.museum":true,"uscountryestate.museum":true,"usculture.museum":true,"usdecorativearts.museum":true,"usgarden.museum":true,"ushistory.museum":true,"ushuaia.museum":true,"uslivinghistory.museum":true,"utah.museum":true,"uvic.museum":true,"valley.museum":true,"vantaa.museum":true,"versailles.museum":true,"viking.museum":true,"village.museum":true,"virginia.museum":true,"virtual.museum":true,"virtuel.museum":true,"vlaanderen.museum":true,"volkenkunde.museum":true,"wales.museum":true,"wallonie.museum":true,"war.museum":true,"washingtondc.museum":true,"watchandclock.museum":true,"watch-and-clock.museum":true,"western.museum":true,"westfalen.museum":true,"whaling.museum":true,"wildlife.museum":true,"williamsburg.museum":true,"windmill.museum":true,"workshop.museum":true,"york.museum":true,"yorkshire.museum":true,"yosemite.museum":true,"youth.museum":true,"zoological.museum":true,"zoology.museum":true,"xn--9dbhblg6di.museum":true,"xn--h1aegh.museum":true,"mv":true,"aero.mv":true,"biz.mv":true,"com.mv":true,"coop.mv":true,"edu.mv":true,"gov.mv":true,"info.mv":true,"int.mv":true,"mil.mv":true,"museum.mv":true,"name.mv":true,"net.mv":true,"org.mv":true,"pro.mv":true,"mw":true,"ac.mw":true,"biz.mw":true,"co.mw":true,"com.mw":true,"coop.mw":true,"edu.mw":true,"gov.mw":true,"int.mw":true,"museum.mw":true,"net.mw":true,"org.mw":true,"mx":true,"com.mx":true,"org.mx":true,"gob.mx":true,"edu.mx":true,"net.mx":true,"my":true,"com.my":true,"net.my":true,"org.my":true,"gov.my":true,"edu.my":true,"mil.my":true,"name.my":true,"*.mz":true,"teledata.mz":false,"na":true,"info.na":true,"pro.na":true,"name.na":true,"school.na":true,"or.na":true,"dr.na":true,"us.na":true,"mx.na":true,"ca.na":true,"in.na":true,"cc.na":true,"tv.na":true,"ws.na":true,"mobi.na":true,"co.na":true,"com.na":true,"org.na":true,"name":true,"nc":true,"asso.nc":true,"ne":true,"net":true,"nf":true,"com.nf":true,"net.nf":true,"per.nf":true,"rec.nf":true,"web.nf":true,"arts.nf":true,"firm.nf":true,"info.nf":true,"other.nf":true,"store.nf":true,"ng":true,"com.ng":true,"edu.ng":true,"name.ng":true,"net.ng":true,"org.ng":true,"sch.ng":true,"gov.ng":true,"mil.ng":true,"mobi.ng":true,"*.ni":true,"nl":true,"bv.nl":true,"no":true,"fhs.no":true,"vgs.no":true,"fylkesbibl.no":true,"folkebibl.no":true,"museum.no":true,"idrett.no":true,"priv.no":true,"mil.no":true,"stat.no":true,"dep.no":true,"kommune.no":true,"herad.no":true,"aa.no":true,"ah.no":true,"bu.no":true,"fm.no":true,"hl.no":true,"hm.no":true,"jan-mayen.no":true,"mr.no":true,"nl.no":true,"nt.no":true,"of.no":true,"ol.no":true,"oslo.no":true,"rl.no":true,"sf.no":true,"st.no":true,"svalbard.no":true,"tm.no":true,"tr.no":true,"va.no":true,"vf.no":true,"gs.aa.no":true,"gs.ah.no":true,"gs.bu.no":true,"gs.fm.no":true,"gs.hl.no":true,"gs.hm.no":true,"gs.jan-mayen.no":true,"gs.mr.no":true,"gs.nl.no":true,"gs.nt.no":true,"gs.of.no":true,"gs.ol.no":true,"gs.oslo.no":true,"gs.rl.no":true,"gs.sf.no":true,"gs.st.no":true,"gs.svalbard.no":true,"gs.tm.no":true,"gs.tr.no":true,"gs.va.no":true,"gs.vf.no":true,"akrehamn.no":true,"xn--krehamn-dxa.no":true,"algard.no":true,"xn--lgrd-poac.no":true,"arna.no":true,"brumunddal.no":true,"bryne.no":true,"bronnoysund.no":true,"xn--brnnysund-m8ac.no":true,"drobak.no":true,"xn--drbak-wua.no":true,"egersund.no":true,"fetsund.no":true,"floro.no":true,"xn--flor-jra.no":true,"fredrikstad.no":true,"hokksund.no":true,"honefoss.no":true,"xn--hnefoss-q1a.no":true,"jessheim.no":true,"jorpeland.no":true,"xn--jrpeland-54a.no":true,"kirkenes.no":true,"kopervik.no":true,"krokstadelva.no":true,"langevag.no":true,"xn--langevg-jxa.no":true,"leirvik.no":true,"mjondalen.no":true,"xn--mjndalen-64a.no":true,"mo-i-rana.no":true,"mosjoen.no":true,"xn--mosjen-eya.no":true,"nesoddtangen.no":true,"orkanger.no":true,"osoyro.no":true,"xn--osyro-wua.no":true,"raholt.no":true,"xn--rholt-mra.no":true,"sandnessjoen.no":true,"xn--sandnessjen-ogb.no":true,"skedsmokorset.no":true,"slattum.no":true,"spjelkavik.no":true,"stathelle.no":true,"stavern.no":true,"stjordalshalsen.no":true,"xn--stjrdalshalsen-sqb.no":true,"tananger.no":true,"tranby.no":true,"vossevangen.no":true,"afjord.no":true,"xn--fjord-lra.no":true,"agdenes.no":true,"al.no":true,"xn--l-1fa.no":true,"alesund.no":true,"xn--lesund-hua.no":true,"alstahaug.no":true,"alta.no":true,"xn--lt-liac.no":true,"alaheadju.no":true,"xn--laheadju-7ya.no":true,"alvdal.no":true,"amli.no":true,"xn--mli-tla.no":true,"amot.no":true,"xn--mot-tla.no":true,"andebu.no":true,"andoy.no":true,"xn--andy-ira.no":true,"andasuolo.no":true,"ardal.no":true,"xn--rdal-poa.no":true,"aremark.no":true,"arendal.no":true,"xn--s-1fa.no":true,"aseral.no":true,"xn--seral-lra.no":true,"asker.no":true,"askim.no":true,"askvoll.no":true,"askoy.no":true,"xn--asky-ira.no":true,"asnes.no":true,"xn--snes-poa.no":true,"audnedaln.no":true,"aukra.no":true,"aure.no":true,"aurland.no":true,"aurskog-holand.no":true,"xn--aurskog-hland-jnb.no":true,"austevoll.no":true,"austrheim.no":true,"averoy.no":true,"xn--avery-yua.no":true,"balestrand.no":true,"ballangen.no":true,"balat.no":true,"xn--blt-elab.no":true,"balsfjord.no":true,"bahccavuotna.no":true,"xn--bhccavuotna-k7a.no":true,"bamble.no":true,"bardu.no":true,"beardu.no":true,"beiarn.no":true,"bajddar.no":true,"xn--bjddar-pta.no":true,"baidar.no":true,"xn--bidr-5nac.no":true,"berg.no":true,"bergen.no":true,"berlevag.no":true,"xn--berlevg-jxa.no":true,"bearalvahki.no":true,"xn--bearalvhki-y4a.no":true,"bindal.no":true,"birkenes.no":true,"bjarkoy.no":true,"xn--bjarky-fya.no":true,"bjerkreim.no":true,"bjugn.no":true,"bodo.no":true,"xn--bod-2na.no":true,"badaddja.no":true,"xn--bdddj-mrabd.no":true,"budejju.no":true,"bokn.no":true,"bremanger.no":true,"bronnoy.no":true,"xn--brnny-wuac.no":true,"bygland.no":true,"bykle.no":true,"barum.no":true,"xn--brum-voa.no":true,"bo.telemark.no":true,"xn--b-5ga.telemark.no":true,"bo.nordland.no":true,"xn--b-5ga.nordland.no":true,"bievat.no":true,"xn--bievt-0qa.no":true,"bomlo.no":true,"xn--bmlo-gra.no":true,"batsfjord.no":true,"xn--btsfjord-9za.no":true,"bahcavuotna.no":true,"xn--bhcavuotna-s4a.no":true,"dovre.no":true,"drammen.no":true,"drangedal.no":true,"dyroy.no":true,"xn--dyry-ira.no":true,"donna.no":true,"xn--dnna-gra.no":true,"eid.no":true,"eidfjord.no":true,"eidsberg.no":true,"eidskog.no":true,"eidsvoll.no":true,"eigersund.no":true,"elverum.no":true,"enebakk.no":true,"engerdal.no":true,"etne.no":true,"etnedal.no":true,"evenes.no":true,"evenassi.no":true,"xn--eveni-0qa01ga.no":true,"evje-og-hornnes.no":true,"farsund.no":true,"fauske.no":true,"fuossko.no":true,"fuoisku.no":true,"fedje.no":true,"fet.no":true,"finnoy.no":true,"xn--finny-yua.no":true,"fitjar.no":true,"fjaler.no":true,"fjell.no":true,"flakstad.no":true,"flatanger.no":true,"flekkefjord.no":true,"flesberg.no":true,"flora.no":true,"fla.no":true,"xn--fl-zia.no":true,"folldal.no":true,"forsand.no":true,"fosnes.no":true,"frei.no":true,"frogn.no":true,"froland.no":true,"frosta.no":true,"frana.no":true,"xn--frna-woa.no":true,"froya.no":true,"xn--frya-hra.no":true,"fusa.no":true,"fyresdal.no":true,"forde.no":true,"xn--frde-gra.no":true,"gamvik.no":true,"gangaviika.no":true,"xn--ggaviika-8ya47h.no":true,"gaular.no":true,"gausdal.no":true,"gildeskal.no":true,"xn--gildeskl-g0a.no":true,"giske.no":true,"gjemnes.no":true,"gjerdrum.no":true,"gjerstad.no":true,"gjesdal.no":true,"gjovik.no":true,"xn--gjvik-wua.no":true,"gloppen.no":true,"gol.no":true,"gran.no":true,"grane.no":true,"granvin.no":true,"gratangen.no":true,"grimstad.no":true,"grong.no":true,"kraanghke.no":true,"xn--kranghke-b0a.no":true,"grue.no":true,"gulen.no":true,"hadsel.no":true,"halden.no":true,"halsa.no":true,"hamar.no":true,"hamaroy.no":true,"habmer.no":true,"xn--hbmer-xqa.no":true,"hapmir.no":true,"xn--hpmir-xqa.no":true,"hammerfest.no":true,"hammarfeasta.no":true,"xn--hmmrfeasta-s4ac.no":true,"haram.no":true,"hareid.no":true,"harstad.no":true,"hasvik.no":true,"aknoluokta.no":true,"xn--koluokta-7ya57h.no":true,"hattfjelldal.no":true,"aarborte.no":true,"haugesund.no":true,"hemne.no":true,"hemnes.no":true,"hemsedal.no":true,"heroy.more-og-romsdal.no":true,"xn--hery-ira.xn--mre-og-romsdal-qqb.no":true,"heroy.nordland.no":true,"xn--hery-ira.nordland.no":true,"hitra.no":true,"hjartdal.no":true,"hjelmeland.no":true,"hobol.no":true,"xn--hobl-ira.no":true,"hof.no":true,"hol.no":true,"hole.no":true,"holmestrand.no":true,"holtalen.no":true,"xn--holtlen-hxa.no":true,"hornindal.no":true,"horten.no":true,"hurdal.no":true,"hurum.no":true,"hvaler.no":true,"hyllestad.no":true,"hagebostad.no":true,"xn--hgebostad-g3a.no":true,"hoyanger.no":true,"xn--hyanger-q1a.no":true,"hoylandet.no":true,"xn--hylandet-54a.no":true,"ha.no":true,"xn--h-2fa.no":true,"ibestad.no":true,"inderoy.no":true,"xn--indery-fya.no":true,"iveland.no":true,"jevnaker.no":true,"jondal.no":true,"jolster.no":true,"xn--jlster-bya.no":true,"karasjok.no":true,"karasjohka.no":true,"xn--krjohka-hwab49j.no":true,"karlsoy.no":true,"galsa.no":true,"xn--gls-elac.no":true,"karmoy.no":true,"xn--karmy-yua.no":true,"kautokeino.no":true,"guovdageaidnu.no":true,"klepp.no":true,"klabu.no":true,"xn--klbu-woa.no":true,"kongsberg.no":true,"kongsvinger.no":true,"kragero.no":true,"xn--krager-gya.no":true,"kristiansand.no":true,"kristiansund.no":true,"krodsherad.no":true,"xn--krdsherad-m8a.no":true,"kvalsund.no":true,"rahkkeravju.no":true,"xn--rhkkervju-01af.no":true,"kvam.no":true,"kvinesdal.no":true,"kvinnherad.no":true,"kviteseid.no":true,"kvitsoy.no":true,"xn--kvitsy-fya.no":true,"kvafjord.no":true,"xn--kvfjord-nxa.no":true,"giehtavuoatna.no":true,"kvanangen.no":true,"xn--kvnangen-k0a.no":true,"navuotna.no":true,"xn--nvuotna-hwa.no":true,"kafjord.no":true,"xn--kfjord-iua.no":true,"gaivuotna.no":true,"xn--givuotna-8ya.no":true,"larvik.no":true,"lavangen.no":true,"lavagis.no":true,"loabat.no":true,"xn--loabt-0qa.no":true,"lebesby.no":true,"davvesiida.no":true,"leikanger.no":true,"leirfjord.no":true,"leka.no":true,"leksvik.no":true,"lenvik.no":true,"leangaviika.no":true,"xn--leagaviika-52b.no":true,"lesja.no":true,"levanger.no":true,"lier.no":true,"lierne.no":true,"lillehammer.no":true,"lillesand.no":true,"lindesnes.no":true,"lindas.no":true,"xn--linds-pra.no":true,"lom.no":true,"loppa.no":true,"lahppi.no":true,"xn--lhppi-xqa.no":true,"lund.no":true,"lunner.no":true,"luroy.no":true,"xn--lury-ira.no":true,"luster.no":true,"lyngdal.no":true,"lyngen.no":true,"ivgu.no":true,"lardal.no":true,"lerdal.no":true,"xn--lrdal-sra.no":true,"lodingen.no":true,"xn--ldingen-q1a.no":true,"lorenskog.no":true,"xn--lrenskog-54a.no":true,"loten.no":true,"xn--lten-gra.no":true,"malvik.no":true,"masoy.no":true,"xn--msy-ula0h.no":true,"muosat.no":true,"xn--muost-0qa.no":true,"mandal.no":true,"marker.no":true,"marnardal.no":true,"masfjorden.no":true,"meland.no":true,"meldal.no":true,"melhus.no":true,"meloy.no":true,"xn--mely-ira.no":true,"meraker.no":true,"xn--merker-kua.no":true,"moareke.no":true,"xn--moreke-jua.no":true,"midsund.no":true,"midtre-gauldal.no":true,"modalen.no":true,"modum.no":true,"molde.no":true,"moskenes.no":true,"moss.no":true,"mosvik.no":true,"malselv.no":true,"xn--mlselv-iua.no":true,"malatvuopmi.no":true,"xn--mlatvuopmi-s4a.no":true,"namdalseid.no":true,"aejrie.no":true,"namsos.no":true,"namsskogan.no":true,"naamesjevuemie.no":true,"xn--nmesjevuemie-tcba.no":true,"laakesvuemie.no":true,"nannestad.no":true,"narvik.no":true,"narviika.no":true,"naustdal.no":true,"nedre-eiker.no":true,"nes.akershus.no":true,"nes.buskerud.no":true,"nesna.no":true,"nesodden.no":true,"nesseby.no":true,"unjarga.no":true,"xn--unjrga-rta.no":true,"nesset.no":true,"nissedal.no":true,"nittedal.no":true,"nord-aurdal.no":true,"nord-fron.no":true,"nord-odal.no":true,"norddal.no":true,"nordkapp.no":true,"davvenjarga.no":true,"xn--davvenjrga-y4a.no":true,"nordre-land.no":true,"nordreisa.no":true,"raisa.no":true,"xn--risa-5na.no":true,"nore-og-uvdal.no":true,"notodden.no":true,"naroy.no":true,"xn--nry-yla5g.no":true,"notteroy.no":true,"xn--nttery-byae.no":true,"odda.no":true,"oksnes.no":true,"xn--ksnes-uua.no":true,"oppdal.no":true,"oppegard.no":true,"xn--oppegrd-ixa.no":true,"orkdal.no":true,"orland.no":true,"xn--rland-uua.no":true,"orskog.no":true,"xn--rskog-uua.no":true,"orsta.no":true,"xn--rsta-fra.no":true,"os.hedmark.no":true,"os.hordaland.no":true,"osen.no":true,"osteroy.no":true,"xn--ostery-fya.no":true,"ostre-toten.no":true,"xn--stre-toten-zcb.no":true,"overhalla.no":true,"ovre-eiker.no":true,"xn--vre-eiker-k8a.no":true,"oyer.no":true,"xn--yer-zna.no":true,"oygarden.no":true,"xn--ygarden-p1a.no":true,"oystre-slidre.no":true,"xn--ystre-slidre-ujb.no":true,"porsanger.no":true,"porsangu.no":true,"xn--porsgu-sta26f.no":true,"porsgrunn.no":true,"radoy.no":true,"xn--rady-ira.no":true,"rakkestad.no":true,"rana.no":true,"ruovat.no":true,"randaberg.no":true,"rauma.no":true,"rendalen.no":true,"rennebu.no":true,"rennesoy.no":true,"xn--rennesy-v1a.no":true,"rindal.no":true,"ringebu.no":true,"ringerike.no":true,"ringsaker.no":true,"rissa.no":true,"risor.no":true,"xn--risr-ira.no":true,"roan.no":true,"rollag.no":true,"rygge.no":true,"ralingen.no":true,"xn--rlingen-mxa.no":true,"rodoy.no":true,"xn--rdy-0nab.no":true,"romskog.no":true,"xn--rmskog-bya.no":true,"roros.no":true,"xn--rros-gra.no":true,"rost.no":true,"xn--rst-0na.no":true,"royken.no":true,"xn--ryken-vua.no":true,"royrvik.no":true,"xn--ryrvik-bya.no":true,"rade.no":true,"xn--rde-ula.no":true,"salangen.no":true,"siellak.no":true,"saltdal.no":true,"salat.no":true,"xn--slt-elab.no":true,"xn--slat-5na.no":true,"samnanger.no":true,"sande.more-og-romsdal.no":true,"sande.xn--mre-og-romsdal-qqb.no":true,"sande.vestfold.no":true,"sandefjord.no":true,"sandnes.no":true,"sandoy.no":true,"xn--sandy-yua.no":true,"sarpsborg.no":true,"sauda.no":true,"sauherad.no":true,"sel.no":true,"selbu.no":true,"selje.no":true,"seljord.no":true,"sigdal.no":true,"siljan.no":true,"sirdal.no":true,"skaun.no":true,"skedsmo.no":true,"ski.no":true,"skien.no":true,"skiptvet.no":true,"skjervoy.no":true,"xn--skjervy-v1a.no":true,"skierva.no":true,"xn--skierv-uta.no":true,"skjak.no":true,"xn--skjk-soa.no":true,"skodje.no":true,"skanland.no":true,"xn--sknland-fxa.no":true,"skanit.no":true,"xn--sknit-yqa.no":true,"smola.no":true,"xn--smla-hra.no":true,"snillfjord.no":true,"snasa.no":true,"xn--snsa-roa.no":true,"snoasa.no":true,"snaase.no":true,"xn--snase-nra.no":true,"sogndal.no":true,"sokndal.no":true,"sola.no":true,"solund.no":true,"songdalen.no":true,"sortland.no":true,"spydeberg.no":true,"stange.no":true,"stavanger.no":true,"steigen.no":true,"steinkjer.no":true,"stjordal.no":true,"xn--stjrdal-s1a.no":true,"stokke.no":true,"stor-elvdal.no":true,"stord.no":true,"stordal.no":true,"storfjord.no":true,"omasvuotna.no":true,"strand.no":true,"stranda.no":true,"stryn.no":true,"sula.no":true,"suldal.no":true,"sund.no":true,"sunndal.no":true,"surnadal.no":true,"sveio.no":true,"svelvik.no":true,"sykkylven.no":true,"sogne.no":true,"xn--sgne-gra.no":true,"somna.no":true,"xn--smna-gra.no":true,"sondre-land.no":true,"xn--sndre-land-0cb.no":true,"sor-aurdal.no":true,"xn--sr-aurdal-l8a.no":true,"sor-fron.no":true,"xn--sr-fron-q1a.no":true,"sor-odal.no":true,"xn--sr-odal-q1a.no":true,"sor-varanger.no":true,"xn--sr-varanger-ggb.no":true,"matta-varjjat.no":true,"xn--mtta-vrjjat-k7af.no":true,"sorfold.no":true,"xn--srfold-bya.no":true,"sorreisa.no":true,"xn--srreisa-q1a.no":true,"sorum.no":true,"xn--srum-gra.no":true,"tana.no":true,"deatnu.no":true,"time.no":true,"tingvoll.no":true,"tinn.no":true,"tjeldsund.no":true,"dielddanuorri.no":true,"tjome.no":true,"xn--tjme-hra.no":true,"tokke.no":true,"tolga.no":true,"torsken.no":true,"tranoy.no":true,"xn--trany-yua.no":true,"tromso.no":true,"xn--troms-zua.no":true,"tromsa.no":true,"romsa.no":true,"trondheim.no":true,"troandin.no":true,"trysil.no":true,"trana.no":true,"xn--trna-woa.no":true,"trogstad.no":true,"xn--trgstad-r1a.no":true,"tvedestrand.no":true,"tydal.no":true,"tynset.no":true,"tysfjord.no":true,"divtasvuodna.no":true,"divttasvuotna.no":true,"tysnes.no":true,"tysvar.no":true,"xn--tysvr-vra.no":true,"tonsberg.no":true,"xn--tnsberg-q1a.no":true,"ullensaker.no":true,"ullensvang.no":true,"ulvik.no":true,"utsira.no":true,"vadso.no":true,"xn--vads-jra.no":true,"cahcesuolo.no":true,"xn--hcesuolo-7ya35b.no":true,"vaksdal.no":true,"valle.no":true,"vang.no":true,"vanylven.no":true,"vardo.no":true,"xn--vard-jra.no":true,"varggat.no":true,"xn--vrggt-xqad.no":true,"vefsn.no":true,"vaapste.no":true,"vega.no":true,"vegarshei.no":true,"xn--vegrshei-c0a.no":true,"vennesla.no":true,"verdal.no":true,"verran.no":true,"vestby.no":true,"vestnes.no":true,"vestre-slidre.no":true,"vestre-toten.no":true,"vestvagoy.no":true,"xn--vestvgy-ixa6o.no":true,"vevelstad.no":true,"vik.no":true,"vikna.no":true,"vindafjord.no":true,"volda.no":true,"voss.no":true,"varoy.no":true,"xn--vry-yla5g.no":true,"vagan.no":true,"xn--vgan-qoa.no":true,"voagat.no":true,"vagsoy.no":true,"xn--vgsy-qoa0j.no":true,"vaga.no":true,"xn--vg-yiab.no":true,"valer.ostfold.no":true,"xn--vler-qoa.xn--stfold-9xa.no":true,"valer.hedmark.no":true,"xn--vler-qoa.hedmark.no":true,"*.np":true,"nr":true,"biz.nr":true,"info.nr":true,"gov.nr":true,"edu.nr":true,"org.nr":true,"net.nr":true,"com.nr":true,"nu":true,"nz":true,"ac.nz":true,"co.nz":true,"cri.nz":true,"geek.nz":true,"gen.nz":true,"govt.nz":true,"health.nz":true,"iwi.nz":true,"kiwi.nz":true,"maori.nz":true,"mil.nz":true,"xn--mori-qsa.nz":true,"net.nz":true,"org.nz":true,"parliament.nz":true,"school.nz":true,"om":true,"co.om":true,"com.om":true,"edu.om":true,"gov.om":true,"med.om":true,"museum.om":true,"net.om":true,"org.om":true,"pro.om":true,"org":true,"pa":true,"ac.pa":true,"gob.pa":true,"com.pa":true,"org.pa":true,"sld.pa":true,"edu.pa":true,"net.pa":true,"ing.pa":true,"abo.pa":true,"med.pa":true,"nom.pa":true,"pe":true,"edu.pe":true,"gob.pe":true,"nom.pe":true,"mil.pe":true,"org.pe":true,"com.pe":true,"net.pe":true,"pf":true,"com.pf":true,"org.pf":true,"edu.pf":true,"*.pg":true,"ph":true,"com.ph":true,"net.ph":true,"org.ph":true,"gov.ph":true,"edu.ph":true,"ngo.ph":true,"mil.ph":true,"i.ph":true,"pk":true,"com.pk":true,"net.pk":true,"edu.pk":true,"org.pk":true,"fam.pk":true,"biz.pk":true,"web.pk":true,"gov.pk":true,"gob.pk":true,"gok.pk":true,"gon.pk":true,"gop.pk":true,"gos.pk":true,"info.pk":true,"pl":true,"com.pl":true,"net.pl":true,"org.pl":true,"info.pl":true,"waw.pl":true,"gov.pl":true,"aid.pl":true,"agro.pl":true,"atm.pl":true,"auto.pl":true,"biz.pl":true,"edu.pl":true,"gmina.pl":true,"gsm.pl":true,"mail.pl":true,"miasta.pl":true,"media.pl":true,"mil.pl":true,"nieruchomosci.pl":true,"nom.pl":true,"pc.pl":true,"powiat.pl":true,"priv.pl":true,"realestate.pl":true,"rel.pl":true,"sex.pl":true,"shop.pl":true,"sklep.pl":true,"sos.pl":true,"szkola.pl":true,"targi.pl":true,"tm.pl":true,"tourism.pl":true,"travel.pl":true,"turystyka.pl":true,"uw.gov.pl":true,"um.gov.pl":true,"ug.gov.pl":true,"upow.gov.pl":true,"starostwo.gov.pl":true,"so.gov.pl":true,"sr.gov.pl":true,"po.gov.pl":true,"pa.gov.pl":true,"augustow.pl":true,"babia-gora.pl":true,"bedzin.pl":true,"beskidy.pl":true,"bialowieza.pl":true,"bialystok.pl":true,"bielawa.pl":true,"bieszczady.pl":true,"boleslawiec.pl":true,"bydgoszcz.pl":true,"bytom.pl":true,"cieszyn.pl":true,"czeladz.pl":true,"czest.pl":true,"dlugoleka.pl":true,"elblag.pl":true,"elk.pl":true,"glogow.pl":true,"gniezno.pl":true,"gorlice.pl":true,"grajewo.pl":true,"ilawa.pl":true,"jaworzno.pl":true,"jelenia-gora.pl":true,"jgora.pl":true,"kalisz.pl":true,"kazimierz-dolny.pl":true,"karpacz.pl":true,"kartuzy.pl":true,"kaszuby.pl":true,"katowice.pl":true,"kepno.pl":true,"ketrzyn.pl":true,"klodzko.pl":true,"kobierzyce.pl":true,"kolobrzeg.pl":true,"konin.pl":true,"konskowola.pl":true,"kutno.pl":true,"lapy.pl":true,"lebork.pl":true,"legnica.pl":true,"lezajsk.pl":true,"limanowa.pl":true,"lomza.pl":true,"lowicz.pl":true,"lubin.pl":true,"lukow.pl":true,"malbork.pl":true,"malopolska.pl":true,"mazowsze.pl":true,"mazury.pl":true,"mielec.pl":true,"mielno.pl":true,"mragowo.pl":true,"naklo.pl":true,"nowaruda.pl":true,"nysa.pl":true,"olawa.pl":true,"olecko.pl":true,"olkusz.pl":true,"olsztyn.pl":true,"opoczno.pl":true,"opole.pl":true,"ostroda.pl":true,"ostroleka.pl":true,"ostrowiec.pl":true,"ostrowwlkp.pl":true,"pila.pl":true,"pisz.pl":true,"podhale.pl":true,"podlasie.pl":true,"polkowice.pl":true,"pomorze.pl":true,"pomorskie.pl":true,"prochowice.pl":true,"pruszkow.pl":true,"przeworsk.pl":true,"pulawy.pl":true,"radom.pl":true,"rawa-maz.pl":true,"rybnik.pl":true,"rzeszow.pl":true,"sanok.pl":true,"sejny.pl":true,"slask.pl":true,"slupsk.pl":true,"sosnowiec.pl":true,"stalowa-wola.pl":true,"skoczow.pl":true,"starachowice.pl":true,"stargard.pl":true,"suwalki.pl":true,"swidnica.pl":true,"swiebodzin.pl":true,"swinoujscie.pl":true,"szczecin.pl":true,"szczytno.pl":true,"tarnobrzeg.pl":true,"tgory.pl":true,"turek.pl":true,"tychy.pl":true,"ustka.pl":true,"walbrzych.pl":true,"warmia.pl":true,"warszawa.pl":true,"wegrow.pl":true,"wielun.pl":true,"wlocl.pl":true,"wloclawek.pl":true,"wodzislaw.pl":true,"wolomin.pl":true,"wroclaw.pl":true,"zachpomor.pl":true,"zagan.pl":true,"zarow.pl":true,"zgora.pl":true,"zgorzelec.pl":true,"pm":true,"pn":true,"gov.pn":true,"co.pn":true,"org.pn":true,"edu.pn":true,"net.pn":true,"post":true,"pr":true,"com.pr":true,"net.pr":true,"org.pr":true,"gov.pr":true,"edu.pr":true,"isla.pr":true,"pro.pr":true,"biz.pr":true,"info.pr":true,"name.pr":true,"est.pr":true,"prof.pr":true,"ac.pr":true,"pro":true,"aca.pro":true,"bar.pro":true,"cpa.pro":true,"jur.pro":true,"law.pro":true,"med.pro":true,"eng.pro":true,"ps":true,"edu.ps":true,"gov.ps":true,"sec.ps":true,"plo.ps":true,"com.ps":true,"org.ps":true,"net.ps":true,"pt":true,"net.pt":true,"gov.pt":true,"org.pt":true,"edu.pt":true,"int.pt":true,"publ.pt":true,"com.pt":true,"nome.pt":true,"pw":true,"co.pw":true,"ne.pw":true,"or.pw":true,"ed.pw":true,"go.pw":true,"belau.pw":true,"py":true,"com.py":true,"coop.py":true,"edu.py":true,"gov.py":true,"mil.py":true,"net.py":true,"org.py":true,"qa":true,"com.qa":true,"edu.qa":true,"gov.qa":true,"mil.qa":true,"name.qa":true,"net.qa":true,"org.qa":true,"sch.qa":true,"re":true,"com.re":true,"asso.re":true,"nom.re":true,"ro":true,"com.ro":true,"org.ro":true,"tm.ro":true,"nt.ro":true,"nom.ro":true,"info.ro":true,"rec.ro":true,"arts.ro":true,"firm.ro":true,"store.ro":true,"www.ro":true,"rs":true,"co.rs":true,"org.rs":true,"edu.rs":true,"ac.rs":true,"gov.rs":true,"in.rs":true,"ru":true,"ac.ru":true,"com.ru":true,"edu.ru":true,"int.ru":true,"net.ru":true,"org.ru":true,"pp.ru":true,"adygeya.ru":true,"altai.ru":true,"amur.ru":true,"arkhangelsk.ru":true,"astrakhan.ru":true,"bashkiria.ru":true,"belgorod.ru":true,"bir.ru":true,"bryansk.ru":true,"buryatia.ru":true,"cbg.ru":true,"chel.ru":true,"chelyabinsk.ru":true,"chita.ru":true,"chukotka.ru":true,"chuvashia.ru":true,"dagestan.ru":true,"dudinka.ru":true,"e-burg.ru":true,"grozny.ru":true,"irkutsk.ru":true,"ivanovo.ru":true,"izhevsk.ru":true,"jar.ru":true,"joshkar-ola.ru":true,"kalmykia.ru":true,"kaluga.ru":true,"kamchatka.ru":true,"karelia.ru":true,"kazan.ru":true,"kchr.ru":true,"kemerovo.ru":true,"khabarovsk.ru":true,"khakassia.ru":true,"khv.ru":true,"kirov.ru":true,"koenig.ru":true,"komi.ru":true,"kostroma.ru":true,"krasnoyarsk.ru":true,"kuban.ru":true,"kurgan.ru":true,"kursk.ru":true,"lipetsk.ru":true,"magadan.ru":true,"mari.ru":true,"mari-el.ru":true,"marine.ru":true,"mordovia.ru":true,"msk.ru":true,"murmansk.ru":true,"nalchik.ru":true,"nnov.ru":true,"nov.ru":true,"novosibirsk.ru":true,"nsk.ru":true,"omsk.ru":true,"orenburg.ru":true,"oryol.ru":true,"palana.ru":true,"penza.ru":true,"perm.ru":true,"ptz.ru":true,"rnd.ru":true,"ryazan.ru":true,"sakhalin.ru":true,"samara.ru":true,"saratov.ru":true,"simbirsk.ru":true,"smolensk.ru":true,"spb.ru":true,"stavropol.ru":true,"stv.ru":true,"surgut.ru":true,"tambov.ru":true,"tatarstan.ru":true,"tom.ru":true,"tomsk.ru":true,"tsaritsyn.ru":true,"tsk.ru":true,"tula.ru":true,"tuva.ru":true,"tver.ru":true,"tyumen.ru":true,"udm.ru":true,"udmurtia.ru":true,"ulan-ude.ru":true,"vladikavkaz.ru":true,"vladimir.ru":true,"vladivostok.ru":true,"volgograd.ru":true,"vologda.ru":true,"voronezh.ru":true,"vrn.ru":true,"vyatka.ru":true,"yakutia.ru":true,"yamal.ru":true,"yaroslavl.ru":true,"yekaterinburg.ru":true,"yuzhno-sakhalinsk.ru":true,"amursk.ru":true,"baikal.ru":true,"cmw.ru":true,"fareast.ru":true,"jamal.ru":true,"kms.ru":true,"k-uralsk.ru":true,"kustanai.ru":true,"kuzbass.ru":true,"magnitka.ru":true,"mytis.ru":true,"nakhodka.ru":true,"nkz.ru":true,"norilsk.ru":true,"oskol.ru":true,"pyatigorsk.ru":true,"rubtsovsk.ru":true,"snz.ru":true,"syzran.ru":true,"vdonsk.ru":true,"zgrad.ru":true,"gov.ru":true,"mil.ru":true,"test.ru":true,"rw":true,"gov.rw":true,"net.rw":true,"edu.rw":true,"ac.rw":true,"com.rw":true,"co.rw":true,"int.rw":true,"mil.rw":true,"gouv.rw":true,"sa":true,"com.sa":true,"net.sa":true,"org.sa":true,"gov.sa":true,"med.sa":true,"pub.sa":true,"edu.sa":true,"sch.sa":true,"sb":true,"com.sb":true,"edu.sb":true,"gov.sb":true,"net.sb":true,"org.sb":true,"sc":true,"com.sc":true,"gov.sc":true,"net.sc":true,"org.sc":true,"edu.sc":true,"sd":true,"com.sd":true,"net.sd":true,"org.sd":true,"edu.sd":true,"med.sd":true,"tv.sd":true,"gov.sd":true,"info.sd":true,"se":true,"a.se":true,"ac.se":true,"b.se":true,"bd.se":true,"brand.se":true,"c.se":true,"d.se":true,"e.se":true,"f.se":true,"fh.se":true,"fhsk.se":true,"fhv.se":true,"g.se":true,"h.se":true,"i.se":true,"k.se":true,"komforb.se":true,"kommunalforbund.se":true,"komvux.se":true,"l.se":true,"lanbib.se":true,"m.se":true,"n.se":true,"naturbruksgymn.se":true,"o.se":true,"org.se":true,"p.se":true,"parti.se":true,"pp.se":true,"press.se":true,"r.se":true,"s.se":true,"t.se":true,"tm.se":true,"u.se":true,"w.se":true,"x.se":true,"y.se":true,"z.se":true,"sg":true,"com.sg":true,"net.sg":true,"org.sg":true,"gov.sg":true,"edu.sg":true,"per.sg":true,"sh":true,"com.sh":true,"net.sh":true,"gov.sh":true,"org.sh":true,"mil.sh":true,"si":true,"sj":true,"sk":true,"sl":true,"com.sl":true,"net.sl":true,"edu.sl":true,"gov.sl":true,"org.sl":true,"sm":true,"sn":true,"art.sn":true,"com.sn":true,"edu.sn":true,"gouv.sn":true,"org.sn":true,"perso.sn":true,"univ.sn":true,"so":true,"com.so":true,"net.so":true,"org.so":true,"sr":true,"st":true,"co.st":true,"com.st":true,"consulado.st":true,"edu.st":true,"embaixada.st":true,"gov.st":true,"mil.st":true,"net.st":true,"org.st":true,"principe.st":true,"saotome.st":true,"store.st":true,"su":true,"adygeya.su":true,"arkhangelsk.su":true,"balashov.su":true,"bashkiria.su":true,"bryansk.su":true,"dagestan.su":true,"grozny.su":true,"ivanovo.su":true,"kalmykia.su":true,"kaluga.su":true,"karelia.su":true,"khakassia.su":true,"krasnodar.su":true,"kurgan.su":true,"lenug.su":true,"mordovia.su":true,"msk.su":true,"murmansk.su":true,"nalchik.su":true,"nov.su":true,"obninsk.su":true,"penza.su":true,"pokrovsk.su":true,"sochi.su":true,"spb.su":true,"togliatti.su":true,"troitsk.su":true,"tula.su":true,"tuva.su":true,"vladikavkaz.su":true,"vladimir.su":true,"vologda.su":true,"sv":true,"com.sv":true,"edu.sv":true,"gob.sv":true,"org.sv":true,"red.sv":true,"sx":true,"gov.sx":true,"sy":true,"edu.sy":true,"gov.sy":true,"net.sy":true,"mil.sy":true,"com.sy":true,"org.sy":true,"sz":true,"co.sz":true,"ac.sz":true,"org.sz":true,"tc":true,"td":true,"tel":true,"tf":true,"tg":true,"th":true,"ac.th":true,"co.th":true,"go.th":true,"in.th":true,"mi.th":true,"net.th":true,"or.th":true,"tj":true,"ac.tj":true,"biz.tj":true,"co.tj":true,"com.tj":true,"edu.tj":true,"go.tj":true,"gov.tj":true,"int.tj":true,"mil.tj":true,"name.tj":true,"net.tj":true,"nic.tj":true,"org.tj":true,"test.tj":true,"web.tj":true,"tk":true,"tl":true,"gov.tl":true,"tm":true,"com.tm":true,"co.tm":true,"org.tm":true,"net.tm":true,"nom.tm":true,"gov.tm":true,"mil.tm":true,"edu.tm":true,"tn":true,"com.tn":true,"ens.tn":true,"fin.tn":true,"gov.tn":true,"ind.tn":true,"intl.tn":true,"nat.tn":true,"net.tn":true,"org.tn":true,"info.tn":true,"perso.tn":true,"tourism.tn":true,"edunet.tn":true,"rnrt.tn":true,"rns.tn":true,"rnu.tn":true,"mincom.tn":true,"agrinet.tn":true,"defense.tn":true,"turen.tn":true,"to":true,"com.to":true,"gov.to":true,"net.to":true,"org.to":true,"edu.to":true,"mil.to":true,"tp":true,"tr":true,"com.tr":true,"info.tr":true,"biz.tr":true,"net.tr":true,"org.tr":true,"web.tr":true,"gen.tr":true,"tv.tr":true,"av.tr":true,"dr.tr":true,"bbs.tr":true,"name.tr":true,"tel.tr":true,"gov.tr":true,"bel.tr":true,"pol.tr":true,"mil.tr":true,"k12.tr":true,"edu.tr":true,"kep.tr":true,"nc.tr":true,"gov.nc.tr":true,"travel":true,"tt":true,"co.tt":true,"com.tt":true,"org.tt":true,"net.tt":true,"biz.tt":true,"info.tt":true,"pro.tt":true,"int.tt":true,"coop.tt":true,"jobs.tt":true,"mobi.tt":true,"travel.tt":true,"museum.tt":true,"aero.tt":true,"name.tt":true,"gov.tt":true,"edu.tt":true,"tv":true,"tw":true,"edu.tw":true,"gov.tw":true,"mil.tw":true,"com.tw":true,"net.tw":true,"org.tw":true,"idv.tw":true,"game.tw":true,"ebiz.tw":true,"club.tw":true,"xn--zf0ao64a.tw":true,"xn--uc0atv.tw":true,"xn--czrw28b.tw":true,"tz":true,"ac.tz":true,"co.tz":true,"go.tz":true,"hotel.tz":true,"info.tz":true,"me.tz":true,"mil.tz":true,"mobi.tz":true,"ne.tz":true,"or.tz":true,"sc.tz":true,"tv.tz":true,"ua":true,"com.ua":true,"edu.ua":true,"gov.ua":true,"in.ua":true,"net.ua":true,"org.ua":true,"cherkassy.ua":true,"cherkasy.ua":true,"chernigov.ua":true,"chernihiv.ua":true,"chernivtsi.ua":true,"chernovtsy.ua":true,"ck.ua":true,"cn.ua":true,"cr.ua":true,"crimea.ua":true,"cv.ua":true,"dn.ua":true,"dnepropetrovsk.ua":true,"dnipropetrovsk.ua":true,"dominic.ua":true,"donetsk.ua":true,"dp.ua":true,"if.ua":true,"ivano-frankivsk.ua":true,"kh.ua":true,"kharkiv.ua":true,"kharkov.ua":true,"kherson.ua":true,"khmelnitskiy.ua":true,"khmelnytskyi.ua":true,"kiev.ua":true,"kirovograd.ua":true,"km.ua":true,"kr.ua":true,"krym.ua":true,"ks.ua":true,"kv.ua":true,"kyiv.ua":true,"lg.ua":true,"lt.ua":true,"lugansk.ua":true,"lutsk.ua":true,"lv.ua":true,"lviv.ua":true,"mk.ua":true,"mykolaiv.ua":true,"nikolaev.ua":true,"od.ua":true,"odesa.ua":true,"odessa.ua":true,"pl.ua":true,"poltava.ua":true,"rivne.ua":true,"rovno.ua":true,"rv.ua":true,"sb.ua":true,"sebastopol.ua":true,"sevastopol.ua":true,"sm.ua":true,"sumy.ua":true,"te.ua":true,"ternopil.ua":true,"uz.ua":true,"uzhgorod.ua":true,"vinnica.ua":true,"vinnytsia.ua":true,"vn.ua":true,"volyn.ua":true,"yalta.ua":true,"zaporizhzhe.ua":true,"zaporizhzhia.ua":true,"zhitomir.ua":true,"zhytomyr.ua":true,"zp.ua":true,"zt.ua":true,"co.ua":true,"pp.ua":true,"ug":true,"co.ug":true,"or.ug":true,"ac.ug":true,"sc.ug":true,"go.ug":true,"ne.ug":true,"com.ug":true,"org.ug":true,"uk":true,"ac.uk":true,"co.uk":true,"gov.uk":true,"ltd.uk":true,"me.uk":true,"net.uk":true,"nhs.uk":true,"org.uk":true,"plc.uk":true,"police.uk":true,"*.sch.uk":true,"us":true,"dni.us":true,"fed.us":true,"isa.us":true,"kids.us":true,"nsn.us":true,"ak.us":true,"al.us":true,"ar.us":true,"as.us":true,"az.us":true,"ca.us":true,"co.us":true,"ct.us":true,"dc.us":true,"de.us":true,"fl.us":true,"ga.us":true,"gu.us":true,"hi.us":true,"ia.us":true,"id.us":true,"il.us":true,"in.us":true,"ks.us":true,"ky.us":true,"la.us":true,"ma.us":true,"md.us":true,"me.us":true,"mi.us":true,"mn.us":true,"mo.us":true,"ms.us":true,"mt.us":true,"nc.us":true,"nd.us":true,"ne.us":true,"nh.us":true,"nj.us":true,"nm.us":true,"nv.us":true,"ny.us":true,"oh.us":true,"ok.us":true,"or.us":true,"pa.us":true,"pr.us":true,"ri.us":true,"sc.us":true,"sd.us":true,"tn.us":true,"tx.us":true,"ut.us":true,"vi.us":true,"vt.us":true,"va.us":true,"wa.us":true,"wi.us":true,"wv.us":true,"wy.us":true,"k12.ak.us":true,"k12.al.us":true,"k12.ar.us":true,"k12.as.us":true,"k12.az.us":true,"k12.ca.us":true,"k12.co.us":true,"k12.ct.us":true,"k12.dc.us":true,"k12.de.us":true,"k12.fl.us":true,"k12.ga.us":true,"k12.gu.us":true,"k12.ia.us":true,"k12.id.us":true,"k12.il.us":true,"k12.in.us":true,"k12.ks.us":true,"k12.ky.us":true,"k12.la.us":true,"k12.ma.us":true,"k12.md.us":true,"k12.me.us":true,"k12.mi.us":true,"k12.mn.us":true,"k12.mo.us":true,"k12.ms.us":true,"k12.mt.us":true,"k12.nc.us":true,"k12.ne.us":true,"k12.nh.us":true,"k12.nj.us":true,"k12.nm.us":true,"k12.nv.us":true,"k12.ny.us":true,"k12.oh.us":true,"k12.ok.us":true,"k12.or.us":true,"k12.pa.us":true,"k12.pr.us":true,"k12.ri.us":true,"k12.sc.us":true,"k12.tn.us":true,"k12.tx.us":true,"k12.ut.us":true,"k12.vi.us":true,"k12.vt.us":true,"k12.va.us":true,"k12.wa.us":true,"k12.wi.us":true,"k12.wy.us":true,"cc.ak.us":true,"cc.al.us":true,"cc.ar.us":true,"cc.as.us":true,"cc.az.us":true,"cc.ca.us":true,"cc.co.us":true,"cc.ct.us":true,"cc.dc.us":true,"cc.de.us":true,"cc.fl.us":true,"cc.ga.us":true,"cc.gu.us":true,"cc.hi.us":true,"cc.ia.us":true,"cc.id.us":true,"cc.il.us":true,"cc.in.us":true,"cc.ks.us":true,"cc.ky.us":true,"cc.la.us":true,"cc.ma.us":true,"cc.md.us":true,"cc.me.us":true,"cc.mi.us":true,"cc.mn.us":true,"cc.mo.us":true,"cc.ms.us":true,"cc.mt.us":true,"cc.nc.us":true,"cc.nd.us":true,"cc.ne.us":true,"cc.nh.us":true,"cc.nj.us":true,"cc.nm.us":true,"cc.nv.us":true,"cc.ny.us":true,"cc.oh.us":true,"cc.ok.us":true,"cc.or.us":true,"cc.pa.us":true,"cc.pr.us":true,"cc.ri.us":true,"cc.sc.us":true,"cc.sd.us":true,"cc.tn.us":true,"cc.tx.us":true,"cc.ut.us":true,"cc.vi.us":true,"cc.vt.us":true,"cc.va.us":true,"cc.wa.us":true,"cc.wi.us":true,"cc.wv.us":true,"cc.wy.us":true,"lib.ak.us":true,"lib.al.us":true,"lib.ar.us":true,"lib.as.us":true,"lib.az.us":true,"lib.ca.us":true,"lib.co.us":true,"lib.ct.us":true,"lib.dc.us":true,"lib.de.us":true,"lib.fl.us":true,"lib.ga.us":true,"lib.gu.us":true,"lib.hi.us":true,"lib.ia.us":true,"lib.id.us":true,"lib.il.us":true,"lib.in.us":true,"lib.ks.us":true,"lib.ky.us":true,"lib.la.us":true,"lib.ma.us":true,"lib.md.us":true,"lib.me.us":true,"lib.mi.us":true,"lib.mn.us":true,"lib.mo.us":true,"lib.ms.us":true,"lib.mt.us":true,"lib.nc.us":true,"lib.nd.us":true,"lib.ne.us":true,"lib.nh.us":true,"lib.nj.us":true,"lib.nm.us":true,"lib.nv.us":true,"lib.ny.us":true,"lib.oh.us":true,"lib.ok.us":true,"lib.or.us":true,"lib.pa.us":true,"lib.pr.us":true,"lib.ri.us":true,"lib.sc.us":true,"lib.sd.us":true,"lib.tn.us":true,"lib.tx.us":true,"lib.ut.us":true,"lib.vi.us":true,"lib.vt.us":true,"lib.va.us":true,"lib.wa.us":true,"lib.wi.us":true,"lib.wy.us":true,"pvt.k12.ma.us":true,"chtr.k12.ma.us":true,"paroch.k12.ma.us":true,"uy":true,"com.uy":true,"edu.uy":true,"gub.uy":true,"mil.uy":true,"net.uy":true,"org.uy":true,"uz":true,"co.uz":true,"com.uz":true,"net.uz":true,"org.uz":true,"va":true,"vc":true,"com.vc":true,"net.vc":true,"org.vc":true,"gov.vc":true,"mil.vc":true,"edu.vc":true,"ve":true,"arts.ve":true,"co.ve":true,"com.ve":true,"e12.ve":true,"edu.ve":true,"firm.ve":true,"gob.ve":true,"gov.ve":true,"info.ve":true,"int.ve":true,"mil.ve":true,"net.ve":true,"org.ve":true,"rec.ve":true,"store.ve":true,"tec.ve":true,"web.ve":true,"vg":true,"vi":true,"co.vi":true,"com.vi":true,"k12.vi":true,"net.vi":true,"org.vi":true,"vn":true,"com.vn":true,"net.vn":true,"org.vn":true,"edu.vn":true,"gov.vn":true,"int.vn":true,"ac.vn":true,"biz.vn":true,"info.vn":true,"name.vn":true,"pro.vn":true,"health.vn":true,"vu":true,"com.vu":true,"edu.vu":true,"net.vu":true,"org.vu":true,"wf":true,"ws":true,"com.ws":true,"net.ws":true,"org.ws":true,"gov.ws":true,"edu.ws":true,"yt":true,"xn--mgbaam7a8h":true,"xn--54b7fta0cc":true,"xn--fiqs8s":true,"xn--fiqz9s":true,"xn--lgbbat1ad8j":true,"xn--wgbh1c":true,"xn--node":true,"xn--j6w193g":true,"xn--h2brj9c":true,"xn--mgbbh1a71e":true,"xn--fpcrj9c3d":true,"xn--gecrj9c":true,"xn--s9brj9c":true,"xn--45brj9c":true,"xn--xkc2dl3a5ee0h":true,"xn--mgba3a4f16a":true,"xn--mgba3a4fra":true,"xn--mgbayh7gpa":true,"xn--3e0b707e":true,"xn--80ao21a":true,"xn--fzc2c9e2c":true,"xn--xkc2al3hye2a":true,"xn--mgbc0a9azcg":true,"xn--l1acc":true,"xn--mgbx4cd0ab":true,"xn--mgb9awbf":true,"xn--ygbi2ammx":true,"xn--90a3ac":true,"xn--o1ac.xn--90a3ac":true,"xn--c1avg.xn--90a3ac":true,"xn--90azh.xn--90a3ac":true,"xn--d1at.xn--90a3ac":true,"xn--o1ach.xn--90a3ac":true,"xn--80au.xn--90a3ac":true,"xn--p1ai":true,"xn--wgbl6a":true,"xn--mgberp4a5d4ar":true,"xn--mgberp4a5d4a87g":true,"xn--mgbqly7c0a67fbc":true,"xn--mgbqly7cvafr":true,"xn--ogbpf8fl":true,"xn--mgbtf8fl":true,"xn--yfro4i67o":true,"xn--clchc0ea0b2g2a9gcd":true,"xn--o3cw4h":true,"xn--pgbs0dh":true,"xn--kpry57d":true,"xn--kprw13d":true,"xn--nnx388a":true,"xn--j1amh":true,"xn--mgb2ddes":true,"xxx":true,"*.ye":true,"*.za":true,"*.zm":true,"*.zw":true,"aaa":true,"abb":true,"abbott":true,"abogado":true,"academy":true,"accenture":true,"accountant":true,"accountants":true,"aco":true,"active":true,"actor":true,"ads":true,"adult":true,"aeg":true,"afl":true,"africa":true,"africamagic":true,"agency":true,"aig":true,"airforce":true,"airtel":true,"alibaba":true,"alipay":true,"allfinanz":true,"alsace":true,"amsterdam":true,"analytics":true,"android":true,"anquan":true,"apartments":true,"aquarelle":true,"aramco":true,"archi":true,"army":true,"arte":true,"associates":true,"attorney":true,"auction":true,"audio":true,"author":true,"auto":true,"autos":true,"avianca":true,"axa":true,"azure":true,"baidu":true,"band":true,"bank":true,"bar":true,"barcelona":true,"barclaycard":true,"barclays":true,"bargains":true,"bauhaus":true,"bayern":true,"bbc":true,"bbva":true,"bcg":true,"bcn":true,"beer":true,"bentley":true,"berlin":true,"best":true,"bharti":true,"bible":true,"bid":true,"bike":true,"bing":true,"bingo":true,"bio":true,"black":true,"blackfriday":true,"bloomberg":true,"blue":true,"bms":true,"bmw":true,"bnl":true,"bnpparibas":true,"boats":true,"bom":true,"bond":true,"boo":true,"boots":true,"bot":true,"boutique":true,"bradesco":true,"bridgestone":true,"broadway":true,"broker":true,"brother":true,"brussels":true,"budapest":true,"build":true,"builders":true,"business":true,"buy":true,"buzz":true,"bzh":true,"cab":true,"cafe":true,"cal":true,"call":true,"camera":true,"camp":true,"cancerresearch":true,"canon":true,"capetown":true,"capital":true,"car":true,"caravan":true,"cards":true,"care":true,"career":true,"careers":true,"cars":true,"cartier":true,"casa":true,"cash":true,"casino":true,"catering":true,"cba":true,"cbn":true,"center":true,"ceo":true,"cern":true,"cfa":true,"cfd":true,"channel":true,"chat":true,"cheap":true,"chloe":true,"christmas":true,"chrome":true,"church":true,"cipriani":true,"circle":true,"cisco":true,"citic":true,"city":true,"cityeats":true,"claims":true,"cleaning":true,"click":true,"clinic":true,"clothing":true,"club":true,"coach":true,"codes":true,"coffee":true,"college":true,"cologne":true,"commbank":true,"community":true,"company":true,"computer":true,"comsec":true,"condos":true,"construction":true,"consulting":true,"contact":true,"contractors":true,"cooking":true,"cool":true,"corsica":true,"country":true,"coupon":true,"coupons":true,"courses":true,"credit":true,"creditcard":true,"creditunion":true,"cricket":true,"crown":true,"crs":true,"cruises":true,"csc":true,"cuisinella":true,"cymru":true,"cyou":true,"dabur":true,"dad":true,"dance":true,"date":true,"dating":true,"datsun":true,"day":true,"dclk":true,"dealer":true,"deals":true,"degree":true,"delivery":true,"dell":true,"delta":true,"democrat":true,"dental":true,"dentist":true,"desi":true,"design":true,"dev":true,"diamonds":true,"diet":true,"digital":true,"direct":true,"directory":true,"discount":true,"dnp":true,"docs":true,"dog":true,"doha":true,"domains":true,"doosan":true,"download":true,"drive":true,"dstv":true,"dubai":true,"durban":true,"dvag":true,"earth":true,"eat":true,"edeka":true,"education":true,"email":true,"emerck":true,"energy":true,"engineer":true,"engineering":true,"enterprises":true,"epson":true,"equipment":true,"erni":true,"esq":true,"estate":true,"eurovision":true,"eus":true,"events":true,"everbank":true,"exchange":true,"expert":true,"exposed":true,"express":true,"fage":true,"fail":true,"fairwinds":true,"faith":true,"family":true,"fan":true,"fans":true,"farm":true,"fashion":true,"fast":true,"feedback":true,"ferrero":true,"film":true,"final":true,"finance":true,"financial":true,"firestone":true,"firmdale":true,"fish":true,"fishing":true,"fit":true,"fitness":true,"flickr":true,"flights":true,"florist":true,"flowers":true,"flsmidth":true,"fly":true,"foo":true,"football":true,"ford":true,"forex":true,"forsale":true,"forum":true,"foundation":true,"frl":true,"frogans":true,"frontier":true,"fund":true,"furniture":true,"futbol":true,"fyi":true,"gal":true,"gallery":true,"gallup":true,"garden":true,"gbiz":true,"gdn":true,"gea":true,"gent":true,"genting":true,"ggee":true,"gift":true,"gifts":true,"gives":true,"giving":true,"glass":true,"gle":true,"global":true,"globo":true,"gmail":true,"gmo":true,"gmx":true,"gold":true,"goldpoint":true,"golf":true,"goo":true,"goog":true,"google":true,"gop":true,"got":true,"gotv":true,"graphics":true,"gratis":true,"green":true,"gripe":true,"group":true,"gucci":true,"guge":true,"guide":true,"guitars":true,"guru":true,"hamburg":true,"hangout":true,"haus":true,"hdfcbank":true,"health":true,"healthcare":true,"help":true,"helsinki":true,"here":true,"hermes":true,"hiphop":true,"hitachi":true,"hiv":true,"hockey":true,"holdings":true,"holiday":true,"homedepot":true,"homes":true,"honda":true,"horse":true,"host":true,"hosting":true,"hoteles":true,"hotmail":true,"house":true,"how":true,"hsbc":true,"htc":true,"ibm":true,"icbc":true,"ice":true,"icu":true,"ifm":true,"iinet":true,"immo":true,"immobilien":true,"industries":true,"infiniti":true,"ing":true,"ink":true,"institute":true,"insurance":true,"insure":true,"international":true,"investments":true,"ipiranga":true,"irish":true,"iselect":true,"ist":true,"istanbul":true,"itau":true,"iwc":true,"jaguar":true,"java":true,"jcb":true,"jetzt":true,"jewelry":true,"jio":true,"jlc":true,"jll":true,"jmp":true,"joburg":true,"jot":true,"joy":true,"jprs":true,"juegos":true,"kaufen":true,"kddi":true,"kfh":true,"kim":true,"kinder":true,"kitchen":true,"kiwi":true,"koeln":true,"komatsu":true,"kpn":true,"krd":true,"kred":true,"kyknet":true,"kyoto":true,"lacaixa":true,"lancaster":true,"land":true,"landrover":true,"lasalle":true,"lat":true,"latrobe":true,"law":true,"lawyer":true,"lds":true,"lease":true,"leclerc":true,"legal":true,"lgbt":true,"liaison":true,"lidl":true,"life":true,"lifeinsurance":true,"lifestyle":true,"lighting":true,"like":true,"limited":true,"limo":true,"lincoln":true,"linde":true,"link":true,"live":true,"lixil":true,"loan":true,"loans":true,"lol":true,"london":true,"lotte":true,"lotto":true,"love":true,"ltd":true,"ltda":true,"lupin":true,"luxe":true,"luxury":true,"madrid":true,"maif":true,"maison":true,"makeup":true,"man":true,"management":true,"mango":true,"market":true,"marketing":true,"markets":true,"marriott":true,"mba":true,"media":true,"meet":true,"melbourne":true,"meme":true,"memorial":true,"men":true,"menu":true,"meo":true,"miami":true,"microsoft":true,"mini":true,"mma":true,"mnet":true,"mobily":true,"moda":true,"moe":true,"moi":true,"monash":true,"money":true,"montblanc":true,"mormon":true,"mortgage":true,"moscow":true,"motorcycles":true,"mov":true,"movie":true,"movistar":true,"mtn":true,"mtpc":true,"mtr":true,"multichoice":true,"mutual":true,"mzansimagic":true,"nadex":true,"nagoya":true,"naspers":true,"natura":true,"navy":true,"nec":true,"netbank":true,"network":true,"neustar":true,"new":true,"news":true,"nexus":true,"ngo":true,"nhk":true,"nico":true,"ninja":true,"nissan":true,"nokia":true,"norton":true,"nowruz":true,"nra":true,"nrw":true,"ntt":true,"nyc":true,"obi":true,"office":true,"okinawa":true,"omega":true,"one":true,"ong":true,"onl":true,"online":true,"ooo":true,"oracle":true,"orange":true,"organic":true,"orientexpress":true,"osaka":true,"otsuka":true,"ovh":true,"page":true,"pamperedchef":true,"panerai":true,"paris":true,"pars":true,"partners":true,"parts":true,"party":true,"passagens":true,"payu":true,"pharmacy":true,"philips":true,"photo":true,"photography":true,"photos":true,"physio":true,"piaget":true,"pics":true,"pictet":true,"pictures":true,"pid":true,"pin":true,"pink":true,"pizza":true,"place":true,"play":true,"plumbing":true,"plus":true,"pohl":true,"poker":true,"porn":true,"praxi":true,"press":true,"prod":true,"productions":true,"prof":true,"promo":true,"properties":true,"property":true,"pub":true,"qpon":true,"quebec":true,"quest":true,"racing":true,"read":true,"realtor":true,"realty":true,"recipes":true,"red":true,"redstone":true,"redumbrella":true,"rehab":true,"reise":true,"reisen":true,"reit":true,"reliance":true,"ren":true,"rent":true,"rentals":true,"repair":true,"report":true,"republican":true,"rest":true,"restaurant":true,"review":true,"reviews":true,"rich":true,"ricoh":true,"ril":true,"rio":true,"rip":true,"rocher":true,"rocks":true,"rodeo":true,"room":true,"rsvp":true,"ruhr":true,"run":true,"rwe":true,"ryukyu":true,"saarland":true,"safe":true,"safety":true,"sakura":true,"sale":true,"salon":true,"samsung":true,"sandvik":true,"sandvikcoromant":true,"sanofi":true,"sap":true,"sapo":true,"sarl":true,"sas":true,"saxo":true,"sbi":true,"sbs":true,"sca":true,"scb":true,"schmidt":true,"scholarships":true,"school":true,"schule":true,"schwarz":true,"science":true,"scor":true,"scot":true,"seat":true,"seek":true,"sener":true,"services":true,"sew":true,"sex":true,"sexy":true,"sharp":true,"shia":true,"shiksha":true,"shoes":true,"shouji":true,"show":true,"shriram":true,"sina":true,"singles":true,"site":true,"skin":true,"sky":true,"skype":true,"smile":true,"sncf":true,"soccer":true,"social":true,"software":true,"sohu":true,"solar":true,"solutions":true,"song":true,"sony":true,"soy":true,"space":true,"spiegel":true,"spot":true,"spreadbetting":true,"stada":true,"star":true,"starhub":true,"statebank":true,"statoil":true,"stc":true,"stcgroup":true,"stockholm":true,"storage":true,"studio":true,"study":true,"style":true,"sucks":true,"supersport":true,"supplies":true,"supply":true,"support":true,"surf":true,"surgery":true,"suzuki":true,"swatch":true,"swiss":true,"sydney":true,"symantec":true,"systems":true,"tab":true,"taipei":true,"taobao":true,"tatamotors":true,"tatar":true,"tattoo":true,"tax":true,"taxi":true,"tci":true,"team":true,"tech":true,"technology":true,"telecity":true,"telefonica":true,"temasek":true,"tennis":true,"thd":true,"theater":true,"tickets":true,"tienda":true,"tiffany":true,"tips":true,"tires":true,"tirol":true,"tmall":true,"today":true,"tokyo":true,"tools":true,"top":true,"toray":true,"toshiba":true,"tours":true,"town":true,"toys":true,"trade":true,"trading":true,"training":true,"travelers":true,"travelersinsurance":true,"trust":true,"trv":true,"tui":true,"tunes":true,"tushu":true,"tvs":true,"ubs":true,"university":true,"uno":true,"uol":true,"vacations":true,"vana":true,"vegas":true,"ventures":true,"versicherung":true,"vet":true,"viajes":true,"video":true,"viking":true,"villas":true,"vip":true,"virgin":true,"vision":true,"vista":true,"vistaprint":true,"viva":true,"vlaanderen":true,"vodka":true,"vote":true,"voting":true,"voto":true,"voyage":true,"vuelos":true,"wales":true,"walter":true,"wang":true,"wanggou":true,"watch":true,"watches":true,"weather":true,"weatherchannel":true,"webcam":true,"website":true,"wed":true,"wedding":true,"weibo":true,"weir":true,"whoswho":true,"wien":true,"wiki":true,"williamhill":true,"win":true,"windows":true,"wme":true,"work":true,"works":true,"world":true,"wtc":true,"wtf":true,"xbox":true,"xerox":true,"xihuan":true,"xin":true,"xn--11b4c3d":true,"xn--1ck2e1b":true,"xn--1qqw23a":true,"xn--30rr7y":true,"xn--3bst00m":true,"xn--3ds443g":true,"xn--3pxu8k":true,"xn--42c2d9a":true,"xn--45q11c":true,"xn--4gbrim":true,"xn--55qw42g":true,"xn--55qx5d":true,"xn--5tzm5g":true,"xn--6frz82g":true,"xn--6qq986b3xl":true,"xn--80adxhks":true,"xn--80asehdb":true,"xn--80aswg":true,"xn--8y0a063a":true,"xn--9dbq2a":true,"xn--9et52u":true,"xn--9krt00a":true,"xn--b4w605ferd":true,"xn--bck1b9a5dre4c":true,"xn--c1avg":true,"xn--c2br7g":true,"xn--cck2b3b":true,"xn--cg4bki":true,"xn--czr694b":true,"xn--czrs0t":true,"xn--czru2d":true,"xn--d1acj3b":true,"xn--eckvdtc9d":true,"xn--efvy88h":true,"xn--estv75g":true,"xn--fhbei":true,"xn--fiq228c5hs":true,"xn--fiq64b":true,"xn--fjq720a":true,"xn--flw351e":true,"xn--g2xx48c":true,"xn--gckr3f0f":true,"xn--hxt814e":true,"xn--i1b6b1a6a2e":true,"xn--imr513n":true,"xn--io0a7i":true,"xn--j1aef":true,"xn--jlq61u9w7b":true,"xn--jvr189m":true,"xn--kcrx77d1x4a":true,"xn--kpu716f":true,"xn--kput3i":true,"xn--mgba3a3ejt":true,"xn--mgbab2bd":true,"xn--mgbb9fbpob":true,"xn--mgbt3dhd":true,"xn--mk1bu44c":true,"xn--mxtq1m":true,"xn--ngbc5azd":true,"xn--ngbe9e0a":true,"xn--nqv7f":true,"xn--nqv7fs00ema":true,"xn--nyqy26a":true,"xn--p1acf":true,"xn--pbt977c":true,"xn--pssy2u":true,"xn--q9jyb4c":true,"xn--qcka1pmc":true,"xn--rhqv96g":true,"xn--rovu88b":true,"xn--ses554g":true,"xn--t60b56a":true,"xn--tckwe":true,"xn--unup4y":true,"xn--vermgensberater-ctb":true,"xn--vermgensberatung-pwb":true,"xn--vhquv":true,"xn--vuq861b":true,"xn--xhq521b":true,"xn--zfr164b":true,"xyz":true,"yachts":true,"yahoo":true,"yamaxun":true,"yandex":true,"yodobashi":true,"yoga":true,"yokohama":true,"youtube":true,"yun":true,"zara":true,"zero":true,"zip":true,"zone":true,"zuerich":true,"cloudfront.net":true,"ap-northeast-1.compute.amazonaws.com":true,"ap-southeast-1.compute.amazonaws.com":true,"ap-southeast-2.compute.amazonaws.com":true,"cn-north-1.compute.amazonaws.cn":true,"compute.amazonaws.cn":true,"compute.amazonaws.com":true,"compute-1.amazonaws.com":true,"eu-west-1.compute.amazonaws.com":true,"eu-central-1.compute.amazonaws.com":true,"sa-east-1.compute.amazonaws.com":true,"us-east-1.amazonaws.com":true,"us-gov-west-1.compute.amazonaws.com":true,"us-west-1.compute.amazonaws.com":true,"us-west-2.compute.amazonaws.com":true,"z-1.compute-1.amazonaws.com":true,"z-2.compute-1.amazonaws.com":true,"elasticbeanstalk.com":true,"elb.amazonaws.com":true,"s3.amazonaws.com":true,"s3-us-west-2.amazonaws.com":true,"s3-us-west-1.amazonaws.com":true,"s3-eu-west-1.amazonaws.com":true,"s3-ap-southeast-1.amazonaws.com":true,"s3-ap-southeast-2.amazonaws.com":true,"s3-ap-northeast-1.amazonaws.com":true,"s3-sa-east-1.amazonaws.com":true,"s3-us-gov-west-1.amazonaws.com":true,"s3-fips-us-gov-west-1.amazonaws.com":true,"s3-website-us-east-1.amazonaws.com":true,"s3-website-us-west-2.amazonaws.com":true,"s3-website-us-west-1.amazonaws.com":true,"s3-website-eu-west-1.amazonaws.com":true,"s3-website-ap-southeast-1.amazonaws.com":true,"s3-website-ap-southeast-2.amazonaws.com":true,"s3-website-ap-northeast-1.amazonaws.com":true,"s3-website-sa-east-1.amazonaws.com":true,"s3-website-us-gov-west-1.amazonaws.com":true,"betainabox.com":true,"ae.org":true,"ar.com":true,"br.com":true,"cn.com":true,"com.de":true,"com.se":true,"de.com":true,"eu.com":true,"gb.com":true,"gb.net":true,"hu.com":true,"hu.net":true,"jp.net":true,"jpn.com":true,"kr.com":true,"mex.com":true,"no.com":true,"qc.com":true,"ru.com":true,"sa.com":true,"se.com":true,"se.net":true,"uk.com":true,"uk.net":true,"us.com":true,"uy.com":true,"za.bz":true,"za.com":true,"africa.com":true,"gr.com":true,"in.net":true,"us.org":true,"co.com":true,"c.la":true,"cloudcontrolled.com":true,"cloudcontrolapp.com":true,"co.ca":true,"co.nl":true,"co.no":true,"*.platform.sh":true,"cupcake.is":true,"dreamhosters.com":true,"dyndns-at-home.com":true,"dyndns-at-work.com":true,"dyndns-blog.com":true,"dyndns-free.com":true,"dyndns-home.com":true,"dyndns-ip.com":true,"dyndns-mail.com":true,"dyndns-office.com":true,"dyndns-pics.com":true,"dyndns-remote.com":true,"dyndns-server.com":true,"dyndns-web.com":true,"dyndns-wiki.com":true,"dyndns-work.com":true,"dyndns.biz":true,"dyndns.info":true,"dyndns.org":true,"dyndns.tv":true,"at-band-camp.net":true,"ath.cx":true,"barrel-of-knowledge.info":true,"barrell-of-knowledge.info":true,"better-than.tv":true,"blogdns.com":true,"blogdns.net":true,"blogdns.org":true,"blogsite.org":true,"boldlygoingnowhere.org":true,"broke-it.net":true,"buyshouses.net":true,"cechire.com":true,"dnsalias.com":true,"dnsalias.net":true,"dnsalias.org":true,"dnsdojo.com":true,"dnsdojo.net":true,"dnsdojo.org":true,"does-it.net":true,"doesntexist.com":true,"doesntexist.org":true,"dontexist.com":true,"dontexist.net":true,"dontexist.org":true,"doomdns.com":true,"doomdns.org":true,"dvrdns.org":true,"dyn-o-saur.com":true,"dynalias.com":true,"dynalias.net":true,"dynalias.org":true,"dynathome.net":true,"dyndns.ws":true,"endofinternet.net":true,"endofinternet.org":true,"endoftheinternet.org":true,"est-a-la-maison.com":true,"est-a-la-masion.com":true,"est-le-patron.com":true,"est-mon-blogueur.com":true,"for-better.biz":true,"for-more.biz":true,"for-our.info":true,"for-some.biz":true,"for-the.biz":true,"forgot.her.name":true,"forgot.his.name":true,"from-ak.com":true,"from-al.com":true,"from-ar.com":true,"from-az.net":true,"from-ca.com":true,"from-co.net":true,"from-ct.com":true,"from-dc.com":true,"from-de.com":true,"from-fl.com":true,"from-ga.com":true,"from-hi.com":true,"from-ia.com":true,"from-id.com":true,"from-il.com":true,"from-in.com":true,"from-ks.com":true,"from-ky.com":true,"from-la.net":true,"from-ma.com":true,"from-md.com":true,"from-me.org":true,"from-mi.com":true,"from-mn.com":true,"from-mo.com":true,"from-ms.com":true,"from-mt.com":true,"from-nc.com":true,"from-nd.com":true,"from-ne.com":true,"from-nh.com":true,"from-nj.com":true,"from-nm.com":true,"from-nv.com":true,"from-ny.net":true,"from-oh.com":true,"from-ok.com":true,"from-or.com":true,"from-pa.com":true,"from-pr.com":true,"from-ri.com":true,"from-sc.com":true,"from-sd.com":true,"from-tn.com":true,"from-tx.com":true,"from-ut.com":true,"from-va.com":true,"from-vt.com":true,"from-wa.com":true,"from-wi.com":true,"from-wv.com":true,"from-wy.com":true,"ftpaccess.cc":true,"fuettertdasnetz.de":true,"game-host.org":true,"game-server.cc":true,"getmyip.com":true,"gets-it.net":true,"go.dyndns.org":true,"gotdns.com":true,"gotdns.org":true,"groks-the.info":true,"groks-this.info":true,"ham-radio-op.net":true,"here-for-more.info":true,"hobby-site.com":true,"hobby-site.org":true,"home.dyndns.org":true,"homedns.org":true,"homeftp.net":true,"homeftp.org":true,"homeip.net":true,"homelinux.com":true,"homelinux.net":true,"homelinux.org":true,"homeunix.com":true,"homeunix.net":true,"homeunix.org":true,"iamallama.com":true,"in-the-band.net":true,"is-a-anarchist.com":true,"is-a-blogger.com":true,"is-a-bookkeeper.com":true,"is-a-bruinsfan.org":true,"is-a-bulls-fan.com":true,"is-a-candidate.org":true,"is-a-caterer.com":true,"is-a-celticsfan.org":true,"is-a-chef.com":true,"is-a-chef.net":true,"is-a-chef.org":true,"is-a-conservative.com":true,"is-a-cpa.com":true,"is-a-cubicle-slave.com":true,"is-a-democrat.com":true,"is-a-designer.com":true,"is-a-doctor.com":true,"is-a-financialadvisor.com":true,"is-a-geek.com":true,"is-a-geek.net":true,"is-a-geek.org":true,"is-a-green.com":true,"is-a-guru.com":true,"is-a-hard-worker.com":true,"is-a-hunter.com":true,"is-a-knight.org":true,"is-a-landscaper.com":true,"is-a-lawyer.com":true,"is-a-liberal.com":true,"is-a-libertarian.com":true,"is-a-linux-user.org":true,"is-a-llama.com":true,"is-a-musician.com":true,"is-a-nascarfan.com":true,"is-a-nurse.com":true,"is-a-painter.com":true,"is-a-patsfan.org":true,"is-a-personaltrainer.com":true,"is-a-photographer.com":true,"is-a-player.com":true,"is-a-republican.com":true,"is-a-rockstar.com":true,"is-a-socialist.com":true,"is-a-soxfan.org":true,"is-a-student.com":true,"is-a-teacher.com":true,"is-a-techie.com":true,"is-a-therapist.com":true,"is-an-accountant.com":true,"is-an-actor.com":true,"is-an-actress.com":true,"is-an-anarchist.com":true,"is-an-artist.com":true,"is-an-engineer.com":true,"is-an-entertainer.com":true,"is-by.us":true,"is-certified.com":true,"is-found.org":true,"is-gone.com":true,"is-into-anime.com":true,"is-into-cars.com":true,"is-into-cartoons.com":true,"is-into-games.com":true,"is-leet.com":true,"is-lost.org":true,"is-not-certified.com":true,"is-saved.org":true,"is-slick.com":true,"is-uberleet.com":true,"is-very-bad.org":true,"is-very-evil.org":true,"is-very-good.org":true,"is-very-nice.org":true,"is-very-sweet.org":true,"is-with-theband.com":true,"isa-geek.com":true,"isa-geek.net":true,"isa-geek.org":true,"isa-hockeynut.com":true,"issmarterthanyou.com":true,"isteingeek.de":true,"istmein.de":true,"kicks-ass.net":true,"kicks-ass.org":true,"knowsitall.info":true,"land-4-sale.us":true,"lebtimnetz.de":true,"leitungsen.de":true,"likes-pie.com":true,"likescandy.com":true,"merseine.nu":true,"mine.nu":true,"misconfused.org":true,"mypets.ws":true,"myphotos.cc":true,"neat-url.com":true,"office-on-the.net":true,"on-the-web.tv":true,"podzone.net":true,"podzone.org":true,"readmyblog.org":true,"saves-the-whales.com":true,"scrapper-site.net":true,"scrapping.cc":true,"selfip.biz":true,"selfip.com":true,"selfip.info":true,"selfip.net":true,"selfip.org":true,"sells-for-less.com":true,"sells-for-u.com":true,"sells-it.net":true,"sellsyourhome.org":true,"servebbs.com":true,"servebbs.net":true,"servebbs.org":true,"serveftp.net":true,"serveftp.org":true,"servegame.org":true,"shacknet.nu":true,"simple-url.com":true,"space-to-rent.com":true,"stuff-4-sale.org":true,"stuff-4-sale.us":true,"teaches-yoga.com":true,"thruhere.net":true,"traeumtgerade.de":true,"webhop.biz":true,"webhop.info":true,"webhop.net":true,"webhop.org":true,"worse-than.tv":true,"writesthisblog.com":true,"a.ssl.fastly.net":true,"b.ssl.fastly.net":true,"global.ssl.fastly.net":true,"a.prod.fastly.net":true,"global.prod.fastly.net":true,"firebaseapp.com":true,"flynnhub.com":true,"service.gov.uk":true,"github.io":true,"githubusercontent.com":true,"ro.com":true,"appspot.com":true,"blogspot.ae":true,"blogspot.be":true,"blogspot.bj":true,"blogspot.ca":true,"blogspot.cf":true,"blogspot.ch":true,"blogspot.co.at":true,"blogspot.co.il":true,"blogspot.co.nz":true,"blogspot.co.uk":true,"blogspot.com":true,"blogspot.com.ar":true,"blogspot.com.au":true,"blogspot.com.br":true,"blogspot.com.es":true,"blogspot.com.tr":true,"blogspot.cv":true,"blogspot.cz":true,"blogspot.de":true,"blogspot.dk":true,"blogspot.fi":true,"blogspot.fr":true,"blogspot.gr":true,"blogspot.hk":true,"blogspot.hu":true,"blogspot.ie":true,"blogspot.in":true,"blogspot.it":true,"blogspot.jp":true,"blogspot.kr":true,"blogspot.mr":true,"blogspot.mx":true,"blogspot.nl":true,"blogspot.no":true,"blogspot.pt":true,"blogspot.re":true,"blogspot.ro":true,"blogspot.ru":true,"blogspot.se":true,"blogspot.sg":true,"blogspot.sk":true,"blogspot.td":true,"blogspot.tw":true,"codespot.com":true,"googleapis.com":true,"googlecode.com":true,"pagespeedmobilizer.com":true,"withgoogle.com":true,"herokuapp.com":true,"herokussl.com":true,"iki.fi":true,"biz.at":true,"info.at":true,"co.pl":true,"azurewebsites.net":true,"azure-mobile.net":true,"cloudapp.net":true,"nfshost.com":true,"nyc.mn":true,"nid.io":true,"operaunite.com":true,"outsystemscloud.com":true,"art.pl":true,"gliwice.pl":true,"krakow.pl":true,"poznan.pl":true,"wroc.pl":true,"zakopane.pl":true,"priv.at":true,"rhcloud.com":true,"sinaapp.com":true,"vipsinaapp.com":true,"1kapp.com":true,"gda.pl":true,"gdansk.pl":true,"gdynia.pl":true,"med.pl":true,"sopot.pl":true,"hk.com":true,"hk.org":true,"ltd.hk":true,"inc.hk":true,"yolasite.com":true,"za.net":true,"za.org":true}); + +// END of automatically generated file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/store.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/store.js new file mode 100644 index 0000000..ad69c14 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/lib/store.js @@ -0,0 +1,67 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +/*jshint unused:false */ + +function Store() { +} +exports.Store = Store; + +// Stores may be synchronous, but are still required to use a +// Continuation-Passing Style API. The CookieJar itself will expose a "*Sync" +// API that converts from synchronous-callbacks to imperative style. +Store.prototype.synchronous = false; + +Store.prototype.findCookie = function(domain, path, key, cb) { + throw new Error('findCookie is not implemented'); +}; + +Store.prototype.findCookies = function(domain, path, cb) { + throw new Error('findCookies is not implemented'); +}; + +Store.prototype.putCookie = function(cookie, cb) { + throw new Error('putCookie is not implemented'); +}; + +Store.prototype.updateCookie = function(oldCookie, newCookie, cb) { + // recommended default implementation: + // return this.putCookie(newCookie, cb); + throw new Error('updateCookie is not implemented'); +}; + +Store.prototype.removeCookie = function(domain, path, key, cb) { + throw new Error('removeCookie is not implemented'); +}; + +Store.prototype.removeCookies = function removeCookies(domain, path, cb) { + throw new Error('removeCookies is not implemented'); +}; diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/package.json new file mode 100644 index 0000000..f38a15d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/package.json @@ -0,0 +1,66 @@ +{ + "author": { + "name": "Jeremy Stashewsky", + "email": "jstashewsky@salesforce.com" + }, + "license": "BSD-3-Clause", + "name": "tough-cookie", + "description": "RFC6265 Cookies and Cookie Jar for node.js", + "keywords": [ + "HTTP", + "cookie", + "cookies", + "set-cookie", + "cookiejar", + "jar", + "RFC6265", + "RFC2965" + ], + "version": "1.1.0", + "homepage": "https://github.com/SalesforceEng/tough-cookie", + "repository": { + "type": "git", + "url": "git://github.com/SalesforceEng/tough-cookie.git" + }, + "bugs": { + "url": "https://github.com/SalesforceEng/tough-cookie/issues" + }, + "main": "./lib/cookie", + "scripts": { + "test": "vows test/*_test.js" + }, + "engines": { + "node": ">=0.10.0" + }, + "devDependencies": { + "vows": "0.7.0", + "async": ">=0.1.12" + }, + "gitHead": "ddbcc02c8c24726c68e36a67d5864291acfdf57d", + "_id": "tough-cookie@1.1.0", + "_shasum": "126d2490e66ae5286b6863debd4a341076915954", + "_from": "tough-cookie@>=0.12.0", + "_npmVersion": "2.7.4", + "_nodeVersion": "0.12.2", + "_npmUser": { + "name": "jstash", + "email": "jstash@gmail.com" + }, + "dist": { + "shasum": "126d2490e66ae5286b6863debd4a341076915954", + "tarball": "http://registry.npmjs.org/tough-cookie/-/tough-cookie-1.1.0.tgz" + }, + "maintainers": [ + { + "name": "jstash", + "email": "jeremy@goinstant.com" + }, + { + "name": "goinstant", + "email": "services@goinstant.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-1.1.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/public-suffix.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/public-suffix.txt new file mode 100644 index 0000000..f8941f7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/public-suffix.txt @@ -0,0 +1,10079 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +// ===BEGIN ICANN DOMAINS=== + +// ac : http://en.wikipedia.org/wiki/.ac +ac +com.ac +edu.ac +gov.ac +net.ac +mil.ac +org.ac + +// ad : http://en.wikipedia.org/wiki/.ad +ad +nom.ad + +// ae : http://en.wikipedia.org/wiki/.ae +// see also: "Domain Name Eligibility Policy" at http://www.aeda.ae/eng/aepolicy.php +ae +co.ae +net.ae +org.ae +sch.ae +ac.ae +gov.ae +mil.ae + +// aero : see http://www.information.aero/index.php?id=66 +aero +accident-investigation.aero +accident-prevention.aero +aerobatic.aero +aeroclub.aero +aerodrome.aero +agents.aero +aircraft.aero +airline.aero +airport.aero +air-surveillance.aero +airtraffic.aero +air-traffic-control.aero +ambulance.aero +amusement.aero +association.aero +author.aero +ballooning.aero +broker.aero +caa.aero +cargo.aero +catering.aero +certification.aero +championship.aero +charter.aero +civilaviation.aero +club.aero +conference.aero +consultant.aero +consulting.aero +control.aero +council.aero +crew.aero +design.aero +dgca.aero +educator.aero +emergency.aero +engine.aero +engineer.aero +entertainment.aero +equipment.aero +exchange.aero +express.aero +federation.aero +flight.aero +freight.aero +fuel.aero +gliding.aero +government.aero +groundhandling.aero +group.aero +hanggliding.aero +homebuilt.aero +insurance.aero +journal.aero +journalist.aero +leasing.aero +logistics.aero +magazine.aero +maintenance.aero +marketplace.aero +media.aero +microlight.aero +modelling.aero +navigation.aero +parachuting.aero +paragliding.aero +passenger-association.aero +pilot.aero +press.aero +production.aero +recreation.aero +repbody.aero +res.aero +research.aero +rotorcraft.aero +safety.aero +scientist.aero +services.aero +show.aero +skydiving.aero +software.aero +student.aero +taxi.aero +trader.aero +trading.aero +trainer.aero +union.aero +workinggroup.aero +works.aero + +// af : http://www.nic.af/help.jsp +af +gov.af +com.af +org.af +net.af +edu.af + +// ag : http://www.nic.ag/prices.htm +ag +com.ag +org.ag +net.ag +co.ag +nom.ag + +// ai : http://nic.com.ai/ +ai +off.ai +com.ai +net.ai +org.ai + +// al : http://www.ert.gov.al/ert_alb/faq_det.html?Id=31 +al +com.al +edu.al +gov.al +mil.al +net.al +org.al + +// am : http://en.wikipedia.org/wiki/.am +am + +// an : http://www.una.an/an_domreg/default.asp +an +com.an +net.an +org.an +edu.an + +// ao : http://en.wikipedia.org/wiki/.ao +// http://www.dns.ao/REGISTR.DOC +ao +ed.ao +gv.ao +og.ao +co.ao +pb.ao +it.ao + +// aq : http://en.wikipedia.org/wiki/.aq +aq + +// ar : https://nic.ar/normativa-vigente.xhtml +ar +com.ar +edu.ar +gob.ar +gov.ar +int.ar +mil.ar +net.ar +org.ar +tur.ar + +// arpa : http://en.wikipedia.org/wiki/.arpa +// Confirmed by registry 2008-06-18 +arpa +e164.arpa +in-addr.arpa +ip6.arpa +iris.arpa +uri.arpa +urn.arpa + +// as : http://en.wikipedia.org/wiki/.as +as +gov.as + +// asia : http://en.wikipedia.org/wiki/.asia +asia + +// at : http://en.wikipedia.org/wiki/.at +// Confirmed by registry 2008-06-17 +at +ac.at +co.at +gv.at +or.at + +// au : http://en.wikipedia.org/wiki/.au +// http://www.auda.org.au/ +au +// 2LDs +com.au +net.au +org.au +edu.au +gov.au +asn.au +id.au +// Historic 2LDs (closed to new registration, but sites still exist) +info.au +conf.au +oz.au +// CGDNs - http://www.cgdn.org.au/ +act.au +nsw.au +nt.au +qld.au +sa.au +tas.au +vic.au +wa.au +// 3LDs +act.edu.au +nsw.edu.au +nt.edu.au +qld.edu.au +sa.edu.au +tas.edu.au +vic.edu.au +wa.edu.au +// act.gov.au Bug 984824 - Removed at request of Greg Tankard +// nsw.gov.au Bug 547985 - Removed at request of +// nt.gov.au Bug 940478 - Removed at request of Greg Connors +qld.gov.au +sa.gov.au +tas.gov.au +vic.gov.au +wa.gov.au + +// aw : http://en.wikipedia.org/wiki/.aw +aw +com.aw + +// ax : http://en.wikipedia.org/wiki/.ax +ax + +// az : http://en.wikipedia.org/wiki/.az +az +com.az +net.az +int.az +gov.az +org.az +edu.az +info.az +pp.az +mil.az +name.az +pro.az +biz.az + +// ba : http://en.wikipedia.org/wiki/.ba +ba +org.ba +net.ba +edu.ba +gov.ba +mil.ba +unsa.ba +unbi.ba +co.ba +com.ba +rs.ba + +// bb : http://en.wikipedia.org/wiki/.bb +bb +biz.bb +co.bb +com.bb +edu.bb +gov.bb +info.bb +net.bb +org.bb +store.bb +tv.bb + +// bd : http://en.wikipedia.org/wiki/.bd +*.bd + +// be : http://en.wikipedia.org/wiki/.be +// Confirmed by registry 2008-06-08 +be +ac.be + +// bf : http://en.wikipedia.org/wiki/.bf +bf +gov.bf + +// bg : http://en.wikipedia.org/wiki/.bg +// https://www.register.bg/user/static/rules/en/index.html +bg +a.bg +b.bg +c.bg +d.bg +e.bg +f.bg +g.bg +h.bg +i.bg +j.bg +k.bg +l.bg +m.bg +n.bg +o.bg +p.bg +q.bg +r.bg +s.bg +t.bg +u.bg +v.bg +w.bg +x.bg +y.bg +z.bg +0.bg +1.bg +2.bg +3.bg +4.bg +5.bg +6.bg +7.bg +8.bg +9.bg + +// bh : http://en.wikipedia.org/wiki/.bh +bh +com.bh +edu.bh +net.bh +org.bh +gov.bh + +// bi : http://en.wikipedia.org/wiki/.bi +// http://whois.nic.bi/ +bi +co.bi +com.bi +edu.bi +or.bi +org.bi + +// biz : http://en.wikipedia.org/wiki/.biz +biz + +// bj : http://en.wikipedia.org/wiki/.bj +bj +asso.bj +barreau.bj +gouv.bj + +// bm : http://www.bermudanic.bm/dnr-text.txt +bm +com.bm +edu.bm +gov.bm +net.bm +org.bm + +// bn : http://en.wikipedia.org/wiki/.bn +*.bn + +// bo : http://www.nic.bo/ +bo +com.bo +edu.bo +gov.bo +gob.bo +int.bo +org.bo +net.bo +mil.bo +tv.bo + +// br : http://registro.br/dominio/categoria.html +// Submitted by registry 2014-08-11 +br +adm.br +adv.br +agr.br +am.br +arq.br +art.br +ato.br +b.br +bio.br +blog.br +bmd.br +cim.br +cng.br +cnt.br +com.br +coop.br +ecn.br +eco.br +edu.br +emp.br +eng.br +esp.br +etc.br +eti.br +far.br +flog.br +fm.br +fnd.br +fot.br +fst.br +g12.br +ggf.br +gov.br +imb.br +ind.br +inf.br +jor.br +jus.br +leg.br +lel.br +mat.br +med.br +mil.br +mp.br +mus.br +net.br +*.nom.br +not.br +ntr.br +odo.br +org.br +ppg.br +pro.br +psc.br +psi.br +qsl.br +radio.br +rec.br +slg.br +srv.br +taxi.br +teo.br +tmp.br +trd.br +tur.br +tv.br +vet.br +vlog.br +wiki.br +zlg.br + +// bs : http://www.nic.bs/rules.html +bs +com.bs +net.bs +org.bs +edu.bs +gov.bs + +// bt : http://en.wikipedia.org/wiki/.bt +bt +com.bt +edu.bt +gov.bt +net.bt +org.bt + +// bv : No registrations at this time. +// Submitted by registry 2006-06-16 +bv + +// bw : http://en.wikipedia.org/wiki/.bw +// http://www.gobin.info/domainname/bw.doc +// list of other 2nd level tlds ? +bw +co.bw +org.bw + +// by : http://en.wikipedia.org/wiki/.by +// http://tld.by/rules_2006_en.html +// list of other 2nd level tlds ? +by +gov.by +mil.by +// Official information does not indicate that com.by is a reserved +// second-level domain, but it's being used as one (see www.google.com.by and +// www.yahoo.com.by, for example), so we list it here for safety's sake. +com.by + +// http://hoster.by/ +of.by + +// bz : http://en.wikipedia.org/wiki/.bz +// http://www.belizenic.bz/ +bz +com.bz +net.bz +org.bz +edu.bz +gov.bz + +// ca : http://en.wikipedia.org/wiki/.ca +ca +// ca geographical names +ab.ca +bc.ca +mb.ca +nb.ca +nf.ca +nl.ca +ns.ca +nt.ca +nu.ca +on.ca +pe.ca +qc.ca +sk.ca +yk.ca +// gc.ca: http://en.wikipedia.org/wiki/.gc.ca +// see also: http://registry.gc.ca/en/SubdomainFAQ +gc.ca + +// cat : http://en.wikipedia.org/wiki/.cat +cat + +// cc : http://en.wikipedia.org/wiki/.cc +cc + +// cd : http://en.wikipedia.org/wiki/.cd +// see also: https://www.nic.cd/domain/insertDomain_2.jsp?act=1 +cd +gov.cd + +// cf : http://en.wikipedia.org/wiki/.cf +cf + +// cg : http://en.wikipedia.org/wiki/.cg +cg + +// ch : http://en.wikipedia.org/wiki/.ch +ch + +// ci : http://en.wikipedia.org/wiki/.ci +// http://www.nic.ci/index.php?page=charte +ci +org.ci +or.ci +com.ci +co.ci +edu.ci +ed.ci +ac.ci +net.ci +go.ci +asso.ci +aéroport.ci +int.ci +presse.ci +md.ci +gouv.ci + +// ck : http://en.wikipedia.org/wiki/.ck +*.ck +!www.ck + +// cl : http://en.wikipedia.org/wiki/.cl +cl +gov.cl +gob.cl +co.cl +mil.cl + +// cm : http://en.wikipedia.org/wiki/.cm plus bug 981927 +cm +co.cm +com.cm +gov.cm +net.cm + +// cn : http://en.wikipedia.org/wiki/.cn +// Submitted by registry 2008-06-11 +cn +ac.cn +com.cn +edu.cn +gov.cn +net.cn +org.cn +mil.cn +公司.cn +网络.cn +網絡.cn +// cn geographic names +ah.cn +bj.cn +cq.cn +fj.cn +gd.cn +gs.cn +gz.cn +gx.cn +ha.cn +hb.cn +he.cn +hi.cn +hl.cn +hn.cn +jl.cn +js.cn +jx.cn +ln.cn +nm.cn +nx.cn +qh.cn +sc.cn +sd.cn +sh.cn +sn.cn +sx.cn +tj.cn +xj.cn +xz.cn +yn.cn +zj.cn +hk.cn +mo.cn +tw.cn + +// co : http://en.wikipedia.org/wiki/.co +// Submitted by registry 2008-06-11 +co +arts.co +com.co +edu.co +firm.co +gov.co +info.co +int.co +mil.co +net.co +nom.co +org.co +rec.co +web.co + +// com : http://en.wikipedia.org/wiki/.com +com + +// coop : http://en.wikipedia.org/wiki/.coop +coop + +// cr : http://www.nic.cr/niccr_publico/showRegistroDominiosScreen.do +cr +ac.cr +co.cr +ed.cr +fi.cr +go.cr +or.cr +sa.cr + +// cu : http://en.wikipedia.org/wiki/.cu +cu +com.cu +edu.cu +org.cu +net.cu +gov.cu +inf.cu + +// cv : http://en.wikipedia.org/wiki/.cv +cv + +// cw : http://www.una.cw/cw_registry/ +// Confirmed by registry 2013-03-26 +cw +com.cw +edu.cw +net.cw +org.cw + +// cx : http://en.wikipedia.org/wiki/.cx +// list of other 2nd level tlds ? +cx +gov.cx + +// cy : http://en.wikipedia.org/wiki/.cy +*.cy + +// cz : http://en.wikipedia.org/wiki/.cz +cz + +// de : http://en.wikipedia.org/wiki/.de +// Confirmed by registry (with technical +// reservations) 2008-07-01 +de + +// dj : http://en.wikipedia.org/wiki/.dj +dj + +// dk : http://en.wikipedia.org/wiki/.dk +// Confirmed by registry 2008-06-17 +dk + +// dm : http://en.wikipedia.org/wiki/.dm +dm +com.dm +net.dm +org.dm +edu.dm +gov.dm + +// do : http://en.wikipedia.org/wiki/.do +do +art.do +com.do +edu.do +gob.do +gov.do +mil.do +net.do +org.do +sld.do +web.do + +// dz : http://en.wikipedia.org/wiki/.dz +dz +com.dz +org.dz +net.dz +gov.dz +edu.dz +asso.dz +pol.dz +art.dz + +// ec : http://www.nic.ec/reg/paso1.asp +// Submitted by registry 2008-07-04 +ec +com.ec +info.ec +net.ec +fin.ec +k12.ec +med.ec +pro.ec +org.ec +edu.ec +gov.ec +gob.ec +mil.ec + +// edu : http://en.wikipedia.org/wiki/.edu +edu + +// ee : http://www.eenet.ee/EENet/dom_reeglid.html#lisa_B +ee +edu.ee +gov.ee +riik.ee +lib.ee +med.ee +com.ee +pri.ee +aip.ee +org.ee +fie.ee + +// eg : http://en.wikipedia.org/wiki/.eg +eg +com.eg +edu.eg +eun.eg +gov.eg +mil.eg +name.eg +net.eg +org.eg +sci.eg + +// er : http://en.wikipedia.org/wiki/.er +*.er + +// es : https://www.nic.es/site_ingles/ingles/dominios/index.html +es +com.es +nom.es +org.es +gob.es +edu.es + +// et : http://en.wikipedia.org/wiki/.et +et +com.et +gov.et +org.et +edu.et +biz.et +name.et +info.et + +// eu : http://en.wikipedia.org/wiki/.eu +eu + +// fi : http://en.wikipedia.org/wiki/.fi +fi +// aland.fi : http://en.wikipedia.org/wiki/.ax +// This domain is being phased out in favor of .ax. As there are still many +// domains under aland.fi, we still keep it on the list until aland.fi is +// completely removed. +// TODO: Check for updates (expected to be phased out around Q1/2009) +aland.fi + +// fj : http://en.wikipedia.org/wiki/.fj +*.fj + +// fk : http://en.wikipedia.org/wiki/.fk +*.fk + +// fm : http://en.wikipedia.org/wiki/.fm +fm + +// fo : http://en.wikipedia.org/wiki/.fo +fo + +// fr : http://www.afnic.fr/ +// domaines descriptifs : http://www.afnic.fr/obtenir/chartes/nommage-fr/annexe-descriptifs +fr +com.fr +asso.fr +nom.fr +prd.fr +presse.fr +tm.fr +// domaines sectoriels : http://www.afnic.fr/obtenir/chartes/nommage-fr/annexe-sectoriels +aeroport.fr +assedic.fr +avocat.fr +avoues.fr +cci.fr +chambagri.fr +chirurgiens-dentistes.fr +experts-comptables.fr +geometre-expert.fr +gouv.fr +greta.fr +huissier-justice.fr +medecin.fr +notaires.fr +pharmacien.fr +port.fr +veterinaire.fr + +// ga : http://en.wikipedia.org/wiki/.ga +ga + +// gb : This registry is effectively dormant +// Submitted by registry 2008-06-12 +gb + +// gd : http://en.wikipedia.org/wiki/.gd +gd + +// ge : http://www.nic.net.ge/policy_en.pdf +ge +com.ge +edu.ge +gov.ge +org.ge +mil.ge +net.ge +pvt.ge + +// gf : http://en.wikipedia.org/wiki/.gf +gf + +// gg : http://www.channelisles.net/register-domains/ +// Confirmed by registry 2013-11-28 +gg +co.gg +net.gg +org.gg + +// gh : http://en.wikipedia.org/wiki/.gh +// see also: http://www.nic.gh/reg_now.php +// Although domains directly at second level are not possible at the moment, +// they have been possible for some time and may come back. +gh +com.gh +edu.gh +gov.gh +org.gh +mil.gh + +// gi : http://www.nic.gi/rules.html +gi +com.gi +ltd.gi +gov.gi +mod.gi +edu.gi +org.gi + +// gl : http://en.wikipedia.org/wiki/.gl +// http://nic.gl +gl + +// gm : http://www.nic.gm/htmlpages%5Cgm-policy.htm +gm + +// gn : http://psg.com/dns/gn/gn.txt +// Submitted by registry 2008-06-17 +gn +ac.gn +com.gn +edu.gn +gov.gn +org.gn +net.gn + +// gov : http://en.wikipedia.org/wiki/.gov +gov + +// gp : http://www.nic.gp/index.php?lang=en +gp +com.gp +net.gp +mobi.gp +edu.gp +org.gp +asso.gp + +// gq : http://en.wikipedia.org/wiki/.gq +gq + +// gr : https://grweb.ics.forth.gr/english/1617-B-2005.html +// Submitted by registry 2008-06-09 +gr +com.gr +edu.gr +net.gr +org.gr +gov.gr + +// gs : http://en.wikipedia.org/wiki/.gs +gs + +// gt : http://www.gt/politicas_de_registro.html +gt +com.gt +edu.gt +gob.gt +ind.gt +mil.gt +net.gt +org.gt + +// gu : http://gadao.gov.gu/registration.txt +*.gu + +// gw : http://en.wikipedia.org/wiki/.gw +gw + +// gy : http://en.wikipedia.org/wiki/.gy +// http://registry.gy/ +gy +co.gy +com.gy +net.gy + +// hk : https://www.hkdnr.hk +// Submitted by registry 2008-06-11 +hk +com.hk +edu.hk +gov.hk +idv.hk +net.hk +org.hk +公司.hk +教育.hk +敎育.hk +政府.hk +個人.hk +个人.hk +箇人.hk +網络.hk +网络.hk +组織.hk +網絡.hk +网絡.hk +组织.hk +組織.hk +組织.hk + +// hm : http://en.wikipedia.org/wiki/.hm +hm + +// hn : http://www.nic.hn/politicas/ps02,,05.html +hn +com.hn +edu.hn +org.hn +net.hn +mil.hn +gob.hn + +// hr : http://www.dns.hr/documents/pdf/HRTLD-regulations.pdf +hr +iz.hr +from.hr +name.hr +com.hr + +// ht : http://www.nic.ht/info/charte.cfm +ht +com.ht +shop.ht +firm.ht +info.ht +adult.ht +net.ht +pro.ht +org.ht +med.ht +art.ht +coop.ht +pol.ht +asso.ht +edu.ht +rel.ht +gouv.ht +perso.ht + +// hu : http://www.domain.hu/domain/English/sld.html +// Confirmed by registry 2008-06-12 +hu +co.hu +info.hu +org.hu +priv.hu +sport.hu +tm.hu +2000.hu +agrar.hu +bolt.hu +casino.hu +city.hu +erotica.hu +erotika.hu +film.hu +forum.hu +games.hu +hotel.hu +ingatlan.hu +jogasz.hu +konyvelo.hu +lakas.hu +media.hu +news.hu +reklam.hu +sex.hu +shop.hu +suli.hu +szex.hu +tozsde.hu +utazas.hu +video.hu + +// id : https://register.pandi.or.id/ +id +ac.id +biz.id +co.id +desa.id +go.id +mil.id +my.id +net.id +or.id +sch.id +web.id + +// ie : http://en.wikipedia.org/wiki/.ie +ie +gov.ie + +// il : http://en.wikipedia.org/wiki/.il +*.il + +// im : https://www.nic.im/ +// Submitted by registry 2013-11-15 +im +ac.im +co.im +com.im +ltd.co.im +net.im +org.im +plc.co.im +tt.im +tv.im + +// in : http://en.wikipedia.org/wiki/.in +// see also: https://registry.in/Policies +// Please note, that nic.in is not an offical eTLD, but used by most +// government institutions. +in +co.in +firm.in +net.in +org.in +gen.in +ind.in +nic.in +ac.in +edu.in +res.in +gov.in +mil.in + +// info : http://en.wikipedia.org/wiki/.info +info + +// int : http://en.wikipedia.org/wiki/.int +// Confirmed by registry 2008-06-18 +int +eu.int + +// io : http://www.nic.io/rules.html +// list of other 2nd level tlds ? +io +com.io + +// iq : http://www.cmc.iq/english/iq/iqregister1.htm +iq +gov.iq +edu.iq +mil.iq +com.iq +org.iq +net.iq + +// ir : http://www.nic.ir/Terms_and_Conditions_ir,_Appendix_1_Domain_Rules +// Also see http://www.nic.ir/Internationalized_Domain_Names +// Two .ir entries added at request of , 2010-04-16 +ir +ac.ir +co.ir +gov.ir +id.ir +net.ir +org.ir +sch.ir +// xn--mgba3a4f16a.ir (.ir, Persian YEH) +ایران.ir +// xn--mgba3a4fra.ir (.ir, Arabic YEH) +ايران.ir + +// is : http://www.isnic.is/domain/rules.php +// Confirmed by registry 2008-12-06 +is +net.is +com.is +edu.is +gov.is +org.is +int.is + +// it : http://en.wikipedia.org/wiki/.it +it +gov.it +edu.it +// Reserved geo-names: +// http://www.nic.it/documenti/regolamenti-e-linee-guida/regolamento-assegnazione-versione-6.0.pdf +// There is also a list of reserved geo-names corresponding to Italian municipalities +// http://www.nic.it/documenti/appendice-c.pdf, but it is not included here. +// Regions +abr.it +abruzzo.it +aosta-valley.it +aostavalley.it +bas.it +basilicata.it +cal.it +calabria.it +cam.it +campania.it +emilia-romagna.it +emiliaromagna.it +emr.it +friuli-v-giulia.it +friuli-ve-giulia.it +friuli-vegiulia.it +friuli-venezia-giulia.it +friuli-veneziagiulia.it +friuli-vgiulia.it +friuliv-giulia.it +friulive-giulia.it +friulivegiulia.it +friulivenezia-giulia.it +friuliveneziagiulia.it +friulivgiulia.it +fvg.it +laz.it +lazio.it +lig.it +liguria.it +lom.it +lombardia.it +lombardy.it +lucania.it +mar.it +marche.it +mol.it +molise.it +piedmont.it +piemonte.it +pmn.it +pug.it +puglia.it +sar.it +sardegna.it +sardinia.it +sic.it +sicilia.it +sicily.it +taa.it +tos.it +toscana.it +trentino-a-adige.it +trentino-aadige.it +trentino-alto-adige.it +trentino-altoadige.it +trentino-s-tirol.it +trentino-stirol.it +trentino-sud-tirol.it +trentino-sudtirol.it +trentino-sued-tirol.it +trentino-suedtirol.it +trentinoa-adige.it +trentinoaadige.it +trentinoalto-adige.it +trentinoaltoadige.it +trentinos-tirol.it +trentinostirol.it +trentinosud-tirol.it +trentinosudtirol.it +trentinosued-tirol.it +trentinosuedtirol.it +tuscany.it +umb.it +umbria.it +val-d-aosta.it +val-daosta.it +vald-aosta.it +valdaosta.it +valle-aosta.it +valle-d-aosta.it +valle-daosta.it +valleaosta.it +valled-aosta.it +valledaosta.it +vallee-aoste.it +valleeaoste.it +vao.it +vda.it +ven.it +veneto.it +// Provinces +ag.it +agrigento.it +al.it +alessandria.it +alto-adige.it +altoadige.it +an.it +ancona.it +andria-barletta-trani.it +andria-trani-barletta.it +andriabarlettatrani.it +andriatranibarletta.it +ao.it +aosta.it +aoste.it +ap.it +aq.it +aquila.it +ar.it +arezzo.it +ascoli-piceno.it +ascolipiceno.it +asti.it +at.it +av.it +avellino.it +ba.it +balsan.it +bari.it +barletta-trani-andria.it +barlettatraniandria.it +belluno.it +benevento.it +bergamo.it +bg.it +bi.it +biella.it +bl.it +bn.it +bo.it +bologna.it +bolzano.it +bozen.it +br.it +brescia.it +brindisi.it +bs.it +bt.it +bz.it +ca.it +cagliari.it +caltanissetta.it +campidano-medio.it +campidanomedio.it +campobasso.it +carbonia-iglesias.it +carboniaiglesias.it +carrara-massa.it +carraramassa.it +caserta.it +catania.it +catanzaro.it +cb.it +ce.it +cesena-forli.it +cesenaforli.it +ch.it +chieti.it +ci.it +cl.it +cn.it +co.it +como.it +cosenza.it +cr.it +cremona.it +crotone.it +cs.it +ct.it +cuneo.it +cz.it +dell-ogliastra.it +dellogliastra.it +en.it +enna.it +fc.it +fe.it +fermo.it +ferrara.it +fg.it +fi.it +firenze.it +florence.it +fm.it +foggia.it +forli-cesena.it +forlicesena.it +fr.it +frosinone.it +ge.it +genoa.it +genova.it +go.it +gorizia.it +gr.it +grosseto.it +iglesias-carbonia.it +iglesiascarbonia.it +im.it +imperia.it +is.it +isernia.it +kr.it +la-spezia.it +laquila.it +laspezia.it +latina.it +lc.it +le.it +lecce.it +lecco.it +li.it +livorno.it +lo.it +lodi.it +lt.it +lu.it +lucca.it +macerata.it +mantova.it +massa-carrara.it +massacarrara.it +matera.it +mb.it +mc.it +me.it +medio-campidano.it +mediocampidano.it +messina.it +mi.it +milan.it +milano.it +mn.it +mo.it +modena.it +monza-brianza.it +monza-e-della-brianza.it +monza.it +monzabrianza.it +monzaebrianza.it +monzaedellabrianza.it +ms.it +mt.it +na.it +naples.it +napoli.it +no.it +novara.it +nu.it +nuoro.it +og.it +ogliastra.it +olbia-tempio.it +olbiatempio.it +or.it +oristano.it +ot.it +pa.it +padova.it +padua.it +palermo.it +parma.it +pavia.it +pc.it +pd.it +pe.it +perugia.it +pesaro-urbino.it +pesarourbino.it +pescara.it +pg.it +pi.it +piacenza.it +pisa.it +pistoia.it +pn.it +po.it +pordenone.it +potenza.it +pr.it +prato.it +pt.it +pu.it +pv.it +pz.it +ra.it +ragusa.it +ravenna.it +rc.it +re.it +reggio-calabria.it +reggio-emilia.it +reggiocalabria.it +reggioemilia.it +rg.it +ri.it +rieti.it +rimini.it +rm.it +rn.it +ro.it +roma.it +rome.it +rovigo.it +sa.it +salerno.it +sassari.it +savona.it +si.it +siena.it +siracusa.it +so.it +sondrio.it +sp.it +sr.it +ss.it +suedtirol.it +sv.it +ta.it +taranto.it +te.it +tempio-olbia.it +tempioolbia.it +teramo.it +terni.it +tn.it +to.it +torino.it +tp.it +tr.it +trani-andria-barletta.it +trani-barletta-andria.it +traniandriabarletta.it +tranibarlettaandria.it +trapani.it +trentino.it +trento.it +treviso.it +trieste.it +ts.it +turin.it +tv.it +ud.it +udine.it +urbino-pesaro.it +urbinopesaro.it +va.it +varese.it +vb.it +vc.it +ve.it +venezia.it +venice.it +verbania.it +vercelli.it +verona.it +vi.it +vibo-valentia.it +vibovalentia.it +vicenza.it +viterbo.it +vr.it +vs.it +vt.it +vv.it + +// je : http://www.channelisles.net/register-domains/ +// Confirmed by registry 2013-11-28 +je +co.je +net.je +org.je + +// jm : http://www.com.jm/register.html +*.jm + +// jo : http://www.dns.jo/Registration_policy.aspx +jo +com.jo +org.jo +net.jo +edu.jo +sch.jo +gov.jo +mil.jo +name.jo + +// jobs : http://en.wikipedia.org/wiki/.jobs +jobs + +// jp : http://en.wikipedia.org/wiki/.jp +// http://jprs.co.jp/en/jpdomain.html +// Submitted by registry 2014-10-30 +jp +// jp organizational type names +ac.jp +ad.jp +co.jp +ed.jp +go.jp +gr.jp +lg.jp +ne.jp +or.jp +// jp prefecture type names +aichi.jp +akita.jp +aomori.jp +chiba.jp +ehime.jp +fukui.jp +fukuoka.jp +fukushima.jp +gifu.jp +gunma.jp +hiroshima.jp +hokkaido.jp +hyogo.jp +ibaraki.jp +ishikawa.jp +iwate.jp +kagawa.jp +kagoshima.jp +kanagawa.jp +kochi.jp +kumamoto.jp +kyoto.jp +mie.jp +miyagi.jp +miyazaki.jp +nagano.jp +nagasaki.jp +nara.jp +niigata.jp +oita.jp +okayama.jp +okinawa.jp +osaka.jp +saga.jp +saitama.jp +shiga.jp +shimane.jp +shizuoka.jp +tochigi.jp +tokushima.jp +tokyo.jp +tottori.jp +toyama.jp +wakayama.jp +yamagata.jp +yamaguchi.jp +yamanashi.jp +栃木.jp +愛知.jp +愛媛.jp +兵庫.jp +熊本.jp +茨城.jp +北海道.jp +千葉.jp +和歌山.jp +長崎.jp +長野.jp +新潟.jp +青森.jp +静岡.jp +東京.jp +石川.jp +埼玉.jp +三重.jp +京都.jp +佐賀.jp +大分.jp +大阪.jp +奈良.jp +宮城.jp +宮崎.jp +富山.jp +山口.jp +山形.jp +山梨.jp +岩手.jp +岐阜.jp +岡山.jp +島根.jp +広島.jp +徳島.jp +沖縄.jp +滋賀.jp +神奈川.jp +福井.jp +福岡.jp +福島.jp +秋田.jp +群馬.jp +香川.jp +高知.jp +鳥取.jp +鹿児島.jp +// jp geographic type names +// http://jprs.jp/doc/rule/saisoku-1.html +*.kawasaki.jp +*.kitakyushu.jp +*.kobe.jp +*.nagoya.jp +*.sapporo.jp +*.sendai.jp +*.yokohama.jp +!city.kawasaki.jp +!city.kitakyushu.jp +!city.kobe.jp +!city.nagoya.jp +!city.sapporo.jp +!city.sendai.jp +!city.yokohama.jp +// 4th level registration +aisai.aichi.jp +ama.aichi.jp +anjo.aichi.jp +asuke.aichi.jp +chiryu.aichi.jp +chita.aichi.jp +fuso.aichi.jp +gamagori.aichi.jp +handa.aichi.jp +hazu.aichi.jp +hekinan.aichi.jp +higashiura.aichi.jp +ichinomiya.aichi.jp +inazawa.aichi.jp +inuyama.aichi.jp +isshiki.aichi.jp +iwakura.aichi.jp +kanie.aichi.jp +kariya.aichi.jp +kasugai.aichi.jp +kira.aichi.jp +kiyosu.aichi.jp +komaki.aichi.jp +konan.aichi.jp +kota.aichi.jp +mihama.aichi.jp +miyoshi.aichi.jp +nishio.aichi.jp +nisshin.aichi.jp +obu.aichi.jp +oguchi.aichi.jp +oharu.aichi.jp +okazaki.aichi.jp +owariasahi.aichi.jp +seto.aichi.jp +shikatsu.aichi.jp +shinshiro.aichi.jp +shitara.aichi.jp +tahara.aichi.jp +takahama.aichi.jp +tobishima.aichi.jp +toei.aichi.jp +togo.aichi.jp +tokai.aichi.jp +tokoname.aichi.jp +toyoake.aichi.jp +toyohashi.aichi.jp +toyokawa.aichi.jp +toyone.aichi.jp +toyota.aichi.jp +tsushima.aichi.jp +yatomi.aichi.jp +akita.akita.jp +daisen.akita.jp +fujisato.akita.jp +gojome.akita.jp +hachirogata.akita.jp +happou.akita.jp +higashinaruse.akita.jp +honjo.akita.jp +honjyo.akita.jp +ikawa.akita.jp +kamikoani.akita.jp +kamioka.akita.jp +katagami.akita.jp +kazuno.akita.jp +kitaakita.akita.jp +kosaka.akita.jp +kyowa.akita.jp +misato.akita.jp +mitane.akita.jp +moriyoshi.akita.jp +nikaho.akita.jp +noshiro.akita.jp +odate.akita.jp +oga.akita.jp +ogata.akita.jp +semboku.akita.jp +yokote.akita.jp +yurihonjo.akita.jp +aomori.aomori.jp +gonohe.aomori.jp +hachinohe.aomori.jp +hashikami.aomori.jp +hiranai.aomori.jp +hirosaki.aomori.jp +itayanagi.aomori.jp +kuroishi.aomori.jp +misawa.aomori.jp +mutsu.aomori.jp +nakadomari.aomori.jp +noheji.aomori.jp +oirase.aomori.jp +owani.aomori.jp +rokunohe.aomori.jp +sannohe.aomori.jp +shichinohe.aomori.jp +shingo.aomori.jp +takko.aomori.jp +towada.aomori.jp +tsugaru.aomori.jp +tsuruta.aomori.jp +abiko.chiba.jp +asahi.chiba.jp +chonan.chiba.jp +chosei.chiba.jp +choshi.chiba.jp +chuo.chiba.jp +funabashi.chiba.jp +futtsu.chiba.jp +hanamigawa.chiba.jp +ichihara.chiba.jp +ichikawa.chiba.jp +ichinomiya.chiba.jp +inzai.chiba.jp +isumi.chiba.jp +kamagaya.chiba.jp +kamogawa.chiba.jp +kashiwa.chiba.jp +katori.chiba.jp +katsuura.chiba.jp +kimitsu.chiba.jp +kisarazu.chiba.jp +kozaki.chiba.jp +kujukuri.chiba.jp +kyonan.chiba.jp +matsudo.chiba.jp +midori.chiba.jp +mihama.chiba.jp +minamiboso.chiba.jp +mobara.chiba.jp +mutsuzawa.chiba.jp +nagara.chiba.jp +nagareyama.chiba.jp +narashino.chiba.jp +narita.chiba.jp +noda.chiba.jp +oamishirasato.chiba.jp +omigawa.chiba.jp +onjuku.chiba.jp +otaki.chiba.jp +sakae.chiba.jp +sakura.chiba.jp +shimofusa.chiba.jp +shirako.chiba.jp +shiroi.chiba.jp +shisui.chiba.jp +sodegaura.chiba.jp +sosa.chiba.jp +tako.chiba.jp +tateyama.chiba.jp +togane.chiba.jp +tohnosho.chiba.jp +tomisato.chiba.jp +urayasu.chiba.jp +yachimata.chiba.jp +yachiyo.chiba.jp +yokaichiba.chiba.jp +yokoshibahikari.chiba.jp +yotsukaido.chiba.jp +ainan.ehime.jp +honai.ehime.jp +ikata.ehime.jp +imabari.ehime.jp +iyo.ehime.jp +kamijima.ehime.jp +kihoku.ehime.jp +kumakogen.ehime.jp +masaki.ehime.jp +matsuno.ehime.jp +matsuyama.ehime.jp +namikata.ehime.jp +niihama.ehime.jp +ozu.ehime.jp +saijo.ehime.jp +seiyo.ehime.jp +shikokuchuo.ehime.jp +tobe.ehime.jp +toon.ehime.jp +uchiko.ehime.jp +uwajima.ehime.jp +yawatahama.ehime.jp +echizen.fukui.jp +eiheiji.fukui.jp +fukui.fukui.jp +ikeda.fukui.jp +katsuyama.fukui.jp +mihama.fukui.jp +minamiechizen.fukui.jp +obama.fukui.jp +ohi.fukui.jp +ono.fukui.jp +sabae.fukui.jp +sakai.fukui.jp +takahama.fukui.jp +tsuruga.fukui.jp +wakasa.fukui.jp +ashiya.fukuoka.jp +buzen.fukuoka.jp +chikugo.fukuoka.jp +chikuho.fukuoka.jp +chikujo.fukuoka.jp +chikushino.fukuoka.jp +chikuzen.fukuoka.jp +chuo.fukuoka.jp +dazaifu.fukuoka.jp +fukuchi.fukuoka.jp +hakata.fukuoka.jp +higashi.fukuoka.jp +hirokawa.fukuoka.jp +hisayama.fukuoka.jp +iizuka.fukuoka.jp +inatsuki.fukuoka.jp +kaho.fukuoka.jp +kasuga.fukuoka.jp +kasuya.fukuoka.jp +kawara.fukuoka.jp +keisen.fukuoka.jp +koga.fukuoka.jp +kurate.fukuoka.jp +kurogi.fukuoka.jp +kurume.fukuoka.jp +minami.fukuoka.jp +miyako.fukuoka.jp +miyama.fukuoka.jp +miyawaka.fukuoka.jp +mizumaki.fukuoka.jp +munakata.fukuoka.jp +nakagawa.fukuoka.jp +nakama.fukuoka.jp +nishi.fukuoka.jp +nogata.fukuoka.jp +ogori.fukuoka.jp +okagaki.fukuoka.jp +okawa.fukuoka.jp +oki.fukuoka.jp +omuta.fukuoka.jp +onga.fukuoka.jp +onojo.fukuoka.jp +oto.fukuoka.jp +saigawa.fukuoka.jp +sasaguri.fukuoka.jp +shingu.fukuoka.jp +shinyoshitomi.fukuoka.jp +shonai.fukuoka.jp +soeda.fukuoka.jp +sue.fukuoka.jp +tachiarai.fukuoka.jp +tagawa.fukuoka.jp +takata.fukuoka.jp +toho.fukuoka.jp +toyotsu.fukuoka.jp +tsuiki.fukuoka.jp +ukiha.fukuoka.jp +umi.fukuoka.jp +usui.fukuoka.jp +yamada.fukuoka.jp +yame.fukuoka.jp +yanagawa.fukuoka.jp +yukuhashi.fukuoka.jp +aizubange.fukushima.jp +aizumisato.fukushima.jp +aizuwakamatsu.fukushima.jp +asakawa.fukushima.jp +bandai.fukushima.jp +date.fukushima.jp +fukushima.fukushima.jp +furudono.fukushima.jp +futaba.fukushima.jp +hanawa.fukushima.jp +higashi.fukushima.jp +hirata.fukushima.jp +hirono.fukushima.jp +iitate.fukushima.jp +inawashiro.fukushima.jp +ishikawa.fukushima.jp +iwaki.fukushima.jp +izumizaki.fukushima.jp +kagamiishi.fukushima.jp +kaneyama.fukushima.jp +kawamata.fukushima.jp +kitakata.fukushima.jp +kitashiobara.fukushima.jp +koori.fukushima.jp +koriyama.fukushima.jp +kunimi.fukushima.jp +miharu.fukushima.jp +mishima.fukushima.jp +namie.fukushima.jp +nango.fukushima.jp +nishiaizu.fukushima.jp +nishigo.fukushima.jp +okuma.fukushima.jp +omotego.fukushima.jp +ono.fukushima.jp +otama.fukushima.jp +samegawa.fukushima.jp +shimogo.fukushima.jp +shirakawa.fukushima.jp +showa.fukushima.jp +soma.fukushima.jp +sukagawa.fukushima.jp +taishin.fukushima.jp +tamakawa.fukushima.jp +tanagura.fukushima.jp +tenei.fukushima.jp +yabuki.fukushima.jp +yamato.fukushima.jp +yamatsuri.fukushima.jp +yanaizu.fukushima.jp +yugawa.fukushima.jp +anpachi.gifu.jp +ena.gifu.jp +gifu.gifu.jp +ginan.gifu.jp +godo.gifu.jp +gujo.gifu.jp +hashima.gifu.jp +hichiso.gifu.jp +hida.gifu.jp +higashishirakawa.gifu.jp +ibigawa.gifu.jp +ikeda.gifu.jp +kakamigahara.gifu.jp +kani.gifu.jp +kasahara.gifu.jp +kasamatsu.gifu.jp +kawaue.gifu.jp +kitagata.gifu.jp +mino.gifu.jp +minokamo.gifu.jp +mitake.gifu.jp +mizunami.gifu.jp +motosu.gifu.jp +nakatsugawa.gifu.jp +ogaki.gifu.jp +sakahogi.gifu.jp +seki.gifu.jp +sekigahara.gifu.jp +shirakawa.gifu.jp +tajimi.gifu.jp +takayama.gifu.jp +tarui.gifu.jp +toki.gifu.jp +tomika.gifu.jp +wanouchi.gifu.jp +yamagata.gifu.jp +yaotsu.gifu.jp +yoro.gifu.jp +annaka.gunma.jp +chiyoda.gunma.jp +fujioka.gunma.jp +higashiagatsuma.gunma.jp +isesaki.gunma.jp +itakura.gunma.jp +kanna.gunma.jp +kanra.gunma.jp +katashina.gunma.jp +kawaba.gunma.jp +kiryu.gunma.jp +kusatsu.gunma.jp +maebashi.gunma.jp +meiwa.gunma.jp +midori.gunma.jp +minakami.gunma.jp +naganohara.gunma.jp +nakanojo.gunma.jp +nanmoku.gunma.jp +numata.gunma.jp +oizumi.gunma.jp +ora.gunma.jp +ota.gunma.jp +shibukawa.gunma.jp +shimonita.gunma.jp +shinto.gunma.jp +showa.gunma.jp +takasaki.gunma.jp +takayama.gunma.jp +tamamura.gunma.jp +tatebayashi.gunma.jp +tomioka.gunma.jp +tsukiyono.gunma.jp +tsumagoi.gunma.jp +ueno.gunma.jp +yoshioka.gunma.jp +asaminami.hiroshima.jp +daiwa.hiroshima.jp +etajima.hiroshima.jp +fuchu.hiroshima.jp +fukuyama.hiroshima.jp +hatsukaichi.hiroshima.jp +higashihiroshima.hiroshima.jp +hongo.hiroshima.jp +jinsekikogen.hiroshima.jp +kaita.hiroshima.jp +kui.hiroshima.jp +kumano.hiroshima.jp +kure.hiroshima.jp +mihara.hiroshima.jp +miyoshi.hiroshima.jp +naka.hiroshima.jp +onomichi.hiroshima.jp +osakikamijima.hiroshima.jp +otake.hiroshima.jp +saka.hiroshima.jp +sera.hiroshima.jp +seranishi.hiroshima.jp +shinichi.hiroshima.jp +shobara.hiroshima.jp +takehara.hiroshima.jp +abashiri.hokkaido.jp +abira.hokkaido.jp +aibetsu.hokkaido.jp +akabira.hokkaido.jp +akkeshi.hokkaido.jp +asahikawa.hokkaido.jp +ashibetsu.hokkaido.jp +ashoro.hokkaido.jp +assabu.hokkaido.jp +atsuma.hokkaido.jp +bibai.hokkaido.jp +biei.hokkaido.jp +bifuka.hokkaido.jp +bihoro.hokkaido.jp +biratori.hokkaido.jp +chippubetsu.hokkaido.jp +chitose.hokkaido.jp +date.hokkaido.jp +ebetsu.hokkaido.jp +embetsu.hokkaido.jp +eniwa.hokkaido.jp +erimo.hokkaido.jp +esan.hokkaido.jp +esashi.hokkaido.jp +fukagawa.hokkaido.jp +fukushima.hokkaido.jp +furano.hokkaido.jp +furubira.hokkaido.jp +haboro.hokkaido.jp +hakodate.hokkaido.jp +hamatonbetsu.hokkaido.jp +hidaka.hokkaido.jp +higashikagura.hokkaido.jp +higashikawa.hokkaido.jp +hiroo.hokkaido.jp +hokuryu.hokkaido.jp +hokuto.hokkaido.jp +honbetsu.hokkaido.jp +horokanai.hokkaido.jp +horonobe.hokkaido.jp +ikeda.hokkaido.jp +imakane.hokkaido.jp +ishikari.hokkaido.jp +iwamizawa.hokkaido.jp +iwanai.hokkaido.jp +kamifurano.hokkaido.jp +kamikawa.hokkaido.jp +kamishihoro.hokkaido.jp +kamisunagawa.hokkaido.jp +kamoenai.hokkaido.jp +kayabe.hokkaido.jp +kembuchi.hokkaido.jp +kikonai.hokkaido.jp +kimobetsu.hokkaido.jp +kitahiroshima.hokkaido.jp +kitami.hokkaido.jp +kiyosato.hokkaido.jp +koshimizu.hokkaido.jp +kunneppu.hokkaido.jp +kuriyama.hokkaido.jp +kuromatsunai.hokkaido.jp +kushiro.hokkaido.jp +kutchan.hokkaido.jp +kyowa.hokkaido.jp +mashike.hokkaido.jp +matsumae.hokkaido.jp +mikasa.hokkaido.jp +minamifurano.hokkaido.jp +mombetsu.hokkaido.jp +moseushi.hokkaido.jp +mukawa.hokkaido.jp +muroran.hokkaido.jp +naie.hokkaido.jp +nakagawa.hokkaido.jp +nakasatsunai.hokkaido.jp +nakatombetsu.hokkaido.jp +nanae.hokkaido.jp +nanporo.hokkaido.jp +nayoro.hokkaido.jp +nemuro.hokkaido.jp +niikappu.hokkaido.jp +niki.hokkaido.jp +nishiokoppe.hokkaido.jp +noboribetsu.hokkaido.jp +numata.hokkaido.jp +obihiro.hokkaido.jp +obira.hokkaido.jp +oketo.hokkaido.jp +okoppe.hokkaido.jp +otaru.hokkaido.jp +otobe.hokkaido.jp +otofuke.hokkaido.jp +otoineppu.hokkaido.jp +oumu.hokkaido.jp +ozora.hokkaido.jp +pippu.hokkaido.jp +rankoshi.hokkaido.jp +rebun.hokkaido.jp +rikubetsu.hokkaido.jp +rishiri.hokkaido.jp +rishirifuji.hokkaido.jp +saroma.hokkaido.jp +sarufutsu.hokkaido.jp +shakotan.hokkaido.jp +shari.hokkaido.jp +shibecha.hokkaido.jp +shibetsu.hokkaido.jp +shikabe.hokkaido.jp +shikaoi.hokkaido.jp +shimamaki.hokkaido.jp +shimizu.hokkaido.jp +shimokawa.hokkaido.jp +shinshinotsu.hokkaido.jp +shintoku.hokkaido.jp +shiranuka.hokkaido.jp +shiraoi.hokkaido.jp +shiriuchi.hokkaido.jp +sobetsu.hokkaido.jp +sunagawa.hokkaido.jp +taiki.hokkaido.jp +takasu.hokkaido.jp +takikawa.hokkaido.jp +takinoue.hokkaido.jp +teshikaga.hokkaido.jp +tobetsu.hokkaido.jp +tohma.hokkaido.jp +tomakomai.hokkaido.jp +tomari.hokkaido.jp +toya.hokkaido.jp +toyako.hokkaido.jp +toyotomi.hokkaido.jp +toyoura.hokkaido.jp +tsubetsu.hokkaido.jp +tsukigata.hokkaido.jp +urakawa.hokkaido.jp +urausu.hokkaido.jp +uryu.hokkaido.jp +utashinai.hokkaido.jp +wakkanai.hokkaido.jp +wassamu.hokkaido.jp +yakumo.hokkaido.jp +yoichi.hokkaido.jp +aioi.hyogo.jp +akashi.hyogo.jp +ako.hyogo.jp +amagasaki.hyogo.jp +aogaki.hyogo.jp +asago.hyogo.jp +ashiya.hyogo.jp +awaji.hyogo.jp +fukusaki.hyogo.jp +goshiki.hyogo.jp +harima.hyogo.jp +himeji.hyogo.jp +ichikawa.hyogo.jp +inagawa.hyogo.jp +itami.hyogo.jp +kakogawa.hyogo.jp +kamigori.hyogo.jp +kamikawa.hyogo.jp +kasai.hyogo.jp +kasuga.hyogo.jp +kawanishi.hyogo.jp +miki.hyogo.jp +minamiawaji.hyogo.jp +nishinomiya.hyogo.jp +nishiwaki.hyogo.jp +ono.hyogo.jp +sanda.hyogo.jp +sannan.hyogo.jp +sasayama.hyogo.jp +sayo.hyogo.jp +shingu.hyogo.jp +shinonsen.hyogo.jp +shiso.hyogo.jp +sumoto.hyogo.jp +taishi.hyogo.jp +taka.hyogo.jp +takarazuka.hyogo.jp +takasago.hyogo.jp +takino.hyogo.jp +tamba.hyogo.jp +tatsuno.hyogo.jp +toyooka.hyogo.jp +yabu.hyogo.jp +yashiro.hyogo.jp +yoka.hyogo.jp +yokawa.hyogo.jp +ami.ibaraki.jp +asahi.ibaraki.jp +bando.ibaraki.jp +chikusei.ibaraki.jp +daigo.ibaraki.jp +fujishiro.ibaraki.jp +hitachi.ibaraki.jp +hitachinaka.ibaraki.jp +hitachiomiya.ibaraki.jp +hitachiota.ibaraki.jp +ibaraki.ibaraki.jp +ina.ibaraki.jp +inashiki.ibaraki.jp +itako.ibaraki.jp +iwama.ibaraki.jp +joso.ibaraki.jp +kamisu.ibaraki.jp +kasama.ibaraki.jp +kashima.ibaraki.jp +kasumigaura.ibaraki.jp +koga.ibaraki.jp +miho.ibaraki.jp +mito.ibaraki.jp +moriya.ibaraki.jp +naka.ibaraki.jp +namegata.ibaraki.jp +oarai.ibaraki.jp +ogawa.ibaraki.jp +omitama.ibaraki.jp +ryugasaki.ibaraki.jp +sakai.ibaraki.jp +sakuragawa.ibaraki.jp +shimodate.ibaraki.jp +shimotsuma.ibaraki.jp +shirosato.ibaraki.jp +sowa.ibaraki.jp +suifu.ibaraki.jp +takahagi.ibaraki.jp +tamatsukuri.ibaraki.jp +tokai.ibaraki.jp +tomobe.ibaraki.jp +tone.ibaraki.jp +toride.ibaraki.jp +tsuchiura.ibaraki.jp +tsukuba.ibaraki.jp +uchihara.ibaraki.jp +ushiku.ibaraki.jp +yachiyo.ibaraki.jp +yamagata.ibaraki.jp +yawara.ibaraki.jp +yuki.ibaraki.jp +anamizu.ishikawa.jp +hakui.ishikawa.jp +hakusan.ishikawa.jp +kaga.ishikawa.jp +kahoku.ishikawa.jp +kanazawa.ishikawa.jp +kawakita.ishikawa.jp +komatsu.ishikawa.jp +nakanoto.ishikawa.jp +nanao.ishikawa.jp +nomi.ishikawa.jp +nonoichi.ishikawa.jp +noto.ishikawa.jp +shika.ishikawa.jp +suzu.ishikawa.jp +tsubata.ishikawa.jp +tsurugi.ishikawa.jp +uchinada.ishikawa.jp +wajima.ishikawa.jp +fudai.iwate.jp +fujisawa.iwate.jp +hanamaki.iwate.jp +hiraizumi.iwate.jp +hirono.iwate.jp +ichinohe.iwate.jp +ichinoseki.iwate.jp +iwaizumi.iwate.jp +iwate.iwate.jp +joboji.iwate.jp +kamaishi.iwate.jp +kanegasaki.iwate.jp +karumai.iwate.jp +kawai.iwate.jp +kitakami.iwate.jp +kuji.iwate.jp +kunohe.iwate.jp +kuzumaki.iwate.jp +miyako.iwate.jp +mizusawa.iwate.jp +morioka.iwate.jp +ninohe.iwate.jp +noda.iwate.jp +ofunato.iwate.jp +oshu.iwate.jp +otsuchi.iwate.jp +rikuzentakata.iwate.jp +shiwa.iwate.jp +shizukuishi.iwate.jp +sumita.iwate.jp +tanohata.iwate.jp +tono.iwate.jp +yahaba.iwate.jp +yamada.iwate.jp +ayagawa.kagawa.jp +higashikagawa.kagawa.jp +kanonji.kagawa.jp +kotohira.kagawa.jp +manno.kagawa.jp +marugame.kagawa.jp +mitoyo.kagawa.jp +naoshima.kagawa.jp +sanuki.kagawa.jp +tadotsu.kagawa.jp +takamatsu.kagawa.jp +tonosho.kagawa.jp +uchinomi.kagawa.jp +utazu.kagawa.jp +zentsuji.kagawa.jp +akune.kagoshima.jp +amami.kagoshima.jp +hioki.kagoshima.jp +isa.kagoshima.jp +isen.kagoshima.jp +izumi.kagoshima.jp +kagoshima.kagoshima.jp +kanoya.kagoshima.jp +kawanabe.kagoshima.jp +kinko.kagoshima.jp +kouyama.kagoshima.jp +makurazaki.kagoshima.jp +matsumoto.kagoshima.jp +minamitane.kagoshima.jp +nakatane.kagoshima.jp +nishinoomote.kagoshima.jp +satsumasendai.kagoshima.jp +soo.kagoshima.jp +tarumizu.kagoshima.jp +yusui.kagoshima.jp +aikawa.kanagawa.jp +atsugi.kanagawa.jp +ayase.kanagawa.jp +chigasaki.kanagawa.jp +ebina.kanagawa.jp +fujisawa.kanagawa.jp +hadano.kanagawa.jp +hakone.kanagawa.jp +hiratsuka.kanagawa.jp +isehara.kanagawa.jp +kaisei.kanagawa.jp +kamakura.kanagawa.jp +kiyokawa.kanagawa.jp +matsuda.kanagawa.jp +minamiashigara.kanagawa.jp +miura.kanagawa.jp +nakai.kanagawa.jp +ninomiya.kanagawa.jp +odawara.kanagawa.jp +oi.kanagawa.jp +oiso.kanagawa.jp +sagamihara.kanagawa.jp +samukawa.kanagawa.jp +tsukui.kanagawa.jp +yamakita.kanagawa.jp +yamato.kanagawa.jp +yokosuka.kanagawa.jp +yugawara.kanagawa.jp +zama.kanagawa.jp +zushi.kanagawa.jp +aki.kochi.jp +geisei.kochi.jp +hidaka.kochi.jp +higashitsuno.kochi.jp +ino.kochi.jp +kagami.kochi.jp +kami.kochi.jp +kitagawa.kochi.jp +kochi.kochi.jp +mihara.kochi.jp +motoyama.kochi.jp +muroto.kochi.jp +nahari.kochi.jp +nakamura.kochi.jp +nankoku.kochi.jp +nishitosa.kochi.jp +niyodogawa.kochi.jp +ochi.kochi.jp +okawa.kochi.jp +otoyo.kochi.jp +otsuki.kochi.jp +sakawa.kochi.jp +sukumo.kochi.jp +susaki.kochi.jp +tosa.kochi.jp +tosashimizu.kochi.jp +toyo.kochi.jp +tsuno.kochi.jp +umaji.kochi.jp +yasuda.kochi.jp +yusuhara.kochi.jp +amakusa.kumamoto.jp +arao.kumamoto.jp +aso.kumamoto.jp +choyo.kumamoto.jp +gyokuto.kumamoto.jp +hitoyoshi.kumamoto.jp +kamiamakusa.kumamoto.jp +kashima.kumamoto.jp +kikuchi.kumamoto.jp +kosa.kumamoto.jp +kumamoto.kumamoto.jp +mashiki.kumamoto.jp +mifune.kumamoto.jp +minamata.kumamoto.jp +minamioguni.kumamoto.jp +nagasu.kumamoto.jp +nishihara.kumamoto.jp +oguni.kumamoto.jp +ozu.kumamoto.jp +sumoto.kumamoto.jp +takamori.kumamoto.jp +uki.kumamoto.jp +uto.kumamoto.jp +yamaga.kumamoto.jp +yamato.kumamoto.jp +yatsushiro.kumamoto.jp +ayabe.kyoto.jp +fukuchiyama.kyoto.jp +higashiyama.kyoto.jp +ide.kyoto.jp +ine.kyoto.jp +joyo.kyoto.jp +kameoka.kyoto.jp +kamo.kyoto.jp +kita.kyoto.jp +kizu.kyoto.jp +kumiyama.kyoto.jp +kyotamba.kyoto.jp +kyotanabe.kyoto.jp +kyotango.kyoto.jp +maizuru.kyoto.jp +minami.kyoto.jp +minamiyamashiro.kyoto.jp +miyazu.kyoto.jp +muko.kyoto.jp +nagaokakyo.kyoto.jp +nakagyo.kyoto.jp +nantan.kyoto.jp +oyamazaki.kyoto.jp +sakyo.kyoto.jp +seika.kyoto.jp +tanabe.kyoto.jp +uji.kyoto.jp +ujitawara.kyoto.jp +wazuka.kyoto.jp +yamashina.kyoto.jp +yawata.kyoto.jp +asahi.mie.jp +inabe.mie.jp +ise.mie.jp +kameyama.mie.jp +kawagoe.mie.jp +kiho.mie.jp +kisosaki.mie.jp +kiwa.mie.jp +komono.mie.jp +kumano.mie.jp +kuwana.mie.jp +matsusaka.mie.jp +meiwa.mie.jp +mihama.mie.jp +minamiise.mie.jp +misugi.mie.jp +miyama.mie.jp +nabari.mie.jp +shima.mie.jp +suzuka.mie.jp +tado.mie.jp +taiki.mie.jp +taki.mie.jp +tamaki.mie.jp +toba.mie.jp +tsu.mie.jp +udono.mie.jp +ureshino.mie.jp +watarai.mie.jp +yokkaichi.mie.jp +furukawa.miyagi.jp +higashimatsushima.miyagi.jp +ishinomaki.miyagi.jp +iwanuma.miyagi.jp +kakuda.miyagi.jp +kami.miyagi.jp +kawasaki.miyagi.jp +kesennuma.miyagi.jp +marumori.miyagi.jp +matsushima.miyagi.jp +minamisanriku.miyagi.jp +misato.miyagi.jp +murata.miyagi.jp +natori.miyagi.jp +ogawara.miyagi.jp +ohira.miyagi.jp +onagawa.miyagi.jp +osaki.miyagi.jp +rifu.miyagi.jp +semine.miyagi.jp +shibata.miyagi.jp +shichikashuku.miyagi.jp +shikama.miyagi.jp +shiogama.miyagi.jp +shiroishi.miyagi.jp +tagajo.miyagi.jp +taiwa.miyagi.jp +tome.miyagi.jp +tomiya.miyagi.jp +wakuya.miyagi.jp +watari.miyagi.jp +yamamoto.miyagi.jp +zao.miyagi.jp +aya.miyazaki.jp +ebino.miyazaki.jp +gokase.miyazaki.jp +hyuga.miyazaki.jp +kadogawa.miyazaki.jp +kawaminami.miyazaki.jp +kijo.miyazaki.jp +kitagawa.miyazaki.jp +kitakata.miyazaki.jp +kitaura.miyazaki.jp +kobayashi.miyazaki.jp +kunitomi.miyazaki.jp +kushima.miyazaki.jp +mimata.miyazaki.jp +miyakonojo.miyazaki.jp +miyazaki.miyazaki.jp +morotsuka.miyazaki.jp +nichinan.miyazaki.jp +nishimera.miyazaki.jp +nobeoka.miyazaki.jp +saito.miyazaki.jp +shiiba.miyazaki.jp +shintomi.miyazaki.jp +takaharu.miyazaki.jp +takanabe.miyazaki.jp +takazaki.miyazaki.jp +tsuno.miyazaki.jp +achi.nagano.jp +agematsu.nagano.jp +anan.nagano.jp +aoki.nagano.jp +asahi.nagano.jp +azumino.nagano.jp +chikuhoku.nagano.jp +chikuma.nagano.jp +chino.nagano.jp +fujimi.nagano.jp +hakuba.nagano.jp +hara.nagano.jp +hiraya.nagano.jp +iida.nagano.jp +iijima.nagano.jp +iiyama.nagano.jp +iizuna.nagano.jp +ikeda.nagano.jp +ikusaka.nagano.jp +ina.nagano.jp +karuizawa.nagano.jp +kawakami.nagano.jp +kiso.nagano.jp +kisofukushima.nagano.jp +kitaaiki.nagano.jp +komagane.nagano.jp +komoro.nagano.jp +matsukawa.nagano.jp +matsumoto.nagano.jp +miasa.nagano.jp +minamiaiki.nagano.jp +minamimaki.nagano.jp +minamiminowa.nagano.jp +minowa.nagano.jp +miyada.nagano.jp +miyota.nagano.jp +mochizuki.nagano.jp +nagano.nagano.jp +nagawa.nagano.jp +nagiso.nagano.jp +nakagawa.nagano.jp +nakano.nagano.jp +nozawaonsen.nagano.jp +obuse.nagano.jp +ogawa.nagano.jp +okaya.nagano.jp +omachi.nagano.jp +omi.nagano.jp +ookuwa.nagano.jp +ooshika.nagano.jp +otaki.nagano.jp +otari.nagano.jp +sakae.nagano.jp +sakaki.nagano.jp +saku.nagano.jp +sakuho.nagano.jp +shimosuwa.nagano.jp +shinanomachi.nagano.jp +shiojiri.nagano.jp +suwa.nagano.jp +suzaka.nagano.jp +takagi.nagano.jp +takamori.nagano.jp +takayama.nagano.jp +tateshina.nagano.jp +tatsuno.nagano.jp +togakushi.nagano.jp +togura.nagano.jp +tomi.nagano.jp +ueda.nagano.jp +wada.nagano.jp +yamagata.nagano.jp +yamanouchi.nagano.jp +yasaka.nagano.jp +yasuoka.nagano.jp +chijiwa.nagasaki.jp +futsu.nagasaki.jp +goto.nagasaki.jp +hasami.nagasaki.jp +hirado.nagasaki.jp +iki.nagasaki.jp +isahaya.nagasaki.jp +kawatana.nagasaki.jp +kuchinotsu.nagasaki.jp +matsuura.nagasaki.jp +nagasaki.nagasaki.jp +obama.nagasaki.jp +omura.nagasaki.jp +oseto.nagasaki.jp +saikai.nagasaki.jp +sasebo.nagasaki.jp +seihi.nagasaki.jp +shimabara.nagasaki.jp +shinkamigoto.nagasaki.jp +togitsu.nagasaki.jp +tsushima.nagasaki.jp +unzen.nagasaki.jp +ando.nara.jp +gose.nara.jp +heguri.nara.jp +higashiyoshino.nara.jp +ikaruga.nara.jp +ikoma.nara.jp +kamikitayama.nara.jp +kanmaki.nara.jp +kashiba.nara.jp +kashihara.nara.jp +katsuragi.nara.jp +kawai.nara.jp +kawakami.nara.jp +kawanishi.nara.jp +koryo.nara.jp +kurotaki.nara.jp +mitsue.nara.jp +miyake.nara.jp +nara.nara.jp +nosegawa.nara.jp +oji.nara.jp +ouda.nara.jp +oyodo.nara.jp +sakurai.nara.jp +sango.nara.jp +shimoichi.nara.jp +shimokitayama.nara.jp +shinjo.nara.jp +soni.nara.jp +takatori.nara.jp +tawaramoto.nara.jp +tenkawa.nara.jp +tenri.nara.jp +uda.nara.jp +yamatokoriyama.nara.jp +yamatotakada.nara.jp +yamazoe.nara.jp +yoshino.nara.jp +aga.niigata.jp +agano.niigata.jp +gosen.niigata.jp +itoigawa.niigata.jp +izumozaki.niigata.jp +joetsu.niigata.jp +kamo.niigata.jp +kariwa.niigata.jp +kashiwazaki.niigata.jp +minamiuonuma.niigata.jp +mitsuke.niigata.jp +muika.niigata.jp +murakami.niigata.jp +myoko.niigata.jp +nagaoka.niigata.jp +niigata.niigata.jp +ojiya.niigata.jp +omi.niigata.jp +sado.niigata.jp +sanjo.niigata.jp +seiro.niigata.jp +seirou.niigata.jp +sekikawa.niigata.jp +shibata.niigata.jp +tagami.niigata.jp +tainai.niigata.jp +tochio.niigata.jp +tokamachi.niigata.jp +tsubame.niigata.jp +tsunan.niigata.jp +uonuma.niigata.jp +yahiko.niigata.jp +yoita.niigata.jp +yuzawa.niigata.jp +beppu.oita.jp +bungoono.oita.jp +bungotakada.oita.jp +hasama.oita.jp +hiji.oita.jp +himeshima.oita.jp +hita.oita.jp +kamitsue.oita.jp +kokonoe.oita.jp +kuju.oita.jp +kunisaki.oita.jp +kusu.oita.jp +oita.oita.jp +saiki.oita.jp +taketa.oita.jp +tsukumi.oita.jp +usa.oita.jp +usuki.oita.jp +yufu.oita.jp +akaiwa.okayama.jp +asakuchi.okayama.jp +bizen.okayama.jp +hayashima.okayama.jp +ibara.okayama.jp +kagamino.okayama.jp +kasaoka.okayama.jp +kibichuo.okayama.jp +kumenan.okayama.jp +kurashiki.okayama.jp +maniwa.okayama.jp +misaki.okayama.jp +nagi.okayama.jp +niimi.okayama.jp +nishiawakura.okayama.jp +okayama.okayama.jp +satosho.okayama.jp +setouchi.okayama.jp +shinjo.okayama.jp +shoo.okayama.jp +soja.okayama.jp +takahashi.okayama.jp +tamano.okayama.jp +tsuyama.okayama.jp +wake.okayama.jp +yakage.okayama.jp +aguni.okinawa.jp +ginowan.okinawa.jp +ginoza.okinawa.jp +gushikami.okinawa.jp +haebaru.okinawa.jp +higashi.okinawa.jp +hirara.okinawa.jp +iheya.okinawa.jp +ishigaki.okinawa.jp +ishikawa.okinawa.jp +itoman.okinawa.jp +izena.okinawa.jp +kadena.okinawa.jp +kin.okinawa.jp +kitadaito.okinawa.jp +kitanakagusuku.okinawa.jp +kumejima.okinawa.jp +kunigami.okinawa.jp +minamidaito.okinawa.jp +motobu.okinawa.jp +nago.okinawa.jp +naha.okinawa.jp +nakagusuku.okinawa.jp +nakijin.okinawa.jp +nanjo.okinawa.jp +nishihara.okinawa.jp +ogimi.okinawa.jp +okinawa.okinawa.jp +onna.okinawa.jp +shimoji.okinawa.jp +taketomi.okinawa.jp +tarama.okinawa.jp +tokashiki.okinawa.jp +tomigusuku.okinawa.jp +tonaki.okinawa.jp +urasoe.okinawa.jp +uruma.okinawa.jp +yaese.okinawa.jp +yomitan.okinawa.jp +yonabaru.okinawa.jp +yonaguni.okinawa.jp +zamami.okinawa.jp +abeno.osaka.jp +chihayaakasaka.osaka.jp +chuo.osaka.jp +daito.osaka.jp +fujiidera.osaka.jp +habikino.osaka.jp +hannan.osaka.jp +higashiosaka.osaka.jp +higashisumiyoshi.osaka.jp +higashiyodogawa.osaka.jp +hirakata.osaka.jp +ibaraki.osaka.jp +ikeda.osaka.jp +izumi.osaka.jp +izumiotsu.osaka.jp +izumisano.osaka.jp +kadoma.osaka.jp +kaizuka.osaka.jp +kanan.osaka.jp +kashiwara.osaka.jp +katano.osaka.jp +kawachinagano.osaka.jp +kishiwada.osaka.jp +kita.osaka.jp +kumatori.osaka.jp +matsubara.osaka.jp +minato.osaka.jp +minoh.osaka.jp +misaki.osaka.jp +moriguchi.osaka.jp +neyagawa.osaka.jp +nishi.osaka.jp +nose.osaka.jp +osakasayama.osaka.jp +sakai.osaka.jp +sayama.osaka.jp +sennan.osaka.jp +settsu.osaka.jp +shijonawate.osaka.jp +shimamoto.osaka.jp +suita.osaka.jp +tadaoka.osaka.jp +taishi.osaka.jp +tajiri.osaka.jp +takaishi.osaka.jp +takatsuki.osaka.jp +tondabayashi.osaka.jp +toyonaka.osaka.jp +toyono.osaka.jp +yao.osaka.jp +ariake.saga.jp +arita.saga.jp +fukudomi.saga.jp +genkai.saga.jp +hamatama.saga.jp +hizen.saga.jp +imari.saga.jp +kamimine.saga.jp +kanzaki.saga.jp +karatsu.saga.jp +kashima.saga.jp +kitagata.saga.jp +kitahata.saga.jp +kiyama.saga.jp +kouhoku.saga.jp +kyuragi.saga.jp +nishiarita.saga.jp +ogi.saga.jp +omachi.saga.jp +ouchi.saga.jp +saga.saga.jp +shiroishi.saga.jp +taku.saga.jp +tara.saga.jp +tosu.saga.jp +yoshinogari.saga.jp +arakawa.saitama.jp +asaka.saitama.jp +chichibu.saitama.jp +fujimi.saitama.jp +fujimino.saitama.jp +fukaya.saitama.jp +hanno.saitama.jp +hanyu.saitama.jp +hasuda.saitama.jp +hatogaya.saitama.jp +hatoyama.saitama.jp +hidaka.saitama.jp +higashichichibu.saitama.jp +higashimatsuyama.saitama.jp +honjo.saitama.jp +ina.saitama.jp +iruma.saitama.jp +iwatsuki.saitama.jp +kamiizumi.saitama.jp +kamikawa.saitama.jp +kamisato.saitama.jp +kasukabe.saitama.jp +kawagoe.saitama.jp +kawaguchi.saitama.jp +kawajima.saitama.jp +kazo.saitama.jp +kitamoto.saitama.jp +koshigaya.saitama.jp +kounosu.saitama.jp +kuki.saitama.jp +kumagaya.saitama.jp +matsubushi.saitama.jp +minano.saitama.jp +misato.saitama.jp +miyashiro.saitama.jp +miyoshi.saitama.jp +moroyama.saitama.jp +nagatoro.saitama.jp +namegawa.saitama.jp +niiza.saitama.jp +ogano.saitama.jp +ogawa.saitama.jp +ogose.saitama.jp +okegawa.saitama.jp +omiya.saitama.jp +otaki.saitama.jp +ranzan.saitama.jp +ryokami.saitama.jp +saitama.saitama.jp +sakado.saitama.jp +satte.saitama.jp +sayama.saitama.jp +shiki.saitama.jp +shiraoka.saitama.jp +soka.saitama.jp +sugito.saitama.jp +toda.saitama.jp +tokigawa.saitama.jp +tokorozawa.saitama.jp +tsurugashima.saitama.jp +urawa.saitama.jp +warabi.saitama.jp +yashio.saitama.jp +yokoze.saitama.jp +yono.saitama.jp +yorii.saitama.jp +yoshida.saitama.jp +yoshikawa.saitama.jp +yoshimi.saitama.jp +aisho.shiga.jp +gamo.shiga.jp +higashiomi.shiga.jp +hikone.shiga.jp +koka.shiga.jp +konan.shiga.jp +kosei.shiga.jp +koto.shiga.jp +kusatsu.shiga.jp +maibara.shiga.jp +moriyama.shiga.jp +nagahama.shiga.jp +nishiazai.shiga.jp +notogawa.shiga.jp +omihachiman.shiga.jp +otsu.shiga.jp +ritto.shiga.jp +ryuoh.shiga.jp +takashima.shiga.jp +takatsuki.shiga.jp +torahime.shiga.jp +toyosato.shiga.jp +yasu.shiga.jp +akagi.shimane.jp +ama.shimane.jp +gotsu.shimane.jp +hamada.shimane.jp +higashiizumo.shimane.jp +hikawa.shimane.jp +hikimi.shimane.jp +izumo.shimane.jp +kakinoki.shimane.jp +masuda.shimane.jp +matsue.shimane.jp +misato.shimane.jp +nishinoshima.shimane.jp +ohda.shimane.jp +okinoshima.shimane.jp +okuizumo.shimane.jp +shimane.shimane.jp +tamayu.shimane.jp +tsuwano.shimane.jp +unnan.shimane.jp +yakumo.shimane.jp +yasugi.shimane.jp +yatsuka.shimane.jp +arai.shizuoka.jp +atami.shizuoka.jp +fuji.shizuoka.jp +fujieda.shizuoka.jp +fujikawa.shizuoka.jp +fujinomiya.shizuoka.jp +fukuroi.shizuoka.jp +gotemba.shizuoka.jp +haibara.shizuoka.jp +hamamatsu.shizuoka.jp +higashiizu.shizuoka.jp +ito.shizuoka.jp +iwata.shizuoka.jp +izu.shizuoka.jp +izunokuni.shizuoka.jp +kakegawa.shizuoka.jp +kannami.shizuoka.jp +kawanehon.shizuoka.jp +kawazu.shizuoka.jp +kikugawa.shizuoka.jp +kosai.shizuoka.jp +makinohara.shizuoka.jp +matsuzaki.shizuoka.jp +minamiizu.shizuoka.jp +mishima.shizuoka.jp +morimachi.shizuoka.jp +nishiizu.shizuoka.jp +numazu.shizuoka.jp +omaezaki.shizuoka.jp +shimada.shizuoka.jp +shimizu.shizuoka.jp +shimoda.shizuoka.jp +shizuoka.shizuoka.jp +susono.shizuoka.jp +yaizu.shizuoka.jp +yoshida.shizuoka.jp +ashikaga.tochigi.jp +bato.tochigi.jp +haga.tochigi.jp +ichikai.tochigi.jp +iwafune.tochigi.jp +kaminokawa.tochigi.jp +kanuma.tochigi.jp +karasuyama.tochigi.jp +kuroiso.tochigi.jp +mashiko.tochigi.jp +mibu.tochigi.jp +moka.tochigi.jp +motegi.tochigi.jp +nasu.tochigi.jp +nasushiobara.tochigi.jp +nikko.tochigi.jp +nishikata.tochigi.jp +nogi.tochigi.jp +ohira.tochigi.jp +ohtawara.tochigi.jp +oyama.tochigi.jp +sakura.tochigi.jp +sano.tochigi.jp +shimotsuke.tochigi.jp +shioya.tochigi.jp +takanezawa.tochigi.jp +tochigi.tochigi.jp +tsuga.tochigi.jp +ujiie.tochigi.jp +utsunomiya.tochigi.jp +yaita.tochigi.jp +aizumi.tokushima.jp +anan.tokushima.jp +ichiba.tokushima.jp +itano.tokushima.jp +kainan.tokushima.jp +komatsushima.tokushima.jp +matsushige.tokushima.jp +mima.tokushima.jp +minami.tokushima.jp +miyoshi.tokushima.jp +mugi.tokushima.jp +nakagawa.tokushima.jp +naruto.tokushima.jp +sanagochi.tokushima.jp +shishikui.tokushima.jp +tokushima.tokushima.jp +wajiki.tokushima.jp +adachi.tokyo.jp +akiruno.tokyo.jp +akishima.tokyo.jp +aogashima.tokyo.jp +arakawa.tokyo.jp +bunkyo.tokyo.jp +chiyoda.tokyo.jp +chofu.tokyo.jp +chuo.tokyo.jp +edogawa.tokyo.jp +fuchu.tokyo.jp +fussa.tokyo.jp +hachijo.tokyo.jp +hachioji.tokyo.jp +hamura.tokyo.jp +higashikurume.tokyo.jp +higashimurayama.tokyo.jp +higashiyamato.tokyo.jp +hino.tokyo.jp +hinode.tokyo.jp +hinohara.tokyo.jp +inagi.tokyo.jp +itabashi.tokyo.jp +katsushika.tokyo.jp +kita.tokyo.jp +kiyose.tokyo.jp +kodaira.tokyo.jp +koganei.tokyo.jp +kokubunji.tokyo.jp +komae.tokyo.jp +koto.tokyo.jp +kouzushima.tokyo.jp +kunitachi.tokyo.jp +machida.tokyo.jp +meguro.tokyo.jp +minato.tokyo.jp +mitaka.tokyo.jp +mizuho.tokyo.jp +musashimurayama.tokyo.jp +musashino.tokyo.jp +nakano.tokyo.jp +nerima.tokyo.jp +ogasawara.tokyo.jp +okutama.tokyo.jp +ome.tokyo.jp +oshima.tokyo.jp +ota.tokyo.jp +setagaya.tokyo.jp +shibuya.tokyo.jp +shinagawa.tokyo.jp +shinjuku.tokyo.jp +suginami.tokyo.jp +sumida.tokyo.jp +tachikawa.tokyo.jp +taito.tokyo.jp +tama.tokyo.jp +toshima.tokyo.jp +chizu.tottori.jp +hino.tottori.jp +kawahara.tottori.jp +koge.tottori.jp +kotoura.tottori.jp +misasa.tottori.jp +nanbu.tottori.jp +nichinan.tottori.jp +sakaiminato.tottori.jp +tottori.tottori.jp +wakasa.tottori.jp +yazu.tottori.jp +yonago.tottori.jp +asahi.toyama.jp +fuchu.toyama.jp +fukumitsu.toyama.jp +funahashi.toyama.jp +himi.toyama.jp +imizu.toyama.jp +inami.toyama.jp +johana.toyama.jp +kamiichi.toyama.jp +kurobe.toyama.jp +nakaniikawa.toyama.jp +namerikawa.toyama.jp +nanto.toyama.jp +nyuzen.toyama.jp +oyabe.toyama.jp +taira.toyama.jp +takaoka.toyama.jp +tateyama.toyama.jp +toga.toyama.jp +tonami.toyama.jp +toyama.toyama.jp +unazuki.toyama.jp +uozu.toyama.jp +yamada.toyama.jp +arida.wakayama.jp +aridagawa.wakayama.jp +gobo.wakayama.jp +hashimoto.wakayama.jp +hidaka.wakayama.jp +hirogawa.wakayama.jp +inami.wakayama.jp +iwade.wakayama.jp +kainan.wakayama.jp +kamitonda.wakayama.jp +katsuragi.wakayama.jp +kimino.wakayama.jp +kinokawa.wakayama.jp +kitayama.wakayama.jp +koya.wakayama.jp +koza.wakayama.jp +kozagawa.wakayama.jp +kudoyama.wakayama.jp +kushimoto.wakayama.jp +mihama.wakayama.jp +misato.wakayama.jp +nachikatsuura.wakayama.jp +shingu.wakayama.jp +shirahama.wakayama.jp +taiji.wakayama.jp +tanabe.wakayama.jp +wakayama.wakayama.jp +yuasa.wakayama.jp +yura.wakayama.jp +asahi.yamagata.jp +funagata.yamagata.jp +higashine.yamagata.jp +iide.yamagata.jp +kahoku.yamagata.jp +kaminoyama.yamagata.jp +kaneyama.yamagata.jp +kawanishi.yamagata.jp +mamurogawa.yamagata.jp +mikawa.yamagata.jp +murayama.yamagata.jp +nagai.yamagata.jp +nakayama.yamagata.jp +nanyo.yamagata.jp +nishikawa.yamagata.jp +obanazawa.yamagata.jp +oe.yamagata.jp +oguni.yamagata.jp +ohkura.yamagata.jp +oishida.yamagata.jp +sagae.yamagata.jp +sakata.yamagata.jp +sakegawa.yamagata.jp +shinjo.yamagata.jp +shirataka.yamagata.jp +shonai.yamagata.jp +takahata.yamagata.jp +tendo.yamagata.jp +tozawa.yamagata.jp +tsuruoka.yamagata.jp +yamagata.yamagata.jp +yamanobe.yamagata.jp +yonezawa.yamagata.jp +yuza.yamagata.jp +abu.yamaguchi.jp +hagi.yamaguchi.jp +hikari.yamaguchi.jp +hofu.yamaguchi.jp +iwakuni.yamaguchi.jp +kudamatsu.yamaguchi.jp +mitou.yamaguchi.jp +nagato.yamaguchi.jp +oshima.yamaguchi.jp +shimonoseki.yamaguchi.jp +shunan.yamaguchi.jp +tabuse.yamaguchi.jp +tokuyama.yamaguchi.jp +toyota.yamaguchi.jp +ube.yamaguchi.jp +yuu.yamaguchi.jp +chuo.yamanashi.jp +doshi.yamanashi.jp +fuefuki.yamanashi.jp +fujikawa.yamanashi.jp +fujikawaguchiko.yamanashi.jp +fujiyoshida.yamanashi.jp +hayakawa.yamanashi.jp +hokuto.yamanashi.jp +ichikawamisato.yamanashi.jp +kai.yamanashi.jp +kofu.yamanashi.jp +koshu.yamanashi.jp +kosuge.yamanashi.jp +minami-alps.yamanashi.jp +minobu.yamanashi.jp +nakamichi.yamanashi.jp +nanbu.yamanashi.jp +narusawa.yamanashi.jp +nirasaki.yamanashi.jp +nishikatsura.yamanashi.jp +oshino.yamanashi.jp +otsuki.yamanashi.jp +showa.yamanashi.jp +tabayama.yamanashi.jp +tsuru.yamanashi.jp +uenohara.yamanashi.jp +yamanakako.yamanashi.jp +yamanashi.yamanashi.jp + +// ke : http://www.kenic.or.ke/index.php?option=com_content&task=view&id=117&Itemid=145 +*.ke + +// kg : http://www.domain.kg/dmn_n.html +kg +org.kg +net.kg +com.kg +edu.kg +gov.kg +mil.kg + +// kh : http://www.mptc.gov.kh/dns_registration.htm +*.kh + +// ki : http://www.ki/dns/index.html +ki +edu.ki +biz.ki +net.ki +org.ki +gov.ki +info.ki +com.ki + +// km : http://en.wikipedia.org/wiki/.km +// http://www.domaine.km/documents/charte.doc +km +org.km +nom.km +gov.km +prd.km +tm.km +edu.km +mil.km +ass.km +com.km +// These are only mentioned as proposed suggestions at domaine.km, but +// http://en.wikipedia.org/wiki/.km says they're available for registration: +coop.km +asso.km +presse.km +medecin.km +notaires.km +pharmaciens.km +veterinaire.km +gouv.km + +// kn : http://en.wikipedia.org/wiki/.kn +// http://www.dot.kn/domainRules.html +kn +net.kn +org.kn +edu.kn +gov.kn + +// kp : http://www.kcce.kp/en_index.php +kp +com.kp +edu.kp +gov.kp +org.kp +rep.kp +tra.kp + +// kr : http://en.wikipedia.org/wiki/.kr +// see also: http://domain.nida.or.kr/eng/registration.jsp +kr +ac.kr +co.kr +es.kr +go.kr +hs.kr +kg.kr +mil.kr +ms.kr +ne.kr +or.kr +pe.kr +re.kr +sc.kr +// kr geographical names +busan.kr +chungbuk.kr +chungnam.kr +daegu.kr +daejeon.kr +gangwon.kr +gwangju.kr +gyeongbuk.kr +gyeonggi.kr +gyeongnam.kr +incheon.kr +jeju.kr +jeonbuk.kr +jeonnam.kr +seoul.kr +ulsan.kr + +// kw : http://en.wikipedia.org/wiki/.kw +*.kw + +// ky : http://www.icta.ky/da_ky_reg_dom.php +// Confirmed by registry 2008-06-17 +ky +edu.ky +gov.ky +com.ky +org.ky +net.ky + +// kz : http://en.wikipedia.org/wiki/.kz +// see also: http://www.nic.kz/rules/index.jsp +kz +org.kz +edu.kz +net.kz +gov.kz +mil.kz +com.kz + +// la : http://en.wikipedia.org/wiki/.la +// Submitted by registry 2008-06-10 +la +int.la +net.la +info.la +edu.la +gov.la +per.la +com.la +org.la + +// lb : http://en.wikipedia.org/wiki/.lb +// Submitted by registry 2008-06-17 +lb +com.lb +edu.lb +gov.lb +net.lb +org.lb + +// lc : http://en.wikipedia.org/wiki/.lc +// see also: http://www.nic.lc/rules.htm +lc +com.lc +net.lc +co.lc +org.lc +edu.lc +gov.lc + +// li : http://en.wikipedia.org/wiki/.li +li + +// lk : http://www.nic.lk/seclevpr.html +lk +gov.lk +sch.lk +net.lk +int.lk +com.lk +org.lk +edu.lk +ngo.lk +soc.lk +web.lk +ltd.lk +assn.lk +grp.lk +hotel.lk + +// lr : http://psg.com/dns/lr/lr.txt +// Submitted by registry 2008-06-17 +lr +com.lr +edu.lr +gov.lr +org.lr +net.lr + +// ls : http://en.wikipedia.org/wiki/.ls +ls +co.ls +org.ls + +// lt : http://en.wikipedia.org/wiki/.lt +lt +// gov.lt : http://www.gov.lt/index_en.php +gov.lt + +// lu : http://www.dns.lu/en/ +lu + +// lv : http://www.nic.lv/DNS/En/generic.php +lv +com.lv +edu.lv +gov.lv +org.lv +mil.lv +id.lv +net.lv +asn.lv +conf.lv + +// ly : http://www.nic.ly/regulations.php +ly +com.ly +net.ly +gov.ly +plc.ly +edu.ly +sch.ly +med.ly +org.ly +id.ly + +// ma : http://en.wikipedia.org/wiki/.ma +// http://www.anrt.ma/fr/admin/download/upload/file_fr782.pdf +ma +co.ma +net.ma +gov.ma +org.ma +ac.ma +press.ma + +// mc : http://www.nic.mc/ +mc +tm.mc +asso.mc + +// md : http://en.wikipedia.org/wiki/.md +md + +// me : http://en.wikipedia.org/wiki/.me +me +co.me +net.me +org.me +edu.me +ac.me +gov.me +its.me +priv.me + +// mg : http://www.nic.mg/tarif.htm +mg +org.mg +nom.mg +gov.mg +prd.mg +tm.mg +edu.mg +mil.mg +com.mg + +// mh : http://en.wikipedia.org/wiki/.mh +mh + +// mil : http://en.wikipedia.org/wiki/.mil +mil + +// mk : http://en.wikipedia.org/wiki/.mk +// see also: http://dns.marnet.net.mk/postapka.php +mk +com.mk +org.mk +net.mk +edu.mk +gov.mk +inf.mk +name.mk + +// ml : http://www.gobin.info/domainname/ml-template.doc +// see also: http://en.wikipedia.org/wiki/.ml +ml +com.ml +edu.ml +gouv.ml +gov.ml +net.ml +org.ml +presse.ml + +// mm : http://en.wikipedia.org/wiki/.mm +*.mm + +// mn : http://en.wikipedia.org/wiki/.mn +mn +gov.mn +edu.mn +org.mn + +// mo : http://www.monic.net.mo/ +mo +com.mo +net.mo +org.mo +edu.mo +gov.mo + +// mobi : http://en.wikipedia.org/wiki/.mobi +mobi + +// mp : http://www.dot.mp/ +// Confirmed by registry 2008-06-17 +mp + +// mq : http://en.wikipedia.org/wiki/.mq +mq + +// mr : http://en.wikipedia.org/wiki/.mr +mr +gov.mr + +// ms : http://www.nic.ms/pdf/MS_Domain_Name_Rules.pdf +ms +com.ms +edu.ms +gov.ms +net.ms +org.ms + +// mt : https://www.nic.org.mt/go/policy +// Submitted by registry 2013-11-19 +mt +com.mt +edu.mt +net.mt +org.mt + +// mu : http://en.wikipedia.org/wiki/.mu +mu +com.mu +net.mu +org.mu +gov.mu +ac.mu +co.mu +or.mu + +// museum : http://about.museum/naming/ +// http://index.museum/ +museum +academy.museum +agriculture.museum +air.museum +airguard.museum +alabama.museum +alaska.museum +amber.museum +ambulance.museum +american.museum +americana.museum +americanantiques.museum +americanart.museum +amsterdam.museum +and.museum +annefrank.museum +anthro.museum +anthropology.museum +antiques.museum +aquarium.museum +arboretum.museum +archaeological.museum +archaeology.museum +architecture.museum +art.museum +artanddesign.museum +artcenter.museum +artdeco.museum +arteducation.museum +artgallery.museum +arts.museum +artsandcrafts.museum +asmatart.museum +assassination.museum +assisi.museum +association.museum +astronomy.museum +atlanta.museum +austin.museum +australia.museum +automotive.museum +aviation.museum +axis.museum +badajoz.museum +baghdad.museum +bahn.museum +bale.museum +baltimore.museum +barcelona.museum +baseball.museum +basel.museum +baths.museum +bauern.museum +beauxarts.museum +beeldengeluid.museum +bellevue.museum +bergbau.museum +berkeley.museum +berlin.museum +bern.museum +bible.museum +bilbao.museum +bill.museum +birdart.museum +birthplace.museum +bonn.museum +boston.museum +botanical.museum +botanicalgarden.museum +botanicgarden.museum +botany.museum +brandywinevalley.museum +brasil.museum +bristol.museum +british.museum +britishcolumbia.museum +broadcast.museum +brunel.museum +brussel.museum +brussels.museum +bruxelles.museum +building.museum +burghof.museum +bus.museum +bushey.museum +cadaques.museum +california.museum +cambridge.museum +can.museum +canada.museum +capebreton.museum +carrier.museum +cartoonart.museum +casadelamoneda.museum +castle.museum +castres.museum +celtic.museum +center.museum +chattanooga.museum +cheltenham.museum +chesapeakebay.museum +chicago.museum +children.museum +childrens.museum +childrensgarden.museum +chiropractic.museum +chocolate.museum +christiansburg.museum +cincinnati.museum +cinema.museum +circus.museum +civilisation.museum +civilization.museum +civilwar.museum +clinton.museum +clock.museum +coal.museum +coastaldefence.museum +cody.museum +coldwar.museum +collection.museum +colonialwilliamsburg.museum +coloradoplateau.museum +columbia.museum +columbus.museum +communication.museum +communications.museum +community.museum +computer.museum +computerhistory.museum +comunicações.museum +contemporary.museum +contemporaryart.museum +convent.museum +copenhagen.museum +corporation.museum +correios-e-telecomunicações.museum +corvette.museum +costume.museum +countryestate.museum +county.museum +crafts.museum +cranbrook.museum +creation.museum +cultural.museum +culturalcenter.museum +culture.museum +cyber.museum +cymru.museum +dali.museum +dallas.museum +database.museum +ddr.museum +decorativearts.museum +delaware.museum +delmenhorst.museum +denmark.museum +depot.museum +design.museum +detroit.museum +dinosaur.museum +discovery.museum +dolls.museum +donostia.museum +durham.museum +eastafrica.museum +eastcoast.museum +education.museum +educational.museum +egyptian.museum +eisenbahn.museum +elburg.museum +elvendrell.museum +embroidery.museum +encyclopedic.museum +england.museum +entomology.museum +environment.museum +environmentalconservation.museum +epilepsy.museum +essex.museum +estate.museum +ethnology.museum +exeter.museum +exhibition.museum +family.museum +farm.museum +farmequipment.museum +farmers.museum +farmstead.museum +field.museum +figueres.museum +filatelia.museum +film.museum +fineart.museum +finearts.museum +finland.museum +flanders.museum +florida.museum +force.museum +fortmissoula.museum +fortworth.museum +foundation.museum +francaise.museum +frankfurt.museum +franziskaner.museum +freemasonry.museum +freiburg.museum +fribourg.museum +frog.museum +fundacio.museum +furniture.museum +gallery.museum +garden.museum +gateway.museum +geelvinck.museum +gemological.museum +geology.museum +georgia.museum +giessen.museum +glas.museum +glass.museum +gorge.museum +grandrapids.museum +graz.museum +guernsey.museum +halloffame.museum +hamburg.museum +handson.museum +harvestcelebration.museum +hawaii.museum +health.museum +heimatunduhren.museum +hellas.museum +helsinki.museum +hembygdsforbund.museum +heritage.museum +histoire.museum +historical.museum +historicalsociety.museum +historichouses.museum +historisch.museum +historisches.museum +history.museum +historyofscience.museum +horology.museum +house.museum +humanities.museum +illustration.museum +imageandsound.museum +indian.museum +indiana.museum +indianapolis.museum +indianmarket.museum +intelligence.museum +interactive.museum +iraq.museum +iron.museum +isleofman.museum +jamison.museum +jefferson.museum +jerusalem.museum +jewelry.museum +jewish.museum +jewishart.museum +jfk.museum +journalism.museum +judaica.museum +judygarland.museum +juedisches.museum +juif.museum +karate.museum +karikatur.museum +kids.museum +koebenhavn.museum +koeln.museum +kunst.museum +kunstsammlung.museum +kunstunddesign.museum +labor.museum +labour.museum +lajolla.museum +lancashire.museum +landes.museum +lans.museum +läns.museum +larsson.museum +lewismiller.museum +lincoln.museum +linz.museum +living.museum +livinghistory.museum +localhistory.museum +london.museum +losangeles.museum +louvre.museum +loyalist.museum +lucerne.museum +luxembourg.museum +luzern.museum +mad.museum +madrid.museum +mallorca.museum +manchester.museum +mansion.museum +mansions.museum +manx.museum +marburg.museum +maritime.museum +maritimo.museum +maryland.museum +marylhurst.museum +media.museum +medical.museum +medizinhistorisches.museum +meeres.museum +memorial.museum +mesaverde.museum +michigan.museum +midatlantic.museum +military.museum +mill.museum +miners.museum +mining.museum +minnesota.museum +missile.museum +missoula.museum +modern.museum +moma.museum +money.museum +monmouth.museum +monticello.museum +montreal.museum +moscow.museum +motorcycle.museum +muenchen.museum +muenster.museum +mulhouse.museum +muncie.museum +museet.museum +museumcenter.museum +museumvereniging.museum +music.museum +national.museum +nationalfirearms.museum +nationalheritage.museum +nativeamerican.museum +naturalhistory.museum +naturalhistorymuseum.museum +naturalsciences.museum +nature.museum +naturhistorisches.museum +natuurwetenschappen.museum +naumburg.museum +naval.museum +nebraska.museum +neues.museum +newhampshire.museum +newjersey.museum +newmexico.museum +newport.museum +newspaper.museum +newyork.museum +niepce.museum +norfolk.museum +north.museum +nrw.museum +nuernberg.museum +nuremberg.museum +nyc.museum +nyny.museum +oceanographic.museum +oceanographique.museum +omaha.museum +online.museum +ontario.museum +openair.museum +oregon.museum +oregontrail.museum +otago.museum +oxford.museum +pacific.museum +paderborn.museum +palace.museum +paleo.museum +palmsprings.museum +panama.museum +paris.museum +pasadena.museum +pharmacy.museum +philadelphia.museum +philadelphiaarea.museum +philately.museum +phoenix.museum +photography.museum +pilots.museum +pittsburgh.museum +planetarium.museum +plantation.museum +plants.museum +plaza.museum +portal.museum +portland.museum +portlligat.museum +posts-and-telecommunications.museum +preservation.museum +presidio.museum +press.museum +project.museum +public.museum +pubol.museum +quebec.museum +railroad.museum +railway.museum +research.museum +resistance.museum +riodejaneiro.museum +rochester.museum +rockart.museum +roma.museum +russia.museum +saintlouis.museum +salem.museum +salvadordali.museum +salzburg.museum +sandiego.museum +sanfrancisco.museum +santabarbara.museum +santacruz.museum +santafe.museum +saskatchewan.museum +satx.museum +savannahga.museum +schlesisches.museum +schoenbrunn.museum +schokoladen.museum +school.museum +schweiz.museum +science.museum +scienceandhistory.museum +scienceandindustry.museum +sciencecenter.museum +sciencecenters.museum +science-fiction.museum +sciencehistory.museum +sciences.museum +sciencesnaturelles.museum +scotland.museum +seaport.museum +settlement.museum +settlers.museum +shell.museum +sherbrooke.museum +sibenik.museum +silk.museum +ski.museum +skole.museum +society.museum +sologne.museum +soundandvision.museum +southcarolina.museum +southwest.museum +space.museum +spy.museum +square.museum +stadt.museum +stalbans.museum +starnberg.museum +state.museum +stateofdelaware.museum +station.museum +steam.museum +steiermark.museum +stjohn.museum +stockholm.museum +stpetersburg.museum +stuttgart.museum +suisse.museum +surgeonshall.museum +surrey.museum +svizzera.museum +sweden.museum +sydney.museum +tank.museum +tcm.museum +technology.museum +telekommunikation.museum +television.museum +texas.museum +textile.museum +theater.museum +time.museum +timekeeping.museum +topology.museum +torino.museum +touch.museum +town.museum +transport.museum +tree.museum +trolley.museum +trust.museum +trustee.museum +uhren.museum +ulm.museum +undersea.museum +university.museum +usa.museum +usantiques.museum +usarts.museum +uscountryestate.museum +usculture.museum +usdecorativearts.museum +usgarden.museum +ushistory.museum +ushuaia.museum +uslivinghistory.museum +utah.museum +uvic.museum +valley.museum +vantaa.museum +versailles.museum +viking.museum +village.museum +virginia.museum +virtual.museum +virtuel.museum +vlaanderen.museum +volkenkunde.museum +wales.museum +wallonie.museum +war.museum +washingtondc.museum +watchandclock.museum +watch-and-clock.museum +western.museum +westfalen.museum +whaling.museum +wildlife.museum +williamsburg.museum +windmill.museum +workshop.museum +york.museum +yorkshire.museum +yosemite.museum +youth.museum +zoological.museum +zoology.museum +ירושלים.museum +иком.museum + +// mv : http://en.wikipedia.org/wiki/.mv +// "mv" included because, contra Wikipedia, google.mv exists. +mv +aero.mv +biz.mv +com.mv +coop.mv +edu.mv +gov.mv +info.mv +int.mv +mil.mv +museum.mv +name.mv +net.mv +org.mv +pro.mv + +// mw : http://www.registrar.mw/ +mw +ac.mw +biz.mw +co.mw +com.mw +coop.mw +edu.mw +gov.mw +int.mw +museum.mw +net.mw +org.mw + +// mx : http://www.nic.mx/ +// Submitted by registry 2008-06-19 +mx +com.mx +org.mx +gob.mx +edu.mx +net.mx + +// my : http://www.mynic.net.my/ +my +com.my +net.my +org.my +gov.my +edu.my +mil.my +name.my + +// mz : http://www.gobin.info/domainname/mz-template.doc +*.mz +!teledata.mz + +// na : http://www.na-nic.com.na/ +// http://www.info.na/domain/ +na +info.na +pro.na +name.na +school.na +or.na +dr.na +us.na +mx.na +ca.na +in.na +cc.na +tv.na +ws.na +mobi.na +co.na +com.na +org.na + +// name : has 2nd-level tlds, but there's no list of them +name + +// nc : http://www.cctld.nc/ +nc +asso.nc + +// ne : http://en.wikipedia.org/wiki/.ne +ne + +// net : http://en.wikipedia.org/wiki/.net +net + +// nf : http://en.wikipedia.org/wiki/.nf +nf +com.nf +net.nf +per.nf +rec.nf +web.nf +arts.nf +firm.nf +info.nf +other.nf +store.nf + +// ng : http://psg.com/dns/ng/ +ng +com.ng +edu.ng +name.ng +net.ng +org.ng +sch.ng +gov.ng +mil.ng +mobi.ng + +// ni : http://www.nic.ni/dominios.htm +*.ni + +// nl : http://www.domain-registry.nl/ace.php/c,728,122,,,,Home.html +// Confirmed by registry (with technical +// reservations) 2008-06-08 +nl + +// BV.nl will be a registry for dutch BV's (besloten vennootschap) +bv.nl + +// no : http://www.norid.no/regelverk/index.en.html +// The Norwegian registry has declined to notify us of updates. The web pages +// referenced below are the official source of the data. There is also an +// announce mailing list: +// https://postlister.uninett.no/sympa/info/norid-diskusjon +no +// Norid generic domains : http://www.norid.no/regelverk/vedlegg-c.en.html +fhs.no +vgs.no +fylkesbibl.no +folkebibl.no +museum.no +idrett.no +priv.no +// Non-Norid generic domains : http://www.norid.no/regelverk/vedlegg-d.en.html +mil.no +stat.no +dep.no +kommune.no +herad.no +// no geographical names : http://www.norid.no/regelverk/vedlegg-b.en.html +// counties +aa.no +ah.no +bu.no +fm.no +hl.no +hm.no +jan-mayen.no +mr.no +nl.no +nt.no +of.no +ol.no +oslo.no +rl.no +sf.no +st.no +svalbard.no +tm.no +tr.no +va.no +vf.no +// primary and lower secondary schools per county +gs.aa.no +gs.ah.no +gs.bu.no +gs.fm.no +gs.hl.no +gs.hm.no +gs.jan-mayen.no +gs.mr.no +gs.nl.no +gs.nt.no +gs.of.no +gs.ol.no +gs.oslo.no +gs.rl.no +gs.sf.no +gs.st.no +gs.svalbard.no +gs.tm.no +gs.tr.no +gs.va.no +gs.vf.no +// cities +akrehamn.no +åkrehamn.no +algard.no +ålgård.no +arna.no +brumunddal.no +bryne.no +bronnoysund.no +brønnøysund.no +drobak.no +drøbak.no +egersund.no +fetsund.no +floro.no +florø.no +fredrikstad.no +hokksund.no +honefoss.no +hønefoss.no +jessheim.no +jorpeland.no +jørpeland.no +kirkenes.no +kopervik.no +krokstadelva.no +langevag.no +langevåg.no +leirvik.no +mjondalen.no +mjøndalen.no +mo-i-rana.no +mosjoen.no +mosjøen.no +nesoddtangen.no +orkanger.no +osoyro.no +osøyro.no +raholt.no +råholt.no +sandnessjoen.no +sandnessjøen.no +skedsmokorset.no +slattum.no +spjelkavik.no +stathelle.no +stavern.no +stjordalshalsen.no +stjørdalshalsen.no +tananger.no +tranby.no +vossevangen.no +// communities +afjord.no +åfjord.no +agdenes.no +al.no +ål.no +alesund.no +ålesund.no +alstahaug.no +alta.no +áltá.no +alaheadju.no +álaheadju.no +alvdal.no +amli.no +åmli.no +amot.no +åmot.no +andebu.no +andoy.no +andøy.no +andasuolo.no +ardal.no +årdal.no +aremark.no +arendal.no +ås.no +aseral.no +åseral.no +asker.no +askim.no +askvoll.no +askoy.no +askøy.no +asnes.no +åsnes.no +audnedaln.no +aukra.no +aure.no +aurland.no +aurskog-holand.no +aurskog-høland.no +austevoll.no +austrheim.no +averoy.no +averøy.no +balestrand.no +ballangen.no +balat.no +bálát.no +balsfjord.no +bahccavuotna.no +báhccavuotna.no +bamble.no +bardu.no +beardu.no +beiarn.no +bajddar.no +bájddar.no +baidar.no +báidár.no +berg.no +bergen.no +berlevag.no +berlevåg.no +bearalvahki.no +bearalváhki.no +bindal.no +birkenes.no +bjarkoy.no +bjarkøy.no +bjerkreim.no +bjugn.no +bodo.no +bodø.no +badaddja.no +bådåddjå.no +budejju.no +bokn.no +bremanger.no +bronnoy.no +brønnøy.no +bygland.no +bykle.no +barum.no +bærum.no +bo.telemark.no +bø.telemark.no +bo.nordland.no +bø.nordland.no +bievat.no +bievát.no +bomlo.no +bømlo.no +batsfjord.no +båtsfjord.no +bahcavuotna.no +báhcavuotna.no +dovre.no +drammen.no +drangedal.no +dyroy.no +dyrøy.no +donna.no +dønna.no +eid.no +eidfjord.no +eidsberg.no +eidskog.no +eidsvoll.no +eigersund.no +elverum.no +enebakk.no +engerdal.no +etne.no +etnedal.no +evenes.no +evenassi.no +evenášši.no +evje-og-hornnes.no +farsund.no +fauske.no +fuossko.no +fuoisku.no +fedje.no +fet.no +finnoy.no +finnøy.no +fitjar.no +fjaler.no +fjell.no +flakstad.no +flatanger.no +flekkefjord.no +flesberg.no +flora.no +fla.no +flå.no +folldal.no +forsand.no +fosnes.no +frei.no +frogn.no +froland.no +frosta.no +frana.no +fræna.no +froya.no +frøya.no +fusa.no +fyresdal.no +forde.no +førde.no +gamvik.no +gangaviika.no +gáŋgaviika.no +gaular.no +gausdal.no +gildeskal.no +gildeskål.no +giske.no +gjemnes.no +gjerdrum.no +gjerstad.no +gjesdal.no +gjovik.no +gjøvik.no +gloppen.no +gol.no +gran.no +grane.no +granvin.no +gratangen.no +grimstad.no +grong.no +kraanghke.no +kråanghke.no +grue.no +gulen.no +hadsel.no +halden.no +halsa.no +hamar.no +hamaroy.no +habmer.no +hábmer.no +hapmir.no +hápmir.no +hammerfest.no +hammarfeasta.no +hámmárfeasta.no +haram.no +hareid.no +harstad.no +hasvik.no +aknoluokta.no +ákŋoluokta.no +hattfjelldal.no +aarborte.no +haugesund.no +hemne.no +hemnes.no +hemsedal.no +heroy.more-og-romsdal.no +herøy.møre-og-romsdal.no +heroy.nordland.no +herøy.nordland.no +hitra.no +hjartdal.no +hjelmeland.no +hobol.no +hobøl.no +hof.no +hol.no +hole.no +holmestrand.no +holtalen.no +holtålen.no +hornindal.no +horten.no +hurdal.no +hurum.no +hvaler.no +hyllestad.no +hagebostad.no +hægebostad.no +hoyanger.no +høyanger.no +hoylandet.no +høylandet.no +ha.no +hå.no +ibestad.no +inderoy.no +inderøy.no +iveland.no +jevnaker.no +jondal.no +jolster.no +jølster.no +karasjok.no +karasjohka.no +kárášjohka.no +karlsoy.no +galsa.no +gálsá.no +karmoy.no +karmøy.no +kautokeino.no +guovdageaidnu.no +klepp.no +klabu.no +klæbu.no +kongsberg.no +kongsvinger.no +kragero.no +kragerø.no +kristiansand.no +kristiansund.no +krodsherad.no +krødsherad.no +kvalsund.no +rahkkeravju.no +ráhkkerávju.no +kvam.no +kvinesdal.no +kvinnherad.no +kviteseid.no +kvitsoy.no +kvitsøy.no +kvafjord.no +kvæfjord.no +giehtavuoatna.no +kvanangen.no +kvænangen.no +navuotna.no +návuotna.no +kafjord.no +kåfjord.no +gaivuotna.no +gáivuotna.no +larvik.no +lavangen.no +lavagis.no +loabat.no +loabát.no +lebesby.no +davvesiida.no +leikanger.no +leirfjord.no +leka.no +leksvik.no +lenvik.no +leangaviika.no +leaŋgaviika.no +lesja.no +levanger.no +lier.no +lierne.no +lillehammer.no +lillesand.no +lindesnes.no +lindas.no +lindås.no +lom.no +loppa.no +lahppi.no +láhppi.no +lund.no +lunner.no +luroy.no +lurøy.no +luster.no +lyngdal.no +lyngen.no +ivgu.no +lardal.no +lerdal.no +lærdal.no +lodingen.no +lødingen.no +lorenskog.no +lørenskog.no +loten.no +løten.no +malvik.no +masoy.no +måsøy.no +muosat.no +muosát.no +mandal.no +marker.no +marnardal.no +masfjorden.no +meland.no +meldal.no +melhus.no +meloy.no +meløy.no +meraker.no +meråker.no +moareke.no +moåreke.no +midsund.no +midtre-gauldal.no +modalen.no +modum.no +molde.no +moskenes.no +moss.no +mosvik.no +malselv.no +målselv.no +malatvuopmi.no +málatvuopmi.no +namdalseid.no +aejrie.no +namsos.no +namsskogan.no +naamesjevuemie.no +nååmesjevuemie.no +laakesvuemie.no +nannestad.no +narvik.no +narviika.no +naustdal.no +nedre-eiker.no +nes.akershus.no +nes.buskerud.no +nesna.no +nesodden.no +nesseby.no +unjarga.no +unjárga.no +nesset.no +nissedal.no +nittedal.no +nord-aurdal.no +nord-fron.no +nord-odal.no +norddal.no +nordkapp.no +davvenjarga.no +davvenjárga.no +nordre-land.no +nordreisa.no +raisa.no +ráisa.no +nore-og-uvdal.no +notodden.no +naroy.no +nærøy.no +notteroy.no +nøtterøy.no +odda.no +oksnes.no +øksnes.no +oppdal.no +oppegard.no +oppegård.no +orkdal.no +orland.no +ørland.no +orskog.no +ørskog.no +orsta.no +ørsta.no +os.hedmark.no +os.hordaland.no +osen.no +osteroy.no +osterøy.no +ostre-toten.no +østre-toten.no +overhalla.no +ovre-eiker.no +øvre-eiker.no +oyer.no +øyer.no +oygarden.no +øygarden.no +oystre-slidre.no +øystre-slidre.no +porsanger.no +porsangu.no +porsáŋgu.no +porsgrunn.no +radoy.no +radøy.no +rakkestad.no +rana.no +ruovat.no +randaberg.no +rauma.no +rendalen.no +rennebu.no +rennesoy.no +rennesøy.no +rindal.no +ringebu.no +ringerike.no +ringsaker.no +rissa.no +risor.no +risør.no +roan.no +rollag.no +rygge.no +ralingen.no +rælingen.no +rodoy.no +rødøy.no +romskog.no +rømskog.no +roros.no +røros.no +rost.no +røst.no +royken.no +røyken.no +royrvik.no +røyrvik.no +rade.no +råde.no +salangen.no +siellak.no +saltdal.no +salat.no +sálát.no +sálat.no +samnanger.no +sande.more-og-romsdal.no +sande.møre-og-romsdal.no +sande.vestfold.no +sandefjord.no +sandnes.no +sandoy.no +sandøy.no +sarpsborg.no +sauda.no +sauherad.no +sel.no +selbu.no +selje.no +seljord.no +sigdal.no +siljan.no +sirdal.no +skaun.no +skedsmo.no +ski.no +skien.no +skiptvet.no +skjervoy.no +skjervøy.no +skierva.no +skiervá.no +skjak.no +skjåk.no +skodje.no +skanland.no +skånland.no +skanit.no +skánit.no +smola.no +smøla.no +snillfjord.no +snasa.no +snåsa.no +snoasa.no +snaase.no +snåase.no +sogndal.no +sokndal.no +sola.no +solund.no +songdalen.no +sortland.no +spydeberg.no +stange.no +stavanger.no +steigen.no +steinkjer.no +stjordal.no +stjørdal.no +stokke.no +stor-elvdal.no +stord.no +stordal.no +storfjord.no +omasvuotna.no +strand.no +stranda.no +stryn.no +sula.no +suldal.no +sund.no +sunndal.no +surnadal.no +sveio.no +svelvik.no +sykkylven.no +sogne.no +søgne.no +somna.no +sømna.no +sondre-land.no +søndre-land.no +sor-aurdal.no +sør-aurdal.no +sor-fron.no +sør-fron.no +sor-odal.no +sør-odal.no +sor-varanger.no +sør-varanger.no +matta-varjjat.no +mátta-várjjat.no +sorfold.no +sørfold.no +sorreisa.no +sørreisa.no +sorum.no +sørum.no +tana.no +deatnu.no +time.no +tingvoll.no +tinn.no +tjeldsund.no +dielddanuorri.no +tjome.no +tjøme.no +tokke.no +tolga.no +torsken.no +tranoy.no +tranøy.no +tromso.no +tromsø.no +tromsa.no +romsa.no +trondheim.no +troandin.no +trysil.no +trana.no +træna.no +trogstad.no +trøgstad.no +tvedestrand.no +tydal.no +tynset.no +tysfjord.no +divtasvuodna.no +divttasvuotna.no +tysnes.no +tysvar.no +tysvær.no +tonsberg.no +tønsberg.no +ullensaker.no +ullensvang.no +ulvik.no +utsira.no +vadso.no +vadsø.no +cahcesuolo.no +čáhcesuolo.no +vaksdal.no +valle.no +vang.no +vanylven.no +vardo.no +vardø.no +varggat.no +várggát.no +vefsn.no +vaapste.no +vega.no +vegarshei.no +vegårshei.no +vennesla.no +verdal.no +verran.no +vestby.no +vestnes.no +vestre-slidre.no +vestre-toten.no +vestvagoy.no +vestvågøy.no +vevelstad.no +vik.no +vikna.no +vindafjord.no +volda.no +voss.no +varoy.no +værøy.no +vagan.no +vågan.no +voagat.no +vagsoy.no +vågsøy.no +vaga.no +vågå.no +valer.ostfold.no +våler.østfold.no +valer.hedmark.no +våler.hedmark.no + +// np : http://www.mos.com.np/register.html +*.np + +// nr : http://cenpac.net.nr/dns/index.html +// Confirmed by registry 2008-06-17 +nr +biz.nr +info.nr +gov.nr +edu.nr +org.nr +net.nr +com.nr + +// nu : http://en.wikipedia.org/wiki/.nu +nu + +// nz : http://en.wikipedia.org/wiki/.nz +// Confirmed by registry 2014-05-19 +nz +ac.nz +co.nz +cri.nz +geek.nz +gen.nz +govt.nz +health.nz +iwi.nz +kiwi.nz +maori.nz +mil.nz +māori.nz +net.nz +org.nz +parliament.nz +school.nz + +// om : http://en.wikipedia.org/wiki/.om +om +co.om +com.om +edu.om +gov.om +med.om +museum.om +net.om +org.om +pro.om + +// org : http://en.wikipedia.org/wiki/.org +org + +// pa : http://www.nic.pa/ +// Some additional second level "domains" resolve directly as hostnames, such as +// pannet.pa, so we add a rule for "pa". +pa +ac.pa +gob.pa +com.pa +org.pa +sld.pa +edu.pa +net.pa +ing.pa +abo.pa +med.pa +nom.pa + +// pe : https://www.nic.pe/InformeFinalComision.pdf +pe +edu.pe +gob.pe +nom.pe +mil.pe +org.pe +com.pe +net.pe + +// pf : http://www.gobin.info/domainname/formulaire-pf.pdf +pf +com.pf +org.pf +edu.pf + +// pg : http://en.wikipedia.org/wiki/.pg +*.pg + +// ph : http://www.domains.ph/FAQ2.asp +// Submitted by registry 2008-06-13 +ph +com.ph +net.ph +org.ph +gov.ph +edu.ph +ngo.ph +mil.ph +i.ph + +// pk : http://pk5.pknic.net.pk/pk5/msgNamepk.PK +pk +com.pk +net.pk +edu.pk +org.pk +fam.pk +biz.pk +web.pk +gov.pk +gob.pk +gok.pk +gon.pk +gop.pk +gos.pk +info.pk + +// pl http://www.dns.pl/english/index.html +// confirmed on 26.09.2014 from Bogna Tchórzewska +pl +com.pl +net.pl +org.pl +info.pl +waw.pl +gov.pl +// pl functional domains (http://www.dns.pl/english/index.html) +aid.pl +agro.pl +atm.pl +auto.pl +biz.pl +edu.pl +gmina.pl +gsm.pl +mail.pl +miasta.pl +media.pl +mil.pl +nieruchomosci.pl +nom.pl +pc.pl +powiat.pl +priv.pl +realestate.pl +rel.pl +sex.pl +shop.pl +sklep.pl +sos.pl +szkola.pl +targi.pl +tm.pl +tourism.pl +travel.pl +turystyka.pl +// Government domains (administred by ippt.gov.pl) +uw.gov.pl +um.gov.pl +ug.gov.pl +upow.gov.pl +starostwo.gov.pl +so.gov.pl +sr.gov.pl +po.gov.pl +pa.gov.pl +// pl regional domains (http://www.dns.pl/english/index.html) +augustow.pl +babia-gora.pl +bedzin.pl +beskidy.pl +bialowieza.pl +bialystok.pl +bielawa.pl +bieszczady.pl +boleslawiec.pl +bydgoszcz.pl +bytom.pl +cieszyn.pl +czeladz.pl +czest.pl +dlugoleka.pl +elblag.pl +elk.pl +glogow.pl +gniezno.pl +gorlice.pl +grajewo.pl +ilawa.pl +jaworzno.pl +jelenia-gora.pl +jgora.pl +kalisz.pl +kazimierz-dolny.pl +karpacz.pl +kartuzy.pl +kaszuby.pl +katowice.pl +kepno.pl +ketrzyn.pl +klodzko.pl +kobierzyce.pl +kolobrzeg.pl +konin.pl +konskowola.pl +kutno.pl +lapy.pl +lebork.pl +legnica.pl +lezajsk.pl +limanowa.pl +lomza.pl +lowicz.pl +lubin.pl +lukow.pl +malbork.pl +malopolska.pl +mazowsze.pl +mazury.pl +mielec.pl +mielno.pl +mragowo.pl +naklo.pl +nowaruda.pl +nysa.pl +olawa.pl +olecko.pl +olkusz.pl +olsztyn.pl +opoczno.pl +opole.pl +ostroda.pl +ostroleka.pl +ostrowiec.pl +ostrowwlkp.pl +pila.pl +pisz.pl +podhale.pl +podlasie.pl +polkowice.pl +pomorze.pl +pomorskie.pl +prochowice.pl +pruszkow.pl +przeworsk.pl +pulawy.pl +radom.pl +rawa-maz.pl +rybnik.pl +rzeszow.pl +sanok.pl +sejny.pl +slask.pl +slupsk.pl +sosnowiec.pl +stalowa-wola.pl +skoczow.pl +starachowice.pl +stargard.pl +suwalki.pl +swidnica.pl +swiebodzin.pl +swinoujscie.pl +szczecin.pl +szczytno.pl +tarnobrzeg.pl +tgory.pl +turek.pl +tychy.pl +ustka.pl +walbrzych.pl +warmia.pl +warszawa.pl +wegrow.pl +wielun.pl +wlocl.pl +wloclawek.pl +wodzislaw.pl +wolomin.pl +wroclaw.pl +zachpomor.pl +zagan.pl +zarow.pl +zgora.pl +zgorzelec.pl + +// pm : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +pm + +// pn : http://www.government.pn/PnRegistry/policies.htm +pn +gov.pn +co.pn +org.pn +edu.pn +net.pn + +// post : http://en.wikipedia.org/wiki/.post +post + +// pr : http://www.nic.pr/index.asp?f=1 +pr +com.pr +net.pr +org.pr +gov.pr +edu.pr +isla.pr +pro.pr +biz.pr +info.pr +name.pr +// these aren't mentioned on nic.pr, but on http://en.wikipedia.org/wiki/.pr +est.pr +prof.pr +ac.pr + +// pro : http://www.nic.pro/support_faq.htm +pro +aca.pro +bar.pro +cpa.pro +jur.pro +law.pro +med.pro +eng.pro + +// ps : http://en.wikipedia.org/wiki/.ps +// http://www.nic.ps/registration/policy.html#reg +ps +edu.ps +gov.ps +sec.ps +plo.ps +com.ps +org.ps +net.ps + +// pt : http://online.dns.pt/dns/start_dns +pt +net.pt +gov.pt +org.pt +edu.pt +int.pt +publ.pt +com.pt +nome.pt + +// pw : http://en.wikipedia.org/wiki/.pw +pw +co.pw +ne.pw +or.pw +ed.pw +go.pw +belau.pw + +// py : http://www.nic.py/pautas.html#seccion_9 +// Confirmed by registry 2012-10-03 +py +com.py +coop.py +edu.py +gov.py +mil.py +net.py +org.py + +// qa : http://domains.qa/en/ +qa +com.qa +edu.qa +gov.qa +mil.qa +name.qa +net.qa +org.qa +sch.qa + +// re : http://www.afnic.re/obtenir/chartes/nommage-re/annexe-descriptifs +re +com.re +asso.re +nom.re + +// ro : http://www.rotld.ro/ +ro +com.ro +org.ro +tm.ro +nt.ro +nom.ro +info.ro +rec.ro +arts.ro +firm.ro +store.ro +www.ro + +// rs : http://en.wikipedia.org/wiki/.rs +rs +co.rs +org.rs +edu.rs +ac.rs +gov.rs +in.rs + +// ru : http://www.cctld.ru/ru/docs/aktiv_8.php +// Industry domains +ru +ac.ru +com.ru +edu.ru +int.ru +net.ru +org.ru +pp.ru +// Geographical domains +adygeya.ru +altai.ru +amur.ru +arkhangelsk.ru +astrakhan.ru +bashkiria.ru +belgorod.ru +bir.ru +bryansk.ru +buryatia.ru +cbg.ru +chel.ru +chelyabinsk.ru +chita.ru +chukotka.ru +chuvashia.ru +dagestan.ru +dudinka.ru +e-burg.ru +grozny.ru +irkutsk.ru +ivanovo.ru +izhevsk.ru +jar.ru +joshkar-ola.ru +kalmykia.ru +kaluga.ru +kamchatka.ru +karelia.ru +kazan.ru +kchr.ru +kemerovo.ru +khabarovsk.ru +khakassia.ru +khv.ru +kirov.ru +koenig.ru +komi.ru +kostroma.ru +krasnoyarsk.ru +kuban.ru +kurgan.ru +kursk.ru +lipetsk.ru +magadan.ru +mari.ru +mari-el.ru +marine.ru +mordovia.ru +// mosreg.ru Bug 1090800 - removed at request of Aleksey Konstantinov +msk.ru +murmansk.ru +nalchik.ru +nnov.ru +nov.ru +novosibirsk.ru +nsk.ru +omsk.ru +orenburg.ru +oryol.ru +palana.ru +penza.ru +perm.ru +ptz.ru +rnd.ru +ryazan.ru +sakhalin.ru +samara.ru +saratov.ru +simbirsk.ru +smolensk.ru +spb.ru +stavropol.ru +stv.ru +surgut.ru +tambov.ru +tatarstan.ru +tom.ru +tomsk.ru +tsaritsyn.ru +tsk.ru +tula.ru +tuva.ru +tver.ru +tyumen.ru +udm.ru +udmurtia.ru +ulan-ude.ru +vladikavkaz.ru +vladimir.ru +vladivostok.ru +volgograd.ru +vologda.ru +voronezh.ru +vrn.ru +vyatka.ru +yakutia.ru +yamal.ru +yaroslavl.ru +yekaterinburg.ru +yuzhno-sakhalinsk.ru +// More geographical domains +amursk.ru +baikal.ru +cmw.ru +fareast.ru +jamal.ru +kms.ru +k-uralsk.ru +kustanai.ru +kuzbass.ru +magnitka.ru +mytis.ru +nakhodka.ru +nkz.ru +norilsk.ru +oskol.ru +pyatigorsk.ru +rubtsovsk.ru +snz.ru +syzran.ru +vdonsk.ru +zgrad.ru +// State domains +gov.ru +mil.ru +// Technical domains +test.ru + +// rw : http://www.nic.rw/cgi-bin/policy.pl +rw +gov.rw +net.rw +edu.rw +ac.rw +com.rw +co.rw +int.rw +mil.rw +gouv.rw + +// sa : http://www.nic.net.sa/ +sa +com.sa +net.sa +org.sa +gov.sa +med.sa +pub.sa +edu.sa +sch.sa + +// sb : http://www.sbnic.net.sb/ +// Submitted by registry 2008-06-08 +sb +com.sb +edu.sb +gov.sb +net.sb +org.sb + +// sc : http://www.nic.sc/ +sc +com.sc +gov.sc +net.sc +org.sc +edu.sc + +// sd : http://www.isoc.sd/sudanic.isoc.sd/billing_pricing.htm +// Submitted by registry 2008-06-17 +sd +com.sd +net.sd +org.sd +edu.sd +med.sd +tv.sd +gov.sd +info.sd + +// se : http://en.wikipedia.org/wiki/.se +// Submitted by registry 2014-03-18 +se +a.se +ac.se +b.se +bd.se +brand.se +c.se +d.se +e.se +f.se +fh.se +fhsk.se +fhv.se +g.se +h.se +i.se +k.se +komforb.se +kommunalforbund.se +komvux.se +l.se +lanbib.se +m.se +n.se +naturbruksgymn.se +o.se +org.se +p.se +parti.se +pp.se +press.se +r.se +s.se +t.se +tm.se +u.se +w.se +x.se +y.se +z.se + +// sg : http://www.nic.net.sg/page/registration-policies-procedures-and-guidelines +sg +com.sg +net.sg +org.sg +gov.sg +edu.sg +per.sg + +// sh : http://www.nic.sh/registrar.html +sh +com.sh +net.sh +gov.sh +org.sh +mil.sh + +// si : http://en.wikipedia.org/wiki/.si +si + +// sj : No registrations at this time. +// Submitted by registry 2008-06-16 +sj + +// sk : http://en.wikipedia.org/wiki/.sk +// list of 2nd level domains ? +sk + +// sl : http://www.nic.sl +// Submitted by registry 2008-06-12 +sl +com.sl +net.sl +edu.sl +gov.sl +org.sl + +// sm : http://en.wikipedia.org/wiki/.sm +sm + +// sn : http://en.wikipedia.org/wiki/.sn +sn +art.sn +com.sn +edu.sn +gouv.sn +org.sn +perso.sn +univ.sn + +// so : http://www.soregistry.com/ +so +com.so +net.so +org.so + +// sr : http://en.wikipedia.org/wiki/.sr +sr + +// st : http://www.nic.st/html/policyrules/ +st +co.st +com.st +consulado.st +edu.st +embaixada.st +gov.st +mil.st +net.st +org.st +principe.st +saotome.st +store.st + +// su : http://en.wikipedia.org/wiki/.su +su +adygeya.su +arkhangelsk.su +balashov.su +bashkiria.su +bryansk.su +dagestan.su +grozny.su +ivanovo.su +kalmykia.su +kaluga.su +karelia.su +khakassia.su +krasnodar.su +kurgan.su +lenug.su +mordovia.su +msk.su +murmansk.su +nalchik.su +nov.su +obninsk.su +penza.su +pokrovsk.su +sochi.su +spb.su +togliatti.su +troitsk.su +tula.su +tuva.su +vladikavkaz.su +vladimir.su +vologda.su + +// sv : http://www.svnet.org.sv/niveldos.pdf +sv +com.sv +edu.sv +gob.sv +org.sv +red.sv + +// sx : http://en.wikipedia.org/wiki/.sx +// Confirmed by registry 2012-05-31 +sx +gov.sx + +// sy : http://en.wikipedia.org/wiki/.sy +// see also: http://www.gobin.info/domainname/sy.doc +sy +edu.sy +gov.sy +net.sy +mil.sy +com.sy +org.sy + +// sz : http://en.wikipedia.org/wiki/.sz +// http://www.sispa.org.sz/ +sz +co.sz +ac.sz +org.sz + +// tc : http://en.wikipedia.org/wiki/.tc +tc + +// td : http://en.wikipedia.org/wiki/.td +td + +// tel: http://en.wikipedia.org/wiki/.tel +// http://www.telnic.org/ +tel + +// tf : http://en.wikipedia.org/wiki/.tf +tf + +// tg : http://en.wikipedia.org/wiki/.tg +// http://www.nic.tg/ +tg + +// th : http://en.wikipedia.org/wiki/.th +// Submitted by registry 2008-06-17 +th +ac.th +co.th +go.th +in.th +mi.th +net.th +or.th + +// tj : http://www.nic.tj/policy.html +tj +ac.tj +biz.tj +co.tj +com.tj +edu.tj +go.tj +gov.tj +int.tj +mil.tj +name.tj +net.tj +nic.tj +org.tj +test.tj +web.tj + +// tk : http://en.wikipedia.org/wiki/.tk +tk + +// tl : http://en.wikipedia.org/wiki/.tl +tl +gov.tl + +// tm : http://www.nic.tm/local.html +tm +com.tm +co.tm +org.tm +net.tm +nom.tm +gov.tm +mil.tm +edu.tm + +// tn : http://en.wikipedia.org/wiki/.tn +// http://whois.ati.tn/ +tn +com.tn +ens.tn +fin.tn +gov.tn +ind.tn +intl.tn +nat.tn +net.tn +org.tn +info.tn +perso.tn +tourism.tn +edunet.tn +rnrt.tn +rns.tn +rnu.tn +mincom.tn +agrinet.tn +defense.tn +turen.tn + +// to : http://en.wikipedia.org/wiki/.to +// Submitted by registry 2008-06-17 +to +com.to +gov.to +net.to +org.to +edu.to +mil.to + +// tp : No registrations at this time. +// Submitted by Ryan Sleevi 2014-01-03 +tp + +// subTLDs: https://www.nic.tr/forms/eng/policies.pdf +// and: https://www.nic.tr/forms/politikalar.pdf +// Submitted by 2014-07-19 +tr +com.tr +info.tr +biz.tr +net.tr +org.tr +web.tr +gen.tr +tv.tr +av.tr +dr.tr +bbs.tr +name.tr +tel.tr +gov.tr +bel.tr +pol.tr +mil.tr +k12.tr +edu.tr +kep.tr + +// Used by Northern Cyprus +nc.tr + +// Used by government agencies of Northern Cyprus +gov.nc.tr + +// travel : http://en.wikipedia.org/wiki/.travel +travel + +// tt : http://www.nic.tt/ +tt +co.tt +com.tt +org.tt +net.tt +biz.tt +info.tt +pro.tt +int.tt +coop.tt +jobs.tt +mobi.tt +travel.tt +museum.tt +aero.tt +name.tt +gov.tt +edu.tt + +// tv : http://en.wikipedia.org/wiki/.tv +// Not listing any 2LDs as reserved since none seem to exist in practice, +// Wikipedia notwithstanding. +tv + +// tw : http://en.wikipedia.org/wiki/.tw +tw +edu.tw +gov.tw +mil.tw +com.tw +net.tw +org.tw +idv.tw +game.tw +ebiz.tw +club.tw +網路.tw +組織.tw +商業.tw + +// tz : http://www.tznic.or.tz/index.php/domains +// Confirmed by registry 2013-01-22 +tz +ac.tz +co.tz +go.tz +hotel.tz +info.tz +me.tz +mil.tz +mobi.tz +ne.tz +or.tz +sc.tz +tv.tz + +// ua : https://hostmaster.ua/policy/?ua +// Submitted by registry 2012-04-27 +ua +// ua 2LD +com.ua +edu.ua +gov.ua +in.ua +net.ua +org.ua +// ua geographic names +// https://hostmaster.ua/2ld/ +cherkassy.ua +cherkasy.ua +chernigov.ua +chernihiv.ua +chernivtsi.ua +chernovtsy.ua +ck.ua +cn.ua +cr.ua +crimea.ua +cv.ua +dn.ua +dnepropetrovsk.ua +dnipropetrovsk.ua +dominic.ua +donetsk.ua +dp.ua +if.ua +ivano-frankivsk.ua +kh.ua +kharkiv.ua +kharkov.ua +kherson.ua +khmelnitskiy.ua +khmelnytskyi.ua +kiev.ua +kirovograd.ua +km.ua +kr.ua +krym.ua +ks.ua +kv.ua +kyiv.ua +lg.ua +lt.ua +lugansk.ua +lutsk.ua +lv.ua +lviv.ua +mk.ua +mykolaiv.ua +nikolaev.ua +od.ua +odesa.ua +odessa.ua +pl.ua +poltava.ua +rivne.ua +rovno.ua +rv.ua +sb.ua +sebastopol.ua +sevastopol.ua +sm.ua +sumy.ua +te.ua +ternopil.ua +uz.ua +uzhgorod.ua +vinnica.ua +vinnytsia.ua +vn.ua +volyn.ua +yalta.ua +zaporizhzhe.ua +zaporizhzhia.ua +zhitomir.ua +zhytomyr.ua +zp.ua +zt.ua + +// Private registries in .ua +co.ua +pp.ua + +// ug : https://www.registry.co.ug/ +ug +co.ug +or.ug +ac.ug +sc.ug +go.ug +ne.ug +com.ug +org.ug + +// uk : http://en.wikipedia.org/wiki/.uk +// Submitted by registry +uk +ac.uk +co.uk +gov.uk +ltd.uk +me.uk +net.uk +nhs.uk +org.uk +plc.uk +police.uk +*.sch.uk + +// us : http://en.wikipedia.org/wiki/.us +us +dni.us +fed.us +isa.us +kids.us +nsn.us +// us geographic names +ak.us +al.us +ar.us +as.us +az.us +ca.us +co.us +ct.us +dc.us +de.us +fl.us +ga.us +gu.us +hi.us +ia.us +id.us +il.us +in.us +ks.us +ky.us +la.us +ma.us +md.us +me.us +mi.us +mn.us +mo.us +ms.us +mt.us +nc.us +nd.us +ne.us +nh.us +nj.us +nm.us +nv.us +ny.us +oh.us +ok.us +or.us +pa.us +pr.us +ri.us +sc.us +sd.us +tn.us +tx.us +ut.us +vi.us +vt.us +va.us +wa.us +wi.us +wv.us +wy.us +// The registrar notes several more specific domains available in each state, +// such as state.*.us, dst.*.us, etc., but resolution of these is somewhat +// haphazard; in some states these domains resolve as addresses, while in others +// only subdomains are available, or even nothing at all. We include the +// most common ones where it's clear that different sites are different +// entities. +k12.ak.us +k12.al.us +k12.ar.us +k12.as.us +k12.az.us +k12.ca.us +k12.co.us +k12.ct.us +k12.dc.us +k12.de.us +k12.fl.us +k12.ga.us +k12.gu.us +// k12.hi.us Bug 614565 - Hawaii has a state-wide DOE login +k12.ia.us +k12.id.us +k12.il.us +k12.in.us +k12.ks.us +k12.ky.us +k12.la.us +k12.ma.us +k12.md.us +k12.me.us +k12.mi.us +k12.mn.us +k12.mo.us +k12.ms.us +k12.mt.us +k12.nc.us +// k12.nd.us Bug 1028347 - Removed at request of Travis Rosso +k12.ne.us +k12.nh.us +k12.nj.us +k12.nm.us +k12.nv.us +k12.ny.us +k12.oh.us +k12.ok.us +k12.or.us +k12.pa.us +k12.pr.us +k12.ri.us +k12.sc.us +// k12.sd.us Bug 934131 - Removed at request of James Booze +k12.tn.us +k12.tx.us +k12.ut.us +k12.vi.us +k12.vt.us +k12.va.us +k12.wa.us +k12.wi.us +// k12.wv.us Bug 947705 - Removed at request of Verne Britton +k12.wy.us +cc.ak.us +cc.al.us +cc.ar.us +cc.as.us +cc.az.us +cc.ca.us +cc.co.us +cc.ct.us +cc.dc.us +cc.de.us +cc.fl.us +cc.ga.us +cc.gu.us +cc.hi.us +cc.ia.us +cc.id.us +cc.il.us +cc.in.us +cc.ks.us +cc.ky.us +cc.la.us +cc.ma.us +cc.md.us +cc.me.us +cc.mi.us +cc.mn.us +cc.mo.us +cc.ms.us +cc.mt.us +cc.nc.us +cc.nd.us +cc.ne.us +cc.nh.us +cc.nj.us +cc.nm.us +cc.nv.us +cc.ny.us +cc.oh.us +cc.ok.us +cc.or.us +cc.pa.us +cc.pr.us +cc.ri.us +cc.sc.us +cc.sd.us +cc.tn.us +cc.tx.us +cc.ut.us +cc.vi.us +cc.vt.us +cc.va.us +cc.wa.us +cc.wi.us +cc.wv.us +cc.wy.us +lib.ak.us +lib.al.us +lib.ar.us +lib.as.us +lib.az.us +lib.ca.us +lib.co.us +lib.ct.us +lib.dc.us +lib.de.us +lib.fl.us +lib.ga.us +lib.gu.us +lib.hi.us +lib.ia.us +lib.id.us +lib.il.us +lib.in.us +lib.ks.us +lib.ky.us +lib.la.us +lib.ma.us +lib.md.us +lib.me.us +lib.mi.us +lib.mn.us +lib.mo.us +lib.ms.us +lib.mt.us +lib.nc.us +lib.nd.us +lib.ne.us +lib.nh.us +lib.nj.us +lib.nm.us +lib.nv.us +lib.ny.us +lib.oh.us +lib.ok.us +lib.or.us +lib.pa.us +lib.pr.us +lib.ri.us +lib.sc.us +lib.sd.us +lib.tn.us +lib.tx.us +lib.ut.us +lib.vi.us +lib.vt.us +lib.va.us +lib.wa.us +lib.wi.us +// lib.wv.us Bug 941670 - Removed at request of Larry W Arnold +lib.wy.us +// k12.ma.us contains school districts in Massachusetts. The 4LDs are +// managed indepedently except for private (PVT), charter (CHTR) and +// parochial (PAROCH) schools. Those are delegated dorectly to the +// 5LD operators. +pvt.k12.ma.us +chtr.k12.ma.us +paroch.k12.ma.us + +// uy : http://www.nic.org.uy/ +uy +com.uy +edu.uy +gub.uy +mil.uy +net.uy +org.uy + +// uz : http://www.reg.uz/ +uz +co.uz +com.uz +net.uz +org.uz + +// va : http://en.wikipedia.org/wiki/.va +va + +// vc : http://en.wikipedia.org/wiki/.vc +// Submitted by registry 2008-06-13 +vc +com.vc +net.vc +org.vc +gov.vc +mil.vc +edu.vc + +// ve : https://registro.nic.ve/ +// Confirmed by registry 2012-10-04 +// Updated 2014-05-20 - Bug 940478 +ve +arts.ve +co.ve +com.ve +e12.ve +edu.ve +firm.ve +gob.ve +gov.ve +info.ve +int.ve +mil.ve +net.ve +org.ve +rec.ve +store.ve +tec.ve +web.ve + +// vg : http://en.wikipedia.org/wiki/.vg +vg + +// vi : http://www.nic.vi/newdomainform.htm +// http://www.nic.vi/Domain_Rules/body_domain_rules.html indicates some other +// TLDs are "reserved", such as edu.vi and gov.vi, but doesn't actually say they +// are available for registration (which they do not seem to be). +vi +co.vi +com.vi +k12.vi +net.vi +org.vi + +// vn : https://www.dot.vn/vnnic/vnnic/domainregistration.jsp +vn +com.vn +net.vn +org.vn +edu.vn +gov.vn +int.vn +ac.vn +biz.vn +info.vn +name.vn +pro.vn +health.vn + +// vu : http://en.wikipedia.org/wiki/.vu +// http://www.vunic.vu/ +vu +com.vu +edu.vu +net.vu +org.vu + +// wf : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +wf + +// ws : http://en.wikipedia.org/wiki/.ws +// http://samoanic.ws/index.dhtml +ws +com.ws +net.ws +org.ws +gov.ws +edu.ws + +// yt : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +yt + +// IDN ccTLDs +// Please sort by ISO 3166 ccTLD, then punicode string +// when submitting patches and follow this format: +// ("" ) : +// [optional sponsoring org] +// + +// xn--mgbaam7a8h ("Emerat" Arabic) : AE +// http://nic.ae/english/arabicdomain/rules.jsp +امارات + +// xn--54b7fta0cc ("Bangla" Bangla) : BD +বাংলা + +// xn--fiqs8s ("China" Chinese-Han-Simplified <.Zhongguo>) : CN +// CNNIC +// http://cnnic.cn/html/Dir/2005/10/11/3218.htm +中国 + +// xn--fiqz9s ("China" Chinese-Han-Traditional <.Zhongguo>) : CN +// CNNIC +// http://cnnic.cn/html/Dir/2005/10/11/3218.htm +中國 + +// xn--lgbbat1ad8j ("Algeria / Al Jazair" Arabic) : DZ +الجزائر + +// xn--wgbh1c ("Egypt" Arabic .masr) : EG +// http://www.dotmasr.eg/ +مصر + +// xn--node ("ge" Georgian (Mkhedruli)) : GE +გე + +// xn--j6w193g ("Hong Kong" Chinese-Han) : HK +// https://www2.hkirc.hk/register/rules.jsp +香港 + +// xn--h2brj9c ("Bharat" Devanagari) : IN +// India +भारत + +// xn--mgbbh1a71e ("Bharat" Arabic) : IN +// India +بھارت + +// xn--fpcrj9c3d ("Bharat" Telugu) : IN +// India +భారత్ + +// xn--gecrj9c ("Bharat" Gujarati) : IN +// India +ભારત + +// xn--s9brj9c ("Bharat" Gurmukhi) : IN +// India +ਭਾਰਤ + +// xn--45brj9c ("Bharat" Bengali) : IN +// India +ভারত + +// xn--xkc2dl3a5ee0h ("India" Tamil) : IN +// India +இந்தியா + +// xn--mgba3a4f16a ("Iran" Persian) : IR +ایران + +// xn--mgba3a4fra ("Iran" Arabic) : IR +ايران + +// xn--mgbayh7gpa ("al-Ordon" Arabic) : JO +// National Information Technology Center (NITC) +// Royal Scientific Society, Al-Jubeiha +الاردن + +// xn--3e0b707e ("Republic of Korea" Hangul) : KR +한국 + +// xn--80ao21a ("Kaz" Kazakh) : KZ +қаз + +// xn--fzc2c9e2c ("Lanka" Sinhalese-Sinhala) : LK +// http://nic.lk +ලංකා + +// xn--xkc2al3hye2a ("Ilangai" Tamil) : LK +// http://nic.lk +இலங்கை + +// xn--mgbc0a9azcg ("Morocco / al-Maghrib" Arabic) : MA +المغرب + +// xn--l1acc ("mon" Mongolian) : MN +мон + +// xn--mgbx4cd0ab ("Malaysia" Malay) : MY +مليسيا + +// xn--mgb9awbf ("Oman" Arabic) : OM +عمان + +// xn--ygbi2ammx ("Falasteen" Arabic) : PS +// The Palestinian National Internet Naming Authority (PNINA) +// http://www.pnina.ps +فلسطين + +// xn--90a3ac ("srb" Cyrillic) : RS +// http://www.rnids.rs/en/the-.срб-domain +срб +пр.срб +орг.срб +обр.срб +од.срб +упр.срб +ак.срб + +// xn--p1ai ("rf" Russian-Cyrillic) : RU +// http://www.cctld.ru/en/docs/rulesrf.php +рф + +// xn--wgbl6a ("Qatar" Arabic) : QA +// http://www.ict.gov.qa/ +قطر + +// xn--mgberp4a5d4ar ("AlSaudiah" Arabic) : SA +// http://www.nic.net.sa/ +السعودية + +// xn--mgberp4a5d4a87g ("AlSaudiah" Arabic) variant : SA +السعودیة + +// xn--mgbqly7c0a67fbc ("AlSaudiah" Arabic) variant : SA +السعودیۃ + +// xn--mgbqly7cvafr ("AlSaudiah" Arabic) variant : SA +السعوديه + +// xn--ogbpf8fl ("Syria" Arabic) : SY +سورية + +// xn--mgbtf8fl ("Syria" Arabic) variant : SY +سوريا + +// xn--yfro4i67o Singapore ("Singapore" Chinese-Han) : SG +新加坡 + +// xn--clchc0ea0b2g2a9gcd ("Singapore" Tamil) : SG +சிங்கப்பூர் + +// xn--o3cw4h ("Thai" Thai) : TH +// http://www.thnic.co.th +ไทย + +// xn--pgbs0dh ("Tunis") : TN +// http://nic.tn +تونس + +// xn--kpry57d ("Taiwan" Chinese-Han-Traditional) : TW +// http://www.twnic.net/english/dn/dn_07a.htm +台灣 + +// xn--kprw13d ("Taiwan" Chinese-Han-Simplified) : TW +// http://www.twnic.net/english/dn/dn_07a.htm +台湾 + +// xn--nnx388a ("Taiwan") variant : TW +臺灣 + +// xn--j1amh ("ukr" Cyrillic) : UA +укр + +// xn--mgb2ddes ("AlYemen" Arabic) : YE +اليمن + +// xxx : http://icmregistry.com +xxx + +// ye : http://www.y.net.ye/services/domain_name.htm +*.ye + +// za : http://www.zadna.org.za/slds.html +*.za + +// zm : http://en.wikipedia.org/wiki/.zm +*.zm + +// zw : http://en.wikipedia.org/wiki/.zw +*.zw + + +// List of new gTLDs imported from https://newgtlds.icann.org/newgtlds.csv on 2015-04-07T06:02:08Z + +// aaa : 2015-02-26 American Automobile Association, Inc. +aaa + +// abb : 2014-10-24 ABB Ltd +abb + +// abbott : 2014-07-24 Abbott Laboratories, Inc. +abbott + +// abogado : 2014-04-24 Top Level Domain Holdings Limited +abogado + +// academy : 2013-11-07 Half Oaks, LLC +academy + +// accenture : 2014-08-15 Accenture plc +accenture + +// accountant : 2014-11-20 dot Accountant Limited +accountant + +// accountants : 2014-03-20 Knob Town, LLC +accountants + +// aco : 2015-01-08 ACO Severin Ahlmann GmbH & Co. KG +aco + +// active : 2014-05-01 The Active Network, Inc +active + +// actor : 2013-12-12 United TLD Holdco Ltd. +actor + +// ads : 2014-12-04 Charleston Road Registry Inc. +ads + +// adult : 2014-10-16 ICM Registry AD LLC +adult + +// aeg : 2015-03-19 Aktiebolaget Electrolux +aeg + +// afl : 2014-10-02 Australian Football League +afl + +// africa : 2014-03-24 ZA Central Registry NPC trading as Registry.Africa +africa + +// africamagic : 2015-03-05 Electronic Media Network (Pty) Ltd +africamagic + +// agency : 2013-11-14 Steel Falls, LLC +agency + +// aig : 2014-12-18 American International Group, Inc. +aig + +// airforce : 2014-03-06 United TLD Holdco Ltd. +airforce + +// airtel : 2014-10-24 Bharti Airtel Limited +airtel + +// alibaba : 2015-01-15 Alibaba Group Holding Limited +alibaba + +// alipay : 2015-01-15 Alibaba Group Holding Limited +alipay + +// allfinanz : 2014-07-03 Allfinanz Deutsche Vermögensberatung Aktiengesellschaft +allfinanz + +// alsace : 2014-07-02 REGION D ALSACE +alsace + +// amsterdam : 2014-07-24 Gemeente Amsterdam +amsterdam + +// analytics : 2014-12-18 Campus IP LLC +analytics + +// android : 2014-08-07 Charleston Road Registry Inc. +android + +// anquan : 2015-01-08 QIHOO 360 TECHNOLOGY CO. LTD. +anquan + +// apartments : 2014-12-11 June Maple, LLC +apartments + +// aquarelle : 2014-07-24 Aquarelle.com +aquarelle + +// aramco : 2014-11-20 Aramco Services Company +aramco + +// archi : 2014-02-06 STARTING DOT LIMITED +archi + +// army : 2014-03-06 United TLD Holdco Ltd. +army + +// arte : 2014-12-11 Association Relative à la Télévision Européenne G.E.I.E. +arte + +// associates : 2014-03-06 Baxter Hill, LLC +associates + +// attorney : 2014-03-20 +attorney + +// auction : 2014-03-20 +auction + +// audio : 2014-03-20 Uniregistry, Corp. +audio + +// author : 2014-12-18 Amazon EU S.à r.l. +author + +// auto : 2014-11-13 Uniregistry, Corp. +auto + +// autos : 2014-01-09 DERAutos, LLC +autos + +// avianca : 2015-01-08 Aerovias del Continente Americano S.A. Avianca +avianca + +// axa : 2013-12-19 AXA SA +axa + +// azure : 2014-12-18 Microsoft Corporation +azure + +// baidu : 2015-01-08 Baidu, Inc. +baidu + +// band : 2014-06-12 +band + +// bank : 2014-09-25 fTLD Registry Services LLC +bank + +// bar : 2013-12-12 Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable +bar + +// barcelona : 2014-07-24 Municipi de Barcelona +barcelona + +// barclaycard : 2014-11-20 Barclays Bank PLC +barclaycard + +// barclays : 2014-11-20 Barclays Bank PLC +barclays + +// bargains : 2013-11-14 Half Hallow, LLC +bargains + +// bauhaus : 2014-04-17 Werkhaus GmbH +bauhaus + +// bayern : 2014-01-23 Bayern Connect GmbH +bayern + +// bbc : 2014-12-18 British Broadcasting Corporation +bbc + +// bbva : 2014-10-02 BANCO BILBAO VIZCAYA ARGENTARIA, S.A. +bbva + +// bcg : 2015-04-02 The Boston Consulting Group, Inc. +bcg + +// bcn : 2014-07-24 Municipi de Barcelona +bcn + +// beer : 2014-01-09 Top Level Domain Holdings Limited +beer + +// bentley : 2014-12-18 Bentley Motors Limited +bentley + +// berlin : 2013-10-31 dotBERLIN GmbH & Co. KG +berlin + +// best : 2013-12-19 BestTLD Pty Ltd +best + +// bharti : 2014-01-09 Bharti Enterprises (Holding) Private Limited +bharti + +// bible : 2014-06-19 American Bible Society +bible + +// bid : 2013-12-19 dot Bid Limited +bid + +// bike : 2013-08-27 Grand Hollow, LLC +bike + +// bing : 2014-12-18 Microsoft Corporation +bing + +// bingo : 2014-12-04 Sand Cedar, LLC +bingo + +// bio : 2014-03-06 STARTING DOT LIMITED +bio + +// black : 2014-01-16 Afilias Limited +black + +// blackfriday : 2014-01-16 Uniregistry, Corp. +blackfriday + +// bloomberg : 2014-07-17 Bloomberg IP Holdings LLC +bloomberg + +// blue : 2013-11-07 Afilias Limited +blue + +// bms : 2014-10-30 Bristol-Myers Squibb Company +bms + +// bmw : 2014-01-09 Bayerische Motoren Werke Aktiengesellschaft +bmw + +// bnl : 2014-07-24 Banca Nazionale del Lavoro +bnl + +// bnpparibas : 2014-05-29 BNP Paribas +bnpparibas + +// boats : 2014-12-04 DERBoats, LLC +boats + +// bom : 2014-10-16 Núcleo de Informação e Coordenação do Ponto BR - NIC.br +bom + +// bond : 2014-06-05 Bond University Limited +bond + +// boo : 2014-01-30 Charleston Road Registry Inc. +boo + +// boots : 2015-01-08 THE BOOTS COMPANY PLC +boots + +// bot : 2014-12-18 Amazon EU S.à r.l. +bot + +// boutique : 2013-11-14 Over Galley, LLC +boutique + +// bradesco : 2014-12-18 Banco Bradesco S.A. +bradesco + +// bridgestone : 2014-12-18 Bridgestone Corporation +bridgestone + +// broadway : 2014-12-22 Celebrate Broadway, Inc. +broadway + +// broker : 2014-12-11 IG Group Holdings PLC +broker + +// brother : 2015-01-29 Brother Industries, Ltd. +brother + +// brussels : 2014-02-06 DNS.be vzw +brussels + +// budapest : 2013-11-21 Top Level Domain Holdings Limited +budapest + +// build : 2013-11-07 Plan Bee LLC +build + +// builders : 2013-11-07 Atomic Madison, LLC +builders + +// business : 2013-11-07 Spring Cross, LLC +business + +// buy : 2014-12-18 Amazon EU S.à r.l. +buy + +// buzz : 2013-10-02 DOTSTRATEGY CO. +buzz + +// bzh : 2014-02-27 Association www.bzh +bzh + +// cab : 2013-10-24 Half Sunset, LLC +cab + +// cafe : 2015-02-11 Pioneer Canyon, LLC +cafe + +// cal : 2014-07-24 Charleston Road Registry Inc. +cal + +// call : 2014-12-18 Amazon EU S.à r.l. +call + +// camera : 2013-08-27 Atomic Maple, LLC +camera + +// camp : 2013-11-07 Delta Dynamite, LLC +camp + +// cancerresearch : 2014-05-15 Australian Cancer Research Foundation +cancerresearch + +// canon : 2014-09-12 Canon Inc. +canon + +// capetown : 2014-03-24 ZA Central Registry NPC trading as ZA Central Registry +capetown + +// capital : 2014-03-06 Delta Mill, LLC +capital + +// car : 2015-01-22 Charleston Road Registry Inc. +car + +// caravan : 2013-12-12 Caravan International, Inc. +caravan + +// cards : 2013-12-05 Foggy Hollow, LLC +cards + +// care : 2014-03-06 Goose Cross +care + +// career : 2013-10-09 dotCareer LLC +career + +// careers : 2013-10-02 Wild Corner, LLC +careers + +// cars : 2014-11-13 Uniregistry, Corp. +cars + +// cartier : 2014-06-23 Richemont DNS Inc. +cartier + +// casa : 2013-11-21 Top Level Domain Holdings Limited +casa + +// cash : 2014-03-06 Delta Lake, LLC +cash + +// casino : 2014-12-18 Binky Sky, LLC +casino + +// catering : 2013-12-05 New Falls. LLC +catering + +// cba : 2014-06-26 COMMONWEALTH BANK OF AUSTRALIA +cba + +// cbn : 2014-08-22 The Christian Broadcasting Network, Inc. +cbn + +// center : 2013-11-07 Tin Mill, LLC +center + +// ceo : 2013-11-07 CEOTLD Pty Ltd +ceo + +// cern : 2014-06-05 European Organization for Nuclear Research (\ +cern + +// cfa : 2014-08-28 CFA Institute +cfa + +// cfd : 2014-12-11 IG Group Holdings PLC +cfd + +// channel : 2014-05-08 Charleston Road Registry Inc. +channel + +// chat : 2014-12-04 Sand Fields, LLC +chat + +// cheap : 2013-11-14 Sand Cover, LLC +cheap + +// chloe : 2014-10-16 Richemont DNS Inc. +chloe + +// christmas : 2013-11-21 Uniregistry, Corp. +christmas + +// chrome : 2014-07-24 Charleston Road Registry Inc. +chrome + +// church : 2014-02-06 Holly Fields, LLC +church + +// cipriani : 2015-02-19 Hotel Cipriani Srl +cipriani + +// circle : 2014-12-18 Amazon EU S.à r.l. +circle + +// cisco : 2014-12-22 Cisco Technology, Inc. +cisco + +// citic : 2014-01-09 CITIC Group Corporation +citic + +// city : 2014-05-29 Snow Sky, LLC +city + +// cityeats : 2014-12-11 Lifestyle Domain Holdings, Inc. +cityeats + +// claims : 2014-03-20 Black Corner, LLC +claims + +// cleaning : 2013-12-05 Fox Shadow, LLC +cleaning + +// click : 2014-06-05 Uniregistry, Corp. +click + +// clinic : 2014-03-20 Goose Park, LLC +clinic + +// clothing : 2013-08-27 Steel Lake, LLC +clothing + +// club : 2013-11-08 .CLUB DOMAINS, LLC +club + +// coach : 2014-10-09 Koko Island, LLC +coach + +// codes : 2013-10-31 Puff Willow, LLC +codes + +// coffee : 2013-10-17 Trixy Cover, LLC +coffee + +// college : 2014-01-16 XYZ.COM LLC +college + +// cologne : 2014-02-05 NetCologne Gesellschaft für Telekommunikation mbH +cologne + +// commbank : 2014-06-26 COMMONWEALTH BANK OF AUSTRALIA +commbank + +// community : 2013-12-05 Fox Orchard, LLC +community + +// company : 2013-11-07 Silver Avenue, LLC +company + +// computer : 2013-10-24 Pine Mill, LLC +computer + +// comsec : 2015-01-08 VeriSign, Inc. +comsec + +// condos : 2013-12-05 Pine House, LLC +condos + +// construction : 2013-09-16 Fox Dynamite, LLC +construction + +// consulting : 2013-12-05 +consulting + +// contact : 2015-01-08 Top Level Spectrum, Inc. +contact + +// contractors : 2013-09-10 Magic Woods, LLC +contractors + +// cooking : 2013-11-21 Top Level Domain Holdings Limited +cooking + +// cool : 2013-11-14 Koko Lake, LLC +cool + +// corsica : 2014-09-25 Collectivité Territoriale de Corse +corsica + +// country : 2013-12-19 Top Level Domain Holdings Limited +country + +// coupon : 2015-02-26 Amazon EU S.à r.l. +coupon + +// coupons : 2015-03-26 Black Island, LLC +coupons + +// courses : 2014-12-04 OPEN UNIVERSITIES AUSTRALIA PTY LTD +courses + +// credit : 2014-03-20 Snow Shadow, LLC +credit + +// creditcard : 2014-03-20 Binky Frostbite, LLC +creditcard + +// creditunion : 2015-01-22 CUNA Performance Resources, LLC +creditunion + +// cricket : 2014-10-09 dot Cricket Limited +cricket + +// crown : 2014-10-24 Crown Equipment Corporation +crown + +// crs : 2014-04-03 Federated Co-operatives Limited +crs + +// cruises : 2013-12-05 Spring Way, LLC +cruises + +// csc : 2014-09-25 Alliance-One Services, Inc. +csc + +// cuisinella : 2014-04-03 SALM S.A.S. +cuisinella + +// cymru : 2014-05-08 Nominet UK +cymru + +// cyou : 2015-01-22 Beijing Gamease Age Digital Technology Co., Ltd. +cyou + +// dabur : 2014-02-06 Dabur India Limited +dabur + +// dad : 2014-01-23 Charleston Road Registry Inc. +dad + +// dance : 2013-10-24 United TLD Holdco Ltd. +dance + +// date : 2014-11-20 dot Date Limited +date + +// dating : 2013-12-05 Pine Fest, LLC +dating + +// datsun : 2014-03-27 NISSAN MOTOR CO., LTD. +datsun + +// day : 2014-01-30 Charleston Road Registry Inc. +day + +// dclk : 2014-11-20 Charleston Road Registry Inc. +dclk + +// dealer : 2014-12-22 Dealer Dot Com, Inc. +dealer + +// deals : 2014-05-22 Sand Sunset, LLC +deals + +// degree : 2014-03-06 +degree + +// delivery : 2014-09-11 Steel Station, LLC +delivery + +// dell : 2014-10-24 Dell Inc. +dell + +// delta : 2015-02-19 Delta Air Lines, Inc. +delta + +// democrat : 2013-10-24 United TLD Holdco Ltd. +democrat + +// dental : 2014-03-20 Tin Birch, LLC +dental + +// dentist : 2014-03-20 +dentist + +// desi : 2013-11-14 Desi Networks LLC +desi + +// design : 2014-11-07 Top Level Design, LLC +design + +// dev : 2014-10-16 Charleston Road Registry Inc. +dev + +// diamonds : 2013-09-22 John Edge, LLC +diamonds + +// diet : 2014-06-26 Uniregistry, Corp. +diet + +// digital : 2014-03-06 Dash Park, LLC +digital + +// direct : 2014-04-10 Half Trail, LLC +direct + +// directory : 2013-09-20 Extra Madison, LLC +directory + +// discount : 2014-03-06 Holly Hill, LLC +discount + +// dnp : 2013-12-13 Dai Nippon Printing Co., Ltd. +dnp + +// docs : 2014-10-16 Charleston Road Registry Inc. +docs + +// dog : 2014-12-04 Koko Mill, LLC +dog + +// doha : 2014-09-18 Communications Regulatory Authority (CRA) +doha + +// domains : 2013-10-17 Sugar Cross, LLC +domains + +// doosan : 2014-04-03 Doosan Corporation +doosan + +// download : 2014-11-20 dot Support Limited +download + +// drive : 2015-03-05 Charleston Road Registry Inc. +drive + +// dstv : 2015-03-12 MultiChoice (Proprietary) Limited +dstv + +// dubai : 2015-01-01 Dubai Smart Government Department +dubai + +// durban : 2014-03-24 ZA Central Registry NPC trading as ZA Central Registry +durban + +// dvag : 2014-06-23 Deutsche Vermögensberatung Aktiengesellschaft DVAG +dvag + +// earth : 2014-12-04 Interlink Co., Ltd. +earth + +// eat : 2014-01-23 Charleston Road Registry Inc. +eat + +// edeka : 2014-12-18 EDEKA Verband kaufmännischer Genossenschaften e.V. +edeka + +// education : 2013-11-07 Brice Way, LLC +education + +// email : 2013-10-31 Spring Madison, LLC +email + +// emerck : 2014-04-03 Merck KGaA +emerck + +// energy : 2014-09-11 Binky Birch, LLC +energy + +// engineer : 2014-03-06 United TLD Holdco Ltd. +engineer + +// engineering : 2014-03-06 Romeo Canyon +engineering + +// enterprises : 2013-09-20 Snow Oaks, LLC +enterprises + +// epson : 2014-12-04 Seiko Epson Corporation +epson + +// equipment : 2013-08-27 Corn Station, LLC +equipment + +// erni : 2014-04-03 ERNI Group Holding AG +erni + +// esq : 2014-05-08 Charleston Road Registry Inc. +esq + +// estate : 2013-08-27 Trixy Park, LLC +estate + +// eurovision : 2014-04-24 European Broadcasting Union (EBU) +eurovision + +// eus : 2013-12-12 Puntueus Fundazioa +eus + +// events : 2013-12-05 Pioneer Maple, LLC +events + +// everbank : 2014-05-15 EverBank +everbank + +// exchange : 2014-03-06 Spring Falls, LLC +exchange + +// expert : 2013-11-21 Magic Pass, LLC +expert + +// exposed : 2013-12-05 Victor Beach, LLC +exposed + +// express : 2015-02-11 Sea Sunset, LLC +express + +// fage : 2014-12-18 Fage International S.A. +fage + +// fail : 2014-03-06 Atomic Pipe, LLC +fail + +// fairwinds : 2014-11-13 FairWinds Partners, LLC +fairwinds + +// faith : 2014-11-20 dot Faith Limited +faith + +// family : 2015-04-02 Bitter Galley, LLC +family + +// fan : 2014-03-06 +fan + +// fans : 2014-11-07 Asiamix Digital Limited +fans + +// farm : 2013-11-07 Just Maple, LLC +farm + +// fashion : 2014-07-03 Top Level Domain Holdings Limited +fashion + +// fast : 2014-12-18 Amazon EU S.à r.l. +fast + +// feedback : 2013-12-19 Top Level Spectrum, Inc. +feedback + +// ferrero : 2014-12-18 Ferrero Trading Lux S.A. +ferrero + +// film : 2015-01-08 Motion Picture Domain Registry Pty Ltd +film + +// final : 2014-10-16 Núcleo de Informação e Coordenação do Ponto BR - NIC.br +final + +// finance : 2014-03-20 Cotton Cypress, LLC +finance + +// financial : 2014-03-06 Just Cover, LLC +financial + +// firestone : 2014-12-18 Bridgestone Corporation +firestone + +// firmdale : 2014-03-27 Firmdale Holdings Limited +firmdale + +// fish : 2013-12-12 Fox Woods, LLC +fish + +// fishing : 2013-11-21 Top Level Domain Holdings Limited +fishing + +// fit : 2014-11-07 Top Level Domain Holdings Limited +fit + +// fitness : 2014-03-06 Brice Orchard, LLC +fitness + +// flickr : 2015-04-02 Yahoo! Domain Services Inc. +flickr + +// flights : 2013-12-05 Fox Station, LLC +flights + +// florist : 2013-11-07 Half Cypress, LLC +florist + +// flowers : 2014-10-09 Uniregistry, Corp. +flowers + +// flsmidth : 2014-07-24 FLSmidth A/S +flsmidth + +// fly : 2014-05-08 Charleston Road Registry Inc. +fly + +// foo : 2014-01-23 Charleston Road Registry Inc. +foo + +// football : 2014-12-18 Foggy Farms, LLC +football + +// ford : 2014-11-13 Ford Motor Company +ford + +// forex : 2014-12-11 IG Group Holdings PLC +forex + +// forsale : 2014-05-22 +forsale + +// forum : 2015-04-02 Fegistry, LLC +forum + +// foundation : 2013-12-05 John Dale, LLC +foundation + +// frl : 2014-05-15 FRLregistry B.V. +frl + +// frogans : 2013-12-19 OP3FT +frogans + +// frontier : 2015-02-05 Frontier Communications Corporation +frontier + +// fund : 2014-03-20 John Castle, LLC +fund + +// furniture : 2014-03-20 Lone Fields, LLC +furniture + +// futbol : 2013-09-20 +futbol + +// fyi : 2015-04-02 Silver Tigers, LLC +fyi + +// gal : 2013-11-07 Asociación puntoGAL +gal + +// gallery : 2013-09-13 Sugar House, LLC +gallery + +// gallup : 2015-02-19 Gallup, Inc. +gallup + +// garden : 2014-06-26 Top Level Domain Holdings Limited +garden + +// gbiz : 2014-07-17 Charleston Road Registry Inc. +gbiz + +// gdn : 2014-07-31 Joint Stock Company \ +gdn + +// gea : 2014-12-04 GEA Group Aktiengesellschaft +gea + +// gent : 2014-01-23 COMBELL GROUP NV/SA +gent + +// genting : 2015-03-12 Resorts World Inc Pte. Ltd. +genting + +// ggee : 2014-01-09 GMO Internet, Inc. +ggee + +// gift : 2013-10-17 Uniregistry, Corp. +gift + +// gifts : 2014-07-03 Goose Sky, LLC +gifts + +// gives : 2014-03-06 United TLD Holdco Ltd. +gives + +// giving : 2014-11-13 Giving Limited +giving + +// glass : 2013-11-07 Black Cover, LLC +glass + +// gle : 2014-07-24 Charleston Road Registry Inc. +gle + +// global : 2014-04-17 Dot GLOBAL AS +global + +// globo : 2013-12-19 Globo Comunicação e Participações S.A +globo + +// gmail : 2014-05-01 Charleston Road Registry Inc. +gmail + +// gmo : 2014-01-09 GMO Internet, Inc. +gmo + +// gmx : 2014-04-24 1&1 Mail & Media GmbH +gmx + +// gold : 2015-01-22 June Edge, LLC +gold + +// goldpoint : 2014-11-20 YODOBASHI CAMERA CO.,LTD. +goldpoint + +// golf : 2014-12-18 Lone falls, LLC +golf + +// goo : 2014-12-18 NTT Resonant Inc. +goo + +// goog : 2014-11-20 Charleston Road Registry Inc. +goog + +// google : 2014-07-24 Charleston Road Registry Inc. +google + +// gop : 2014-01-16 Republican State Leadership Committee, Inc. +gop + +// got : 2014-12-18 Amazon EU S.à r.l. +got + +// gotv : 2015-03-12 MultiChoice (Proprietary) Limited +gotv + +// graphics : 2013-09-13 Over Madison, LLC +graphics + +// gratis : 2014-03-20 Pioneer Tigers, LLC +gratis + +// green : 2014-05-08 Afilias Limited +green + +// gripe : 2014-03-06 Corn Sunset, LLC +gripe + +// group : 2014-08-15 Romeo Town, LLC +group + +// gucci : 2014-11-13 Guccio Gucci S.p.a. +gucci + +// guge : 2014-08-28 Charleston Road Registry Inc. +guge + +// guide : 2013-09-13 Snow Moon, LLC +guide + +// guitars : 2013-11-14 Uniregistry, Corp. +guitars + +// guru : 2013-08-27 Pioneer Cypress, LLC +guru + +// hamburg : 2014-02-20 Hamburg Top-Level-Domain GmbH +hamburg + +// hangout : 2014-11-13 Charleston Road Registry Inc. +hangout + +// haus : 2013-12-05 +haus + +// hdfcbank : 2015-02-12 HDFC Bank Limited +hdfcbank + +// health : 2015-02-11 DotHealth, LLC +health + +// healthcare : 2014-06-12 Silver Glen, LLC +healthcare + +// help : 2014-06-26 Uniregistry, Corp. +help + +// helsinki : 2015-02-05 City of Helsinki +helsinki + +// here : 2014-02-06 Charleston Road Registry Inc. +here + +// hermes : 2014-07-10 HERMES INTERNATIONAL +hermes + +// hiphop : 2014-03-06 Uniregistry, Corp. +hiphop + +// hitachi : 2014-10-31 Hitachi, Ltd. +hitachi + +// hiv : 2014-03-13 dotHIV gemeinnuetziger e.V. +hiv + +// hockey : 2015-03-19 Half Willow, LLC +hockey + +// holdings : 2013-08-27 John Madison, LLC +holdings + +// holiday : 2013-11-07 Goose Woods, LLC +holiday + +// homedepot : 2015-04-02 Homer TLC, Inc. +homedepot + +// homes : 2014-01-09 DERHomes, LLC +homes + +// honda : 2014-12-18 Honda Motor Co., Ltd. +honda + +// horse : 2013-11-21 Top Level Domain Holdings Limited +horse + +// host : 2014-04-17 DotHost Inc. +host + +// hosting : 2014-05-29 Uniregistry, Corp. +hosting + +// hoteles : 2015-03-05 Travel Reservations SRL +hoteles + +// hotmail : 2014-12-18 Microsoft Corporation +hotmail + +// house : 2013-11-07 Sugar Park, LLC +house + +// how : 2014-01-23 Charleston Road Registry Inc. +how + +// hsbc : 2014-10-24 HSBC Holdings PLC +hsbc + +// htc : 2015-04-02 HTC corporation +htc + +// ibm : 2014-07-31 International Business Machines Corporation +ibm + +// icbc : 2015-02-19 Industrial and Commercial Bank of China Limited +icbc + +// ice : 2014-10-30 IntercontinentalExchange, Inc. +ice + +// icu : 2015-01-08 One.com A/S +icu + +// ifm : 2014-01-30 ifm electronic gmbh +ifm + +// iinet : 2014-07-03 Connect West Pty. Ltd. +iinet + +// immo : 2014-07-10 Auburn Bloom, LLC +immo + +// immobilien : 2013-11-07 United TLD Holdco Ltd. +immobilien + +// industries : 2013-12-05 Outer House, LLC +industries + +// infiniti : 2014-03-27 NISSAN MOTOR CO., LTD. +infiniti + +// ing : 2014-01-23 Charleston Road Registry Inc. +ing + +// ink : 2013-12-05 Top Level Design, LLC +ink + +// institute : 2013-11-07 Outer Maple, LLC +institute + +// insurance : 2015-02-19 fTLD Registry Services LLC +insurance + +// insure : 2014-03-20 Pioneer Willow, LLC +insure + +// international : 2013-11-07 Wild Way, LLC +international + +// investments : 2014-03-20 Holly Glen, LLC +investments + +// ipiranga : 2014-08-28 Ipiranga Produtos de Petroleo S.A. +ipiranga + +// irish : 2014-08-07 Dot-Irish LLC +irish + +// iselect : 2015-02-11 iSelect Ltd +iselect + +// ist : 2014-08-28 Istanbul Metropolitan Municipality +ist + +// istanbul : 2014-08-28 Istanbul Metropolitan Municipality +istanbul + +// itau : 2014-10-02 Itau Unibanco Holding S.A. +itau + +// iwc : 2014-06-23 Richemont DNS Inc. +iwc + +// jaguar : 2014-11-13 Jaguar Land Rover Ltd +jaguar + +// java : 2014-06-19 Oracle Corporation +java + +// jcb : 2014-11-20 JCB Co., Ltd. +jcb + +// jetzt : 2014-01-09 New TLD Company AB +jetzt + +// jewelry : 2015-03-05 Wild Bloom, LLC +jewelry + +// jio : 2015-04-02 Affinity Names, Inc. +jio + +// jlc : 2014-12-04 Richemont DNS Inc. +jlc + +// jll : 2015-04-02 Jones Lang LaSalle Incorporated +jll + +// jmp : 2015-03-26 Matrix IP LLC +jmp + +// joburg : 2014-03-24 ZA Central Registry NPC trading as ZA Central Registry +joburg + +// jot : 2014-12-18 Amazon EU S.à r.l. +jot + +// joy : 2014-12-18 Amazon EU S.à r.l. +joy + +// jprs : 2014-09-18 Japan Registry Services Co., Ltd. +jprs + +// juegos : 2014-03-20 Uniregistry, Corp. +juegos + +// kaufen : 2013-11-07 United TLD Holdco Ltd. +kaufen + +// kddi : 2014-09-12 KDDI CORPORATION +kddi + +// kfh : 2014-12-04 Kuwait Finance House +kfh + +// kim : 2013-09-23 Afilias Limited +kim + +// kinder : 2014-11-07 Ferrero Trading Lux S.A. +kinder + +// kitchen : 2013-09-20 Just Goodbye, LLC +kitchen + +// kiwi : 2013-09-20 DOT KIWI LIMITED +kiwi + +// koeln : 2014-01-09 NetCologne Gesellschaft für Telekommunikation mbH +koeln + +// komatsu : 2015-01-08 Komatsu Ltd. +komatsu + +// kpn : 2015-01-08 Koninklijke KPN N.V. +kpn + +// krd : 2013-12-05 KRG Department of Information Technology +krd + +// kred : 2013-12-19 KredTLD Pty Ltd +kred + +// kyknet : 2015-03-05 Electronic Media Network (Pty) Ltd +kyknet + +// kyoto : 2014-11-07 Academic Institution: Kyoto Jyoho Gakuen +kyoto + +// lacaixa : 2014-01-09 CAIXA D'ESTALVIS I PENSIONS DE BARCELONA +lacaixa + +// lancaster : 2015-02-12 LANCASTER +lancaster + +// land : 2013-09-10 Pine Moon, LLC +land + +// landrover : 2014-11-13 Jaguar Land Rover Ltd +landrover + +// lasalle : 2015-04-02 Jones Lang LaSalle Incorporated +lasalle + +// lat : 2014-10-16 ECOM-LAC Federaciòn de Latinoamèrica y el Caribe para Internet y el Comercio Electrònico +lat + +// latrobe : 2014-06-16 La Trobe University +latrobe + +// law : 2015-01-22 Minds + Machines Group Limited +law + +// lawyer : 2014-03-20 +lawyer + +// lds : 2014-03-20 IRI Domain Management, LLC (\ +lds + +// lease : 2014-03-06 Victor Trail, LLC +lease + +// leclerc : 2014-08-07 A.C.D. LEC Association des Centres Distributeurs Edouard Leclerc +leclerc + +// legal : 2014-10-16 Blue Falls, LLC +legal + +// lgbt : 2014-05-08 Afilias Limited +lgbt + +// liaison : 2014-10-02 Liaison Technologies, Incorporated +liaison + +// lidl : 2014-09-18 Schwarz Domains und Services GmbH & Co. KG +lidl + +// life : 2014-02-06 Trixy Oaks, LLC +life + +// lifeinsurance : 2015-01-15 American Council of Life Insurers +lifeinsurance + +// lifestyle : 2014-12-11 Lifestyle Domain Holdings, Inc. +lifestyle + +// lighting : 2013-08-27 John McCook, LLC +lighting + +// like : 2014-12-18 Amazon EU S.à r.l. +like + +// limited : 2014-03-06 Big Fest, LLC +limited + +// limo : 2013-10-17 Hidden Frostbite, LLC +limo + +// lincoln : 2014-11-13 Ford Motor Company +lincoln + +// linde : 2014-12-04 Linde Aktiengesellschaft +linde + +// link : 2013-11-14 Uniregistry, Corp. +link + +// live : 2014-12-04 Half Woods, LLC +live + +// lixil : 2015-03-19 LIXIL Group Corporation +lixil + +// loan : 2014-11-20 dot Loan Limited +loan + +// loans : 2014-03-20 June Woods, LLC +loans + +// lol : 2015-01-30 Uniregistry, Corp. +lol + +// london : 2013-11-14 Dot London Domains Limited +london + +// lotte : 2014-11-07 Lotte Holdings Co., Ltd. +lotte + +// lotto : 2014-04-10 Afilias Limited +lotto + +// love : 2014-12-22 Merchant Law Group LLP +love + +// ltd : 2014-09-25 Over Corner, LLC +ltd + +// ltda : 2014-04-17 DOMAIN ROBOT SERVICOS DE HOSPEDAGEM NA INTERNET LTDA +ltda + +// lupin : 2014-11-07 LUPIN LIMITED +lupin + +// luxe : 2014-01-09 Top Level Domain Holdings Limited +luxe + +// luxury : 2013-10-17 Luxury Partners, LLC +luxury + +// madrid : 2014-05-01 Comunidad de Madrid +madrid + +// maif : 2014-10-02 Mutuelle Assurance Instituteur France (MAIF) +maif + +// maison : 2013-12-05 Victor Frostbite, LLC +maison + +// makeup : 2015-01-15 L'Oréal +makeup + +// man : 2014-12-04 MAN SE +man + +// management : 2013-11-07 John Goodbye, LLC +management + +// mango : 2013-10-24 PUNTO FA S.L. +mango + +// market : 2014-03-06 +market + +// marketing : 2013-11-07 Fern Pass, LLC +marketing + +// markets : 2014-12-11 IG Group Holdings PLC +markets + +// marriott : 2014-10-09 Marriott Worldwide Corporation +marriott + +// mba : 2015-04-02 Lone Hollow, LLC +mba + +// media : 2014-03-06 Grand Glen, LLC +media + +// meet : 2014-01-16 +meet + +// melbourne : 2014-05-29 The Crown in right of the State of Victoria, represented by its Department of State Development, Business and Innovation +melbourne + +// meme : 2014-01-30 Charleston Road Registry Inc. +meme + +// memorial : 2014-10-16 Dog Beach, LLC +memorial + +// men : 2015-02-26 Exclusive Registry Limited +men + +// menu : 2013-09-11 Wedding TLD2, LLC +menu + +// meo : 2014-11-07 PT Comunicacoes S.A. +meo + +// miami : 2013-12-19 Top Level Domain Holdings Limited +miami + +// microsoft : 2014-12-18 Microsoft Corporation +microsoft + +// mini : 2014-01-09 Bayerische Motoren Werke Aktiengesellschaft +mini + +// mma : 2014-11-07 MMA IARD +mma + +// mnet : 2015-03-05 Electronic Media Network (Pty) Ltd +mnet + +// mobily : 2014-12-18 GreenTech Consultancy Company W.L.L. +mobily + +// moda : 2013-11-07 United TLD Holdco Ltd. +moda + +// moe : 2013-11-13 Interlink Co., Ltd. +moe + +// moi : 2014-12-18 Amazon EU S.à r.l. +moi + +// monash : 2013-09-30 Monash University +monash + +// money : 2014-10-16 Outer McCook, LLC +money + +// montblanc : 2014-06-23 Richemont DNS Inc. +montblanc + +// mormon : 2013-12-05 IRI Domain Management, LLC (\ +mormon + +// mortgage : 2014-03-20 +mortgage + +// moscow : 2013-12-19 Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID) +moscow + +// motorcycles : 2014-01-09 DERMotorcycles, LLC +motorcycles + +// mov : 2014-01-30 Charleston Road Registry Inc. +mov + +// movie : 2015-02-05 New Frostbite, LLC +movie + +// movistar : 2014-10-16 Telefónica S.A. +movistar + +// mtn : 2014-12-04 MTN Dubai Limited +mtn + +// mtpc : 2014-11-20 Mitsubishi Tanabe Pharma Corporation +mtpc + +// mtr : 2015-03-12 MTR Corporation Limited +mtr + +// multichoice : 2015-03-12 MultiChoice (Proprietary) Limited +multichoice + +// mutual : 2015-04-02 Northwestern Mutual MU TLD Registry, LLC +mutual + +// mzansimagic : 2015-03-05 Electronic Media Network (Pty) Ltd +mzansimagic + +// nadex : 2014-12-11 IG Group Holdings PLC +nadex + +// nagoya : 2013-10-24 GMO Registry, Inc. +nagoya + +// naspers : 2015-02-12 Intelprop (Proprietary) Limited +naspers + +// natura : 2015-03-12 NATURA COSMÉTICOS S.A. +natura + +// navy : 2014-03-06 United TLD Holdco Ltd. +navy + +// nec : 2015-01-08 NEC Corporation +nec + +// netbank : 2014-06-26 COMMONWEALTH BANK OF AUSTRALIA +netbank + +// network : 2013-11-14 Trixy Manor, LLC +network + +// neustar : 2013-12-05 NeuStar, Inc. +neustar + +// new : 2014-01-30 Charleston Road Registry Inc. +new + +// news : 2014-12-18 +news + +// nexus : 2014-07-24 Charleston Road Registry Inc. +nexus + +// ngo : 2014-03-06 Public Interest Registry +ngo + +// nhk : 2014-02-13 Japan Broadcasting Corporation (NHK) +nhk + +// nico : 2014-12-04 DWANGO Co., Ltd. +nico + +// ninja : 2013-11-07 United TLD Holdco Ltd. +ninja + +// nissan : 2014-03-27 NISSAN MOTOR CO., LTD. +nissan + +// nokia : 2015-01-08 Nokia Corporation +nokia + +// norton : 2014-12-04 Symantec Corporation +norton + +// nowruz : 2014-09-04 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +nowruz + +// nra : 2014-05-22 NRA Holdings Company, INC. +nra + +// nrw : 2013-11-21 Minds + Machines GmbH +nrw + +// ntt : 2014-10-31 NIPPON TELEGRAPH AND TELEPHONE CORPORATION +ntt + +// nyc : 2014-01-23 The City of New York by and through the New York City Department of Information Technology & Telecommunications +nyc + +// obi : 2014-09-25 OBI Group Holding SE & Co. KGaA +obi + +// office : 2015-03-12 Microsoft Corporation +office + +// okinawa : 2013-12-05 BusinessRalliart Inc. +okinawa + +// omega : 2015-01-08 The Swatch Group Ltd +omega + +// one : 2014-11-07 One.com A/S +one + +// ong : 2014-03-06 Public Interest Registry +ong + +// onl : 2013-09-16 I-Registry Ltd. +onl + +// online : 2015-01-15 DotOnline Inc. +online + +// ooo : 2014-01-09 INFIBEAM INCORPORATION LIMITED +ooo + +// oracle : 2014-06-19 Oracle Corporation +oracle + +// orange : 2015-03-12 Orange Brand Services Limited +orange + +// organic : 2014-03-27 Afilias Limited +organic + +// orientexpress : 2015-02-05 Belmond Ltd. +orientexpress + +// osaka : 2014-09-04 Interlink Co., Ltd. +osaka + +// otsuka : 2013-10-11 Otsuka Holdings Co., Ltd. +otsuka + +// ovh : 2014-01-16 OVH SAS +ovh + +// page : 2014-12-04 Charleston Road Registry Inc. +page + +// pamperedchef : 2015-02-05 The Pampered Chef, Ltd. +pamperedchef + +// panerai : 2014-11-07 Richemont DNS Inc. +panerai + +// paris : 2014-01-30 City of Paris +paris + +// pars : 2014-09-04 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +pars + +// partners : 2013-12-05 Magic Glen, LLC +partners + +// parts : 2013-12-05 Sea Goodbye, LLC +parts + +// party : 2014-09-11 Blue Sky Registry Limited +party + +// passagens : 2015-03-05 Travel Reservations SRL +passagens + +// payu : 2015-02-12 MIH PayU B.V. +payu + +// pharmacy : 2014-06-19 National Association of Boards of Pharmacy +pharmacy + +// philips : 2014-11-07 Koninklijke Philips N.V. +philips + +// photo : 2013-11-14 Uniregistry, Corp. +photo + +// photography : 2013-09-20 Sugar Glen, LLC +photography + +// photos : 2013-10-17 Sea Corner, LLC +photos + +// physio : 2014-05-01 PhysBiz Pty Ltd +physio + +// piaget : 2014-10-16 Richemont DNS Inc. +piaget + +// pics : 2013-11-14 Uniregistry, Corp. +pics + +// pictet : 2014-06-26 Pictet Europe S.A. +pictet + +// pictures : 2014-03-06 Foggy Sky, LLC +pictures + +// pid : 2015-01-08 Top Level Spectrum, Inc. +pid + +// pin : 2014-12-18 Amazon EU S.à r.l. +pin + +// pink : 2013-10-01 Afilias Limited +pink + +// pizza : 2014-06-26 Foggy Moon, LLC +pizza + +// place : 2014-04-24 Snow Galley, LLC +place + +// play : 2015-03-05 Charleston Road Registry Inc. +play + +// plumbing : 2013-09-10 Spring Tigers, LLC +plumbing + +// plus : 2015-02-05 Sugar Mill, LLC +plus + +// pohl : 2014-06-23 Deutsche Vermögensberatung Aktiengesellschaft DVAG +pohl + +// poker : 2014-07-03 Afilias Domains No. 5 Limited +poker + +// porn : 2014-10-16 ICM Registry PN LLC +porn + +// praxi : 2013-12-05 Praxi S.p.A. +praxi + +// press : 2014-04-03 DotPress Inc. +press + +// prod : 2014-01-23 Charleston Road Registry Inc. +prod + +// productions : 2013-12-05 Magic Birch, LLC +productions + +// prof : 2014-07-24 Charleston Road Registry Inc. +prof + +// promo : 2014-12-18 Play.PROMO Oy +promo + +// properties : 2013-12-05 Big Pass, LLC +properties + +// property : 2014-05-22 Uniregistry, Corp. +property + +// pub : 2013-12-12 United TLD Holdco Ltd. +pub + +// qpon : 2013-11-14 dotCOOL, Inc. +qpon + +// quebec : 2013-12-19 PointQuébec Inc +quebec + +// quest : 2015-03-26 Quest ION Limited +quest + +// racing : 2014-12-04 Premier Registry Limited +racing + +// read : 2014-12-18 Amazon EU S.à r.l. +read + +// realtor : 2014-05-29 Real Estate Domains LLC +realtor + +// realty : 2015-03-19 Fegistry, LLC +realty + +// recipes : 2013-10-17 Grand Island, LLC +recipes + +// red : 2013-11-07 Afilias Limited +red + +// redstone : 2014-10-31 Redstone Haute Couture Co., Ltd. +redstone + +// redumbrella : 2015-03-26 Travelers TLD, LLC +redumbrella + +// rehab : 2014-03-06 United TLD Holdco Ltd. +rehab + +// reise : 2014-03-13 dotreise GmbH +reise + +// reisen : 2014-03-06 New Cypress, LLC +reisen + +// reit : 2014-09-04 National Association of Real Estate Investment Trusts, Inc. +reit + +// reliance : 2015-04-02 Reliance Industries Limited +reliance + +// ren : 2013-12-12 Beijing Qianxiang Wangjing Technology Development Co., Ltd. +ren + +// rent : 2014-12-04 DERRent, LLC +rent + +// rentals : 2013-12-05 Big Hollow,LLC +rentals + +// repair : 2013-11-07 Lone Sunset, LLC +repair + +// report : 2013-12-05 Binky Glen, LLC +report + +// republican : 2014-03-20 United TLD Holdco Ltd. +republican + +// rest : 2013-12-19 Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable +rest + +// restaurant : 2014-07-03 Snow Avenue, LLC +restaurant + +// review : 2014-11-20 dot Review Limited +review + +// reviews : 2013-09-13 +reviews + +// rich : 2013-11-21 I-Registry Ltd. +rich + +// ricoh : 2014-11-20 Ricoh Company, Ltd. +ricoh + +// ril : 2015-04-02 Reliance Industries Limited +ril + +// rio : 2014-02-27 Empresa Municipal de Informática SA - IPLANRIO +rio + +// rip : 2014-07-10 United TLD Holdco Ltd. +rip + +// rocher : 2014-12-18 Ferrero Trading Lux S.A. +rocher + +// rocks : 2013-11-14 +rocks + +// rodeo : 2013-12-19 Top Level Domain Holdings Limited +rodeo + +// room : 2014-12-18 Amazon EU S.à r.l. +room + +// rsvp : 2014-05-08 Charleston Road Registry Inc. +rsvp + +// ruhr : 2013-10-02 regiodot GmbH & Co. KG +ruhr + +// run : 2015-03-19 Snow Park, LLC +run + +// rwe : 2015-04-02 RWE AG +rwe + +// ryukyu : 2014-01-09 BusinessRalliart Inc. +ryukyu + +// saarland : 2013-12-12 dotSaarland GmbH +saarland + +// safe : 2014-12-18 Amazon EU S.à r.l. +safe + +// safety : 2015-01-08 Safety Registry Services, LLC. +safety + +// sakura : 2014-12-18 SAKURA Internet Inc. +sakura + +// sale : 2014-10-16 +sale + +// salon : 2014-12-11 Outer Orchard, LLC +salon + +// samsung : 2014-04-03 SAMSUNG SDS CO., LTD +samsung + +// sandvik : 2014-11-13 Sandvik AB +sandvik + +// sandvikcoromant : 2014-11-07 Sandvik AB +sandvikcoromant + +// sanofi : 2014-10-09 Sanofi +sanofi + +// sap : 2014-03-27 SAP AG +sap + +// sapo : 2014-11-07 PT Comunicacoes S.A. +sapo + +// sarl : 2014-07-03 Delta Orchard, LLC +sarl + +// sas : 2015-04-02 Research IP LLC +sas + +// saxo : 2014-10-31 Saxo Bank A/S +saxo + +// sbi : 2015-03-12 STATE BANK OF INDIA +sbi + +// sbs : 2014-11-07 SPECIAL BROADCASTING SERVICE CORPORATION +sbs + +// sca : 2014-03-13 SVENSKA CELLULOSA AKTIEBOLAGET SCA (publ) +sca + +// scb : 2014-02-20 The Siam Commercial Bank Public Company Limited (\ +scb + +// schmidt : 2014-04-03 SALM S.A.S. +schmidt + +// scholarships : 2014-04-24 Scholarships.com, LLC +scholarships + +// school : 2014-12-18 Little Galley, LLC +school + +// schule : 2014-03-06 Outer Moon, LLC +schule + +// schwarz : 2014-09-18 Schwarz Domains und Services GmbH & Co. KG +schwarz + +// science : 2014-09-11 dot Science Limited +science + +// scor : 2014-10-31 SCOR SE +scor + +// scot : 2014-01-23 Dot Scot Registry Limited +scot + +// seat : 2014-05-22 SEAT, S.A. (Sociedad Unipersonal) +seat + +// seek : 2014-12-04 Seek Limited +seek + +// sener : 2014-10-24 Sener Ingeniería y Sistemas, S.A. +sener + +// services : 2014-02-27 Fox Castle, LLC +services + +// sew : 2014-07-17 SEW-EURODRIVE GmbH & Co KG +sew + +// sex : 2014-11-13 ICM Registry SX LLC +sex + +// sexy : 2013-09-11 Uniregistry, Corp. +sexy + +// sharp : 2014-05-01 Sharp Corporation +sharp + +// shia : 2014-09-04 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +shia + +// shiksha : 2013-11-14 Afilias Limited +shiksha + +// shoes : 2013-10-02 Binky Galley, LLC +shoes + +// shouji : 2015-01-08 QIHOO 360 TECHNOLOGY CO. LTD. +shouji + +// show : 2015-03-05 Snow Beach, LLC +show + +// shriram : 2014-01-23 Shriram Capital Ltd. +shriram + +// sina : 2015-03-12 Sina Corporation +sina + +// singles : 2013-08-27 Fern Madison, LLC +singles + +// site : 2015-01-15 DotSite Inc. +site + +// skin : 2015-01-15 L'Oréal +skin + +// sky : 2014-06-19 Sky IP International Ltd, a company incorporated in England and Wales, operating via its registered Swiss branch +sky + +// skype : 2014-12-18 Microsoft Corporation +skype + +// smile : 2014-12-18 Amazon EU S.à r.l. +smile + +// sncf : 2015-02-19 Société Nationale des Chemins de fer Francais S N C F +sncf + +// soccer : 2015-03-26 Foggy Shadow, LLC +soccer + +// social : 2013-11-07 United TLD Holdco Ltd. +social + +// software : 2014-03-20 +software + +// sohu : 2013-12-19 Sohu.com Limited +sohu + +// solar : 2013-11-07 Ruby Town, LLC +solar + +// solutions : 2013-11-07 Silver Cover, LLC +solutions + +// song : 2015-02-26 Amazon EU S.à r.l. +song + +// sony : 2015-01-08 Sony Corporation +sony + +// soy : 2014-01-23 Charleston Road Registry Inc. +soy + +// space : 2014-04-03 DotSpace Inc. +space + +// spiegel : 2014-02-05 SPIEGEL-Verlag Rudolf Augstein GmbH & Co. KG +spiegel + +// spot : 2015-02-26 Amazon EU S.à r.l. +spot + +// spreadbetting : 2014-12-11 IG Group Holdings PLC +spreadbetting + +// stada : 2014-11-13 STADA Arzneimittel AG +stada + +// star : 2015-01-08 Star India Private Limited +star + +// starhub : 2015-02-05 StarHub Limited +starhub + +// statebank : 2015-03-12 STATE BANK OF INDIA +statebank + +// statoil : 2014-12-04 Statoil ASA +statoil + +// stc : 2014-10-09 Saudi Telecom Company +stc + +// stcgroup : 2014-10-09 Saudi Telecom Company +stcgroup + +// stockholm : 2014-12-18 Stockholms kommun +stockholm + +// storage : 2014-12-22 Self Storage Company LLC +storage + +// studio : 2015-02-11 Spring Goodbye, LLC +studio + +// study : 2014-12-11 OPEN UNIVERSITIES AUSTRALIA PTY LTD +study + +// style : 2014-12-04 Binky Moon, LLC +style + +// sucks : 2014-12-22 Vox Populi Registry Inc. +sucks + +// supersport : 2015-03-05 SuperSport International Holdings Proprietary Limited +supersport + +// supplies : 2013-12-19 Atomic Fields, LLC +supplies + +// supply : 2013-12-19 Half Falls, LLC +supply + +// support : 2013-10-24 Grand Orchard, LLC +support + +// surf : 2014-01-09 Top Level Domain Holdings Limited +surf + +// surgery : 2014-03-20 Tin Avenue, LLC +surgery + +// suzuki : 2014-02-20 SUZUKI MOTOR CORPORATION +suzuki + +// swatch : 2015-01-08 The Swatch Group Ltd +swatch + +// swiss : 2014-10-16 Swiss Confederation +swiss + +// sydney : 2014-09-18 State of New South Wales, Department of Premier and Cabinet +sydney + +// symantec : 2014-12-04 Symantec Corporation +symantec + +// systems : 2013-11-07 Dash Cypress, LLC +systems + +// tab : 2014-12-04 Tabcorp Holdings Limited +tab + +// taipei : 2014-07-10 Taipei City Government +taipei + +// taobao : 2015-01-15 Alibaba Group Holding Limited +taobao + +// tatamotors : 2015-03-12 Tata Motors Ltd +tatamotors + +// tatar : 2014-04-24 Limited Liability Company \ +tatar + +// tattoo : 2013-08-30 Uniregistry, Corp. +tattoo + +// tax : 2014-03-20 Storm Orchard, LLC +tax + +// taxi : 2015-03-19 Pine Falls, LLC +taxi + +// tci : 2014-09-12 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +tci + +// team : 2015-03-05 Atomic Lake, LLC +team + +// tech : 2015-01-30 Dot Tech LLC +tech + +// technology : 2013-09-13 Auburn Falls +technology + +// telecity : 2015-02-19 TelecityGroup International Limited +telecity + +// telefonica : 2014-10-16 Telefónica S.A. +telefonica + +// temasek : 2014-08-07 Temasek Holdings (Private) Limited +temasek + +// tennis : 2014-12-04 Cotton Bloom, LLC +tennis + +// thd : 2015-04-02 Homer TLC, Inc. +thd + +// theater : 2015-03-19 Blue Tigers, LLC +theater + +// tickets : 2015-02-05 Accent Media Limited +tickets + +// tienda : 2013-11-14 Victor Manor, LLC +tienda + +// tiffany : 2015-01-30 Tiffany and Company +tiffany + +// tips : 2013-09-20 Corn Willow, LLC +tips + +// tires : 2014-11-07 Dog Edge, LLC +tires + +// tirol : 2014-04-24 punkt Tirol GmbH +tirol + +// tmall : 2015-01-15 Alibaba Group Holding Limited +tmall + +// today : 2013-09-20 Pearl Woods, LLC +today + +// tokyo : 2013-11-13 GMO Registry, Inc. +tokyo + +// tools : 2013-11-21 Pioneer North, LLC +tools + +// top : 2014-03-20 Jiangsu Bangning Science & Technology Co.,Ltd. +top + +// toray : 2014-12-18 Toray Industries, Inc. +toray + +// toshiba : 2014-04-10 TOSHIBA Corporation +toshiba + +// tours : 2015-01-22 Sugar Station, LLC +tours + +// town : 2014-03-06 Koko Moon, LLC +town + +// toys : 2014-03-06 Pioneer Orchard, LLC +toys + +// trade : 2014-01-23 Elite Registry Limited +trade + +// trading : 2014-12-11 IG Group Holdings PLC +trading + +// training : 2013-11-07 Wild Willow, LLC +training + +// travelers : 2015-03-26 Travelers TLD, LLC +travelers + +// travelersinsurance : 2015-03-26 Travelers TLD, LLC +travelersinsurance + +// trust : 2014-10-16 +trust + +// trv : 2015-03-26 Travelers TLD, LLC +trv + +// tui : 2014-07-03 TUI AG +tui + +// tunes : 2015-02-26 Amazon EU S.à r.l. +tunes + +// tushu : 2014-12-18 Amazon EU S.à r.l. +tushu + +// tvs : 2015-02-19 T V SUNDRAM IYENGAR & SONS LIMITED +tvs + +// ubs : 2014-12-11 UBS AG +ubs + +// university : 2014-03-06 Little Station, LLC +university + +// uno : 2013-09-11 Dot Latin LLC +uno + +// uol : 2014-05-01 UBN INTERNET LTDA. +uol + +// vacations : 2013-12-05 Atomic Tigers, LLC +vacations + +// vana : 2014-12-11 Lifestyle Domain Holdings, Inc. +vana + +// vegas : 2014-01-16 Dot Vegas, Inc. +vegas + +// ventures : 2013-08-27 Binky Lake, LLC +ventures + +// versicherung : 2014-03-20 dotversicherung-registry GmbH +versicherung + +// vet : 2014-03-06 +vet + +// viajes : 2013-10-17 Black Madison, LLC +viajes + +// video : 2014-10-16 +video + +// viking : 2015-04-02 Viking River Cruises (Bermuda) Ltd. +viking + +// villas : 2013-12-05 New Sky, LLC +villas + +// vip : 2015-01-22 Minds + Machines Group Limited +vip + +// virgin : 2014-09-25 Virgin Enterprises Limited +virgin + +// vision : 2013-12-05 Koko Station, LLC +vision + +// vista : 2014-09-18 Vistaprint Limited +vista + +// vistaprint : 2014-09-18 Vistaprint Limited +vistaprint + +// viva : 2014-11-07 Saudi Telecom Company +viva + +// vlaanderen : 2014-02-06 DNS.be vzw +vlaanderen + +// vodka : 2013-12-19 Top Level Domain Holdings Limited +vodka + +// vote : 2013-11-21 Monolith Registry LLC +vote + +// voting : 2013-11-13 Valuetainment Corp. +voting + +// voto : 2013-11-21 Monolith Registry LLC +voto + +// voyage : 2013-08-27 Ruby House, LLC +voyage + +// vuelos : 2015-03-05 Travel Reservations SRL +vuelos + +// wales : 2014-05-08 Nominet UK +wales + +// walter : 2014-11-13 Sandvik AB +walter + +// wang : 2013-10-24 Zodiac Leo Limited +wang + +// wanggou : 2014-12-18 Amazon EU S.à r.l. +wanggou + +// watch : 2013-11-14 Sand Shadow, LLC +watch + +// watches : 2014-12-22 Richemont DNS Inc. +watches + +// weather : 2015-01-08 The Weather Channel, LLC +weather + +// weatherchannel : 2015-03-12 The Weather Channel, LLC +weatherchannel + +// webcam : 2014-01-23 dot Webcam Limited +webcam + +// website : 2014-04-03 DotWebsite Inc. +website + +// wed : 2013-10-01 Atgron, Inc. +wed + +// wedding : 2014-04-24 Top Level Domain Holdings Limited +wedding + +// weibo : 2015-03-05 Sina Corporation +weibo + +// weir : 2015-01-29 Weir Group IP Limited +weir + +// whoswho : 2014-02-20 Who's Who Registry +whoswho + +// wien : 2013-10-28 punkt.wien GmbH +wien + +// wiki : 2013-11-07 Top Level Design, LLC +wiki + +// williamhill : 2014-03-13 William Hill Organization Limited +williamhill + +// win : 2014-11-20 First Registry Limited +win + +// windows : 2014-12-18 Microsoft Corporation +windows + +// wme : 2014-02-13 William Morris Endeavor Entertainment, LLC +wme + +// work : 2013-12-19 Top Level Domain Holdings Limited +work + +// works : 2013-11-14 Little Dynamite, LLC +works + +// world : 2014-06-12 Bitter Fields, LLC +world + +// wtc : 2013-12-19 World Trade Centers Association, Inc. +wtc + +// wtf : 2014-03-06 Hidden Way, LLC +wtf + +// xbox : 2014-12-18 Microsoft Corporation +xbox + +// xerox : 2014-10-24 Xerox DNHC LLC +xerox + +// xihuan : 2015-01-08 QIHOO 360 TECHNOLOGY CO. LTD. +xihuan + +// xin : 2014-12-11 Elegant Leader Limited +xin + +// xn--11b4c3d : 2015-01-15 VeriSign Sarl +कॉम + +// xn--1ck2e1b : 2015-02-26 Amazon EU S.à r.l. +セール + +// xn--1qqw23a : 2014-01-09 Guangzhou YU Wei Information Technology Co., Ltd. +佛山 + +// xn--30rr7y : 2014-06-12 Excellent First Limited +慈善 + +// xn--3bst00m : 2013-09-13 Eagle Horizon Limited +集团 + +// xn--3ds443g : 2013-09-08 TLD REGISTRY LIMITED +在线 + +// xn--3pxu8k : 2015-01-15 VeriSign Sarl +点看 + +// xn--42c2d9a : 2015-01-15 VeriSign Sarl +คอม + +// xn--45q11c : 2013-11-21 Zodiac Scorpio Limited +八卦 + +// xn--4gbrim : 2013-10-04 Suhub Electronic Establishment +موقع + +// xn--55qw42g : 2013-11-08 China Organizational Name Administration Center +公益 + +// xn--55qx5d : 2013-11-14 Computer Network Information Center of Chinese Academy of Sciences (China Internet Network Information Center) +公司 + +// xn--5tzm5g : 2014-12-22 Global Website TLD Asia Limited +网站 + +// xn--6frz82g : 2013-09-23 Afilias Limited +移动 + +// xn--6qq986b3xl : 2013-09-13 Tycoon Treasure Limited +我爱你 + +// xn--80adxhks : 2013-12-19 Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID) +москва + +// xn--80asehdb : 2013-07-14 CORE Association +онлайн + +// xn--80aswg : 2013-07-14 CORE Association +сайт + +// xn--8y0a063a : 2015-03-26 China United Network Communications Corporation Limited +联通 + +// xn--9dbq2a : 2015-01-15 VeriSign Sarl +קום + +// xn--9et52u : 2014-06-12 RISE VICTORY LIMITED +时尚 + +// xn--9krt00a : 2015-03-12 Sina Corporation +微博 + +// xn--b4w605ferd : 2014-08-07 Temasek Holdings (Private) Limited +淡马锡 + +// xn--bck1b9a5dre4c : 2015-02-26 Amazon EU S.à r.l. +ファッション + +// xn--c1avg : 2013-11-14 Public Interest Registry +орг + +// xn--c2br7g : 2015-01-15 VeriSign Sarl +नेट + +// xn--cck2b3b : 2015-02-26 Amazon EU S.à r.l. +ストア + +// xn--cg4bki : 2013-09-27 SAMSUNG SDS CO., LTD +삼성 + +// xn--czr694b : 2014-01-16 HU YI GLOBAL INFORMATION RESOURCES (HOLDING) COMPANY.HONGKONG LIMITED +商标 + +// xn--czrs0t : 2013-12-19 Wild Island, LLC +商店 + +// xn--czru2d : 2013-11-21 Zodiac Capricorn Limited +商城 + +// xn--d1acj3b : 2013-11-20 The Foundation for Network Initiatives “The Smart Internet” +дети + +// xn--eckvdtc9d : 2014-12-18 Amazon EU S.à r.l. +ポイント + +// xn--efvy88h : 2014-08-22 Xinhua News Agency Guangdong Branch 新华通讯社广东分社 +新闻 + +// xn--estv75g : 2015-02-19 Industrial and Commercial Bank of China Limited +工行 + +// xn--fhbei : 2015-01-15 VeriSign Sarl +كوم + +// xn--fiq228c5hs : 2013-09-08 TLD REGISTRY LIMITED +中文网 + +// xn--fiq64b : 2013-10-14 CITIC Group Corporation +中信 + +// xn--fjq720a : 2014-05-22 Will Bloom, LLC +娱乐 + +// xn--flw351e : 2014-07-31 Charleston Road Registry Inc. +谷歌 + +// xn--g2xx48c : 2015-01-30 Minds + Machines Group Limited +购物 + +// xn--gckr3f0f : 2015-02-26 Amazon EU S.à r.l. +クラウド + +// xn--hxt814e : 2014-05-15 Zodiac Libra Limited +网店 + +// xn--i1b6b1a6a2e : 2013-11-14 Public Interest Registry +संगठन + +// xn--imr513n : 2014-12-11 HU YI GLOBAL INFORMATION RESOURCES (HOLDING) COMPANY. HONGKONG LIMITED +餐厅 + +// xn--io0a7i : 2013-11-14 Computer Network Information Center of Chinese Academy of Sciences (China Internet Network Information Center) +网络 + +// xn--j1aef : 2015-01-15 VeriSign Sarl +ком + +// xn--jlq61u9w7b : 2015-01-08 Nokia Corporation +诺基亚 + +// xn--jvr189m : 2015-02-26 Amazon EU S.à r.l. +食品 + +// xn--kcrx77d1x4a : 2014-11-07 Koninklijke Philips N.V. +飞利浦 + +// xn--kpu716f : 2014-12-22 Richemont DNS Inc. +手表 + +// xn--kput3i : 2014-02-13 Beijing RITT-Net Technology Development Co., Ltd +手机 + +// xn--mgba3a3ejt : 2014-11-20 Aramco Services Company +ارامكو + +// xn--mgbab2bd : 2013-10-31 CORE Association +بازار + +// xn--mgbb9fbpob : 2014-12-18 GreenTech Consultancy Company W.L.L. +موبايلي + +// xn--mgbt3dhd : 2014-09-04 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. +همراه + +// xn--mk1bu44c : 2015-01-15 VeriSign Sarl +닷컴 + +// xn--mxtq1m : 2014-03-06 Net-Chinese Co., Ltd. +政府 + +// xn--ngbc5azd : 2013-07-13 International Domain Registry Pty. Ltd. +شبكة + +// xn--ngbe9e0a : 2014-12-04 Kuwait Finance House +بيتك + +// xn--nqv7f : 2013-11-14 Public Interest Registry +机构 + +// xn--nqv7fs00ema : 2013-11-14 Public Interest Registry +组织机构 + +// xn--nyqy26a : 2014-11-07 Stable Tone Limited +健康 + +// xn--p1acf : 2013-12-12 Rusnames Limited +рус + +// xn--pbt977c : 2014-12-22 Richemont DNS Inc. +珠宝 + +// xn--pssy2u : 2015-01-15 VeriSign Sarl +大拿 + +// xn--q9jyb4c : 2013-09-17 Charleston Road Registry Inc. +みんな + +// xn--qcka1pmc : 2014-07-31 Charleston Road Registry Inc. +グーグル + +// xn--rhqv96g : 2013-09-11 Stable Tone Limited +世界 + +// xn--rovu88b : 2015-02-26 Amazon EU S.à r.l. +書籍 + +// xn--ses554g : 2014-01-16 +网址 + +// xn--t60b56a : 2015-01-15 VeriSign Sarl +닷넷 + +// xn--tckwe : 2015-01-15 VeriSign Sarl +コム + +// xn--unup4y : 2013-07-14 Spring Fields, LLC +游戏 + +// xn--vermgensberater-ctb : 2014-06-23 Deutsche Vermögensberatung Aktiengesellschaft DVAG +vermögensberater + +// xn--vermgensberatung-pwb : 2014-06-23 Deutsche Vermögensberatung Aktiengesellschaft DVAG +vermögensberatung + +// xn--vhquv : 2013-08-27 Dash McCook, LLC +企业 + +// xn--vuq861b : 2014-10-16 Beijing Tele-info Network Technology Co., Ltd. +信息 + +// xn--xhq521b : 2013-11-14 Guangzhou YU Wei Information Technology Co., Ltd. +广东 + +// xn--zfr164b : 2013-11-08 China Organizational Name Administration Center +政务 + +// xyz : 2013-12-05 XYZ.COM LLC +xyz + +// yachts : 2014-01-09 DERYachts, LLC +yachts + +// yahoo : 2015-04-02 Yahoo! Domain Services Inc. +yahoo + +// yamaxun : 2014-12-18 Amazon EU S.à r.l. +yamaxun + +// yandex : 2014-04-10 YANDEX, LLC +yandex + +// yodobashi : 2014-11-20 YODOBASHI CAMERA CO.,LTD. +yodobashi + +// yoga : 2014-05-29 Top Level Domain Holdings Limited +yoga + +// yokohama : 2013-12-12 GMO Registry, Inc. +yokohama + +// youtube : 2014-05-01 Charleston Road Registry Inc. +youtube + +// yun : 2015-01-08 QIHOO 360 TECHNOLOGY CO. LTD. +yun + +// zara : 2014-11-07 Industria de Diseño Textil, S.A. (INDITEX, S.A.) +zara + +// zero : 2014-12-18 Amazon EU S.à r.l. +zero + +// zip : 2014-05-08 Charleston Road Registry Inc. +zip + +// zone : 2013-11-14 Outer Falls, LLC +zone + +// zuerich : 2014-11-07 Kanton Zürich (Canton of Zurich) +zuerich + + +// ===END ICANN DOMAINS=== +// ===BEGIN PRIVATE DOMAINS=== +// (Note: these are in alphabetical order by company name) + +// Amazon CloudFront : https://aws.amazon.com/cloudfront/ +// Submitted by Donavan Miller 2013-03-22 +cloudfront.net + +// Amazon Elastic Compute Cloud: https://aws.amazon.com/ec2/ +// Submitted by Osman Surkatty 2014-12-16 +ap-northeast-1.compute.amazonaws.com +ap-southeast-1.compute.amazonaws.com +ap-southeast-2.compute.amazonaws.com +cn-north-1.compute.amazonaws.cn +compute.amazonaws.cn +compute.amazonaws.com +compute-1.amazonaws.com +eu-west-1.compute.amazonaws.com +eu-central-1.compute.amazonaws.com +sa-east-1.compute.amazonaws.com +us-east-1.amazonaws.com +us-gov-west-1.compute.amazonaws.com +us-west-1.compute.amazonaws.com +us-west-2.compute.amazonaws.com +z-1.compute-1.amazonaws.com +z-2.compute-1.amazonaws.com + +// Amazon Elastic Beanstalk : https://aws.amazon.com/elasticbeanstalk/ +// Submitted by Adam Stein 2013-04-02 +elasticbeanstalk.com + +// Amazon Elastic Load Balancing : https://aws.amazon.com/elasticloadbalancing/ +// Submitted by Scott Vidmar 2013-03-27 +elb.amazonaws.com + +// Amazon S3 : https://aws.amazon.com/s3/ +// Submitted by Courtney Eckhardt 2013-03-22 +s3.amazonaws.com +s3-us-west-2.amazonaws.com +s3-us-west-1.amazonaws.com +s3-eu-west-1.amazonaws.com +s3-ap-southeast-1.amazonaws.com +s3-ap-southeast-2.amazonaws.com +s3-ap-northeast-1.amazonaws.com +s3-sa-east-1.amazonaws.com +s3-us-gov-west-1.amazonaws.com +s3-fips-us-gov-west-1.amazonaws.com +s3-website-us-east-1.amazonaws.com +s3-website-us-west-2.amazonaws.com +s3-website-us-west-1.amazonaws.com +s3-website-eu-west-1.amazonaws.com +s3-website-ap-southeast-1.amazonaws.com +s3-website-ap-southeast-2.amazonaws.com +s3-website-ap-northeast-1.amazonaws.com +s3-website-sa-east-1.amazonaws.com +s3-website-us-gov-west-1.amazonaws.com + +// BetaInABox +// Submitted by adrian@betainabox.com 2012-09-13 +betainabox.com + +// CentralNic : http://www.centralnic.com/names/domains +// Submitted by registry 2012-09-27 +ae.org +ar.com +br.com +cn.com +com.de +com.se +de.com +eu.com +gb.com +gb.net +hu.com +hu.net +jp.net +jpn.com +kr.com +mex.com +no.com +qc.com +ru.com +sa.com +se.com +se.net +uk.com +uk.net +us.com +uy.com +za.bz +za.com + +// Africa.com Web Solutions Ltd : https://registry.africa.com +// Submitted by Gavin Brown 2014-02-04 +africa.com + +// iDOT Services Limited : http://www.domain.gr.com +// Submitted by Gavin Brown 2014-02-04 +gr.com + +// Radix FZC : http://domains.in.net +// Submitted by Gavin Brown 2014-02-04 +in.net + +// US REGISTRY LLC : http://us.org +// Submitted by Gavin Brown 2014-02-04 +us.org + +// co.com Registry, LLC : https://registry.co.com +// Submitted by Gavin Brown 2014-02-04 +co.com + +// c.la : http://www.c.la/ +c.la + +// cloudControl : https://www.cloudcontrol.com/ +// Submitted by Tobias Wilken 2013-07-23 +cloudcontrolled.com +cloudcontrolapp.com + +// co.ca : http://registry.co.ca/ +co.ca + +// CoDNS B.V. +co.nl +co.no + +// Commerce Guys, SAS +// Submitted by Damien Tournoud 2015-01-22 +*.platform.sh + +// Cupcake : https://cupcake.io/ +// Submitted by Jonathan Rudenberg 2013-10-08 +cupcake.is + +// DreamHost : http://www.dreamhost.com/ +// Submitted by Andrew Farmer 2012-10-02 +dreamhosters.com + +// DynDNS.com : http://www.dyndns.com/services/dns/dyndns/ +dyndns-at-home.com +dyndns-at-work.com +dyndns-blog.com +dyndns-free.com +dyndns-home.com +dyndns-ip.com +dyndns-mail.com +dyndns-office.com +dyndns-pics.com +dyndns-remote.com +dyndns-server.com +dyndns-web.com +dyndns-wiki.com +dyndns-work.com +dyndns.biz +dyndns.info +dyndns.org +dyndns.tv +at-band-camp.net +ath.cx +barrel-of-knowledge.info +barrell-of-knowledge.info +better-than.tv +blogdns.com +blogdns.net +blogdns.org +blogsite.org +boldlygoingnowhere.org +broke-it.net +buyshouses.net +cechire.com +dnsalias.com +dnsalias.net +dnsalias.org +dnsdojo.com +dnsdojo.net +dnsdojo.org +does-it.net +doesntexist.com +doesntexist.org +dontexist.com +dontexist.net +dontexist.org +doomdns.com +doomdns.org +dvrdns.org +dyn-o-saur.com +dynalias.com +dynalias.net +dynalias.org +dynathome.net +dyndns.ws +endofinternet.net +endofinternet.org +endoftheinternet.org +est-a-la-maison.com +est-a-la-masion.com +est-le-patron.com +est-mon-blogueur.com +for-better.biz +for-more.biz +for-our.info +for-some.biz +for-the.biz +forgot.her.name +forgot.his.name +from-ak.com +from-al.com +from-ar.com +from-az.net +from-ca.com +from-co.net +from-ct.com +from-dc.com +from-de.com +from-fl.com +from-ga.com +from-hi.com +from-ia.com +from-id.com +from-il.com +from-in.com +from-ks.com +from-ky.com +from-la.net +from-ma.com +from-md.com +from-me.org +from-mi.com +from-mn.com +from-mo.com +from-ms.com +from-mt.com +from-nc.com +from-nd.com +from-ne.com +from-nh.com +from-nj.com +from-nm.com +from-nv.com +from-ny.net +from-oh.com +from-ok.com +from-or.com +from-pa.com +from-pr.com +from-ri.com +from-sc.com +from-sd.com +from-tn.com +from-tx.com +from-ut.com +from-va.com +from-vt.com +from-wa.com +from-wi.com +from-wv.com +from-wy.com +ftpaccess.cc +fuettertdasnetz.de +game-host.org +game-server.cc +getmyip.com +gets-it.net +go.dyndns.org +gotdns.com +gotdns.org +groks-the.info +groks-this.info +ham-radio-op.net +here-for-more.info +hobby-site.com +hobby-site.org +home.dyndns.org +homedns.org +homeftp.net +homeftp.org +homeip.net +homelinux.com +homelinux.net +homelinux.org +homeunix.com +homeunix.net +homeunix.org +iamallama.com +in-the-band.net +is-a-anarchist.com +is-a-blogger.com +is-a-bookkeeper.com +is-a-bruinsfan.org +is-a-bulls-fan.com +is-a-candidate.org +is-a-caterer.com +is-a-celticsfan.org +is-a-chef.com +is-a-chef.net +is-a-chef.org +is-a-conservative.com +is-a-cpa.com +is-a-cubicle-slave.com +is-a-democrat.com +is-a-designer.com +is-a-doctor.com +is-a-financialadvisor.com +is-a-geek.com +is-a-geek.net +is-a-geek.org +is-a-green.com +is-a-guru.com +is-a-hard-worker.com +is-a-hunter.com +is-a-knight.org +is-a-landscaper.com +is-a-lawyer.com +is-a-liberal.com +is-a-libertarian.com +is-a-linux-user.org +is-a-llama.com +is-a-musician.com +is-a-nascarfan.com +is-a-nurse.com +is-a-painter.com +is-a-patsfan.org +is-a-personaltrainer.com +is-a-photographer.com +is-a-player.com +is-a-republican.com +is-a-rockstar.com +is-a-socialist.com +is-a-soxfan.org +is-a-student.com +is-a-teacher.com +is-a-techie.com +is-a-therapist.com +is-an-accountant.com +is-an-actor.com +is-an-actress.com +is-an-anarchist.com +is-an-artist.com +is-an-engineer.com +is-an-entertainer.com +is-by.us +is-certified.com +is-found.org +is-gone.com +is-into-anime.com +is-into-cars.com +is-into-cartoons.com +is-into-games.com +is-leet.com +is-lost.org +is-not-certified.com +is-saved.org +is-slick.com +is-uberleet.com +is-very-bad.org +is-very-evil.org +is-very-good.org +is-very-nice.org +is-very-sweet.org +is-with-theband.com +isa-geek.com +isa-geek.net +isa-geek.org +isa-hockeynut.com +issmarterthanyou.com +isteingeek.de +istmein.de +kicks-ass.net +kicks-ass.org +knowsitall.info +land-4-sale.us +lebtimnetz.de +leitungsen.de +likes-pie.com +likescandy.com +merseine.nu +mine.nu +misconfused.org +mypets.ws +myphotos.cc +neat-url.com +office-on-the.net +on-the-web.tv +podzone.net +podzone.org +readmyblog.org +saves-the-whales.com +scrapper-site.net +scrapping.cc +selfip.biz +selfip.com +selfip.info +selfip.net +selfip.org +sells-for-less.com +sells-for-u.com +sells-it.net +sellsyourhome.org +servebbs.com +servebbs.net +servebbs.org +serveftp.net +serveftp.org +servegame.org +shacknet.nu +simple-url.com +space-to-rent.com +stuff-4-sale.org +stuff-4-sale.us +teaches-yoga.com +thruhere.net +traeumtgerade.de +webhop.biz +webhop.info +webhop.net +webhop.org +worse-than.tv +writesthisblog.com + +// Fastly Inc. http://www.fastly.com/ +// Submitted by Vladimir Vuksan 2013-05-31 +a.ssl.fastly.net +b.ssl.fastly.net +global.ssl.fastly.net +a.prod.fastly.net +global.prod.fastly.net + +// Firebase, Inc. +// Submitted by Chris Raynor 2014-01-21 +firebaseapp.com + +// Flynn : https://flynn.io +// Submitted by Jonathan Rudenberg 2014-07-12 +flynnhub.com + +// GDS : https://www.gov.uk/service-manual/operations/operating-servicegovuk-subdomains +// Submitted by David Illsley 2014-08-28 +service.gov.uk + +// GitHub, Inc. +// Submitted by Ben Toews 2014-02-06 +github.io +githubusercontent.com + +// GlobeHosting, Inc. +// Submitted by Zoltan Egresi 2013-07-12 +ro.com + +// Google, Inc. +// Submitted by Eduardo Vela 2014-12-19 +appspot.com +blogspot.ae +blogspot.be +blogspot.bj +blogspot.ca +blogspot.cf +blogspot.ch +blogspot.co.at +blogspot.co.il +blogspot.co.nz +blogspot.co.uk +blogspot.com +blogspot.com.ar +blogspot.com.au +blogspot.com.br +blogspot.com.es +blogspot.com.tr +blogspot.cv +blogspot.cz +blogspot.de +blogspot.dk +blogspot.fi +blogspot.fr +blogspot.gr +blogspot.hk +blogspot.hu +blogspot.ie +blogspot.in +blogspot.it +blogspot.jp +blogspot.kr +blogspot.mr +blogspot.mx +blogspot.nl +blogspot.no +blogspot.pt +blogspot.re +blogspot.ro +blogspot.ru +blogspot.se +blogspot.sg +blogspot.sk +blogspot.td +blogspot.tw +codespot.com +googleapis.com +googlecode.com +pagespeedmobilizer.com +withgoogle.com + +// Heroku : https://www.heroku.com/ +// Submitted by Tom Maher 2013-05-02 +herokuapp.com +herokussl.com + +// iki.fi +// Submitted by Hannu Aronsson 2009-11-05 +iki.fi + +// info.at : http://www.info.at/ +biz.at +info.at + +// Michau Enterprises Limited : http://www.co.pl/ +co.pl + +// Microsoft : http://microsoft.com +// Submitted by Barry Dorrans 2014-01-24 +azurewebsites.net +azure-mobile.net +cloudapp.net + +// NFSN, Inc. : https://www.NearlyFreeSpeech.NET/ +// Submitted by Jeff Wheelhouse 2014-02-02 +nfshost.com + +// NYC.mn : http://www.information.nyc.mn +// Submitted by Matthew Brown 2013-03-11 +nyc.mn + +// One Fold Media : http://www.onefoldmedia.com/ +// Submitted by Eddie Jones 2014-06-10 +nid.io + +// Opera Software, A.S.A. +// Submitted by Yngve Pettersen 2009-11-26 +operaunite.com + +// OutSystems +// Submitted by Duarte Santos 2014-03-11 +outsystemscloud.com + +// .pl domains (grandfathered) +art.pl +gliwice.pl +krakow.pl +poznan.pl +wroc.pl +zakopane.pl + +// priv.at : http://www.nic.priv.at/ +// Submitted by registry 2008-06-09 +priv.at + +// Red Hat, Inc. OpenShift : https://openshift.redhat.com/ +// Submitted by Tim Kramer 2012-10-24 +rhcloud.com + +// SinaAppEngine : http://sae.sina.com.cn/ +// Submitted by SinaAppEngine 2015-02-02 +sinaapp.com +vipsinaapp.com +1kapp.com + +// TASK geographical domains (www.task.gda.pl/uslugi/dns) +gda.pl +gdansk.pl +gdynia.pl +med.pl +sopot.pl + +// UDR Limited : http://www.udr.hk.com +// Submitted by registry 2014-11-07 +hk.com +hk.org +ltd.hk +inc.hk + +// Yola : https://www.yola.com/ +// Submitted by Stefano Rivera 2014-07-09 +yolasite.com + +// ZaNiC : http://www.za.net/ +// Submitted by registry 2009-10-03 +za.net +za.org + +// ===END PRIVATE DOMAINS=== diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/api_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/api_test.js new file mode 100644 index 0000000..b21326c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/api_test.js @@ -0,0 +1,372 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var async = require('async'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; +var CookieJar = tough.CookieJar; + + +var atNow = Date.now(); + +function at(offset) { + return {now: new Date(atNow + offset)}; +} + +vows + .describe('API') + .addBatch({ + "All defined": function () { + assert.ok(Cookie); + assert.ok(CookieJar); + } + }) + .addBatch({ + "Constructor": { + topic: function () { + return new Cookie({ + key: 'test', + value: 'b', + maxAge: 60 + }); + }, + 'check for key property': function (c) { + assert.ok(c); + assert.equal(c.key, 'test'); + }, + 'check for value property': function (c) { + assert.equal(c.value, 'b'); + }, + 'check for maxAge': function (c) { + assert.equal(c.maxAge, 60); + }, + 'check for default values for unspecified properties': function (c) { + assert.equal(c.expires, "Infinity"); + assert.equal(c.secure, false); + assert.equal(c.httpOnly, false); + } + } + }) + .addBatch({ + "expiry option": { + topic: function () { + var cb = this.callback; + var cj = new CookieJar(); + cj.setCookie('near=expiry; Domain=example.com; Path=/; Max-Age=1', 'http://www.example.com', at(-1), function (err, cookie) { + + cb(err, {cj: cj, cookie: cookie}); + }); + }, + "set the cookie": function (t) { + assert.ok(t.cookie, "didn't set?!"); + assert.equal(t.cookie.key, 'near'); + }, + "then, retrieving": { + topic: function (t) { + var cb = this.callback; + setTimeout(function () { + t.cj.getCookies('http://www.example.com', {http: true, expire: false}, function (err, cookies) { + t.cookies = cookies; + cb(err, t); + }); + }, 2000); + }, + "got the cookie": function (t) { + assert.lengthOf(t.cookies, 1); + assert.equal(t.cookies[0].key, 'near'); + } + } + } + }) + .addBatch({ + "allPaths option": { + topic: function () { + var cj = new CookieJar(); + var tasks = []; + tasks.push(cj.setCookie.bind(cj, 'nopath_dom=qq; Path=/; Domain=example.com', 'http://example.com', {})); + tasks.push(cj.setCookie.bind(cj, 'path_dom=qq; Path=/foo; Domain=example.com', 'http://example.com', {})); + tasks.push(cj.setCookie.bind(cj, 'nopath_host=qq; Path=/', 'http://www.example.com', {})); + tasks.push(cj.setCookie.bind(cj, 'path_host=qq; Path=/foo', 'http://www.example.com', {})); + tasks.push(cj.setCookie.bind(cj, 'other=qq; Path=/', 'http://other.example.com/', {})); + tasks.push(cj.setCookie.bind(cj, 'other2=qq; Path=/foo', 'http://other.example.com/foo', {})); + var cb = this.callback; + async.parallel(tasks, function (err, results) { + cb(err, {cj: cj, cookies: results}); + }); + }, + "all set": function (t) { + assert.equal(t.cookies.length, 6); + assert.ok(t.cookies.every(function (c) { + return !!c + })); + }, + "getting without allPaths": { + topic: function (t) { + var cb = this.callback; + var cj = t.cj; + cj.getCookies('http://www.example.com/', {}, function (err, cookies) { + cb(err, {cj: cj, cookies: cookies}); + }); + }, + "found just two cookies": function (t) { + assert.equal(t.cookies.length, 2); + }, + "all are path=/": function (t) { + assert.ok(t.cookies.every(function (c) { + return c.path === '/' + })); + }, + "no 'other' cookies": function (t) { + assert.ok(!t.cookies.some(function (c) { + return (/^other/).test(c.name) + })); + } + }, + "getting without allPaths for /foo": { + topic: function (t) { + var cb = this.callback; + var cj = t.cj; + cj.getCookies('http://www.example.com/foo', {}, function (err, cookies) { + cb(err, {cj: cj, cookies: cookies}); + }); + }, + "found four cookies": function (t) { + assert.equal(t.cookies.length, 4); + }, + "no 'other' cookies": function (t) { + assert.ok(!t.cookies.some(function (c) { + return (/^other/).test(c.name) + })); + } + }, + "getting with allPaths:true": { + topic: function (t) { + var cb = this.callback; + var cj = t.cj; + cj.getCookies('http://www.example.com/', {allPaths: true}, function (err, cookies) { + cb(err, {cj: cj, cookies: cookies}); + }); + }, + "found four cookies": function (t) { + assert.equal(t.cookies.length, 4); + }, + "no 'other' cookies": function (t) { + assert.ok(!t.cookies.some(function (c) { + return (/^other/).test(c.name) + })); + } + } + } + }) + .addBatch({ + "Remove cookies": { + topic: function () { + var jar = new CookieJar(); + var cookie = Cookie.parse("a=b; Domain=example.com; Path=/"); + var cookie2 = Cookie.parse("a=b; Domain=foo.com; Path=/"); + var cookie3 = Cookie.parse("foo=bar; Domain=foo.com; Path=/"); + jar.setCookie(cookie, 'http://example.com/index.html', function () { + }); + jar.setCookie(cookie2, 'http://foo.com/index.html', function () { + }); + jar.setCookie(cookie3, 'http://foo.com/index.html', function () { + }); + return jar; + }, + "all from matching domain": function (jar) { + jar.store.removeCookies('example.com', null, function (err) { + assert(err == null); + + jar.store.findCookies('example.com', null, function (err, cookies) { + assert(err == null); + assert(cookies != null); + assert(cookies.length === 0, 'cookie was not removed'); + }); + + jar.store.findCookies('foo.com', null, function (err, cookies) { + assert(err == null); + assert(cookies != null); + assert(cookies.length === 2, 'cookies should not have been removed'); + }); + }); + }, + "from cookie store matching domain and key": function (jar) { + jar.store.removeCookie('foo.com', '/', 'foo', function (err) { + assert(err == null); + + jar.store.findCookies('foo.com', null, function (err, cookies) { + assert(err == null); + assert(cookies != null); + assert(cookies.length === 1, 'cookie was not removed correctly'); + assert(cookies[0].key === 'a', 'wrong cookie was removed'); + }); + }); + } + } + }) + .addBatch({ + "Synchronous CookieJar": { + "setCookieSync": { + topic: function () { + var jar = new CookieJar(); + var cookie = Cookie.parse("a=b; Domain=example.com; Path=/"); + cookie = jar.setCookieSync(cookie, 'http://example.com/index.html'); + return cookie; + }, + "returns a copy of the cookie": function (cookie) { + assert.instanceOf(cookie, Cookie); + } + }, + "getCookiesSync": { + topic: function () { + var jar = new CookieJar(); + var url = 'http://example.com/index.html'; + jar.setCookieSync("a=b; Domain=example.com; Path=/", url); + jar.setCookieSync("c=d; Domain=example.com; Path=/", url); + return jar.getCookiesSync(url); + }, + "returns the cookie array": function (err, cookies) { + assert.ok(!err); + assert.ok(Array.isArray(cookies)); + assert.lengthOf(cookies, 2); + cookies.forEach(function (cookie) { + assert.instanceOf(cookie, Cookie); + }); + } + }, + + "getCookieStringSync": { + topic: function () { + var jar = new CookieJar(); + var url = 'http://example.com/index.html'; + jar.setCookieSync("a=b; Domain=example.com; Path=/", url); + jar.setCookieSync("c=d; Domain=example.com; Path=/", url); + return jar.getCookieStringSync(url); + }, + "returns the cookie header string": function (err, str) { + assert.ok(!err); + assert.typeOf(str, 'string'); + } + }, + + "getSetCookieStringsSync": { + topic: function () { + var jar = new CookieJar(); + var url = 'http://example.com/index.html'; + jar.setCookieSync("a=b; Domain=example.com; Path=/", url); + jar.setCookieSync("c=d; Domain=example.com; Path=/", url); + return jar.getSetCookieStringsSync(url); + }, + "returns the cookie header string": function (err, headers) { + assert.ok(!err); + assert.ok(Array.isArray(headers)); + assert.lengthOf(headers, 2); + headers.forEach(function (header) { + assert.typeOf(header, 'string'); + }); + } + } + } + }) + .addBatch({ + "Synchronous API on async CookieJar": { + topic: function () { + return new tough.Store(); + }, + "setCookieSync": { + topic: function (store) { + var jar = new CookieJar(store); + try { + jar.setCookieSync("a=b", 'http://example.com/index.html'); + return false; + } catch (e) { + return e; + } + }, + "fails": function (err) { + assert.instanceOf(err, Error); + assert.equal(err.message, + 'CookieJar store is not synchronous; use async API instead.'); + } + }, + "getCookiesSync": { + topic: function (store) { + var jar = new CookieJar(store); + try { + jar.getCookiesSync('http://example.com/index.html'); + return false; + } catch (e) { + return e; + } + }, + "fails": function (err) { + assert.instanceOf(err, Error); + assert.equal(err.message, + 'CookieJar store is not synchronous; use async API instead.'); + } + }, + "getCookieStringSync": { + topic: function (store) { + var jar = new CookieJar(store); + try { + jar.getCookieStringSync('http://example.com/index.html'); + return false; + } catch (e) { + return e; + } + }, + "fails": function (err) { + assert.instanceOf(err, Error); + assert.equal(err.message, + 'CookieJar store is not synchronous; use async API instead.'); + } + }, + "getSetCookieStringsSync": { + topic: function (store) { + var jar = new CookieJar(store); + try { + jar.getSetCookieStringsSync('http://example.com/index.html'); + return false; + } catch (e) { + return e; + } + }, + "fails": function (err) { + assert.instanceOf(err, Error); + assert.equal(err.message, + 'CookieJar store is not synchronous; use async API instead.'); + } + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_jar_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_jar_test.js new file mode 100644 index 0000000..689407b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_jar_test.js @@ -0,0 +1,468 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var async = require('async'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; +var CookieJar = tough.CookieJar; + +var atNow = Date.now(); + +function at(offset) { + return {now: new Date(atNow + offset)}; +} + +vows + .describe('CookieJar') + .addBatch({ + "Setting a basic cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com; Path=/"); + assert.strictEqual(c.hostOnly, null); + assert.instanceOf(c.creation, Date); + assert.strictEqual(c.lastAccessed, null); + c.creation = new Date(Date.now() - 10000); + cj.setCookie(c, 'http://example.com/index.html', this.callback); + }, + "works": function (c) { + assert.instanceOf(c, Cookie) + }, // C is for Cookie, good enough for me + "gets timestamped": function (c) { + assert.ok(c.creation); + assert.ok(Date.now() - c.creation.getTime() < 5000); // recently stamped + assert.ok(c.lastAccessed); + assert.equal(c.creation, c.lastAccessed); + assert.equal(c.TTL(), Infinity); + assert.ok(!c.isPersistent()); + } + }, + "Setting a no-path cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com"); + assert.strictEqual(c.hostOnly, null); + assert.instanceOf(c.creation, Date); + assert.strictEqual(c.lastAccessed, null); + c.creation = new Date(Date.now() - 10000); + cj.setCookie(c, 'http://example.com/index.html', this.callback); + }, + "domain": function (c) { + assert.equal(c.domain, 'example.com') + }, + "path is /": function (c) { + assert.equal(c.path, '/') + }, + "path was derived": function (c) { + assert.strictEqual(c.pathIsDefault, true) + } + }, + "Setting a cookie already marked as host-only": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com"); + assert.strictEqual(c.hostOnly, null); + assert.instanceOf(c.creation, Date); + assert.strictEqual(c.lastAccessed, null); + c.creation = new Date(Date.now() - 10000); + c.hostOnly = true; + cj.setCookie(c, 'http://example.com/index.html', this.callback); + }, + "domain": function (c) { + assert.equal(c.domain, 'example.com') + }, + "still hostOnly": function (c) { + assert.strictEqual(c.hostOnly, true) + } + }, + "Setting a session cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b"); + assert.strictEqual(c.path, null); + cj.setCookie(c, 'http://www.example.com/dir/index.html', this.callback); + }, + "works": function (c) { + assert.instanceOf(c, Cookie) + }, + "gets the domain": function (c) { + assert.equal(c.domain, 'www.example.com') + }, + "gets the default path": function (c) { + assert.equal(c.path, '/dir') + }, + "is 'hostOnly'": function (c) { + assert.ok(c.hostOnly) + } + }, + "Setting wrong domain cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=fooxample.com; Path=/"); + cj.setCookie(c, 'http://example.com/index.html', this.callback); + }, + "fails": function (err, c) { + assert.ok(err.message.match(/domain/i)); + assert.ok(!c); + } + }, + "Setting sub-domain cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=www.example.com; Path=/"); + cj.setCookie(c, 'http://example.com/index.html', this.callback); + }, + "fails": function (err, c) { + assert.ok(err.message.match(/domain/i)); + assert.ok(!c); + } + }, + "Setting super-domain cookie": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com; Path=/"); + cj.setCookie(c, 'http://www.app.example.com/index.html', this.callback); + }, + "success": function (err, c) { + assert.ok(!err); + assert.equal(c.domain, 'example.com'); + } + }, + "Setting a sub-path cookie on a super-domain": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com; Path=/subpath"); + assert.strictEqual(c.hostOnly, null); + assert.instanceOf(c.creation, Date); + assert.strictEqual(c.lastAccessed, null); + c.creation = new Date(Date.now() - 10000); + cj.setCookie(c, 'http://www.example.com/index.html', this.callback); + }, + "domain is super-domain": function (c) { + assert.equal(c.domain, 'example.com') + }, + "path is /subpath": function (c) { + assert.equal(c.path, '/subpath') + }, + "path was NOT derived": function (c) { + assert.strictEqual(c.pathIsDefault, null) + } + }, + "Setting HttpOnly cookie over non-HTTP API": { + topic: function () { + var cj = new CookieJar(); + var c = Cookie.parse("a=b; Domain=example.com; Path=/; HttpOnly"); + cj.setCookie(c, 'http://example.com/index.html', {http: false}, this.callback); + }, + "fails": function (err, c) { + assert.match(err.message, /HttpOnly/i); + assert.ok(!c); + } + } + }) + .addBatch({ + "Store eight cookies": { + topic: function () { + var cj = new CookieJar(); + var ex = 'http://example.com/index.html'; + var tasks = []; + tasks.push(function (next) { + cj.setCookie('a=1; Domain=example.com; Path=/', ex, at(0), next); + }); + tasks.push(function (next) { + cj.setCookie('b=2; Domain=example.com; Path=/; HttpOnly', ex, at(1000), next); + }); + tasks.push(function (next) { + cj.setCookie('c=3; Domain=example.com; Path=/; Secure', ex, at(2000), next); + }); + tasks.push(function (next) { // path + cj.setCookie('d=4; Domain=example.com; Path=/foo', ex, at(3000), next); + }); + tasks.push(function (next) { // host only + cj.setCookie('e=5', ex, at(4000), next); + }); + tasks.push(function (next) { // other domain + cj.setCookie('f=6; Domain=nodejs.org; Path=/', 'http://nodejs.org', at(5000), next); + }); + tasks.push(function (next) { // expired + cj.setCookie('g=7; Domain=example.com; Path=/; Expires=Tue, 18 Oct 2011 00:00:00 GMT', ex, at(6000), next); + }); + tasks.push(function (next) { // expired via Max-Age + cj.setCookie('h=8; Domain=example.com; Path=/; Max-Age=1', ex, next); + }); + var cb = this.callback; + async.parallel(tasks, function (err, results) { + setTimeout(function () { + cb(err, cj, results); + }, 2000); // so that 'h=8' expires + }); + }, + "setup ok": function (err, cj, results) { + assert.ok(!err); + assert.ok(cj); + assert.ok(results); + }, + "then retrieving for http://nodejs.org": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://nodejs.org', this.callback); + }, + "get a nodejs cookie": function (cookies) { + assert.lengthOf(cookies, 1); + var cookie = cookies[0]; + assert.equal(cookie.domain, 'nodejs.org'); + } + }, + "then retrieving for https://example.com": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('https://example.com', {secure: true}, this.callback); + }, + "get a secure example cookie with others": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['a', 'b', 'c', 'e']); + } + }, + "then retrieving for https://example.com (missing options)": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('https://example.com', this.callback); + }, + "get a secure example cookie with others": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['a', 'b', 'c', 'e']); + } + }, + "then retrieving for http://example.com": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://example.com', this.callback); + }, + "get a bunch of cookies": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['a', 'b', 'e']); + } + }, + "then retrieving for http://EXAMPlE.com": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://EXAMPlE.com', this.callback); + }, + "get a bunch of cookies": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['a', 'b', 'e']); + } + }, + "then retrieving for http://example.com, non-HTTP": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://example.com', {http: false}, this.callback); + }, + "get a bunch of cookies": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['a', 'e']); + } + }, + "then retrieving for http://example.com/foo/bar": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://example.com/foo/bar', this.callback); + }, + "get a bunch of cookies": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['d', 'a', 'b', 'e']); + } + }, + "then retrieving for http://example.com as a string": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookieString('http://example.com', this.callback); + }, + "get a single string": function (cookieHeader) { + assert.equal(cookieHeader, "a=1; b=2; e=5"); + } + }, + "then retrieving for http://example.com as a set-cookie header": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getSetCookieStrings('http://example.com', this.callback); + }, + "get a single string": function (cookieHeaders) { + assert.lengthOf(cookieHeaders, 3); + assert.equal(cookieHeaders[0], "a=1; Domain=example.com; Path=/"); + assert.equal(cookieHeaders[1], "b=2; Domain=example.com; Path=/; HttpOnly"); + assert.equal(cookieHeaders[2], "e=5; Path=/"); + } + }, + "then retrieving for http://www.example.com/": { + topic: function (cj, oldResults) { + assert.ok(oldResults); + cj.getCookies('http://www.example.com/foo/bar', this.callback); + }, + "get a bunch of cookies": function (cookies) { + var names = cookies.map(function (c) { + return c.key + }); + assert.deepEqual(names, ['d', 'a', 'b']); // note lack of 'e' + } + } + } + }) + .addBatch({ + "Repeated names": { + topic: function () { + var cb = this.callback; + var cj = new CookieJar(); + var ex = 'http://www.example.com/'; + var sc = cj.setCookie; + var tasks = []; + var now = Date.now(); + tasks.push(sc.bind(cj, 'aaaa=xxxx', ex, at(0))); + tasks.push(sc.bind(cj, 'aaaa=1111; Domain=www.example.com', ex, at(1000))); + tasks.push(sc.bind(cj, 'aaaa=2222; Domain=example.com', ex, at(2000))); + tasks.push(sc.bind(cj, 'aaaa=3333; Domain=www.example.com; Path=/pathA', ex, at(3000))); + async.series(tasks, function (err, results) { + results = results.filter(function (e) { + return e !== undefined + }); + cb(err, {cj: cj, cookies: results, now: now}); + }); + }, + "all got set": function (err, t) { + assert.lengthOf(t.cookies, 4); + }, + "then getting 'em back": { + topic: function (t) { + var cj = t.cj; + cj.getCookies('http://www.example.com/pathA', this.callback); + }, + "there's just three": function (err, cookies) { + var vals = cookies.map(function (c) { + return c.value + }); + // may break with sorting; sorting should put 3333 first due to longest path: + assert.deepEqual(vals, ['3333', '1111', '2222']); + } + } + } + }) + .addBatch({ + "CookieJar setCookie errors": { + "public-suffix domain": { + topic: function () { + var cj = new CookieJar(); + cj.setCookie('i=9; Domain=kyoto.jp; Path=/', 'kyoto.jp', this.callback); + }, + "errors": function (err, cookie) { + assert.ok(err); + assert.ok(!cookie); + assert.match(err.message, /public suffix/i); + } + }, + "wrong domain": { + topic: function () { + var cj = new CookieJar(); + cj.setCookie('j=10; Domain=google.com; Path=/', 'http://google.ca', this.callback); + }, + "errors": function (err, cookie) { + assert.ok(err); + assert.ok(!cookie); + assert.match(err.message, /not in this host's domain/i); + } + }, + "old cookie is HttpOnly": { + topic: function () { + var cb = this.callback; + var next = function (err, c) { + c = null; + return cb(err, cj); + }; + var cj = new CookieJar(); + cj.setCookie('k=11; Domain=example.ca; Path=/; HttpOnly', 'http://example.ca', {http: true}, next); + }, + "initial cookie is set": function (err, cj) { + assert.ok(!err); + assert.ok(cj); + }, + "but when trying to overwrite": { + topic: function (cj) { + var cb = this.callback; + var next = function (err, c) { + c = null; + cb(null, err); + }; + cj.setCookie('k=12; Domain=example.ca; Path=/', 'http://example.ca', {http: false}, next); + }, + "it's an error": function (err) { + assert.ok(err); + }, + "then, checking the original": { + topic: function (ignored, cj) { + assert.ok(cj instanceof CookieJar); + cj.getCookies('http://example.ca', {http: true}, this.callback); + }, + "cookie has original value": function (err, cookies) { + assert.equal(err, null); + assert.lengthOf(cookies, 1); + assert.equal(cookies[0].value, 11); + } + } + } + }, + "similar to public suffix": { + topic: function () { + var cj = new CookieJar(); + var url = 'http://www.foonet.net'; + assert.isTrue(cj.rejectPublicSuffixes); + cj.setCookie('l=13; Domain=foonet.net; Path=/', url, this.callback); + }, + "doesn't error": function (err, cookie) { + assert.ok(!err); + assert.ok(cookie); + } + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_sorting_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_sorting_test.js new file mode 100644 index 0000000..8cc9842 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_sorting_test.js @@ -0,0 +1,90 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +function toKeyArray(cookies) { + return cookies.map(function (c) { + return c.key + }); +} + +vows + .describe('Cookie sorting') + .addBatch({ + "Cookie Sorting": { + topic: function () { + var cookies = []; + cookies.push(Cookie.parse("a=0; Domain=example.com")); + cookies.push(Cookie.parse("b=1; Domain=www.example.com")); + cookies.push(Cookie.parse("c=2; Domain=example.com; Path=/pathA")); + cookies.push(Cookie.parse("d=3; Domain=www.example.com; Path=/pathA")); + cookies.push(Cookie.parse("e=4; Domain=example.com; Path=/pathA/pathB")); + cookies.push(Cookie.parse("f=5; Domain=www.example.com; Path=/pathA/pathB")); + + // weak shuffle: + cookies = cookies.sort(function () { + return Math.random() - 0.5 + }); + + cookies = cookies.sort(tough.cookieCompare); + return cookies; + }, + "got": function (cookies) { + assert.lengthOf(cookies, 6); + assert.deepEqual(toKeyArray(cookies), ['e', 'f', 'c', 'd', 'a', 'b']); + } + } + }) + .addBatch({ + "Changing creation date affects sorting": { + topic: function () { + var cookies = []; + var now = Date.now(); + cookies.push(Cookie.parse("a=0;")); + cookies.push(Cookie.parse("b=1;")); + cookies.push(Cookie.parse("c=2;")); + + cookies.forEach(function (cookie, idx) { + cookie.creation = new Date(now - 100 * idx); + }); + + return cookies.sort(tough.cookieCompare); + }, + "got": function (cookies) { + assert.deepEqual(toKeyArray(cookies), ['c', 'b', 'a']); + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_json_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_json_test.js new file mode 100644 index 0000000..cc3f1fc --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_json_test.js @@ -0,0 +1,164 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +vows + .describe('Cookie.toJSON()') + .addBatch({ + "JSON": { + "serialization": { + topic: function() { + var c = Cookie.parse('alpha=beta; Domain=example.com; Path=/foo; Expires=Tue, 19 Jan 2038 03:14:07 GMT; HttpOnly'); + return JSON.stringify(c); + }, + "gives a string": function(str) { + assert.equal(typeof str, "string"); + }, + "date is in ISO format": function(str) { + assert.match(str, /"expires":"2038-01-19T03:14:07\.000Z"/, 'expires is in ISO format'); + } + }, + "deserialization": { + topic: function() { + var json = '{"key":"alpha","value":"beta","domain":"example.com","path":"/foo","expires":"2038-01-19T03:14:07.000Z","httpOnly":true,"lastAccessed":2000000000123}'; + return Cookie.fromJSON(json); + }, + "works": function(c) { + assert.ok(c); + }, + "key": function(c) { assert.equal(c.key, "alpha") }, + "value": function(c) { assert.equal(c.value, "beta") }, + "domain": function(c) { assert.equal(c.domain, "example.com") }, + "path": function(c) { assert.equal(c.path, "/foo") }, + "httpOnly": function(c) { assert.strictEqual(c.httpOnly, true) }, + "secure": function(c) { assert.strictEqual(c.secure, false) }, + "hostOnly": function(c) { assert.strictEqual(c.hostOnly, null) }, + "expires is a date object": function(c) { + assert.equal(c.expires.getTime(), 2147483647000); + }, + "lastAccessed is a date object": function(c) { + assert.equal(c.lastAccessed.getTime(), 2000000000123); + }, + "creation defaulted": function(c) { + assert.ok(c.creation.getTime()); + } + }, + "null deserialization": { + topic: function() { + return Cookie.fromJSON(null); + }, + "is null": function(cookie) { + assert.equal(cookie,null); + } + } + }, + "expiry deserialization": { + "Infinity": { + topic: Cookie.fromJSON.bind(null, '{"expires":"Infinity"}'), + "is infinite": function(c) { + assert.strictEqual(c.expires, "Infinity"); + assert.equal(c.expires, Infinity); + } + } + }, + "maxAge serialization": { + topic: function() { + return function(toSet) { + var c = new Cookie(); + c.key = 'foo'; c.value = 'bar'; + c.setMaxAge(toSet); + return JSON.stringify(c); + }; + }, + "zero": { + topic: function(f) { return f(0) }, + "looks good": function(str) { + assert.match(str, /"maxAge":0/); + } + }, + "Infinity": { + topic: function(f) { return f(Infinity) }, + "looks good": function(str) { + assert.match(str, /"maxAge":"Infinity"/); + } + }, + "-Infinity": { + topic: function(f) { return f(-Infinity) }, + "looks good": function(str) { + assert.match(str, /"maxAge":"-Infinity"/); + } + }, + "null": { + topic: function(f) { return f(null) }, + "looks good": function(str) { + assert.match(str, /"maxAge":null/); + } + } + }, + "maxAge deserialization": { + "number": { + topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":123}'), + "is the number": function(c) { + assert.strictEqual(c.maxAge, 123); + } + }, + "null": { + topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":null}'), + "is null": function(c) { + assert.strictEqual(c.maxAge, null); + } + }, + "less than zero": { + topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":-123}'), + "is -123": function(c) { + assert.strictEqual(c.maxAge, -123); + } + }, + "Infinity": { + topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":"Infinity"}'), + "is inf-as-string": function(c) { + assert.strictEqual(c.maxAge, "Infinity"); + } + }, + "-Infinity": { + topic: Cookie.fromJSON.bind(null,'{"key":"foo","value":"bar","maxAge":"-Infinity"}'), + "is inf-as-string": function(c) { + assert.strictEqual(c.maxAge, "-Infinity"); + } + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_string_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_string_test.js new file mode 100644 index 0000000..b7ad10d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/cookie_to_string_test.js @@ -0,0 +1,162 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +vows + .describe('Cookie.toString()') + .addBatch({ + "a simple cookie": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + return c; + }, + "validates": function (c) { + assert.ok(c.validate()); + }, + "to string": function (c) { + assert.equal(c.toString(), 'a=b'); + } + }, + "a cookie with spaces in the value": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'beta gamma'; + return c; + }, + "doesn't validate": function (c) { + assert.ok(!c.validate()); + }, + "'garbage in, garbage out'": function (c) { + assert.equal(c.toString(), 'a=beta gamma'); + } + }, + "with an empty value and HttpOnly": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.httpOnly = true; + return c; + }, + "to string": function (c) { + assert.equal(c.toString(), 'a=; HttpOnly'); + } + }, + "with an expiry": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.setExpires("Oct 18 2011 07:05:03 GMT"); + return c; + }, + "validates": function (c) { + assert.ok(c.validate()); + }, + "to string": function (c) { + assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT'); + }, + "to short string": function (c) { + assert.equal(c.cookieString(), 'a=b'); + } + }, + "with a max-age": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.setExpires("Oct 18 2011 07:05:03 GMT"); + c.maxAge = 12345; + return c; + }, + "validates": function (c) { + assert.ok(c.validate()); // mabe this one *shouldn't*? + }, + "to string": function (c) { + assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Max-Age=12345'); + } + }, + "with a bunch of things": function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.setExpires("Oct 18 2011 07:05:03 GMT"); + c.maxAge = 12345; + c.domain = 'example.com'; + c.path = '/foo'; + c.secure = true; + c.httpOnly = true; + c.extensions = ['MyExtension']; + assert.equal(c.toString(), 'a=b; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Max-Age=12345; Domain=example.com; Path=/foo; Secure; HttpOnly; MyExtension'); + }, + "a host-only cookie": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.hostOnly = true; + c.domain = 'shouldnt-stringify.example.com'; + c.path = '/should-stringify'; + return c; + }, + "validates": function (c) { + assert.ok(c.validate()); + }, + "to string": function (c) { + assert.equal(c.toString(), 'a=b; Path=/should-stringify'); + } + }, + "minutes are '10'": { + topic: function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.expires = new Date(1284113410000); + return c; + }, + "validates": function (c) { + assert.ok(c.validate()); + }, + "to string": function (c) { + var str = c.toString(); + assert.notEqual(str, 'a=b; Expires=Fri, 010 Sep 2010 010:010:010 GMT'); + assert.equal(str, 'a=b; Expires=Fri, 10 Sep 2010 10:10:10 GMT'); + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/date_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/date_test.js new file mode 100644 index 0000000..afd989c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/date_test.js @@ -0,0 +1,79 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); + +function dateVows(table) { + var theVows = {}; + Object.keys(table).forEach(function (date) { + var expect = table[date]; + theVows[date] = function () { + var got = tough.parseDate(date) ? 'valid' : 'invalid'; + assert.equal(got, expect ? 'valid' : 'invalid'); + }; + }); + return {"date parsing": theVows}; +} + +vows + .describe('Date') + .addBatch(dateVows({ + "Wed, 09 Jun 2021 10:18:14 GMT": true, + "Wed, 09 Jun 2021 22:18:14 GMT": true, + "Tue, 18 Oct 2011 07:42:42.123 GMT": true, + "18 Oct 2011 07:42:42 GMT": true, + "8 Oct 2011 7:42:42 GMT": true, + "8 Oct 2011 7:2:42 GMT": true, + "Oct 18 2011 07:42:42 GMT": true, + "Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)": true, + "09 Jun 2021 10:18:14 GMT": true, + "99 Jix 3038 48:86:72 ZMT": false, + '01 Jan 1970 00:00:00 GMT': true, + '01 Jan 1600 00:00:00 GMT': false, // before 1601 + '01 Jan 1601 00:00:00 GMT': true, + '10 Feb 81 13:00:00 GMT': true, // implicit year + 'Thu, 17-Apr-2014 02:12:29 GMT': true, // dashes + 'Thu, 17-Apr-2014 02:12:29 UTC': true // dashes and UTC + })) + .addBatch({ + "strict date parse of Thu, 01 Jan 1970 00:00:010 GMT": { + topic: function () { + return tough.parseDate('Thu, 01 Jan 1970 00:00:010 GMT', true) ? true : false; + }, + "invalid": function (date) { + assert.equal(date, false); + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/domain_and_path_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/domain_and_path_test.js new file mode 100644 index 0000000..36b85b9 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/domain_and_path_test.js @@ -0,0 +1,201 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +function matchVows(func, table) { + var theVows = {}; + table.forEach(function (item) { + var str = item[0]; + var dom = item[1]; + var expect = item[2]; + var label = str + (expect ? " matches " : " doesn't match ") + dom; + theVows[label] = function () { + assert.equal(func(str, dom), expect); + }; + }); + return theVows; +} + +function defaultPathVows(table) { + var theVows = {}; + table.forEach(function (item) { + var str = item[0]; + var expect = item[1]; + var label = str + " gives " + expect; + theVows[label] = function () { + assert.equal(tough.defaultPath(str), expect); + }; + }); + return theVows; +} + +vows + .describe('Domain and Path') + .addBatch({ + "domain normalization": { + "simple": function () { + var c = new Cookie(); + c.domain = "EXAMPLE.com"; + assert.equal(c.canonicalizedDomain(), "example.com"); + }, + "extra dots": function () { + var c = new Cookie(); + c.domain = ".EXAMPLE.com"; + assert.equal(c.cdomain(), "example.com"); + }, + "weird trailing dot": function () { + var c = new Cookie(); + c.domain = "EXAMPLE.ca."; + assert.equal(c.canonicalizedDomain(), "example.ca."); + }, + "weird internal dots": function () { + var c = new Cookie(); + c.domain = "EXAMPLE...ca."; + assert.equal(c.canonicalizedDomain(), "example...ca."); + }, + "IDN": function () { + var c = new Cookie(); + c.domain = "δοκιμή.δοκιμή"; // "test.test" in greek + assert.equal(c.canonicalizedDomain(), "xn--jxalpdlp.xn--jxalpdlp"); + } + } + }) + .addBatch({ + "Domain Match": matchVows(tough.domainMatch, [ + // str, dom, expect + ["example.com", "example.com", true], + ["eXaMpLe.cOm", "ExAmPlE.CoM", true], + ["no.ca", "yes.ca", false], + ["wwwexample.com", "example.com", false], + ["www.example.com", "example.com", true], + ["example.com", "www.example.com", false], + ["www.subdom.example.com", "example.com", true], + ["www.subdom.example.com", "subdom.example.com", true], + ["example.com", "example.com.", false], // RFC6265 S4.1.2.3 + ["192.168.0.1", "168.0.1", false], // S5.1.3 "The string is a host name" + [null, "example.com", null], + ["example.com", null, null], + [null, null, null], + [undefined, undefined, null], + ]) + }) + + .addBatch({ + "default-path": defaultPathVows([ + [null, "/"], + ["/", "/"], + ["/file", "/"], + ["/dir/file", "/dir"], + ["noslash", "/"], + ]) + }) + .addBatch({ + "Path-Match": matchVows(tough.pathMatch, [ + // request, cookie, match + ["/", "/", true], + ["/dir", "/", true], + ["/", "/dir", false], + ["/dir/", "/dir/", true], + ["/dir/file", "/dir/", true], + ["/dir/file", "/dir", true], + ["/directory", "/dir", false], + ]) + }) + .addBatch({ + "permuteDomain": { + "base case": { + topic: tough.permuteDomain.bind(null, 'example.com'), + "got the domain": function (list) { + assert.deepEqual(list, ['example.com']); + } + }, + "two levels": { + topic: tough.permuteDomain.bind(null, 'foo.bar.example.com'), + "got three things": function (list) { + assert.deepEqual(list, ['example.com', 'bar.example.com', 'foo.bar.example.com']); + } + }, + "local domain": { + topic: tough.permuteDomain.bind(null, 'foo.bar.example.localduhmain'), + "got three things": function (list) { + assert.deepEqual(list, ['example.localduhmain', 'bar.example.localduhmain', 'foo.bar.example.localduhmain']); + } + } + }, + "permutePath": { + "base case": { + topic: tough.permutePath.bind(null, '/'), + "just slash": function (list) { + assert.deepEqual(list, ['/']); + } + }, + "single case": { + topic: tough.permutePath.bind(null, '/foo'), + "two things": function (list) { + assert.deepEqual(list, ['/foo', '/']); + }, + "path matching": function (list) { + list.forEach(function (e) { + assert.ok(tough.pathMatch('/foo', e)); + }); + } + }, + "double case": { + topic: tough.permutePath.bind(null, '/foo/bar'), + "four things": function (list) { + assert.deepEqual(list, ['/foo/bar', '/foo', '/']); + }, + "path matching": function (list) { + list.forEach(function (e) { + assert.ok(tough.pathMatch('/foo/bar', e)); + }); + } + }, + "trailing slash": { + topic: tough.permutePath.bind(null, '/foo/bar/'), + "three things": function (list) { + assert.deepEqual(list, ['/foo/bar', '/foo', '/']); + }, + "path matching": function (list) { + list.forEach(function (e) { + assert.ok(tough.pathMatch('/foo/bar/', e)); + }); + } + } + } + }) + .export(module); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/bsd-examples.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/bsd-examples.json new file mode 100644 index 0000000..bc43160 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/bsd-examples.json @@ -0,0 +1,168 @@ +[ + { + "test": "Sat, 15-Apr-17 21:01:22 GMT", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Thu, 19-Apr-2007 16:00:00 GMT", + "expected": "Thu, 19 Apr 2007 16:00:00 GMT" + }, { + "test": "Wed, 25 Apr 2007 21:02:13 GMT", + "expected": "Wed, 25 Apr 2007 21:02:13 GMT" + }, { + "test": "Thu, 19/Apr\\2007 16:00:00 GMT", + "expected": "Thu, 19 Apr 2007 16:00:00 GMT" + }, { + "test": "Fri, 1 Jan 2010 01:01:50 GMT", + "expected": "Fri, 01 Jan 2010 01:01:50 GMT" + }, { + "test": "Wednesday, 1-Jan-2003 00:00:00 GMT", + "expected": "Wed, 01 Jan 2003 00:00:00 GMT" + }, { + "test": ", 1-Jan-2003 00:00:00 GMT", + "expected": "Wed, 01 Jan 2003 00:00:00 GMT" + }, { + "test": " 1-Jan-2003 00:00:00 GMT", + "expected": "Wed, 01 Jan 2003 00:00:00 GMT" + }, { + "test": "1-Jan-2003 00:00:00 GMT", + "expected": "Wed, 01 Jan 2003 00:00:00 GMT" + }, { + "test": "Wed,18-Apr-07 22:50:12 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "WillyWonka , 18-Apr-07 22:50:12 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "WillyWonka , 18-Apr-07 22:50:12", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "WillyWonka , 18-apr-07 22:50:12", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Mon, 18-Apr-1977 22:50:13 GMT", + "expected": "Mon, 18 Apr 1977 22:50:13 GMT" + }, { + "test": "Mon, 18-Apr-77 22:50:13 GMT", + "expected": "Mon, 18 Apr 1977 22:50:13 GMT" + }, { + "test": "\"Sat, 15-Apr-17\\\"21:01:22\\\"GMT\"", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Partyday, 18- April-07 22:50:12", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Partyday, 18 - Apri-07 22:50:12", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Wednes, 1-Januar-2003 00:00:00 GMT", + "expected": "Wed, 01 Jan 2003 00:00:00 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 GMT-2", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 GMT BLAH", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 GMT-0400", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 DST", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 -0400", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 (hello there)", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 11:22:33", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 ::00 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 boink:z 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Sat, 15-Apr-17 91:22:33 21:01:22", + "expected": null + }, { + "test": "Thu Apr 18 22:50:12 2007 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "22:50:12 Thu Apr 18 2007 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Thu 22:50:12 Apr 18 2007 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Thu Apr 22:50:12 18 2007 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Thu Apr 18 22:50:12 2007 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Thu Apr 18 2007 22:50:12 GMT", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Thu Apr 18 2007 GMT 22:50:12", + "expected": "Wed, 18 Apr 2007 22:50:12 GMT" + }, { + "test": "Sat, 15-Apr-17 21:01:22 GMT", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15-Sat, Apr-17 21:01:22 GMT", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15-Sat, Apr 21:01:22 GMT 17", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15-Sat, Apr 21:01:22 GMT 2017", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15 Apr 21:01:22 2017", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15 17 Apr 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Apr 15 17 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "Apr 15 21:01:22 17", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "2017 April 15 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "15 April 2017 21:01:22", + "expected": "Sat, 15 Apr 2017 21:01:22 GMT" + }, { + "test": "98 April 17 21:01:22", + "expected": null + }, { + "test": "Thu, 012-Aug-2008 20:49:07 GMT", + "expected": null + }, { + "test": "Thu, 12-Aug-31841 20:49:07 GMT", + "expected": null + }, { + "test": "Thu, 12-Aug-9999999999 20:49:07 GMT", + "expected": null + }, { + "test": "Thu, 999999999999-Aug-2007 20:49:07 GMT", + "expected": null + }, { + "test": "Thu, 12-Aug-2007 20:61:99999999999 GMT", + "expected": null + }, { + "test": "IAintNoDateFool", + "expected": null + } +] diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/examples.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/examples.json new file mode 100644 index 0000000..61e674d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/dates/examples.json @@ -0,0 +1,48 @@ +[ + { + "test": "Mon, 10-Dec-2007 17:02:24 GMT", + "expected": "Mon, 10 Dec 2007 17:02:24 GMT" + }, { + "test": "Wed, 09 Dec 2009 16:27:23 GMT", + "expected": "Wed, 09 Dec 2009 16:27:23 GMT" + }, { + "test": "Thursday, 01-Jan-1970 00:00:00 GMT", + "expected": "Thu, 01 Jan 1970 00:00:00 GMT" + }, { + "test": "Mon Dec 10 16:32:30 2007 GMT", + "expected": "Mon, 10 Dec 2007 16:32:30 GMT" + }, { + "test": "Wednesday, 01-Jan-10 00:00:00 GMT", + "expected": "Fri, 01 Jan 2010 00:00:00 GMT" + }, { + "test": "Mon, 10-Dec-07 20:35:03 GMT", + "expected": "Mon, 10 Dec 2007 20:35:03 GMT" + }, { + "test": "Wed, 1 Jan 2020 00:00:00 GMT", + "expected": "Wed, 01 Jan 2020 00:00:00 GMT" + }, { + "test": "Saturday, 8-Dec-2012 21:24:09 GMT", + "expected": "Sat, 08 Dec 2012 21:24:09 GMT" + }, { + "test": "Thu, 31 Dec 23:55:55 2037 GMT", + "expected": "Thu, 31 Dec 2037 23:55:55 GMT" + }, { + "test": "Sun, 9 Dec 2012 13:42:05 GMT", + "expected": "Sun, 09 Dec 2012 13:42:05 GMT" + }, { + "test": "Wed Dec 12 2007 08:44:07 GMT-0500 (EST)", + "expected": "Wed, 12 Dec 2007 08:44:07 GMT" + }, { + "test": "Mon, 01-Jan-2011 00: 00:00 GMT", + "expected": null + }, { + "test": "Sun, 1-Jan-1995 00:00:00 GMT", + "expected": "Sun, 01 Jan 1995 00:00:00 GMT" + }, { + "test": "Wednesday, 01-Jan-10 0:0:00 GMT", + "expected": "Fri, 01 Jan 2010 00:00:00 GMT" + }, { + "test": "Thu, 10 Dec 2009 13:57:2 GMT", + "expected": "Thu, 10 Dec 2009 13:57:02 GMT" + } +] diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/parser.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/parser.json new file mode 100644 index 0000000..783f660 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_data/parser.json @@ -0,0 +1,1959 @@ +[ + { + "test": "0001", + "received": [ + "foo=bar" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0002", + "received": [ + "foo=bar; Expires=Fri, 07 Aug 2019 08:04:19 GMT" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0003", + "received": [ + "foo=bar; Expires=Fri, 07 Aug 2007 08:04:19 GMT", + "foo2=bar2; Expires=Fri, 07 Aug 2017 08:04:19 GMT" + ], + "sent": [ + { "name": "foo2", "value": "bar2" } + ] + }, + { + "test": "0004", + "received": [ + "foo" + ], + "sent": [] + }, + { + "test": "0005", + "received": [ + "foo=bar; max-age=10000;" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0006", + "received": [ + "foo=bar; max-age=0;" + ], + "sent": [] + }, + { + "test": "0007", + "received": [ + "foo=bar; version=1;" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0008", + "received": [ + "foo=bar; version=1000;" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0009", + "received": [ + "foo=bar; customvalue=1000;" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0010", + "received": [ + "foo=bar; secure;" + ], + "sent": [] + }, + { + "test": "0011", + "received": [ + "foo=bar; customvalue=\"1000 or more\";" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0012", + "received": [ + "foo=bar; customvalue=\"no trailing semicolon\"" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "0013", + "received": [ + "foo=bar", + "foo=qux" + ], + "sent": [ + { "name": "foo", "value": "qux" } + ] + }, + { + "test": "0014", + "received": [ + "foo1=bar", + "foo2=qux" + ], + "sent": [ + { "name": "foo1", "value": "bar" }, + { "name": "foo2", "value": "qux" } + ] + }, + { + "test": "0015", + "received": [ + "a=b", + "z=y" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "z", "value": "y" } + ] + }, + { + "test": "0016", + "received": [ + "z=y", + "a=b" + ], + "sent": [ + { "name": "z", "value": "y" }, + { "name": "a", "value": "b" } + ] + }, + { + "test": "0017", + "received": [ + "z=y, a=b" + ], + "sent": [ + { "name": "z", "value": "y, a=b" } + ] + }, + { + "test": "0018", + "received": [ + "z=y; foo=bar, a=b" + ], + "sent": [ + { "name": "z", "value": "y" } + ] + }, + { + "test": "0019", + "received": [ + "foo=b;max-age=3600, c=d;path=/" + ], + "sent": [ + { "name": "foo", "value": "b" } + ] + }, + { + "test": "0020", + "received": [ + "a=b", + "=", + "c=d" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "c", "value": "d" } + ] + }, + { + "test": "0021", + "received": [ + "a=b", + "=x", + "c=d" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "c", "value": "d" } + ] + }, + { + "test": "0022", + "received": [ + "a=b", + "x=", + "c=d" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "x", "value": "" }, + { "name": "c", "value": "d" } + ] + }, + { + "test": "0023", + "received": [ + "foo", + "" + ], + "sent": [] + }, + { + "test": "0024", + "received": [ + "foo", + "=" + ], + "sent": [] + }, + { + "test": "0025", + "received": [ + "foo", + "; bar" + ], + "sent": [] + }, + { + "test": "0026", + "received": [ + "foo", + " " + ], + "sent": [] + }, + { + "test": "0027", + "received": [ + "foo", + "bar" + ], + "sent": [] + }, + { + "test": "0028", + "received": [ + "foo", + "\t" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0001", + "received": [ + "foo=bar; Secure" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0002", + "received": [ + "foo=bar; seCURe" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0003", + "received": [ + "foo=bar; \"Secure\"" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0004", + "received": [ + "foo=bar; Secure=" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0005", + "received": [ + "foo=bar; Secure=aaaa" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0006", + "received": [ + "foo=bar; Secure qux" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0007", + "received": [ + "foo=bar; Secure =aaaaa" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0008", + "received": [ + "foo=bar; Secure= aaaaa" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0009", + "received": [ + "foo=bar; Secure; qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0010", + "received": [ + "foo=bar; Secure;qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0011", + "received": [ + "foo=bar; Secure ; qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0012", + "received": [ + "foo=bar; Secure" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0013", + "received": [ + "foo=bar; Secure ;" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0014", + "received": [ + "foo=bar; Path" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0015", + "received": [ + "foo=bar; Path=" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0016", + "received": [ + "foo=bar; Path=/" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0017", + "received": [ + "foo=bar; Path=/qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0018", + "received": [ + "foo=bar; Path =/qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0019", + "received": [ + "foo=bar; Path= /qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0020", + "received": [ + "foo=bar; Path=/qux ; taz" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0021", + "received": [ + "foo=bar; Path=/qux; Path=/" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0022", + "received": [ + "foo=bar; Path=/; Path=/qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0023", + "received": [ + "foo=bar; Path=/qux; Path=/cookie-parser-result" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "ATTRIBUTE0024", + "received": [ + "foo=bar; Path=/cookie-parser-result; Path=/qux" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0025", + "received": [ + "foo=bar; qux; Secure" + ], + "sent": [] + }, + { + "test": "ATTRIBUTE0026", + "received": [ + "foo=bar; qux=\"aaa;bbb\"; Secure" + ], + "sent": [] + }, + { + "test": "CHARSET0001", + "received": [ + "foo=\u6625\u8282\u56de\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c" + ], + "sent": [ + { "name": "foo", "value": "\u6625\u8282\u56de\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c" } + ] + }, + { + "test": "CHARSET0002", + "received": [ + "\u6625\u8282\u56de=\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c" + ], + "sent": [ + { "name": "\u6625\u8282\u56de", "value": "\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c" } + ] + }, + { + "test": "CHARSET0003", + "received": [ + "\u6625\u8282\u56de=\u5bb6\u8def\u00b7\u6625\u8fd0; \u5b8c\u5168\u624b\u518c" + ], + "sent": [ + { "name": "\u6625\u8282\u56de", "value": "\u5bb6\u8def\u00b7\u6625\u8fd0" } + ] + }, + { + "test": "CHARSET0004", + "received": [ + "foo=\"\u6625\u8282\u56de\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c\"" + ], + "sent": [ + { "name": "foo", "value": "\"\u6625\u8282\u56de\u5bb6\u8def\u00b7\u6625\u8fd0\u5b8c\u5168\u624b\u518c\"" } + ] + }, + { + "test": "CHROMIUM0001", + "received": [ + "a=b" + ], + "sent": [ + { "name": "a", "value": "b" } + ] + }, + { + "test": "CHROMIUM0002", + "received": [ + "aBc=\"zzz \" ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zzz \"" } + ] + }, + { + "test": "CHROMIUM0003", + "received": [ + "aBc=\"zzz \" ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zzz \"" } + ] + }, + { + "test": "CHROMIUM0004", + "received": [ + "aBc=\"zz;pp\" ; ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zz" } + ] + }, + { + "test": "CHROMIUM0005", + "received": [ + "aBc=\"zz ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zz" } + ] + }, + { + "test": "CHROMIUM0006", + "received": [ + "aBc=\"zzz \" \"ppp\" ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zzz \" \"ppp\"" } + ] + }, + { + "test": "CHROMIUM0007", + "received": [ + "aBc=\"zzz \" \"ppp\" ;" + ], + "sent": [ + { "name": "aBc", "value": "\"zzz \" \"ppp\"" } + ] + }, + { + "test": "CHROMIUM0008", + "received": [ + "aBc=A\"B ;" + ], + "sent": [ + { "name": "aBc", "value": "A\"B" } + ] + }, + { + "test": "CHROMIUM0009", + "received": [ + "BLAHHH; path=/;" + ], + "sent": [] + }, + { + "test": "CHROMIUM0010", + "received": [ + "\"BLA\\\"HHH\"; path=/;" + ], + "sent": [] + }, + { + "test": "CHROMIUM0011", + "received": [ + "a=\"B" + ], + "sent": [ + { "name": "a", "value": "\"B" } + ] + }, + { + "test": "CHROMIUM0012", + "received": [ + "=ABC" + ], + "sent": [] + }, + { + "test": "CHROMIUM0013", + "received": [ + "ABC=; path = /" + ], + "sent": [ + { "name": "ABC", "value": "" } + ] + }, + { + "test": "CHROMIUM0014", + "received": [ + " A = BC ;foo;;; bar" + ], + "sent": [ + { "name": "A", "value": "BC" } + ] + }, + { + "test": "CHROMIUM0015", + "received": [ + " A=== BC ;foo;;; bar" + ], + "sent": [ + { "name": "A", "value": "== BC" } + ] + }, + { + "test": "CHROMIUM0016", + "received": [ + "foo=\"zohNumRKgI0oxyhSsV3Z7D\" ; expires=Sun, 18-Apr-2027 21:06:29 GMT ; path=/ ; " + ], + "sent": [ + { "name": "foo", "value": "\"zohNumRKgI0oxyhSsV3Z7D\"" } + ] + }, + { + "test": "CHROMIUM0017", + "received": [ + "foo=zohNumRKgI0oxyhSsV3Z7D ; expires=Sun, 18-Apr-2027 21:06:29 GMT ; path=/ ; " + ], + "sent": [ + { "name": "foo", "value": "zohNumRKgI0oxyhSsV3Z7D" } + ] + }, + { + "test": "CHROMIUM0018", + "received": [ + " " + ], + "sent": [] + }, + { + "test": "CHROMIUM0019", + "received": [ + "a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "sent": [ + { "name": "a", "value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } + ] + }, + { + "test": "CHROMIUM0021", + "received": [ + "" + ], + "sent": [] + }, + { + "test": "COMMA0001", + "received": [ + "foo=bar, baz=qux" + ], + "sent": [ + { "name": "foo", "value": "bar, baz=qux" } + ] + }, + { + "test": "COMMA0002", + "received": [ + "foo=\"bar, baz=qux\"" + ], + "sent": [ + { "name": "foo", "value": "\"bar, baz=qux\"" } + ] + }, + { + "test": "COMMA0003", + "received": [ + "foo=bar; b,az=qux" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "COMMA0004", + "received": [ + "foo=bar; baz=q,ux" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "COMMA0005", + "received": [ + "foo=bar; Max-Age=50,399" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "COMMA0006", + "received": [ + "foo=bar; Expires=Fri, 07 Aug 2019 08:04:19 GMT" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "COMMA0007", + "received": [ + "foo=bar; Expires=Fri 07 Aug 2019 08:04:19 GMT, baz=qux" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DISABLED_CHROMIUM0020", + "received": [ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "sent": [] + }, + { + "test": "DISABLED_CHROMIUM0022", + "received": [ + "AAA=BB\u0000ZYX" + ], + "sent": [ + { "name": "AAA", "value": "BB" } + ] + }, + { + "test": "DISABLED_CHROMIUM0023", + "received": [ + "AAA=BB\rZYX" + ], + "sent": [ + { "name": "AAA", "value": "BB" } + ] + }, + { + "test": "DISABLED_PATH0029", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/bar" + ], + "sent-to": "/cookie-parser-result/f%6Fo/bar?disabled-path0029", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0001", + "received": [ + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0001", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0002", + "received": [ + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0002", + "sent": [] + }, + { + "test": "DOMAIN0003", + "received": [ + "foo=bar; domain=.home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0003", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0004", + "received": [ + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://subdomain.home.example.org:8888/cookie-parser-result?domain0004", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0005", + "received": [ + "foo=bar; domain=.home.example.org" + ], + "sent-to": "http://subdomain.home.example.org:8888/cookie-parser-result?domain0005", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0006", + "received": [ + "foo=bar; domain=.home.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0006", + "sent": [] + }, + { + "test": "DOMAIN0007", + "received": [ + "foo=bar; domain=sibling.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0007", + "sent": [] + }, + { + "test": "DOMAIN0008", + "received": [ + "foo=bar; domain=.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0008", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0009", + "received": [ + "foo=bar; domain=example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0009", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0010", + "received": [ + "foo=bar; domain=..home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0010", + "sent": [] + }, + { + "test": "DOMAIN0011", + "received": [ + "foo=bar; domain=home..example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0011", + "sent": [] + }, + { + "test": "DOMAIN0012", + "received": [ + "foo=bar; domain= .home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0012", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0013", + "received": [ + "foo=bar; domain= . home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0013", + "sent": [] + }, + { + "test": "DOMAIN0014", + "received": [ + "foo=bar; domain=home.example.org." + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0014", + "sent": [] + }, + { + "test": "DOMAIN0015", + "received": [ + "foo=bar; domain=home.example.org.." + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0015", + "sent": [] + }, + { + "test": "DOMAIN0016", + "received": [ + "foo=bar; domain=home.example.org ." + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0016", + "sent": [] + }, + { + "test": "DOMAIN0017", + "received": [ + "foo=bar; domain=.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0017", + "sent": [] + }, + { + "test": "DOMAIN0018", + "received": [ + "foo=bar; domain=.org." + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0018", + "sent": [] + }, + { + "test": "DOMAIN0019", + "received": [ + "foo=bar; domain=home.example.org", + "foo2=bar2; domain=.home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0019", + "sent": [ + { "name": "foo", "value": "bar" }, + { "name": "foo2", "value": "bar2" } + ] + }, + { + "test": "DOMAIN0020", + "received": [ + "foo2=bar2; domain=.home.example.org", + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0020", + "sent": [ + { "name": "foo2", "value": "bar2" }, + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0021", + "received": [ + "foo=bar; domain=\"home.example.org\"" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0021", + "sent": [] + }, + { + "test": "DOMAIN0022", + "received": [ + "foo=bar; domain=home.example.org", + "foo2=bar2; domain=.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0022", + "sent": [ + { "name": "foo", "value": "bar" }, + { "name": "foo2", "value": "bar2" } + ] + }, + { + "test": "DOMAIN0023", + "received": [ + "foo2=bar2; domain=.example.org", + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0023", + "sent": [ + { "name": "foo2", "value": "bar2" }, + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0024", + "received": [ + "foo=bar; domain=.example.org; domain=home.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0024", + "sent": [] + }, + { + "test": "DOMAIN0025", + "received": [ + "foo=bar; domain=home.example.org; domain=.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0025", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0026", + "received": [ + "foo=bar; domain=home.eXaMpLe.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0026", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0027", + "received": [ + "foo=bar; domain=home.example.org:8888" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0027", + "sent": [] + }, + { + "test": "DOMAIN0028", + "received": [ + "foo=bar; domain=subdomain.home.example.org" + ], + "sent-to": "http://subdomain.home.example.org:8888/cookie-parser-result?domain0028", + "sent": [] + }, + { + "test": "DOMAIN0029", + "received": [ + "foo=bar" + ], + "sent-to": "http://subdomain.home.example.org:8888/cookie-parser-result?domain0029", + "sent": [] + }, + { + "test": "DOMAIN0031", + "received": [ + "foo=bar; domain=home.example.org; domain=.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0031", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0033", + "received": [ + "foo=bar; domain=home.example.org" + ], + "sent-to": "http://hoMe.eXaMplE.org:8888/cookie-parser-result?domain0033", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0034", + "received": [ + "foo=bar; domain=home.example.org; domain=home.example.com" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0034", + "sent": [] + }, + { + "test": "DOMAIN0035", + "received": [ + "foo=bar; domain=home.example.com; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0035", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0036", + "received": [ + "foo=bar; domain=home.example.org; domain=home.example.com; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0036", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0037", + "received": [ + "foo=bar; domain=home.example.com; domain=home.example.org; domain=home.example.com" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0037", + "sent": [] + }, + { + "test": "DOMAIN0038", + "received": [ + "foo=bar; domain=home.example.org; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0038", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0039", + "received": [ + "foo=bar; domain=home.example.org; domain=example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0039", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0040", + "received": [ + "foo=bar; domain=example.org; domain=home.example.org" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?domain0040", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "DOMAIN0041", + "received": [ + "foo=bar; domain=.sibling.example.org" + ], + "sent-to": "http://sibling.example.org:8888/cookie-parser-result?domain0041", + "sent": [] + }, + { + "test": "DOMAIN0042", + "received": [ + "foo=bar; domain=.sibling.home.example.org" + ], + "sent-to": "http://sibling.home.example.org:8888/cookie-parser-result?domain0042", + "sent": [] + }, + { + "test": "MOZILLA0001", + "received": [ + "foo=bar; max-age=-1" + ], + "sent": [] + }, + { + "test": "MOZILLA0002", + "received": [ + "foo=bar; max-age=0" + ], + "sent": [] + }, + { + "test": "MOZILLA0003", + "received": [ + "foo=bar; expires=Thu, 10 Apr 1980 16:33:12 GMT" + ], + "sent": [] + }, + { + "test": "MOZILLA0004", + "received": [ + "foo=bar; max-age=60" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "MOZILLA0005", + "received": [ + "foo=bar; max-age=-20" + ], + "sent": [] + }, + { + "test": "MOZILLA0006", + "received": [ + "foo=bar; max-age=60" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "MOZILLA0007", + "received": [ + "foo=bar; expires=Thu, 10 Apr 1980 16:33:12 GMT" + ], + "sent": [] + }, + { + "test": "MOZILLA0008", + "received": [ + "foo=bar; max-age=60", + "foo1=bar; max-age=60" + ], + "sent": [ + { "name": "foo", "value": "bar" }, + { "name": "foo1", "value": "bar" } + ] + }, + { + "test": "MOZILLA0009", + "received": [ + "foo=bar; max-age=60", + "foo1=bar; max-age=60", + "foo=differentvalue; max-age=0" + ], + "sent": [ + { "name": "foo1", "value": "bar" } + ] + }, + { + "test": "MOZILLA0010", + "received": [ + "foo=bar; max-age=60", + "foo1=bar; max-age=60", + "foo=differentvalue; max-age=0", + "foo2=evendifferentvalue; max-age=0" + ], + "sent": [ + { "name": "foo1", "value": "bar" } + ] + }, + { + "test": "MOZILLA0011", + "received": [ + "test=parser; domain=.parser.test; ;; ;=; ,,, ===,abc,=; abracadabra! max-age=20;=;;" + ], + "sent": [] + }, + { + "test": "MOZILLA0012", + "received": [ + "test=\"fubar! = foo;bar\\\";\" parser; max-age=6", + "five; max-age=2.63," + ], + "sent": [ + { "name": "test", "value": "\"fubar! = foo" } + ] + }, + { + "test": "MOZILLA0013", + "received": [ + "test=kill; max-age=0", + "five; max-age=0" + ], + "sent": [] + }, + { + "test": "MOZILLA0014", + "received": [ + "six" + ], + "sent": [] + }, + { + "test": "MOZILLA0015", + "received": [ + "six", + "seven" + ], + "sent": [] + }, + { + "test": "MOZILLA0016", + "received": [ + "six", + "seven", + " =eight" + ], + "sent": [] + }, + { + "test": "MOZILLA0017", + "received": [ + "six", + "seven", + " =eight", + "test=six" + ], + "sent": [ + { "name": "test", "value": "six" } + ] + }, + { + "test": "NAME0001", + "received": [ + "a=bar" + ], + "sent": [ + { "name": "a", "value": "bar" } + ] + }, + { + "test": "NAME0002", + "received": [ + "1=bar" + ], + "sent": [ + { "name": "1", "value": "bar" } + ] + }, + { + "test": "NAME0003", + "received": [ + "$=bar" + ], + "sent": [ + { "name": "$", "value": "bar" } + ] + }, + { + "test": "NAME0004", + "received": [ + "!a=bar" + ], + "sent": [ + { "name": "!a", "value": "bar" } + ] + }, + { + "test": "NAME0005", + "received": [ + "@a=bar" + ], + "sent": [ + { "name": "@a", "value": "bar" } + ] + }, + { + "test": "NAME0006", + "received": [ + "#a=bar" + ], + "sent": [ + { "name": "#a", "value": "bar" } + ] + }, + { + "test": "NAME0007", + "received": [ + "$a=bar" + ], + "sent": [ + { "name": "$a", "value": "bar" } + ] + }, + { + "test": "NAME0008", + "received": [ + "%a=bar" + ], + "sent": [ + { "name": "%a", "value": "bar" } + ] + }, + { + "test": "NAME0009", + "received": [ + "^a=bar" + ], + "sent": [ + { "name": "^a", "value": "bar" } + ] + }, + { + "test": "NAME0010", + "received": [ + "&a=bar" + ], + "sent": [ + { "name": "&a", "value": "bar" } + ] + }, + { + "test": "NAME0011", + "received": [ + "*a=bar" + ], + "sent": [ + { "name": "*a", "value": "bar" } + ] + }, + { + "test": "NAME0012", + "received": [ + "(a=bar" + ], + "sent": [ + { "name": "(a", "value": "bar" } + ] + }, + { + "test": "NAME0013", + "received": [ + ")a=bar" + ], + "sent": [ + { "name": ")a", "value": "bar" } + ] + }, + { + "test": "NAME0014", + "received": [ + "-a=bar" + ], + "sent": [ + { "name": "-a", "value": "bar" } + ] + }, + { + "test": "NAME0015", + "received": [ + "_a=bar" + ], + "sent": [ + { "name": "_a", "value": "bar" } + ] + }, + { + "test": "NAME0016", + "received": [ + "+=bar" + ], + "sent": [ + { "name": "+", "value": "bar" } + ] + }, + { + "test": "NAME0017", + "received": [ + "=a=bar" + ], + "sent": [] + }, + { + "test": "NAME0018", + "received": [ + "a =bar" + ], + "sent": [ + { "name": "a", "value": "bar" } + ] + }, + { + "test": "NAME0019", + "received": [ + "\"a=bar" + ], + "sent": [ + { "name": "\"a", "value": "bar" } + ] + }, + { + "test": "NAME0020", + "received": [ + "\"a=b\"=bar" + ], + "sent": [ + { "name": "\"a", "value": "b\"=bar" } + ] + }, + { + "test": "NAME0021", + "received": [ + "\"a=b\"=bar", + "\"a=qux" + ], + "sent": [ + { "name": "\"a", "value": "qux" } + ] + }, + { + "test": "NAME0022", + "received": [ + " foo=bar" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "NAME0023", + "received": [ + "foo;bar=baz" + ], + "sent": [] + }, + { + "test": "NAME0024", + "received": [ + "$Version=1; foo=bar" + ], + "sent": [ + { "name": "$Version", "value": "1" } + ] + }, + { + "test": "NAME0025", + "received": [ + "===a=bar" + ], + "sent": [] + }, + { + "test": "NAME0026", + "received": [ + "foo=bar " + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "NAME0027", + "received": [ + "foo=bar ;" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "NAME0028", + "received": [ + "=a" + ], + "sent": [] + }, + { + "test": "NAME0029", + "received": [ + "=" + ], + "sent": [] + }, + { + "test": "NAME0030", + "received": [ + "foo bar=baz" + ], + "sent": [ + { "name": "foo bar", "value": "baz" } + ] + }, + { + "test": "NAME0031", + "received": [ + "\"foo;bar\"=baz" + ], + "sent": [] + }, + { + "test": "NAME0032", + "received": [ + "\"foo\\\"bar;baz\"=qux" + ], + "sent": [] + }, + { + "test": "NAME0033", + "received": [ + "=foo=bar", + "aaa" + ], + "sent": [] + }, + { + "test": "OPTIONAL_DOMAIN0030", + "received": [ + "foo=bar; domain=" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?optional-domain0030", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "OPTIONAL_DOMAIN0041", + "received": [ + "foo=bar; domain=example.org; domain=" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?optional-domain0041", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "OPTIONAL_DOMAIN0042", + "received": [ + "foo=bar; domain=foo.example.org; domain=" + ], + "sent-to": "http://home.example.org:8888/cookie-parser-result?optional-domain0042", + "sent": [] + }, + { + "test": "OPTIONAL_DOMAIN0043", + "received": [ + "foo=bar; domain=foo.example.org; domain=" + ], + "sent-to": "http://subdomain.home.example.org:8888/cookie-parser-result?optional-domain0043", + "sent": [] + }, + { + "test": "ORDERING0001", + "received": [ + "key=val0;", + "key=val1; path=/cookie-parser-result", + "key=val2; path=/", + "key=val3; path=/bar", + "key=val4; domain=.example.org", + "key=val5; domain=.example.org; path=/cookie-parser-result/foo" + ], + "sent-to": "/cookie-parser-result/foo/baz?ordering0001", + "sent": [ + { "name": "key", "value": "val5" }, + { "name": "key", "value": "val1" }, + { "name": "key", "value": "val2" }, + { "name": "key", "value": "val4" } + ] + }, + { + "test": "PATH0001", + "received": [ + "a=b; path=/", + "x=y; path=/cookie-parser-result" + ], + "sent": [ + { "name": "x", "value": "y" }, + { "name": "a", "value": "b" } + ] + }, + { + "test": "PATH0002", + "received": [ + "a=b; path=/cookie-parser-result", + "x=y; path=/" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "x", "value": "y" } + ] + }, + { + "test": "PATH0003", + "received": [ + "x=y; path=/", + "a=b; path=/cookie-parser-result" + ], + "sent": [ + { "name": "a", "value": "b" }, + { "name": "x", "value": "y" } + ] + }, + { + "test": "PATH0004", + "received": [ + "x=y; path=/cookie-parser-result", + "a=b; path=/" + ], + "sent": [ + { "name": "x", "value": "y" }, + { "name": "a", "value": "b" } + ] + }, + { + "test": "PATH0005", + "received": [ + "foo=bar; path=/cookie-parser-result/foo" + ], + "sent": [] + }, + { + "test": "PATH0006", + "received": [ + "foo=bar", + "foo=qux; path=/cookie-parser-result/foo" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0007", + "received": [ + "foo=bar; path=/cookie-parser-result/foo" + ], + "sent-to": "/cookie-parser-result/foo?path0007", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0008", + "received": [ + "foo=bar; path=/cookie-parser-result/foo" + ], + "sent-to": "/cookie-parser-result/bar?path0008", + "sent": [] + }, + { + "test": "PATH0009", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux" + ], + "sent-to": "/cookie-parser-result/foo?path0009", + "sent": [] + }, + { + "test": "PATH0010", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0010", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0011", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux" + ], + "sent-to": "/cookie-parser-result/bar/qux?path0011", + "sent": [] + }, + { + "test": "PATH0012", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux" + ], + "sent-to": "/cookie-parser-result/foo/baz?path0012", + "sent": [] + }, + { + "test": "PATH0013", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux/" + ], + "sent-to": "/cookie-parser-result/foo/baz?path0013", + "sent": [] + }, + { + "test": "PATH0014", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux/" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0014", + "sent": [] + }, + { + "test": "PATH0015", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux/" + ], + "sent-to": "/cookie-parser-result/foo/qux/?path0015", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0016", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0016", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0017", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/" + ], + "sent-to": "/cookie-parser-result/foo//qux?path0017", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0018", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/" + ], + "sent-to": "/cookie-parser-result/fooqux?path0018", + "sent": [] + }, + { + "test": "PATH0019", + "received": [ + "foo=bar; path" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0020", + "received": [ + "foo=bar; path=" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0021", + "received": [ + "foo=bar; path=/" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0022", + "received": [ + "foo=bar; path= /" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0023", + "received": [ + "foo=bar; Path=/cookie-PARSER-result" + ], + "sent": [] + }, + { + "test": "PATH0024", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux?" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0024", + "sent": [] + }, + { + "test": "PATH0025", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux#" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0025", + "sent": [] + }, + { + "test": "PATH0026", + "received": [ + "foo=bar; path=/cookie-parser-result/foo/qux;" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0026", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0027", + "received": [ + "foo=bar; path=\"/cookie-parser-result/foo/qux;\"" + ], + "sent-to": "/cookie-parser-result/foo/qux?path0027", + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0028", + "received": [ + "foo=bar; path=/cookie-parser-result/f%6Fo/bar" + ], + "sent-to": "/cookie-parser-result/foo/bar?path0028", + "sent": [] + }, + { + "test": "PATH0029", + "received": [ + "a=b; \tpath\t=\t/cookie-parser-result\t", + "x=y; \tpath\t=\t/book\t" + ], + "sent": [ + { "name": "a", "value": "b" } + ] + }, + { + "test": "PATH0030", + "received": [ + "foo=bar; path=/dog; path=" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "PATH0031", + "received": [ + "foo=bar; path=; path=/dog" + ], + "sent": [] + }, + { + "test": "PATH0032", + "received": [ + "foo=bar; path=/cookie-parser-result", + "foo=qux; path=/cookie-parser-result/" + ], + "sent-to": "/cookie-parser-result/dog?path0032", + "sent": [ + { "name": "foo", "value": "qux" }, + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "VALUE0001", + "received": [ + "foo= bar" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + }, + { + "test": "VALUE0002", + "received": [ + "foo=\"bar\"" + ], + "sent": [ + { "name": "foo", "value": "\"bar\"" } + ] + }, + { + "test": "VALUE0003", + "received": [ + "foo=\" bar \"" + ], + "sent": [ + { "name": "foo", "value": "\" bar \"" } + ] + }, + { + "test": "VALUE0004", + "received": [ + "foo=\"bar;baz\"" + ], + "sent": [ + { "name": "foo", "value": "\"bar" } + ] + }, + { + "test": "VALUE0005", + "received": [ + "foo=\"bar=baz\"" + ], + "sent": [ + { "name": "foo", "value": "\"bar=baz\"" } + ] + }, + { + "test": "VALUE0006", + "received": [ + "\tfoo\t=\tbar\t \t;\tttt" + ], + "sent": [ + { "name": "foo", "value": "bar" } + ] + } +] diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_test.js new file mode 100644 index 0000000..fac2e3e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/ietf_test.js @@ -0,0 +1,106 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var fs = require('fs'); +var path = require('path'); +var url = require('url'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; +var CookieJar = tough.CookieJar; + +function readJson(filePath) { + filePath = path.join(__dirname, filePath); + return JSON.parse(fs.readFileSync(filePath).toString()); +} + +function setGetCookieVows() { + var theVows = {}; + var data = readJson('./ietf_data/parser.json'); + + data.forEach(function (testCase) { + theVows[testCase.test] = function () { + var jar = new CookieJar(); + var expected = testCase['sent'] + var sentFrom = 'http://home.example.org/cookie-parser?' + testCase.test; + var sentTo = testCase['sent-to'] ? + url.resolve('http://home.example.org', testCase['sent-to']) : + 'http://home.example.org/cookie-parser-result?' + testCase.test; + + testCase['received'].forEach(function (cookieStr) { + jar.setCookieSync(cookieStr, sentFrom, {ignoreError: true}); + }); + + var actual = jar.getCookiesSync(sentTo); + actual = actual.sort(tough.cookieCompare); + + assert.strictEqual(actual.length, expected.length); + + actual.forEach(function (actualCookie, idx) { + var expectedCookie = expected[idx]; + assert.strictEqual(actualCookie.key, expectedCookie.name); + assert.strictEqual(actualCookie.value, expectedCookie.value); + }); + }; + }); + + return {'Set/get cookie tests': theVows}; +} + +function dateVows() { + var theVows = {}; + + [ + './ietf_data/dates/bsd-examples.json', + './ietf_data/dates/examples.json' + ].forEach(function (filePath) { + var data = readJson(filePath); + var fileName = path.basename(filePath); + + data.forEach(function (testCase) { + theVows[fileName + ' : ' + testCase.test] = function () { + var actual = tough.parseDate(testCase.test); + actual = actual ? actual.toUTCString() : null; + assert.strictEqual(actual, testCase.expected); + }; + }); + }); + + return {'Date': theVows}; +} + +vows + .describe('IETF http state tests') + .addBatch(setGetCookieVows()) + .addBatch(dateVows()) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/lifetime_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/lifetime_test.js new file mode 100644 index 0000000..e66a22b --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/lifetime_test.js @@ -0,0 +1,97 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +vows + .describe('Lifetime') + .addBatch({ + "TTL with max-age": function () { + var c = new Cookie(); + c.maxAge = 123; + assert.equal(c.TTL(), 123000); + assert.equal(c.expiryTime(new Date(9000000)), 9123000); + }, + "TTL with zero max-age": function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.maxAge = 0; // should be treated as "earliest representable" + assert.equal(c.TTL(), 0); + assert.equal(c.expiryTime(new Date(9000000)), -Infinity); + assert.ok(!c.validate()); // not valid, really: non-zero-digit *DIGIT + }, + "TTL with negative max-age": function () { + var c = new Cookie(); + c.key = 'a'; + c.value = 'b'; + c.maxAge = -1; // should be treated as "earliest representable" + assert.equal(c.TTL(), 0); + assert.equal(c.expiryTime(new Date(9000000)), -Infinity); + assert.ok(!c.validate()); // not valid, really: non-zero-digit *DIGIT + }, + "TTL with max-age and expires": function () { + var c = new Cookie(); + c.maxAge = 123; + c.expires = new Date(Date.now() + 9000); + assert.equal(c.TTL(), 123000); + assert.ok(c.isPersistent()); + }, + "TTL with expires": function () { + var c = new Cookie(); + var now = Date.now(); + c.expires = new Date(now + 9000); + assert.equal(c.TTL(now), 9000); + assert.equal(c.expiryTime(), c.expires.getTime()); + }, + "TTL with old expires": function () { + var c = new Cookie(); + c.setExpires('17 Oct 2010 00:00:00 GMT'); + assert.ok(c.TTL() < 0); + assert.ok(c.isPersistent()); + }, + "default TTL": { + topic: function () { + return new Cookie(); + }, + "is Infinite-future": function (c) { + assert.equal(c.TTL(), Infinity) + }, + "is a 'session' cookie": function (c) { + assert.ok(!c.isPersistent()) + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/parsing_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/parsing_test.js new file mode 100644 index 0000000..cb37c63 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/parsing_test.js @@ -0,0 +1,294 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; + +vows + .describe('Parsing') + .addBatch({ + "simple": { + topic: function() { + return Cookie.parse('a=bcd') || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'a') }, + "value": function(c) { assert.equal(c.value, 'bcd') }, + "no path": function(c) { assert.equal(c.path, null) }, + "no domain": function(c) { assert.equal(c.domain, null) }, + "no extensions": function(c) { assert.ok(!c.extensions) } + }, + "with expiry": { + topic: function() { + return Cookie.parse('a=bcd; Expires=Tue, 18 Oct 2011 07:05:03 GMT') || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'a') }, + "value": function(c) { assert.equal(c.value, 'bcd') }, + "has expires": function(c) { + assert.ok(c.expires !== Infinity, 'expiry is infinite when it shouldn\'t be'); + assert.equal(c.expires.getTime(), 1318921503000); + } + }, + "with expiry and path": { + topic: function() { + return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc') || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'abc') }, + "value": function(c) { assert.equal(c.value, '"xyzzy!"') }, + "has expires": function(c) { + assert.ok(c.expires !== Infinity, 'expiry is infinite when it shouldn\'t be'); + assert.equal(c.expires.getTime(), 1318921503000); + }, + "has path": function(c) { assert.equal(c.path, '/aBc'); }, + "no httponly or secure": function(c) { + assert.ok(!c.httpOnly); + assert.ok(!c.secure); + } + }, + "with everything": { + topic: function() { + return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc; Domain=example.com; Secure; HTTPOnly; Max-Age=1234; Foo=Bar; Baz') || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'abc') }, + "value": function(c) { assert.equal(c.value, '"xyzzy!"') }, + "has expires": function(c) { + assert.ok(c.expires !== Infinity, 'expiry is infinite when it shouldn\'t be'); + assert.equal(c.expires.getTime(), 1318921503000); + }, + "has path": function(c) { assert.equal(c.path, '/aBc'); }, + "has domain": function(c) { assert.equal(c.domain, 'example.com'); }, + "has httponly": function(c) { assert.equal(c.httpOnly, true); }, + "has secure": function(c) { assert.equal(c.secure, true); }, + "has max-age": function(c) { assert.equal(c.maxAge, 1234); }, + "has extensions": function(c) { + assert.ok(c.extensions); + assert.equal(c.extensions[0], 'Foo=Bar'); + assert.equal(c.extensions[1], 'Baz'); + } + }, + "invalid expires": function() { + var c = Cookie.parse("a=b; Expires=xyzzy"); + assert.ok(c); + assert.equal(c.expires, Infinity); + }, + "zero max-age": function() { + var c = Cookie.parse("a=b; Max-Age=0"); + assert.ok(c); + assert.equal(c.maxAge, 0); + }, + "negative max-age": function() { + var c = Cookie.parse("a=b; Max-Age=-1"); + assert.ok(c); + assert.equal(c.maxAge, -1); + }, + "empty domain": function() { + var c = Cookie.parse("a=b; domain="); + assert.ok(c); + assert.equal(c.domain, null); + }, + "dot domain": function() { + var c = Cookie.parse("a=b; domain=."); + assert.ok(c); + assert.equal(c.domain, null); + }, + "uppercase domain": function() { + var c = Cookie.parse("a=b; domain=EXAMPLE.COM"); + assert.ok(c); + assert.equal(c.domain, 'example.com'); + }, + "trailing dot in domain": { + topic: function() { + return Cookie.parse("a=b; Domain=example.com.", true) || null; + }, + "has the domain": function(c) { assert.equal(c.domain,"example.com.") }, + "but doesn't validate": function(c) { assert.equal(c.validate(),false) } + }, + "empty path": function() { + var c = Cookie.parse("a=b; path="); + assert.ok(c); + assert.equal(c.path, null); + }, + "no-slash path": function() { + var c = Cookie.parse("a=b; path=xyzzy"); + assert.ok(c); + assert.equal(c.path, null); + }, + "trailing semi-colons after path": { + topic: function () { + return [ + "a=b; path=/;", + "c=d;;;;" + ]; + }, + "strips semi-colons": function (t) { + var c1 = Cookie.parse(t[0]); + var c2 = Cookie.parse(t[1]); + assert.ok(c1); + assert.ok(c2); + assert.equal(c1.path, '/'); + } + }, + "secure-with-value": function() { + var c = Cookie.parse("a=b; Secure=xyzzy"); + assert.ok(c); + assert.equal(c.secure, true); + }, + "httponly-with-value": function() { + var c = Cookie.parse("a=b; HttpOnly=xyzzy"); + assert.ok(c); + assert.equal(c.httpOnly, true); + }, + "garbage": { + topic: function() { + return Cookie.parse("\x08", true) || null; + }, + "doesn't parse": function(c) { assert.equal(c,null) } + }, + "public suffix domain": { + topic: function() { + return Cookie.parse("a=b; domain=kyoto.jp", true) || null; + }, + "parses fine": function(c) { + assert.ok(c); + assert.equal(c.domain, 'kyoto.jp'); + }, + "but fails validation": function(c) { + assert.ok(c); + assert.ok(!c.validate()); + } + }, + "public suffix foonet.net": { + "top level": { + topic: function() { + return Cookie.parse("a=b; domain=foonet.net") || null; + }, + "parses and is valid": function(c) { + assert.ok(c); + assert.equal(c.domain, 'foonet.net'); + assert.ok(c.validate()); + } + }, + "www": { + topic: function() { + return Cookie.parse("a=b; domain=www.foonet.net") || null; + }, + "parses and is valid": function(c) { + assert.ok(c); + assert.equal(c.domain, 'www.foonet.net'); + assert.ok(c.validate()); + } + }, + "with a dot": { + topic: function() { + return Cookie.parse("a=b; domain=.foonet.net") || null; + }, + "parses and is valid": function(c) { + assert.ok(c); + assert.equal(c.domain, 'foonet.net'); + assert.ok(c.validate()); + } + } + }, + "Ironically, Google 'GAPS' cookie has very little whitespace": { + topic: function() { + return Cookie.parse("GAPS=1:A1aaaaAaAAa1aaAaAaaAAAaaa1a11a:aaaAaAaAa-aaaA1-;Path=/;Expires=Thu, 17-Apr-2014 02:12:29 GMT;Secure;HttpOnly"); + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'GAPS') }, + "value": function(c) { assert.equal(c.value, '1:A1aaaaAaAAa1aaAaAaaAAAaaa1a11a:aaaAaAaAa-aaaA1-') }, + "path": function(c) { + assert.notEqual(c.path, '/;Expires'); // BUG + assert.equal(c.path, '/'); + }, + "expires": function(c) { + assert.notEqual(c.expires, Infinity); + assert.equal(c.expires.getTime(), 1397700749000); + }, + "secure": function(c) { assert.ok(c.secure) }, + "httponly": function(c) { assert.ok(c.httpOnly) } + }, + "lots of equal signs": { + topic: function() { + return Cookie.parse("queryPref=b=c&d=e; Path=/f=g; Expires=Thu, 17 Apr 2014 02:12:29 GMT; HttpOnly"); + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'queryPref') }, + "value": function(c) { assert.equal(c.value, 'b=c&d=e') }, + "path": function(c) { + assert.equal(c.path, '/f=g'); + }, + "expires": function(c) { + assert.notEqual(c.expires, Infinity); + assert.equal(c.expires.getTime(), 1397700749000); + }, + "httponly": function(c) { assert.ok(c.httpOnly) } + }, + "spaces in value": { + topic: function() { + return Cookie.parse('a=one two three',false) || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'a') }, + "value": function(c) { assert.equal(c.value, 'one two three') }, + "no path": function(c) { assert.equal(c.path, null) }, + "no domain": function(c) { assert.equal(c.domain, null) }, + "no extensions": function(c) { assert.ok(!c.extensions) } + }, + "quoted spaces in value": { + topic: function() { + return Cookie.parse('a="one two three"',false) || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'a') }, + "value": function(c) { assert.equal(c.value, '"one two three"') }, + "no path": function(c) { assert.equal(c.path, null) }, + "no domain": function(c) { assert.equal(c.domain, null) }, + "no extensions": function(c) { assert.ok(!c.extensions) } + }, + "non-ASCII in value": { + topic: function() { + return Cookie.parse('farbe=weiß',false) || null; + }, + "parsed": function(c) { assert.ok(c) }, + "key": function(c) { assert.equal(c.key, 'farbe') }, + "value": function(c) { assert.equal(c.value, 'weiß') }, + "no path": function(c) { assert.equal(c.path, null) }, + "no domain": function(c) { assert.equal(c.domain, null) }, + "no extensions": function(c) { assert.ok(!c.extensions) } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/regression_test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/regression_test.js new file mode 100644 index 0000000..4edb609 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/test/regression_test.js @@ -0,0 +1,143 @@ +/*! + * Copyright (c) 2015, Salesforce.com, Inc. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of Salesforce.com nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. + */ + +'use strict'; +var vows = require('vows'); +var assert = require('assert'); +var async = require('async'); +var tough = require('../lib/cookie'); +var Cookie = tough.Cookie; +var CookieJar = tough.CookieJar; + +var atNow = Date.now(); + +function at(offset) { + return {now: new Date(atNow + offset)}; +} + +vows + .describe('Regression tests') + .addBatch({ + "Issue 1": { + topic: function () { + var cj = new CookieJar(); + cj.setCookie('hello=world; path=/some/path/', 'http://domain/some/path/file', function (err, cookie) { + this.callback(err, {cj: cj, cookie: cookie}); + }.bind(this)); + }, + "stored a cookie": function (t) { + assert.ok(t.cookie); + }, + "getting it back": { + topic: function (t) { + t.cj.getCookies('http://domain/some/path/file', function (err, cookies) { + this.callback(err, {cj: t.cj, cookies: cookies || []}); + }.bind(this)); + }, + "got one cookie": function (t) { + assert.lengthOf(t.cookies, 1); + }, + "it's the right one": function (t) { + var c = t.cookies[0]; + assert.equal(c.key, 'hello'); + assert.equal(c.value, 'world'); + } + } + } + }) + .addBatch({ + "trailing semi-colon set into cj": { + topic: function () { + var cb = this.callback; + var cj = new CookieJar(); + var ex = 'http://www.example.com'; + var tasks = []; + tasks.push(function (next) { + cj.setCookie('broken_path=testme; path=/;', ex, at(-1), next); + }); + tasks.push(function (next) { + cj.setCookie('b=2; Path=/;;;;', ex, at(-1), next); + }); + async.parallel(tasks, function (err, cookies) { + cb(null, { + cj: cj, + cookies: cookies + }); + }); + }, + "check number of cookies": function (t) { + assert.lengthOf(t.cookies, 2, "didn't set"); + }, + "check *broken_path* was set properly": function (t) { + assert.equal(t.cookies[0].key, "broken_path"); + assert.equal(t.cookies[0].value, "testme"); + assert.equal(t.cookies[0].path, "/"); + }, + "check *b* was set properly": function (t) { + assert.equal(t.cookies[1].key, "b"); + assert.equal(t.cookies[1].value, "2"); + assert.equal(t.cookies[1].path, "/"); + }, + "retrieve the cookie": { + topic: function (t) { + var cb = this.callback; + t.cj.getCookies('http://www.example.com', {}, function (err, cookies) { + t.cookies = cookies; + cb(err, t); + }); + }, + "get the cookie": function (t) { + assert.lengthOf(t.cookies, 2); + assert.equal(t.cookies[0].key, 'broken_path'); + assert.equal(t.cookies[0].value, 'testme'); + assert.equal(t.cookies[1].key, "b"); + assert.equal(t.cookies[1].value, "2"); + assert.equal(t.cookies[1].path, "/"); + } + } + } + }) + .addBatch({ + "tough-cookie throws exception on malformed URI (GH-32)": { + topic: function () { + var url = "http://www.example.com/?test=100%"; + var cj = new CookieJar(); + + cj.setCookieSync("Test=Test", url); + + return cj.getCookieStringSync(url); + }, + "cookies are set": function (cookieStr) { + assert.strictEqual(cookieStr, "Test=Test"); + } + } + }) + .export(module); diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/tough-cookie-deps.tsv b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/tough-cookie-deps.tsv new file mode 100644 index 0000000..6796773 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tough-cookie/tough-cookie-deps.tsv @@ -0,0 +1,6 @@ +async (0.1.18) MIT (http://github.com/caolan/async/raw/master/LICENSE) node_modules/async/package.json +diff (1.0.8) BSD (http://github.com/kpdecker/jsdiff/blob/master/LICENSE) node_modules/vows/node_modules/diff/package.json +eyes (0.1.8) MIT License (https://spdx.org/licenses/MIT) node_modules/vows/node_modules/eyes/package.json +punycode (1.0.0) MIT (http://mths.be/mit) node_modules/punycode/package.json +tough-cookie (0.12.1) MIT License (https://spdx.org/licenses/MIT) package.json +vows (0.7.0) MIT License (https://spdx.org/licenses/MIT) node_modules/vows/LICENSE diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/.jshintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/.jshintrc new file mode 100644 index 0000000..4c1c8d4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/.jshintrc @@ -0,0 +1,5 @@ +{ + "node": true, + "asi": true, + "laxcomma": true +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/LICENSE new file mode 100644 index 0000000..a4a9aee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/LICENSE @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and + +You must cause any modified files to carry prominent notices stating that You changed the files; and + +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/README.md new file mode 100644 index 0000000..bb533d5 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/README.md @@ -0,0 +1,4 @@ +tunnel-agent +============ + +HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/index.js new file mode 100644 index 0000000..13c0427 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/index.js @@ -0,0 +1,236 @@ +'use strict' + +var net = require('net') + , tls = require('tls') + , http = require('http') + , https = require('https') + , events = require('events') + , assert = require('assert') + , util = require('util') + ; + +exports.httpOverHttp = httpOverHttp +exports.httpsOverHttp = httpsOverHttp +exports.httpOverHttps = httpOverHttps +exports.httpsOverHttps = httpsOverHttps + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options) + agent.request = http.request + return agent +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options) + agent.request = http.request + agent.createSocket = createSecureSocket + return agent +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options) + agent.request = https.request + return agent +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options) + agent.request = https.request + agent.createSocket = createSecureSocket + return agent +} + + +function TunnelingAgent(options) { + var self = this + self.options = options || {} + self.proxyOptions = self.options.proxy || {} + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets + self.requests = [] + self.sockets = [] + + self.on('free', function onFree(socket, host, port) { + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i] + if (pending.host === host && pending.port === port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1) + pending.request.onSocket(socket) + return + } + } + socket.destroy() + self.removeSocket(socket) + }) +} +util.inherits(TunnelingAgent, events.EventEmitter) + +TunnelingAgent.prototype.addRequest = function addRequest(req, options) { + var self = this + + // Legacy API: addRequest(req, host, port, path) + if (typeof options === 'string') { + options = { + host: options, + port: arguments[2], + path: arguments[3] + }; + } + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push({host: host, port: port, request: req}) + return + } + + // If we are under maxSockets create a new one. + self.createSocket({host: options.host, port: options.port, request: req}, function(socket) { + socket.on('free', onFree) + socket.on('close', onCloseOrRemove) + socket.on('agentRemove', onCloseOrRemove) + req.onSocket(socket) + + function onFree() { + self.emit('free', socket, options.host, options.port) + } + + function onCloseOrRemove(err) { + self.removeSocket() + socket.removeListener('free', onFree) + socket.removeListener('close', onCloseOrRemove) + socket.removeListener('agentRemove', onCloseOrRemove) + } + }) +} + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this + var placeholder = {} + self.sockets.push(placeholder) + + var connectOptions = mergeOptions({}, self.proxyOptions, + { method: 'CONNECT' + , path: options.host + ':' + options.port + , agent: false + } + ) + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {} + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64') + } + + debug('making CONNECT request') + var connectReq = self.request(connectOptions) + connectReq.useChunkedEncodingByDefault = false // for v0.6 + connectReq.once('response', onResponse) // for v0.6 + connectReq.once('upgrade', onUpgrade) // for v0.6 + connectReq.once('connect', onConnect) // for v0.7 or later + connectReq.once('error', onError) + connectReq.end() + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head) + }) + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners() + socket.removeAllListeners() + + if (res.statusCode === 200) { + assert.equal(head.length, 0) + debug('tunneling connection has established') + self.sockets[self.sockets.indexOf(placeholder)] = socket + cb(socket) + } else { + debug('tunneling socket could not be established, statusCode=%d', res.statusCode) + var error = new Error('tunneling socket could not be established, ' + 'statusCode=' + res.statusCode) + error.code = 'ECONNRESET' + options.request.emit('error', error) + self.removeSocket(placeholder) + } + } + + function onError(cause) { + connectReq.removeAllListeners() + + debug('tunneling socket could not be established, cause=%s\n', cause.message, cause.stack) + var error = new Error('tunneling socket could not be established, ' + 'cause=' + cause.message) + error.code = 'ECONNRESET' + options.request.emit('error', error) + self.removeSocket(placeholder) + } +} + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) return + + this.sockets.splice(pos, 1) + + var pending = this.requests.shift() + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket) + }) + } +} + +function createSecureSocket(options, cb) { + var self = this + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, mergeOptions({}, self.options, + { servername: options.host + , socket: socket + } + )) + cb(secureSocket) + }) +} + + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i] + if (typeof overrides === 'object') { + var keys = Object.keys(overrides) + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j] + if (overrides[k] !== undefined) { + target[k] = overrides[k] + } + } + } + } + return target +} + + +var debug +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments) + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0] + } else { + args.unshift('TUNNEL:') + } + console.error.apply(console, args) + } +} else { + debug = function() {} +} +exports.debug = debug // for test diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/package.json new file mode 100644 index 0000000..d1455ee --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/node_modules/tunnel-agent/package.json @@ -0,0 +1,46 @@ +{ + "author": { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com", + "url": "http://www.futurealoof.com" + }, + "name": "tunnel-agent", + "description": "HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.", + "version": "0.4.0", + "repository": { + "url": "git+https://github.com/mikeal/tunnel-agent.git" + }, + "main": "index.js", + "dependencies": {}, + "devDependencies": {}, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "bugs": { + "url": "https://github.com/mikeal/tunnel-agent/issues" + }, + "homepage": "https://github.com/mikeal/tunnel-agent", + "_id": "tunnel-agent@0.4.0", + "dist": { + "shasum": "b1184e312ffbcf70b3b4c78e8c219de7ebb1c550", + "tarball": "http://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.0.tgz" + }, + "_from": "tunnel-agent@>=0.4.0 <0.5.0", + "_npmVersion": "1.3.21", + "_npmUser": { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + } + ], + "directories": {}, + "_shasum": "b1184e312ffbcf70b3b4c78e8c219de7ebb1c550", + "_resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.0.tgz", + "readme": "ERROR: No README data found!", + "scripts": {} +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/package.json new file mode 100644 index 0000000..c96c1eb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/package.json @@ -0,0 +1,106 @@ +{ + "name": "request", + "description": "Simplified HTTP request client.", + "tags": [ + "http", + "simple", + "util", + "utility" + ], + "version": "2.55.0", + "author": { + "name": "Mikeal Rogers", + "email": "mikeal.rogers@gmail.com" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/request/request.git" + }, + "bugs": { + "url": "http://github.com/request/request/issues" + }, + "license": "Apache-2.0", + "engines": { + "node": ">=0.8.0" + }, + "main": "index.js", + "dependencies": { + "bl": "~0.9.0", + "caseless": "~0.9.0", + "forever-agent": "~0.6.0", + "form-data": "~0.2.0", + "json-stringify-safe": "~5.0.0", + "mime-types": "~2.0.1", + "node-uuid": "~1.4.0", + "qs": "~2.4.0", + "tunnel-agent": "~0.4.0", + "tough-cookie": ">=0.12.0", + "http-signature": "~0.10.0", + "oauth-sign": "~0.6.0", + "hawk": "~2.3.0", + "aws-sign2": "~0.5.0", + "stringstream": "~0.0.4", + "combined-stream": "~0.0.5", + "isstream": "~0.1.1", + "har-validator": "^1.4.0" + }, + "scripts": { + "test": "npm run lint && node node_modules/.bin/taper tests/test-*.js && npm run test-browser", + "test-browser": "node tests/browser/start.js", + "lint": "node node_modules/.bin/eslint lib/ *.js tests/ && echo Lint passed." + }, + "devDependencies": { + "browserify": "~5.9.1", + "browserify-istanbul": "~0.1.3", + "coveralls": "~2.11.2", + "eslint": "0.17.1", + "function-bind": "~1.0.0", + "istanbul": "~0.3.2", + "karma": "~0.12.21", + "karma-browserify": "~3.0.1", + "karma-cli": "0.0.4", + "karma-coverage": "0.2.6", + "karma-phantomjs-launcher": "~0.1.4", + "karma-tap": "~1.0.1", + "rimraf": "~2.2.8", + "server-destroy": "~1.0.0", + "tape": "~3.0.0", + "taper": "~0.4.0", + "bluebird": "~2.9.21" + }, + "gitHead": "b6000376387db12d0c2d7ed9ee87b0ba123e36dc", + "homepage": "https://github.com/request/request", + "_id": "request@2.55.0", + "_shasum": "d75c1cdf679d76bb100f9bffe1fe551b5c24e93d", + "_from": "request@>=2.0.0 <3.0.0", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "simov", + "email": "simeonvelichkov@gmail.com" + }, + "maintainers": [ + { + "name": "mikeal", + "email": "mikeal.rogers@gmail.com" + }, + { + "name": "nylen", + "email": "jnylen@gmail.com" + }, + { + "name": "fredkschott", + "email": "fkschott@gmail.com" + }, + { + "name": "simov", + "email": "simeonvelichkov@gmail.com" + } + ], + "dist": { + "shasum": "d75c1cdf679d76bb100f9bffe1fe551b5c24e93d", + "tarball": "http://registry.npmjs.org/request/-/request-2.55.0.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/release.sh b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/release.sh new file mode 100755 index 0000000..7678bf8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/release.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +if [ -z "`which github-changes`" ]; then + # specify version because github-changes "is under heavy development. Things + # may break between releases" until 0.1.0 + echo "First, do: [sudo] npm install -g github-changes@0.0.14" + exit 1 +fi + +if [ -d .git/refs/remotes/upstream ]; then + remote=upstream +else + remote=origin +fi + +# Increment v2.x.y -> v2.x+1.0 +npm version minor || exit 1 + +# Generate changelog from pull requests +github-changes -o request -r request \ + --auth --verbose \ + --file CHANGELOG.md \ + --only-pulls --use-commit-body \ + --date-format '(YYYY/MM/DD)' \ + || exit 1 + +# Since the tag for the new version hasn't been pushed yet, any changes in it +# will be marked as "upcoming" +version="$(grep '"version"' package.json | cut -d'"' -f4)" +sed -i -e "s/^### upcoming/### v$version/" CHANGELOG.md + +# This may fail if no changelog updates +# TODO: would this ever actually happen? handle it better? +git add CHANGELOG.md; git commit -m 'Update changelog' + +# Publish the new version to npm +npm publish || exit 1 + +# Increment v2.x.0 -> v2.x.1 +# For rationale, see: +# https://github.com/request/oauth-sign/issues/10#issuecomment-58917018 +npm version patch || exit 1 + +# Push back to the main repo +git push $remote master --tags || exit 1 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/request.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/request.js new file mode 100644 index 0000000..5f8f268 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/request/request.js @@ -0,0 +1,1569 @@ +'use strict' + +var http = require('http') + , https = require('https') + , url = require('url') + , util = require('util') + , stream = require('stream') + , qs = require('qs') + , querystring = require('querystring') + , zlib = require('zlib') + , helpers = require('./lib/helpers') + , bl = require('bl') + , hawk = require('hawk') + , aws = require('aws-sign2') + , httpSignature = require('http-signature') + , mime = require('mime-types') + , tunnel = require('tunnel-agent') + , stringstream = require('stringstream') + , caseless = require('caseless') + , ForeverAgent = require('forever-agent') + , FormData = require('form-data') + , cookies = require('./lib/cookies') + , copy = require('./lib/copy') + , getProxyFromURI = require('./lib/getProxyFromURI') + , Har = require('./lib/har').Har + , Auth = require('./lib/auth').Auth + , OAuth = require('./lib/oauth').OAuth + , Multipart = require('./lib/multipart').Multipart + , Redirect = require('./lib/redirect').Redirect + +var safeStringify = helpers.safeStringify + , isReadStream = helpers.isReadStream + , toBase64 = helpers.toBase64 + , defer = helpers.defer + , globalCookieJar = cookies.jar() + + +var globalPool = {} + +var defaultProxyHeaderWhiteList = [ + 'accept', + 'accept-charset', + 'accept-encoding', + 'accept-language', + 'accept-ranges', + 'cache-control', + 'content-encoding', + 'content-language', + 'content-length', + 'content-location', + 'content-md5', + 'content-range', + 'content-type', + 'connection', + 'date', + 'expect', + 'max-forwards', + 'pragma', + 'referer', + 'te', + 'transfer-encoding', + 'user-agent', + 'via' +] + +var defaultProxyHeaderExclusiveList = [ + 'proxy-authorization' +] + +function filterForNonReserved(reserved, options) { + // Filter out properties that are not reserved. + // Reserved values are passed in at call site. + + var object = {} + for (var i in options) { + var notReserved = (reserved.indexOf(i) === -1) + if (notReserved) { + object[i] = options[i] + } + } + return object +} + +function filterOutReservedFunctions(reserved, options) { + // Filter out properties that are functions and are reserved. + // Reserved values are passed in at call site. + + var object = {} + for (var i in options) { + var isReserved = !(reserved.indexOf(i) === -1) + var isFunction = (typeof options[i] === 'function') + if (!(isReserved && isFunction)) { + object[i] = options[i] + } + } + return object + +} + +function constructProxyHost(uriObject) { + var port = uriObject.portA + , protocol = uriObject.protocol + , proxyHost = uriObject.hostname + ':' + + if (port) { + proxyHost += port + } else if (protocol === 'https:') { + proxyHost += '443' + } else { + proxyHost += '80' + } + + return proxyHost +} + +function constructProxyHeaderWhiteList(headers, proxyHeaderWhiteList) { + var whiteList = proxyHeaderWhiteList + .reduce(function (set, header) { + set[header.toLowerCase()] = true + return set + }, {}) + + return Object.keys(headers) + .filter(function (header) { + return whiteList[header.toLowerCase()] + }) + .reduce(function (set, header) { + set[header] = headers[header] + return set + }, {}) +} + +function getTunnelOption(self, options) { + // Tunnel HTTPS by default, or if a previous request in the redirect chain + // was tunneled. Allow the user to override this setting. + + // If self.tunnel is already set (because this is a redirect), use the + // existing value. + if (typeof self.tunnel !== 'undefined') { + return self.tunnel + } + + // If options.tunnel is set (the user specified a value), use it. + if (typeof options.tunnel !== 'undefined') { + return options.tunnel + } + + // If the destination is HTTPS, tunnel. + if (self.uri.protocol === 'https:') { + return true + } + + // Otherwise, leave tunnel unset, because if a later request in the redirect + // chain is HTTPS then that request (and any subsequent ones) should be + // tunneled. + return undefined +} + +function constructTunnelOptions(request) { + var proxy = request.proxy + + var tunnelOptions = { + proxy : { + host : proxy.hostname, + port : +proxy.port, + proxyAuth : proxy.auth, + headers : request.proxyHeaders + }, + headers : request.headers, + ca : request.ca, + cert : request.cert, + key : request.key, + passphrase : request.passphrase, + pfx : request.pfx, + ciphers : request.ciphers, + rejectUnauthorized : request.rejectUnauthorized, + secureOptions : request.secureOptions, + secureProtocol : request.secureProtocol + } + + return tunnelOptions +} + +function constructTunnelFnName(uri, proxy) { + var uriProtocol = (uri.protocol === 'https:' ? 'https' : 'http') + var proxyProtocol = (proxy.protocol === 'https:' ? 'Https' : 'Http') + return [uriProtocol, proxyProtocol].join('Over') +} + +function getTunnelFn(request) { + var uri = request.uri + var proxy = request.proxy + var tunnelFnName = constructTunnelFnName(uri, proxy) + return tunnel[tunnelFnName] +} + +// Function for properly handling a connection error +function connectionErrorHandler(error) { + var socket = this + if (socket.res) { + if (socket.res.request) { + socket.res.request.emit('error', error) + } else { + socket.res.emit('error', error) + } + } else { + socket._httpMessage.emit('error', error) + } +} + +// Return a simpler request object to allow serialization +function requestToJSON() { + var self = this + return { + uri: self.uri, + method: self.method, + headers: self.headers + } +} + +// Return a simpler response object to allow serialization +function responseToJSON() { + var self = this + return { + statusCode: self.statusCode, + body: self.body, + headers: self.headers, + request: requestToJSON.call(self.request) + } +} + +// encode rfc3986 characters +function rfc3986 (str) { + return str.replace(/[!'()*]/g, function(c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) +} + +function Request (options) { + // if given the method property in options, set property explicitMethod to true + + // extend the Request instance with any non-reserved properties + // remove any reserved functions from the options object + // set Request instance to be readable and writable + // call init + + var self = this + + // start with HAR, then override with additional options + if (options.har) { + self._har = new Har(self) + options = self._har.options(options) + } + + stream.Stream.call(self) + var reserved = Object.keys(Request.prototype) + var nonReserved = filterForNonReserved(reserved, options) + + stream.Stream.call(self) + util._extend(self, nonReserved) + options = filterOutReservedFunctions(reserved, options) + + self.readable = true + self.writable = true + if (options.method) { + self.explicitMethod = true + } + self._auth = new Auth(self) + self._oauth = new OAuth(self) + self._multipart = new Multipart(self) + self._redirect = new Redirect(self) + self.init(options) +} + +util.inherits(Request, stream.Stream) + +// Debugging +Request.debug = process.env.NODE_DEBUG && /\brequest\b/.test(process.env.NODE_DEBUG) +function debug() { + if (Request.debug) { + console.error('REQUEST %s', util.format.apply(util, arguments)) + } +} + +Request.prototype.setupTunnel = function () { + var self = this + + if (typeof self.proxy === 'string') { + self.proxy = url.parse(self.proxy) + } + + if (!self.proxy || !self.tunnel) { + return false + } + + // Setup Proxy Header Exclusive List and White List + self.proxyHeaderExclusiveList = self.proxyHeaderExclusiveList || [] + self.proxyHeaderWhiteList = self.proxyHeaderWhiteList || defaultProxyHeaderWhiteList + var proxyHeaderExclusiveList = self.proxyHeaderExclusiveList.concat(defaultProxyHeaderExclusiveList) + var proxyHeaderWhiteList = self.proxyHeaderWhiteList.concat(proxyHeaderExclusiveList) + + // Setup Proxy Headers and Proxy Headers Host + // Only send the Proxy White Listed Header names + self.proxyHeaders = constructProxyHeaderWhiteList(self.headers, proxyHeaderWhiteList) + self.proxyHeaders.host = constructProxyHost(self.uri) + proxyHeaderExclusiveList.forEach(self.removeHeader, self) + + // Set Agent from Tunnel Data + var tunnelFn = getTunnelFn(self) + var tunnelOptions = constructTunnelOptions(self) + self.agent = tunnelFn(tunnelOptions) + + return true +} + +Request.prototype.init = function (options) { + // init() contains all the code to setup the request object. + // the actual outgoing request is not started until start() is called + // this function is called from both the constructor and on redirect. + var self = this + if (!options) { + options = {} + } + self.headers = self.headers ? copy(self.headers) : {} + + // Delete headers with value undefined since they break + // ClientRequest.OutgoingMessage.setHeader in node 0.12 + for (var headerName in self.headers) { + if (typeof self.headers[headerName] === 'undefined') { + delete self.headers[headerName] + } + } + + caseless.httpify(self, self.headers) + + if (!self.method) { + self.method = options.method || 'GET' + } + if (!self.localAddress) { + self.localAddress = options.localAddress + } + + if (!self.qsLib) { + self.qsLib = (options.useQuerystring ? querystring : qs) + } + if (!self.qsParseOptions) { + self.qsParseOptions = options.qsParseOptions + } + if (!self.qsStringifyOptions) { + self.qsStringifyOptions = options.qsStringifyOptions + } + + debug(options) + if (!self.pool && self.pool !== false) { + self.pool = globalPool + } + self.dests = self.dests || [] + self.__isRequestRequest = true + + // Protect against double callback + if (!self._callback && self.callback) { + self._callback = self.callback + self.callback = function () { + if (self._callbackCalled) { + return // Print a warning maybe? + } + self._callbackCalled = true + self._callback.apply(self, arguments) + } + self.on('error', self.callback.bind()) + self.on('complete', self.callback.bind(self, null)) + } + + // People use this property instead all the time, so support it + if (!self.uri && self.url) { + self.uri = self.url + delete self.url + } + + // If there's a baseUrl, then use it as the base URL (i.e. uri must be + // specified as a relative path and is appended to baseUrl). + if (self.baseUrl) { + if (typeof self.baseUrl !== 'string') { + return self.emit('error', new Error('options.baseUrl must be a string')) + } + + if (typeof self.uri !== 'string') { + return self.emit('error', new Error('options.uri must be a string when using options.baseUrl')) + } + + if (self.uri.indexOf('//') === 0 || self.uri.indexOf('://') !== -1) { + return self.emit('error', new Error('options.uri must be a path when using options.baseUrl')) + } + + // Handle all cases to make sure that there's only one slash between + // baseUrl and uri. + var baseUrlEndsWithSlash = self.baseUrl.lastIndexOf('/') === self.baseUrl.length - 1 + var uriStartsWithSlash = self.uri.indexOf('/') === 0 + + if (baseUrlEndsWithSlash && uriStartsWithSlash) { + self.uri = self.baseUrl + self.uri.slice(1) + } else if (baseUrlEndsWithSlash || uriStartsWithSlash) { + self.uri = self.baseUrl + self.uri + } else if (self.uri === '') { + self.uri = self.baseUrl + } else { + self.uri = self.baseUrl + '/' + self.uri + } + delete self.baseUrl + } + + // A URI is needed by this point, throw if we haven't been able to get one + if (!self.uri) { + return self.emit('error', new Error('options.uri is a required argument')) + } + + // If a string URI/URL was given, parse it into a URL object + if(typeof self.uri === 'string') { + self.uri = url.parse(self.uri) + } + + // DEPRECATED: Warning for users of the old Unix Sockets URL Scheme + if (self.uri.protocol === 'unix:') { + return self.emit('error', new Error('`unix://` URL scheme is no longer supported. Please use the format `http://unix:SOCKET:PATH`')) + } + + // Support Unix Sockets + if(self.uri.host === 'unix') { + // Get the socket & request paths from the URL + var unixParts = self.uri.path.split(':') + , host = unixParts[0] + , path = unixParts[1] + // Apply unix properties to request + self.socketPath = host + self.uri.pathname = path + self.uri.path = path + self.uri.host = host + self.uri.hostname = host + self.uri.isUnix = true + } + + if (self.strictSSL === false) { + self.rejectUnauthorized = false + } + + if(!self.hasOwnProperty('proxy')) { + self.proxy = getProxyFromURI(self.uri) + } + + self.tunnel = getTunnelOption(self, options) + if (self.proxy) { + self.setupTunnel() + } + + if (!self.uri.pathname) {self.uri.pathname = '/'} + + if (!(self.uri.host || (self.uri.hostname && self.uri.port)) && !self.uri.isUnix) { + // Invalid URI: it may generate lot of bad errors, like 'TypeError: Cannot call method `indexOf` of undefined' in CookieJar + // Detect and reject it as soon as possible + var faultyUri = url.format(self.uri) + var message = 'Invalid URI "' + faultyUri + '"' + if (Object.keys(options).length === 0) { + // No option ? This can be the sign of a redirect + // As this is a case where the user cannot do anything (they didn't call request directly with this URL) + // they should be warned that it can be caused by a redirection (can save some hair) + message += '. This can be caused by a crappy redirection.' + } + // This error was fatal + return self.emit('error', new Error(message)) + } + + self._redirect.onRequest() + + self.setHost = false + if (!self.hasHeader('host')) { + var hostHeaderName = self.originalHostHeaderName || 'host' + self.setHeader(hostHeaderName, self.uri.hostname) + if (self.uri.port) { + if ( !(self.uri.port === 80 && self.uri.protocol === 'http:') && + !(self.uri.port === 443 && self.uri.protocol === 'https:') ) { + self.setHeader(hostHeaderName, self.getHeader('host') + (':' + self.uri.port) ) + } + } + self.setHost = true + } + + self.jar(self._jar || options.jar) + + if (!self.uri.port) { + if (self.uri.protocol === 'http:') {self.uri.port = 80} + else if (self.uri.protocol === 'https:') {self.uri.port = 443} + } + + if (self.proxy && !self.tunnel) { + self.port = self.proxy.port + self.host = self.proxy.hostname + } else { + self.port = self.uri.port + self.host = self.uri.hostname + } + + if (options.form) { + self.form(options.form) + } + + if (options.formData) { + var formData = options.formData + var requestForm = self.form() + var appendFormValue = function (key, value) { + if (value.hasOwnProperty('value') && value.hasOwnProperty('options')) { + requestForm.append(key, value.value, value.options) + } else { + requestForm.append(key, value) + } + } + for (var formKey in formData) { + if (formData.hasOwnProperty(formKey)) { + var formValue = formData[formKey] + if (formValue instanceof Array) { + for (var j = 0; j < formValue.length; j++) { + appendFormValue(formKey, formValue[j]) + } + } else { + appendFormValue(formKey, formValue) + } + } + } + } + + if (options.qs) { + self.qs(options.qs) + } + + if (self.uri.path) { + self.path = self.uri.path + } else { + self.path = self.uri.pathname + (self.uri.search || '') + } + + if (self.path.length === 0) { + self.path = '/' + } + + // Auth must happen last in case signing is dependent on other headers + if (options.oauth) { + self.oauth(options.oauth) + } + + if (options.aws) { + self.aws(options.aws) + } + + if (options.hawk) { + self.hawk(options.hawk) + } + + if (options.httpSignature) { + self.httpSignature(options.httpSignature) + } + + if (options.auth) { + if (Object.prototype.hasOwnProperty.call(options.auth, 'username')) { + options.auth.user = options.auth.username + } + if (Object.prototype.hasOwnProperty.call(options.auth, 'password')) { + options.auth.pass = options.auth.password + } + + self.auth( + options.auth.user, + options.auth.pass, + options.auth.sendImmediately, + options.auth.bearer + ) + } + + if (self.gzip && !self.hasHeader('accept-encoding')) { + self.setHeader('accept-encoding', 'gzip') + } + + if (self.uri.auth && !self.hasHeader('authorization')) { + var uriAuthPieces = self.uri.auth.split(':').map(function(item){ return querystring.unescape(item) }) + self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true) + } + + if (!self.tunnel && self.proxy && self.proxy.auth && !self.hasHeader('proxy-authorization')) { + var proxyAuthPieces = self.proxy.auth.split(':').map(function(item){ + return querystring.unescape(item) + }) + var authHeader = 'Basic ' + toBase64(proxyAuthPieces.join(':')) + self.setHeader('proxy-authorization', authHeader) + } + + if (self.proxy && !self.tunnel) { + self.path = (self.uri.protocol + '//' + self.uri.host + self.path) + } + + if (options.json) { + self.json(options.json) + } + if (options.multipart) { + self.multipart(options.multipart) + } + + if (options.time) { + self.timing = true + self.elapsedTime = self.elapsedTime || 0 + } + + if (self.body) { + var length = 0 + if (!Buffer.isBuffer(self.body)) { + if (Array.isArray(self.body)) { + for (var i = 0; i < self.body.length; i++) { + length += self.body[i].length + } + } else { + self.body = new Buffer(self.body) + length = self.body.length + } + } else { + length = self.body.length + } + if (length) { + if (!self.hasHeader('content-length')) { + self.setHeader('content-length', length) + } + } else { + throw new Error('Argument error, options.body.') + } + } + + var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol + , defaultModules = {'http:':http, 'https:':https} + , httpModules = self.httpModules || {} + + self.httpModule = httpModules[protocol] || defaultModules[protocol] + + if (!self.httpModule) { + return self.emit('error', new Error('Invalid protocol: ' + protocol)) + } + + if (options.ca) { + self.ca = options.ca + } + + if (!self.agent) { + if (options.agentOptions) { + self.agentOptions = options.agentOptions + } + + if (options.agentClass) { + self.agentClass = options.agentClass + } else if (options.forever) { + self.agentClass = protocol === 'http:' ? ForeverAgent : ForeverAgent.SSL + } else { + self.agentClass = self.httpModule.Agent + } + } + + if (self.pool === false) { + self.agent = false + } else { + self.agent = self.agent || self.getNewAgent() + } + + self.on('pipe', function (src) { + if (self.ntick && self._started) { + throw new Error('You cannot pipe to this stream after the outbound request has started.') + } + self.src = src + if (isReadStream(src)) { + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', mime.lookup(src.path)) + } + } else { + if (src.headers) { + for (var i in src.headers) { + if (!self.hasHeader(i)) { + self.setHeader(i, src.headers[i]) + } + } + } + if (self._json && !self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + if (src.method && !self.explicitMethod) { + self.method = src.method + } + } + + // self.on('pipe', function () { + // console.error('You have already piped to this stream. Pipeing twice is likely to break the request.') + // }) + }) + + defer(function () { + if (self._aborted) { + return + } + + var end = function () { + if (self._form) { + if (!self._auth.hasAuth) { + self._form.pipe(self) + } + else if (self._auth.hasAuth && self._auth.sentAuth) { + self._form.pipe(self) + } + } + if (self._multipart && self._multipart.chunked) { + self._multipart.body.pipe(self) + } + if (self.body) { + if (Array.isArray(self.body)) { + self.body.forEach(function (part) { + self.write(part) + }) + } else { + self.write(self.body) + } + self.end() + } else if (self.requestBodyStream) { + console.warn('options.requestBodyStream is deprecated, please pass the request object to stream.pipe.') + self.requestBodyStream.pipe(self) + } else if (!self.src) { + if (self._auth.hasAuth && !self._auth.sentAuth) { + self.end() + return + } + if (self.method !== 'GET' && typeof self.method !== 'undefined') { + self.setHeader('content-length', 0) + } + self.end() + } + } + + if (self._form && !self.hasHeader('content-length')) { + // Before ending the request, we had to compute the length of the whole form, asyncly + self.setHeader(self._form.getHeaders()) + self._form.getLength(function (err, length) { + if (!err) { + self.setHeader('content-length', length) + } + end() + }) + } else { + end() + } + + self.ntick = true + }) + +} + +// Must call this when following a redirect from https to http or vice versa +// Attempts to keep everything as identical as possible, but update the +// httpModule, Tunneling agent, and/or Forever Agent in use. +Request.prototype._updateProtocol = function () { + var self = this + var protocol = self.uri.protocol + + if (protocol === 'https:' || self.tunnel) { + // previously was doing http, now doing https + // if it's https, then we might need to tunnel now. + if (self.proxy) { + if (self.setupTunnel()) { + return + } + } + + self.httpModule = https + switch (self.agentClass) { + case ForeverAgent: + self.agentClass = ForeverAgent.SSL + break + case http.Agent: + self.agentClass = https.Agent + break + default: + // nothing we can do. Just hope for the best. + return + } + + // if there's an agent, we need to get a new one. + if (self.agent) { + self.agent = self.getNewAgent() + } + + } else { + // previously was doing https, now doing http + self.httpModule = http + switch (self.agentClass) { + case ForeverAgent.SSL: + self.agentClass = ForeverAgent + break + case https.Agent: + self.agentClass = http.Agent + break + default: + // nothing we can do. just hope for the best + return + } + + // if there's an agent, then get a new one. + if (self.agent) { + self.agent = null + self.agent = self.getNewAgent() + } + } +} + +Request.prototype.getNewAgent = function () { + var self = this + var Agent = self.agentClass + var options = {} + if (self.agentOptions) { + for (var i in self.agentOptions) { + options[i] = self.agentOptions[i] + } + } + if (self.ca) { + options.ca = self.ca + } + if (self.ciphers) { + options.ciphers = self.ciphers + } + if (self.secureProtocol) { + options.secureProtocol = self.secureProtocol + } + if (self.secureOptions) { + options.secureOptions = self.secureOptions + } + if (typeof self.rejectUnauthorized !== 'undefined') { + options.rejectUnauthorized = self.rejectUnauthorized + } + + if (self.cert && self.key) { + options.key = self.key + options.cert = self.cert + } + + if (self.pfx) { + options.pfx = self.pfx + } + + if (self.passphrase) { + options.passphrase = self.passphrase + } + + var poolKey = '' + + // different types of agents are in different pools + if (Agent !== self.httpModule.Agent) { + poolKey += Agent.name + } + + // ca option is only relevant if proxy or destination are https + var proxy = self.proxy + if (typeof proxy === 'string') { + proxy = url.parse(proxy) + } + var isHttps = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:' + + if (isHttps) { + if (options.ca) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.ca + } + + if (typeof options.rejectUnauthorized !== 'undefined') { + if (poolKey) { + poolKey += ':' + } + poolKey += options.rejectUnauthorized + } + + if (options.cert) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.cert.toString('ascii') + options.key.toString('ascii') + } + + if (options.pfx) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.pfx.toString('ascii') + } + + if (options.ciphers) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.ciphers + } + + if (options.secureProtocol) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.secureProtocol + } + + if (options.secureOptions) { + if (poolKey) { + poolKey += ':' + } + poolKey += options.secureOptions + } + } + + if (self.pool === globalPool && !poolKey && Object.keys(options).length === 0 && self.httpModule.globalAgent) { + // not doing anything special. Use the globalAgent + return self.httpModule.globalAgent + } + + // we're using a stored agent. Make sure it's protocol-specific + poolKey = self.uri.protocol + poolKey + + // generate a new agent for this setting if none yet exists + if (!self.pool[poolKey]) { + self.pool[poolKey] = new Agent(options) + // properly set maxSockets on new agents + if (self.pool.maxSockets) { + self.pool[poolKey].maxSockets = self.pool.maxSockets + } + } + + return self.pool[poolKey] +} + +Request.prototype.start = function () { + // start() is called once we are ready to send the outgoing HTTP request. + // this is usually called on the first write(), end() or on nextTick() + var self = this + + if (self._aborted) { + return + } + + self._started = true + self.method = self.method || 'GET' + self.href = self.uri.href + + if (self.src && self.src.stat && self.src.stat.size && !self.hasHeader('content-length')) { + self.setHeader('content-length', self.src.stat.size) + } + if (self._aws) { + self.aws(self._aws, true) + } + + // We have a method named auth, which is completely different from the http.request + // auth option. If we don't remove it, we're gonna have a bad time. + var reqOptions = copy(self) + delete reqOptions.auth + + debug('make request', self.uri.href) + + self.req = self.httpModule.request(reqOptions) + + if (self.timing) { + self.startTime = new Date().getTime() + } + + if (self.timeout && !self.timeoutTimer) { + var timeout = self.timeout < 0 ? 0 : self.timeout + self.timeoutTimer = setTimeout(function () { + self.abort() + var e = new Error('ETIMEDOUT') + e.code = 'ETIMEDOUT' + self.emit('error', e) + }, timeout) + + // Set additional timeout on socket - in case if remote + // server freeze after sending headers + if (self.req.setTimeout) { // only works on node 0.6+ + self.req.setTimeout(timeout, function () { + if (self.req) { + self.req.abort() + var e = new Error('ESOCKETTIMEDOUT') + e.code = 'ESOCKETTIMEDOUT' + self.emit('error', e) + } + }) + } + } + + self.req.on('response', self.onRequestResponse.bind(self)) + self.req.on('error', self.onRequestError.bind(self)) + self.req.on('drain', function() { + self.emit('drain') + }) + self.req.on('socket', function(socket) { + self.emit('socket', socket) + }) + + self.on('end', function() { + if ( self.req.connection ) { + self.req.connection.removeListener('error', connectionErrorHandler) + } + }) + self.emit('request', self.req) +} + +Request.prototype.onRequestError = function (error) { + var self = this + if (self._aborted) { + return + } + if (self.req && self.req._reusedSocket && error.code === 'ECONNRESET' + && self.agent.addRequestNoreuse) { + self.agent = { addRequest: self.agent.addRequestNoreuse.bind(self.agent) } + self.start() + self.req.end() + return + } + if (self.timeout && self.timeoutTimer) { + clearTimeout(self.timeoutTimer) + self.timeoutTimer = null + } + self.emit('error', error) +} + +Request.prototype.onRequestResponse = function (response) { + var self = this + debug('onRequestResponse', self.uri.href, response.statusCode, response.headers) + response.on('end', function() { + if (self.timing) { + self.elapsedTime += (new Date().getTime() - self.startTime) + debug('elapsed time', self.elapsedTime) + response.elapsedTime = self.elapsedTime + } + debug('response end', self.uri.href, response.statusCode, response.headers) + }) + + // The check on response.connection is a workaround for browserify. + if (response.connection && response.connection.listeners('error').indexOf(connectionErrorHandler) === -1) { + response.connection.setMaxListeners(0) + response.connection.once('error', connectionErrorHandler) + } + if (self._aborted) { + debug('aborted', self.uri.href) + response.resume() + return + } + if (self._paused) { + response.pause() + } else if (response.resume) { + // response.resume should be defined, but check anyway before calling. Workaround for browserify. + response.resume() + } + + self.response = response + response.request = self + response.toJSON = responseToJSON + + // XXX This is different on 0.10, because SSL is strict by default + if (self.httpModule === https && + self.strictSSL && (!response.hasOwnProperty('client') || + !response.client.authorized)) { + debug('strict ssl error', self.uri.href) + var sslErr = response.hasOwnProperty('client') ? response.client.authorizationError : self.uri.href + ' does not support SSL' + self.emit('error', new Error('SSL Error: ' + sslErr)) + return + } + + // Save the original host before any redirect (if it changes, we need to + // remove any authorization headers). Also remember the case of the header + // name because lots of broken servers expect Host instead of host and we + // want the caller to be able to specify this. + self.originalHost = self.getHeader('host') + if (!self.originalHostHeaderName) { + self.originalHostHeaderName = self.hasHeader('host') + } + if (self.setHost) { + self.removeHeader('host') + } + if (self.timeout && self.timeoutTimer) { + clearTimeout(self.timeoutTimer) + self.timeoutTimer = null + } + + var targetCookieJar = (self._jar && self._jar.setCookie) ? self._jar : globalCookieJar + var addCookie = function (cookie) { + //set the cookie if it's domain in the href's domain. + try { + targetCookieJar.setCookie(cookie, self.uri.href, {ignoreError: true}) + } catch (e) { + self.emit('error', e) + } + } + + response.caseless = caseless(response.headers) + + if (response.caseless.has('set-cookie') && (!self._disableCookies)) { + var headerName = response.caseless.has('set-cookie') + if (Array.isArray(response.headers[headerName])) { + response.headers[headerName].forEach(addCookie) + } else { + addCookie(response.headers[headerName]) + } + } + + if (self._redirect.onResponse(response)) { + return // Ignore the rest of the response + } else { + // Be a good stream and emit end when the response is finished. + // Hack to emit end on close because of a core bug that never fires end + response.on('close', function () { + if (!self._ended) { + self.response.emit('end') + } + }) + + response.on('end', function () { + self._ended = true + }) + + var dataStream + if (self.gzip) { + var contentEncoding = response.headers['content-encoding'] || 'identity' + contentEncoding = contentEncoding.trim().toLowerCase() + + if (contentEncoding === 'gzip') { + dataStream = zlib.createGunzip() + response.pipe(dataStream) + } else { + // Since previous versions didn't check for Content-Encoding header, + // ignore any invalid values to preserve backwards-compatibility + if (contentEncoding !== 'identity') { + debug('ignoring unrecognized Content-Encoding ' + contentEncoding) + } + dataStream = response + } + } else { + dataStream = response + } + + if (self.encoding) { + if (self.dests.length !== 0) { + console.error('Ignoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.') + } else if (dataStream.setEncoding) { + dataStream.setEncoding(self.encoding) + } else { + // Should only occur on node pre-v0.9.4 (joyent/node@9b5abe5) with + // zlib streams. + // If/When support for 0.9.4 is dropped, this should be unnecessary. + dataStream = dataStream.pipe(stringstream(self.encoding)) + } + } + + self.emit('response', response) + + self.dests.forEach(function (dest) { + self.pipeDest(dest) + }) + + dataStream.on('data', function (chunk) { + self._destdata = true + self.emit('data', chunk) + }) + dataStream.on('end', function (chunk) { + self.emit('end', chunk) + }) + dataStream.on('error', function (error) { + self.emit('error', error) + }) + dataStream.on('close', function () {self.emit('close')}) + + if (self.callback) { + var buffer = bl() + , strings = [] + + self.on('data', function (chunk) { + if (Buffer.isBuffer(chunk)) { + buffer.append(chunk) + } else { + strings.push(chunk) + } + }) + self.on('end', function () { + debug('end event', self.uri.href) + if (self._aborted) { + debug('aborted', self.uri.href) + return + } + + if (buffer.length) { + debug('has body', self.uri.href, buffer.length) + if (self.encoding === null) { + // response.body = buffer + // can't move to this until https://github.com/rvagg/bl/issues/13 + response.body = buffer.slice() + } else { + response.body = buffer.toString(self.encoding) + } + } else if (strings.length) { + // The UTF8 BOM [0xEF,0xBB,0xBF] is converted to [0xFE,0xFF] in the JS UTC16/UCS2 representation. + // Strip this value out when the encoding is set to 'utf8', as upstream consumers won't expect it and it breaks JSON.parse(). + if (self.encoding === 'utf8' && strings[0].length > 0 && strings[0][0] === '\uFEFF') { + strings[0] = strings[0].substring(1) + } + response.body = strings.join('') + } + + if (self._json) { + try { + response.body = JSON.parse(response.body, self._jsonReviver) + } catch (e) {} + } + debug('emitting complete', self.uri.href) + if(typeof response.body === 'undefined' && !self._json) { + response.body = self.encoding === null ? new Buffer(0) : '' + } + self.emit('complete', response, response.body) + }) + } + //if no callback + else{ + self.on('end', function () { + if (self._aborted) { + debug('aborted', self.uri.href) + return + } + self.emit('complete', response) + }) + } + } + debug('finish init function', self.uri.href) +} + +Request.prototype.abort = function () { + var self = this + self._aborted = true + + if (self.req) { + self.req.abort() + } + else if (self.response) { + self.response.abort() + } + + self.emit('abort') +} + +Request.prototype.pipeDest = function (dest) { + var self = this + var response = self.response + // Called after the response is received + if (dest.headers && !dest.headersSent) { + if (response.caseless.has('content-type')) { + var ctname = response.caseless.has('content-type') + if (dest.setHeader) { + dest.setHeader(ctname, response.headers[ctname]) + } + else { + dest.headers[ctname] = response.headers[ctname] + } + } + + if (response.caseless.has('content-length')) { + var clname = response.caseless.has('content-length') + if (dest.setHeader) { + dest.setHeader(clname, response.headers[clname]) + } else { + dest.headers[clname] = response.headers[clname] + } + } + } + if (dest.setHeader && !dest.headersSent) { + for (var i in response.headers) { + // If the response content is being decoded, the Content-Encoding header + // of the response doesn't represent the piped content, so don't pass it. + if (!self.gzip || i !== 'content-encoding') { + dest.setHeader(i, response.headers[i]) + } + } + dest.statusCode = response.statusCode + } + if (self.pipefilter) { + self.pipefilter(response, dest) + } +} + +Request.prototype.qs = function (q, clobber) { + var self = this + var base + if (!clobber && self.uri.query) { + base = self.qsLib.parse(self.uri.query, self.qsParseOptions) + } else { + base = {} + } + + for (var i in q) { + base[i] = q[i] + } + + if (self.qsLib.stringify(base, self.qsStringifyOptions) === ''){ + return self + } + + var qs = self.qsLib.stringify(base, self.qsStringifyOptions) + + self.uri = url.parse(self.uri.href.split('?')[0] + '?' + rfc3986(qs)) + self.url = self.uri + self.path = self.uri.path + + return self +} +Request.prototype.form = function (form) { + var self = this + if (form) { + self.setHeader('content-type', 'application/x-www-form-urlencoded') + self.body = (typeof form === 'string') + ? form.toString('utf8') + : self.qsLib.stringify(form, self.qsStringifyOptions).toString('utf8') + self.body = rfc3986(self.body) + return self + } + // create form-data object + self._form = new FormData() + self._form.on('error', function(err) { + err.message = 'form-data: ' + err.message + self.emit('error', err) + self.abort() + }) + return self._form +} +Request.prototype.multipart = function (multipart) { + var self = this + + self._multipart.onRequest(multipart) + + if (!self._multipart.chunked) { + self.body = self._multipart.body + } + + return self +} +Request.prototype.json = function (val) { + var self = this + + if (!self.hasHeader('accept')) { + self.setHeader('accept', 'application/json') + } + + self._json = true + if (typeof val === 'boolean') { + if (self.body !== undefined) { + if (!/^application\/x-www-form-urlencoded\b/.test(self.getHeader('content-type'))) { + self.body = safeStringify(self.body) + } else { + self.body = rfc3986(self.body) + } + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + } + } else { + self.body = safeStringify(val) + if (!self.hasHeader('content-type')) { + self.setHeader('content-type', 'application/json') + } + } + + if (typeof self.jsonReviver === 'function') { + self._jsonReviver = self.jsonReviver + } + + return self +} +Request.prototype.getHeader = function (name, headers) { + var self = this + var result, re, match + if (!headers) { + headers = self.headers + } + Object.keys(headers).forEach(function (key) { + if (key.length !== name.length) { + return + } + re = new RegExp(name, 'i') + match = key.match(re) + if (match) { + result = headers[key] + } + }) + return result +} + +Request.prototype.auth = function (user, pass, sendImmediately, bearer) { + var self = this + + self._auth.onRequest(user, pass, sendImmediately, bearer) + + return self +} +Request.prototype.aws = function (opts, now) { + var self = this + + if (!now) { + self._aws = opts + return self + } + var date = new Date() + self.setHeader('date', date.toUTCString()) + var auth = + { key: opts.key + , secret: opts.secret + , verb: self.method.toUpperCase() + , date: date + , contentType: self.getHeader('content-type') || '' + , md5: self.getHeader('content-md5') || '' + , amazonHeaders: aws.canonicalizeHeaders(self.headers) + } + var path = self.uri.path + if (opts.bucket && path) { + auth.resource = '/' + opts.bucket + path + } else if (opts.bucket && !path) { + auth.resource = '/' + opts.bucket + } else if (!opts.bucket && path) { + auth.resource = path + } else if (!opts.bucket && !path) { + auth.resource = '/' + } + auth.resource = aws.canonicalizeResource(auth.resource) + self.setHeader('authorization', aws.authorization(auth)) + + return self +} +Request.prototype.httpSignature = function (opts) { + var self = this + httpSignature.signRequest({ + getHeader: function(header) { + return self.getHeader(header, self.headers) + }, + setHeader: function(header, value) { + self.setHeader(header, value) + }, + method: self.method, + path: self.path + }, opts) + debug('httpSignature authorization', self.getHeader('authorization')) + + return self +} +Request.prototype.hawk = function (opts) { + var self = this + self.setHeader('Authorization', hawk.client.header(self.uri, self.method, opts).field) +} +Request.prototype.oauth = function (_oauth) { + var self = this + + self._oauth.onRequest(_oauth) + + return self +} + +Request.prototype.jar = function (jar) { + var self = this + var cookies + + if (self._redirect.redirectsFollowed === 0) { + self.originalCookieHeader = self.getHeader('cookie') + } + + if (!jar) { + // disable cookies + cookies = false + self._disableCookies = true + } else { + var targetCookieJar = (jar && jar.getCookieString) ? jar : globalCookieJar + var urihref = self.uri.href + //fetch cookie in the Specified host + if (targetCookieJar) { + cookies = targetCookieJar.getCookieString(urihref) + } + } + + //if need cookie and cookie is not empty + if (cookies && cookies.length) { + if (self.originalCookieHeader) { + // Don't overwrite existing Cookie header + self.setHeader('cookie', self.originalCookieHeader + '; ' + cookies) + } else { + self.setHeader('cookie', cookies) + } + } + self._jar = jar + return self +} + + +// Stream API +Request.prototype.pipe = function (dest, opts) { + var self = this + + if (self.response) { + if (self._destdata) { + throw new Error('You cannot pipe after data has been emitted from the response.') + } else if (self._ended) { + throw new Error('You cannot pipe after the response has been ended.') + } else { + stream.Stream.prototype.pipe.call(self, dest, opts) + self.pipeDest(dest) + return dest + } + } else { + self.dests.push(dest) + stream.Stream.prototype.pipe.call(self, dest, opts) + return dest + } +} +Request.prototype.write = function () { + var self = this + if (!self._started) { + self.start() + } + return self.req.write.apply(self.req, arguments) +} +Request.prototype.end = function (chunk) { + var self = this + if (chunk) { + self.write(chunk) + } + if (!self._started) { + self.start() + } + self.req.end() +} +Request.prototype.pause = function () { + var self = this + if (!self.response) { + self._paused = true + } else { + self.response.pause.apply(self.response, arguments) + } +} +Request.prototype.resume = function () { + var self = this + if (!self.response) { + self._paused = false + } else { + self.response.resume.apply(self.response, arguments) + } +} +Request.prototype.destroy = function () { + var self = this + if (!self._ended) { + self.end() + } else if (self.response) { + self.response.destroy() + } +} + +Request.defaultProxyHeaderWhiteList = + defaultProxyHeaderWhiteList.slice() + +Request.defaultProxyHeaderExclusiveList = + defaultProxyHeaderExclusiveList.slice() + +// Exports + +Request.prototype.toJSON = requestToJSON +module.exports = Request diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/LICENSE new file mode 100644 index 0000000..05a4010 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/LICENSE @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/README.md new file mode 100644 index 0000000..58e7ac3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/README.md @@ -0,0 +1,36 @@ +The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node. + +Install with `npm install rimraf`, or just drop rimraf.js somewhere. + +## API + +`rimraf(f, callback)` + +The callback will be called with an error if there is one. Certain +errors are handled for you: + +* Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of + `opts.maxBusyTries` times before giving up, adding 100ms of wait + between each attempt. The default `maxBusyTries` is 3. +* `ENOENT` - If the file doesn't exist, rimraf will return + successfully, since your desired outcome is already the case. +* `EMFILE` - Since `readdir` requires opening a file descriptor, it's + possible to hit `EMFILE` if too many file descriptors are in use. + In the sync case, there's nothing to be done for this. But in the + async case, rimraf will gradually back off with timeouts up to + `opts.emfileWait` ms, which defaults to 1000. + +## rimraf.sync + +It can remove stuff synchronously, too. But that's not so good. Use +the async API. It's better. + +## CLI + +If installed with `npm install rimraf -g` it can be used as a global +command `rimraf ` which is useful for cross platform support. + +## mkdirp + +If you need to create a directory recursively, check out +[mkdirp](https://github.com/substack/node-mkdirp). diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/bin.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/bin.js new file mode 100755 index 0000000..29bfa8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/bin.js @@ -0,0 +1,33 @@ +#!/usr/bin/env node + +var rimraf = require('./') + +var help = false +var dashdash = false +var args = process.argv.slice(2).filter(function(arg) { + if (dashdash) + return !!arg + else if (arg === '--') + dashdash = true + else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/)) + help = true + else + return !!arg +}); + +if (help || args.length === 0) { + // If they didn't ask for help, then this is not a "success" + var log = help ? console.log : console.error + log('Usage: rimraf ') + log('') + log(' Deletes all files and folders at "path" recursively.') + log('') + log('Options:') + log('') + log(' -h, --help Display this usage info') + process.exit(help ? 0 : 1) +} else { + args.forEach(function(arg) { + rimraf.sync(arg) + }) +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/README.md new file mode 100644 index 0000000..258257e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/README.md @@ -0,0 +1,369 @@ +[](https://travis-ci.org/isaacs/node-glob/) [](https://david-dm.org/isaacs/node-glob) [](https://david-dm.org/isaacs/node-glob#info=devDependencies) [](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. + + + +## 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/common.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/common.js new file mode 100644 index 0000000..cd7c824 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/common.js @@ -0,0 +1,237 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/glob.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/glob.js new file mode 100644 index 0000000..eac0693 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/glob.js @@ -0,0 +1,740 @@ +// 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/.eslintrc b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/.eslintrc new file mode 100644 index 0000000..b7a1550 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/.eslintrc @@ -0,0 +1,17 @@ +{ + "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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/LICENSE new file mode 100644 index 0000000..05eeeb8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/LICENSE @@ -0,0 +1,15 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/README.md new file mode 100644 index 0000000..6dc8929 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/README.md @@ -0,0 +1,37 @@ +# 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/inflight.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/inflight.js new file mode 100644 index 0000000..8bc96cb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/inflight.js @@ -0,0 +1,44 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE new file mode 100644 index 0000000..19129e3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE @@ -0,0 +1,15 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md new file mode 100644 index 0000000..98eab25 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md @@ -0,0 +1,36 @@ +# 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json new file mode 100644 index 0000000..5a07040 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json @@ -0,0 +1,52 @@ +{ + "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": "git+https://github.com/npm/wrappy.git" + }, + "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.0.0 <2.0.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": "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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js new file mode 100644 index 0000000..5ed0fcd --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js @@ -0,0 +1,51 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js new file mode 100644 index 0000000..bb7e7d6 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js @@ -0,0 +1,33 @@ +// 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/package.json new file mode 100644 index 0000000..fd0da2d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/package.json @@ -0,0 +1,61 @@ +{ + "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.git" + }, + "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 <2.0.0", + "_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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/test.js new file mode 100644 index 0000000..2bb75b3 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inflight/test.js @@ -0,0 +1,97 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE new file mode 100644 index 0000000..dea3013 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md new file mode 100644 index 0000000..b1c5665 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js new file mode 100644 index 0000000..29f5e24 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js @@ -0,0 +1 @@ +module.exports = require('util').inherits diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js new file mode 100644 index 0000000..c1e78a7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js @@ -0,0 +1,23 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json new file mode 100644 index 0000000..cae2306 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json @@ -0,0 +1,50 @@ +{ + "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.git" + }, + "license": "ISC", + "scripts": { + "test": "node test" + }, + "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@>=2.0.0 <3.0.0", + "_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", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/isaacs/inherits" +} diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js new file mode 100644 index 0000000..fc53012 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js @@ -0,0 +1,25 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/README.md new file mode 100644 index 0000000..d458bc2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/README.md @@ -0,0 +1,216 @@ +# minimatch + +A minimal matching utility. + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/browser.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/browser.js new file mode 100644 index 0000000..967b45c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/browser.js @@ -0,0 +1,1113 @@ +(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 +var 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. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var 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 (path.sep !== '/') { + pattern = pattern.split(path.sep).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 s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var 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 = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var 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 (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 + break + 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 { + 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 + 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. + for (var pl = patternListStack.pop(); pl; 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' : '' + var 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) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var 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 { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +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 (path.sep !== '/') { + f = f.split(path.sep).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 + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var 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] + var 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 + var 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 (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 + } + + // ** 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,"path":undefined}],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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/minimatch.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/minimatch.js new file mode 100644 index 0000000..5e13d6d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/minimatch.js @@ -0,0 +1,867 @@ +module.exports = minimatch +minimatch.Minimatch = Minimatch + +var path = { sep: '/' } +try { + path = require('path') +} catch (er) {} + +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = require('brace-expansion') + +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' + +// * => any number of characters +var 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. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' + +// characters that need to be escaped in RegExp. +var 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 (path.sep !== '/') { + pattern = pattern.split(path.sep).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 s.indexOf(false) === -1 + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + var negate = false + var options = this.options + var 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 = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var 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 (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 + break + 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 { + 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 + 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. + for (var pl = patternListStack.pop(); pl; 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' : '' + var 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) { + this.regexp = false + return this.regexp + } + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + var 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 { + this.regexp = new RegExp(re, flags) + } catch (ex) { + this.regexp = false + } + return this.regexp +} + +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 (path.sep !== '/') { + f = f.split(path.sep).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 + var i + for (i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var 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] + var 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 + var 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 (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 + } + + // ** 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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore new file mode 100644 index 0000000..249bc20 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore @@ -0,0 +1,2 @@ +node_modules +*.sw* diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml new file mode 100644 index 0000000..6e5919d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md new file mode 100644 index 0000000..62bc7ba --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md @@ -0,0 +1,121 @@ +# brace-expansion + +[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), +as known from sh/bash, in JavaScript. + +[](http://travis-ci.org/juliangruber/brace-expansion) + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js new file mode 100644 index 0000000..60ecfc7 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js @@ -0,0 +1,8 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js new file mode 100644 index 0000000..a23104e --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js @@ -0,0 +1,191 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore new file mode 100644 index 0000000..fd4f2b0 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml new file mode 100644 index 0000000..cc4dba2 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile new file mode 100644 index 0000000..fa5da71 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile @@ -0,0 +1,6 @@ + +test: + @node_modules/.bin/tape test/*.js + +.PHONY: test + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md new file mode 100644 index 0000000..2aff0eb --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md @@ -0,0 +1,80 @@ +# balanced-match + +Match balanced string pairs, like `{` and `}` or `` and ``. + +[](http://travis-ci.org/juliangruber/balanced-match) +[](https://www.npmjs.org/package/balanced-match) + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js new file mode 100644 index 0000000..c02ad34 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js @@ -0,0 +1,5 @@ +var balanced = require('./'); + +console.log(balanced('{', '}', 'pre{in{nested}}post')); +console.log(balanced('{', '}', 'pre{first}between{second}post')); + diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js new file mode 100644 index 0000000..d165ae8 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js @@ -0,0 +1,38 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json new file mode 100644 index 0000000..ede6efe --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json @@ -0,0 +1,73 @@ +{ + "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 <0.3.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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js new file mode 100644 index 0000000..36bfd39 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js @@ -0,0 +1,56 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml new file mode 100644 index 0000000..f1d0f13 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - 0.4 + - 0.6 diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE new file mode 100644 index 0000000..ee27ba4 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE @@ -0,0 +1,18 @@ +This software is released under the MIT license: + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown new file mode 100644 index 0000000..408f70a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown @@ -0,0 +1,62 @@ +concat-map +========== + +Concatenative mapdashery. + +[](http://ci.testling.com/substack/node-concat-map) + +[](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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js new file mode 100644 index 0000000..3365621 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js @@ -0,0 +1,6 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js new file mode 100644 index 0000000..b29a781 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js @@ -0,0 +1,13 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json new file mode 100644 index 0000000..b516138 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json @@ -0,0 +1,83 @@ +{ + "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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js new file mode 100644 index 0000000..fdbd702 --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js @@ -0,0 +1,39 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json new file mode 100644 index 0000000..5f1866c --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json @@ -0,0 +1,75 @@ +{ + "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 <2.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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js new file mode 100644 index 0000000..5fe2b8a --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js @@ -0,0 +1,32 @@ +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/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt new file mode 100644 index 0000000..958148d --- /dev/null +++ b/JavaScript/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt @@ -0,0 +1,1075 @@ +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]><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
' + func(text) + '
fred, barney, & pebbles
new BufferList([ callback ])
bl.length
bl.append(buffer)
bl.get(index)
bl.slice([ start[, end ] ])
bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
bl.duplicate()
bl.consume(bytes)
bl.toString([encoding, [ start, [ end ]]])
bl.readDoubleBE()
bl.readDoubleLE()
bl.readFloatBE()
bl.readFloatLE()
bl.readInt32BE()
bl.readInt32LE()
bl.readUInt32BE()
bl.readUInt32LE()
bl.readInt16BE()
bl.readInt16LE()
bl.readUInt16BE()
bl.readUInt16LE()
bl.readInt8()
bl.readUInt8()
[Buffer](http://nodejs.org/docs/latest/api/buffer.html)