pax_global_header00006660000000000000000000000064130127426110014507gustar00rootroot0000000000000052 comment=54cfffdb7c115c4fc52ce7c2f2af9f6351091c88 node-simple-swizzle-0.2.2/000077500000000000000000000000001301274261100154315ustar00rootroot00000000000000node-simple-swizzle-0.2.2/.editorconfig000066400000000000000000000003471301274261100201120ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false node-simple-swizzle-0.2.2/.gitignore000066400000000000000000000000621301274261100174170ustar00rootroot00000000000000*.sw[a-p] /node_modules/ npm-debug.log /coverage/ node-simple-swizzle-0.2.2/.istanbul.yml000066400000000000000000000000731301274261100200530ustar00rootroot00000000000000instrumentation: excludes: - test.js - test/**/* node-simple-swizzle-0.2.2/.travis.yml000066400000000000000000000004401301274261100175400ustar00rootroot00000000000000language: node_js script: - node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --compilers coffee:coffee-script/register - cat coverage/lcov.info | node_modules/.bin/coveralls node_js: - 7 - 6 - 5 - 4 - 3 - "0.10" - "0.11" - "0.12" - "iojs" os: - linux node-simple-swizzle-0.2.2/LICENSE000066400000000000000000000020651301274261100164410ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Josh Junon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-simple-swizzle-0.2.2/README.md000066400000000000000000000023141301274261100167100ustar00rootroot00000000000000# simple-swizzle [![Travis-CI.org Build Status](https://img.shields.io/travis/Qix-/node-simple-swizzle.svg?style=flat-square)](https://travis-ci.org/Qix-/node-simple-swizzle) [![Coveralls.io Coverage Rating](https://img.shields.io/coveralls/Qix-/node-simple-swizzle.svg?style=flat-square)](https://coveralls.io/r/Qix-/node-simple-swizzle) > [Swizzle](https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)) your function arguments; pass in mixed arrays/values and get a clean array ## Usage ```js var swizzle = require('simple-swizzle'); function myFunc() { var args = swizzle(arguments); // ... return args; } myFunc(1, [2, 3], 4); // [1, 2, 3, 4] myFunc(1, 2, 3, 4); // [1, 2, 3, 4] myFunc([1, 2, 3, 4]); // [1, 2, 3, 4] ``` Functions can also be wrapped to automatically swizzle arguments and be passed the resulting array. ```js var swizzle = require('simple-swizzle'); var swizzledFn = swizzle.wrap(function (args) { // ... return args; }); swizzledFn(1, [2, 3], 4); // [1, 2, 3, 4] swizzledFn(1, 2, 3, 4); // [1, 2, 3, 4] swizzledFn([1, 2, 3, 4]); // [1, 2, 3, 4] ``` ## License Licensed under the [MIT License](http://opensource.org/licenses/MIT). You can find a copy of it in [LICENSE](LICENSE). node-simple-swizzle-0.2.2/index.js000066400000000000000000000010731301274261100170770ustar00rootroot00000000000000'use strict'; var isArrayish = require('is-arrayish'); var concat = Array.prototype.concat; var slice = Array.prototype.slice; var swizzle = module.exports = function swizzle(args) { var results = []; for (var i = 0, len = args.length; i < len; i++) { var arg = args[i]; if (isArrayish(arg)) { // http://jsperf.com/javascript-array-concat-vs-push/98 results = concat.call(results, slice.call(arg)); } else { results.push(arg); } } return results; }; swizzle.wrap = function (fn) { return function () { return fn(swizzle(arguments)); }; }; node-simple-swizzle-0.2.2/package.json000066400000000000000000000013261301274261100177210ustar00rootroot00000000000000{ "name": "simple-swizzle", "description": "Simply swizzle your arguments", "version": "0.2.2", "author": "Qix (http://github.com/qix-)", "keywords": [ "argument", "arguments", "swizzle", "swizzling", "parameter", "parameters", "mixed", "array" ], "license": "MIT", "scripts": { "pretest": "xo", "test": "mocha --compilers coffee:coffee-script/register" }, "files": [ "index.js" ], "repository": "qix-/node-simple-swizzle", "devDependencies": { "coffee-script": "^1.9.3", "coveralls": "^2.11.2", "istanbul": "^0.3.17", "mocha": "^2.2.5", "should": "^7.0.1", "xo": "^0.7.1" }, "dependencies": { "is-arrayish": "^0.3.1" } } node-simple-swizzle-0.2.2/test/000077500000000000000000000000001301274261100164105ustar00rootroot00000000000000node-simple-swizzle-0.2.2/test/test.coffee000066400000000000000000000027421301274261100205450ustar00rootroot00000000000000should = require 'should' swizzle = require '../' Error.stackTraceLimit = Infinity swizMyself = -> swizzle arguments it 'should swizzle single values', -> (swizMyself 1, 2, 3, 4).should.deepEqual [1, 2, 3, 4] (swizMyself 1, 2, 3, 4).should.not.deepEqual [1, 2, 4] swizMyself().should.deepEqual [] it 'should swizzle a single array', -> (swizMyself [1, 2, 3, 4]).should.deepEqual [1, 2, 3, 4] it 'should swizzle interleaved values/arrays', -> (swizMyself 1, 2, [3, 4]).should.deepEqual [1, 2, 3, 4] (swizMyself [1, 2], [3, 4]).should.deepEqual [1, 2, 3, 4] (swizMyself [1, 2, 3], 4).should.deepEqual [1, 2, 3, 4] (swizMyself [1], [2], [3], [4]).should.deepEqual [1, 2, 3, 4] it 'should swizzle pseudo-arrays', -> (swizMyself 1, 2, {length: 2, 0: 3, 1: 4}).should.deepEqual [1, 2, 3, 4] (swizMyself {length: 1, 0: 1}, 2, 3, {length: 1, 0: 4}).should.deepEqual [1, 2, 3, 4] it 'should correctly swizzle string arguments', -> (swizMyself 'hello').should.deepEqual ['hello'] (swizMyself ['hello']).should.deepEqual ['hello'] (swizMyself ['hello'], 'there').should.deepEqual ['hello', 'there'] it 'should wrap a function for swizzling', -> fn = (args) -> args swizzleMyFn = swizzle.wrap fn (swizzleMyFn 1, 2, 3, 4).should.deepEqual [1, 2, 3, 4] (swizzleMyFn 1, 2, [3, 4]).should.deepEqual [1, 2, 3, 4] (swizzleMyFn [1, 2], [3, 4]).should.deepEqual [1, 2, 3, 4] (swizzleMyFn [1, 2, 3, 4]).should.deepEqual [1, 2, 3, 4] (swizzleMyFn [1], [2], [3], [4]).should.deepEqual [1, 2, 3, 4]