exercism-analysis 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/exercism-analysis.gemspec +30 -0
- data/lib/exercism-analysis.rb +38 -0
- data/lib/exercism-analysis/adapters/adapter.rb +23 -0
- data/lib/exercism-analysis/adapters/clojure.rb +13 -0
- data/lib/exercism-analysis/adapters/go.rb +19 -0
- data/lib/exercism-analysis/adapters/javascript.rb +13 -0
- data/lib/exercism-analysis/adapters/python.rb +13 -0
- data/lib/exercism-analysis/adapters/ruby.rb +19 -0
- data/lib/exercism-analysis/analysis.rb +18 -0
- data/lib/exercism-analysis/analyzers/analyzer.rb +54 -0
- data/lib/exercism-analysis/analyzers/clojure/kibit.rb +25 -0
- data/lib/exercism-analysis/analyzers/go/golint.rb +23 -0
- data/lib/exercism-analysis/analyzers/javascript/jslint.rb +24 -0
- data/lib/exercism-analysis/analyzers/python/pylint.rb +24 -0
- data/lib/exercism-analysis/analyzers/ruby/control_flow.rb +21 -0
- data/lib/exercism-analysis/analyzers/ruby/enumerable_condition.rb +21 -0
- data/lib/exercism-analysis/analyzers/ruby/for_loop.rb +29 -0
- data/lib/exercism-analysis/analyzers/ruby/indentation.rb +21 -0
- data/lib/exercism-analysis/analyzers/ruby/iter_mutation.rb +37 -0
- data/lib/exercism-analysis/analyzers/ruby/output.rb +20 -0
- data/lib/exercism-analysis/analyzers/ruby/range.rb +28 -0
- data/lib/exercism-analysis/analyzers/ruby/roodi.rb +19 -0
- data/lib/exercism-analysis/analyzers/ruby/send.rb +25 -0
- data/lib/exercism-analysis/analyzers/ruby/shebang.rb +23 -0
- data/lib/exercism-analysis/analyzers/ruby/tab.rb +38 -0
- data/lib/exercism-analysis/processors/call_processor.rb +39 -0
- data/lib/exercism-analysis/processors/control_flow_processor.rb +27 -0
- data/lib/exercism-analysis/processors/enumerable_condition_processor.rb +31 -0
- data/lib/exercism-analysis/processors/for_loop_processor.rb +21 -0
- data/lib/exercism-analysis/processors/indentation_processor.rb +69 -0
- data/lib/exercism-analysis/processors/iter_mutation_processor.rb +50 -0
- data/lib/exercism-analysis/processors/processor.rb +34 -0
- data/lib/exercism-analysis/processors/range_processor.rb +23 -0
- data/lib/exercism-analysis/processors/send_processor.rb +23 -0
- data/lib/exercism-analysis/templates/each_to_map.rb +29 -0
- data/lib/exercism-analysis/templates/each_to_select.rb +31 -0
- data/lib/exercism-analysis/templates/range_exclusive.rb +19 -0
- data/lib/exercism-analysis/templates/template.rb +29 -0
- data/vendor/clojure/kibit-runner/LICENSE +214 -0
- data/vendor/clojure/kibit-runner/project.clj +10 -0
- data/vendor/clojure/kibit-runner/src/kibit_runner/core.clj +17 -0
- data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT-standalone.jar +0 -0
- data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT.jar +0 -0
- data/vendor/clojure/kibit-runner/target/stale/extract-native.dependencies +1 -0
- data/vendor/go/src/github.com/golang/lint/LICENSE +27 -0
- data/vendor/go/src/github.com/golang/lint/README +59 -0
- data/vendor/go/src/github.com/golang/lint/golint/golint.go +67 -0
- data/vendor/go/src/github.com/golang/lint/lint.go +1061 -0
- data/vendor/go/src/runner/golint_runner.go +23 -0
- data/vendor/javascript/jshint_runner.js +6 -0
- data/vendor/javascript/node_modules/jshint/README.md +47 -0
- data/vendor/javascript/node_modules/jshint/bin/apply +6 -0
- data/vendor/javascript/node_modules/jshint/bin/build +36 -0
- data/vendor/javascript/node_modules/jshint/bin/changelog +36 -0
- data/vendor/javascript/node_modules/jshint/bin/jshint +3 -0
- data/vendor/javascript/node_modules/jshint/bin/land +34 -0
- data/vendor/javascript/node_modules/jshint/data/ascii-identifier-data.js +22 -0
- data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-part-only.js +1570 -0
- data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-start.js +48477 -0
- data/vendor/javascript/node_modules/jshint/dist/jshint-rhino.js +60642 -0
- data/vendor/javascript/node_modules/jshint/dist/jshint.js +60525 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/README.md +196 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/cli.js +1139 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/cat.js +17 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/command.js +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/echo.js +54 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/glob.js +6 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/long_desc.js +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/progress.js +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/sort.js +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/spinner.js +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.coffee +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.js +25 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/index.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/LICENSE +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/README.md +250 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/g.js +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/usr-local.js +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/glob.js +728 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/README.md +42 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/package.json +51 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/test.js +25 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/package.json +58 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/00-setup.js +176 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-comparison.js +63 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-results.json +351 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/cwd-test.js +55 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/globstar-match.js +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/mark.js +118 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/new-glob-optional-options.js +10 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/nocase-nomagic.js +113 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/pause-resume.js +73 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/readme-issue.js +36 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root-nomount.js +39 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root.js +46 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/stat.js +32 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/zz-cleanup.js +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/cli/package.json +70 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/LICENCE +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/README.md +33 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/index.js +86 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/LICENCE +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/README.md +45 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/index.js +5 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/package.json +89 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/seed.js +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/index.js +28 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/static/index.html +10 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/package.json +88 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/index.js +67 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/index.html +12 -0
- data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/test-adapter.js +53 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/Gruntfile.js +48 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/LICENSE-MIT +22 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/README.md +75 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/lib/exit.js +41 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/package.json +69 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/exit_test.js +121 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stderr.txt +10 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout-stderr.txt +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout.txt +10 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stderr.txt +100 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout-stderr.txt +200 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout.txt +100 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stderr.txt +1000 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout-stderr.txt +2000 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout.txt +1000 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/create-files.sh +8 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log-broken.js +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log.js +25 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/LICENSE +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/README.md +83 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/CollectingHandler.js +55 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/FeedHandler.js +95 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Parser.js +337 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/ProxyHandler.js +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Stream.js +35 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Tokenizer.js +891 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/WritableStream.js +21 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/index.js +68 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/LICENSE +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/index.js +14 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/package.json +40 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/readme.md +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/LICENSE +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/index.js +211 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/package.json +68 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/readme.md +102 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/01-basic.json +57 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/12-text_only.json +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/23-dom-lvl1.json +121 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/tests.js +58 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/LICENSE +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/index.js +14 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/helpers.js +141 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/legacy.js +87 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/manipulation.js +77 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/querying.js +94 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/stringify.js +93 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/traversal.js +24 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/package.json +71 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/readme.md +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/fixture.js +6 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/helpers.js +89 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/legacy.js +119 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/utils.js +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/LICENSE +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/index.js +31 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode.js +72 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode_codepoint.js +26 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/encode.js +48 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/decode.json +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/entities.json +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/legacy.json +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/xml.json +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/package.json +79 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/readme.md +31 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/mocha.opts +2 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/test.js +150 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/LICENSE +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/README.md +15 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/duplex.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/float.patch +923 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_readable.js +944 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_transform.js +209 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_writable.js +472 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/LICENSE +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/README.md +42 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits_browser.js +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/package.json +51 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/test.js +25 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/README.md +54 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/build/build.js +209 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/component.json +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/index.js +3 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/package.json +54 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/LICENSE +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/README.md +7 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/index.js +200 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/package.json +53 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/package.json +68 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/passthrough.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/readable.js +7 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/transform.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/writable.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/package.json +90 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/01-events.js +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/02-stream.js +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/03-feed.js +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Atom_Example.xml +25 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Attributes.html +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Basic.html +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RDF_Example.xml +63 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RSS_Example.xml +48 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/01-simple.json +44 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/02-template.json +63 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/03-lowercase_tags.json +46 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/04-cdata.json +50 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/05-cdata-special.json +35 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/06-leading-lt.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/07-self-closing.json +67 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/08-implicit-close-tags.json +59 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/09-attributes.json +68 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/10-crazy-attrib.json +52 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/11-script_in_script.json +54 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/12-long-comment-end.json +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/13-long-cdata-end.json +22 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/14-implicit-open-tags.json +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/15-lt-whitespace.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/16-double_attribs.json +45 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/17-numeric_entities.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/18-legacy_entities.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/19-named_entities.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/20-xml_entities.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/21-entity_in_attribute.json +38 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/22-double_brackets.json +41 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/23-legacy_entity_fail.json +16 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/24-special_special.json +133 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/25-empty_tag_name.json +13 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/26-not-quite-closed.json +35 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/27-entities_in_attributes.json +62 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/28-cdata_in_html.json +9 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/29-comment_edge-cases.json +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/30-cdata_edge-cases.json +22 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/01-rss.js +34 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/02-atom.js +18 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/03-rdf.js +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/01-basic.json +83 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/02-RSS.json +1093 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/03-Atom.json +644 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/04-RDF.json +1399 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/05-Attributes.json +354 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/api.js +63 -0
- data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/test-helper.js +83 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/LICENSE +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/README.md +218 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/minimatch.js +1061 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/package.json +50 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/package.json +58 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/package.json +57 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/brace-expand.js +33 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/caching.js +14 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/LICENSE +26 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/README.md +569 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/bin/shjs +51 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/global.js +3 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/make.js +47 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/package.json +61 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/generate-docs.js +21 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/run-tests.js +50 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/shell.js +157 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cat.js +43 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cd.js +19 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/chmod.js +208 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/common.js +203 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cp.js +201 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/dirs.js +191 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/echo.js +20 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/error.js +10 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/exec.js +181 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/find.js +51 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/grep.js +52 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ln.js +53 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ls.js +126 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mkdir.js +68 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mv.js +80 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/popd.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pushd.js +1 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pwd.js +11 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/rm.js +145 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/sed.js +43 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/tempdir.js +56 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/test.js +85 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/to.js +29 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/toEnd.js +29 -0
- data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/which.js +83 -0
- data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/cli.js +41 -0
- data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/package.json +76 -0
- data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/readme.md +74 -0
- data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/strip-json-comments.js +64 -0
- data/vendor/javascript/node_modules/jshint/node_modules/underscore/LICENSE +23 -0
- data/vendor/javascript/node_modules/jshint/node_modules/underscore/README.md +22 -0
- data/vendor/javascript/node_modules/jshint/node_modules/underscore/package.json +66 -0
- data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore-min.js +6 -0
- data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore.js +1343 -0
- data/vendor/javascript/node_modules/jshint/package.json +80 -0
- data/vendor/javascript/node_modules/jshint/src/cli.js +731 -0
- data/vendor/javascript/node_modules/jshint/src/jshint.js +5023 -0
- data/vendor/javascript/node_modules/jshint/src/lex.js +1650 -0
- data/vendor/javascript/node_modules/jshint/src/messages.js +223 -0
- data/vendor/javascript/node_modules/jshint/src/platforms/rhino.js +115 -0
- data/vendor/javascript/node_modules/jshint/src/reg.js +38 -0
- data/vendor/javascript/node_modules/jshint/src/reporters/checkstyle.js +81 -0
- data/vendor/javascript/node_modules/jshint/src/reporters/default.js +34 -0
- data/vendor/javascript/node_modules/jshint/src/reporters/jslint_xml.js +57 -0
- data/vendor/javascript/node_modules/jshint/src/reporters/non_error.js +52 -0
- data/vendor/javascript/node_modules/jshint/src/state.js +28 -0
- data/vendor/javascript/node_modules/jshint/src/style.js +143 -0
- data/vendor/javascript/node_modules/jshint/src/vars.js +658 -0
- data/vendor/python/astroid/COPYING +339 -0
- data/vendor/python/astroid/COPYING.LESSER +510 -0
- data/vendor/python/astroid/ChangeLog +574 -0
- data/vendor/python/astroid/MANIFEST.in +9 -0
- data/vendor/python/astroid/README +56 -0
- data/vendor/python/astroid/README.Python3 +26 -0
- data/vendor/python/astroid/__init__.py +118 -0
- data/vendor/python/astroid/__init__.pyc +0 -0
- data/vendor/python/astroid/__pkginfo__.py +48 -0
- data/vendor/python/astroid/__pkginfo__.pyc +0 -0
- data/vendor/python/astroid/announce.txt +23 -0
- data/vendor/python/astroid/as_string.py +496 -0
- data/vendor/python/astroid/as_string.pyc +0 -0
- data/vendor/python/astroid/bases.py +618 -0
- data/vendor/python/astroid/bases.pyc +0 -0
- data/vendor/python/astroid/brain/py2gi.py +159 -0
- data/vendor/python/astroid/brain/py2gi.pyc +0 -0
- data/vendor/python/astroid/brain/py2mechanize.py +20 -0
- data/vendor/python/astroid/brain/py2mechanize.pyc +0 -0
- data/vendor/python/astroid/brain/py2qt4.py +25 -0
- data/vendor/python/astroid/brain/py2qt4.pyc +0 -0
- data/vendor/python/astroid/brain/py2stdlib.py +252 -0
- data/vendor/python/astroid/brain/py2stdlib.pyc +0 -0
- data/vendor/python/astroid/builder.py +238 -0
- data/vendor/python/astroid/builder.pyc +0 -0
- data/vendor/python/astroid/exceptions.py +51 -0
- data/vendor/python/astroid/exceptions.pyc +0 -0
- data/vendor/python/astroid/inference.py +393 -0
- data/vendor/python/astroid/inference.pyc +0 -0
- data/vendor/python/astroid/inspector.py +275 -0
- data/vendor/python/astroid/manager.py +336 -0
- data/vendor/python/astroid/manager.pyc +0 -0
- data/vendor/python/astroid/mixins.py +122 -0
- data/vendor/python/astroid/mixins.pyc +0 -0
- data/vendor/python/astroid/node_classes.py +928 -0
- data/vendor/python/astroid/node_classes.pyc +0 -0
- data/vendor/python/astroid/nodes.py +73 -0
- data/vendor/python/astroid/nodes.pyc +0 -0
- data/vendor/python/astroid/protocols.py +322 -0
- data/vendor/python/astroid/protocols.pyc +0 -0
- data/vendor/python/astroid/raw_building.py +361 -0
- data/vendor/python/astroid/raw_building.pyc +0 -0
- data/vendor/python/astroid/rebuilder.py +954 -0
- data/vendor/python/astroid/rebuilder.pyc +0 -0
- data/vendor/python/astroid/scoped_nodes.py +1118 -0
- data/vendor/python/astroid/scoped_nodes.pyc +0 -0
- data/vendor/python/astroid/setup.py +184 -0
- data/vendor/python/astroid/tox.ini +10 -0
- data/vendor/python/astroid/utils.py +236 -0
- data/vendor/python/astroid/utils.pyc +0 -0
- data/vendor/python/logilab/__init__.py +0 -0
- data/vendor/python/logilab/__init__.pyc +0 -0
- data/vendor/python/logilab/common/COPYING +339 -0
- data/vendor/python/logilab/common/COPYING.LESSER +510 -0
- data/vendor/python/logilab/common/ChangeLog +1517 -0
- data/vendor/python/logilab/common/MANIFEST.in +13 -0
- data/vendor/python/logilab/common/README +185 -0
- data/vendor/python/logilab/common/README.Python3 +29 -0
- data/vendor/python/logilab/common/__init__.py +171 -0
- data/vendor/python/logilab/common/__init__.pyc +0 -0
- data/vendor/python/logilab/common/__pkginfo__.py +53 -0
- data/vendor/python/logilab/common/__pkginfo__.pyc +0 -0
- data/vendor/python/logilab/common/announce.txt +25 -0
- data/vendor/python/logilab/common/bin/pytest +7 -0
- data/vendor/python/logilab/common/bin/pytest.bat +17 -0
- data/vendor/python/logilab/common/cache.py +114 -0
- data/vendor/python/logilab/common/changelog.py +236 -0
- data/vendor/python/logilab/common/changelog.pyc +0 -0
- data/vendor/python/logilab/common/clcommands.py +332 -0
- data/vendor/python/logilab/common/cli.py +208 -0
- data/vendor/python/logilab/common/compat.py +243 -0
- data/vendor/python/logilab/common/compat.pyc +0 -0
- data/vendor/python/logilab/common/configuration.py +1094 -0
- data/vendor/python/logilab/common/configuration.pyc +0 -0
- data/vendor/python/logilab/common/contexts.py +5 -0
- data/vendor/python/logilab/common/corbautils.py +117 -0
- data/vendor/python/logilab/common/daemon.py +100 -0
- data/vendor/python/logilab/common/date.py +333 -0
- data/vendor/python/logilab/common/dbf.py +229 -0
- data/vendor/python/logilab/common/debugger.py +210 -0
- data/vendor/python/logilab/common/decorators.py +281 -0
- data/vendor/python/logilab/common/decorators.pyc +0 -0
- data/vendor/python/logilab/common/deprecation.py +188 -0
- data/vendor/python/logilab/common/deprecation.pyc +0 -0
- data/vendor/python/logilab/common/fileutils.py +402 -0
- data/vendor/python/logilab/common/graph.py +276 -0
- data/vendor/python/logilab/common/graph.pyc +0 -0
- data/vendor/python/logilab/common/hg.py +130 -0
- data/vendor/python/logilab/common/interface.py +71 -0
- data/vendor/python/logilab/common/interface.pyc +0 -0
- data/vendor/python/logilab/common/logging_ext.py +193 -0
- data/vendor/python/logilab/common/modutils.py +695 -0
- data/vendor/python/logilab/common/modutils.pyc +0 -0
- data/vendor/python/logilab/common/optik_ext.py +391 -0
- data/vendor/python/logilab/common/optik_ext.pyc +0 -0
- data/vendor/python/logilab/common/optparser.py +90 -0
- data/vendor/python/logilab/common/proc.py +277 -0
- data/vendor/python/logilab/common/pyro_ext.py +180 -0
- data/vendor/python/logilab/common/pytest.py +1177 -0
- data/vendor/python/logilab/common/python-logilab-common.spec +184 -0
- data/vendor/python/logilab/common/registry.py +1113 -0
- data/vendor/python/logilab/common/setup.cfg +3 -0
- data/vendor/python/logilab/common/setup.py +189 -0
- data/vendor/python/logilab/common/shellutils.py +455 -0
- data/vendor/python/logilab/common/sphinx_ext.py +87 -0
- data/vendor/python/logilab/common/sphinxutils.py +122 -0
- data/vendor/python/logilab/common/table.py +925 -0
- data/vendor/python/logilab/common/tasksqueue.py +100 -0
- data/vendor/python/logilab/common/textutils.py +534 -0
- data/vendor/python/logilab/common/textutils.pyc +0 -0
- data/vendor/python/logilab/common/tree.py +369 -0
- data/vendor/python/logilab/common/tree.pyc +0 -0
- data/vendor/python/logilab/common/umessage.py +190 -0
- data/vendor/python/logilab/common/ureports/__init__.py +174 -0
- data/vendor/python/logilab/common/ureports/__init__.pyc +0 -0
- data/vendor/python/logilab/common/ureports/docbook_writer.py +139 -0
- data/vendor/python/logilab/common/ureports/html_writer.py +131 -0
- data/vendor/python/logilab/common/ureports/html_writer.pyc +0 -0
- data/vendor/python/logilab/common/ureports/nodes.py +201 -0
- data/vendor/python/logilab/common/ureports/nodes.pyc +0 -0
- data/vendor/python/logilab/common/ureports/text_writer.py +140 -0
- data/vendor/python/logilab/common/ureports/text_writer.pyc +0 -0
- data/vendor/python/logilab/common/urllib2ext.py +87 -0
- data/vendor/python/logilab/common/vcgutils.py +216 -0
- data/vendor/python/logilab/common/visitor.py +107 -0
- data/vendor/python/logilab/common/visitor.pyc +0 -0
- data/vendor/python/logilab/common/xmlrpcutils.py +131 -0
- data/vendor/python/logilab/common/xmlutils.py +61 -0
- data/vendor/python/pylint/CONTRIBUTORS.txt +38 -0
- data/vendor/python/pylint/COPYING +340 -0
- data/vendor/python/pylint/ChangeLog +1437 -0
- data/vendor/python/pylint/DEPENDS +3 -0
- data/vendor/python/pylint/MANIFEST.in +14 -0
- data/vendor/python/pylint/README +50 -0
- data/vendor/python/pylint/README.Python3 +37 -0
- data/vendor/python/pylint/__init__.py +44 -0
- data/vendor/python/pylint/__init__.pyc +0 -0
- data/vendor/python/pylint/__main__.py +3 -0
- data/vendor/python/pylint/__pkginfo__.py +74 -0
- data/vendor/python/pylint/__pkginfo__.pyc +0 -0
- data/vendor/python/pylint/bin/epylint +3 -0
- data/vendor/python/pylint/bin/epylint.bat +5 -0
- data/vendor/python/pylint/bin/pylint +3 -0
- data/vendor/python/pylint/bin/pylint-gui +3 -0
- data/vendor/python/pylint/bin/pylint-gui.bat +5 -0
- data/vendor/python/pylint/bin/pylint.bat +5 -0
- data/vendor/python/pylint/bin/pyreverse +3 -0
- data/vendor/python/pylint/bin/pyreverse.bat +5 -0
- data/vendor/python/pylint/bin/symilar +3 -0
- data/vendor/python/pylint/bin/symilar.bat +5 -0
- data/vendor/python/pylint/checkers/__init__.py +145 -0
- data/vendor/python/pylint/checkers/__init__.pyc +0 -0
- data/vendor/python/pylint/checkers/base.py +1141 -0
- data/vendor/python/pylint/checkers/base.pyc +0 -0
- data/vendor/python/pylint/checkers/classes.py +792 -0
- data/vendor/python/pylint/checkers/classes.pyc +0 -0
- data/vendor/python/pylint/checkers/design_analysis.py +367 -0
- data/vendor/python/pylint/checkers/design_analysis.pyc +0 -0
- data/vendor/python/pylint/checkers/exceptions.py +306 -0
- data/vendor/python/pylint/checkers/exceptions.pyc +0 -0
- data/vendor/python/pylint/checkers/format.py +943 -0
- data/vendor/python/pylint/checkers/format.pyc +0 -0
- data/vendor/python/pylint/checkers/imports.py +394 -0
- data/vendor/python/pylint/checkers/imports.pyc +0 -0
- data/vendor/python/pylint/checkers/logging.py +213 -0
- data/vendor/python/pylint/checkers/logging.pyc +0 -0
- data/vendor/python/pylint/checkers/misc.py +90 -0
- data/vendor/python/pylint/checkers/misc.pyc +0 -0
- data/vendor/python/pylint/checkers/newstyle.py +151 -0
- data/vendor/python/pylint/checkers/newstyle.pyc +0 -0
- data/vendor/python/pylint/checkers/raw_metrics.py +129 -0
- data/vendor/python/pylint/checkers/raw_metrics.pyc +0 -0
- data/vendor/python/pylint/checkers/similar.py +365 -0
- data/vendor/python/pylint/checkers/similar.pyc +0 -0
- data/vendor/python/pylint/checkers/stdlib.py +69 -0
- data/vendor/python/pylint/checkers/stdlib.pyc +0 -0
- data/vendor/python/pylint/checkers/strings.py +304 -0
- data/vendor/python/pylint/checkers/strings.pyc +0 -0
- data/vendor/python/pylint/checkers/typecheck.py +451 -0
- data/vendor/python/pylint/checkers/typecheck.pyc +0 -0
- data/vendor/python/pylint/checkers/utils.py +416 -0
- data/vendor/python/pylint/checkers/utils.pyc +0 -0
- data/vendor/python/pylint/checkers/variables.py +741 -0
- data/vendor/python/pylint/checkers/variables.pyc +0 -0
- data/vendor/python/pylint/config.py +156 -0
- data/vendor/python/pylint/config.pyc +0 -0
- data/vendor/python/pylint/epylint.py +175 -0
- data/vendor/python/pylint/gui.py +508 -0
- data/vendor/python/pylint/interfaces.py +72 -0
- data/vendor/python/pylint/interfaces.pyc +0 -0
- data/vendor/python/pylint/lint.py +1106 -0
- data/vendor/python/pylint/lint.pyc +0 -0
- data/vendor/python/pylint/pyreverse/__init__.py +5 -0
- data/vendor/python/pylint/pyreverse/diadefslib.py +233 -0
- data/vendor/python/pylint/pyreverse/diagrams.py +247 -0
- data/vendor/python/pylint/pyreverse/main.py +124 -0
- data/vendor/python/pylint/pyreverse/utils.py +131 -0
- data/vendor/python/pylint/pyreverse/writer.py +199 -0
- data/vendor/python/pylint/reporters/__init__.py +138 -0
- data/vendor/python/pylint/reporters/__init__.pyc +0 -0
- data/vendor/python/pylint/reporters/guireporter.py +28 -0
- data/vendor/python/pylint/reporters/guireporter.pyc +0 -0
- data/vendor/python/pylint/reporters/html.py +70 -0
- data/vendor/python/pylint/reporters/html.pyc +0 -0
- data/vendor/python/pylint/reporters/text.py +143 -0
- data/vendor/python/pylint/reporters/text.pyc +0 -0
- data/vendor/python/pylint/setup.cfg +3 -0
- data/vendor/python/pylint/setup.py +203 -0
- data/vendor/python/pylint/tox.ini +10 -0
- data/vendor/python/pylint/utils.py +744 -0
- data/vendor/python/pylint/utils.pyc +0 -0
- data/vendor/python/pylint_runner.py +22 -0
- metadata +675 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
# strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments)
|
2
|
+
|
3
|
+
> Strip comments from JSON. Lets you use comments in your JSON files!
|
4
|
+
|
5
|
+
This is now possible:
|
6
|
+
|
7
|
+
```js
|
8
|
+
{
|
9
|
+
// rainbows
|
10
|
+
"unicorn": /* ❤ */ "cake"
|
11
|
+
}
|
12
|
+
```
|
13
|
+
|
14
|
+
It will remove single-line comments `//` and mult-line comments `/**/`.
|
15
|
+
|
16
|
+
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).
|
17
|
+
|
18
|
+
|
19
|
+
*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.*
|
20
|
+
|
21
|
+
|
22
|
+
## Install
|
23
|
+
|
24
|
+
```sh
|
25
|
+
$ npm install --save strip-json-comments
|
26
|
+
```
|
27
|
+
|
28
|
+
```sh
|
29
|
+
$ bower install --save strip-json-comments
|
30
|
+
```
|
31
|
+
|
32
|
+
```sh
|
33
|
+
$ component install sindresorhus/strip-json-comments
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
```js
|
40
|
+
var json = '{/*rainbows*/"unicorn":"cake"}';
|
41
|
+
JSON.parse(stripJsonComments(json));
|
42
|
+
//=> {unicorn: 'cake'}
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
## API
|
47
|
+
|
48
|
+
### stripJsonComments(input)
|
49
|
+
|
50
|
+
#### input
|
51
|
+
|
52
|
+
Type: `string`
|
53
|
+
|
54
|
+
Accepts a string with JSON and returns a string without comments.
|
55
|
+
|
56
|
+
|
57
|
+
## CLI
|
58
|
+
|
59
|
+
```sh
|
60
|
+
$ npm install --global strip-json-comments
|
61
|
+
```
|
62
|
+
|
63
|
+
```sh
|
64
|
+
$ strip-json-comments --help
|
65
|
+
|
66
|
+
strip-json-comments <input-file> > <output-file>
|
67
|
+
# or
|
68
|
+
cat <input-file> | strip-json-comments > <output-file>
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/strip-json-comments.js
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
/*!
|
2
|
+
strip-json-comments
|
3
|
+
Strip comments from JSON. Lets you use comments in your JSON files!
|
4
|
+
https://github.com/sindresorhus/strip-json-comments
|
5
|
+
by Sindre Sorhus
|
6
|
+
MIT License
|
7
|
+
*/
|
8
|
+
(function () {
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
function stripJsonComments(str) {
|
12
|
+
var currentChar;
|
13
|
+
var nextChar;
|
14
|
+
var insideString = false;
|
15
|
+
var insideComment = false;
|
16
|
+
var ret = '';
|
17
|
+
|
18
|
+
for (var i = 0; i < str.length; i++) {
|
19
|
+
currentChar = str[i];
|
20
|
+
nextChar = str[i + 1];
|
21
|
+
|
22
|
+
if (!insideComment && str[i - 1] !== '\\' && currentChar === '"') {
|
23
|
+
insideString = !insideString;
|
24
|
+
}
|
25
|
+
|
26
|
+
if (insideString) {
|
27
|
+
ret += currentChar;
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
|
31
|
+
if (!insideComment && currentChar + nextChar === '//') {
|
32
|
+
insideComment = 'single';
|
33
|
+
i++;
|
34
|
+
} else if (insideComment === 'single' && currentChar + nextChar === '\r\n') {
|
35
|
+
insideComment = false;
|
36
|
+
i++;
|
37
|
+
} else if (insideComment === 'single' && currentChar === '\n') {
|
38
|
+
insideComment = false;
|
39
|
+
} else if (!insideComment && currentChar + nextChar === '/*') {
|
40
|
+
insideComment = 'multi';
|
41
|
+
i++;
|
42
|
+
continue;
|
43
|
+
} else if (insideComment === 'multi' && currentChar + nextChar === '*/') {
|
44
|
+
insideComment = false;
|
45
|
+
i++;
|
46
|
+
continue;
|
47
|
+
}
|
48
|
+
|
49
|
+
if (insideComment) {
|
50
|
+
continue;
|
51
|
+
}
|
52
|
+
|
53
|
+
ret += currentChar;
|
54
|
+
}
|
55
|
+
|
56
|
+
return ret;
|
57
|
+
}
|
58
|
+
|
59
|
+
if (typeof module !== 'undefined' && module.exports) {
|
60
|
+
module.exports = stripJsonComments;
|
61
|
+
} else {
|
62
|
+
window.stripJsonComments = stripJsonComments;
|
63
|
+
}
|
64
|
+
})();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
|
2
|
+
Reporters & Editors
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
__
|
2
|
+
/\ \ __
|
3
|
+
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
4
|
+
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
5
|
+
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
6
|
+
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
7
|
+
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
8
|
+
\ \____/
|
9
|
+
\/___/
|
10
|
+
|
11
|
+
Underscore.js is a utility-belt library for JavaScript that provides
|
12
|
+
support for the usual functional suspects (each, map, reduce, filter...)
|
13
|
+
without extending any core JavaScript objects.
|
14
|
+
|
15
|
+
For Docs, License, Tests, and pre-packed downloads, see:
|
16
|
+
http://underscorejs.org
|
17
|
+
|
18
|
+
Underscore is an open-sourced component of DocumentCloud:
|
19
|
+
https://github.com/documentcloud
|
20
|
+
|
21
|
+
Many thanks to our contributors:
|
22
|
+
https://github.com/jashkenas/underscore/contributors
|
@@ -0,0 +1,66 @@
|
|
1
|
+
{
|
2
|
+
"name": "underscore",
|
3
|
+
"description": "JavaScript's functional programming helper library.",
|
4
|
+
"homepage": "http://underscorejs.org",
|
5
|
+
"keywords": [
|
6
|
+
"util",
|
7
|
+
"functional",
|
8
|
+
"server",
|
9
|
+
"client",
|
10
|
+
"browser"
|
11
|
+
],
|
12
|
+
"author": {
|
13
|
+
"name": "Jeremy Ashkenas",
|
14
|
+
"email": "jeremy@documentcloud.org"
|
15
|
+
},
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "git://github.com/jashkenas/underscore.git"
|
19
|
+
},
|
20
|
+
"main": "underscore.js",
|
21
|
+
"version": "1.6.0",
|
22
|
+
"devDependencies": {
|
23
|
+
"docco": "0.6.x",
|
24
|
+
"phantomjs": "1.9.0-1",
|
25
|
+
"uglify-js": "2.4.x"
|
26
|
+
},
|
27
|
+
"scripts": {
|
28
|
+
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true",
|
29
|
+
"build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js",
|
30
|
+
"doc": "docco underscore.js"
|
31
|
+
},
|
32
|
+
"licenses": [
|
33
|
+
{
|
34
|
+
"type": "MIT",
|
35
|
+
"url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"files": [
|
39
|
+
"underscore.js",
|
40
|
+
"underscore-min.js",
|
41
|
+
"LICENSE"
|
42
|
+
],
|
43
|
+
"bugs": {
|
44
|
+
"url": "https://github.com/jashkenas/underscore/issues"
|
45
|
+
},
|
46
|
+
"_id": "underscore@1.6.0",
|
47
|
+
"dist": {
|
48
|
+
"shasum": "8b38b10cacdef63337b8b24e4ff86d45aea529a8",
|
49
|
+
"tarball": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz"
|
50
|
+
},
|
51
|
+
"_from": "underscore@1.6.x",
|
52
|
+
"_npmVersion": "1.3.21",
|
53
|
+
"_npmUser": {
|
54
|
+
"name": "jashkenas",
|
55
|
+
"email": "jashkenas@gmail.com"
|
56
|
+
},
|
57
|
+
"maintainers": [
|
58
|
+
{
|
59
|
+
"name": "jashkenas",
|
60
|
+
"email": "jashkenas@gmail.com"
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"directories": {},
|
64
|
+
"_shasum": "8b38b10cacdef63337b8b24e4ff86d45aea529a8",
|
65
|
+
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz"
|
66
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// Underscore.js 1.6.0
|
2
|
+
// http://underscorejs.org
|
3
|
+
// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
4
|
+
// Underscore may be freely distributed under the MIT license.
|
5
|
+
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:j.now(),a=null,i=n.apply(e,u),e=u=null};return function(){var l=j.now();o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this);
|
6
|
+
//# sourceMappingURL=underscore-min.map
|
@@ -0,0 +1,1343 @@
|
|
1
|
+
// Underscore.js 1.6.0
|
2
|
+
// http://underscorejs.org
|
3
|
+
// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
4
|
+
// Underscore may be freely distributed under the MIT license.
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
|
8
|
+
// Baseline setup
|
9
|
+
// --------------
|
10
|
+
|
11
|
+
// Establish the root object, `window` in the browser, or `exports` on the server.
|
12
|
+
var root = this;
|
13
|
+
|
14
|
+
// Save the previous value of the `_` variable.
|
15
|
+
var previousUnderscore = root._;
|
16
|
+
|
17
|
+
// Establish the object that gets returned to break out of a loop iteration.
|
18
|
+
var breaker = {};
|
19
|
+
|
20
|
+
// Save bytes in the minified (but not gzipped) version:
|
21
|
+
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
|
22
|
+
|
23
|
+
// Create quick reference variables for speed access to core prototypes.
|
24
|
+
var
|
25
|
+
push = ArrayProto.push,
|
26
|
+
slice = ArrayProto.slice,
|
27
|
+
concat = ArrayProto.concat,
|
28
|
+
toString = ObjProto.toString,
|
29
|
+
hasOwnProperty = ObjProto.hasOwnProperty;
|
30
|
+
|
31
|
+
// All **ECMAScript 5** native function implementations that we hope to use
|
32
|
+
// are declared here.
|
33
|
+
var
|
34
|
+
nativeForEach = ArrayProto.forEach,
|
35
|
+
nativeMap = ArrayProto.map,
|
36
|
+
nativeReduce = ArrayProto.reduce,
|
37
|
+
nativeReduceRight = ArrayProto.reduceRight,
|
38
|
+
nativeFilter = ArrayProto.filter,
|
39
|
+
nativeEvery = ArrayProto.every,
|
40
|
+
nativeSome = ArrayProto.some,
|
41
|
+
nativeIndexOf = ArrayProto.indexOf,
|
42
|
+
nativeLastIndexOf = ArrayProto.lastIndexOf,
|
43
|
+
nativeIsArray = Array.isArray,
|
44
|
+
nativeKeys = Object.keys,
|
45
|
+
nativeBind = FuncProto.bind;
|
46
|
+
|
47
|
+
// Create a safe reference to the Underscore object for use below.
|
48
|
+
var _ = function(obj) {
|
49
|
+
if (obj instanceof _) return obj;
|
50
|
+
if (!(this instanceof _)) return new _(obj);
|
51
|
+
this._wrapped = obj;
|
52
|
+
};
|
53
|
+
|
54
|
+
// Export the Underscore object for **Node.js**, with
|
55
|
+
// backwards-compatibility for the old `require()` API. If we're in
|
56
|
+
// the browser, add `_` as a global object via a string identifier,
|
57
|
+
// for Closure Compiler "advanced" mode.
|
58
|
+
if (typeof exports !== 'undefined') {
|
59
|
+
if (typeof module !== 'undefined' && module.exports) {
|
60
|
+
exports = module.exports = _;
|
61
|
+
}
|
62
|
+
exports._ = _;
|
63
|
+
} else {
|
64
|
+
root._ = _;
|
65
|
+
}
|
66
|
+
|
67
|
+
// Current version.
|
68
|
+
_.VERSION = '1.6.0';
|
69
|
+
|
70
|
+
// Collection Functions
|
71
|
+
// --------------------
|
72
|
+
|
73
|
+
// The cornerstone, an `each` implementation, aka `forEach`.
|
74
|
+
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
75
|
+
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
76
|
+
var each = _.each = _.forEach = function(obj, iterator, context) {
|
77
|
+
if (obj == null) return obj;
|
78
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
79
|
+
obj.forEach(iterator, context);
|
80
|
+
} else if (obj.length === +obj.length) {
|
81
|
+
for (var i = 0, length = obj.length; i < length; i++) {
|
82
|
+
if (iterator.call(context, obj[i], i, obj) === breaker) return;
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
var keys = _.keys(obj);
|
86
|
+
for (var i = 0, length = keys.length; i < length; i++) {
|
87
|
+
if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return obj;
|
91
|
+
};
|
92
|
+
|
93
|
+
// Return the results of applying the iterator to each element.
|
94
|
+
// Delegates to **ECMAScript 5**'s native `map` if available.
|
95
|
+
_.map = _.collect = function(obj, iterator, context) {
|
96
|
+
var results = [];
|
97
|
+
if (obj == null) return results;
|
98
|
+
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
|
99
|
+
each(obj, function(value, index, list) {
|
100
|
+
results.push(iterator.call(context, value, index, list));
|
101
|
+
});
|
102
|
+
return results;
|
103
|
+
};
|
104
|
+
|
105
|
+
var reduceError = 'Reduce of empty array with no initial value';
|
106
|
+
|
107
|
+
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
108
|
+
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
109
|
+
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
110
|
+
var initial = arguments.length > 2;
|
111
|
+
if (obj == null) obj = [];
|
112
|
+
if (nativeReduce && obj.reduce === nativeReduce) {
|
113
|
+
if (context) iterator = _.bind(iterator, context);
|
114
|
+
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
|
115
|
+
}
|
116
|
+
each(obj, function(value, index, list) {
|
117
|
+
if (!initial) {
|
118
|
+
memo = value;
|
119
|
+
initial = true;
|
120
|
+
} else {
|
121
|
+
memo = iterator.call(context, memo, value, index, list);
|
122
|
+
}
|
123
|
+
});
|
124
|
+
if (!initial) throw new TypeError(reduceError);
|
125
|
+
return memo;
|
126
|
+
};
|
127
|
+
|
128
|
+
// The right-associative version of reduce, also known as `foldr`.
|
129
|
+
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
|
130
|
+
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
|
131
|
+
var initial = arguments.length > 2;
|
132
|
+
if (obj == null) obj = [];
|
133
|
+
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
|
134
|
+
if (context) iterator = _.bind(iterator, context);
|
135
|
+
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
|
136
|
+
}
|
137
|
+
var length = obj.length;
|
138
|
+
if (length !== +length) {
|
139
|
+
var keys = _.keys(obj);
|
140
|
+
length = keys.length;
|
141
|
+
}
|
142
|
+
each(obj, function(value, index, list) {
|
143
|
+
index = keys ? keys[--length] : --length;
|
144
|
+
if (!initial) {
|
145
|
+
memo = obj[index];
|
146
|
+
initial = true;
|
147
|
+
} else {
|
148
|
+
memo = iterator.call(context, memo, obj[index], index, list);
|
149
|
+
}
|
150
|
+
});
|
151
|
+
if (!initial) throw new TypeError(reduceError);
|
152
|
+
return memo;
|
153
|
+
};
|
154
|
+
|
155
|
+
// Return the first value which passes a truth test. Aliased as `detect`.
|
156
|
+
_.find = _.detect = function(obj, predicate, context) {
|
157
|
+
var result;
|
158
|
+
any(obj, function(value, index, list) {
|
159
|
+
if (predicate.call(context, value, index, list)) {
|
160
|
+
result = value;
|
161
|
+
return true;
|
162
|
+
}
|
163
|
+
});
|
164
|
+
return result;
|
165
|
+
};
|
166
|
+
|
167
|
+
// Return all the elements that pass a truth test.
|
168
|
+
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
169
|
+
// Aliased as `select`.
|
170
|
+
_.filter = _.select = function(obj, predicate, context) {
|
171
|
+
var results = [];
|
172
|
+
if (obj == null) return results;
|
173
|
+
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context);
|
174
|
+
each(obj, function(value, index, list) {
|
175
|
+
if (predicate.call(context, value, index, list)) results.push(value);
|
176
|
+
});
|
177
|
+
return results;
|
178
|
+
};
|
179
|
+
|
180
|
+
// Return all the elements for which a truth test fails.
|
181
|
+
_.reject = function(obj, predicate, context) {
|
182
|
+
return _.filter(obj, function(value, index, list) {
|
183
|
+
return !predicate.call(context, value, index, list);
|
184
|
+
}, context);
|
185
|
+
};
|
186
|
+
|
187
|
+
// Determine whether all of the elements match a truth test.
|
188
|
+
// Delegates to **ECMAScript 5**'s native `every` if available.
|
189
|
+
// Aliased as `all`.
|
190
|
+
_.every = _.all = function(obj, predicate, context) {
|
191
|
+
predicate || (predicate = _.identity);
|
192
|
+
var result = true;
|
193
|
+
if (obj == null) return result;
|
194
|
+
if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context);
|
195
|
+
each(obj, function(value, index, list) {
|
196
|
+
if (!(result = result && predicate.call(context, value, index, list))) return breaker;
|
197
|
+
});
|
198
|
+
return !!result;
|
199
|
+
};
|
200
|
+
|
201
|
+
// Determine if at least one element in the object matches a truth test.
|
202
|
+
// Delegates to **ECMAScript 5**'s native `some` if available.
|
203
|
+
// Aliased as `any`.
|
204
|
+
var any = _.some = _.any = function(obj, predicate, context) {
|
205
|
+
predicate || (predicate = _.identity);
|
206
|
+
var result = false;
|
207
|
+
if (obj == null) return result;
|
208
|
+
if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context);
|
209
|
+
each(obj, function(value, index, list) {
|
210
|
+
if (result || (result = predicate.call(context, value, index, list))) return breaker;
|
211
|
+
});
|
212
|
+
return !!result;
|
213
|
+
};
|
214
|
+
|
215
|
+
// Determine if the array or object contains a given value (using `===`).
|
216
|
+
// Aliased as `include`.
|
217
|
+
_.contains = _.include = function(obj, target) {
|
218
|
+
if (obj == null) return false;
|
219
|
+
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
|
220
|
+
return any(obj, function(value) {
|
221
|
+
return value === target;
|
222
|
+
});
|
223
|
+
};
|
224
|
+
|
225
|
+
// Invoke a method (with arguments) on every item in a collection.
|
226
|
+
_.invoke = function(obj, method) {
|
227
|
+
var args = slice.call(arguments, 2);
|
228
|
+
var isFunc = _.isFunction(method);
|
229
|
+
return _.map(obj, function(value) {
|
230
|
+
return (isFunc ? method : value[method]).apply(value, args);
|
231
|
+
});
|
232
|
+
};
|
233
|
+
|
234
|
+
// Convenience version of a common use case of `map`: fetching a property.
|
235
|
+
_.pluck = function(obj, key) {
|
236
|
+
return _.map(obj, _.property(key));
|
237
|
+
};
|
238
|
+
|
239
|
+
// Convenience version of a common use case of `filter`: selecting only objects
|
240
|
+
// containing specific `key:value` pairs.
|
241
|
+
_.where = function(obj, attrs) {
|
242
|
+
return _.filter(obj, _.matches(attrs));
|
243
|
+
};
|
244
|
+
|
245
|
+
// Convenience version of a common use case of `find`: getting the first object
|
246
|
+
// containing specific `key:value` pairs.
|
247
|
+
_.findWhere = function(obj, attrs) {
|
248
|
+
return _.find(obj, _.matches(attrs));
|
249
|
+
};
|
250
|
+
|
251
|
+
// Return the maximum element or (element-based computation).
|
252
|
+
// Can't optimize arrays of integers longer than 65,535 elements.
|
253
|
+
// See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797)
|
254
|
+
_.max = function(obj, iterator, context) {
|
255
|
+
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
256
|
+
return Math.max.apply(Math, obj);
|
257
|
+
}
|
258
|
+
var result = -Infinity, lastComputed = -Infinity;
|
259
|
+
each(obj, function(value, index, list) {
|
260
|
+
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
261
|
+
if (computed > lastComputed) {
|
262
|
+
result = value;
|
263
|
+
lastComputed = computed;
|
264
|
+
}
|
265
|
+
});
|
266
|
+
return result;
|
267
|
+
};
|
268
|
+
|
269
|
+
// Return the minimum element (or element-based computation).
|
270
|
+
_.min = function(obj, iterator, context) {
|
271
|
+
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
272
|
+
return Math.min.apply(Math, obj);
|
273
|
+
}
|
274
|
+
var result = Infinity, lastComputed = Infinity;
|
275
|
+
each(obj, function(value, index, list) {
|
276
|
+
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
277
|
+
if (computed < lastComputed) {
|
278
|
+
result = value;
|
279
|
+
lastComputed = computed;
|
280
|
+
}
|
281
|
+
});
|
282
|
+
return result;
|
283
|
+
};
|
284
|
+
|
285
|
+
// Shuffle an array, using the modern version of the
|
286
|
+
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
287
|
+
_.shuffle = function(obj) {
|
288
|
+
var rand;
|
289
|
+
var index = 0;
|
290
|
+
var shuffled = [];
|
291
|
+
each(obj, function(value) {
|
292
|
+
rand = _.random(index++);
|
293
|
+
shuffled[index - 1] = shuffled[rand];
|
294
|
+
shuffled[rand] = value;
|
295
|
+
});
|
296
|
+
return shuffled;
|
297
|
+
};
|
298
|
+
|
299
|
+
// Sample **n** random values from a collection.
|
300
|
+
// If **n** is not specified, returns a single random element.
|
301
|
+
// The internal `guard` argument allows it to work with `map`.
|
302
|
+
_.sample = function(obj, n, guard) {
|
303
|
+
if (n == null || guard) {
|
304
|
+
if (obj.length !== +obj.length) obj = _.values(obj);
|
305
|
+
return obj[_.random(obj.length - 1)];
|
306
|
+
}
|
307
|
+
return _.shuffle(obj).slice(0, Math.max(0, n));
|
308
|
+
};
|
309
|
+
|
310
|
+
// An internal function to generate lookup iterators.
|
311
|
+
var lookupIterator = function(value) {
|
312
|
+
if (value == null) return _.identity;
|
313
|
+
if (_.isFunction(value)) return value;
|
314
|
+
return _.property(value);
|
315
|
+
};
|
316
|
+
|
317
|
+
// Sort the object's values by a criterion produced by an iterator.
|
318
|
+
_.sortBy = function(obj, iterator, context) {
|
319
|
+
iterator = lookupIterator(iterator);
|
320
|
+
return _.pluck(_.map(obj, function(value, index, list) {
|
321
|
+
return {
|
322
|
+
value: value,
|
323
|
+
index: index,
|
324
|
+
criteria: iterator.call(context, value, index, list)
|
325
|
+
};
|
326
|
+
}).sort(function(left, right) {
|
327
|
+
var a = left.criteria;
|
328
|
+
var b = right.criteria;
|
329
|
+
if (a !== b) {
|
330
|
+
if (a > b || a === void 0) return 1;
|
331
|
+
if (a < b || b === void 0) return -1;
|
332
|
+
}
|
333
|
+
return left.index - right.index;
|
334
|
+
}), 'value');
|
335
|
+
};
|
336
|
+
|
337
|
+
// An internal function used for aggregate "group by" operations.
|
338
|
+
var group = function(behavior) {
|
339
|
+
return function(obj, iterator, context) {
|
340
|
+
var result = {};
|
341
|
+
iterator = lookupIterator(iterator);
|
342
|
+
each(obj, function(value, index) {
|
343
|
+
var key = iterator.call(context, value, index, obj);
|
344
|
+
behavior(result, key, value);
|
345
|
+
});
|
346
|
+
return result;
|
347
|
+
};
|
348
|
+
};
|
349
|
+
|
350
|
+
// Groups the object's values by a criterion. Pass either a string attribute
|
351
|
+
// to group by, or a function that returns the criterion.
|
352
|
+
_.groupBy = group(function(result, key, value) {
|
353
|
+
_.has(result, key) ? result[key].push(value) : result[key] = [value];
|
354
|
+
});
|
355
|
+
|
356
|
+
// Indexes the object's values by a criterion, similar to `groupBy`, but for
|
357
|
+
// when you know that your index values will be unique.
|
358
|
+
_.indexBy = group(function(result, key, value) {
|
359
|
+
result[key] = value;
|
360
|
+
});
|
361
|
+
|
362
|
+
// Counts instances of an object that group by a certain criterion. Pass
|
363
|
+
// either a string attribute to count by, or a function that returns the
|
364
|
+
// criterion.
|
365
|
+
_.countBy = group(function(result, key) {
|
366
|
+
_.has(result, key) ? result[key]++ : result[key] = 1;
|
367
|
+
});
|
368
|
+
|
369
|
+
// Use a comparator function to figure out the smallest index at which
|
370
|
+
// an object should be inserted so as to maintain order. Uses binary search.
|
371
|
+
_.sortedIndex = function(array, obj, iterator, context) {
|
372
|
+
iterator = lookupIterator(iterator);
|
373
|
+
var value = iterator.call(context, obj);
|
374
|
+
var low = 0, high = array.length;
|
375
|
+
while (low < high) {
|
376
|
+
var mid = (low + high) >>> 1;
|
377
|
+
iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
|
378
|
+
}
|
379
|
+
return low;
|
380
|
+
};
|
381
|
+
|
382
|
+
// Safely create a real, live array from anything iterable.
|
383
|
+
_.toArray = function(obj) {
|
384
|
+
if (!obj) return [];
|
385
|
+
if (_.isArray(obj)) return slice.call(obj);
|
386
|
+
if (obj.length === +obj.length) return _.map(obj, _.identity);
|
387
|
+
return _.values(obj);
|
388
|
+
};
|
389
|
+
|
390
|
+
// Return the number of elements in an object.
|
391
|
+
_.size = function(obj) {
|
392
|
+
if (obj == null) return 0;
|
393
|
+
return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
|
394
|
+
};
|
395
|
+
|
396
|
+
// Array Functions
|
397
|
+
// ---------------
|
398
|
+
|
399
|
+
// Get the first element of an array. Passing **n** will return the first N
|
400
|
+
// values in the array. Aliased as `head` and `take`. The **guard** check
|
401
|
+
// allows it to work with `_.map`.
|
402
|
+
_.first = _.head = _.take = function(array, n, guard) {
|
403
|
+
if (array == null) return void 0;
|
404
|
+
if ((n == null) || guard) return array[0];
|
405
|
+
if (n < 0) return [];
|
406
|
+
return slice.call(array, 0, n);
|
407
|
+
};
|
408
|
+
|
409
|
+
// Returns everything but the last entry of the array. Especially useful on
|
410
|
+
// the arguments object. Passing **n** will return all the values in
|
411
|
+
// the array, excluding the last N. The **guard** check allows it to work with
|
412
|
+
// `_.map`.
|
413
|
+
_.initial = function(array, n, guard) {
|
414
|
+
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
|
415
|
+
};
|
416
|
+
|
417
|
+
// Get the last element of an array. Passing **n** will return the last N
|
418
|
+
// values in the array. The **guard** check allows it to work with `_.map`.
|
419
|
+
_.last = function(array, n, guard) {
|
420
|
+
if (array == null) return void 0;
|
421
|
+
if ((n == null) || guard) return array[array.length - 1];
|
422
|
+
return slice.call(array, Math.max(array.length - n, 0));
|
423
|
+
};
|
424
|
+
|
425
|
+
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
|
426
|
+
// Especially useful on the arguments object. Passing an **n** will return
|
427
|
+
// the rest N values in the array. The **guard**
|
428
|
+
// check allows it to work with `_.map`.
|
429
|
+
_.rest = _.tail = _.drop = function(array, n, guard) {
|
430
|
+
return slice.call(array, (n == null) || guard ? 1 : n);
|
431
|
+
};
|
432
|
+
|
433
|
+
// Trim out all falsy values from an array.
|
434
|
+
_.compact = function(array) {
|
435
|
+
return _.filter(array, _.identity);
|
436
|
+
};
|
437
|
+
|
438
|
+
// Internal implementation of a recursive `flatten` function.
|
439
|
+
var flatten = function(input, shallow, output) {
|
440
|
+
if (shallow && _.every(input, _.isArray)) {
|
441
|
+
return concat.apply(output, input);
|
442
|
+
}
|
443
|
+
each(input, function(value) {
|
444
|
+
if (_.isArray(value) || _.isArguments(value)) {
|
445
|
+
shallow ? push.apply(output, value) : flatten(value, shallow, output);
|
446
|
+
} else {
|
447
|
+
output.push(value);
|
448
|
+
}
|
449
|
+
});
|
450
|
+
return output;
|
451
|
+
};
|
452
|
+
|
453
|
+
// Flatten out an array, either recursively (by default), or just one level.
|
454
|
+
_.flatten = function(array, shallow) {
|
455
|
+
return flatten(array, shallow, []);
|
456
|
+
};
|
457
|
+
|
458
|
+
// Return a version of the array that does not contain the specified value(s).
|
459
|
+
_.without = function(array) {
|
460
|
+
return _.difference(array, slice.call(arguments, 1));
|
461
|
+
};
|
462
|
+
|
463
|
+
// Split an array into two arrays: one whose elements all satisfy the given
|
464
|
+
// predicate, and one whose elements all do not satisfy the predicate.
|
465
|
+
_.partition = function(array, predicate) {
|
466
|
+
var pass = [], fail = [];
|
467
|
+
each(array, function(elem) {
|
468
|
+
(predicate(elem) ? pass : fail).push(elem);
|
469
|
+
});
|
470
|
+
return [pass, fail];
|
471
|
+
};
|
472
|
+
|
473
|
+
// Produce a duplicate-free version of the array. If the array has already
|
474
|
+
// been sorted, you have the option of using a faster algorithm.
|
475
|
+
// Aliased as `unique`.
|
476
|
+
_.uniq = _.unique = function(array, isSorted, iterator, context) {
|
477
|
+
if (_.isFunction(isSorted)) {
|
478
|
+
context = iterator;
|
479
|
+
iterator = isSorted;
|
480
|
+
isSorted = false;
|
481
|
+
}
|
482
|
+
var initial = iterator ? _.map(array, iterator, context) : array;
|
483
|
+
var results = [];
|
484
|
+
var seen = [];
|
485
|
+
each(initial, function(value, index) {
|
486
|
+
if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
|
487
|
+
seen.push(value);
|
488
|
+
results.push(array[index]);
|
489
|
+
}
|
490
|
+
});
|
491
|
+
return results;
|
492
|
+
};
|
493
|
+
|
494
|
+
// Produce an array that contains the union: each distinct element from all of
|
495
|
+
// the passed-in arrays.
|
496
|
+
_.union = function() {
|
497
|
+
return _.uniq(_.flatten(arguments, true));
|
498
|
+
};
|
499
|
+
|
500
|
+
// Produce an array that contains every item shared between all the
|
501
|
+
// passed-in arrays.
|
502
|
+
_.intersection = function(array) {
|
503
|
+
var rest = slice.call(arguments, 1);
|
504
|
+
return _.filter(_.uniq(array), function(item) {
|
505
|
+
return _.every(rest, function(other) {
|
506
|
+
return _.contains(other, item);
|
507
|
+
});
|
508
|
+
});
|
509
|
+
};
|
510
|
+
|
511
|
+
// Take the difference between one array and a number of other arrays.
|
512
|
+
// Only the elements present in just the first array will remain.
|
513
|
+
_.difference = function(array) {
|
514
|
+
var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
|
515
|
+
return _.filter(array, function(value){ return !_.contains(rest, value); });
|
516
|
+
};
|
517
|
+
|
518
|
+
// Zip together multiple lists into a single array -- elements that share
|
519
|
+
// an index go together.
|
520
|
+
_.zip = function() {
|
521
|
+
var length = _.max(_.pluck(arguments, 'length').concat(0));
|
522
|
+
var results = new Array(length);
|
523
|
+
for (var i = 0; i < length; i++) {
|
524
|
+
results[i] = _.pluck(arguments, '' + i);
|
525
|
+
}
|
526
|
+
return results;
|
527
|
+
};
|
528
|
+
|
529
|
+
// Converts lists into objects. Pass either a single array of `[key, value]`
|
530
|
+
// pairs, or two parallel arrays of the same length -- one of keys, and one of
|
531
|
+
// the corresponding values.
|
532
|
+
_.object = function(list, values) {
|
533
|
+
if (list == null) return {};
|
534
|
+
var result = {};
|
535
|
+
for (var i = 0, length = list.length; i < length; i++) {
|
536
|
+
if (values) {
|
537
|
+
result[list[i]] = values[i];
|
538
|
+
} else {
|
539
|
+
result[list[i][0]] = list[i][1];
|
540
|
+
}
|
541
|
+
}
|
542
|
+
return result;
|
543
|
+
};
|
544
|
+
|
545
|
+
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
|
546
|
+
// we need this function. Return the position of the first occurrence of an
|
547
|
+
// item in an array, or -1 if the item is not included in the array.
|
548
|
+
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
|
549
|
+
// If the array is large and already in sort order, pass `true`
|
550
|
+
// for **isSorted** to use binary search.
|
551
|
+
_.indexOf = function(array, item, isSorted) {
|
552
|
+
if (array == null) return -1;
|
553
|
+
var i = 0, length = array.length;
|
554
|
+
if (isSorted) {
|
555
|
+
if (typeof isSorted == 'number') {
|
556
|
+
i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
|
557
|
+
} else {
|
558
|
+
i = _.sortedIndex(array, item);
|
559
|
+
return array[i] === item ? i : -1;
|
560
|
+
}
|
561
|
+
}
|
562
|
+
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
|
563
|
+
for (; i < length; i++) if (array[i] === item) return i;
|
564
|
+
return -1;
|
565
|
+
};
|
566
|
+
|
567
|
+
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
|
568
|
+
_.lastIndexOf = function(array, item, from) {
|
569
|
+
if (array == null) return -1;
|
570
|
+
var hasIndex = from != null;
|
571
|
+
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
|
572
|
+
return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
|
573
|
+
}
|
574
|
+
var i = (hasIndex ? from : array.length);
|
575
|
+
while (i--) if (array[i] === item) return i;
|
576
|
+
return -1;
|
577
|
+
};
|
578
|
+
|
579
|
+
// Generate an integer Array containing an arithmetic progression. A port of
|
580
|
+
// the native Python `range()` function. See
|
581
|
+
// [the Python documentation](http://docs.python.org/library/functions.html#range).
|
582
|
+
_.range = function(start, stop, step) {
|
583
|
+
if (arguments.length <= 1) {
|
584
|
+
stop = start || 0;
|
585
|
+
start = 0;
|
586
|
+
}
|
587
|
+
step = arguments[2] || 1;
|
588
|
+
|
589
|
+
var length = Math.max(Math.ceil((stop - start) / step), 0);
|
590
|
+
var idx = 0;
|
591
|
+
var range = new Array(length);
|
592
|
+
|
593
|
+
while(idx < length) {
|
594
|
+
range[idx++] = start;
|
595
|
+
start += step;
|
596
|
+
}
|
597
|
+
|
598
|
+
return range;
|
599
|
+
};
|
600
|
+
|
601
|
+
// Function (ahem) Functions
|
602
|
+
// ------------------
|
603
|
+
|
604
|
+
// Reusable constructor function for prototype setting.
|
605
|
+
var ctor = function(){};
|
606
|
+
|
607
|
+
// Create a function bound to a given object (assigning `this`, and arguments,
|
608
|
+
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
|
609
|
+
// available.
|
610
|
+
_.bind = function(func, context) {
|
611
|
+
var args, bound;
|
612
|
+
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
|
613
|
+
if (!_.isFunction(func)) throw new TypeError;
|
614
|
+
args = slice.call(arguments, 2);
|
615
|
+
return bound = function() {
|
616
|
+
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
|
617
|
+
ctor.prototype = func.prototype;
|
618
|
+
var self = new ctor;
|
619
|
+
ctor.prototype = null;
|
620
|
+
var result = func.apply(self, args.concat(slice.call(arguments)));
|
621
|
+
if (Object(result) === result) return result;
|
622
|
+
return self;
|
623
|
+
};
|
624
|
+
};
|
625
|
+
|
626
|
+
// Partially apply a function by creating a version that has had some of its
|
627
|
+
// arguments pre-filled, without changing its dynamic `this` context. _ acts
|
628
|
+
// as a placeholder, allowing any combination of arguments to be pre-filled.
|
629
|
+
_.partial = function(func) {
|
630
|
+
var boundArgs = slice.call(arguments, 1);
|
631
|
+
return function() {
|
632
|
+
var position = 0;
|
633
|
+
var args = boundArgs.slice();
|
634
|
+
for (var i = 0, length = args.length; i < length; i++) {
|
635
|
+
if (args[i] === _) args[i] = arguments[position++];
|
636
|
+
}
|
637
|
+
while (position < arguments.length) args.push(arguments[position++]);
|
638
|
+
return func.apply(this, args);
|
639
|
+
};
|
640
|
+
};
|
641
|
+
|
642
|
+
// Bind a number of an object's methods to that object. Remaining arguments
|
643
|
+
// are the method names to be bound. Useful for ensuring that all callbacks
|
644
|
+
// defined on an object belong to it.
|
645
|
+
_.bindAll = function(obj) {
|
646
|
+
var funcs = slice.call(arguments, 1);
|
647
|
+
if (funcs.length === 0) throw new Error('bindAll must be passed function names');
|
648
|
+
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
|
649
|
+
return obj;
|
650
|
+
};
|
651
|
+
|
652
|
+
// Memoize an expensive function by storing its results.
|
653
|
+
_.memoize = function(func, hasher) {
|
654
|
+
var memo = {};
|
655
|
+
hasher || (hasher = _.identity);
|
656
|
+
return function() {
|
657
|
+
var key = hasher.apply(this, arguments);
|
658
|
+
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
|
659
|
+
};
|
660
|
+
};
|
661
|
+
|
662
|
+
// Delays a function for the given number of milliseconds, and then calls
|
663
|
+
// it with the arguments supplied.
|
664
|
+
_.delay = function(func, wait) {
|
665
|
+
var args = slice.call(arguments, 2);
|
666
|
+
return setTimeout(function(){ return func.apply(null, args); }, wait);
|
667
|
+
};
|
668
|
+
|
669
|
+
// Defers a function, scheduling it to run after the current call stack has
|
670
|
+
// cleared.
|
671
|
+
_.defer = function(func) {
|
672
|
+
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
|
673
|
+
};
|
674
|
+
|
675
|
+
// Returns a function, that, when invoked, will only be triggered at most once
|
676
|
+
// during a given window of time. Normally, the throttled function will run
|
677
|
+
// as much as it can, without ever going more than once per `wait` duration;
|
678
|
+
// but if you'd like to disable the execution on the leading edge, pass
|
679
|
+
// `{leading: false}`. To disable execution on the trailing edge, ditto.
|
680
|
+
_.throttle = function(func, wait, options) {
|
681
|
+
var context, args, result;
|
682
|
+
var timeout = null;
|
683
|
+
var previous = 0;
|
684
|
+
options || (options = {});
|
685
|
+
var later = function() {
|
686
|
+
previous = options.leading === false ? 0 : _.now();
|
687
|
+
timeout = null;
|
688
|
+
result = func.apply(context, args);
|
689
|
+
context = args = null;
|
690
|
+
};
|
691
|
+
return function() {
|
692
|
+
var now = _.now();
|
693
|
+
if (!previous && options.leading === false) previous = now;
|
694
|
+
var remaining = wait - (now - previous);
|
695
|
+
context = this;
|
696
|
+
args = arguments;
|
697
|
+
if (remaining <= 0) {
|
698
|
+
clearTimeout(timeout);
|
699
|
+
timeout = null;
|
700
|
+
previous = now;
|
701
|
+
result = func.apply(context, args);
|
702
|
+
context = args = null;
|
703
|
+
} else if (!timeout && options.trailing !== false) {
|
704
|
+
timeout = setTimeout(later, remaining);
|
705
|
+
}
|
706
|
+
return result;
|
707
|
+
};
|
708
|
+
};
|
709
|
+
|
710
|
+
// Returns a function, that, as long as it continues to be invoked, will not
|
711
|
+
// be triggered. The function will be called after it stops being called for
|
712
|
+
// N milliseconds. If `immediate` is passed, trigger the function on the
|
713
|
+
// leading edge, instead of the trailing.
|
714
|
+
_.debounce = function(func, wait, immediate) {
|
715
|
+
var timeout, args, context, timestamp, result;
|
716
|
+
|
717
|
+
var later = function() {
|
718
|
+
var last = _.now() - timestamp;
|
719
|
+
if (last < wait) {
|
720
|
+
timeout = setTimeout(later, wait - last);
|
721
|
+
} else {
|
722
|
+
timeout = null;
|
723
|
+
if (!immediate) {
|
724
|
+
result = func.apply(context, args);
|
725
|
+
context = args = null;
|
726
|
+
}
|
727
|
+
}
|
728
|
+
};
|
729
|
+
|
730
|
+
return function() {
|
731
|
+
context = this;
|
732
|
+
args = arguments;
|
733
|
+
timestamp = _.now();
|
734
|
+
var callNow = immediate && !timeout;
|
735
|
+
if (!timeout) {
|
736
|
+
timeout = setTimeout(later, wait);
|
737
|
+
}
|
738
|
+
if (callNow) {
|
739
|
+
result = func.apply(context, args);
|
740
|
+
context = args = null;
|
741
|
+
}
|
742
|
+
|
743
|
+
return result;
|
744
|
+
};
|
745
|
+
};
|
746
|
+
|
747
|
+
// Returns a function that will be executed at most one time, no matter how
|
748
|
+
// often you call it. Useful for lazy initialization.
|
749
|
+
_.once = function(func) {
|
750
|
+
var ran = false, memo;
|
751
|
+
return function() {
|
752
|
+
if (ran) return memo;
|
753
|
+
ran = true;
|
754
|
+
memo = func.apply(this, arguments);
|
755
|
+
func = null;
|
756
|
+
return memo;
|
757
|
+
};
|
758
|
+
};
|
759
|
+
|
760
|
+
// Returns the first function passed as an argument to the second,
|
761
|
+
// allowing you to adjust arguments, run code before and after, and
|
762
|
+
// conditionally execute the original function.
|
763
|
+
_.wrap = function(func, wrapper) {
|
764
|
+
return _.partial(wrapper, func);
|
765
|
+
};
|
766
|
+
|
767
|
+
// Returns a function that is the composition of a list of functions, each
|
768
|
+
// consuming the return value of the function that follows.
|
769
|
+
_.compose = function() {
|
770
|
+
var funcs = arguments;
|
771
|
+
return function() {
|
772
|
+
var args = arguments;
|
773
|
+
for (var i = funcs.length - 1; i >= 0; i--) {
|
774
|
+
args = [funcs[i].apply(this, args)];
|
775
|
+
}
|
776
|
+
return args[0];
|
777
|
+
};
|
778
|
+
};
|
779
|
+
|
780
|
+
// Returns a function that will only be executed after being called N times.
|
781
|
+
_.after = function(times, func) {
|
782
|
+
return function() {
|
783
|
+
if (--times < 1) {
|
784
|
+
return func.apply(this, arguments);
|
785
|
+
}
|
786
|
+
};
|
787
|
+
};
|
788
|
+
|
789
|
+
// Object Functions
|
790
|
+
// ----------------
|
791
|
+
|
792
|
+
// Retrieve the names of an object's properties.
|
793
|
+
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
794
|
+
_.keys = function(obj) {
|
795
|
+
if (!_.isObject(obj)) return [];
|
796
|
+
if (nativeKeys) return nativeKeys(obj);
|
797
|
+
var keys = [];
|
798
|
+
for (var key in obj) if (_.has(obj, key)) keys.push(key);
|
799
|
+
return keys;
|
800
|
+
};
|
801
|
+
|
802
|
+
// Retrieve the values of an object's properties.
|
803
|
+
_.values = function(obj) {
|
804
|
+
var keys = _.keys(obj);
|
805
|
+
var length = keys.length;
|
806
|
+
var values = new Array(length);
|
807
|
+
for (var i = 0; i < length; i++) {
|
808
|
+
values[i] = obj[keys[i]];
|
809
|
+
}
|
810
|
+
return values;
|
811
|
+
};
|
812
|
+
|
813
|
+
// Convert an object into a list of `[key, value]` pairs.
|
814
|
+
_.pairs = function(obj) {
|
815
|
+
var keys = _.keys(obj);
|
816
|
+
var length = keys.length;
|
817
|
+
var pairs = new Array(length);
|
818
|
+
for (var i = 0; i < length; i++) {
|
819
|
+
pairs[i] = [keys[i], obj[keys[i]]];
|
820
|
+
}
|
821
|
+
return pairs;
|
822
|
+
};
|
823
|
+
|
824
|
+
// Invert the keys and values of an object. The values must be serializable.
|
825
|
+
_.invert = function(obj) {
|
826
|
+
var result = {};
|
827
|
+
var keys = _.keys(obj);
|
828
|
+
for (var i = 0, length = keys.length; i < length; i++) {
|
829
|
+
result[obj[keys[i]]] = keys[i];
|
830
|
+
}
|
831
|
+
return result;
|
832
|
+
};
|
833
|
+
|
834
|
+
// Return a sorted list of the function names available on the object.
|
835
|
+
// Aliased as `methods`
|
836
|
+
_.functions = _.methods = function(obj) {
|
837
|
+
var names = [];
|
838
|
+
for (var key in obj) {
|
839
|
+
if (_.isFunction(obj[key])) names.push(key);
|
840
|
+
}
|
841
|
+
return names.sort();
|
842
|
+
};
|
843
|
+
|
844
|
+
// Extend a given object with all the properties in passed-in object(s).
|
845
|
+
_.extend = function(obj) {
|
846
|
+
each(slice.call(arguments, 1), function(source) {
|
847
|
+
if (source) {
|
848
|
+
for (var prop in source) {
|
849
|
+
obj[prop] = source[prop];
|
850
|
+
}
|
851
|
+
}
|
852
|
+
});
|
853
|
+
return obj;
|
854
|
+
};
|
855
|
+
|
856
|
+
// Return a copy of the object only containing the whitelisted properties.
|
857
|
+
_.pick = function(obj) {
|
858
|
+
var copy = {};
|
859
|
+
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
|
860
|
+
each(keys, function(key) {
|
861
|
+
if (key in obj) copy[key] = obj[key];
|
862
|
+
});
|
863
|
+
return copy;
|
864
|
+
};
|
865
|
+
|
866
|
+
// Return a copy of the object without the blacklisted properties.
|
867
|
+
_.omit = function(obj) {
|
868
|
+
var copy = {};
|
869
|
+
var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
|
870
|
+
for (var key in obj) {
|
871
|
+
if (!_.contains(keys, key)) copy[key] = obj[key];
|
872
|
+
}
|
873
|
+
return copy;
|
874
|
+
};
|
875
|
+
|
876
|
+
// Fill in a given object with default properties.
|
877
|
+
_.defaults = function(obj) {
|
878
|
+
each(slice.call(arguments, 1), function(source) {
|
879
|
+
if (source) {
|
880
|
+
for (var prop in source) {
|
881
|
+
if (obj[prop] === void 0) obj[prop] = source[prop];
|
882
|
+
}
|
883
|
+
}
|
884
|
+
});
|
885
|
+
return obj;
|
886
|
+
};
|
887
|
+
|
888
|
+
// Create a (shallow-cloned) duplicate of an object.
|
889
|
+
_.clone = function(obj) {
|
890
|
+
if (!_.isObject(obj)) return obj;
|
891
|
+
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
|
892
|
+
};
|
893
|
+
|
894
|
+
// Invokes interceptor with the obj, and then returns obj.
|
895
|
+
// The primary purpose of this method is to "tap into" a method chain, in
|
896
|
+
// order to perform operations on intermediate results within the chain.
|
897
|
+
_.tap = function(obj, interceptor) {
|
898
|
+
interceptor(obj);
|
899
|
+
return obj;
|
900
|
+
};
|
901
|
+
|
902
|
+
// Internal recursive comparison function for `isEqual`.
|
903
|
+
var eq = function(a, b, aStack, bStack) {
|
904
|
+
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
905
|
+
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
906
|
+
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
907
|
+
// A strict comparison is necessary because `null == undefined`.
|
908
|
+
if (a == null || b == null) return a === b;
|
909
|
+
// Unwrap any wrapped objects.
|
910
|
+
if (a instanceof _) a = a._wrapped;
|
911
|
+
if (b instanceof _) b = b._wrapped;
|
912
|
+
// Compare `[[Class]]` names.
|
913
|
+
var className = toString.call(a);
|
914
|
+
if (className != toString.call(b)) return false;
|
915
|
+
switch (className) {
|
916
|
+
// Strings, numbers, dates, and booleans are compared by value.
|
917
|
+
case '[object String]':
|
918
|
+
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
919
|
+
// equivalent to `new String("5")`.
|
920
|
+
return a == String(b);
|
921
|
+
case '[object Number]':
|
922
|
+
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
|
923
|
+
// other numeric values.
|
924
|
+
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
|
925
|
+
case '[object Date]':
|
926
|
+
case '[object Boolean]':
|
927
|
+
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
928
|
+
// millisecond representations. Note that invalid dates with millisecond representations
|
929
|
+
// of `NaN` are not equivalent.
|
930
|
+
return +a == +b;
|
931
|
+
// RegExps are compared by their source patterns and flags.
|
932
|
+
case '[object RegExp]':
|
933
|
+
return a.source == b.source &&
|
934
|
+
a.global == b.global &&
|
935
|
+
a.multiline == b.multiline &&
|
936
|
+
a.ignoreCase == b.ignoreCase;
|
937
|
+
}
|
938
|
+
if (typeof a != 'object' || typeof b != 'object') return false;
|
939
|
+
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
940
|
+
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
941
|
+
var length = aStack.length;
|
942
|
+
while (length--) {
|
943
|
+
// Linear search. Performance is inversely proportional to the number of
|
944
|
+
// unique nested structures.
|
945
|
+
if (aStack[length] == a) return bStack[length] == b;
|
946
|
+
}
|
947
|
+
// Objects with different constructors are not equivalent, but `Object`s
|
948
|
+
// from different frames are.
|
949
|
+
var aCtor = a.constructor, bCtor = b.constructor;
|
950
|
+
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
|
951
|
+
_.isFunction(bCtor) && (bCtor instanceof bCtor))
|
952
|
+
&& ('constructor' in a && 'constructor' in b)) {
|
953
|
+
return false;
|
954
|
+
}
|
955
|
+
// Add the first object to the stack of traversed objects.
|
956
|
+
aStack.push(a);
|
957
|
+
bStack.push(b);
|
958
|
+
var size = 0, result = true;
|
959
|
+
// Recursively compare objects and arrays.
|
960
|
+
if (className == '[object Array]') {
|
961
|
+
// Compare array lengths to determine if a deep comparison is necessary.
|
962
|
+
size = a.length;
|
963
|
+
result = size == b.length;
|
964
|
+
if (result) {
|
965
|
+
// Deep compare the contents, ignoring non-numeric properties.
|
966
|
+
while (size--) {
|
967
|
+
if (!(result = eq(a[size], b[size], aStack, bStack))) break;
|
968
|
+
}
|
969
|
+
}
|
970
|
+
} else {
|
971
|
+
// Deep compare objects.
|
972
|
+
for (var key in a) {
|
973
|
+
if (_.has(a, key)) {
|
974
|
+
// Count the expected number of properties.
|
975
|
+
size++;
|
976
|
+
// Deep compare each member.
|
977
|
+
if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
|
978
|
+
}
|
979
|
+
}
|
980
|
+
// Ensure that both objects contain the same number of properties.
|
981
|
+
if (result) {
|
982
|
+
for (key in b) {
|
983
|
+
if (_.has(b, key) && !(size--)) break;
|
984
|
+
}
|
985
|
+
result = !size;
|
986
|
+
}
|
987
|
+
}
|
988
|
+
// Remove the first object from the stack of traversed objects.
|
989
|
+
aStack.pop();
|
990
|
+
bStack.pop();
|
991
|
+
return result;
|
992
|
+
};
|
993
|
+
|
994
|
+
// Perform a deep comparison to check if two objects are equal.
|
995
|
+
_.isEqual = function(a, b) {
|
996
|
+
return eq(a, b, [], []);
|
997
|
+
};
|
998
|
+
|
999
|
+
// Is a given array, string, or object empty?
|
1000
|
+
// An "empty" object has no enumerable own-properties.
|
1001
|
+
_.isEmpty = function(obj) {
|
1002
|
+
if (obj == null) return true;
|
1003
|
+
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
|
1004
|
+
for (var key in obj) if (_.has(obj, key)) return false;
|
1005
|
+
return true;
|
1006
|
+
};
|
1007
|
+
|
1008
|
+
// Is a given value a DOM element?
|
1009
|
+
_.isElement = function(obj) {
|
1010
|
+
return !!(obj && obj.nodeType === 1);
|
1011
|
+
};
|
1012
|
+
|
1013
|
+
// Is a given value an array?
|
1014
|
+
// Delegates to ECMA5's native Array.isArray
|
1015
|
+
_.isArray = nativeIsArray || function(obj) {
|
1016
|
+
return toString.call(obj) == '[object Array]';
|
1017
|
+
};
|
1018
|
+
|
1019
|
+
// Is a given variable an object?
|
1020
|
+
_.isObject = function(obj) {
|
1021
|
+
return obj === Object(obj);
|
1022
|
+
};
|
1023
|
+
|
1024
|
+
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
|
1025
|
+
each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
|
1026
|
+
_['is' + name] = function(obj) {
|
1027
|
+
return toString.call(obj) == '[object ' + name + ']';
|
1028
|
+
};
|
1029
|
+
});
|
1030
|
+
|
1031
|
+
// Define a fallback version of the method in browsers (ahem, IE), where
|
1032
|
+
// there isn't any inspectable "Arguments" type.
|
1033
|
+
if (!_.isArguments(arguments)) {
|
1034
|
+
_.isArguments = function(obj) {
|
1035
|
+
return !!(obj && _.has(obj, 'callee'));
|
1036
|
+
};
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
// Optimize `isFunction` if appropriate.
|
1040
|
+
if (typeof (/./) !== 'function') {
|
1041
|
+
_.isFunction = function(obj) {
|
1042
|
+
return typeof obj === 'function';
|
1043
|
+
};
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
// Is a given object a finite number?
|
1047
|
+
_.isFinite = function(obj) {
|
1048
|
+
return isFinite(obj) && !isNaN(parseFloat(obj));
|
1049
|
+
};
|
1050
|
+
|
1051
|
+
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
|
1052
|
+
_.isNaN = function(obj) {
|
1053
|
+
return _.isNumber(obj) && obj != +obj;
|
1054
|
+
};
|
1055
|
+
|
1056
|
+
// Is a given value a boolean?
|
1057
|
+
_.isBoolean = function(obj) {
|
1058
|
+
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
|
1059
|
+
};
|
1060
|
+
|
1061
|
+
// Is a given value equal to null?
|
1062
|
+
_.isNull = function(obj) {
|
1063
|
+
return obj === null;
|
1064
|
+
};
|
1065
|
+
|
1066
|
+
// Is a given variable undefined?
|
1067
|
+
_.isUndefined = function(obj) {
|
1068
|
+
return obj === void 0;
|
1069
|
+
};
|
1070
|
+
|
1071
|
+
// Shortcut function for checking if an object has a given property directly
|
1072
|
+
// on itself (in other words, not on a prototype).
|
1073
|
+
_.has = function(obj, key) {
|
1074
|
+
return hasOwnProperty.call(obj, key);
|
1075
|
+
};
|
1076
|
+
|
1077
|
+
// Utility Functions
|
1078
|
+
// -----------------
|
1079
|
+
|
1080
|
+
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
|
1081
|
+
// previous owner. Returns a reference to the Underscore object.
|
1082
|
+
_.noConflict = function() {
|
1083
|
+
root._ = previousUnderscore;
|
1084
|
+
return this;
|
1085
|
+
};
|
1086
|
+
|
1087
|
+
// Keep the identity function around for default iterators.
|
1088
|
+
_.identity = function(value) {
|
1089
|
+
return value;
|
1090
|
+
};
|
1091
|
+
|
1092
|
+
_.constant = function(value) {
|
1093
|
+
return function () {
|
1094
|
+
return value;
|
1095
|
+
};
|
1096
|
+
};
|
1097
|
+
|
1098
|
+
_.property = function(key) {
|
1099
|
+
return function(obj) {
|
1100
|
+
return obj[key];
|
1101
|
+
};
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
// Returns a predicate for checking whether an object has a given set of `key:value` pairs.
|
1105
|
+
_.matches = function(attrs) {
|
1106
|
+
return function(obj) {
|
1107
|
+
if (obj === attrs) return true; //avoid comparing an object to itself.
|
1108
|
+
for (var key in attrs) {
|
1109
|
+
if (attrs[key] !== obj[key])
|
1110
|
+
return false;
|
1111
|
+
}
|
1112
|
+
return true;
|
1113
|
+
}
|
1114
|
+
};
|
1115
|
+
|
1116
|
+
// Run a function **n** times.
|
1117
|
+
_.times = function(n, iterator, context) {
|
1118
|
+
var accum = Array(Math.max(0, n));
|
1119
|
+
for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
|
1120
|
+
return accum;
|
1121
|
+
};
|
1122
|
+
|
1123
|
+
// Return a random integer between min and max (inclusive).
|
1124
|
+
_.random = function(min, max) {
|
1125
|
+
if (max == null) {
|
1126
|
+
max = min;
|
1127
|
+
min = 0;
|
1128
|
+
}
|
1129
|
+
return min + Math.floor(Math.random() * (max - min + 1));
|
1130
|
+
};
|
1131
|
+
|
1132
|
+
// A (possibly faster) way to get the current timestamp as an integer.
|
1133
|
+
_.now = Date.now || function() { return new Date().getTime(); };
|
1134
|
+
|
1135
|
+
// List of HTML entities for escaping.
|
1136
|
+
var entityMap = {
|
1137
|
+
escape: {
|
1138
|
+
'&': '&',
|
1139
|
+
'<': '<',
|
1140
|
+
'>': '>',
|
1141
|
+
'"': '"',
|
1142
|
+
"'": '''
|
1143
|
+
}
|
1144
|
+
};
|
1145
|
+
entityMap.unescape = _.invert(entityMap.escape);
|
1146
|
+
|
1147
|
+
// Regexes containing the keys and values listed immediately above.
|
1148
|
+
var entityRegexes = {
|
1149
|
+
escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
|
1150
|
+
unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
|
1151
|
+
};
|
1152
|
+
|
1153
|
+
// Functions for escaping and unescaping strings to/from HTML interpolation.
|
1154
|
+
_.each(['escape', 'unescape'], function(method) {
|
1155
|
+
_[method] = function(string) {
|
1156
|
+
if (string == null) return '';
|
1157
|
+
return ('' + string).replace(entityRegexes[method], function(match) {
|
1158
|
+
return entityMap[method][match];
|
1159
|
+
});
|
1160
|
+
};
|
1161
|
+
});
|
1162
|
+
|
1163
|
+
// If the value of the named `property` is a function then invoke it with the
|
1164
|
+
// `object` as context; otherwise, return it.
|
1165
|
+
_.result = function(object, property) {
|
1166
|
+
if (object == null) return void 0;
|
1167
|
+
var value = object[property];
|
1168
|
+
return _.isFunction(value) ? value.call(object) : value;
|
1169
|
+
};
|
1170
|
+
|
1171
|
+
// Add your own custom functions to the Underscore object.
|
1172
|
+
_.mixin = function(obj) {
|
1173
|
+
each(_.functions(obj), function(name) {
|
1174
|
+
var func = _[name] = obj[name];
|
1175
|
+
_.prototype[name] = function() {
|
1176
|
+
var args = [this._wrapped];
|
1177
|
+
push.apply(args, arguments);
|
1178
|
+
return result.call(this, func.apply(_, args));
|
1179
|
+
};
|
1180
|
+
});
|
1181
|
+
};
|
1182
|
+
|
1183
|
+
// Generate a unique integer id (unique within the entire client session).
|
1184
|
+
// Useful for temporary DOM ids.
|
1185
|
+
var idCounter = 0;
|
1186
|
+
_.uniqueId = function(prefix) {
|
1187
|
+
var id = ++idCounter + '';
|
1188
|
+
return prefix ? prefix + id : id;
|
1189
|
+
};
|
1190
|
+
|
1191
|
+
// By default, Underscore uses ERB-style template delimiters, change the
|
1192
|
+
// following template settings to use alternative delimiters.
|
1193
|
+
_.templateSettings = {
|
1194
|
+
evaluate : /<%([\s\S]+?)%>/g,
|
1195
|
+
interpolate : /<%=([\s\S]+?)%>/g,
|
1196
|
+
escape : /<%-([\s\S]+?)%>/g
|
1197
|
+
};
|
1198
|
+
|
1199
|
+
// When customizing `templateSettings`, if you don't want to define an
|
1200
|
+
// interpolation, evaluation or escaping regex, we need one that is
|
1201
|
+
// guaranteed not to match.
|
1202
|
+
var noMatch = /(.)^/;
|
1203
|
+
|
1204
|
+
// Certain characters need to be escaped so that they can be put into a
|
1205
|
+
// string literal.
|
1206
|
+
var escapes = {
|
1207
|
+
"'": "'",
|
1208
|
+
'\\': '\\',
|
1209
|
+
'\r': 'r',
|
1210
|
+
'\n': 'n',
|
1211
|
+
'\t': 't',
|
1212
|
+
'\u2028': 'u2028',
|
1213
|
+
'\u2029': 'u2029'
|
1214
|
+
};
|
1215
|
+
|
1216
|
+
var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
|
1217
|
+
|
1218
|
+
// JavaScript micro-templating, similar to John Resig's implementation.
|
1219
|
+
// Underscore templating handles arbitrary delimiters, preserves whitespace,
|
1220
|
+
// and correctly escapes quotes within interpolated code.
|
1221
|
+
_.template = function(text, data, settings) {
|
1222
|
+
var render;
|
1223
|
+
settings = _.defaults({}, settings, _.templateSettings);
|
1224
|
+
|
1225
|
+
// Combine delimiters into one regular expression via alternation.
|
1226
|
+
var matcher = new RegExp([
|
1227
|
+
(settings.escape || noMatch).source,
|
1228
|
+
(settings.interpolate || noMatch).source,
|
1229
|
+
(settings.evaluate || noMatch).source
|
1230
|
+
].join('|') + '|$', 'g');
|
1231
|
+
|
1232
|
+
// Compile the template source, escaping string literals appropriately.
|
1233
|
+
var index = 0;
|
1234
|
+
var source = "__p+='";
|
1235
|
+
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
|
1236
|
+
source += text.slice(index, offset)
|
1237
|
+
.replace(escaper, function(match) { return '\\' + escapes[match]; });
|
1238
|
+
|
1239
|
+
if (escape) {
|
1240
|
+
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
|
1241
|
+
}
|
1242
|
+
if (interpolate) {
|
1243
|
+
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
|
1244
|
+
}
|
1245
|
+
if (evaluate) {
|
1246
|
+
source += "';\n" + evaluate + "\n__p+='";
|
1247
|
+
}
|
1248
|
+
index = offset + match.length;
|
1249
|
+
return match;
|
1250
|
+
});
|
1251
|
+
source += "';\n";
|
1252
|
+
|
1253
|
+
// If a variable is not specified, place data values in local scope.
|
1254
|
+
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
|
1255
|
+
|
1256
|
+
source = "var __t,__p='',__j=Array.prototype.join," +
|
1257
|
+
"print=function(){__p+=__j.call(arguments,'');};\n" +
|
1258
|
+
source + "return __p;\n";
|
1259
|
+
|
1260
|
+
try {
|
1261
|
+
render = new Function(settings.variable || 'obj', '_', source);
|
1262
|
+
} catch (e) {
|
1263
|
+
e.source = source;
|
1264
|
+
throw e;
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
if (data) return render(data, _);
|
1268
|
+
var template = function(data) {
|
1269
|
+
return render.call(this, data, _);
|
1270
|
+
};
|
1271
|
+
|
1272
|
+
// Provide the compiled function source as a convenience for precompilation.
|
1273
|
+
template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
|
1274
|
+
|
1275
|
+
return template;
|
1276
|
+
};
|
1277
|
+
|
1278
|
+
// Add a "chain" function, which will delegate to the wrapper.
|
1279
|
+
_.chain = function(obj) {
|
1280
|
+
return _(obj).chain();
|
1281
|
+
};
|
1282
|
+
|
1283
|
+
// OOP
|
1284
|
+
// ---------------
|
1285
|
+
// If Underscore is called as a function, it returns a wrapped object that
|
1286
|
+
// can be used OO-style. This wrapper holds altered versions of all the
|
1287
|
+
// underscore functions. Wrapped objects may be chained.
|
1288
|
+
|
1289
|
+
// Helper function to continue chaining intermediate results.
|
1290
|
+
var result = function(obj) {
|
1291
|
+
return this._chain ? _(obj).chain() : obj;
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
// Add all of the Underscore functions to the wrapper object.
|
1295
|
+
_.mixin(_);
|
1296
|
+
|
1297
|
+
// Add all mutator Array functions to the wrapper.
|
1298
|
+
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
1299
|
+
var method = ArrayProto[name];
|
1300
|
+
_.prototype[name] = function() {
|
1301
|
+
var obj = this._wrapped;
|
1302
|
+
method.apply(obj, arguments);
|
1303
|
+
if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
|
1304
|
+
return result.call(this, obj);
|
1305
|
+
};
|
1306
|
+
});
|
1307
|
+
|
1308
|
+
// Add all accessor Array functions to the wrapper.
|
1309
|
+
each(['concat', 'join', 'slice'], function(name) {
|
1310
|
+
var method = ArrayProto[name];
|
1311
|
+
_.prototype[name] = function() {
|
1312
|
+
return result.call(this, method.apply(this._wrapped, arguments));
|
1313
|
+
};
|
1314
|
+
});
|
1315
|
+
|
1316
|
+
_.extend(_.prototype, {
|
1317
|
+
|
1318
|
+
// Start chaining a wrapped Underscore object.
|
1319
|
+
chain: function() {
|
1320
|
+
this._chain = true;
|
1321
|
+
return this;
|
1322
|
+
},
|
1323
|
+
|
1324
|
+
// Extracts the result from a wrapped and chained object.
|
1325
|
+
value: function() {
|
1326
|
+
return this._wrapped;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
});
|
1330
|
+
|
1331
|
+
// AMD registration happens at the end for compatibility with AMD loaders
|
1332
|
+
// that may not enforce next-turn semantics on modules. Even though general
|
1333
|
+
// practice for AMD registration is to be anonymous, underscore registers
|
1334
|
+
// as a named module because, like jQuery, it is a base library that is
|
1335
|
+
// popular enough to be bundled in a third party lib, but not be part of
|
1336
|
+
// an AMD load request. Those cases could generate an error when an
|
1337
|
+
// anonymous define() is called outside of a loader request.
|
1338
|
+
if (typeof define === 'function' && define.amd) {
|
1339
|
+
define('underscore', [], function() {
|
1340
|
+
return _;
|
1341
|
+
});
|
1342
|
+
}
|
1343
|
+
}).call(this);
|