cssesc-source 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/cssesc/source.rb +7 -0
- data/vendor/LICENSE-MIT.txt +20 -0
- data/vendor/README.md +207 -0
- data/vendor/bin/cssesc +122 -0
- data/vendor/cssesc.js +177 -0
- data/vendor/man/cssesc.1 +70 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/MIT-LICENSE.txt +21 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/README.md +43 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/bin/stripcolorcodes.js +18 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/index.js +3 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/package.json +42 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/test/fixture/with-colors +2 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/test/fixture/without-colors +2 -0
- data/vendor/node_modules/grunt-shell/node_modules/stripcolorcodes/test/stripcolorcodes-test.js +20 -0
- data/vendor/node_modules/grunt-shell/package.json +53 -0
- data/vendor/node_modules/grunt-shell/readme.md +221 -0
- data/vendor/node_modules/grunt-shell/tasks/shell.js +54 -0
- data/vendor/node_modules/grunt-template/LICENSE-MIT.txt +20 -0
- data/vendor/node_modules/grunt-template/README.md +123 -0
- data/vendor/node_modules/grunt-template/package.json +50 -0
- data/vendor/node_modules/grunt-template/tasks/template.js +44 -0
- data/vendor/node_modules/grunt/CONTRIBUTING.md +1 -0
- data/vendor/node_modules/grunt/LICENSE-MIT +22 -0
- data/vendor/node_modules/grunt/README.md +16 -0
- data/vendor/node_modules/grunt/internal-tasks/bump.js +151 -0
- data/vendor/node_modules/grunt/internal-tasks/subgrunt.js +34 -0
- data/vendor/node_modules/grunt/lib/grunt.js +156 -0
- data/vendor/node_modules/grunt/lib/grunt/cli.js +128 -0
- data/vendor/node_modules/grunt/lib/grunt/config.js +118 -0
- data/vendor/node_modules/grunt/lib/grunt/event.js +16 -0
- data/vendor/node_modules/grunt/lib/grunt/fail.js +84 -0
- data/vendor/node_modules/grunt/lib/grunt/file.js +440 -0
- data/vendor/node_modules/grunt/lib/grunt/help.js +129 -0
- data/vendor/node_modules/grunt/lib/grunt/log.js +352 -0
- data/vendor/node_modules/grunt/lib/grunt/option.js +42 -0
- data/vendor/node_modules/grunt/lib/grunt/task.js +451 -0
- data/vendor/node_modules/grunt/lib/grunt/template.js +95 -0
- data/vendor/node_modules/grunt/lib/grunt/util.js +188 -0
- data/vendor/node_modules/grunt/lib/util/task.js +323 -0
- data/vendor/node_modules/grunt/node_modules/async/LICENSE +19 -0
- data/vendor/node_modules/grunt/node_modules/async/Makefile +25 -0
- data/vendor/node_modules/grunt/node_modules/async/README.md +1021 -0
- data/vendor/node_modules/grunt/node_modules/async/index.js +3 -0
- data/vendor/node_modules/grunt/node_modules/async/lib/async.js +692 -0
- data/vendor/node_modules/grunt/node_modules/async/package.json +32 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/CNAME +1 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/LICENSE +22 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/README +51 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/Rakefile +78 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/bin/cake +7 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/bin/coffee +7 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/vendor/node_modules/grunt/node_modules/coffee-script/package.json +47 -0
- data/vendor/node_modules/grunt/node_modules/colors/MIT-LICENSE.txt +22 -0
- data/vendor/node_modules/grunt/node_modules/colors/ReadMe.md +77 -0
- data/vendor/node_modules/grunt/node_modules/colors/colors.js +342 -0
- data/vendor/node_modules/grunt/node_modules/colors/example.html +76 -0
- data/vendor/node_modules/grunt/node_modules/colors/example.js +77 -0
- data/vendor/node_modules/grunt/node_modules/colors/package.json +29 -0
- data/vendor/node_modules/grunt/node_modules/colors/test.js +70 -0
- data/vendor/node_modules/grunt/node_modules/colors/themes/winston-dark.js +12 -0
- data/vendor/node_modules/grunt/node_modules/colors/themes/winston-light.js +12 -0
- data/vendor/node_modules/grunt/node_modules/dateformat/Readme.md +67 -0
- data/vendor/node_modules/grunt/node_modules/dateformat/lib/dateformat.js +165 -0
- data/vendor/node_modules/grunt/node_modules/dateformat/package.json +20 -0
- data/vendor/node_modules/grunt/node_modules/dateformat/test/test_weekofyear.js +4 -0
- data/vendor/node_modules/grunt/node_modules/dateformat/test/test_weekofyear.sh +27 -0
- data/vendor/node_modules/grunt/node_modules/eventemitter2/README.md +212 -0
- data/vendor/node_modules/grunt/node_modules/eventemitter2/index.js +1 -0
- data/vendor/node_modules/grunt/node_modules/eventemitter2/lib/eventemitter2.js +561 -0
- data/vendor/node_modules/grunt/node_modules/eventemitter2/package.json +62 -0
- data/vendor/node_modules/grunt/node_modules/exit/Gruntfile.js +48 -0
- data/vendor/node_modules/grunt/node_modules/exit/LICENSE-MIT +22 -0
- data/vendor/node_modules/grunt/node_modules/exit/README.md +75 -0
- data/vendor/node_modules/grunt/node_modules/exit/lib/exit.js +41 -0
- data/vendor/node_modules/grunt/node_modules/exit/package.json +51 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/exit_test.js +121 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/10-stderr.txt +10 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/10-stdout-stderr.txt +20 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/10-stdout.txt +10 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/100-stderr.txt +100 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/100-stdout-stderr.txt +200 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/100-stdout.txt +100 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/1000-stderr.txt +1000 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/1000-stdout-stderr.txt +2000 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/1000-stdout.txt +1000 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/create-files.sh +8 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/log-broken.js +23 -0
- data/vendor/node_modules/grunt/node_modules/exit/test/fixtures/log.js +25 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/Gruntfile.js +25 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/LICENSE-MIT +22 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/README.md +44 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/lib/findup-sync.js +46 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/README.md +164 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.js +5152 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.compat.min.js +42 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.js +4983 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.min.js +40 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.underscore.js +4307 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/dist/lodash.underscore.min.js +34 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/package.json +62 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/package.json +48 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/test/findup-sync_test.js +48 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/test/fixtures/a.txt +0 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/b/bar.txt +0 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/foo.txt +0 -0
- data/vendor/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt +0 -0
- data/vendor/node_modules/grunt/node_modules/getobject/Gruntfile.js +48 -0
- data/vendor/node_modules/grunt/node_modules/getobject/LICENSE-MIT +22 -0
- data/vendor/node_modules/grunt/node_modules/getobject/README.md +20 -0
- data/vendor/node_modules/grunt/node_modules/getobject/lib/getobject.js +60 -0
- data/vendor/node_modules/grunt/node_modules/getobject/package.json +48 -0
- data/vendor/node_modules/grunt/node_modules/getobject/test/namespace_test.js +51 -0
- data/vendor/node_modules/grunt/node_modules/glob/LICENSE +27 -0
- data/vendor/node_modules/grunt/node_modules/glob/README.md +233 -0
- data/vendor/node_modules/grunt/node_modules/glob/examples/g.js +9 -0
- data/vendor/node_modules/grunt/node_modules/glob/examples/usr-local.js +9 -0
- data/vendor/node_modules/grunt/node_modules/glob/glob.js +643 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/LICENSE +27 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/README.md +33 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/graceful-fs.js +442 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/package.json +49 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/test/open.js +46 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/test/ulimit.js +158 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/inherits/README.md +51 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/inherits/inherits.js +29 -0
- data/vendor/node_modules/grunt/node_modules/glob/node_modules/inherits/package.json +30 -0
- data/vendor/node_modules/grunt/node_modules/glob/package.json +40 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/00-setup.js +176 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/bash-comparison.js +63 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/bash-results.json +348 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/cwd-test.js +55 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/mark.js +74 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/nocase-nomagic.js +113 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/pause-resume.js +73 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/root-nomount.js +39 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/root.js +46 -0
- data/vendor/node_modules/grunt/node_modules/glob/test/zz-cleanup.js +11 -0
- data/vendor/node_modules/grunt/node_modules/hooker/LICENSE-MIT +22 -0
- data/vendor/node_modules/grunt/node_modules/hooker/README.md +186 -0
- data/vendor/node_modules/grunt/node_modules/hooker/child.js +101 -0
- data/vendor/node_modules/grunt/node_modules/hooker/dist/ba-hooker.js +169 -0
- data/vendor/node_modules/grunt/node_modules/hooker/dist/ba-hooker.min.js +4 -0
- data/vendor/node_modules/grunt/node_modules/hooker/grunt.js +47 -0
- data/vendor/node_modules/grunt/node_modules/hooker/lib/hooker.js +174 -0
- data/vendor/node_modules/grunt/node_modules/hooker/package.json +45 -0
- data/vendor/node_modules/grunt/node_modules/hooker/parent.js +17 -0
- data/vendor/node_modules/grunt/node_modules/hooker/test/hooker_test.js +435 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/LICENSE +21 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/README.md +72 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/README.md~ +54 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/encodings/big5.js +9 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/encodings/gbk.js +9 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/encodings/singlebyte.js +340 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/encodings/table/big5.js +1 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/encodings/table/gbk.js +1 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/generation/generate-big5-table.js +25 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/generation/generate-singlebyte.js +142 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/index.js +231 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/package.json +80 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/big5-test.js +36 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/big5File.txt +13 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/cyrillic-test.js +86 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/gbk-test.js +38 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/gbkFile.txt +14 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/greek-test.js +79 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/main-test.js +55 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/performance.js +67 -0
- data/vendor/node_modules/grunt/node_modules/iconv-lite/test/turkish-test.js +90 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/HISTORY.md +155 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/LICENSE +21 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/README.md +249 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/bin/js-yaml.js +125 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/custom_types.js +104 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/custom_types.yaml +18 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/dumper.js +31 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/dumper.json +22 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/sample_document.js +15 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/examples/sample_document.yaml +197 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/index.js +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml.js +33 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/common.js +60 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/dumper.js +437 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/exception.js +25 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/loader.js +1549 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/mark.js +78 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/require.js +23 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/schema.js +103 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/schema/default.js +16 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/schema/minimal.js +13 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/schema/safe.js +25 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type.js +82 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/binary.js +118 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/bool.js +74 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/float.js +102 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/int.js +85 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/js/function.js +56 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +56 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/map.js +11 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/merge.js +18 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/null.js +36 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/omap.js +53 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/pairs.js +41 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/seq.js +11 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/set.js +31 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/str.js +11 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +91 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/HISTORY.md +109 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/LICENSE +21 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/README.md +239 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/arguments.js +36 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/choice.js +22 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/constants.js +59 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/help.js +13 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/nargs.js +33 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/parents.js +28 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js +23 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js +49 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/sum.js +35 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js +270 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/index.js +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action.js +146 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/append.js +55 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/append/constant.js +47 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/count.js +40 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/help.js +48 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/store.js +50 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/store/constant.js +43 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/store/false.js +27 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/store/true.js +26 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/subparsers.js +148 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action/version.js +50 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/action_container.js +481 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/argparse.js +14 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/argument/error.js +50 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/argument/exclusive.js +54 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/argument/group.js +75 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/argument_parser.js +1165 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/const.js +18 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/help/added_formatters.js +88 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/help/formatter.js +803 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/lib/namespace.js +77 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile +4 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile.lock +17 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown +814 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Rakefile +23 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/component.json +11 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/dist/underscore.string.min.js +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/lib/underscore.string.js +673 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log +0 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json +73 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/run-qunit.js +45 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/speed.js +148 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/strings.js +685 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/strings_standalone.js +12 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test.html +31 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_standalone.html +18 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/arrays.js +200 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/chaining.js +59 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/collections.js +426 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/functions.js +259 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/index.html +45 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/objects.js +548 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/speed.js +75 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/utility.js +249 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/jquery.js +9404 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/jslitmus.js +670 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/qunit.css +235 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/qunit.js +1977 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/underscore.js +1201 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CNAME +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CONTRIBUTING.md +9 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE +22 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md +19 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/favicon.ico +0 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/index.html +2467 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/index.js +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json +35 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore-min.js +1 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore.js +1226 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/package.json +50 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/README.md +73 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/bin/esparse.js +117 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/bin/esvalidate.js +177 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/esprima.js +3908 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/package.json +59 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/test/compat.js +239 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/test/reflect.js +422 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/test/run.js +66 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/test/runner.js +387 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/node_modules/esprima/test/test.js +20238 -0
- data/vendor/node_modules/grunt/node_modules/js-yaml/package.json +60 -0
- data/vendor/node_modules/grunt/node_modules/lodash/README.md +140 -0
- data/vendor/node_modules/grunt/node_modules/lodash/lodash.js +4258 -0
- data/vendor/node_modules/grunt/node_modules/lodash/lodash.min.js +35 -0
- data/vendor/node_modules/grunt/node_modules/lodash/lodash.underscore.js +3688 -0
- data/vendor/node_modules/grunt/node_modules/lodash/lodash.underscore.min.js +28 -0
- data/vendor/node_modules/grunt/node_modules/lodash/package.json +62 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/README.md +218 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/minimatch.js +1055 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/package.json +40 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/test/brace-expand.js +33 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/test/caching.js +14 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/node_modules/grunt/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/node_modules/grunt/node_modules/nopt/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/nopt/README.md +208 -0
- data/vendor/node_modules/grunt/node_modules/nopt/bin/nopt.js +44 -0
- data/vendor/node_modules/grunt/node_modules/nopt/examples/my-program.js +30 -0
- data/vendor/node_modules/grunt/node_modules/nopt/lib/nopt.js +552 -0
- data/vendor/node_modules/grunt/node_modules/nopt/node_modules/abbrev/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/nopt/node_modules/abbrev/README.md +23 -0
- data/vendor/node_modules/grunt/node_modules/nopt/node_modules/abbrev/lib/abbrev.js +111 -0
- data/vendor/node_modules/grunt/node_modules/nopt/node_modules/abbrev/package.json +29 -0
- data/vendor/node_modules/grunt/node_modules/nopt/package.json +36 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/AUTHORS +6 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/README.md +21 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/README.md +5 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js +312 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/package.json +40 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/test/open.js +41 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/package.json +59 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/rimraf.js +161 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/test/run.sh +10 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/test/setup.sh +47 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/test/test-async.js +5 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/test/test-fiber.js +0 -0
- data/vendor/node_modules/grunt/node_modules/rimraf/test/test-sync.js +3 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/Gemfile +5 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/Gemfile.lock +34 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/README.markdown +668 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/Rakefile +28 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/dist/underscore.string.min.js +1 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/lib/underscore.string.js +525 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/package.json +72 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/run-qunit.js +44 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/speed.js +138 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/strings.js +438 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/strings_standalone.js +12 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test.html +31 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_standalone.html +18 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/arrays.js +166 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/chaining.js +59 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/collections.js +270 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/functions.js +198 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/objects.js +535 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/speed.js +70 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/temp.js +27 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/temp_tests.html +19 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/test.html +43 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/utility.js +155 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/jquery.js +19 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/jslitmus.js +670 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/qunit.css +196 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/qunit.js +2360 -0
- data/vendor/node_modules/grunt/node_modules/underscore.string/test/underscore.js +999 -0
- data/vendor/node_modules/grunt/node_modules/which/LICENSE +23 -0
- data/vendor/node_modules/grunt/node_modules/which/README.md +5 -0
- data/vendor/node_modules/grunt/node_modules/which/bin/which +14 -0
- data/vendor/node_modules/grunt/node_modules/which/package.json +31 -0
- data/vendor/node_modules/grunt/node_modules/which/which.js +104 -0
- data/vendor/node_modules/grunt/package.json +82 -0
- data/vendor/node_modules/istanbul/CHANGELOG.md +57 -0
- data/vendor/node_modules/istanbul/LICENSE +24 -0
- data/vendor/node_modules/istanbul/README.md +205 -0
- data/vendor/node_modules/istanbul/index.js +115 -0
- data/vendor/node_modules/istanbul/lib/cli.js +74 -0
- data/vendor/node_modules/istanbul/lib/collector.js +121 -0
- data/vendor/node_modules/istanbul/lib/command/check-coverage.js +115 -0
- data/vendor/node_modules/istanbul/lib/command/common/run-with-cover.js +199 -0
- data/vendor/node_modules/istanbul/lib/command/cover.js +33 -0
- data/vendor/node_modules/istanbul/lib/command/help.js +58 -0
- data/vendor/node_modules/istanbul/lib/command/index.js +33 -0
- data/vendor/node_modules/istanbul/lib/command/instrument.js +244 -0
- data/vendor/node_modules/istanbul/lib/command/report.js +97 -0
- data/vendor/node_modules/istanbul/lib/command/test.js +31 -0
- data/vendor/node_modules/istanbul/lib/hook.js +187 -0
- data/vendor/node_modules/istanbul/lib/instrumenter.js +759 -0
- data/vendor/node_modules/istanbul/lib/object-utils.js +341 -0
- data/vendor/node_modules/istanbul/lib/register-plugins.js +15 -0
- data/vendor/node_modules/istanbul/lib/report/cobertura.js +207 -0
- data/vendor/node_modules/istanbul/lib/report/html.js +517 -0
- data/vendor/node_modules/istanbul/lib/report/index.js +60 -0
- data/vendor/node_modules/istanbul/lib/report/json.js +55 -0
- data/vendor/node_modules/istanbul/lib/report/lcov.js +49 -0
- data/vendor/node_modules/istanbul/lib/report/lcovonly.js +93 -0
- data/vendor/node_modules/istanbul/lib/report/none.js +20 -0
- data/vendor/node_modules/istanbul/lib/report/teamcity.js +82 -0
- data/vendor/node_modules/istanbul/lib/report/templates/foot.txt +102 -0
- data/vendor/node_modules/istanbul/lib/report/templates/head.txt +200 -0
- data/vendor/node_modules/istanbul/lib/report/text-summary.js +72 -0
- data/vendor/node_modules/istanbul/lib/report/text.js +210 -0
- data/vendor/node_modules/istanbul/lib/store/fslookup.js +60 -0
- data/vendor/node_modules/istanbul/lib/store/index.js +122 -0
- data/vendor/node_modules/istanbul/lib/store/memory.js +55 -0
- data/vendor/node_modules/istanbul/lib/store/tmp.js +80 -0
- data/vendor/node_modules/istanbul/lib/util/factory.js +88 -0
- data/vendor/node_modules/istanbul/lib/util/file-matcher.js +60 -0
- data/vendor/node_modules/istanbul/lib/util/file-writer.js +131 -0
- data/vendor/node_modules/istanbul/lib/util/flow-control.js +26 -0
- data/vendor/node_modules/istanbul/lib/util/help-formatter.js +24 -0
- data/vendor/node_modules/istanbul/lib/util/input-error.js +12 -0
- data/vendor/node_modules/istanbul/lib/util/insertion-text.js +109 -0
- data/vendor/node_modules/istanbul/lib/util/meta.js +13 -0
- data/vendor/node_modules/istanbul/lib/util/tree-summarizer.js +213 -0
- data/vendor/node_modules/istanbul/lib/util/writer.js +56 -0
- data/vendor/node_modules/istanbul/lib/util/yui-load-hook.js +49 -0
- data/vendor/node_modules/istanbul/lib/vendor/prettify.css +1 -0
- data/vendor/node_modules/istanbul/lib/vendor/prettify.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/abbrev/LICENSE +23 -0
- data/vendor/node_modules/istanbul/node_modules/abbrev/README.md +23 -0
- data/vendor/node_modules/istanbul/node_modules/abbrev/lib/abbrev.js +111 -0
- data/vendor/node_modules/istanbul/node_modules/abbrev/package.json +29 -0
- data/vendor/node_modules/istanbul/node_modules/async/LICENSE +19 -0
- data/vendor/node_modules/istanbul/node_modules/async/README.md +1414 -0
- data/vendor/node_modules/istanbul/node_modules/async/component.json +11 -0
- data/vendor/node_modules/istanbul/node_modules/async/lib/async.js +955 -0
- data/vendor/node_modules/istanbul/node_modules/async/package.json +43 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/LICENSE.BSD +19 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/LICENSE.source-map +27 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/README.md +99 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/bin/escodegen.js +45 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/bin/esgenerate.js +45 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/component.json +48 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/escodegen.browser.js +3072 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/escodegen.js +2275 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/estraverse/LICENSE.BSD +19 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/estraverse/README.md +29 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/estraverse/estraverse.js +315 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/estraverse/package.json +41 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/CHANGELOG.md +112 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/LICENSE +28 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/Makefile.dryice.js +166 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/README.md +434 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/assert-shim.js +56 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/mini-require.js +152 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/suffix-browser.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/suffix-utils.jsm +21 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/test-prefix.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/build/test-suffix.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/array-set.js +97 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-consumer.js +477 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/source-map-generator.js +380 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/source-node.js +371 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/lib/source-map/util.js +205 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/README.md +171 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/intercept.js +36 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/node_modules/amdefine/package.json +36 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/package.json +110 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/run-tests.js +71 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-array-set.js +104 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-map-consumer.js +451 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-map-generator.js +417 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/test-source-node.js +365 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/node_modules/source-map/test/source-map/util.js +161 -0
- data/vendor/node_modules/istanbul/node_modules/escodegen/package.json +58 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/README.md +73 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/bin/esparse.js +117 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/bin/esvalidate.js +177 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/esprima.js +3908 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/package.json +59 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/test/compat.js +239 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/test/reflect.js +422 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/test/run.js +66 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/test/runner.js +387 -0
- data/vendor/node_modules/istanbul/node_modules/esprima/test/test.js +20238 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/LICENSE-MIT +22 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/README.md +87 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/lib/fileset.js +64 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/LICENSE +27 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/README.md +250 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/examples/g.js +9 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/examples/usr-local.js +9 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/glob.js +680 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/README.md +42 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/package.json +33 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/node_modules/inherits/test.js +25 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/package.json +39 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/00-setup.js +176 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/bash-comparison.js +63 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/bash-results.json +350 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/cwd-test.js +55 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/globstar-match.js +19 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/mark.js +74 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/new-glob-optional-options.js +10 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/nocase-nomagic.js +113 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/pause-resume.js +73 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/root-nomount.js +39 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/root.js +46 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/stat.js +32 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/zz-cleanup.js +11 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/LICENSE +23 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/README.md +218 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/minimatch.js +1055 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/package.json +40 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/test/basic.js +399 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/test/brace-expand.js +33 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/test/caching.js +14 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/test/defaults.js +274 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/package.json +34 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/tests/fixtures/an (odd) filename.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/tests/helper.js +61 -0
- data/vendor/node_modules/istanbul/node_modules/fileset/tests/test.js +133 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/LICENSE +19 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/README.markdown +391 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/bin/handlebars +213 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/bower.json +9 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/dist/handlebars.js +2278 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/dist/handlebars.min.js +2 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/dist/handlebars.runtime.js +362 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/dist/handlebars.runtime.min.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/global-test.js +18 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/global.js +4 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/handlebars-source.gemspec +21 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/handlebars.js.nuspec +17 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars.js +43 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/base.js +166 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/browser-prefix.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/browser-suffix.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/ast.js +138 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/base.js +21 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/compiler.js +1305 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/index.js +16 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/parser.js +483 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/printer.js +138 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/compiler/visitor.js +18 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/runtime.js +106 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/source.rb +11 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/lib/handlebars/utils.js +83 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/min.sh +11 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/LICENSE +21 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/bool.js +10 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/boolean_double.js +7 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/boolean_single.js +7 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/default_hash.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/default_singles.js +7 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/divide.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/line_count.js +20 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/line_count_options.js +29 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/line_count_wrap.js +29 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/nonopt.js +4 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/reflect.js +2 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/short.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/string.js +11 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/usage-options.js +19 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/example/xup.js +10 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/index.js +478 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/package.json +46 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/readme.markdown +487 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/test/_.js +71 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/test/_/argv.js +2 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/test/_/bin.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/test/parse.js +446 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/optimist/test/usage.js +292 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/LICENSE +29 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/README.md +588 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/bin/uglifyjs +402 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/ast.js +985 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/compress.js +2028 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/mozilla-ast.js +267 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/output.js +1229 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/parse.js +1410 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/scope.js +581 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/sourcemap.js +81 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/transform.js +217 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/lib/utils.js +295 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/CHANGELOG.md +112 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/LICENSE +28 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/Makefile.dryice.js +166 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/README.md +434 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/assert-shim.js +56 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/mini-require.js +152 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/suffix-browser.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/suffix-utils.jsm +21 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/test-prefix.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/build/test-suffix.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/array-set.js +97 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-consumer.js +477 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js +380 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-node.js +371 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/lib/source-map/util.js +205 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/README.md +171 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/intercept.js +36 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/package.json +37 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/package.json +110 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/run-tests.js +71 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-array-set.js +104 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-source-map-consumer.js +451 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-source-map-generator.js +417 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/test-source-node.js +365 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/node_modules/source-map/test/source-map/util.js +161 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/package.json +39 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/arrays.js +12 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/blocks.js +49 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/conditionals.js +143 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/dead-code.js +89 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/debugger.js +24 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/drop-unused.js +97 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-105.js +25 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-12.js +11 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-143.js +48 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-22.js +17 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-44.js +31 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/issue-59.js +30 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/labels.js +163 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/loops.js +123 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/properties.js +54 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/sequences.js +161 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/switch.js +260 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/compress/typeof.js +25 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/test/run-tests.js +170 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/node_modules/uglify-js/tools/node.js +165 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/package.json +42 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/release-notes.md +93 -0
- data/vendor/node_modules/istanbul/node_modules/handlebars/test.js +20 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/LICENSE +21 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/examples/pow.js +6 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/index.js +82 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/package.json +34 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/readme.markdown +63 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/chmod.js +38 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/clobber.js +37 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/perm.js +32 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/race.js +41 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/rel.js +32 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/return.js +25 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/return_sync.js +24 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/root.js +18 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/sync.js +32 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/umask.js +28 -0
- data/vendor/node_modules/istanbul/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/LICENSE +23 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/README.md +210 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/bin/nopt.js +51 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/examples/my-program.js +30 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/lib/nopt.js +612 -0
- data/vendor/node_modules/istanbul/node_modules/nopt/package.json +36 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/LICENSE +18 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/example/async.js +5 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/example/sync.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/index.js +5 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/async.js +125 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/caller.js +8 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/core.js +4 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/core.json +38 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/node-modules-paths.js +25 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/lib/sync.js +80 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/package.json +36 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/readme.markdown +144 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/core.js +12 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/filter.js +18 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/filter_sync.js +15 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/mock.js +142 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/mock_sync.js +68 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver.js +270 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/bar/node_modules/foo/index.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/baz/doom.js +0 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/baz/package.json +3 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/baz/quux.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/biz/node_modules/garply/lib/index.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/biz/node_modules/garply/package.json +3 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/biz/node_modules/grux/index.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/biz/node_modules/tiv/index.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/cup.coffee +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/foo.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/incorrect_main/index.js +2 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/incorrect_main/package.json +3 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/mug.coffee +0 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/mug.js +0 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/other_path/lib/other-lib.js +0 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/other_path/root.js +0 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/quux/foo/index.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/without_basedir/main.js +6 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver/without_basedir/node_modules/mymodule.js +1 -0
- data/vendor/node_modules/istanbul/node_modules/resolve/test/resolver_sync.js +170 -0
- data/vendor/node_modules/istanbul/node_modules/which/LICENSE +23 -0
- data/vendor/node_modules/istanbul/node_modules/which/README.md +5 -0
- data/vendor/node_modules/istanbul/node_modules/which/bin/which +14 -0
- data/vendor/node_modules/istanbul/node_modules/which/package.json +32 -0
- data/vendor/node_modules/istanbul/node_modules/which/which.js +104 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/README.markdown +70 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/example/center.js +10 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/example/meat.js +3 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/index.js +76 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/package.json +45 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/test/break.js +30 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/test/idleness.txt +63 -0
- data/vendor/node_modules/istanbul/node_modules/wordwrap/test/wrap.js +31 -0
- data/vendor/node_modules/istanbul/package.json +117 -0
- data/vendor/node_modules/istanbul/test/browser/support/index.html +153 -0
- data/vendor/node_modules/istanbul/test/browser/support/phantom-test.client.js +49 -0
- data/vendor/node_modules/istanbul/test/browser/support/server.js +154 -0
- data/vendor/node_modules/istanbul/test/browser/test-browser-instrumentation.js +94 -0
- data/vendor/node_modules/istanbul/test/cli-helper.js +219 -0
- data/vendor/node_modules/istanbul/test/cli/package.json +8 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/amd/ipsum.js +11 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/amd/lorem.js +7 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/lib/bar.js +13 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/lib/foo.js +12 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/lib/util/bad.js +1 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/lib/util/generate-names.js +5 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/node_modules/dependency/index.js +9 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/node_modules/post-require/hook.js +11 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/node_modules/post-require/package.json +5 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/test/amd-run.js +16 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/test/global-leak.js +30 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/test/run.js +25 -0
- data/vendor/node_modules/istanbul/test/cli/sample-project/vendor/dummy_vendor_lib.js +9 -0
- data/vendor/node_modules/istanbul/test/cli/test-base-cli.js +39 -0
- data/vendor/node_modules/istanbul/test/cli/test-check-coverage-command.js +97 -0
- data/vendor/node_modules/istanbul/test/cli/test-cobertura-report.js +54 -0
- data/vendor/node_modules/istanbul/test/cli/test-cover-command.js +170 -0
- data/vendor/node_modules/istanbul/test/cli/test-html-report.js +125 -0
- data/vendor/node_modules/istanbul/test/cli/test-instrument-command.js +167 -0
- data/vendor/node_modules/istanbul/test/cli/test-json-report.js +60 -0
- data/vendor/node_modules/istanbul/test/cli/test-lcov-report.js +58 -0
- data/vendor/node_modules/istanbul/test/cli/test-lcovonly-report.js +61 -0
- data/vendor/node_modules/istanbul/test/cli/test-lots-of-files.js +87 -0
- data/vendor/node_modules/istanbul/test/cli/test-none-report.js +17 -0
- data/vendor/node_modules/istanbul/test/cli/test-report-command.js +65 -0
- data/vendor/node_modules/istanbul/test/cli/test-teamcity-report.js +54 -0
- data/vendor/node_modules/istanbul/test/cli/test-test-command.js +43 -0
- data/vendor/node_modules/istanbul/test/common.js +19 -0
- data/vendor/node_modules/istanbul/test/helper.js +122 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-do.js +53 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-expressions.js +70 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-for.js +206 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-forin.js +50 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-functions.js +102 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-if.js +393 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-misc.js +35 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-statement.js +182 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-strict.js +121 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-switch.js +155 -0
- data/vendor/node_modules/istanbul/test/instrumentation/test-while.js +104 -0
- data/vendor/node_modules/istanbul/test/loader.js +38 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/baz.js +3 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/fixture.xml +1 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/foo.js +4 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/myfile1 +0 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/myfile2 +1 -0
- data/vendor/node_modules/istanbul/test/other/data-complete-copy/subdir/x.css +3 -0
- data/vendor/node_modules/istanbul/test/other/data/baz.js +3 -0
- data/vendor/node_modules/istanbul/test/other/data/foo.js +4 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/general/general.js +2 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/general/node_modules/mod-file.js +2 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/lib/lib-top.js +2 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/node_modules/dep/mod-file.js +2 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/node_modules/mod-file.js +2 -0
- data/vendor/node_modules/istanbul/test/other/data/matcher/top.js +2 -0
- data/vendor/node_modules/istanbul/test/other/test-collector.js +85 -0
- data/vendor/node_modules/istanbul/test/other/test-command-xface.js +35 -0
- data/vendor/node_modules/istanbul/test/other/test-file-writer.js +71 -0
- data/vendor/node_modules/istanbul/test/other/test-help-formatter.js +31 -0
- data/vendor/node_modules/istanbul/test/other/test-hook.js +87 -0
- data/vendor/node_modules/istanbul/test/other/test-index-xface.js +17 -0
- data/vendor/node_modules/istanbul/test/other/test-input-error.js +10 -0
- data/vendor/node_modules/istanbul/test/other/test-insertion-text.js +102 -0
- data/vendor/node_modules/istanbul/test/other/test-matcher.js +93 -0
- data/vendor/node_modules/istanbul/test/other/test-object-utils.js +201 -0
- data/vendor/node_modules/istanbul/test/other/test-store.js +129 -0
- data/vendor/node_modules/istanbul/test/other/test-summarizer.js +172 -0
- data/vendor/node_modules/istanbul/test/run-again.js +19 -0
- data/vendor/node_modules/istanbul/test/run.js +108 -0
- data/vendor/node_modules/istanbul/yui-coverage-comparison.md +85 -0
- data/vendor/node_modules/qunit-clib/LICENSE.txt +20 -0
- data/vendor/node_modules/qunit-clib/README.md +2 -0
- data/vendor/node_modules/qunit-clib/package.json +36 -0
- data/vendor/node_modules/qunit-clib/qunit-clib.js +570 -0
- data/vendor/node_modules/qunitjs/AUTHORS.txt +55 -0
- data/vendor/node_modules/qunitjs/History.md +496 -0
- data/vendor/node_modules/qunitjs/README.md +62 -0
- data/vendor/node_modules/qunitjs/addons/canvas/README.md +17 -0
- data/vendor/node_modules/qunitjs/addons/canvas/canvas-test.js +76 -0
- data/vendor/node_modules/qunitjs/addons/canvas/canvas.html +15 -0
- data/vendor/node_modules/qunitjs/addons/canvas/qunit-canvas.js +6 -0
- data/vendor/node_modules/qunitjs/addons/close-enough/README.md +18 -0
- data/vendor/node_modules/qunitjs/addons/close-enough/close-enough-test.js +35 -0
- data/vendor/node_modules/qunitjs/addons/close-enough/close-enough.html +14 -0
- data/vendor/node_modules/qunitjs/addons/close-enough/qunit-close-enough.js +32 -0
- data/vendor/node_modules/qunitjs/addons/composite/README.md +26 -0
- data/vendor/node_modules/qunitjs/addons/composite/composite-demo-test.html +24 -0
- data/vendor/node_modules/qunitjs/addons/composite/index.html +34 -0
- data/vendor/node_modules/qunitjs/addons/composite/qunit-composite.css +13 -0
- data/vendor/node_modules/qunitjs/addons/composite/qunit-composite.js +112 -0
- data/vendor/node_modules/qunitjs/addons/junitlogger/README.md +18 -0
- data/vendor/node_modules/qunitjs/addons/junitlogger/index.html +44 -0
- data/vendor/node_modules/qunitjs/addons/junitlogger/junitlogger.js +306 -0
- data/vendor/node_modules/qunitjs/addons/phantomjs/README.md +16 -0
- data/vendor/node_modules/qunitjs/addons/phantomjs/runner.js +127 -0
- data/vendor/node_modules/qunitjs/addons/step/README.md +20 -0
- data/vendor/node_modules/qunitjs/addons/step/qunit-step.js +26 -0
- data/vendor/node_modules/qunitjs/addons/step/step-test.js +15 -0
- data/vendor/node_modules/qunitjs/addons/step/step.html +14 -0
- data/vendor/node_modules/qunitjs/addons/themes/README.md +6 -0
- data/vendor/node_modules/qunitjs/addons/themes/gabe.css +371 -0
- data/vendor/node_modules/qunitjs/addons/themes/gabe.html +15 -0
- data/vendor/node_modules/qunitjs/addons/themes/ninja.css +196 -0
- data/vendor/node_modules/qunitjs/addons/themes/ninja.html +15 -0
- data/vendor/node_modules/qunitjs/addons/themes/nv.css +217 -0
- data/vendor/node_modules/qunitjs/addons/themes/nv.html +15 -0
- data/vendor/node_modules/qunitjs/grunt.js +101 -0
- data/vendor/node_modules/qunitjs/package.json +49 -0
- data/vendor/node_modules/qunitjs/qunit/qunit.css +244 -0
- data/vendor/node_modules/qunitjs/qunit/qunit.js +2152 -0
- data/vendor/node_modules/qunitjs/test/async.html +26 -0
- data/vendor/node_modules/qunitjs/test/async.js +6 -0
- data/vendor/node_modules/qunitjs/test/deepEqual.js +1438 -0
- data/vendor/node_modules/qunitjs/test/headless.html +28 -0
- data/vendor/node_modules/qunitjs/test/index.html +16 -0
- data/vendor/node_modules/qunitjs/test/logs.html +14 -0
- data/vendor/node_modules/qunitjs/test/logs.js +184 -0
- data/vendor/node_modules/qunitjs/test/narwhal-test.js +22 -0
- data/vendor/node_modules/qunitjs/test/node-test.js +22 -0
- data/vendor/node_modules/qunitjs/test/swarminject.js +10 -0
- data/vendor/node_modules/qunitjs/test/test.js +804 -0
- data/vendor/node_modules/regenerate/LICENSE-MIT.txt +20 -0
- data/vendor/node_modules/regenerate/README.md +467 -0
- data/vendor/node_modules/regenerate/package.json +50 -0
- data/vendor/node_modules/regenerate/regenerate.js +617 -0
- data/vendor/node_modules/requirejs/README.md +9 -0
- data/vendor/node_modules/requirejs/bin/r.js +26059 -0
- data/vendor/node_modules/requirejs/package.json +39 -0
- data/vendor/node_modules/requirejs/require.js +2054 -0
- data/vendor/package.json +56 -0
- metadata +949 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
"name": "js-yaml",
|
3
|
+
"version": "2.0.5",
|
4
|
+
"description": "YAML 1.2 parser and serializer",
|
5
|
+
"keywords": [
|
6
|
+
"yaml",
|
7
|
+
"parser",
|
8
|
+
"serializer",
|
9
|
+
"pyyaml"
|
10
|
+
],
|
11
|
+
"homepage": "https://github.com/nodeca/js-yaml",
|
12
|
+
"author": {
|
13
|
+
"name": "Dervus Grim",
|
14
|
+
"email": "dervus@lavabit.com"
|
15
|
+
},
|
16
|
+
"contributors": [
|
17
|
+
{
|
18
|
+
"name": "Aleksey V Zapparov",
|
19
|
+
"email": "ixti@member.fsf.org",
|
20
|
+
"url": "http://www.ixti.net/"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"name": "Martin Grenfell",
|
24
|
+
"email": "martin.grenfell@gmail.com",
|
25
|
+
"url": "http://got-ravings.blogspot.com"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"bugs": {
|
29
|
+
"url": "https://github.com/nodeca/js-yaml/issues"
|
30
|
+
},
|
31
|
+
"license": {
|
32
|
+
"type": "MIT",
|
33
|
+
"url": "https://github.com/nodeca/js-yaml/blob/master/LICENSE"
|
34
|
+
},
|
35
|
+
"repository": {
|
36
|
+
"type": "git",
|
37
|
+
"url": "git://github.com/nodeca/js-yaml.git"
|
38
|
+
},
|
39
|
+
"main": "./index.js",
|
40
|
+
"bin": {
|
41
|
+
"js-yaml": "bin/js-yaml.js"
|
42
|
+
},
|
43
|
+
"scripts": {
|
44
|
+
"test": "make test"
|
45
|
+
},
|
46
|
+
"dependencies": {
|
47
|
+
"argparse": "~ 0.1.11",
|
48
|
+
"esprima": "~ 1.0.2"
|
49
|
+
},
|
50
|
+
"devDependencies": {
|
51
|
+
"mocha": "*"
|
52
|
+
},
|
53
|
+
"engines": {
|
54
|
+
"node": ">= 0.6.0"
|
55
|
+
},
|
56
|
+
"readme": "JS-YAML - YAML 1.2 parser and serializer for JavaScript\n=======================================================\n\n[![Build Status](https://secure.travis-ci.org/nodeca/js-yaml.png)](http://travis-ci.org/nodeca/js-yaml)\n\n[Online Demo](http://nodeca.github.com/js-yaml/)\n\n\nThis is an implementation of [YAML](http://yaml.org/), a human friendly data\nserialization language. Started as [PyYAML](http://pyyaml.org/) port, it was\ncompletely rewritten from scratch. Now it's very fast, and supports 1.2 spec.\n\n\nBreaking changes in 1.x.x -> 2.0.x\n----------------------------------\n\nIf your have not used __custom__ tags or loader classes - no changes needed. Just\nupgrade library and enjoy high parse speed.\n\nIn other case, you should rewrite your tag constructors and custom loader\nclasses, to conform new schema-based API. See\n[examples](https://github.com/nodeca/js-yaml/tree/master/examples) and\n[wiki](https://github.com/nodeca/js-yaml/wiki) for details.\nNote, that parser internals were completely rewritten.\n\n\nInstallation\n------------\n\n### YAML module for node.js\n\n```\nnpm install js-yaml\n```\n\n\n### CLI executable\n\nIf you want to inspect your YAML files from CLI, install js-yaml globally:\n\n```\nnpm install js-yaml -g\n```\n\n#### Usage\n\n```\nusage: js-yaml [-h] [-v] [-c] [-j] [-t] file\n\nPositional arguments:\n file File with YAML document(s)\n\nOptional arguments:\n -h, --help Show this help message and exit.\n -v, --version Show program's version number and exit.\n -c, --compact Display errors in compact mode\n -j, --to-json Output a non-funky boring JSON\n -t, --trace Show stack trace on error\n```\n\n\n### Bundled YAML library for browsers\n\n``` html\n<script src=\"js-yaml.min.js\"></script>\n<script type=\"text/javascript\">\nvar doc = jsyaml.load('greeting: hello\\nname: world');\n</script>\n```\n\nBrowser support was done mostly for online demo. If you find any errors - feel\nfree to send pull requests with fixes. Also note, that IE and other old browsers\nneeds [es5-shims](https://github.com/kriskowal/es5-shim) to operate.\n\n\nAPI\n---\n\nHere we cover the most 'useful' methods. If you need advanced details (creating\nyour own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and\n[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more\ninfo.\n\nIn node.js JS-YAML automatically registers handlers for `.yml` and `.yaml`\nfiles. You can load them just with `require`. That's mostly equivalent to\ncalling `load()` on fetched content of a file. Just with one string!\n\n``` javascript\nrequire('js-yaml');\n\n// Get document, or throw exception on error\ntry {\n var doc = require('/home/ixti/example.yml');\n console.log(doc);\n} catch (e) {\n console.log(e);\n}\n```\n\n\n### load (string [ , options ])\n\nParses `string` as single YAML document. Returns a JavaScript object or throws\n`YAMLException` on error.\n\nNOTE: This function **does not** understands multi-document sources, it throws\nexception on those.\n\noptions:\n\n- `filename` _(default: null)_ - string to be used as a file path in\n error/warning messages.\n- `strict` _(default - false)_ makes the loader to throw errors instead of\n warnings.\n- `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use.\n\n\n### loadAll (string, iterator [ , options ])\n\nSame as `load()`, but understands multi-document sources and apply `iterator` to\neach document.\n\n``` javascript\nvar yaml = require('js-yaml');\n\nyaml.loadAll(data, function (doc) {\n console.log(doc);\n});\n```\n\n\n### safeLoad (string [ , options ])\n\nSame as `load()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\n### safeLoadAll (string, iterator [ , options ])\n\nSame as `loadAll()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\n### dump (object [ , options ])\n\nSerializes `object` as YAML document.\n\noptions:\n\n- `indent` _(default: 2)_ - indentation width to use (in spaces).\n- `flowLevel` (default: -1) - specifies level of nesting, when to switch from\n block to flow style for collections. -1 means block style everwhere\n- `styles` - \"tag\" => \"style\" map. Each tag may have own set of styles.\n- `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use.\n\nstyles:\n\n``` none\n!!null\n \"canonical\" => \"~\"\n\n!!int\n \"binary\" => \"0b1\", \"0b101010\", \"0b1110001111010\"\n \"octal\" => \"01\", \"052\", \"016172\"\n \"decimal\" => \"1\", \"42\", \"7290\"\n \"hexadecimal\" => \"0x1\", \"0x2A\", \"0x1C7A\"\n\n!!null, !!bool, !!float\n \"lowercase\" => \"null\", \"true\", \"false\", \".nan\", '.inf'\n \"uppercase\" => \"NULL\", \"TRUE\", \"FALSE\", \".NAN\", '.INF'\n \"camelcase\" => \"Null\", \"True\", \"False\", \".NaN\", '.Inf'\n```\n\nBy default, !!int uses `decimal`, and !!null, !!bool, !!float use `lowercase`.\n\n\n### safeDump (object [ , options ])\n\nSame as `dump()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\nSupported YAML types\n--------------------\n\nThe list of standard YAML tags and corresponding JavaScipt types. See also\n[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and\n[YAML types repository](http://yaml.org/type/).\n\n```\n!!null '' # null\n!!bool 'yes' # bool\n!!int '3...' # number\n!!float '3.14...' # number\n!!binary '...base64...' # buffer\n!!timestamp 'YYYY-...' # date\n!!omap [ ... ] # array of key-value pairs\n!!pairs [ ... ] # array or array pairs\n!!set { ... } # array of objects with given keys and null values\n!!str '...' # string\n!!seq [ ... ] # array\n!!map { ... } # object\n```\n\n**JavaScript-specific tags**\n\n```\n!!js/regexp /pattern/gim # RegExp\n!!js/undefined '' # Undefined\n!!js/function 'function () {...}' # Function\n```\n\n\n\n\n## Caveats\n\nNote, that you use arrays or objects as key in JS-YAML. JS do not allows objects\nor array as keys, and stringifies (by calling .toString method) them at the\nmoment of adding them.\n\n``` yaml\n---\n? [ foo, bar ]\n: - baz\n? { foo: bar }\n: - baz\n - baz\n```\n\n``` javascript\n{ \"foo,bar\": [\"baz\"], \"[object Object]\": [\"baz\", \"baz\"] }\n```\n\nAlso, reading of properties on implicit block mapping keys is not supported yet.\nSo, the following YAML document cannot be loaded.\n\n``` yaml\n&anchor foo:\n foo: bar\n *anchor: duplicate key\n baz: bat\n *anchor: duplicate key\n```\n\n## License\n\nView the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file\n(MIT).\n",
|
57
|
+
"readmeFilename": "README.md",
|
58
|
+
"_id": "js-yaml@2.0.5",
|
59
|
+
"_from": "js-yaml@~2.0.5"
|
60
|
+
}
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# Lo-Dash v0.9.2
|
2
|
+
|
3
|
+
A utility library delivering consistency, [customization](http://lodash.com/custom-builds), [performance](http://lodash.com/benchmarks), & [extras](http://lodash.com/#features).
|
4
|
+
|
5
|
+
## Download
|
6
|
+
|
7
|
+
* [Development build](https://raw.github.com/lodash/lodash/0.9.2/lodash.js)
|
8
|
+
* [Production build](https://raw.github.com/lodash/lodash/0.9.2/lodash.min.js)
|
9
|
+
* [Underscore build](https://raw.github.com/lodash/lodash/0.9.2/lodash.underscore.min.js) tailored for projects already using Underscore
|
10
|
+
* CDN copies of ≤ v0.9.2’s [Production](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.min.js), [Underscore](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.underscore.min.js), and [Development](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.js) builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/)
|
11
|
+
* For optimal file size, [create a custom build](http://lodash.com/custom-builds) with only the features you need
|
12
|
+
|
13
|
+
## Dive in
|
14
|
+
|
15
|
+
We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests).
|
16
|
+
|
17
|
+
Create your own benchmarks at [jsPerf](http://jsperf.com), or [search](http://jsperf.com/search?q=lodash) for existing ones.
|
18
|
+
|
19
|
+
For a list of upcoming features, check out our [roadmap](https://github.com/lodash/lodash/wiki/Roadmap).
|
20
|
+
|
21
|
+
## Screencasts
|
22
|
+
|
23
|
+
For more information check out these screencasts over Lo-Dash:
|
24
|
+
|
25
|
+
* [Introducing Lo-Dash](https://vimeo.com/44154599)
|
26
|
+
* [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601)
|
27
|
+
* [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600)
|
28
|
+
* [Unit testing in Lo-Dash](https://vimeo.com/45865290)
|
29
|
+
* [Lo-Dash’s approach to native method use](https://vimeo.com/48576012)
|
30
|
+
|
31
|
+
## Features
|
32
|
+
|
33
|
+
* AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.)
|
34
|
+
* [_.clone](http://lodash.com/docs#clone) supports *“deep”* cloning
|
35
|
+
* [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument
|
36
|
+
* [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early
|
37
|
+
* [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties
|
38
|
+
* [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties
|
39
|
+
* [_.isPlainObject](http://lodash.com/docs#isPlainObject) checks if values are created by the `Object` constructor
|
40
|
+
* [_.lateBind](http://lodash.com/docs#lateBind) for late binding
|
41
|
+
* [_.merge](http://lodash.com/docs#merge) for a *“deep”* [_.extend](http://lodash.com/docs#extend)
|
42
|
+
* [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding
|
43
|
+
* [_.pick](http://lodash.com/docs#pick) and [_.omit](http://lodash.com/docs#omit) accepts `callback` and `thisArg` arguments
|
44
|
+
* [_.template](http://lodash.com/docs#template) supports [ES6 delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6) and utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging
|
45
|
+
* [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray),
|
46
|
+
[and more…](http://lodash.com/docs "_.countBy, _.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.some, _.sortBy, _.where") accept strings
|
47
|
+
|
48
|
+
## Support
|
49
|
+
|
50
|
+
Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~16, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.14, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
|
51
|
+
|
52
|
+
## Installation and usage
|
53
|
+
|
54
|
+
In browsers:
|
55
|
+
|
56
|
+
```html
|
57
|
+
<script src="lodash.js"></script>
|
58
|
+
```
|
59
|
+
|
60
|
+
Using [npm](http://npmjs.org/):
|
61
|
+
|
62
|
+
```bash
|
63
|
+
npm install lodash
|
64
|
+
|
65
|
+
npm install -g lodash
|
66
|
+
npm link lodash
|
67
|
+
```
|
68
|
+
|
69
|
+
In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
|
70
|
+
|
71
|
+
```js
|
72
|
+
var _ = require('lodash');
|
73
|
+
```
|
74
|
+
|
75
|
+
**Note:** If Lo-Dash is installed globally, [run `npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it.
|
76
|
+
|
77
|
+
In [RingoJS v0.7.0-](http://ringojs.org/):
|
78
|
+
|
79
|
+
```js
|
80
|
+
var _ = require('lodash')._;
|
81
|
+
```
|
82
|
+
|
83
|
+
In [Rhino](http://www.mozilla.org/rhino/):
|
84
|
+
|
85
|
+
```js
|
86
|
+
load('lodash.js');
|
87
|
+
```
|
88
|
+
|
89
|
+
In an AMD loader like [RequireJS](http://requirejs.org/):
|
90
|
+
|
91
|
+
```js
|
92
|
+
require({
|
93
|
+
'paths': {
|
94
|
+
'underscore': 'path/to/lodash'
|
95
|
+
}
|
96
|
+
},
|
97
|
+
['underscore'], function(_) {
|
98
|
+
console.log(_.VERSION);
|
99
|
+
});
|
100
|
+
```
|
101
|
+
|
102
|
+
## Resolved Underscore.js issues
|
103
|
+
|
104
|
+
* Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L545-551)]
|
105
|
+
* Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L558-582)]
|
106
|
+
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L140-146)]
|
107
|
+
* `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L747-752)]
|
108
|
+
* `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L828-840)]
|
109
|
+
* `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L921-923)]
|
110
|
+
* `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/lodash/lodash/blob/0.9.2/test/test.js#L1337-1340)]
|
111
|
+
|
112
|
+
## Release Notes
|
113
|
+
|
114
|
+
### <sup>v0.9.2</sup>
|
115
|
+
|
116
|
+
* Added `fromIndex` argument to `_.contains`
|
117
|
+
* Added `moduleId` build option
|
118
|
+
* Added Closure Compiler *“simple”* optimizations to the build process
|
119
|
+
* Added support for strings in `_.max` and `_.min`
|
120
|
+
* Added support for ES6 template delimiters to `_.template`
|
121
|
+
* Ensured re-minification of Lo-Dash by third parties avoids Closure Compiler bugs
|
122
|
+
* Optimized `_.every`, `_.find`, `_.some`, and `_.uniq`
|
123
|
+
|
124
|
+
The full changelog is available [here](https://github.com/lodash/lodash/wiki/Changelog).
|
125
|
+
|
126
|
+
## BestieJS
|
127
|
+
|
128
|
+
Lo-Dash is part of the [BestieJS](https://github.com/bestiejs) *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
|
129
|
+
|
130
|
+
## Author
|
131
|
+
|
132
|
+
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](http://twitter.com/jdalton "Follow @jdalton on Twitter") |
|
133
|
+
|---|
|
134
|
+
| [John-David Dalton](http://allyoucanleet.com/) |
|
135
|
+
|
136
|
+
## Contributors
|
137
|
+
|
138
|
+
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](http://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](http://twitter.com/mathias "Follow @mathias on Twitter") |
|
139
|
+
|---|---|---|
|
140
|
+
| [Blaine Bublitz](http://iceddev.com/) | [Kit Cambridge](http://kitcambridge.github.io/) | [Mathias Bynens](http://mathiasbynens.be/) |
|
@@ -0,0 +1,4258 @@
|
|
1
|
+
/*!
|
2
|
+
* Lo-Dash v0.9.2 <http://lodash.com>
|
3
|
+
* (c) 2012 John-David Dalton <http://allyoucanleet.com/>
|
4
|
+
* Based on Underscore.js 1.4.2 <http://underscorejs.org>
|
5
|
+
* (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
6
|
+
* Available under MIT license <http://lodash.com/license>
|
7
|
+
*/
|
8
|
+
;(function(window, undefined) {
|
9
|
+
|
10
|
+
/** Detect free variable `exports` */
|
11
|
+
var freeExports = typeof exports == 'object' && exports;
|
12
|
+
|
13
|
+
/** Detect free variable `global` and use it as `window` */
|
14
|
+
var freeGlobal = typeof global == 'object' && global;
|
15
|
+
if (freeGlobal.global === freeGlobal) {
|
16
|
+
window = freeGlobal;
|
17
|
+
}
|
18
|
+
|
19
|
+
/** Used for array and object method references */
|
20
|
+
var arrayRef = [],
|
21
|
+
// avoid a Closure Compiler bug by creatively creating an object
|
22
|
+
objectRef = new function(){};
|
23
|
+
|
24
|
+
/** Used to generate unique IDs */
|
25
|
+
var idCounter = 0;
|
26
|
+
|
27
|
+
/** Used internally to indicate various things */
|
28
|
+
var indicatorObject = objectRef;
|
29
|
+
|
30
|
+
/** Used by `cachedContains` as the default size when optimizations are enabled for large arrays */
|
31
|
+
var largeArraySize = 30;
|
32
|
+
|
33
|
+
/** Used to restore the original `_` reference in `noConflict` */
|
34
|
+
var oldDash = window._;
|
35
|
+
|
36
|
+
/** Used to detect template delimiter values that require a with-statement */
|
37
|
+
var reComplexDelimiter = /[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/;
|
38
|
+
|
39
|
+
/** Used to match HTML entities */
|
40
|
+
var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g;
|
41
|
+
|
42
|
+
/** Used to match empty string literals in compiled template source */
|
43
|
+
var reEmptyStringLeading = /\b__p \+= '';/g,
|
44
|
+
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
45
|
+
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
46
|
+
|
47
|
+
/** Used to match regexp flags from their coerced string values */
|
48
|
+
var reFlags = /\w*$/;
|
49
|
+
|
50
|
+
/** Used to insert the data object variable into compiled template source */
|
51
|
+
var reInsertVariable = /(?:__e|__t = )\(\s*(?![\d\s"']|this\.)/g;
|
52
|
+
|
53
|
+
/** Used to detect if a method is native */
|
54
|
+
var reNative = RegExp('^' +
|
55
|
+
(objectRef.valueOf + '')
|
56
|
+
.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&')
|
57
|
+
.replace(/valueOf|for [^\]]+/g, '.+?') + '$'
|
58
|
+
);
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Used to match ES6 template delimiters
|
62
|
+
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
|
63
|
+
*/
|
64
|
+
var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)}/g;
|
65
|
+
|
66
|
+
/** Used to match "interpolate" template delimiters */
|
67
|
+
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
68
|
+
|
69
|
+
/** Used to ensure capturing order of template delimiters */
|
70
|
+
var reNoMatch = /($^)/;
|
71
|
+
|
72
|
+
/** Used to match HTML characters */
|
73
|
+
var reUnescapedHtml = /[&<>"']/g;
|
74
|
+
|
75
|
+
/** Used to match unescaped characters in compiled string literals */
|
76
|
+
var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g;
|
77
|
+
|
78
|
+
/** Used to fix the JScript [[DontEnum]] bug */
|
79
|
+
var shadowed = [
|
80
|
+
'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
|
81
|
+
'toLocaleString', 'toString', 'valueOf'
|
82
|
+
];
|
83
|
+
|
84
|
+
/** Used to make template sourceURLs easier to identify */
|
85
|
+
var templateCounter = 0;
|
86
|
+
|
87
|
+
/** Native method shortcuts */
|
88
|
+
var ceil = Math.ceil,
|
89
|
+
concat = arrayRef.concat,
|
90
|
+
floor = Math.floor,
|
91
|
+
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
92
|
+
hasOwnProperty = objectRef.hasOwnProperty,
|
93
|
+
push = arrayRef.push,
|
94
|
+
propertyIsEnumerable = objectRef.propertyIsEnumerable,
|
95
|
+
slice = arrayRef.slice,
|
96
|
+
toString = objectRef.toString;
|
97
|
+
|
98
|
+
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
99
|
+
var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
|
100
|
+
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
101
|
+
nativeIsFinite = window.isFinite,
|
102
|
+
nativeIsNaN = window.isNaN,
|
103
|
+
nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,
|
104
|
+
nativeMax = Math.max,
|
105
|
+
nativeMin = Math.min,
|
106
|
+
nativeRandom = Math.random;
|
107
|
+
|
108
|
+
/** `Object#toString` result shortcuts */
|
109
|
+
var argsClass = '[object Arguments]',
|
110
|
+
arrayClass = '[object Array]',
|
111
|
+
boolClass = '[object Boolean]',
|
112
|
+
dateClass = '[object Date]',
|
113
|
+
funcClass = '[object Function]',
|
114
|
+
numberClass = '[object Number]',
|
115
|
+
objectClass = '[object Object]',
|
116
|
+
regexpClass = '[object RegExp]',
|
117
|
+
stringClass = '[object String]';
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Detect the JScript [[DontEnum]] bug:
|
121
|
+
*
|
122
|
+
* In IE < 9 an objects own properties, shadowing non-enumerable ones, are
|
123
|
+
* made non-enumerable as well.
|
124
|
+
*/
|
125
|
+
var hasDontEnumBug;
|
126
|
+
|
127
|
+
/** Detect if own properties are iterated after inherited properties (IE < 9) */
|
128
|
+
var iteratesOwnLast;
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Detect if `Array#shift` and `Array#splice` augment array-like objects
|
132
|
+
* incorrectly:
|
133
|
+
*
|
134
|
+
* Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()`
|
135
|
+
* and `splice()` functions that fail to remove the last element, `value[0]`,
|
136
|
+
* of array-like objects even though the `length` property is set to `0`.
|
137
|
+
* The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`
|
138
|
+
* is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.
|
139
|
+
*/
|
140
|
+
var hasObjectSpliceBug = (hasObjectSpliceBug = { '0': 1, 'length': 1 },
|
141
|
+
arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]);
|
142
|
+
|
143
|
+
/** Detect if an `arguments` object's indexes are non-enumerable (IE < 9) */
|
144
|
+
var noArgsEnum = true;
|
145
|
+
|
146
|
+
(function() {
|
147
|
+
var props = [];
|
148
|
+
function ctor() { this.x = 1; }
|
149
|
+
ctor.prototype = { 'valueOf': 1, 'y': 1 };
|
150
|
+
for (var prop in new ctor) { props.push(prop); }
|
151
|
+
for (prop in arguments) { noArgsEnum = !prop; }
|
152
|
+
|
153
|
+
hasDontEnumBug = !/valueOf/.test(props);
|
154
|
+
iteratesOwnLast = props[0] != 'x';
|
155
|
+
}(1));
|
156
|
+
|
157
|
+
/** Detect if an `arguments` object's [[Class]] is unresolvable (Firefox < 4, IE < 9) */
|
158
|
+
var noArgsClass = !isArguments(arguments);
|
159
|
+
|
160
|
+
/** Detect if `Array#slice` cannot be used to convert strings to arrays (Opera < 10.52) */
|
161
|
+
var noArraySliceOnStrings = slice.call('x')[0] != 'x';
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Detect lack of support for accessing string characters by index:
|
165
|
+
*
|
166
|
+
* IE < 8 can't access characters by index and IE 8 can only access
|
167
|
+
* characters by index on string literals.
|
168
|
+
*/
|
169
|
+
var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx';
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Detect if a node's [[Class]] is unresolvable (IE < 9)
|
173
|
+
* and that the JS engine won't error when attempting to coerce an object to
|
174
|
+
* a string without a `toString` property value of `typeof` "function".
|
175
|
+
*/
|
176
|
+
try {
|
177
|
+
var noNodeClass = ({ 'toString': 0 } + '', toString.call(window.document || 0) == objectClass);
|
178
|
+
} catch(e) { }
|
179
|
+
|
180
|
+
/* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */
|
181
|
+
var isBindFast = nativeBind && /\n|Opera/.test(nativeBind + toString.call(window.opera));
|
182
|
+
|
183
|
+
/* Detect if `Object.keys` exists and is inferred to be fast (IE, Opera, V8) */
|
184
|
+
var isKeysFast = nativeKeys && /^.+$|true/.test(nativeKeys + !!window.attachEvent);
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Detect if sourceURL syntax is usable without erroring:
|
188
|
+
*
|
189
|
+
* The JS engine in Adobe products, like InDesign, will throw a syntax error
|
190
|
+
* when it encounters a single line comment beginning with the `@` symbol.
|
191
|
+
*
|
192
|
+
* The JS engine in Narwhal will generate the function `function anonymous(){//}`
|
193
|
+
* and throw a syntax error.
|
194
|
+
*
|
195
|
+
* Avoid comments beginning `@` symbols in IE because they are part of its
|
196
|
+
* non-standard conditional compilation support.
|
197
|
+
* http://msdn.microsoft.com/en-us/library/121hztk3(v=vs.94).aspx
|
198
|
+
*/
|
199
|
+
try {
|
200
|
+
var useSourceURL = (Function('//@')(), !window.attachEvent);
|
201
|
+
} catch(e) { }
|
202
|
+
|
203
|
+
/** Used to identify object classifications that `_.clone` supports */
|
204
|
+
var cloneableClasses = {};
|
205
|
+
cloneableClasses[argsClass] = cloneableClasses[funcClass] = false;
|
206
|
+
cloneableClasses[arrayClass] = cloneableClasses[boolClass] = cloneableClasses[dateClass] =
|
207
|
+
cloneableClasses[numberClass] = cloneableClasses[objectClass] = cloneableClasses[regexpClass] =
|
208
|
+
cloneableClasses[stringClass] = true;
|
209
|
+
|
210
|
+
/** Used to determine if values are of the language type Object */
|
211
|
+
var objectTypes = {
|
212
|
+
'boolean': false,
|
213
|
+
'function': true,
|
214
|
+
'object': true,
|
215
|
+
'number': false,
|
216
|
+
'string': false,
|
217
|
+
'undefined': false
|
218
|
+
};
|
219
|
+
|
220
|
+
/** Used to escape characters for inclusion in compiled string literals */
|
221
|
+
var stringEscapes = {
|
222
|
+
'\\': '\\',
|
223
|
+
"'": "'",
|
224
|
+
'\n': 'n',
|
225
|
+
'\r': 'r',
|
226
|
+
'\t': 't',
|
227
|
+
'\u2028': 'u2028',
|
228
|
+
'\u2029': 'u2029'
|
229
|
+
};
|
230
|
+
|
231
|
+
/*--------------------------------------------------------------------------*/
|
232
|
+
|
233
|
+
/**
|
234
|
+
* The `lodash` function.
|
235
|
+
*
|
236
|
+
* @name _
|
237
|
+
* @constructor
|
238
|
+
* @category Chaining
|
239
|
+
* @param {Mixed} value The value to wrap in a `lodash` instance.
|
240
|
+
* @returns {Object} Returns a `lodash` instance.
|
241
|
+
*/
|
242
|
+
function lodash(value) {
|
243
|
+
// exit early if already wrapped
|
244
|
+
if (value && value.__wrapped__) {
|
245
|
+
return value;
|
246
|
+
}
|
247
|
+
// allow invoking `lodash` without the `new` operator
|
248
|
+
if (!(this instanceof lodash)) {
|
249
|
+
return new lodash(value);
|
250
|
+
}
|
251
|
+
this.__wrapped__ = value;
|
252
|
+
}
|
253
|
+
|
254
|
+
/**
|
255
|
+
* By default, the template delimiters used by Lo-Dash are similar to those in
|
256
|
+
* embedded Ruby (ERB). Change the following template settings to use alternative
|
257
|
+
* delimiters.
|
258
|
+
*
|
259
|
+
* @static
|
260
|
+
* @memberOf _
|
261
|
+
* @type Object
|
262
|
+
*/
|
263
|
+
lodash.templateSettings = {
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Used to detect `data` property values to be HTML-escaped.
|
267
|
+
*
|
268
|
+
* @static
|
269
|
+
* @memberOf _.templateSettings
|
270
|
+
* @type RegExp
|
271
|
+
*/
|
272
|
+
'escape': /<%-([\s\S]+?)%>/g,
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Used to detect code to be evaluated.
|
276
|
+
*
|
277
|
+
* @static
|
278
|
+
* @memberOf _.templateSettings
|
279
|
+
* @type RegExp
|
280
|
+
*/
|
281
|
+
'evaluate': /<%([\s\S]+?)%>/g,
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Used to detect `data` property values to inject.
|
285
|
+
*
|
286
|
+
* @static
|
287
|
+
* @memberOf _.templateSettings
|
288
|
+
* @type RegExp
|
289
|
+
*/
|
290
|
+
'interpolate': reInterpolate,
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Used to reference the data object in the template text.
|
294
|
+
*
|
295
|
+
* @static
|
296
|
+
* @memberOf _.templateSettings
|
297
|
+
* @type String
|
298
|
+
*/
|
299
|
+
'variable': ''
|
300
|
+
};
|
301
|
+
|
302
|
+
/*--------------------------------------------------------------------------*/
|
303
|
+
|
304
|
+
/**
|
305
|
+
* The template used to create iterator functions.
|
306
|
+
*
|
307
|
+
* @private
|
308
|
+
* @param {Obect} data The data object used to populate the text.
|
309
|
+
* @returns {String} Returns the interpolated text.
|
310
|
+
*/
|
311
|
+
var iteratorTemplate = template(
|
312
|
+
// conditional strict mode
|
313
|
+
'<% if (obj.useStrict) { %>\'use strict\';\n<% } %>' +
|
314
|
+
|
315
|
+
// the `iteratee` may be reassigned by the `top` snippet
|
316
|
+
'var index, value, iteratee = <%= firstArg %>, ' +
|
317
|
+
// assign the `result` variable an initial value
|
318
|
+
'result = <%= firstArg %>;\n' +
|
319
|
+
// exit early if the first argument is falsey
|
320
|
+
'if (!<%= firstArg %>) return result;\n' +
|
321
|
+
// add code before the iteration branches
|
322
|
+
'<%= top %>;\n' +
|
323
|
+
|
324
|
+
// array-like iteration:
|
325
|
+
'<% if (arrayLoop) { %>' +
|
326
|
+
'var length = iteratee.length; index = -1;\n' +
|
327
|
+
'if (typeof length == \'number\') {' +
|
328
|
+
|
329
|
+
// add support for accessing string characters by index if needed
|
330
|
+
' <% if (noCharByIndex) { %>\n' +
|
331
|
+
' if (isString(iteratee)) {\n' +
|
332
|
+
' iteratee = iteratee.split(\'\')\n' +
|
333
|
+
' }' +
|
334
|
+
' <% } %>\n' +
|
335
|
+
|
336
|
+
// iterate over the array-like value
|
337
|
+
' while (++index < length) {\n' +
|
338
|
+
' value = iteratee[index];\n' +
|
339
|
+
' <%= arrayLoop %>\n' +
|
340
|
+
' }\n' +
|
341
|
+
'}\n' +
|
342
|
+
'else {' +
|
343
|
+
|
344
|
+
// object iteration:
|
345
|
+
// add support for iterating over `arguments` objects if needed
|
346
|
+
' <% } else if (noArgsEnum) { %>\n' +
|
347
|
+
' var length = iteratee.length; index = -1;\n' +
|
348
|
+
' if (length && isArguments(iteratee)) {\n' +
|
349
|
+
' while (++index < length) {\n' +
|
350
|
+
' value = iteratee[index += \'\'];\n' +
|
351
|
+
' <%= objectLoop %>\n' +
|
352
|
+
' }\n' +
|
353
|
+
' } else {' +
|
354
|
+
' <% } %>' +
|
355
|
+
|
356
|
+
// Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
|
357
|
+
// (if the prototype or a property on the prototype has been set)
|
358
|
+
// incorrectly sets a function's `prototype` property [[Enumerable]]
|
359
|
+
// value to `true`. Because of this Lo-Dash standardizes on skipping
|
360
|
+
// the the `prototype` property of functions regardless of its
|
361
|
+
// [[Enumerable]] value.
|
362
|
+
' <% if (!hasDontEnumBug) { %>\n' +
|
363
|
+
' var skipProto = typeof iteratee == \'function\' && \n' +
|
364
|
+
' propertyIsEnumerable.call(iteratee, \'prototype\');\n' +
|
365
|
+
' <% } %>' +
|
366
|
+
|
367
|
+
// iterate own properties using `Object.keys` if it's fast
|
368
|
+
' <% if (isKeysFast && useHas) { %>\n' +
|
369
|
+
' var ownIndex = -1,\n' +
|
370
|
+
' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n' +
|
371
|
+
' length = ownProps.length;\n\n' +
|
372
|
+
' while (++ownIndex < length) {\n' +
|
373
|
+
' index = ownProps[ownIndex];\n' +
|
374
|
+
' <% if (!hasDontEnumBug) { %>if (!(skipProto && index == \'prototype\')) {\n <% } %>' +
|
375
|
+
' value = iteratee[index];\n' +
|
376
|
+
' <%= objectLoop %>\n' +
|
377
|
+
' <% if (!hasDontEnumBug) { %>}\n<% } %>' +
|
378
|
+
' }' +
|
379
|
+
|
380
|
+
// else using a for-in loop
|
381
|
+
' <% } else { %>\n' +
|
382
|
+
' for (index in iteratee) {<%' +
|
383
|
+
' if (!hasDontEnumBug || useHas) { %>\n if (<%' +
|
384
|
+
' if (!hasDontEnumBug) { %>!(skipProto && index == \'prototype\')<% }' +
|
385
|
+
' if (!hasDontEnumBug && useHas) { %> && <% }' +
|
386
|
+
' if (useHas) { %>hasOwnProperty.call(iteratee, index)<% }' +
|
387
|
+
' %>) {' +
|
388
|
+
' <% } %>\n' +
|
389
|
+
' value = iteratee[index];\n' +
|
390
|
+
' <%= objectLoop %>;' +
|
391
|
+
' <% if (!hasDontEnumBug || useHas) { %>\n }<% } %>\n' +
|
392
|
+
' }' +
|
393
|
+
' <% } %>' +
|
394
|
+
|
395
|
+
// Because IE < 9 can't set the `[[Enumerable]]` attribute of an
|
396
|
+
// existing property and the `constructor` property of a prototype
|
397
|
+
// defaults to non-enumerable, Lo-Dash skips the `constructor`
|
398
|
+
// property when it infers it's iterating over a `prototype` object.
|
399
|
+
' <% if (hasDontEnumBug) { %>\n\n' +
|
400
|
+
' var ctor = iteratee.constructor;\n' +
|
401
|
+
' <% for (var k = 0; k < 7; k++) { %>\n' +
|
402
|
+
' index = \'<%= shadowed[k] %>\';\n' +
|
403
|
+
' if (<%' +
|
404
|
+
' if (shadowed[k] == \'constructor\') {' +
|
405
|
+
' %>!(ctor && ctor.prototype === iteratee) && <%' +
|
406
|
+
' } %>hasOwnProperty.call(iteratee, index)) {\n' +
|
407
|
+
' value = iteratee[index];\n' +
|
408
|
+
' <%= objectLoop %>\n' +
|
409
|
+
' }' +
|
410
|
+
' <% } %>' +
|
411
|
+
' <% } %>' +
|
412
|
+
' <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n' +
|
413
|
+
|
414
|
+
// add code to the bottom of the iteration function
|
415
|
+
'<%= bottom %>;\n' +
|
416
|
+
// finally, return the `result`
|
417
|
+
'return result'
|
418
|
+
);
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`.
|
422
|
+
*/
|
423
|
+
var forEachIteratorOptions = {
|
424
|
+
'args': 'collection, callback, thisArg',
|
425
|
+
'top': 'callback = createCallback(callback, thisArg)',
|
426
|
+
'arrayLoop': 'if (callback(value, index, collection) === false) return result',
|
427
|
+
'objectLoop': 'if (callback(value, index, collection) === false) return result'
|
428
|
+
};
|
429
|
+
|
430
|
+
/** Reusable iterator options for `defaults`, and `extend` */
|
431
|
+
var extendIteratorOptions = {
|
432
|
+
'useHas': false,
|
433
|
+
'args': 'object',
|
434
|
+
'top':
|
435
|
+
'for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n' +
|
436
|
+
' if (iteratee = arguments[argsIndex]) {',
|
437
|
+
'objectLoop': 'result[index] = value',
|
438
|
+
'bottom': ' }\n}'
|
439
|
+
};
|
440
|
+
|
441
|
+
/** Reusable iterator options for `forIn` and `forOwn` */
|
442
|
+
var forOwnIteratorOptions = {
|
443
|
+
'arrayLoop': null
|
444
|
+
};
|
445
|
+
|
446
|
+
/*--------------------------------------------------------------------------*/
|
447
|
+
|
448
|
+
/**
|
449
|
+
* Creates a function optimized to search large arrays for a given `value`,
|
450
|
+
* starting at `fromIndex`, using strict equality for comparisons, i.e. `===`.
|
451
|
+
*
|
452
|
+
* @private
|
453
|
+
* @param {Array} array The array to search.
|
454
|
+
* @param {Mixed} value The value to search for.
|
455
|
+
* @param {Number} [fromIndex=0] The index to search from.
|
456
|
+
* @param {Number} [largeSize=30] The length at which an array is considered large.
|
457
|
+
* @returns {Boolean} Returns `true` if `value` is found, else `false`.
|
458
|
+
*/
|
459
|
+
function cachedContains(array, fromIndex, largeSize) {
|
460
|
+
fromIndex || (fromIndex = 0);
|
461
|
+
|
462
|
+
var length = array.length,
|
463
|
+
isLarge = (length - fromIndex) >= (largeSize || largeArraySize);
|
464
|
+
|
465
|
+
if (isLarge) {
|
466
|
+
var cache = {},
|
467
|
+
index = fromIndex - 1;
|
468
|
+
|
469
|
+
while (++index < length) {
|
470
|
+
// manually coerce `value` to a string because `hasOwnProperty`, in some
|
471
|
+
// older versions of Firefox, coerces objects incorrectly
|
472
|
+
var key = array[index] + '';
|
473
|
+
(hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]);
|
474
|
+
}
|
475
|
+
}
|
476
|
+
return function(value) {
|
477
|
+
if (isLarge) {
|
478
|
+
var key = value + '';
|
479
|
+
return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1;
|
480
|
+
}
|
481
|
+
return indexOf(array, value, fromIndex) > -1;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
/**
|
486
|
+
* Used by `_.max` and `_.min` as the default `callback` when a given
|
487
|
+
* `collection` is a string value.
|
488
|
+
*
|
489
|
+
* @private
|
490
|
+
* @param {String} value The character to inspect.
|
491
|
+
* @returns {Number} Returns the code unit of given character.
|
492
|
+
*/
|
493
|
+
function charAtCallback(value) {
|
494
|
+
return value.charCodeAt(0);
|
495
|
+
}
|
496
|
+
|
497
|
+
/**
|
498
|
+
* Used by `sortBy` to compare transformed `collection` values, stable sorting
|
499
|
+
* them in ascending order.
|
500
|
+
*
|
501
|
+
* @private
|
502
|
+
* @param {Object} a The object to compare to `b`.
|
503
|
+
* @param {Object} b The object to compare to `a`.
|
504
|
+
* @returns {Number} Returns the sort order indicator of `1` or `-1`.
|
505
|
+
*/
|
506
|
+
function compareAscending(a, b) {
|
507
|
+
var ai = a.index,
|
508
|
+
bi = b.index;
|
509
|
+
|
510
|
+
a = a.criteria;
|
511
|
+
b = b.criteria;
|
512
|
+
|
513
|
+
// ensure a stable sort in V8 and other engines
|
514
|
+
// http://code.google.com/p/v8/issues/detail?id=90
|
515
|
+
if (a !== b) {
|
516
|
+
if (a > b || a === undefined) {
|
517
|
+
return 1;
|
518
|
+
}
|
519
|
+
if (a < b || b === undefined) {
|
520
|
+
return -1;
|
521
|
+
}
|
522
|
+
}
|
523
|
+
return ai < bi ? -1 : 1;
|
524
|
+
}
|
525
|
+
|
526
|
+
/**
|
527
|
+
* Creates a function that, when called, invokes `func` with the `this`
|
528
|
+
* binding of `thisArg` and prepends any `partailArgs` to the arguments passed
|
529
|
+
* to the bound function.
|
530
|
+
*
|
531
|
+
* @private
|
532
|
+
* @param {Function|String} func The function to bind or the method name.
|
533
|
+
* @param {Mixed} [thisArg] The `this` binding of `func`.
|
534
|
+
* @param {Array} partialArgs An array of arguments to be partially applied.
|
535
|
+
* @returns {Function} Returns the new bound function.
|
536
|
+
*/
|
537
|
+
function createBound(func, thisArg, partialArgs) {
|
538
|
+
var isFunc = isFunction(func),
|
539
|
+
isPartial = !partialArgs,
|
540
|
+
methodName = func;
|
541
|
+
|
542
|
+
// juggle arguments
|
543
|
+
if (isPartial) {
|
544
|
+
partialArgs = thisArg;
|
545
|
+
}
|
546
|
+
|
547
|
+
function bound() {
|
548
|
+
// `Function#bind` spec
|
549
|
+
// http://es5.github.com/#x15.3.4.5
|
550
|
+
var args = arguments,
|
551
|
+
thisBinding = isPartial ? this : thisArg;
|
552
|
+
|
553
|
+
if (!isFunc) {
|
554
|
+
func = thisArg[methodName];
|
555
|
+
}
|
556
|
+
if (partialArgs.length) {
|
557
|
+
args = args.length
|
558
|
+
? partialArgs.concat(slice.call(args))
|
559
|
+
: partialArgs;
|
560
|
+
}
|
561
|
+
if (this instanceof bound) {
|
562
|
+
// get `func` instance if `bound` is invoked in a `new` expression
|
563
|
+
noop.prototype = func.prototype;
|
564
|
+
thisBinding = new noop;
|
565
|
+
|
566
|
+
// mimic the constructor's `return` behavior
|
567
|
+
// http://es5.github.com/#x13.2.2
|
568
|
+
var result = func.apply(thisBinding, args);
|
569
|
+
return isObject(result)
|
570
|
+
? result
|
571
|
+
: thisBinding
|
572
|
+
}
|
573
|
+
return func.apply(thisBinding, args);
|
574
|
+
}
|
575
|
+
return bound;
|
576
|
+
}
|
577
|
+
|
578
|
+
/**
|
579
|
+
* Produces an iteration callback bound to an optional `thisArg`. If `func` is
|
580
|
+
* a property name, the callback will return the property value for a given element.
|
581
|
+
*
|
582
|
+
* @private
|
583
|
+
* @param {Function|String} [func=identity|property] The function called per
|
584
|
+
* iteration or property name to query.
|
585
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
586
|
+
* @returns {Function} Returns a callback function.
|
587
|
+
*/
|
588
|
+
function createCallback(func, thisArg) {
|
589
|
+
if (!func) {
|
590
|
+
return identity;
|
591
|
+
}
|
592
|
+
if (typeof func != 'function') {
|
593
|
+
return function(object) {
|
594
|
+
return object[func];
|
595
|
+
};
|
596
|
+
}
|
597
|
+
if (thisArg !== undefined) {
|
598
|
+
return function(value, index, object) {
|
599
|
+
return func.call(thisArg, value, index, object);
|
600
|
+
};
|
601
|
+
}
|
602
|
+
return func;
|
603
|
+
}
|
604
|
+
|
605
|
+
/**
|
606
|
+
* Creates compiled iteration functions.
|
607
|
+
*
|
608
|
+
* @private
|
609
|
+
* @param {Object} [options1, options2, ...] The compile options object(s).
|
610
|
+
* useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
|
611
|
+
* args - A string of comma separated arguments the iteration function will accept.
|
612
|
+
* top - A string of code to execute before the iteration branches.
|
613
|
+
* arrayLoop - A string of code to execute in the array loop.
|
614
|
+
* objectLoop - A string of code to execute in the object loop.
|
615
|
+
* bottom - A string of code to execute after the iteration branches.
|
616
|
+
*
|
617
|
+
* @returns {Function} Returns the compiled function.
|
618
|
+
*/
|
619
|
+
function createIterator() {
|
620
|
+
var data = {
|
621
|
+
'arrayLoop': '',
|
622
|
+
'bottom': '',
|
623
|
+
'hasDontEnumBug': hasDontEnumBug,
|
624
|
+
'isKeysFast': isKeysFast,
|
625
|
+
'objectLoop': '',
|
626
|
+
'noArgsEnum': noArgsEnum,
|
627
|
+
'noCharByIndex': noCharByIndex,
|
628
|
+
'shadowed': shadowed,
|
629
|
+
'top': '',
|
630
|
+
'useHas': true
|
631
|
+
};
|
632
|
+
|
633
|
+
// merge options into a template data object
|
634
|
+
for (var object, index = 0; object = arguments[index]; index++) {
|
635
|
+
for (var key in object) {
|
636
|
+
data[key] = object[key];
|
637
|
+
}
|
638
|
+
}
|
639
|
+
var args = data.args;
|
640
|
+
data.firstArg = /^[^,]+/.exec(args)[0];
|
641
|
+
|
642
|
+
// create the function factory
|
643
|
+
var factory = Function(
|
644
|
+
'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' +
|
645
|
+
'nativeKeys, propertyIsEnumerable',
|
646
|
+
'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}'
|
647
|
+
);
|
648
|
+
// return the compiled function
|
649
|
+
return factory(
|
650
|
+
createCallback, hasOwnProperty, isArguments, isString, objectTypes,
|
651
|
+
nativeKeys, propertyIsEnumerable
|
652
|
+
);
|
653
|
+
}
|
654
|
+
|
655
|
+
/**
|
656
|
+
* Used by `template` to escape characters for inclusion in compiled
|
657
|
+
* string literals.
|
658
|
+
*
|
659
|
+
* @private
|
660
|
+
* @param {String} match The matched character to escape.
|
661
|
+
* @returns {String} Returns the escaped character.
|
662
|
+
*/
|
663
|
+
function escapeStringChar(match) {
|
664
|
+
return '\\' + stringEscapes[match];
|
665
|
+
}
|
666
|
+
|
667
|
+
/**
|
668
|
+
* Used by `escape` to convert characters to HTML entities.
|
669
|
+
*
|
670
|
+
* @private
|
671
|
+
* @param {String} match The matched character to escape.
|
672
|
+
* @returns {String} Returns the escaped character.
|
673
|
+
*/
|
674
|
+
function escapeHtmlChar(match) {
|
675
|
+
return htmlEscapes[match];
|
676
|
+
}
|
677
|
+
|
678
|
+
/**
|
679
|
+
* A no-operation function.
|
680
|
+
*
|
681
|
+
* @private
|
682
|
+
*/
|
683
|
+
function noop() {
|
684
|
+
// no operation performed
|
685
|
+
}
|
686
|
+
|
687
|
+
/**
|
688
|
+
* Used by `unescape` to convert HTML entities to characters.
|
689
|
+
*
|
690
|
+
* @private
|
691
|
+
* @param {String} match The matched character to unescape.
|
692
|
+
* @returns {String} Returns the unescaped character.
|
693
|
+
*/
|
694
|
+
function unescapeHtmlChar(match) {
|
695
|
+
return htmlUnescapes[match];
|
696
|
+
}
|
697
|
+
|
698
|
+
/*--------------------------------------------------------------------------*/
|
699
|
+
|
700
|
+
/**
|
701
|
+
* Checks if `value` is an `arguments` object.
|
702
|
+
*
|
703
|
+
* @static
|
704
|
+
* @memberOf _
|
705
|
+
* @category Objects
|
706
|
+
* @param {Mixed} value The value to check.
|
707
|
+
* @returns {Boolean} Returns `true` if the `value` is an `arguments` object, else `false`.
|
708
|
+
* @example
|
709
|
+
*
|
710
|
+
* (function() { return _.isArguments(arguments); })(1, 2, 3);
|
711
|
+
* // => true
|
712
|
+
*
|
713
|
+
* _.isArguments([1, 2, 3]);
|
714
|
+
* // => false
|
715
|
+
*/
|
716
|
+
function isArguments(value) {
|
717
|
+
return toString.call(value) == argsClass;
|
718
|
+
}
|
719
|
+
// fallback for browsers that can't detect `arguments` objects by [[Class]]
|
720
|
+
if (noArgsClass) {
|
721
|
+
isArguments = function(value) {
|
722
|
+
return value ? hasOwnProperty.call(value, 'callee') : false;
|
723
|
+
};
|
724
|
+
}
|
725
|
+
|
726
|
+
/**
|
727
|
+
* Iterates over `object`'s own and inherited enumerable properties, executing
|
728
|
+
* the `callback` for each property. The `callback` is bound to `thisArg` and
|
729
|
+
* invoked with three arguments; (value, key, object). Callbacks may exit iteration
|
730
|
+
* early by explicitly returning `false`.
|
731
|
+
*
|
732
|
+
* @static
|
733
|
+
* @memberOf _
|
734
|
+
* @category Objects
|
735
|
+
* @param {Object} object The object to iterate over.
|
736
|
+
* @param {Function} callback The function called per iteration.
|
737
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
738
|
+
* @returns {Object} Returns `object`.
|
739
|
+
* @example
|
740
|
+
*
|
741
|
+
* function Dog(name) {
|
742
|
+
* this.name = name;
|
743
|
+
* }
|
744
|
+
*
|
745
|
+
* Dog.prototype.bark = function() {
|
746
|
+
* alert('Woof, woof!');
|
747
|
+
* };
|
748
|
+
*
|
749
|
+
* _.forIn(new Dog('Dagny'), function(value, key) {
|
750
|
+
* alert(key);
|
751
|
+
* });
|
752
|
+
* // => alerts 'name' and 'bark' (order is not guaranteed)
|
753
|
+
*/
|
754
|
+
var forIn = createIterator(forEachIteratorOptions, forOwnIteratorOptions, {
|
755
|
+
'useHas': false
|
756
|
+
});
|
757
|
+
|
758
|
+
/**
|
759
|
+
* Iterates over `object`'s own enumerable properties, executing the `callback`
|
760
|
+
* for each property. The `callback` is bound to `thisArg` and invoked with three
|
761
|
+
* arguments; (value, key, object). Callbacks may exit iteration early by explicitly
|
762
|
+
* returning `false`.
|
763
|
+
*
|
764
|
+
* @static
|
765
|
+
* @memberOf _
|
766
|
+
* @category Objects
|
767
|
+
* @param {Object} object The object to iterate over.
|
768
|
+
* @param {Function} callback The function called per iteration.
|
769
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
770
|
+
* @returns {Object} Returns `object`.
|
771
|
+
* @example
|
772
|
+
*
|
773
|
+
* _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
|
774
|
+
* alert(key);
|
775
|
+
* });
|
776
|
+
* // => alerts '0', '1', and 'length' (order is not guaranteed)
|
777
|
+
*/
|
778
|
+
var forOwn = createIterator(forEachIteratorOptions, forOwnIteratorOptions);
|
779
|
+
|
780
|
+
/**
|
781
|
+
* A fallback implementation of `isPlainObject` that checks if a given `value`
|
782
|
+
* is an object created by the `Object` constructor, assuming objects created
|
783
|
+
* by the `Object` constructor have no inherited enumerable properties and that
|
784
|
+
* there are no `Object.prototype` extensions.
|
785
|
+
*
|
786
|
+
* @private
|
787
|
+
* @param {Mixed} value The value to check.
|
788
|
+
* @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.
|
789
|
+
*/
|
790
|
+
function shimIsPlainObject(value) {
|
791
|
+
// avoid non-objects and false positives for `arguments` objects
|
792
|
+
var result = false;
|
793
|
+
if (!(value && typeof value == 'object') || isArguments(value)) {
|
794
|
+
return result;
|
795
|
+
}
|
796
|
+
// IE < 9 presents DOM nodes as `Object` objects except they have `toString`
|
797
|
+
// methods that are `typeof` "string" and still can coerce nodes to strings.
|
798
|
+
// Also check that the constructor is `Object` (i.e. `Object instanceof Object`)
|
799
|
+
var ctor = value.constructor;
|
800
|
+
if ((!noNodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) &&
|
801
|
+
(!isFunction(ctor) || ctor instanceof ctor)) {
|
802
|
+
// IE < 9 iterates inherited properties before own properties. If the first
|
803
|
+
// iterated property is an object's own property then there are no inherited
|
804
|
+
// enumerable properties.
|
805
|
+
if (iteratesOwnLast) {
|
806
|
+
forIn(value, function(value, key, object) {
|
807
|
+
result = !hasOwnProperty.call(object, key);
|
808
|
+
return false;
|
809
|
+
});
|
810
|
+
return result === false;
|
811
|
+
}
|
812
|
+
// In most environments an object's own properties are iterated before
|
813
|
+
// its inherited properties. If the last iterated property is an object's
|
814
|
+
// own property then there are no inherited enumerable properties.
|
815
|
+
forIn(value, function(value, key) {
|
816
|
+
result = key;
|
817
|
+
});
|
818
|
+
return result === false || hasOwnProperty.call(value, result);
|
819
|
+
}
|
820
|
+
return result;
|
821
|
+
}
|
822
|
+
|
823
|
+
/**
|
824
|
+
* A fallback implementation of `Object.keys` that produces an array of the
|
825
|
+
* given object's own enumerable property names.
|
826
|
+
*
|
827
|
+
* @private
|
828
|
+
* @param {Object} object The object to inspect.
|
829
|
+
* @returns {Array} Returns a new array of property names.
|
830
|
+
*/
|
831
|
+
function shimKeys(object) {
|
832
|
+
var result = [];
|
833
|
+
forOwn(object, function(value, key) {
|
834
|
+
result.push(key);
|
835
|
+
});
|
836
|
+
return result;
|
837
|
+
}
|
838
|
+
|
839
|
+
/**
|
840
|
+
* Used to convert characters to HTML entities:
|
841
|
+
*
|
842
|
+
* Though the `>` character is escaped for symmetry, characters like `>` and `/`
|
843
|
+
* don't require escaping in HTML and have no special meaning unless they're part
|
844
|
+
* of a tag or an unquoted attribute value.
|
845
|
+
* http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
|
846
|
+
*/
|
847
|
+
var htmlEscapes = {
|
848
|
+
'&': '&',
|
849
|
+
'<': '<',
|
850
|
+
'>': '>',
|
851
|
+
'"': '"',
|
852
|
+
"'": '''
|
853
|
+
};
|
854
|
+
|
855
|
+
/** Used to convert HTML entities to characters */
|
856
|
+
var htmlUnescapes = invert(htmlEscapes);
|
857
|
+
|
858
|
+
/*--------------------------------------------------------------------------*/
|
859
|
+
|
860
|
+
/**
|
861
|
+
* Creates a clone of `value`. If `deep` is `true`, all nested objects will
|
862
|
+
* also be cloned otherwise they will be assigned by reference. Functions, DOM
|
863
|
+
* nodes, `arguments` objects, and objects created by constructors other than
|
864
|
+
* `Object` are **not** cloned.
|
865
|
+
*
|
866
|
+
* @static
|
867
|
+
* @memberOf _
|
868
|
+
* @category Objects
|
869
|
+
* @param {Mixed} value The value to clone.
|
870
|
+
* @param {Boolean} deep A flag to indicate a deep clone.
|
871
|
+
* @param- {Object} [guard] Internally used to allow this method to work with
|
872
|
+
* others like `_.map` without using their callback `index` argument for `deep`.
|
873
|
+
* @param- {Array} [stackA=[]] Internally used to track traversed source objects.
|
874
|
+
* @param- {Array} [stackB=[]] Internally used to associate clones with their
|
875
|
+
* source counterparts.
|
876
|
+
* @returns {Mixed} Returns the cloned `value`.
|
877
|
+
* @example
|
878
|
+
*
|
879
|
+
* var stooges = [
|
880
|
+
* { 'name': 'moe', 'age': 40 },
|
881
|
+
* { 'name': 'larry', 'age': 50 },
|
882
|
+
* { 'name': 'curly', 'age': 60 }
|
883
|
+
* ];
|
884
|
+
*
|
885
|
+
* _.clone({ 'name': 'moe' });
|
886
|
+
* // => { 'name': 'moe' }
|
887
|
+
*
|
888
|
+
* var shallow = _.clone(stooges);
|
889
|
+
* shallow[0] === stooges[0];
|
890
|
+
* // => true
|
891
|
+
*
|
892
|
+
* var deep = _.clone(stooges, true);
|
893
|
+
* shallow[0] === stooges[0];
|
894
|
+
* // => false
|
895
|
+
*/
|
896
|
+
function clone(value, deep, guard, stackA, stackB) {
|
897
|
+
if (value == null) {
|
898
|
+
return value;
|
899
|
+
}
|
900
|
+
if (guard) {
|
901
|
+
deep = false;
|
902
|
+
}
|
903
|
+
// inspect [[Class]]
|
904
|
+
var isObj = isObject(value);
|
905
|
+
if (isObj) {
|
906
|
+
// don't clone `arguments` objects, functions, or non-object Objects
|
907
|
+
var className = toString.call(value);
|
908
|
+
if (!cloneableClasses[className] || (noArgsClass && isArguments(value))) {
|
909
|
+
return value;
|
910
|
+
}
|
911
|
+
var isArr = className == arrayClass;
|
912
|
+
isObj = isArr || (className == objectClass ? isPlainObject(value) : isObj);
|
913
|
+
}
|
914
|
+
// shallow clone
|
915
|
+
if (!isObj || !deep) {
|
916
|
+
// don't clone functions
|
917
|
+
return isObj
|
918
|
+
? (isArr ? slice.call(value) : extend({}, value))
|
919
|
+
: value;
|
920
|
+
}
|
921
|
+
|
922
|
+
var ctor = value.constructor;
|
923
|
+
switch (className) {
|
924
|
+
case boolClass:
|
925
|
+
case dateClass:
|
926
|
+
return new ctor(+value);
|
927
|
+
|
928
|
+
case numberClass:
|
929
|
+
case stringClass:
|
930
|
+
return new ctor(value);
|
931
|
+
|
932
|
+
case regexpClass:
|
933
|
+
return ctor(value.source, reFlags.exec(value));
|
934
|
+
}
|
935
|
+
// check for circular references and return corresponding clone
|
936
|
+
stackA || (stackA = []);
|
937
|
+
stackB || (stackB = []);
|
938
|
+
|
939
|
+
var length = stackA.length;
|
940
|
+
while (length--) {
|
941
|
+
if (stackA[length] == value) {
|
942
|
+
return stackB[length];
|
943
|
+
}
|
944
|
+
}
|
945
|
+
// init cloned object
|
946
|
+
var result = isArr ? ctor(value.length) : {};
|
947
|
+
|
948
|
+
// add the source value to the stack of traversed objects
|
949
|
+
// and associate it with its clone
|
950
|
+
stackA.push(value);
|
951
|
+
stackB.push(result);
|
952
|
+
|
953
|
+
// recursively populate clone (susceptible to call stack limits)
|
954
|
+
(isArr ? forEach : forOwn)(value, function(objValue, key) {
|
955
|
+
result[key] = clone(objValue, deep, null, stackA, stackB);
|
956
|
+
});
|
957
|
+
|
958
|
+
return result;
|
959
|
+
}
|
960
|
+
|
961
|
+
/**
|
962
|
+
* Assigns enumerable properties of the default object(s) to the `destination`
|
963
|
+
* object for all `destination` properties that resolve to `null`/`undefined`.
|
964
|
+
* Once a property is set, additional defaults of the same property will be
|
965
|
+
* ignored.
|
966
|
+
*
|
967
|
+
* @static
|
968
|
+
* @memberOf _
|
969
|
+
* @category Objects
|
970
|
+
* @param {Object} object The destination object.
|
971
|
+
* @param {Object} [default1, default2, ...] The default objects.
|
972
|
+
* @returns {Object} Returns the destination object.
|
973
|
+
* @example
|
974
|
+
*
|
975
|
+
* var iceCream = { 'flavor': 'chocolate' };
|
976
|
+
* _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' });
|
977
|
+
* // => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' }
|
978
|
+
*/
|
979
|
+
var defaults = createIterator(extendIteratorOptions, {
|
980
|
+
'objectLoop': 'if (result[index] == null) ' + extendIteratorOptions.objectLoop
|
981
|
+
});
|
982
|
+
|
983
|
+
/**
|
984
|
+
* Assigns enumerable properties of the source object(s) to the `destination`
|
985
|
+
* object. Subsequent sources will overwrite propery assignments of previous
|
986
|
+
* sources.
|
987
|
+
*
|
988
|
+
* @static
|
989
|
+
* @memberOf _
|
990
|
+
* @category Objects
|
991
|
+
* @param {Object} object The destination object.
|
992
|
+
* @param {Object} [source1, source2, ...] The source objects.
|
993
|
+
* @returns {Object} Returns the destination object.
|
994
|
+
* @example
|
995
|
+
*
|
996
|
+
* _.extend({ 'name': 'moe' }, { 'age': 40 });
|
997
|
+
* // => { 'name': 'moe', 'age': 40 }
|
998
|
+
*/
|
999
|
+
var extend = createIterator(extendIteratorOptions);
|
1000
|
+
|
1001
|
+
/**
|
1002
|
+
* Creates a sorted array of all enumerable properties, own and inherited,
|
1003
|
+
* of `object` that have function values.
|
1004
|
+
*
|
1005
|
+
* @static
|
1006
|
+
* @memberOf _
|
1007
|
+
* @alias methods
|
1008
|
+
* @category Objects
|
1009
|
+
* @param {Object} object The object to inspect.
|
1010
|
+
* @returns {Array} Returns a new array of property names that have function values.
|
1011
|
+
* @example
|
1012
|
+
*
|
1013
|
+
* _.functions(_);
|
1014
|
+
* // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
|
1015
|
+
*/
|
1016
|
+
function functions(object) {
|
1017
|
+
var result = [];
|
1018
|
+
forIn(object, function(value, key) {
|
1019
|
+
if (isFunction(value)) {
|
1020
|
+
result.push(key);
|
1021
|
+
}
|
1022
|
+
});
|
1023
|
+
return result.sort();
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
/**
|
1027
|
+
* Checks if the specified object `property` exists and is a direct property,
|
1028
|
+
* instead of an inherited property.
|
1029
|
+
*
|
1030
|
+
* @static
|
1031
|
+
* @memberOf _
|
1032
|
+
* @category Objects
|
1033
|
+
* @param {Object} object The object to check.
|
1034
|
+
* @param {String} property The property to check for.
|
1035
|
+
* @returns {Boolean} Returns `true` if key is a direct property, else `false`.
|
1036
|
+
* @example
|
1037
|
+
*
|
1038
|
+
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
1039
|
+
* // => true
|
1040
|
+
*/
|
1041
|
+
function has(object, property) {
|
1042
|
+
return object ? hasOwnProperty.call(object, property) : false;
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
/**
|
1046
|
+
* Creates an object composed of the inverted keys and values of the given `object`.
|
1047
|
+
*
|
1048
|
+
* @static
|
1049
|
+
* @memberOf _
|
1050
|
+
* @category Objects
|
1051
|
+
* @param {Object} object The object to invert.
|
1052
|
+
* @returns {Object} Returns the created inverted object.
|
1053
|
+
* @example
|
1054
|
+
*
|
1055
|
+
* _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });
|
1056
|
+
* // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed)
|
1057
|
+
*/
|
1058
|
+
function invert(object) {
|
1059
|
+
var result = {};
|
1060
|
+
forOwn(object, function(value, key) {
|
1061
|
+
result[value] = key;
|
1062
|
+
});
|
1063
|
+
return result;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* Checks if `value` is an array.
|
1068
|
+
*
|
1069
|
+
* @static
|
1070
|
+
* @memberOf _
|
1071
|
+
* @category Objects
|
1072
|
+
* @param {Mixed} value The value to check.
|
1073
|
+
* @returns {Boolean} Returns `true` if the `value` is an array, else `false`.
|
1074
|
+
* @example
|
1075
|
+
*
|
1076
|
+
* (function() { return _.isArray(arguments); })();
|
1077
|
+
* // => false
|
1078
|
+
*
|
1079
|
+
* _.isArray([1, 2, 3]);
|
1080
|
+
* // => true
|
1081
|
+
*/
|
1082
|
+
var isArray = nativeIsArray || function(value) {
|
1083
|
+
return toString.call(value) == arrayClass;
|
1084
|
+
};
|
1085
|
+
|
1086
|
+
/**
|
1087
|
+
* Checks if `value` is a boolean (`true` or `false`) value.
|
1088
|
+
*
|
1089
|
+
* @static
|
1090
|
+
* @memberOf _
|
1091
|
+
* @category Objects
|
1092
|
+
* @param {Mixed} value The value to check.
|
1093
|
+
* @returns {Boolean} Returns `true` if the `value` is a boolean value, else `false`.
|
1094
|
+
* @example
|
1095
|
+
*
|
1096
|
+
* _.isBoolean(null);
|
1097
|
+
* // => false
|
1098
|
+
*/
|
1099
|
+
function isBoolean(value) {
|
1100
|
+
return value === true || value === false || toString.call(value) == boolClass;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
/**
|
1104
|
+
* Checks if `value` is a date.
|
1105
|
+
*
|
1106
|
+
* @static
|
1107
|
+
* @memberOf _
|
1108
|
+
* @category Objects
|
1109
|
+
* @param {Mixed} value The value to check.
|
1110
|
+
* @returns {Boolean} Returns `true` if the `value` is a date, else `false`.
|
1111
|
+
* @example
|
1112
|
+
*
|
1113
|
+
* _.isDate(new Date);
|
1114
|
+
* // => true
|
1115
|
+
*/
|
1116
|
+
function isDate(value) {
|
1117
|
+
return toString.call(value) == dateClass;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
/**
|
1121
|
+
* Checks if `value` is a DOM element.
|
1122
|
+
*
|
1123
|
+
* @static
|
1124
|
+
* @memberOf _
|
1125
|
+
* @category Objects
|
1126
|
+
* @param {Mixed} value The value to check.
|
1127
|
+
* @returns {Boolean} Returns `true` if the `value` is a DOM element, else `false`.
|
1128
|
+
* @example
|
1129
|
+
*
|
1130
|
+
* _.isElement(document.body);
|
1131
|
+
* // => true
|
1132
|
+
*/
|
1133
|
+
function isElement(value) {
|
1134
|
+
return value ? value.nodeType === 1 : false;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
/**
|
1138
|
+
* Checks if `value` is empty. Arrays, strings, or `arguments` objects with a
|
1139
|
+
* length of `0` and objects with no own enumerable properties are considered
|
1140
|
+
* "empty".
|
1141
|
+
*
|
1142
|
+
* @static
|
1143
|
+
* @memberOf _
|
1144
|
+
* @category Objects
|
1145
|
+
* @param {Array|Object|String} value The value to inspect.
|
1146
|
+
* @returns {Boolean} Returns `true` if the `value` is empty, else `false`.
|
1147
|
+
* @example
|
1148
|
+
*
|
1149
|
+
* _.isEmpty([1, 2, 3]);
|
1150
|
+
* // => false
|
1151
|
+
*
|
1152
|
+
* _.isEmpty({});
|
1153
|
+
* // => true
|
1154
|
+
*
|
1155
|
+
* _.isEmpty('');
|
1156
|
+
* // => true
|
1157
|
+
*/
|
1158
|
+
function isEmpty(value) {
|
1159
|
+
var result = true;
|
1160
|
+
if (!value) {
|
1161
|
+
return result;
|
1162
|
+
}
|
1163
|
+
var className = toString.call(value),
|
1164
|
+
length = value.length;
|
1165
|
+
|
1166
|
+
if ((className == arrayClass || className == stringClass ||
|
1167
|
+
className == argsClass || (noArgsClass && isArguments(value))) ||
|
1168
|
+
(className == objectClass && typeof length == 'number' && isFunction(value.splice))) {
|
1169
|
+
return !length;
|
1170
|
+
}
|
1171
|
+
forOwn(value, function() {
|
1172
|
+
return (result = false);
|
1173
|
+
});
|
1174
|
+
return result;
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
/**
|
1178
|
+
* Performs a deep comparison between two values to determine if they are
|
1179
|
+
* equivalent to each other.
|
1180
|
+
*
|
1181
|
+
* @static
|
1182
|
+
* @memberOf _
|
1183
|
+
* @category Objects
|
1184
|
+
* @param {Mixed} a The value to compare.
|
1185
|
+
* @param {Mixed} b The other value to compare.
|
1186
|
+
* @param- {Object} [stackA=[]] Internally used track traversed `a` objects.
|
1187
|
+
* @param- {Object} [stackB=[]] Internally used track traversed `b` objects.
|
1188
|
+
* @returns {Boolean} Returns `true` if the values are equvalent, else `false`.
|
1189
|
+
* @example
|
1190
|
+
*
|
1191
|
+
* var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] };
|
1192
|
+
* var clone = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] };
|
1193
|
+
*
|
1194
|
+
* moe == clone;
|
1195
|
+
* // => false
|
1196
|
+
*
|
1197
|
+
* _.isEqual(moe, clone);
|
1198
|
+
* // => true
|
1199
|
+
*/
|
1200
|
+
function isEqual(a, b, stackA, stackB) {
|
1201
|
+
// exit early for identical values
|
1202
|
+
if (a === b) {
|
1203
|
+
// treat `+0` vs. `-0` as not equal
|
1204
|
+
return a !== 0 || (1 / a == 1 / b);
|
1205
|
+
}
|
1206
|
+
// a strict comparison is necessary because `null == undefined`
|
1207
|
+
if (a == null || b == null) {
|
1208
|
+
return a === b;
|
1209
|
+
}
|
1210
|
+
// compare [[Class]] names
|
1211
|
+
var className = toString.call(a);
|
1212
|
+
if (className != toString.call(b)) {
|
1213
|
+
return false;
|
1214
|
+
}
|
1215
|
+
switch (className) {
|
1216
|
+
case boolClass:
|
1217
|
+
case dateClass:
|
1218
|
+
// coerce dates and booleans to numbers, dates to milliseconds and booleans
|
1219
|
+
// to `1` or `0`, treating invalid dates coerced to `NaN` as not equal
|
1220
|
+
return +a == +b;
|
1221
|
+
|
1222
|
+
case numberClass:
|
1223
|
+
// treat `NaN` vs. `NaN` as equal
|
1224
|
+
return a != +a
|
1225
|
+
? b != +b
|
1226
|
+
// but treat `+0` vs. `-0` as not equal
|
1227
|
+
: (a == 0 ? (1 / a == 1 / b) : a == +b);
|
1228
|
+
|
1229
|
+
case regexpClass:
|
1230
|
+
case stringClass:
|
1231
|
+
// coerce regexes to strings (http://es5.github.com/#x15.10.6.4)
|
1232
|
+
// treat string primitives and their corresponding object instances as equal
|
1233
|
+
return a == b + '';
|
1234
|
+
}
|
1235
|
+
// exit early, in older browsers, if `a` is array-like but not `b`
|
1236
|
+
var isArr = className == arrayClass || className == argsClass;
|
1237
|
+
if (noArgsClass && !isArr && (isArr = isArguments(a)) && !isArguments(b)) {
|
1238
|
+
return false;
|
1239
|
+
}
|
1240
|
+
if (!isArr) {
|
1241
|
+
// unwrap any `lodash` wrapped values
|
1242
|
+
if (a.__wrapped__ || b.__wrapped__) {
|
1243
|
+
return isEqual(a.__wrapped__ || a, b.__wrapped__ || b);
|
1244
|
+
}
|
1245
|
+
// exit for functions and DOM nodes
|
1246
|
+
if (className != objectClass || (noNodeClass && (
|
1247
|
+
(typeof a.toString != 'function' && typeof (a + '') == 'string') ||
|
1248
|
+
(typeof b.toString != 'function' && typeof (b + '') == 'string')))) {
|
1249
|
+
return false;
|
1250
|
+
}
|
1251
|
+
var ctorA = a.constructor,
|
1252
|
+
ctorB = b.constructor;
|
1253
|
+
|
1254
|
+
// non `Object` object instances with different constructors are not equal
|
1255
|
+
if (ctorA != ctorB && !(
|
1256
|
+
isFunction(ctorA) && ctorA instanceof ctorA &&
|
1257
|
+
isFunction(ctorB) && ctorB instanceof ctorB
|
1258
|
+
)) {
|
1259
|
+
return false;
|
1260
|
+
}
|
1261
|
+
}
|
1262
|
+
// assume cyclic structures are equal
|
1263
|
+
// the algorithm for detecting cyclic structures is adapted from ES 5.1
|
1264
|
+
// section 15.12.3, abstract operation `JO` (http://es5.github.com/#x15.12.3)
|
1265
|
+
stackA || (stackA = []);
|
1266
|
+
stackB || (stackB = []);
|
1267
|
+
|
1268
|
+
var length = stackA.length;
|
1269
|
+
while (length--) {
|
1270
|
+
if (stackA[length] == a) {
|
1271
|
+
return stackB[length] == b;
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
var index = -1,
|
1276
|
+
result = true,
|
1277
|
+
size = 0;
|
1278
|
+
|
1279
|
+
// add `a` and `b` to the stack of traversed objects
|
1280
|
+
stackA.push(a);
|
1281
|
+
stackB.push(b);
|
1282
|
+
|
1283
|
+
// recursively compare objects and arrays (susceptible to call stack limits)
|
1284
|
+
if (isArr) {
|
1285
|
+
// compare lengths to determine if a deep comparison is necessary
|
1286
|
+
size = a.length;
|
1287
|
+
result = size == b.length;
|
1288
|
+
|
1289
|
+
if (result) {
|
1290
|
+
// deep compare the contents, ignoring non-numeric properties
|
1291
|
+
while (size--) {
|
1292
|
+
if (!(result = isEqual(a[size], b[size], stackA, stackB))) {
|
1293
|
+
break;
|
1294
|
+
}
|
1295
|
+
}
|
1296
|
+
}
|
1297
|
+
return result;
|
1298
|
+
}
|
1299
|
+
// deep compare objects
|
1300
|
+
for (var key in a) {
|
1301
|
+
if (hasOwnProperty.call(a, key)) {
|
1302
|
+
// count the number of properties.
|
1303
|
+
size++;
|
1304
|
+
// deep compare each property value.
|
1305
|
+
if (!(hasOwnProperty.call(b, key) && isEqual(a[key], b[key], stackA, stackB))) {
|
1306
|
+
return false;
|
1307
|
+
}
|
1308
|
+
}
|
1309
|
+
}
|
1310
|
+
// ensure both objects have the same number of properties
|
1311
|
+
for (key in b) {
|
1312
|
+
// The JS engine in Adobe products, like InDesign, has a bug that causes
|
1313
|
+
// `!size--` to throw an error so it must be wrapped in parentheses.
|
1314
|
+
// https://github.com/documentcloud/underscore/issues/355
|
1315
|
+
if (hasOwnProperty.call(b, key) && !(size--)) {
|
1316
|
+
// `size` will be `-1` if `b` has more properties than `a`
|
1317
|
+
return false;
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
// handle JScript [[DontEnum]] bug
|
1321
|
+
if (hasDontEnumBug) {
|
1322
|
+
while (++index < 7) {
|
1323
|
+
key = shadowed[index];
|
1324
|
+
if (hasOwnProperty.call(a, key) &&
|
1325
|
+
!(hasOwnProperty.call(b, key) && isEqual(a[key], b[key], stackA, stackB))) {
|
1326
|
+
return false;
|
1327
|
+
}
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
return true;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
/**
|
1334
|
+
* Checks if `value` is, or can be coerced to, a finite number.
|
1335
|
+
*
|
1336
|
+
* Note: This is not the same as native `isFinite`, which will return true for
|
1337
|
+
* booleans and empty strings. See http://es5.github.com/#x15.1.2.5.
|
1338
|
+
*
|
1339
|
+
* @deprecated
|
1340
|
+
* @static
|
1341
|
+
* @memberOf _
|
1342
|
+
* @category Objects
|
1343
|
+
* @param {Mixed} value The value to check.
|
1344
|
+
* @returns {Boolean} Returns `true` if the `value` is a finite number, else `false`.
|
1345
|
+
* @example
|
1346
|
+
*
|
1347
|
+
* _.isFinite(-101);
|
1348
|
+
* // => true
|
1349
|
+
*
|
1350
|
+
* _.isFinite('10');
|
1351
|
+
* // => true
|
1352
|
+
*
|
1353
|
+
* _.isFinite(true);
|
1354
|
+
* // => false
|
1355
|
+
*
|
1356
|
+
* _.isFinite('');
|
1357
|
+
* // => false
|
1358
|
+
*
|
1359
|
+
* _.isFinite(Infinity);
|
1360
|
+
* // => false
|
1361
|
+
*/
|
1362
|
+
function isFinite(value) {
|
1363
|
+
return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
/**
|
1367
|
+
* Checks if `value` is a function.
|
1368
|
+
*
|
1369
|
+
* @static
|
1370
|
+
* @memberOf _
|
1371
|
+
* @category Objects
|
1372
|
+
* @param {Mixed} value The value to check.
|
1373
|
+
* @returns {Boolean} Returns `true` if the `value` is a function, else `false`.
|
1374
|
+
* @example
|
1375
|
+
*
|
1376
|
+
* _.isFunction(_);
|
1377
|
+
* // => true
|
1378
|
+
*/
|
1379
|
+
function isFunction(value) {
|
1380
|
+
return typeof value == 'function';
|
1381
|
+
}
|
1382
|
+
// fallback for older versions of Chrome and Safari
|
1383
|
+
if (isFunction(/x/)) {
|
1384
|
+
isFunction = function(value) {
|
1385
|
+
return toString.call(value) == funcClass;
|
1386
|
+
};
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
/**
|
1390
|
+
* Checks if `value` is the language type of Object.
|
1391
|
+
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
1392
|
+
*
|
1393
|
+
* @static
|
1394
|
+
* @memberOf _
|
1395
|
+
* @category Objects
|
1396
|
+
* @param {Mixed} value The value to check.
|
1397
|
+
* @returns {Boolean} Returns `true` if the `value` is an object, else `false`.
|
1398
|
+
* @example
|
1399
|
+
*
|
1400
|
+
* _.isObject({});
|
1401
|
+
* // => true
|
1402
|
+
*
|
1403
|
+
* _.isObject([1, 2, 3]);
|
1404
|
+
* // => true
|
1405
|
+
*
|
1406
|
+
* _.isObject(1);
|
1407
|
+
* // => false
|
1408
|
+
*/
|
1409
|
+
function isObject(value) {
|
1410
|
+
// check if the value is the ECMAScript language type of Object
|
1411
|
+
// http://es5.github.com/#x8
|
1412
|
+
// and avoid a V8 bug
|
1413
|
+
// http://code.google.com/p/v8/issues/detail?id=2291
|
1414
|
+
return value ? objectTypes[typeof value] : false;
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
/**
|
1418
|
+
* Checks if `value` is `NaN`.
|
1419
|
+
*
|
1420
|
+
* Note: This is not the same as native `isNaN`, which will return true for
|
1421
|
+
* `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
|
1422
|
+
*
|
1423
|
+
* @deprecated
|
1424
|
+
* @static
|
1425
|
+
* @memberOf _
|
1426
|
+
* @category Objects
|
1427
|
+
* @param {Mixed} value The value to check.
|
1428
|
+
* @returns {Boolean} Returns `true` if the `value` is `NaN`, else `false`.
|
1429
|
+
* @example
|
1430
|
+
*
|
1431
|
+
* _.isNaN(NaN);
|
1432
|
+
* // => true
|
1433
|
+
*
|
1434
|
+
* _.isNaN(new Number(NaN));
|
1435
|
+
* // => true
|
1436
|
+
*
|
1437
|
+
* isNaN(undefined);
|
1438
|
+
* // => true
|
1439
|
+
*
|
1440
|
+
* _.isNaN(undefined);
|
1441
|
+
* // => false
|
1442
|
+
*/
|
1443
|
+
function isNaN(value) {
|
1444
|
+
// `NaN` as a primitive is the only value that is not equal to itself
|
1445
|
+
// (perform the [[Class]] check first to avoid errors with some host objects in IE)
|
1446
|
+
return toString.call(value) == numberClass && value != +value
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
/**
|
1450
|
+
* Checks if `value` is `null`.
|
1451
|
+
*
|
1452
|
+
* @deprecated
|
1453
|
+
* @static
|
1454
|
+
* @memberOf _
|
1455
|
+
* @category Objects
|
1456
|
+
* @param {Mixed} value The value to check.
|
1457
|
+
* @returns {Boolean} Returns `true` if the `value` is `null`, else `false`.
|
1458
|
+
* @example
|
1459
|
+
*
|
1460
|
+
* _.isNull(null);
|
1461
|
+
* // => true
|
1462
|
+
*
|
1463
|
+
* _.isNull(undefined);
|
1464
|
+
* // => false
|
1465
|
+
*/
|
1466
|
+
function isNull(value) {
|
1467
|
+
return value === null;
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
/**
|
1471
|
+
* Checks if `value` is a number.
|
1472
|
+
*
|
1473
|
+
* @static
|
1474
|
+
* @memberOf _
|
1475
|
+
* @category Objects
|
1476
|
+
* @param {Mixed} value The value to check.
|
1477
|
+
* @returns {Boolean} Returns `true` if the `value` is a number, else `false`.
|
1478
|
+
* @example
|
1479
|
+
*
|
1480
|
+
* _.isNumber(8.4 * 5);
|
1481
|
+
* // => true
|
1482
|
+
*/
|
1483
|
+
function isNumber(value) {
|
1484
|
+
return toString.call(value) == numberClass;
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
/**
|
1488
|
+
* Checks if a given `value` is an object created by the `Object` constructor.
|
1489
|
+
*
|
1490
|
+
* @static
|
1491
|
+
* @memberOf _
|
1492
|
+
* @category Objects
|
1493
|
+
* @param {Mixed} value The value to check.
|
1494
|
+
* @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.
|
1495
|
+
* @example
|
1496
|
+
*
|
1497
|
+
* function Stooge(name, age) {
|
1498
|
+
* this.name = name;
|
1499
|
+
* this.age = age;
|
1500
|
+
* }
|
1501
|
+
*
|
1502
|
+
* _.isPlainObject(new Stooge('moe', 40));
|
1503
|
+
* // => false
|
1504
|
+
*
|
1505
|
+
* _.isPlainObject([1, 2, 3]);
|
1506
|
+
* // => false
|
1507
|
+
*
|
1508
|
+
* _.isPlainObject({ 'name': 'moe', 'age': 40 });
|
1509
|
+
* // => true
|
1510
|
+
*/
|
1511
|
+
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
1512
|
+
if (!(value && typeof value == 'object')) {
|
1513
|
+
return false;
|
1514
|
+
}
|
1515
|
+
var valueOf = value.valueOf,
|
1516
|
+
objProto = typeof valueOf == 'function' && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
1517
|
+
|
1518
|
+
return objProto
|
1519
|
+
? value == objProto || (getPrototypeOf(value) == objProto && !isArguments(value))
|
1520
|
+
: shimIsPlainObject(value);
|
1521
|
+
};
|
1522
|
+
|
1523
|
+
/**
|
1524
|
+
* Checks if `value` is a regular expression.
|
1525
|
+
*
|
1526
|
+
* @static
|
1527
|
+
* @memberOf _
|
1528
|
+
* @category Objects
|
1529
|
+
* @param {Mixed} value The value to check.
|
1530
|
+
* @returns {Boolean} Returns `true` if the `value` is a regular expression, else `false`.
|
1531
|
+
* @example
|
1532
|
+
*
|
1533
|
+
* _.isRegExp(/moe/);
|
1534
|
+
* // => true
|
1535
|
+
*/
|
1536
|
+
function isRegExp(value) {
|
1537
|
+
return toString.call(value) == regexpClass;
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
/**
|
1541
|
+
* Checks if `value` is a string.
|
1542
|
+
*
|
1543
|
+
* @static
|
1544
|
+
* @memberOf _
|
1545
|
+
* @category Objects
|
1546
|
+
* @param {Mixed} value The value to check.
|
1547
|
+
* @returns {Boolean} Returns `true` if the `value` is a string, else `false`.
|
1548
|
+
* @example
|
1549
|
+
*
|
1550
|
+
* _.isString('moe');
|
1551
|
+
* // => true
|
1552
|
+
*/
|
1553
|
+
function isString(value) {
|
1554
|
+
return toString.call(value) == stringClass;
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
/**
|
1558
|
+
* Checks if `value` is `undefined`.
|
1559
|
+
*
|
1560
|
+
* @deprecated
|
1561
|
+
* @static
|
1562
|
+
* @memberOf _
|
1563
|
+
* @category Objects
|
1564
|
+
* @param {Mixed} value The value to check.
|
1565
|
+
* @returns {Boolean} Returns `true` if the `value` is `undefined`, else `false`.
|
1566
|
+
* @example
|
1567
|
+
*
|
1568
|
+
* _.isUndefined(void 0);
|
1569
|
+
* // => true
|
1570
|
+
*/
|
1571
|
+
function isUndefined(value) {
|
1572
|
+
return value === undefined;
|
1573
|
+
}
|
1574
|
+
|
1575
|
+
/**
|
1576
|
+
* Creates an array composed of the own enumerable property names of `object`.
|
1577
|
+
*
|
1578
|
+
* @static
|
1579
|
+
* @memberOf _
|
1580
|
+
* @category Objects
|
1581
|
+
* @param {Object} object The object to inspect.
|
1582
|
+
* @returns {Array} Returns a new array of property names.
|
1583
|
+
* @example
|
1584
|
+
*
|
1585
|
+
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
1586
|
+
* // => ['one', 'two', 'three'] (order is not guaranteed)
|
1587
|
+
*/
|
1588
|
+
var keys = !nativeKeys ? shimKeys : function(object) {
|
1589
|
+
// avoid iterating over the `prototype` property
|
1590
|
+
return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype')
|
1591
|
+
? shimKeys(object)
|
1592
|
+
: (isObject(object) ? nativeKeys(object) : []);
|
1593
|
+
};
|
1594
|
+
|
1595
|
+
/**
|
1596
|
+
* Merges enumerable properties of the source object(s) into the `destination`
|
1597
|
+
* object. Subsequent sources will overwrite propery assignments of previous
|
1598
|
+
* sources.
|
1599
|
+
*
|
1600
|
+
* @static
|
1601
|
+
* @memberOf _
|
1602
|
+
* @category Objects
|
1603
|
+
* @param {Object} object The destination object.
|
1604
|
+
* @param {Object} [source1, source2, ...] The source objects.
|
1605
|
+
* @param- {Object} [indicator] Internally used to indicate that the `stack`
|
1606
|
+
* argument is an array of traversed objects instead of another source object.
|
1607
|
+
* @param- {Array} [stackA=[]] Internally used to track traversed source objects.
|
1608
|
+
* @param- {Array} [stackB=[]] Internally used to associate values with their
|
1609
|
+
* source counterparts.
|
1610
|
+
* @returns {Object} Returns the destination object.
|
1611
|
+
* @example
|
1612
|
+
*
|
1613
|
+
* var stooges = [
|
1614
|
+
* { 'name': 'moe' },
|
1615
|
+
* { 'name': 'larry' }
|
1616
|
+
* ];
|
1617
|
+
*
|
1618
|
+
* var ages = [
|
1619
|
+
* { 'age': 40 },
|
1620
|
+
* { 'age': 50 }
|
1621
|
+
* ];
|
1622
|
+
*
|
1623
|
+
* _.merge(stooges, ages);
|
1624
|
+
* // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }]
|
1625
|
+
*/
|
1626
|
+
function merge(object, source, indicator) {
|
1627
|
+
var args = arguments,
|
1628
|
+
index = 0,
|
1629
|
+
length = 2,
|
1630
|
+
stackA = args[3],
|
1631
|
+
stackB = args[4];
|
1632
|
+
|
1633
|
+
if (indicator !== objectRef) {
|
1634
|
+
stackA = [];
|
1635
|
+
stackB = [];
|
1636
|
+
length = args.length;
|
1637
|
+
}
|
1638
|
+
while (++index < length) {
|
1639
|
+
forOwn(args[index], function(source, key) {
|
1640
|
+
var found, isArr, value;
|
1641
|
+
if (source && ((isArr = isArray(source)) || isPlainObject(source))) {
|
1642
|
+
// avoid merging previously merged cyclic sources
|
1643
|
+
var stackLength = stackA.length;
|
1644
|
+
while (stackLength--) {
|
1645
|
+
found = stackA[stackLength] == source;
|
1646
|
+
if (found) {
|
1647
|
+
break;
|
1648
|
+
}
|
1649
|
+
}
|
1650
|
+
if (found) {
|
1651
|
+
object[key] = stackB[stackLength];
|
1652
|
+
}
|
1653
|
+
else {
|
1654
|
+
// add `source` and associated `value` to the stack of traversed objects
|
1655
|
+
stackA.push(source);
|
1656
|
+
stackB.push(value = (value = object[key], isArr)
|
1657
|
+
? (isArray(value) ? value : [])
|
1658
|
+
: (isPlainObject(value) ? value : {})
|
1659
|
+
);
|
1660
|
+
// recursively merge objects and arrays (susceptible to call stack limits)
|
1661
|
+
object[key] = merge(value, source, objectRef, stackA, stackB);
|
1662
|
+
}
|
1663
|
+
} else if (source != null) {
|
1664
|
+
object[key] = source;
|
1665
|
+
}
|
1666
|
+
});
|
1667
|
+
}
|
1668
|
+
return object;
|
1669
|
+
}
|
1670
|
+
|
1671
|
+
/**
|
1672
|
+
* Creates a shallow clone of `object` excluding the specified properties.
|
1673
|
+
* Property names may be specified as individual arguments or as arrays of
|
1674
|
+
* property names. If `callback` is passed, it will be executed for each property
|
1675
|
+
* in the `object`, omitting the properties `callback` returns truthy for. The
|
1676
|
+
* `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).
|
1677
|
+
*
|
1678
|
+
* @static
|
1679
|
+
* @memberOf _
|
1680
|
+
* @category Objects
|
1681
|
+
* @param {Object} object The source object.
|
1682
|
+
* @param {Function|String} callback|[prop1, prop2, ...] The properties to omit
|
1683
|
+
* or the function called per iteration.
|
1684
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1685
|
+
* @returns {Object} Returns an object without the omitted properties.
|
1686
|
+
* @example
|
1687
|
+
*
|
1688
|
+
* _.omit({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid');
|
1689
|
+
* // => { 'name': 'moe', 'age': 40 }
|
1690
|
+
*
|
1691
|
+
* _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) {
|
1692
|
+
* return key.charAt(0) == '_';
|
1693
|
+
* });
|
1694
|
+
* // => { 'name': 'moe' }
|
1695
|
+
*/
|
1696
|
+
function omit(object, callback, thisArg) {
|
1697
|
+
var isFunc = typeof callback == 'function',
|
1698
|
+
result = {};
|
1699
|
+
|
1700
|
+
if (isFunc) {
|
1701
|
+
callback = createCallback(callback, thisArg);
|
1702
|
+
} else {
|
1703
|
+
var props = concat.apply(arrayRef, arguments);
|
1704
|
+
}
|
1705
|
+
forIn(object, function(value, key, object) {
|
1706
|
+
if (isFunc
|
1707
|
+
? !callback(value, key, object)
|
1708
|
+
: indexOf(props, key, 1) < 0
|
1709
|
+
) {
|
1710
|
+
result[key] = value;
|
1711
|
+
}
|
1712
|
+
});
|
1713
|
+
return result;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
/**
|
1717
|
+
* Creates a two dimensional array of the given object's key-value pairs,
|
1718
|
+
* i.e. `[[key1, value1], [key2, value2]]`.
|
1719
|
+
*
|
1720
|
+
* @static
|
1721
|
+
* @memberOf _
|
1722
|
+
* @category Objects
|
1723
|
+
* @param {Object} object The object to inspect.
|
1724
|
+
* @returns {Array} Returns new array of key-value pairs.
|
1725
|
+
* @example
|
1726
|
+
*
|
1727
|
+
* _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 });
|
1728
|
+
* // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed)
|
1729
|
+
*/
|
1730
|
+
function pairs(object) {
|
1731
|
+
var result = [];
|
1732
|
+
forOwn(object, function(value, key) {
|
1733
|
+
result.push([key, value]);
|
1734
|
+
});
|
1735
|
+
return result;
|
1736
|
+
}
|
1737
|
+
|
1738
|
+
/**
|
1739
|
+
* Creates a shallow clone of `object` composed of the specified properties.
|
1740
|
+
* Property names may be specified as individual arguments or as arrays of
|
1741
|
+
* property names. If `callback` is passed, it will be executed for each property
|
1742
|
+
* in the `object`, picking the properties `callback` returns truthy for. The
|
1743
|
+
* `callback` is bound to `thisArg` and invoked with three arguments; (value, key, object).
|
1744
|
+
*
|
1745
|
+
* @static
|
1746
|
+
* @memberOf _
|
1747
|
+
* @category Objects
|
1748
|
+
* @param {Object} object The source object.
|
1749
|
+
* @param {Function|String} callback|[prop1, prop2, ...] The properties to pick
|
1750
|
+
* or the function called per iteration.
|
1751
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1752
|
+
* @returns {Object} Returns an object composed of the picked properties.
|
1753
|
+
* @example
|
1754
|
+
*
|
1755
|
+
* _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age');
|
1756
|
+
* // => { 'name': 'moe', 'age': 40 }
|
1757
|
+
*
|
1758
|
+
* _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) {
|
1759
|
+
* return key.charAt(0) != '_';
|
1760
|
+
* });
|
1761
|
+
* // => { 'name': 'moe' }
|
1762
|
+
*/
|
1763
|
+
function pick(object, callback, thisArg) {
|
1764
|
+
var result = {};
|
1765
|
+
if (typeof callback != 'function') {
|
1766
|
+
var index = 0,
|
1767
|
+
props = concat.apply(arrayRef, arguments),
|
1768
|
+
length = props.length;
|
1769
|
+
|
1770
|
+
while (++index < length) {
|
1771
|
+
var key = props[index];
|
1772
|
+
if (key in object) {
|
1773
|
+
result[key] = object[key];
|
1774
|
+
}
|
1775
|
+
}
|
1776
|
+
} else {
|
1777
|
+
callback = createCallback(callback, thisArg);
|
1778
|
+
forIn(object, function(value, key, object) {
|
1779
|
+
if (callback(value, key, object)) {
|
1780
|
+
result[key] = value;
|
1781
|
+
}
|
1782
|
+
});
|
1783
|
+
}
|
1784
|
+
return result;
|
1785
|
+
}
|
1786
|
+
|
1787
|
+
/**
|
1788
|
+
* Creates an array composed of the own enumerable property values of `object`.
|
1789
|
+
*
|
1790
|
+
* @static
|
1791
|
+
* @memberOf _
|
1792
|
+
* @category Objects
|
1793
|
+
* @param {Object} object The object to inspect.
|
1794
|
+
* @returns {Array} Returns a new array of property values.
|
1795
|
+
* @example
|
1796
|
+
*
|
1797
|
+
* _.values({ 'one': 1, 'two': 2, 'three': 3 });
|
1798
|
+
* // => [1, 2, 3]
|
1799
|
+
*/
|
1800
|
+
function values(object) {
|
1801
|
+
var result = [];
|
1802
|
+
forOwn(object, function(value) {
|
1803
|
+
result.push(value);
|
1804
|
+
});
|
1805
|
+
return result;
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
/*--------------------------------------------------------------------------*/
|
1809
|
+
|
1810
|
+
/**
|
1811
|
+
* Checks if a given `target` element is present in a `collection` using strict
|
1812
|
+
* equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
|
1813
|
+
* as the offset from the end of the collection.
|
1814
|
+
*
|
1815
|
+
* @static
|
1816
|
+
* @memberOf _
|
1817
|
+
* @alias include
|
1818
|
+
* @category Collections
|
1819
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
1820
|
+
* @param {Mixed} target The value to check for.
|
1821
|
+
* @param {Number} [fromIndex=0] The index to search from.
|
1822
|
+
* @returns {Boolean} Returns `true` if the `target` element is found, else `false`.
|
1823
|
+
* @example
|
1824
|
+
*
|
1825
|
+
* _.contains([1, 2, 3], 1);
|
1826
|
+
* // => true
|
1827
|
+
*
|
1828
|
+
* _.contains([1, 2, 3], 1, 2);
|
1829
|
+
* // => false
|
1830
|
+
*
|
1831
|
+
* _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
|
1832
|
+
* // => true
|
1833
|
+
*
|
1834
|
+
* _.contains('curly', 'ur');
|
1835
|
+
* // => true
|
1836
|
+
*/
|
1837
|
+
function contains(collection, target, fromIndex) {
|
1838
|
+
var index = -1,
|
1839
|
+
length = collection ? collection.length : 0;
|
1840
|
+
|
1841
|
+
fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0;
|
1842
|
+
if (typeof length == 'number') {
|
1843
|
+
return (isString(collection)
|
1844
|
+
? collection.indexOf(target, fromIndex)
|
1845
|
+
: indexOf(collection, target, fromIndex)
|
1846
|
+
) > -1;
|
1847
|
+
}
|
1848
|
+
return some(collection, function(value) {
|
1849
|
+
return ++index >= fromIndex && value === target;
|
1850
|
+
});
|
1851
|
+
}
|
1852
|
+
|
1853
|
+
/**
|
1854
|
+
* Creates an object composed of keys returned from running each element of
|
1855
|
+
* `collection` through a `callback`. The corresponding value of each key is
|
1856
|
+
* the number of times the key was returned by `callback`. The `callback` is
|
1857
|
+
* bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
1858
|
+
* The `callback` argument may also be the name of a property to count by (e.g. 'length').
|
1859
|
+
*
|
1860
|
+
* @static
|
1861
|
+
* @memberOf _
|
1862
|
+
* @category Collections
|
1863
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
1864
|
+
* @param {Function|String} callback|property The function called per iteration
|
1865
|
+
* or property name to count by.
|
1866
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1867
|
+
* @returns {Object} Returns the composed aggregate object.
|
1868
|
+
* @example
|
1869
|
+
*
|
1870
|
+
* _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
|
1871
|
+
* // => { '4': 1, '6': 2 }
|
1872
|
+
*
|
1873
|
+
* _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
1874
|
+
* // => { '4': 1, '6': 2 }
|
1875
|
+
*
|
1876
|
+
* _.countBy(['one', 'two', 'three'], 'length');
|
1877
|
+
* // => { '3': 2, '5': 1 }
|
1878
|
+
*/
|
1879
|
+
function countBy(collection, callback, thisArg) {
|
1880
|
+
var result = {};
|
1881
|
+
callback = createCallback(callback, thisArg);
|
1882
|
+
forEach(collection, function(value, key, collection) {
|
1883
|
+
key = callback(value, key, collection);
|
1884
|
+
(hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
|
1885
|
+
});
|
1886
|
+
return result;
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
/**
|
1890
|
+
* Checks if the `callback` returns a truthy value for **all** elements of a
|
1891
|
+
* `collection`. The `callback` is bound to `thisArg` and invoked with three
|
1892
|
+
* arguments; (value, index|key, collection).
|
1893
|
+
*
|
1894
|
+
* @static
|
1895
|
+
* @memberOf _
|
1896
|
+
* @alias all
|
1897
|
+
* @category Collections
|
1898
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
1899
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
1900
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1901
|
+
* @returns {Boolean} Returns `true` if all elements pass the callback check,
|
1902
|
+
* else `false`.
|
1903
|
+
* @example
|
1904
|
+
*
|
1905
|
+
* _.every([true, 1, null, 'yes'], Boolean);
|
1906
|
+
* // => false
|
1907
|
+
*/
|
1908
|
+
function every(collection, callback, thisArg) {
|
1909
|
+
var result = true;
|
1910
|
+
callback = createCallback(callback, thisArg);
|
1911
|
+
|
1912
|
+
if (isArray(collection)) {
|
1913
|
+
var index = -1,
|
1914
|
+
length = collection.length;
|
1915
|
+
|
1916
|
+
while (++index < length) {
|
1917
|
+
if (!(result = !!callback(collection[index], index, collection))) {
|
1918
|
+
break;
|
1919
|
+
}
|
1920
|
+
}
|
1921
|
+
} else {
|
1922
|
+
forEach(collection, function(value, index, collection) {
|
1923
|
+
return (result = !!callback(value, index, collection));
|
1924
|
+
});
|
1925
|
+
}
|
1926
|
+
return result;
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
/**
|
1930
|
+
* Examines each element in a `collection`, returning an array of all elements
|
1931
|
+
* the `callback` returns truthy for. The `callback` is bound to `thisArg` and
|
1932
|
+
* invoked with three arguments; (value, index|key, collection).
|
1933
|
+
*
|
1934
|
+
* @static
|
1935
|
+
* @memberOf _
|
1936
|
+
* @alias select
|
1937
|
+
* @category Collections
|
1938
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
1939
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
1940
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1941
|
+
* @returns {Array} Returns a new array of elements that passed the callback check.
|
1942
|
+
* @example
|
1943
|
+
*
|
1944
|
+
* var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
1945
|
+
* // => [2, 4, 6]
|
1946
|
+
*/
|
1947
|
+
function filter(collection, callback, thisArg) {
|
1948
|
+
var result = [];
|
1949
|
+
callback = createCallback(callback, thisArg);
|
1950
|
+
forEach(collection, function(value, index, collection) {
|
1951
|
+
if (callback(value, index, collection)) {
|
1952
|
+
result.push(value);
|
1953
|
+
}
|
1954
|
+
});
|
1955
|
+
return result;
|
1956
|
+
}
|
1957
|
+
|
1958
|
+
/**
|
1959
|
+
* Examines each element in a `collection`, returning the first one the `callback`
|
1960
|
+
* returns truthy for. The function returns as soon as it finds an acceptable
|
1961
|
+
* element, and does not iterate over the entire `collection`. The `callback` is
|
1962
|
+
* bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
1963
|
+
*
|
1964
|
+
* @static
|
1965
|
+
* @memberOf _
|
1966
|
+
* @alias detect
|
1967
|
+
* @category Collections
|
1968
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
1969
|
+
* @param {Function} callback The function called per iteration.
|
1970
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
1971
|
+
* @returns {Mixed} Returns the element that passed the callback check,
|
1972
|
+
* else `undefined`.
|
1973
|
+
* @example
|
1974
|
+
*
|
1975
|
+
* var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
1976
|
+
* // => 2
|
1977
|
+
*/
|
1978
|
+
function find(collection, callback, thisArg) {
|
1979
|
+
var result;
|
1980
|
+
callback = createCallback(callback, thisArg);
|
1981
|
+
forEach(collection, function(value, index, collection) {
|
1982
|
+
if (callback(value, index, collection)) {
|
1983
|
+
result = value;
|
1984
|
+
return false;
|
1985
|
+
}
|
1986
|
+
});
|
1987
|
+
return result;
|
1988
|
+
}
|
1989
|
+
|
1990
|
+
/**
|
1991
|
+
* Iterates over a `collection`, executing the `callback` for each element in
|
1992
|
+
* the `collection`. The `callback` is bound to `thisArg` and invoked with three
|
1993
|
+
* arguments; (value, index|key, collection). Callbacks may exit iteration early
|
1994
|
+
* by explicitly returning `false`.
|
1995
|
+
*
|
1996
|
+
* @static
|
1997
|
+
* @memberOf _
|
1998
|
+
* @alias each
|
1999
|
+
* @category Collections
|
2000
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2001
|
+
* @param {Function} callback The function called per iteration.
|
2002
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2003
|
+
* @returns {Array|Object|String} Returns `collection`.
|
2004
|
+
* @example
|
2005
|
+
*
|
2006
|
+
* _([1, 2, 3]).forEach(alert).join(',');
|
2007
|
+
* // => alerts each number and returns '1,2,3'
|
2008
|
+
*
|
2009
|
+
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
|
2010
|
+
* // => alerts each number (order is not guaranteed)
|
2011
|
+
*/
|
2012
|
+
var forEach = createIterator(forEachIteratorOptions);
|
2013
|
+
|
2014
|
+
/**
|
2015
|
+
* Creates an object composed of keys returned from running each element of
|
2016
|
+
* `collection` through a `callback`. The corresponding value of each key is an
|
2017
|
+
* array of elements passed to `callback` that returned the key. The `callback`
|
2018
|
+
* is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
2019
|
+
* The `callback` argument may also be the name of a property to group by (e.g. 'length').
|
2020
|
+
*
|
2021
|
+
* @static
|
2022
|
+
* @memberOf _
|
2023
|
+
* @category Collections
|
2024
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2025
|
+
* @param {Function|String} callback|property The function called per iteration
|
2026
|
+
* or property name to group by.
|
2027
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2028
|
+
* @returns {Object} Returns the composed aggregate object.
|
2029
|
+
* @example
|
2030
|
+
*
|
2031
|
+
* _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
|
2032
|
+
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
2033
|
+
*
|
2034
|
+
* _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
2035
|
+
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
2036
|
+
*
|
2037
|
+
* _.groupBy(['one', 'two', 'three'], 'length');
|
2038
|
+
* // => { '3': ['one', 'two'], '5': ['three'] }
|
2039
|
+
*/
|
2040
|
+
function groupBy(collection, callback, thisArg) {
|
2041
|
+
var result = {};
|
2042
|
+
callback = createCallback(callback, thisArg);
|
2043
|
+
forEach(collection, function(value, key, collection) {
|
2044
|
+
key = callback(value, key, collection);
|
2045
|
+
(hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
|
2046
|
+
});
|
2047
|
+
return result;
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
/**
|
2051
|
+
* Invokes the method named by `methodName` on each element in the `collection`,
|
2052
|
+
* returning an array of the results of each invoked method. Additional arguments
|
2053
|
+
* will be passed to each invoked method. If `methodName` is a function it will
|
2054
|
+
* be invoked for, and `this` bound to, each element in the `collection`.
|
2055
|
+
*
|
2056
|
+
* @static
|
2057
|
+
* @memberOf _
|
2058
|
+
* @category Collections
|
2059
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2060
|
+
* @param {Function|String} methodName The name of the method to invoke or
|
2061
|
+
* the function invoked per iteration.
|
2062
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with.
|
2063
|
+
* @returns {Array} Returns a new array of the results of each invoked method.
|
2064
|
+
* @example
|
2065
|
+
*
|
2066
|
+
* _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
2067
|
+
* // => [[1, 5, 7], [1, 2, 3]]
|
2068
|
+
*
|
2069
|
+
* _.invoke([123, 456], String.prototype.split, '');
|
2070
|
+
* // => [['1', '2', '3'], ['4', '5', '6']]
|
2071
|
+
*/
|
2072
|
+
function invoke(collection, methodName) {
|
2073
|
+
var args = slice.call(arguments, 2),
|
2074
|
+
isFunc = typeof methodName == 'function',
|
2075
|
+
result = [];
|
2076
|
+
|
2077
|
+
forEach(collection, function(value) {
|
2078
|
+
result.push((isFunc ? methodName : value[methodName]).apply(value, args));
|
2079
|
+
});
|
2080
|
+
return result;
|
2081
|
+
}
|
2082
|
+
|
2083
|
+
/**
|
2084
|
+
* Creates an array of values by running each element in the `collection`
|
2085
|
+
* through a `callback`. The `callback` is bound to `thisArg` and invoked with
|
2086
|
+
* three arguments; (value, index|key, collection).
|
2087
|
+
*
|
2088
|
+
* @static
|
2089
|
+
* @memberOf _
|
2090
|
+
* @alias collect
|
2091
|
+
* @category Collections
|
2092
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2093
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
2094
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2095
|
+
* @returns {Array} Returns a new array of the results of each `callback` execution.
|
2096
|
+
* @example
|
2097
|
+
*
|
2098
|
+
* _.map([1, 2, 3], function(num) { return num * 3; });
|
2099
|
+
* // => [3, 6, 9]
|
2100
|
+
*
|
2101
|
+
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
2102
|
+
* // => [3, 6, 9] (order is not guaranteed)
|
2103
|
+
*/
|
2104
|
+
function map(collection, callback, thisArg) {
|
2105
|
+
var index = -1,
|
2106
|
+
length = collection ? collection.length : 0,
|
2107
|
+
result = Array(typeof length == 'number' ? length : 0);
|
2108
|
+
|
2109
|
+
callback = createCallback(callback, thisArg);
|
2110
|
+
if (isArray(collection)) {
|
2111
|
+
while (++index < length) {
|
2112
|
+
result[index] = callback(collection[index], index, collection);
|
2113
|
+
}
|
2114
|
+
} else {
|
2115
|
+
forEach(collection, function(value, key, collection) {
|
2116
|
+
result[++index] = callback(value, key, collection);
|
2117
|
+
});
|
2118
|
+
}
|
2119
|
+
return result;
|
2120
|
+
}
|
2121
|
+
|
2122
|
+
/**
|
2123
|
+
* Retrieves the maximum value of an `array`. If `callback` is passed,
|
2124
|
+
* it will be executed for each value in the `array` to generate the
|
2125
|
+
* criterion by which the value is ranked. The `callback` is bound to
|
2126
|
+
* `thisArg` and invoked with three arguments; (value, index, collection).
|
2127
|
+
*
|
2128
|
+
* @static
|
2129
|
+
* @memberOf _
|
2130
|
+
* @category Collections
|
2131
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2132
|
+
* @param {Function} [callback] The function called per iteration.
|
2133
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2134
|
+
* @returns {Mixed} Returns the maximum value.
|
2135
|
+
* @example
|
2136
|
+
*
|
2137
|
+
* var stooges = [
|
2138
|
+
* { 'name': 'moe', 'age': 40 },
|
2139
|
+
* { 'name': 'larry', 'age': 50 },
|
2140
|
+
* { 'name': 'curly', 'age': 60 }
|
2141
|
+
* ];
|
2142
|
+
*
|
2143
|
+
* _.max(stooges, function(stooge) { return stooge.age; });
|
2144
|
+
* // => { 'name': 'curly', 'age': 60 };
|
2145
|
+
*/
|
2146
|
+
function max(collection, callback, thisArg) {
|
2147
|
+
var computed = -Infinity,
|
2148
|
+
index = -1,
|
2149
|
+
length = collection ? collection.length : 0,
|
2150
|
+
result = computed;
|
2151
|
+
|
2152
|
+
if (callback || !isArray(collection)) {
|
2153
|
+
callback = !callback && isString(collection)
|
2154
|
+
? charAtCallback
|
2155
|
+
: createCallback(callback, thisArg);
|
2156
|
+
|
2157
|
+
forEach(collection, function(value, index, collection) {
|
2158
|
+
var current = callback(value, index, collection);
|
2159
|
+
if (current > computed) {
|
2160
|
+
computed = current;
|
2161
|
+
result = value;
|
2162
|
+
}
|
2163
|
+
});
|
2164
|
+
} else {
|
2165
|
+
while (++index < length) {
|
2166
|
+
if (collection[index] > result) {
|
2167
|
+
result = collection[index];
|
2168
|
+
}
|
2169
|
+
}
|
2170
|
+
}
|
2171
|
+
return result;
|
2172
|
+
}
|
2173
|
+
|
2174
|
+
/**
|
2175
|
+
* Retrieves the minimum value of an `array`. If `callback` is passed,
|
2176
|
+
* it will be executed for each value in the `array` to generate the
|
2177
|
+
* criterion by which the value is ranked. The `callback` is bound to `thisArg`
|
2178
|
+
* and invoked with three arguments; (value, index, collection).
|
2179
|
+
*
|
2180
|
+
* @static
|
2181
|
+
* @memberOf _
|
2182
|
+
* @category Collections
|
2183
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2184
|
+
* @param {Function} [callback] The function called per iteration.
|
2185
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2186
|
+
* @returns {Mixed} Returns the minimum value.
|
2187
|
+
* @example
|
2188
|
+
*
|
2189
|
+
* _.min([10, 5, 100, 2, 1000]);
|
2190
|
+
* // => 2
|
2191
|
+
*/
|
2192
|
+
function min(collection, callback, thisArg) {
|
2193
|
+
var computed = Infinity,
|
2194
|
+
index = -1,
|
2195
|
+
length = collection ? collection.length : 0,
|
2196
|
+
result = computed;
|
2197
|
+
|
2198
|
+
if (callback || !isArray(collection)) {
|
2199
|
+
callback = !callback && isString(collection)
|
2200
|
+
? charAtCallback
|
2201
|
+
: createCallback(callback, thisArg);
|
2202
|
+
|
2203
|
+
forEach(collection, function(value, index, collection) {
|
2204
|
+
var current = callback(value, index, collection);
|
2205
|
+
if (current < computed) {
|
2206
|
+
computed = current;
|
2207
|
+
result = value;
|
2208
|
+
}
|
2209
|
+
});
|
2210
|
+
} else {
|
2211
|
+
while (++index < length) {
|
2212
|
+
if (collection[index] < result) {
|
2213
|
+
result = collection[index];
|
2214
|
+
}
|
2215
|
+
}
|
2216
|
+
}
|
2217
|
+
return result;
|
2218
|
+
}
|
2219
|
+
|
2220
|
+
/**
|
2221
|
+
* Retrieves the value of a specified property from all elements in
|
2222
|
+
* the `collection`.
|
2223
|
+
*
|
2224
|
+
* @static
|
2225
|
+
* @memberOf _
|
2226
|
+
* @category Collections
|
2227
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2228
|
+
* @param {String} property The property to pluck.
|
2229
|
+
* @returns {Array} Returns a new array of property values.
|
2230
|
+
* @example
|
2231
|
+
*
|
2232
|
+
* var stooges = [
|
2233
|
+
* { 'name': 'moe', 'age': 40 },
|
2234
|
+
* { 'name': 'larry', 'age': 50 },
|
2235
|
+
* { 'name': 'curly', 'age': 60 }
|
2236
|
+
* ];
|
2237
|
+
*
|
2238
|
+
* _.pluck(stooges, 'name');
|
2239
|
+
* // => ['moe', 'larry', 'curly']
|
2240
|
+
*/
|
2241
|
+
function pluck(collection, property) {
|
2242
|
+
var result = [];
|
2243
|
+
forEach(collection, function(value) {
|
2244
|
+
result.push(value[property]);
|
2245
|
+
});
|
2246
|
+
return result;
|
2247
|
+
}
|
2248
|
+
|
2249
|
+
/**
|
2250
|
+
* Boils down a `collection` to a single value. The initial state of the
|
2251
|
+
* reduction is `accumulator` and each successive step of it should be returned
|
2252
|
+
* by the `callback`. The `callback` is bound to `thisArg` and invoked with 4
|
2253
|
+
* arguments; for arrays they are (accumulator, value, index|key, collection).
|
2254
|
+
*
|
2255
|
+
* @static
|
2256
|
+
* @memberOf _
|
2257
|
+
* @alias foldl, inject
|
2258
|
+
* @category Collections
|
2259
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2260
|
+
* @param {Function} callback The function called per iteration.
|
2261
|
+
* @param {Mixed} [accumulator] Initial value of the accumulator.
|
2262
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2263
|
+
* @returns {Mixed} Returns the accumulated value.
|
2264
|
+
* @example
|
2265
|
+
*
|
2266
|
+
* var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });
|
2267
|
+
* // => 6
|
2268
|
+
*/
|
2269
|
+
function reduce(collection, callback, accumulator, thisArg) {
|
2270
|
+
var noaccum = arguments.length < 3;
|
2271
|
+
callback = createCallback(callback, thisArg);
|
2272
|
+
forEach(collection, function(value, index, collection) {
|
2273
|
+
accumulator = noaccum
|
2274
|
+
? (noaccum = false, value)
|
2275
|
+
: callback(accumulator, value, index, collection)
|
2276
|
+
});
|
2277
|
+
return accumulator;
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
/**
|
2281
|
+
* The right-associative version of `_.reduce`.
|
2282
|
+
*
|
2283
|
+
* @static
|
2284
|
+
* @memberOf _
|
2285
|
+
* @alias foldr
|
2286
|
+
* @category Collections
|
2287
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2288
|
+
* @param {Function} callback The function called per iteration.
|
2289
|
+
* @param {Mixed} [accumulator] Initial value of the accumulator.
|
2290
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2291
|
+
* @returns {Mixed} Returns the accumulated value.
|
2292
|
+
* @example
|
2293
|
+
*
|
2294
|
+
* var list = [[0, 1], [2, 3], [4, 5]];
|
2295
|
+
* var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
|
2296
|
+
* // => [4, 5, 2, 3, 0, 1]
|
2297
|
+
*/
|
2298
|
+
function reduceRight(collection, callback, accumulator, thisArg) {
|
2299
|
+
var iteratee = collection,
|
2300
|
+
length = collection ? collection.length : 0,
|
2301
|
+
noaccum = arguments.length < 3;
|
2302
|
+
|
2303
|
+
if (typeof length != 'number') {
|
2304
|
+
var props = keys(collection);
|
2305
|
+
length = props.length;
|
2306
|
+
} else if (noCharByIndex && isString(collection)) {
|
2307
|
+
iteratee = collection.split('');
|
2308
|
+
}
|
2309
|
+
forEach(collection, function(value, index, collection) {
|
2310
|
+
index = props ? props[--length] : --length;
|
2311
|
+
accumulator = noaccum
|
2312
|
+
? (noaccum = false, iteratee[index])
|
2313
|
+
: callback.call(thisArg, accumulator, iteratee[index], index, collection);
|
2314
|
+
});
|
2315
|
+
return accumulator;
|
2316
|
+
}
|
2317
|
+
|
2318
|
+
/**
|
2319
|
+
* The opposite of `_.filter`, this method returns the values of a
|
2320
|
+
* `collection` that `callback` does **not** return truthy for.
|
2321
|
+
*
|
2322
|
+
* @static
|
2323
|
+
* @memberOf _
|
2324
|
+
* @category Collections
|
2325
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2326
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
2327
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2328
|
+
* @returns {Array} Returns a new array of elements that did **not** pass the
|
2329
|
+
* callback check.
|
2330
|
+
* @example
|
2331
|
+
*
|
2332
|
+
* var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
2333
|
+
* // => [1, 3, 5]
|
2334
|
+
*/
|
2335
|
+
function reject(collection, callback, thisArg) {
|
2336
|
+
callback = createCallback(callback, thisArg);
|
2337
|
+
return filter(collection, function(value, index, collection) {
|
2338
|
+
return !callback(value, index, collection);
|
2339
|
+
});
|
2340
|
+
}
|
2341
|
+
|
2342
|
+
/**
|
2343
|
+
* Creates an array of shuffled `array` values, using a version of the
|
2344
|
+
* Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
|
2345
|
+
*
|
2346
|
+
* @static
|
2347
|
+
* @memberOf _
|
2348
|
+
* @category Collections
|
2349
|
+
* @param {Array|Object|String} collection The collection to shuffle.
|
2350
|
+
* @returns {Array} Returns a new shuffled collection.
|
2351
|
+
* @example
|
2352
|
+
*
|
2353
|
+
* _.shuffle([1, 2, 3, 4, 5, 6]);
|
2354
|
+
* // => [4, 1, 6, 3, 5, 2]
|
2355
|
+
*/
|
2356
|
+
function shuffle(collection) {
|
2357
|
+
var index = -1,
|
2358
|
+
result = Array(collection ? collection.length : 0);
|
2359
|
+
|
2360
|
+
forEach(collection, function(value) {
|
2361
|
+
var rand = floor(nativeRandom() * (++index + 1));
|
2362
|
+
result[index] = result[rand];
|
2363
|
+
result[rand] = value;
|
2364
|
+
});
|
2365
|
+
return result;
|
2366
|
+
}
|
2367
|
+
|
2368
|
+
/**
|
2369
|
+
* Gets the size of the `collection` by returning `collection.length` for arrays
|
2370
|
+
* and array-like objects or the number of own enumerable properties for objects.
|
2371
|
+
*
|
2372
|
+
* @static
|
2373
|
+
* @memberOf _
|
2374
|
+
* @category Collections
|
2375
|
+
* @param {Array|Object|String} collection The collection to inspect.
|
2376
|
+
* @returns {Number} Returns `collection.length` or number of own enumerable properties.
|
2377
|
+
* @example
|
2378
|
+
*
|
2379
|
+
* _.size([1, 2]);
|
2380
|
+
* // => 2
|
2381
|
+
*
|
2382
|
+
* _.size({ 'one': 1, 'two': 2, 'three': 3 });
|
2383
|
+
* // => 3
|
2384
|
+
*
|
2385
|
+
* _.size('curly');
|
2386
|
+
* // => 5
|
2387
|
+
*/
|
2388
|
+
function size(collection) {
|
2389
|
+
var length = collection ? collection.length : 0;
|
2390
|
+
return typeof length == 'number' ? length : keys(collection).length;
|
2391
|
+
}
|
2392
|
+
|
2393
|
+
/**
|
2394
|
+
* Checks if the `callback` returns a truthy value for **any** element of a
|
2395
|
+
* `collection`. The function returns as soon as it finds passing value, and
|
2396
|
+
* does not iterate over the entire `collection`. The `callback` is bound to
|
2397
|
+
* `thisArg` and invoked with three arguments; (value, index|key, collection).
|
2398
|
+
*
|
2399
|
+
* @static
|
2400
|
+
* @memberOf _
|
2401
|
+
* @alias any
|
2402
|
+
* @category Collections
|
2403
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2404
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
2405
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2406
|
+
* @returns {Boolean} Returns `true` if any element passes the callback check,
|
2407
|
+
* else `false`.
|
2408
|
+
* @example
|
2409
|
+
*
|
2410
|
+
* _.some([null, 0, 'yes', false]);
|
2411
|
+
* // => true
|
2412
|
+
*/
|
2413
|
+
function some(collection, callback, thisArg) {
|
2414
|
+
var result;
|
2415
|
+
callback = createCallback(callback, thisArg);
|
2416
|
+
|
2417
|
+
if (isArray(collection)) {
|
2418
|
+
var index = -1,
|
2419
|
+
length = collection.length;
|
2420
|
+
|
2421
|
+
while (++index < length) {
|
2422
|
+
if (result = callback(collection[index], index, collection)) {
|
2423
|
+
break;
|
2424
|
+
}
|
2425
|
+
}
|
2426
|
+
} else {
|
2427
|
+
forEach(collection, function(value, index, collection) {
|
2428
|
+
return !(result = callback(value, index, collection));
|
2429
|
+
});
|
2430
|
+
}
|
2431
|
+
return !!result;
|
2432
|
+
}
|
2433
|
+
|
2434
|
+
/**
|
2435
|
+
* Creates an array, stable sorted in ascending order by the results of
|
2436
|
+
* running each element of `collection` through a `callback`. The `callback`
|
2437
|
+
* is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
2438
|
+
* The `callback` argument may also be the name of a property to sort by (e.g. 'length').
|
2439
|
+
*
|
2440
|
+
* @static
|
2441
|
+
* @memberOf _
|
2442
|
+
* @category Collections
|
2443
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2444
|
+
* @param {Function|String} callback|property The function called per iteration
|
2445
|
+
* or property name to sort by.
|
2446
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2447
|
+
* @returns {Array} Returns a new array of sorted elements.
|
2448
|
+
* @example
|
2449
|
+
*
|
2450
|
+
* _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
|
2451
|
+
* // => [3, 1, 2]
|
2452
|
+
*
|
2453
|
+
* _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
|
2454
|
+
* // => [3, 1, 2]
|
2455
|
+
*
|
2456
|
+
* _.sortBy(['larry', 'brendan', 'moe'], 'length');
|
2457
|
+
* // => ['moe', 'larry', 'brendan']
|
2458
|
+
*/
|
2459
|
+
function sortBy(collection, callback, thisArg) {
|
2460
|
+
var result = [];
|
2461
|
+
callback = createCallback(callback, thisArg);
|
2462
|
+
forEach(collection, function(value, index, collection) {
|
2463
|
+
result.push({
|
2464
|
+
'criteria': callback(value, index, collection),
|
2465
|
+
'index': index,
|
2466
|
+
'value': value
|
2467
|
+
});
|
2468
|
+
});
|
2469
|
+
|
2470
|
+
var length = result.length;
|
2471
|
+
result.sort(compareAscending);
|
2472
|
+
while (length--) {
|
2473
|
+
result[length] = result[length].value;
|
2474
|
+
}
|
2475
|
+
return result;
|
2476
|
+
}
|
2477
|
+
|
2478
|
+
/**
|
2479
|
+
* Converts the `collection`, to an array.
|
2480
|
+
*
|
2481
|
+
* @static
|
2482
|
+
* @memberOf _
|
2483
|
+
* @category Collections
|
2484
|
+
* @param {Array|Object|String} collection The collection to convert.
|
2485
|
+
* @returns {Array} Returns the new converted array.
|
2486
|
+
* @example
|
2487
|
+
*
|
2488
|
+
* (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
2489
|
+
* // => [2, 3, 4]
|
2490
|
+
*/
|
2491
|
+
function toArray(collection) {
|
2492
|
+
if (collection && typeof collection.length == 'number') {
|
2493
|
+
return (noArraySliceOnStrings ? isString(collection) : typeof collection == 'string')
|
2494
|
+
? collection.split('')
|
2495
|
+
: slice.call(collection);
|
2496
|
+
}
|
2497
|
+
return values(collection);
|
2498
|
+
}
|
2499
|
+
|
2500
|
+
/**
|
2501
|
+
* Examines each element in a `collection`, returning an array of all elements
|
2502
|
+
* that contain the given `properties`.
|
2503
|
+
*
|
2504
|
+
* @static
|
2505
|
+
* @memberOf _
|
2506
|
+
* @category Collections
|
2507
|
+
* @param {Array|Object|String} collection The collection to iterate over.
|
2508
|
+
* @param {Object} properties The object of property values to filter by.
|
2509
|
+
* @returns {Array} Returns a new array of elements that contain the given `properties`.
|
2510
|
+
* @example
|
2511
|
+
*
|
2512
|
+
* var stooges = [
|
2513
|
+
* { 'name': 'moe', 'age': 40 },
|
2514
|
+
* { 'name': 'larry', 'age': 50 },
|
2515
|
+
* { 'name': 'curly', 'age': 60 }
|
2516
|
+
* ];
|
2517
|
+
*
|
2518
|
+
* _.where(stooges, { 'age': 40 });
|
2519
|
+
* // => [{ 'name': 'moe', 'age': 40 }]
|
2520
|
+
*/
|
2521
|
+
function where(collection, properties) {
|
2522
|
+
var props = [];
|
2523
|
+
forIn(properties, function(value, prop) {
|
2524
|
+
props.push(prop);
|
2525
|
+
});
|
2526
|
+
return filter(collection, function(object) {
|
2527
|
+
var length = props.length;
|
2528
|
+
while (length--) {
|
2529
|
+
var result = object[props[length]] === properties[props[length]];
|
2530
|
+
if (!result) {
|
2531
|
+
break;
|
2532
|
+
}
|
2533
|
+
}
|
2534
|
+
return !!result;
|
2535
|
+
});
|
2536
|
+
}
|
2537
|
+
|
2538
|
+
/*--------------------------------------------------------------------------*/
|
2539
|
+
|
2540
|
+
/**
|
2541
|
+
* Creates an array with all falsey values of `array` removed. The values
|
2542
|
+
* `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
|
2543
|
+
*
|
2544
|
+
* @static
|
2545
|
+
* @memberOf _
|
2546
|
+
* @category Arrays
|
2547
|
+
* @param {Array} array The array to compact.
|
2548
|
+
* @returns {Array} Returns a new filtered array.
|
2549
|
+
* @example
|
2550
|
+
*
|
2551
|
+
* _.compact([0, 1, false, 2, '', 3]);
|
2552
|
+
* // => [1, 2, 3]
|
2553
|
+
*/
|
2554
|
+
function compact(array) {
|
2555
|
+
var index = -1,
|
2556
|
+
length = array ? array.length : 0,
|
2557
|
+
result = [];
|
2558
|
+
|
2559
|
+
while (++index < length) {
|
2560
|
+
var value = array[index];
|
2561
|
+
if (value) {
|
2562
|
+
result.push(value);
|
2563
|
+
}
|
2564
|
+
}
|
2565
|
+
return result;
|
2566
|
+
}
|
2567
|
+
|
2568
|
+
/**
|
2569
|
+
* Creates an array of `array` elements not present in the other arrays
|
2570
|
+
* using strict equality for comparisons, i.e. `===`.
|
2571
|
+
*
|
2572
|
+
* @static
|
2573
|
+
* @memberOf _
|
2574
|
+
* @category Arrays
|
2575
|
+
* @param {Array} array The array to process.
|
2576
|
+
* @param {Array} [array1, array2, ...] Arrays to check.
|
2577
|
+
* @returns {Array} Returns a new array of `array` elements not present in the
|
2578
|
+
* other arrays.
|
2579
|
+
* @example
|
2580
|
+
*
|
2581
|
+
* _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
2582
|
+
* // => [1, 3, 4]
|
2583
|
+
*/
|
2584
|
+
function difference(array) {
|
2585
|
+
var index = -1,
|
2586
|
+
length = array ? array.length : 0,
|
2587
|
+
flattened = concat.apply(arrayRef, arguments),
|
2588
|
+
contains = cachedContains(flattened, length),
|
2589
|
+
result = [];
|
2590
|
+
|
2591
|
+
while (++index < length) {
|
2592
|
+
var value = array[index];
|
2593
|
+
if (!contains(value)) {
|
2594
|
+
result.push(value);
|
2595
|
+
}
|
2596
|
+
}
|
2597
|
+
return result;
|
2598
|
+
}
|
2599
|
+
|
2600
|
+
/**
|
2601
|
+
* Gets the first element of the `array`. Pass `n` to return the first `n`
|
2602
|
+
* elements of the `array`.
|
2603
|
+
*
|
2604
|
+
* @static
|
2605
|
+
* @memberOf _
|
2606
|
+
* @alias head, take
|
2607
|
+
* @category Arrays
|
2608
|
+
* @param {Array} array The array to query.
|
2609
|
+
* @param {Number} [n] The number of elements to return.
|
2610
|
+
* @param- {Object} [guard] Internally used to allow this method to work with
|
2611
|
+
* others like `_.map` without using their callback `index` argument for `n`.
|
2612
|
+
* @returns {Mixed} Returns the first element or an array of the first `n`
|
2613
|
+
* elements of `array`.
|
2614
|
+
* @example
|
2615
|
+
*
|
2616
|
+
* _.first([5, 4, 3, 2, 1]);
|
2617
|
+
* // => 5
|
2618
|
+
*/
|
2619
|
+
function first(array, n, guard) {
|
2620
|
+
if (array) {
|
2621
|
+
return (n == null || guard) ? array[0] : slice.call(array, 0, n);
|
2622
|
+
}
|
2623
|
+
}
|
2624
|
+
|
2625
|
+
/**
|
2626
|
+
* Flattens a nested array (the nesting can be to any depth). If `shallow` is
|
2627
|
+
* truthy, `array` will only be flattened a single level.
|
2628
|
+
*
|
2629
|
+
* @static
|
2630
|
+
* @memberOf _
|
2631
|
+
* @category Arrays
|
2632
|
+
* @param {Array} array The array to compact.
|
2633
|
+
* @param {Boolean} shallow A flag to indicate only flattening a single level.
|
2634
|
+
* @returns {Array} Returns a new flattened array.
|
2635
|
+
* @example
|
2636
|
+
*
|
2637
|
+
* _.flatten([1, [2], [3, [[4]]]]);
|
2638
|
+
* // => [1, 2, 3, 4];
|
2639
|
+
*
|
2640
|
+
* _.flatten([1, [2], [3, [[4]]]], true);
|
2641
|
+
* // => [1, 2, 3, [[4]]];
|
2642
|
+
*/
|
2643
|
+
function flatten(array, shallow) {
|
2644
|
+
var index = -1,
|
2645
|
+
length = array ? array.length : 0,
|
2646
|
+
result = [];
|
2647
|
+
|
2648
|
+
while (++index < length) {
|
2649
|
+
var value = array[index];
|
2650
|
+
|
2651
|
+
// recursively flatten arrays (susceptible to call stack limits)
|
2652
|
+
if (isArray(value)) {
|
2653
|
+
push.apply(result, shallow ? value : flatten(value));
|
2654
|
+
} else {
|
2655
|
+
result.push(value);
|
2656
|
+
}
|
2657
|
+
}
|
2658
|
+
return result;
|
2659
|
+
}
|
2660
|
+
|
2661
|
+
/**
|
2662
|
+
* Gets the index at which the first occurrence of `value` is found using
|
2663
|
+
* strict equality for comparisons, i.e. `===`. If the `array` is already
|
2664
|
+
* sorted, passing `true` for `fromIndex` will run a faster binary search.
|
2665
|
+
*
|
2666
|
+
* @static
|
2667
|
+
* @memberOf _
|
2668
|
+
* @category Arrays
|
2669
|
+
* @param {Array} array The array to search.
|
2670
|
+
* @param {Mixed} value The value to search for.
|
2671
|
+
* @param {Boolean|Number} [fromIndex=0] The index to search from or `true` to
|
2672
|
+
* perform a binary search on a sorted `array`.
|
2673
|
+
* @returns {Number} Returns the index of the matched value or `-1`.
|
2674
|
+
* @example
|
2675
|
+
*
|
2676
|
+
* _.indexOf([1, 2, 3, 1, 2, 3], 2);
|
2677
|
+
* // => 1
|
2678
|
+
*
|
2679
|
+
* _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
2680
|
+
* // => 4
|
2681
|
+
*
|
2682
|
+
* _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
2683
|
+
* // => 2
|
2684
|
+
*/
|
2685
|
+
function indexOf(array, value, fromIndex) {
|
2686
|
+
var index = -1,
|
2687
|
+
length = array ? array.length : 0;
|
2688
|
+
|
2689
|
+
if (typeof fromIndex == 'number') {
|
2690
|
+
index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1;
|
2691
|
+
} else if (fromIndex) {
|
2692
|
+
index = sortedIndex(array, value);
|
2693
|
+
return array[index] === value ? index : -1;
|
2694
|
+
}
|
2695
|
+
while (++index < length) {
|
2696
|
+
if (array[index] === value) {
|
2697
|
+
return index;
|
2698
|
+
}
|
2699
|
+
}
|
2700
|
+
return -1;
|
2701
|
+
}
|
2702
|
+
|
2703
|
+
/**
|
2704
|
+
* Gets all but the last element of `array`. Pass `n` to exclude the last `n`
|
2705
|
+
* elements from the result.
|
2706
|
+
*
|
2707
|
+
* @static
|
2708
|
+
* @memberOf _
|
2709
|
+
* @category Arrays
|
2710
|
+
* @param {Array} array The array to query.
|
2711
|
+
* @param {Number} [n=1] The number of elements to exclude.
|
2712
|
+
* @param- {Object} [guard] Internally used to allow this method to work with
|
2713
|
+
* others like `_.map` without using their callback `index` argument for `n`.
|
2714
|
+
* @returns {Array} Returns all but the last element or `n` elements of `array`.
|
2715
|
+
* @example
|
2716
|
+
*
|
2717
|
+
* _.initial([3, 2, 1]);
|
2718
|
+
* // => [3, 2]
|
2719
|
+
*/
|
2720
|
+
function initial(array, n, guard) {
|
2721
|
+
return array
|
2722
|
+
? slice.call(array, 0, -((n == null || guard) ? 1 : n))
|
2723
|
+
: [];
|
2724
|
+
}
|
2725
|
+
|
2726
|
+
/**
|
2727
|
+
* Computes the intersection of all the passed-in arrays using strict equality
|
2728
|
+
* for comparisons, i.e. `===`.
|
2729
|
+
*
|
2730
|
+
* @static
|
2731
|
+
* @memberOf _
|
2732
|
+
* @category Arrays
|
2733
|
+
* @param {Array} [array1, array2, ...] Arrays to process.
|
2734
|
+
* @returns {Array} Returns a new array of unique elements, in order, that are
|
2735
|
+
* present in **all** of the arrays.
|
2736
|
+
* @example
|
2737
|
+
*
|
2738
|
+
* _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
2739
|
+
* // => [1, 2]
|
2740
|
+
*/
|
2741
|
+
function intersection(array) {
|
2742
|
+
var args = arguments,
|
2743
|
+
argsLength = args.length,
|
2744
|
+
cache = {},
|
2745
|
+
result = [];
|
2746
|
+
|
2747
|
+
forEach(array, function(value) {
|
2748
|
+
if (indexOf(result, value) < 0) {
|
2749
|
+
var length = argsLength;
|
2750
|
+
while (--length) {
|
2751
|
+
if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) {
|
2752
|
+
return;
|
2753
|
+
}
|
2754
|
+
}
|
2755
|
+
result.push(value);
|
2756
|
+
}
|
2757
|
+
});
|
2758
|
+
return result;
|
2759
|
+
}
|
2760
|
+
|
2761
|
+
/**
|
2762
|
+
* Gets the last element of the `array`. Pass `n` to return the last `n`
|
2763
|
+
* elements of the `array`.
|
2764
|
+
*
|
2765
|
+
* @static
|
2766
|
+
* @memberOf _
|
2767
|
+
* @category Arrays
|
2768
|
+
* @param {Array} array The array to query.
|
2769
|
+
* @param {Number} [n] The number of elements to return.
|
2770
|
+
* @param- {Object} [guard] Internally used to allow this method to work with
|
2771
|
+
* others like `_.map` without using their callback `index` argument for `n`.
|
2772
|
+
* @returns {Mixed} Returns the last element or an array of the last `n`
|
2773
|
+
* elements of `array`.
|
2774
|
+
* @example
|
2775
|
+
*
|
2776
|
+
* _.last([3, 2, 1]);
|
2777
|
+
* // => 1
|
2778
|
+
*/
|
2779
|
+
function last(array, n, guard) {
|
2780
|
+
if (array) {
|
2781
|
+
var length = array.length;
|
2782
|
+
return (n == null || guard) ? array[length - 1] : slice.call(array, -n || length);
|
2783
|
+
}
|
2784
|
+
}
|
2785
|
+
|
2786
|
+
/**
|
2787
|
+
* Gets the index at which the last occurrence of `value` is found using strict
|
2788
|
+
* equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
|
2789
|
+
* as the offset from the end of the collection.
|
2790
|
+
*
|
2791
|
+
* @static
|
2792
|
+
* @memberOf _
|
2793
|
+
* @category Arrays
|
2794
|
+
* @param {Array} array The array to search.
|
2795
|
+
* @param {Mixed} value The value to search for.
|
2796
|
+
* @param {Number} [fromIndex=array.length-1] The index to search from.
|
2797
|
+
* @returns {Number} Returns the index of the matched value or `-1`.
|
2798
|
+
* @example
|
2799
|
+
*
|
2800
|
+
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
|
2801
|
+
* // => 4
|
2802
|
+
*
|
2803
|
+
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
2804
|
+
* // => 1
|
2805
|
+
*/
|
2806
|
+
function lastIndexOf(array, value, fromIndex) {
|
2807
|
+
var index = array ? array.length : 0;
|
2808
|
+
if (typeof fromIndex == 'number') {
|
2809
|
+
index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1;
|
2810
|
+
}
|
2811
|
+
while (index--) {
|
2812
|
+
if (array[index] === value) {
|
2813
|
+
return index;
|
2814
|
+
}
|
2815
|
+
}
|
2816
|
+
return -1;
|
2817
|
+
}
|
2818
|
+
|
2819
|
+
/**
|
2820
|
+
* Creates an object composed from arrays of `keys` and `values`. Pass either
|
2821
|
+
* a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or
|
2822
|
+
* two arrays, one of `keys` and one of corresponding `values`.
|
2823
|
+
*
|
2824
|
+
* @static
|
2825
|
+
* @memberOf _
|
2826
|
+
* @category Arrays
|
2827
|
+
* @param {Array} keys The array of keys.
|
2828
|
+
* @param {Array} [values=[]] The array of values.
|
2829
|
+
* @returns {Object} Returns an object composed of the given keys and
|
2830
|
+
* corresponding values.
|
2831
|
+
* @example
|
2832
|
+
*
|
2833
|
+
* _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
|
2834
|
+
* // => { 'moe': 30, 'larry': 40, 'curly': 50 }
|
2835
|
+
*/
|
2836
|
+
function object(keys, values) {
|
2837
|
+
var index = -1,
|
2838
|
+
length = keys ? keys.length : 0,
|
2839
|
+
result = {};
|
2840
|
+
|
2841
|
+
while (++index < length) {
|
2842
|
+
var key = keys[index];
|
2843
|
+
if (values) {
|
2844
|
+
result[key] = values[index];
|
2845
|
+
} else {
|
2846
|
+
result[key[0]] = key[1];
|
2847
|
+
}
|
2848
|
+
}
|
2849
|
+
return result;
|
2850
|
+
}
|
2851
|
+
|
2852
|
+
/**
|
2853
|
+
* Creates an array of numbers (positive and/or negative) progressing from
|
2854
|
+
* `start` up to but not including `stop`. This method is a port of Python's
|
2855
|
+
* `range()` function. See http://docs.python.org/library/functions.html#range.
|
2856
|
+
*
|
2857
|
+
* @static
|
2858
|
+
* @memberOf _
|
2859
|
+
* @category Arrays
|
2860
|
+
* @param {Number} [start=0] The start of the range.
|
2861
|
+
* @param {Number} end The end of the range.
|
2862
|
+
* @param {Number} [step=1] The value to increment or descrement by.
|
2863
|
+
* @returns {Array} Returns a new range array.
|
2864
|
+
* @example
|
2865
|
+
*
|
2866
|
+
* _.range(10);
|
2867
|
+
* // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
2868
|
+
*
|
2869
|
+
* _.range(1, 11);
|
2870
|
+
* // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
2871
|
+
*
|
2872
|
+
* _.range(0, 30, 5);
|
2873
|
+
* // => [0, 5, 10, 15, 20, 25]
|
2874
|
+
*
|
2875
|
+
* _.range(0, -10, -1);
|
2876
|
+
* // => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
|
2877
|
+
*
|
2878
|
+
* _.range(0);
|
2879
|
+
* // => []
|
2880
|
+
*/
|
2881
|
+
function range(start, end, step) {
|
2882
|
+
start = +start || 0;
|
2883
|
+
step = +step || 1;
|
2884
|
+
|
2885
|
+
if (end == null) {
|
2886
|
+
end = start;
|
2887
|
+
start = 0;
|
2888
|
+
}
|
2889
|
+
// use `Array(length)` so V8 will avoid the slower "dictionary" mode
|
2890
|
+
// http://www.youtube.com/watch?v=XAqIpGU8ZZk#t=16m27s
|
2891
|
+
var index = -1,
|
2892
|
+
length = nativeMax(0, ceil((end - start) / step)),
|
2893
|
+
result = Array(length);
|
2894
|
+
|
2895
|
+
while (++index < length) {
|
2896
|
+
result[index] = start;
|
2897
|
+
start += step;
|
2898
|
+
}
|
2899
|
+
return result;
|
2900
|
+
}
|
2901
|
+
|
2902
|
+
/**
|
2903
|
+
* The opposite of `_.initial`, this method gets all but the first value of
|
2904
|
+
* `array`. Pass `n` to exclude the first `n` values from the result.
|
2905
|
+
*
|
2906
|
+
* @static
|
2907
|
+
* @memberOf _
|
2908
|
+
* @alias drop, tail
|
2909
|
+
* @category Arrays
|
2910
|
+
* @param {Array} array The array to query.
|
2911
|
+
* @param {Number} [n=1] The number of elements to exclude.
|
2912
|
+
* @param- {Object} [guard] Internally used to allow this method to work with
|
2913
|
+
* others like `_.map` without using their callback `index` argument for `n`.
|
2914
|
+
* @returns {Array} Returns all but the first value or `n` values of `array`.
|
2915
|
+
* @example
|
2916
|
+
*
|
2917
|
+
* _.rest([3, 2, 1]);
|
2918
|
+
* // => [2, 1]
|
2919
|
+
*/
|
2920
|
+
function rest(array, n, guard) {
|
2921
|
+
return array
|
2922
|
+
? slice.call(array, (n == null || guard) ? 1 : n)
|
2923
|
+
: [];
|
2924
|
+
}
|
2925
|
+
|
2926
|
+
/**
|
2927
|
+
* Uses a binary search to determine the smallest index at which the `value`
|
2928
|
+
* should be inserted into `array` in order to maintain the sort order of the
|
2929
|
+
* sorted `array`. If `callback` is passed, it will be executed for `value` and
|
2930
|
+
* each element in `array` to compute their sort ranking. The `callback` is
|
2931
|
+
* bound to `thisArg` and invoked with one argument; (value). The `callback`
|
2932
|
+
* argument may also be the name of a property to order by.
|
2933
|
+
*
|
2934
|
+
* @static
|
2935
|
+
* @memberOf _
|
2936
|
+
* @category Arrays
|
2937
|
+
* @param {Array} array The array to iterate over.
|
2938
|
+
* @param {Mixed} value The value to evaluate.
|
2939
|
+
* @param {Function|String} [callback=identity|property] The function called
|
2940
|
+
* per iteration or property name to order by.
|
2941
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
2942
|
+
* @returns {Number} Returns the index at which the value should be inserted
|
2943
|
+
* into `array`.
|
2944
|
+
* @example
|
2945
|
+
*
|
2946
|
+
* _.sortedIndex([20, 30, 50], 40);
|
2947
|
+
* // => 2
|
2948
|
+
*
|
2949
|
+
* _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
2950
|
+
* // => 2
|
2951
|
+
*
|
2952
|
+
* var dict = {
|
2953
|
+
* 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
|
2954
|
+
* };
|
2955
|
+
*
|
2956
|
+
* _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
|
2957
|
+
* return dict.wordToNumber[word];
|
2958
|
+
* });
|
2959
|
+
* // => 2
|
2960
|
+
*
|
2961
|
+
* _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
|
2962
|
+
* return this.wordToNumber[word];
|
2963
|
+
* }, dict);
|
2964
|
+
* // => 2
|
2965
|
+
*/
|
2966
|
+
function sortedIndex(array, value, callback, thisArg) {
|
2967
|
+
var low = 0,
|
2968
|
+
high = array ? array.length : low;
|
2969
|
+
|
2970
|
+
// explicitly reference `identity` for better engine inlining
|
2971
|
+
callback = callback ? createCallback(callback, thisArg) : identity;
|
2972
|
+
value = callback(value);
|
2973
|
+
while (low < high) {
|
2974
|
+
var mid = (low + high) >>> 1;
|
2975
|
+
callback(array[mid]) < value
|
2976
|
+
? low = mid + 1
|
2977
|
+
: high = mid;
|
2978
|
+
}
|
2979
|
+
return low;
|
2980
|
+
}
|
2981
|
+
|
2982
|
+
/**
|
2983
|
+
* Computes the union of the passed-in arrays using strict equality for
|
2984
|
+
* comparisons, i.e. `===`.
|
2985
|
+
*
|
2986
|
+
* @static
|
2987
|
+
* @memberOf _
|
2988
|
+
* @category Arrays
|
2989
|
+
* @param {Array} [array1, array2, ...] Arrays to process.
|
2990
|
+
* @returns {Array} Returns a new array of unique values, in order, that are
|
2991
|
+
* present in one or more of the arrays.
|
2992
|
+
* @example
|
2993
|
+
*
|
2994
|
+
* _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
2995
|
+
* // => [1, 2, 3, 101, 10]
|
2996
|
+
*/
|
2997
|
+
function union() {
|
2998
|
+
return uniq(concat.apply(arrayRef, arguments));
|
2999
|
+
}
|
3000
|
+
|
3001
|
+
/**
|
3002
|
+
* Creates a duplicate-value-free version of the `array` using strict equality
|
3003
|
+
* for comparisons, i.e. `===`. If the `array` is already sorted, passing `true`
|
3004
|
+
* for `isSorted` will run a faster algorithm. If `callback` is passed, each
|
3005
|
+
* element of `array` is passed through a callback` before uniqueness is computed.
|
3006
|
+
* The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array).
|
3007
|
+
*
|
3008
|
+
* @static
|
3009
|
+
* @memberOf _
|
3010
|
+
* @alias unique
|
3011
|
+
* @category Arrays
|
3012
|
+
* @param {Array} array The array to process.
|
3013
|
+
* @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted.
|
3014
|
+
* @param {Function} [callback=identity] The function called per iteration.
|
3015
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
3016
|
+
* @returns {Array} Returns a duplicate-value-free array.
|
3017
|
+
* @example
|
3018
|
+
*
|
3019
|
+
* _.uniq([1, 2, 1, 3, 1]);
|
3020
|
+
* // => [1, 2, 3]
|
3021
|
+
*
|
3022
|
+
* _.uniq([1, 1, 2, 2, 3], true);
|
3023
|
+
* // => [1, 2, 3]
|
3024
|
+
*
|
3025
|
+
* _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); });
|
3026
|
+
* // => [1, 2, 3]
|
3027
|
+
*
|
3028
|
+
* _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
|
3029
|
+
* // => [1, 2, 3]
|
3030
|
+
*/
|
3031
|
+
function uniq(array, isSorted, callback, thisArg) {
|
3032
|
+
var index = -1,
|
3033
|
+
length = array ? array.length : 0,
|
3034
|
+
result = [],
|
3035
|
+
seen = result;
|
3036
|
+
|
3037
|
+
// juggle arguments
|
3038
|
+
if (typeof isSorted == 'function') {
|
3039
|
+
thisArg = callback;
|
3040
|
+
callback = isSorted;
|
3041
|
+
isSorted = false;
|
3042
|
+
}
|
3043
|
+
// init value cache for large arrays
|
3044
|
+
var isLarge = !isSorted && length > 74;
|
3045
|
+
if (isLarge) {
|
3046
|
+
var cache = {};
|
3047
|
+
}
|
3048
|
+
if (callback) {
|
3049
|
+
seen = [];
|
3050
|
+
callback = createCallback(callback, thisArg);
|
3051
|
+
}
|
3052
|
+
while (++index < length) {
|
3053
|
+
var value = array[index],
|
3054
|
+
computed = callback ? callback(value, index, array) : value;
|
3055
|
+
|
3056
|
+
if (isLarge) {
|
3057
|
+
// manually coerce `computed` to a string because `hasOwnProperty`, in
|
3058
|
+
// some older versions of Firefox, coerces objects incorrectly
|
3059
|
+
seen = hasOwnProperty.call(cache, computed + '') ? cache[computed] : (cache[computed] = []);
|
3060
|
+
}
|
3061
|
+
if (isSorted
|
3062
|
+
? !index || seen[seen.length - 1] !== computed
|
3063
|
+
: indexOf(seen, computed) < 0
|
3064
|
+
) {
|
3065
|
+
if (callback || isLarge) {
|
3066
|
+
seen.push(computed);
|
3067
|
+
}
|
3068
|
+
result.push(value);
|
3069
|
+
}
|
3070
|
+
}
|
3071
|
+
return result;
|
3072
|
+
}
|
3073
|
+
|
3074
|
+
/**
|
3075
|
+
* Creates an array with all occurrences of the passed values removed using
|
3076
|
+
* strict equality for comparisons, i.e. `===`.
|
3077
|
+
*
|
3078
|
+
* @static
|
3079
|
+
* @memberOf _
|
3080
|
+
* @category Arrays
|
3081
|
+
* @param {Array} array The array to filter.
|
3082
|
+
* @param {Mixed} [value1, value2, ...] Values to remove.
|
3083
|
+
* @returns {Array} Returns a new filtered array.
|
3084
|
+
* @example
|
3085
|
+
*
|
3086
|
+
* _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
3087
|
+
* // => [2, 3, 4]
|
3088
|
+
*/
|
3089
|
+
function without(array) {
|
3090
|
+
var index = -1,
|
3091
|
+
length = array ? array.length : 0,
|
3092
|
+
contains = cachedContains(arguments, 1, 20),
|
3093
|
+
result = [];
|
3094
|
+
|
3095
|
+
while (++index < length) {
|
3096
|
+
var value = array[index];
|
3097
|
+
if (!contains(value)) {
|
3098
|
+
result.push(value);
|
3099
|
+
}
|
3100
|
+
}
|
3101
|
+
return result;
|
3102
|
+
}
|
3103
|
+
|
3104
|
+
/**
|
3105
|
+
* Groups the elements of each array at their corresponding indexes. Useful for
|
3106
|
+
* separate data sources that are coordinated through matching array indexes.
|
3107
|
+
* For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix
|
3108
|
+
* in a similar fashion.
|
3109
|
+
*
|
3110
|
+
* @static
|
3111
|
+
* @memberOf _
|
3112
|
+
* @category Arrays
|
3113
|
+
* @param {Array} [array1, array2, ...] Arrays to process.
|
3114
|
+
* @returns {Array} Returns a new array of grouped elements.
|
3115
|
+
* @example
|
3116
|
+
*
|
3117
|
+
* _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
3118
|
+
* // => [['moe', 30, true], ['larry', 40, false], ['curly', 50, false]]
|
3119
|
+
*/
|
3120
|
+
function zip(array) {
|
3121
|
+
var index = -1,
|
3122
|
+
length = array ? max(pluck(arguments, 'length')) : 0,
|
3123
|
+
result = Array(length);
|
3124
|
+
|
3125
|
+
while (++index < length) {
|
3126
|
+
result[index] = pluck(arguments, index);
|
3127
|
+
}
|
3128
|
+
return result;
|
3129
|
+
}
|
3130
|
+
|
3131
|
+
/*--------------------------------------------------------------------------*/
|
3132
|
+
|
3133
|
+
/**
|
3134
|
+
* Creates a function that is restricted to executing `func` only after it is
|
3135
|
+
* called `n` times. The `func` is executed with the `this` binding of the
|
3136
|
+
* created function.
|
3137
|
+
*
|
3138
|
+
* @static
|
3139
|
+
* @memberOf _
|
3140
|
+
* @category Functions
|
3141
|
+
* @param {Number} n The number of times the function must be called before
|
3142
|
+
* it is executed.
|
3143
|
+
* @param {Function} func The function to restrict.
|
3144
|
+
* @returns {Function} Returns the new restricted function.
|
3145
|
+
* @example
|
3146
|
+
*
|
3147
|
+
* var renderNotes = _.after(notes.length, render);
|
3148
|
+
* _.forEach(notes, function(note) {
|
3149
|
+
* note.asyncSave({ 'success': renderNotes });
|
3150
|
+
* });
|
3151
|
+
* // `renderNotes` is run once, after all notes have saved
|
3152
|
+
*/
|
3153
|
+
function after(n, func) {
|
3154
|
+
if (n < 1) {
|
3155
|
+
return func();
|
3156
|
+
}
|
3157
|
+
return function() {
|
3158
|
+
if (--n < 1) {
|
3159
|
+
return func.apply(this, arguments);
|
3160
|
+
}
|
3161
|
+
};
|
3162
|
+
}
|
3163
|
+
|
3164
|
+
/**
|
3165
|
+
* Creates a function that, when called, invokes `func` with the `this`
|
3166
|
+
* binding of `thisArg` and prepends any additional `bind` arguments to those
|
3167
|
+
* passed to the bound function.
|
3168
|
+
*
|
3169
|
+
* @static
|
3170
|
+
* @memberOf _
|
3171
|
+
* @category Functions
|
3172
|
+
* @param {Function} func The function to bind.
|
3173
|
+
* @param {Mixed} [thisArg] The `this` binding of `func`.
|
3174
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
|
3175
|
+
* @returns {Function} Returns the new bound function.
|
3176
|
+
* @example
|
3177
|
+
*
|
3178
|
+
* var func = function(greeting) {
|
3179
|
+
* return greeting + ' ' + this.name;
|
3180
|
+
* };
|
3181
|
+
*
|
3182
|
+
* func = _.bind(func, { 'name': 'moe' }, 'hi');
|
3183
|
+
* func();
|
3184
|
+
* // => 'hi moe'
|
3185
|
+
*/
|
3186
|
+
function bind(func, thisArg) {
|
3187
|
+
// use `Function#bind` if it exists and is fast
|
3188
|
+
// (in V8 `Function#bind` is slower except when partially applied)
|
3189
|
+
return isBindFast || (nativeBind && arguments.length > 2)
|
3190
|
+
? nativeBind.call.apply(nativeBind, arguments)
|
3191
|
+
: createBound(func, thisArg, slice.call(arguments, 2));
|
3192
|
+
}
|
3193
|
+
|
3194
|
+
/**
|
3195
|
+
* Binds methods on `object` to `object`, overwriting the existing method.
|
3196
|
+
* If no method names are provided, all the function properties of `object`
|
3197
|
+
* will be bound.
|
3198
|
+
*
|
3199
|
+
* @static
|
3200
|
+
* @memberOf _
|
3201
|
+
* @category Functions
|
3202
|
+
* @param {Object} object The object to bind and assign the bound methods to.
|
3203
|
+
* @param {String} [methodName1, methodName2, ...] Method names on the object to bind.
|
3204
|
+
* @returns {Object} Returns `object`.
|
3205
|
+
* @example
|
3206
|
+
*
|
3207
|
+
* var buttonView = {
|
3208
|
+
* 'label': 'lodash',
|
3209
|
+
* 'onClick': function() { alert('clicked: ' + this.label); }
|
3210
|
+
* };
|
3211
|
+
*
|
3212
|
+
* _.bindAll(buttonView);
|
3213
|
+
* jQuery('#lodash_button').on('click', buttonView.onClick);
|
3214
|
+
* // => When the button is clicked, `this.label` will have the correct value
|
3215
|
+
*/
|
3216
|
+
function bindAll(object) {
|
3217
|
+
var funcs = arguments,
|
3218
|
+
index = funcs.length > 1 ? 0 : (funcs = functions(object), -1),
|
3219
|
+
length = funcs.length;
|
3220
|
+
|
3221
|
+
while (++index < length) {
|
3222
|
+
var key = funcs[index];
|
3223
|
+
object[key] = bind(object[key], object);
|
3224
|
+
}
|
3225
|
+
return object;
|
3226
|
+
}
|
3227
|
+
|
3228
|
+
/**
|
3229
|
+
* Creates a function that is the composition of the passed functions,
|
3230
|
+
* where each function consumes the return value of the function that follows.
|
3231
|
+
* In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
|
3232
|
+
* Each function is executed with the `this` binding of the composed function.
|
3233
|
+
*
|
3234
|
+
* @static
|
3235
|
+
* @memberOf _
|
3236
|
+
* @category Functions
|
3237
|
+
* @param {Function} [func1, func2, ...] Functions to compose.
|
3238
|
+
* @returns {Function} Returns the new composed function.
|
3239
|
+
* @example
|
3240
|
+
*
|
3241
|
+
* var greet = function(name) { return 'hi: ' + name; };
|
3242
|
+
* var exclaim = function(statement) { return statement + '!'; };
|
3243
|
+
* var welcome = _.compose(exclaim, greet);
|
3244
|
+
* welcome('moe');
|
3245
|
+
* // => 'hi: moe!'
|
3246
|
+
*/
|
3247
|
+
function compose() {
|
3248
|
+
var funcs = arguments;
|
3249
|
+
return function() {
|
3250
|
+
var args = arguments,
|
3251
|
+
length = funcs.length;
|
3252
|
+
|
3253
|
+
while (length--) {
|
3254
|
+
args = [funcs[length].apply(this, args)];
|
3255
|
+
}
|
3256
|
+
return args[0];
|
3257
|
+
};
|
3258
|
+
}
|
3259
|
+
|
3260
|
+
/**
|
3261
|
+
* Creates a function that will delay the execution of `func` until after
|
3262
|
+
* `wait` milliseconds have elapsed since the last time it was invoked. Pass
|
3263
|
+
* `true` for `immediate` to cause debounce to invoke `func` on the leading,
|
3264
|
+
* instead of the trailing, edge of the `wait` timeout. Subsequent calls to
|
3265
|
+
* the debounced function will return the result of the last `func` call.
|
3266
|
+
*
|
3267
|
+
* @static
|
3268
|
+
* @memberOf _
|
3269
|
+
* @category Functions
|
3270
|
+
* @param {Function} func The function to debounce.
|
3271
|
+
* @param {Number} wait The number of milliseconds to delay.
|
3272
|
+
* @param {Boolean} immediate A flag to indicate execution is on the leading
|
3273
|
+
* edge of the timeout.
|
3274
|
+
* @returns {Function} Returns the new debounced function.
|
3275
|
+
* @example
|
3276
|
+
*
|
3277
|
+
* var lazyLayout = _.debounce(calculateLayout, 300);
|
3278
|
+
* jQuery(window).on('resize', lazyLayout);
|
3279
|
+
*/
|
3280
|
+
function debounce(func, wait, immediate) {
|
3281
|
+
var args,
|
3282
|
+
result,
|
3283
|
+
thisArg,
|
3284
|
+
timeoutId;
|
3285
|
+
|
3286
|
+
function delayed() {
|
3287
|
+
timeoutId = null;
|
3288
|
+
if (!immediate) {
|
3289
|
+
result = func.apply(thisArg, args);
|
3290
|
+
}
|
3291
|
+
}
|
3292
|
+
return function() {
|
3293
|
+
var isImmediate = immediate && !timeoutId;
|
3294
|
+
args = arguments;
|
3295
|
+
thisArg = this;
|
3296
|
+
|
3297
|
+
clearTimeout(timeoutId);
|
3298
|
+
timeoutId = setTimeout(delayed, wait);
|
3299
|
+
|
3300
|
+
if (isImmediate) {
|
3301
|
+
result = func.apply(thisArg, args);
|
3302
|
+
}
|
3303
|
+
return result;
|
3304
|
+
};
|
3305
|
+
}
|
3306
|
+
|
3307
|
+
/**
|
3308
|
+
* Executes the `func` function after `wait` milliseconds. Additional arguments
|
3309
|
+
* will be passed to `func` when it is invoked.
|
3310
|
+
*
|
3311
|
+
* @static
|
3312
|
+
* @memberOf _
|
3313
|
+
* @category Functions
|
3314
|
+
* @param {Function} func The function to delay.
|
3315
|
+
* @param {Number} wait The number of milliseconds to delay execution.
|
3316
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
|
3317
|
+
* @returns {Number} Returns the `setTimeout` timeout id.
|
3318
|
+
* @example
|
3319
|
+
*
|
3320
|
+
* var log = _.bind(console.log, console);
|
3321
|
+
* _.delay(log, 1000, 'logged later');
|
3322
|
+
* // => 'logged later' (Appears after one second.)
|
3323
|
+
*/
|
3324
|
+
function delay(func, wait) {
|
3325
|
+
var args = slice.call(arguments, 2);
|
3326
|
+
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
3327
|
+
}
|
3328
|
+
|
3329
|
+
/**
|
3330
|
+
* Defers executing the `func` function until the current call stack has cleared.
|
3331
|
+
* Additional arguments will be passed to `func` when it is invoked.
|
3332
|
+
*
|
3333
|
+
* @static
|
3334
|
+
* @memberOf _
|
3335
|
+
* @category Functions
|
3336
|
+
* @param {Function} func The function to defer.
|
3337
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
|
3338
|
+
* @returns {Number} Returns the `setTimeout` timeout id.
|
3339
|
+
* @example
|
3340
|
+
*
|
3341
|
+
* _.defer(function() { alert('deferred'); });
|
3342
|
+
* // returns from the function before `alert` is called
|
3343
|
+
*/
|
3344
|
+
function defer(func) {
|
3345
|
+
var args = slice.call(arguments, 1);
|
3346
|
+
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
3347
|
+
}
|
3348
|
+
|
3349
|
+
/**
|
3350
|
+
* Creates a function that, when called, invokes `object[methodName]` and
|
3351
|
+
* prepends any additional `lateBind` arguments to those passed to the bound
|
3352
|
+
* function. This method differs from `_.bind` by allowing bound functions to
|
3353
|
+
* reference methods that will be redefined or don't yet exist.
|
3354
|
+
*
|
3355
|
+
* @static
|
3356
|
+
* @memberOf _
|
3357
|
+
* @category Functions
|
3358
|
+
* @param {Object} object The object the method belongs to.
|
3359
|
+
* @param {String} methodName The method name.
|
3360
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
|
3361
|
+
* @returns {Function} Returns the new bound function.
|
3362
|
+
* @example
|
3363
|
+
*
|
3364
|
+
* var object = {
|
3365
|
+
* 'name': 'moe',
|
3366
|
+
* 'greet': function(greeting) {
|
3367
|
+
* return greeting + ' ' + this.name;
|
3368
|
+
* }
|
3369
|
+
* };
|
3370
|
+
*
|
3371
|
+
* var func = _.lateBind(object, 'greet', 'hi');
|
3372
|
+
* func();
|
3373
|
+
* // => 'hi moe'
|
3374
|
+
*
|
3375
|
+
* object.greet = function(greeting) {
|
3376
|
+
* return greeting + ', ' + this.name + '!';
|
3377
|
+
* };
|
3378
|
+
*
|
3379
|
+
* func();
|
3380
|
+
* // => 'hi, moe!'
|
3381
|
+
*/
|
3382
|
+
function lateBind(object, methodName) {
|
3383
|
+
return createBound(methodName, object, slice.call(arguments, 2));
|
3384
|
+
}
|
3385
|
+
|
3386
|
+
/**
|
3387
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
3388
|
+
* passed, it will be used to determine the cache key for storing the result
|
3389
|
+
* based on the arguments passed to the memoized function. By default, the first
|
3390
|
+
* argument passed to the memoized function is used as the cache key. The `func`
|
3391
|
+
* is executed with the `this` binding of the memoized function.
|
3392
|
+
*
|
3393
|
+
* @static
|
3394
|
+
* @memberOf _
|
3395
|
+
* @category Functions
|
3396
|
+
* @param {Function} func The function to have its output memoized.
|
3397
|
+
* @param {Function} [resolver] A function used to resolve the cache key.
|
3398
|
+
* @returns {Function} Returns the new memoizing function.
|
3399
|
+
* @example
|
3400
|
+
*
|
3401
|
+
* var fibonacci = _.memoize(function(n) {
|
3402
|
+
* return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
3403
|
+
* });
|
3404
|
+
*/
|
3405
|
+
function memoize(func, resolver) {
|
3406
|
+
var cache = {};
|
3407
|
+
return function() {
|
3408
|
+
var key = resolver ? resolver.apply(this, arguments) : arguments[0];
|
3409
|
+
return hasOwnProperty.call(cache, key)
|
3410
|
+
? cache[key]
|
3411
|
+
: (cache[key] = func.apply(this, arguments));
|
3412
|
+
};
|
3413
|
+
}
|
3414
|
+
|
3415
|
+
/**
|
3416
|
+
* Creates a function that is restricted to execute `func` once. Repeat calls to
|
3417
|
+
* the function will return the value of the first call. The `func` is executed
|
3418
|
+
* with the `this` binding of the created function.
|
3419
|
+
*
|
3420
|
+
* @static
|
3421
|
+
* @memberOf _
|
3422
|
+
* @category Functions
|
3423
|
+
* @param {Function} func The function to restrict.
|
3424
|
+
* @returns {Function} Returns the new restricted function.
|
3425
|
+
* @example
|
3426
|
+
*
|
3427
|
+
* var initialize = _.once(createApplication);
|
3428
|
+
* initialize();
|
3429
|
+
* initialize();
|
3430
|
+
* // Application is only created once.
|
3431
|
+
*/
|
3432
|
+
function once(func) {
|
3433
|
+
var result,
|
3434
|
+
ran = false;
|
3435
|
+
|
3436
|
+
return function() {
|
3437
|
+
if (ran) {
|
3438
|
+
return result;
|
3439
|
+
}
|
3440
|
+
ran = true;
|
3441
|
+
result = func.apply(this, arguments);
|
3442
|
+
|
3443
|
+
// clear the `func` variable so the function may be garbage collected
|
3444
|
+
func = null;
|
3445
|
+
return result;
|
3446
|
+
};
|
3447
|
+
}
|
3448
|
+
|
3449
|
+
/**
|
3450
|
+
* Creates a function that, when called, invokes `func` with any additional
|
3451
|
+
* `partial` arguments prepended to those passed to the new function. This
|
3452
|
+
* method is similar to `bind`, except it does **not** alter the `this` binding.
|
3453
|
+
*
|
3454
|
+
* @static
|
3455
|
+
* @memberOf _
|
3456
|
+
* @category Functions
|
3457
|
+
* @param {Function} func The function to partially apply arguments to.
|
3458
|
+
* @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
|
3459
|
+
* @returns {Function} Returns the new partially applied function.
|
3460
|
+
* @example
|
3461
|
+
*
|
3462
|
+
* var greet = function(greeting, name) { return greeting + ': ' + name; };
|
3463
|
+
* var hi = _.partial(greet, 'hi');
|
3464
|
+
* hi('moe');
|
3465
|
+
* // => 'hi: moe'
|
3466
|
+
*/
|
3467
|
+
function partial(func) {
|
3468
|
+
return createBound(func, slice.call(arguments, 1));
|
3469
|
+
}
|
3470
|
+
|
3471
|
+
/**
|
3472
|
+
* Creates a function that, when executed, will only call the `func`
|
3473
|
+
* function at most once per every `wait` milliseconds. If the throttled
|
3474
|
+
* function is invoked more than once during the `wait` timeout, `func` will
|
3475
|
+
* also be called on the trailing edge of the timeout. Subsequent calls to the
|
3476
|
+
* throttled function will return the result of the last `func` call.
|
3477
|
+
*
|
3478
|
+
* @static
|
3479
|
+
* @memberOf _
|
3480
|
+
* @category Functions
|
3481
|
+
* @param {Function} func The function to throttle.
|
3482
|
+
* @param {Number} wait The number of milliseconds to throttle executions to.
|
3483
|
+
* @returns {Function} Returns the new throttled function.
|
3484
|
+
* @example
|
3485
|
+
*
|
3486
|
+
* var throttled = _.throttle(updatePosition, 100);
|
3487
|
+
* jQuery(window).on('scroll', throttled);
|
3488
|
+
*/
|
3489
|
+
function throttle(func, wait) {
|
3490
|
+
var args,
|
3491
|
+
result,
|
3492
|
+
thisArg,
|
3493
|
+
timeoutId,
|
3494
|
+
lastCalled = 0;
|
3495
|
+
|
3496
|
+
function trailingCall() {
|
3497
|
+
lastCalled = new Date;
|
3498
|
+
timeoutId = null;
|
3499
|
+
result = func.apply(thisArg, args);
|
3500
|
+
}
|
3501
|
+
return function() {
|
3502
|
+
var now = new Date,
|
3503
|
+
remaining = wait - (now - lastCalled);
|
3504
|
+
|
3505
|
+
args = arguments;
|
3506
|
+
thisArg = this;
|
3507
|
+
|
3508
|
+
if (remaining <= 0) {
|
3509
|
+
clearTimeout(timeoutId);
|
3510
|
+
lastCalled = now;
|
3511
|
+
result = func.apply(thisArg, args);
|
3512
|
+
}
|
3513
|
+
else if (!timeoutId) {
|
3514
|
+
timeoutId = setTimeout(trailingCall, remaining);
|
3515
|
+
}
|
3516
|
+
return result;
|
3517
|
+
};
|
3518
|
+
}
|
3519
|
+
|
3520
|
+
/**
|
3521
|
+
* Creates a function that passes `value` to the `wrapper` function as its
|
3522
|
+
* first argument. Additional arguments passed to the function are appended
|
3523
|
+
* to those passed to the `wrapper` function. The `wrapper` is executed with
|
3524
|
+
* the `this` binding of the created function.
|
3525
|
+
*
|
3526
|
+
* @static
|
3527
|
+
* @memberOf _
|
3528
|
+
* @category Functions
|
3529
|
+
* @param {Mixed} value The value to wrap.
|
3530
|
+
* @param {Function} wrapper The wrapper function.
|
3531
|
+
* @returns {Function} Returns the new function.
|
3532
|
+
* @example
|
3533
|
+
*
|
3534
|
+
* var hello = function(name) { return 'hello ' + name; };
|
3535
|
+
* hello = _.wrap(hello, function(func) {
|
3536
|
+
* return 'before, ' + func('moe') + ', after';
|
3537
|
+
* });
|
3538
|
+
* hello();
|
3539
|
+
* // => 'before, hello moe, after'
|
3540
|
+
*/
|
3541
|
+
function wrap(value, wrapper) {
|
3542
|
+
return function() {
|
3543
|
+
var args = [value];
|
3544
|
+
push.apply(args, arguments);
|
3545
|
+
return wrapper.apply(this, args);
|
3546
|
+
};
|
3547
|
+
}
|
3548
|
+
|
3549
|
+
/*--------------------------------------------------------------------------*/
|
3550
|
+
|
3551
|
+
/**
|
3552
|
+
* Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
|
3553
|
+
* corresponding HTML entities.
|
3554
|
+
*
|
3555
|
+
* @static
|
3556
|
+
* @memberOf _
|
3557
|
+
* @category Utilities
|
3558
|
+
* @param {String} string The string to escape.
|
3559
|
+
* @returns {String} Returns the escaped string.
|
3560
|
+
* @example
|
3561
|
+
*
|
3562
|
+
* _.escape('Moe, Larry & Curly');
|
3563
|
+
* // => "Moe, Larry & Curly"
|
3564
|
+
*/
|
3565
|
+
function escape(string) {
|
3566
|
+
return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar);
|
3567
|
+
}
|
3568
|
+
|
3569
|
+
/**
|
3570
|
+
* This function returns the first argument passed to it.
|
3571
|
+
*
|
3572
|
+
* Note: It is used throughout Lo-Dash as a default callback.
|
3573
|
+
*
|
3574
|
+
* @static
|
3575
|
+
* @memberOf _
|
3576
|
+
* @category Utilities
|
3577
|
+
* @param {Mixed} value Any value.
|
3578
|
+
* @returns {Mixed} Returns `value`.
|
3579
|
+
* @example
|
3580
|
+
*
|
3581
|
+
* var moe = { 'name': 'moe' };
|
3582
|
+
* moe === _.identity(moe);
|
3583
|
+
* // => true
|
3584
|
+
*/
|
3585
|
+
function identity(value) {
|
3586
|
+
return value;
|
3587
|
+
}
|
3588
|
+
|
3589
|
+
/**
|
3590
|
+
* Adds functions properties of `object` to the `lodash` function and chainable
|
3591
|
+
* wrapper.
|
3592
|
+
*
|
3593
|
+
* @static
|
3594
|
+
* @memberOf _
|
3595
|
+
* @category Utilities
|
3596
|
+
* @param {Object} object The object of function properties to add to `lodash`.
|
3597
|
+
* @example
|
3598
|
+
*
|
3599
|
+
* _.mixin({
|
3600
|
+
* 'capitalize': function(string) {
|
3601
|
+
* return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
3602
|
+
* }
|
3603
|
+
* });
|
3604
|
+
*
|
3605
|
+
* _.capitalize('larry');
|
3606
|
+
* // => 'Larry'
|
3607
|
+
*
|
3608
|
+
* _('curly').capitalize();
|
3609
|
+
* // => 'Curly'
|
3610
|
+
*/
|
3611
|
+
function mixin(object) {
|
3612
|
+
forEach(functions(object), function(methodName) {
|
3613
|
+
var func = lodash[methodName] = object[methodName];
|
3614
|
+
|
3615
|
+
lodash.prototype[methodName] = function() {
|
3616
|
+
var args = [this.__wrapped__];
|
3617
|
+
push.apply(args, arguments);
|
3618
|
+
|
3619
|
+
var result = func.apply(lodash, args);
|
3620
|
+
if (this.__chain__) {
|
3621
|
+
result = new lodash(result);
|
3622
|
+
result.__chain__ = true;
|
3623
|
+
}
|
3624
|
+
return result;
|
3625
|
+
};
|
3626
|
+
});
|
3627
|
+
}
|
3628
|
+
|
3629
|
+
/**
|
3630
|
+
* Reverts the '_' variable to its previous value and returns a reference to
|
3631
|
+
* the `lodash` function.
|
3632
|
+
*
|
3633
|
+
* @static
|
3634
|
+
* @memberOf _
|
3635
|
+
* @category Utilities
|
3636
|
+
* @returns {Function} Returns the `lodash` function.
|
3637
|
+
* @example
|
3638
|
+
*
|
3639
|
+
* var lodash = _.noConflict();
|
3640
|
+
*/
|
3641
|
+
function noConflict() {
|
3642
|
+
window._ = oldDash;
|
3643
|
+
return this;
|
3644
|
+
}
|
3645
|
+
|
3646
|
+
/**
|
3647
|
+
* Produces a random number between `min` and `max` (inclusive). If only one
|
3648
|
+
* argument is passed, a number between `0` and the given number will be returned.
|
3649
|
+
*
|
3650
|
+
* @static
|
3651
|
+
* @memberOf _
|
3652
|
+
* @category Utilities
|
3653
|
+
* @param {Number} [min=0] The minimum possible value.
|
3654
|
+
* @param {Number} [max=1] The maximum possible value.
|
3655
|
+
* @returns {Number} Returns a random number.
|
3656
|
+
* @example
|
3657
|
+
*
|
3658
|
+
* _.random(0, 5);
|
3659
|
+
* // => a number between 1 and 5
|
3660
|
+
*
|
3661
|
+
* _.random(5);
|
3662
|
+
* // => also a number between 1 and 5
|
3663
|
+
*/
|
3664
|
+
function random(min, max) {
|
3665
|
+
if (min == null && max == null) {
|
3666
|
+
max = 1;
|
3667
|
+
}
|
3668
|
+
min = +min || 0;
|
3669
|
+
if (max == null) {
|
3670
|
+
max = min;
|
3671
|
+
min = 0;
|
3672
|
+
}
|
3673
|
+
return min + floor(nativeRandom() * ((+max || 0) - min + 1));
|
3674
|
+
}
|
3675
|
+
|
3676
|
+
/**
|
3677
|
+
* Resolves the value of `property` on `object`. If `property` is a function
|
3678
|
+
* it will be invoked and its result returned, else the property value is
|
3679
|
+
* returned. If `object` is falsey, then `null` is returned.
|
3680
|
+
*
|
3681
|
+
* @deprecated
|
3682
|
+
* @static
|
3683
|
+
* @memberOf _
|
3684
|
+
* @category Utilities
|
3685
|
+
* @param {Object} object The object to inspect.
|
3686
|
+
* @param {String} property The property to get the value of.
|
3687
|
+
* @returns {Mixed} Returns the resolved value.
|
3688
|
+
* @example
|
3689
|
+
*
|
3690
|
+
* var object = {
|
3691
|
+
* 'cheese': 'crumpets',
|
3692
|
+
* 'stuff': function() {
|
3693
|
+
* return 'nonsense';
|
3694
|
+
* }
|
3695
|
+
* };
|
3696
|
+
*
|
3697
|
+
* _.result(object, 'cheese');
|
3698
|
+
* // => 'crumpets'
|
3699
|
+
*
|
3700
|
+
* _.result(object, 'stuff');
|
3701
|
+
* // => 'nonsense'
|
3702
|
+
*/
|
3703
|
+
function result(object, property) {
|
3704
|
+
// based on Backbone's private `getValue` function
|
3705
|
+
// https://github.com/documentcloud/backbone/blob/0.9.2/backbone.js#L1419-1424
|
3706
|
+
var value = object ? object[property] : null;
|
3707
|
+
return isFunction(value) ? object[property]() : value;
|
3708
|
+
}
|
3709
|
+
|
3710
|
+
/**
|
3711
|
+
* A micro-templating method that handles arbitrary delimiters, preserves
|
3712
|
+
* whitespace, and correctly escapes quotes within interpolated code.
|
3713
|
+
*
|
3714
|
+
* Note: In the development build `_.template` utilizes sourceURLs for easier
|
3715
|
+
* debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
3716
|
+
*
|
3717
|
+
* Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp`
|
3718
|
+
* build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page.
|
3719
|
+
* See http://developer.chrome.com/trunk/extensions/sandboxingEval.html
|
3720
|
+
*
|
3721
|
+
* @static
|
3722
|
+
* @memberOf _
|
3723
|
+
* @category Utilities
|
3724
|
+
* @param {String} text The template text.
|
3725
|
+
* @param {Obect} data The data object used to populate the text.
|
3726
|
+
* @param {Object} options The options object.
|
3727
|
+
* escape - The "escape" delimiter regexp.
|
3728
|
+
* evaluate - The "evaluate" delimiter regexp.
|
3729
|
+
* interpolate - The "interpolate" delimiter regexp.
|
3730
|
+
* sourceURL - The sourceURL of the template's compiled source.
|
3731
|
+
* variable - The data object variable name.
|
3732
|
+
*
|
3733
|
+
* @returns {Function|String} Returns a compiled function when no `data` object
|
3734
|
+
* is given, else it returns the interpolated text.
|
3735
|
+
* @example
|
3736
|
+
*
|
3737
|
+
* // using a compiled template
|
3738
|
+
* var compiled = _.template('hello <%= name %>');
|
3739
|
+
* compiled({ 'name': 'moe' });
|
3740
|
+
* // => 'hello moe'
|
3741
|
+
*
|
3742
|
+
* var list = '<% _.forEach(people, function(name) { %><li><%= name %></li><% }); %>';
|
3743
|
+
* _.template(list, { 'people': ['moe', 'larry', 'curly'] });
|
3744
|
+
* // => '<li>moe</li><li>larry</li><li>curly</li>'
|
3745
|
+
*
|
3746
|
+
* // using the "escape" delimiter to escape HTML in data property values
|
3747
|
+
* _.template('<b><%- value %></b>', { 'value': '<script>' });
|
3748
|
+
* // => '<b><script></b>'
|
3749
|
+
*
|
3750
|
+
* // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
|
3751
|
+
* _.template('hello ${ name }', { 'name': 'curly' });
|
3752
|
+
* // => 'hello curly'
|
3753
|
+
*
|
3754
|
+
* // using the internal `print` function in "evaluate" delimiters
|
3755
|
+
* _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' });
|
3756
|
+
* // => 'hello stooge!'
|
3757
|
+
*
|
3758
|
+
* // using custom template delimiters
|
3759
|
+
* _.templateSettings = {
|
3760
|
+
* 'interpolate': /{{([\s\S]+?)}}/g
|
3761
|
+
* };
|
3762
|
+
*
|
3763
|
+
* _.template('hello {{ name }}!', { 'name': 'mustache' });
|
3764
|
+
* // => 'hello mustache!'
|
3765
|
+
*
|
3766
|
+
* // using the `sourceURL` option to specify a custom sourceURL for the template
|
3767
|
+
* var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
|
3768
|
+
* compiled(data);
|
3769
|
+
* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
|
3770
|
+
*
|
3771
|
+
* // using the `variable` option to ensure a with-statement isn't used in the compiled template
|
3772
|
+
* var compiled = _.template('hello <%= data.name %>!', null, { 'variable': 'data' });
|
3773
|
+
* compiled.source;
|
3774
|
+
* // => function(data) {
|
3775
|
+
* var __t, __p = '', __e = _.escape;
|
3776
|
+
* __p += 'hello ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
|
3777
|
+
* return __p;
|
3778
|
+
* }
|
3779
|
+
*
|
3780
|
+
* // using the `source` property to inline compiled templates for meaningful
|
3781
|
+
* // line numbers in error messages and a stack trace
|
3782
|
+
* fs.writeFileSync(path.join(cwd, 'jst.js'), '\
|
3783
|
+
* var JST = {\
|
3784
|
+
* "main": ' + _.template(mainText).source + '\
|
3785
|
+
* };\
|
3786
|
+
* ');
|
3787
|
+
*/
|
3788
|
+
function template(text, data, options) {
|
3789
|
+
// based on John Resig's `tmpl` implementation
|
3790
|
+
// http://ejohn.org/blog/javascript-micro-templating/
|
3791
|
+
// and Laura Doktorova's doT.js
|
3792
|
+
// https://github.com/olado/doT
|
3793
|
+
text || (text = '');
|
3794
|
+
options || (options = {});
|
3795
|
+
|
3796
|
+
var isEvaluating,
|
3797
|
+
result,
|
3798
|
+
settings = lodash.templateSettings,
|
3799
|
+
index = 0,
|
3800
|
+
interpolate = options.interpolate || settings.interpolate || reNoMatch,
|
3801
|
+
source = "__p += '",
|
3802
|
+
variable = options.variable || settings.variable,
|
3803
|
+
hasVariable = variable;
|
3804
|
+
|
3805
|
+
// compile regexp to match each delimiter
|
3806
|
+
var reDelimiters = RegExp(
|
3807
|
+
(options.escape || settings.escape || reNoMatch).source + '|' +
|
3808
|
+
interpolate.source + '|' +
|
3809
|
+
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
3810
|
+
(options.evaluate || settings.evaluate || reNoMatch).source + '|$'
|
3811
|
+
, 'g');
|
3812
|
+
|
3813
|
+
text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
3814
|
+
interpolateValue || (interpolateValue = esTemplateValue);
|
3815
|
+
|
3816
|
+
// escape characters that cannot be included in string literals
|
3817
|
+
source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
3818
|
+
|
3819
|
+
// replace delimiters with snippets
|
3820
|
+
source +=
|
3821
|
+
escapeValue ? "' +\n__e(" + escapeValue + ") +\n'" :
|
3822
|
+
evaluateValue ? "';\n" + evaluateValue + ";\n__p += '" :
|
3823
|
+
interpolateValue ? "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'" : '';
|
3824
|
+
|
3825
|
+
isEvaluating || (isEvaluating = evaluateValue || reComplexDelimiter.test(escapeValue || interpolateValue));
|
3826
|
+
index = offset + match.length;
|
3827
|
+
});
|
3828
|
+
|
3829
|
+
source += "';\n";
|
3830
|
+
|
3831
|
+
// if `variable` is not specified and the template contains "evaluate"
|
3832
|
+
// delimiters, wrap a with-statement around the generated code to add the
|
3833
|
+
// data object to the top of the scope chain
|
3834
|
+
if (!hasVariable) {
|
3835
|
+
variable = 'obj';
|
3836
|
+
if (isEvaluating) {
|
3837
|
+
source = 'with (' + variable + ') {\n' + source + '\n}\n';
|
3838
|
+
}
|
3839
|
+
else {
|
3840
|
+
// avoid a with-statement by prepending data object references to property names
|
3841
|
+
var reDoubleVariable = RegExp('(\\(\\s*)' + variable + '\\.' + variable + '\\b', 'g');
|
3842
|
+
source = source
|
3843
|
+
.replace(reInsertVariable, '$&' + variable + '.')
|
3844
|
+
.replace(reDoubleVariable, '$1__d');
|
3845
|
+
}
|
3846
|
+
}
|
3847
|
+
|
3848
|
+
// cleanup code by stripping empty strings
|
3849
|
+
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
3850
|
+
.replace(reEmptyStringMiddle, '$1')
|
3851
|
+
.replace(reEmptyStringTrailing, '$1;');
|
3852
|
+
|
3853
|
+
// frame code as the function body
|
3854
|
+
source = 'function(' + variable + ') {\n' +
|
3855
|
+
(hasVariable ? '' : variable + ' || (' + variable + ' = {});\n') +
|
3856
|
+
'var __t, __p = \'\', __e = _.escape' +
|
3857
|
+
(isEvaluating
|
3858
|
+
? ', __j = Array.prototype.join;\n' +
|
3859
|
+
'function print() { __p += __j.call(arguments, \'\') }\n'
|
3860
|
+
: (hasVariable ? '' : ', __d = ' + variable + '.' + variable + ' || ' + variable) + ';\n'
|
3861
|
+
) +
|
3862
|
+
source +
|
3863
|
+
'return __p\n}';
|
3864
|
+
|
3865
|
+
// use a sourceURL for easier debugging
|
3866
|
+
// http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
3867
|
+
var sourceURL = useSourceURL
|
3868
|
+
? '\n//@ sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']')
|
3869
|
+
: '';
|
3870
|
+
|
3871
|
+
try {
|
3872
|
+
result = Function('_', 'return ' + source + sourceURL)(lodash);
|
3873
|
+
} catch(e) {
|
3874
|
+
e.source = source;
|
3875
|
+
throw e;
|
3876
|
+
}
|
3877
|
+
|
3878
|
+
if (data) {
|
3879
|
+
return result(data);
|
3880
|
+
}
|
3881
|
+
// provide the compiled function's source via its `toString` method, in
|
3882
|
+
// supported environments, or the `source` property as a convenience for
|
3883
|
+
// inlining compiled templates during the build process
|
3884
|
+
result.source = source;
|
3885
|
+
return result;
|
3886
|
+
}
|
3887
|
+
|
3888
|
+
/**
|
3889
|
+
* Executes the `callback` function `n` times, returning an array of the results
|
3890
|
+
* of each `callback` execution. The `callback` is bound to `thisArg` and invoked
|
3891
|
+
* with one argument; (index).
|
3892
|
+
*
|
3893
|
+
* @static
|
3894
|
+
* @memberOf _
|
3895
|
+
* @category Utilities
|
3896
|
+
* @param {Number} n The number of times to execute the callback.
|
3897
|
+
* @param {Function} callback The function called per iteration.
|
3898
|
+
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
3899
|
+
* @returns {Array} Returns a new array of the results of each `callback` execution.
|
3900
|
+
* @example
|
3901
|
+
*
|
3902
|
+
* var diceRolls = _.times(3, _.partial(_.random, 1, 6));
|
3903
|
+
* // => [3, 6, 4]
|
3904
|
+
*
|
3905
|
+
* _.times(3, function(n) { mage.castSpell(n); });
|
3906
|
+
* // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
|
3907
|
+
*
|
3908
|
+
* _.times(3, function(n) { this.cast(n); }, mage);
|
3909
|
+
* // => also calls `mage.castSpell(n)` three times
|
3910
|
+
*/
|
3911
|
+
function times(n, callback, thisArg) {
|
3912
|
+
n = +n || 0;
|
3913
|
+
var index = -1,
|
3914
|
+
result = Array(n);
|
3915
|
+
|
3916
|
+
while (++index < n) {
|
3917
|
+
result[index] = callback.call(thisArg, index);
|
3918
|
+
}
|
3919
|
+
return result;
|
3920
|
+
}
|
3921
|
+
|
3922
|
+
/**
|
3923
|
+
* The opposite of `_.escape`, this method converts the HTML entities
|
3924
|
+
* `&`, `<`, `>`, `"`, and `'` in `string` to their
|
3925
|
+
* corresponding characters.
|
3926
|
+
*
|
3927
|
+
* @static
|
3928
|
+
* @memberOf _
|
3929
|
+
* @category Utilities
|
3930
|
+
* @param {String} string The string to unescape.
|
3931
|
+
* @returns {String} Returns the unescaped string.
|
3932
|
+
* @example
|
3933
|
+
*
|
3934
|
+
* _.unescape('Moe, Larry & Curly');
|
3935
|
+
* // => "Moe, Larry & Curly"
|
3936
|
+
*/
|
3937
|
+
function unescape(string) {
|
3938
|
+
return string == null ? '' : (string + '').replace(reEscapedHtml, unescapeHtmlChar);
|
3939
|
+
}
|
3940
|
+
|
3941
|
+
/**
|
3942
|
+
* Generates a unique id. If `prefix` is passed, the id will be appended to it.
|
3943
|
+
*
|
3944
|
+
* @static
|
3945
|
+
* @memberOf _
|
3946
|
+
* @category Utilities
|
3947
|
+
* @param {String} [prefix] The value to prefix the id with.
|
3948
|
+
* @returns {Number|String} Returns a numeric id if no prefix is passed, else
|
3949
|
+
* a string id may be returned.
|
3950
|
+
* @example
|
3951
|
+
*
|
3952
|
+
* _.uniqueId('contact_');
|
3953
|
+
* // => 'contact_104'
|
3954
|
+
*/
|
3955
|
+
function uniqueId(prefix) {
|
3956
|
+
var id = idCounter++;
|
3957
|
+
return prefix ? prefix + id : id;
|
3958
|
+
}
|
3959
|
+
|
3960
|
+
/*--------------------------------------------------------------------------*/
|
3961
|
+
|
3962
|
+
/**
|
3963
|
+
* Wraps the value in a `lodash` wrapper object.
|
3964
|
+
*
|
3965
|
+
* @static
|
3966
|
+
* @memberOf _
|
3967
|
+
* @category Chaining
|
3968
|
+
* @param {Mixed} value The value to wrap.
|
3969
|
+
* @returns {Object} Returns the wrapper object.
|
3970
|
+
* @example
|
3971
|
+
*
|
3972
|
+
* var stooges = [
|
3973
|
+
* { 'name': 'moe', 'age': 40 },
|
3974
|
+
* { 'name': 'larry', 'age': 50 },
|
3975
|
+
* { 'name': 'curly', 'age': 60 }
|
3976
|
+
* ];
|
3977
|
+
*
|
3978
|
+
* var youngest = _.chain(stooges)
|
3979
|
+
* .sortBy(function(stooge) { return stooge.age; })
|
3980
|
+
* .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })
|
3981
|
+
* .first()
|
3982
|
+
* .value();
|
3983
|
+
* // => 'moe is 40'
|
3984
|
+
*/
|
3985
|
+
function chain(value) {
|
3986
|
+
value = new lodash(value);
|
3987
|
+
value.__chain__ = true;
|
3988
|
+
return value;
|
3989
|
+
}
|
3990
|
+
|
3991
|
+
/**
|
3992
|
+
* Invokes `interceptor` with the `value` as the first argument, and then
|
3993
|
+
* returns `value`. The purpose of this method is to "tap into" a method chain,
|
3994
|
+
* in order to perform operations on intermediate results within the chain.
|
3995
|
+
*
|
3996
|
+
* @static
|
3997
|
+
* @memberOf _
|
3998
|
+
* @category Chaining
|
3999
|
+
* @param {Mixed} value The value to pass to `interceptor`.
|
4000
|
+
* @param {Function} interceptor The function to invoke.
|
4001
|
+
* @returns {Mixed} Returns `value`.
|
4002
|
+
* @example
|
4003
|
+
*
|
4004
|
+
* _.chain([1, 2, 3, 200])
|
4005
|
+
* .filter(function(num) { return num % 2 == 0; })
|
4006
|
+
* .tap(alert)
|
4007
|
+
* .map(function(num) { return num * num })
|
4008
|
+
* .value();
|
4009
|
+
* // => // [2, 200] (alerted)
|
4010
|
+
* // => [4, 40000]
|
4011
|
+
*/
|
4012
|
+
function tap(value, interceptor) {
|
4013
|
+
interceptor(value);
|
4014
|
+
return value;
|
4015
|
+
}
|
4016
|
+
|
4017
|
+
/**
|
4018
|
+
* Enables method chaining on the wrapper object.
|
4019
|
+
*
|
4020
|
+
* @name chain
|
4021
|
+
* @deprecated
|
4022
|
+
* @memberOf _
|
4023
|
+
* @category Chaining
|
4024
|
+
* @returns {Mixed} Returns the wrapper object.
|
4025
|
+
* @example
|
4026
|
+
*
|
4027
|
+
* _([1, 2, 3]).value();
|
4028
|
+
* // => [1, 2, 3]
|
4029
|
+
*/
|
4030
|
+
function wrapperChain() {
|
4031
|
+
this.__chain__ = true;
|
4032
|
+
return this;
|
4033
|
+
}
|
4034
|
+
|
4035
|
+
/**
|
4036
|
+
* Extracts the wrapped value.
|
4037
|
+
*
|
4038
|
+
* @name value
|
4039
|
+
* @memberOf _
|
4040
|
+
* @category Chaining
|
4041
|
+
* @returns {Mixed} Returns the wrapped value.
|
4042
|
+
* @example
|
4043
|
+
*
|
4044
|
+
* _([1, 2, 3]).value();
|
4045
|
+
* // => [1, 2, 3]
|
4046
|
+
*/
|
4047
|
+
function wrapperValue() {
|
4048
|
+
return this.__wrapped__;
|
4049
|
+
}
|
4050
|
+
|
4051
|
+
/*--------------------------------------------------------------------------*/
|
4052
|
+
|
4053
|
+
/**
|
4054
|
+
* The semantic version number.
|
4055
|
+
*
|
4056
|
+
* @static
|
4057
|
+
* @memberOf _
|
4058
|
+
* @type String
|
4059
|
+
*/
|
4060
|
+
lodash.VERSION = '0.9.2';
|
4061
|
+
|
4062
|
+
// assign static methods
|
4063
|
+
lodash.after = after;
|
4064
|
+
lodash.bind = bind;
|
4065
|
+
lodash.bindAll = bindAll;
|
4066
|
+
lodash.chain = chain;
|
4067
|
+
lodash.clone = clone;
|
4068
|
+
lodash.compact = compact;
|
4069
|
+
lodash.compose = compose;
|
4070
|
+
lodash.contains = contains;
|
4071
|
+
lodash.countBy = countBy;
|
4072
|
+
lodash.debounce = debounce;
|
4073
|
+
lodash.defaults = defaults;
|
4074
|
+
lodash.defer = defer;
|
4075
|
+
lodash.delay = delay;
|
4076
|
+
lodash.difference = difference;
|
4077
|
+
lodash.escape = escape;
|
4078
|
+
lodash.every = every;
|
4079
|
+
lodash.extend = extend;
|
4080
|
+
lodash.filter = filter;
|
4081
|
+
lodash.find = find;
|
4082
|
+
lodash.first = first;
|
4083
|
+
lodash.flatten = flatten;
|
4084
|
+
lodash.forEach = forEach;
|
4085
|
+
lodash.forIn = forIn;
|
4086
|
+
lodash.forOwn = forOwn;
|
4087
|
+
lodash.functions = functions;
|
4088
|
+
lodash.groupBy = groupBy;
|
4089
|
+
lodash.has = has;
|
4090
|
+
lodash.identity = identity;
|
4091
|
+
lodash.indexOf = indexOf;
|
4092
|
+
lodash.initial = initial;
|
4093
|
+
lodash.intersection = intersection;
|
4094
|
+
lodash.invert = invert;
|
4095
|
+
lodash.invoke = invoke;
|
4096
|
+
lodash.isArguments = isArguments;
|
4097
|
+
lodash.isArray = isArray;
|
4098
|
+
lodash.isBoolean = isBoolean;
|
4099
|
+
lodash.isDate = isDate;
|
4100
|
+
lodash.isElement = isElement;
|
4101
|
+
lodash.isEmpty = isEmpty;
|
4102
|
+
lodash.isEqual = isEqual;
|
4103
|
+
lodash.isFinite = isFinite;
|
4104
|
+
lodash.isFunction = isFunction;
|
4105
|
+
lodash.isNaN = isNaN;
|
4106
|
+
lodash.isNull = isNull;
|
4107
|
+
lodash.isNumber = isNumber;
|
4108
|
+
lodash.isObject = isObject;
|
4109
|
+
lodash.isPlainObject = isPlainObject;
|
4110
|
+
lodash.isRegExp = isRegExp;
|
4111
|
+
lodash.isString = isString;
|
4112
|
+
lodash.isUndefined = isUndefined;
|
4113
|
+
lodash.keys = keys;
|
4114
|
+
lodash.last = last;
|
4115
|
+
lodash.lastIndexOf = lastIndexOf;
|
4116
|
+
lodash.lateBind = lateBind;
|
4117
|
+
lodash.map = map;
|
4118
|
+
lodash.max = max;
|
4119
|
+
lodash.memoize = memoize;
|
4120
|
+
lodash.merge = merge;
|
4121
|
+
lodash.min = min;
|
4122
|
+
lodash.mixin = mixin;
|
4123
|
+
lodash.noConflict = noConflict;
|
4124
|
+
lodash.object = object;
|
4125
|
+
lodash.omit = omit;
|
4126
|
+
lodash.once = once;
|
4127
|
+
lodash.pairs = pairs;
|
4128
|
+
lodash.partial = partial;
|
4129
|
+
lodash.pick = pick;
|
4130
|
+
lodash.pluck = pluck;
|
4131
|
+
lodash.random = random;
|
4132
|
+
lodash.range = range;
|
4133
|
+
lodash.reduce = reduce;
|
4134
|
+
lodash.reduceRight = reduceRight;
|
4135
|
+
lodash.reject = reject;
|
4136
|
+
lodash.rest = rest;
|
4137
|
+
lodash.result = result;
|
4138
|
+
lodash.shuffle = shuffle;
|
4139
|
+
lodash.size = size;
|
4140
|
+
lodash.some = some;
|
4141
|
+
lodash.sortBy = sortBy;
|
4142
|
+
lodash.sortedIndex = sortedIndex;
|
4143
|
+
lodash.tap = tap;
|
4144
|
+
lodash.template = template;
|
4145
|
+
lodash.throttle = throttle;
|
4146
|
+
lodash.times = times;
|
4147
|
+
lodash.toArray = toArray;
|
4148
|
+
lodash.unescape = unescape;
|
4149
|
+
lodash.union = union;
|
4150
|
+
lodash.uniq = uniq;
|
4151
|
+
lodash.uniqueId = uniqueId;
|
4152
|
+
lodash.values = values;
|
4153
|
+
lodash.where = where;
|
4154
|
+
lodash.without = without;
|
4155
|
+
lodash.wrap = wrap;
|
4156
|
+
lodash.zip = zip;
|
4157
|
+
|
4158
|
+
// assign aliases
|
4159
|
+
lodash.all = every;
|
4160
|
+
lodash.any = some;
|
4161
|
+
lodash.collect = map;
|
4162
|
+
lodash.detect = find;
|
4163
|
+
lodash.drop = rest;
|
4164
|
+
lodash.each = forEach;
|
4165
|
+
lodash.foldl = reduce;
|
4166
|
+
lodash.foldr = reduceRight;
|
4167
|
+
lodash.head = first;
|
4168
|
+
lodash.include = contains;
|
4169
|
+
lodash.inject = reduce;
|
4170
|
+
lodash.methods = functions;
|
4171
|
+
lodash.select = filter;
|
4172
|
+
lodash.tail = rest;
|
4173
|
+
lodash.take = first;
|
4174
|
+
lodash.unique = uniq;
|
4175
|
+
|
4176
|
+
// add pseudo private property to be used and removed during the build process
|
4177
|
+
lodash._iteratorTemplate = iteratorTemplate;
|
4178
|
+
|
4179
|
+
/*--------------------------------------------------------------------------*/
|
4180
|
+
|
4181
|
+
// add all static functions to `lodash.prototype`
|
4182
|
+
mixin(lodash);
|
4183
|
+
|
4184
|
+
// add `lodash.prototype.chain` after calling `mixin()` to avoid overwriting
|
4185
|
+
// it with the wrapped `lodash.chain`
|
4186
|
+
lodash.prototype.chain = wrapperChain;
|
4187
|
+
lodash.prototype.value = wrapperValue;
|
4188
|
+
|
4189
|
+
// add all mutator Array functions to the wrapper.
|
4190
|
+
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
4191
|
+
var func = arrayRef[methodName];
|
4192
|
+
|
4193
|
+
lodash.prototype[methodName] = function() {
|
4194
|
+
var value = this.__wrapped__;
|
4195
|
+
func.apply(value, arguments);
|
4196
|
+
|
4197
|
+
// avoid array-like object bugs with `Array#shift` and `Array#splice` in
|
4198
|
+
// Firefox < 10 and IE < 9
|
4199
|
+
if (hasObjectSpliceBug && value.length === 0) {
|
4200
|
+
delete value[0];
|
4201
|
+
}
|
4202
|
+
if (this.__chain__) {
|
4203
|
+
value = new lodash(value);
|
4204
|
+
value.__chain__ = true;
|
4205
|
+
}
|
4206
|
+
return value;
|
4207
|
+
};
|
4208
|
+
});
|
4209
|
+
|
4210
|
+
// add all accessor Array functions to the wrapper.
|
4211
|
+
forEach(['concat', 'join', 'slice'], function(methodName) {
|
4212
|
+
var func = arrayRef[methodName];
|
4213
|
+
|
4214
|
+
lodash.prototype[methodName] = function() {
|
4215
|
+
var value = this.__wrapped__,
|
4216
|
+
result = func.apply(value, arguments);
|
4217
|
+
|
4218
|
+
if (this.__chain__) {
|
4219
|
+
result = new lodash(result);
|
4220
|
+
result.__chain__ = true;
|
4221
|
+
}
|
4222
|
+
return result;
|
4223
|
+
};
|
4224
|
+
});
|
4225
|
+
|
4226
|
+
/*--------------------------------------------------------------------------*/
|
4227
|
+
|
4228
|
+
// expose Lo-Dash
|
4229
|
+
// some AMD build optimizers, like r.js, check for specific condition patterns like the following:
|
4230
|
+
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
4231
|
+
// Expose Lo-Dash to the global object even when an AMD loader is present in
|
4232
|
+
// case Lo-Dash was injected by a third-party script and not intended to be
|
4233
|
+
// loaded as a module. The global assignment can be reverted in the Lo-Dash
|
4234
|
+
// module via its `noConflict()` method.
|
4235
|
+
window._ = lodash;
|
4236
|
+
|
4237
|
+
// define as an anonymous module so, through path mapping, it can be
|
4238
|
+
// referenced as the "underscore" module
|
4239
|
+
define(function() {
|
4240
|
+
return lodash;
|
4241
|
+
});
|
4242
|
+
}
|
4243
|
+
// check for `exports` after `define` in case a build optimizer adds an `exports` object
|
4244
|
+
else if (freeExports) {
|
4245
|
+
// in Node.js or RingoJS v0.8.0+
|
4246
|
+
if (typeof module == 'object' && module && module.exports == freeExports) {
|
4247
|
+
(module.exports = lodash)._ = lodash;
|
4248
|
+
}
|
4249
|
+
// in Narwhal or RingoJS v0.7.0-
|
4250
|
+
else {
|
4251
|
+
freeExports._ = lodash;
|
4252
|
+
}
|
4253
|
+
}
|
4254
|
+
else {
|
4255
|
+
// in a browser or Rhino
|
4256
|
+
window._ = lodash;
|
4257
|
+
}
|
4258
|
+
}(this));
|