pax_global_header00006660000000000000000000000064150613145210014510gustar00rootroot0000000000000052 comment=eb4f9b11182126927dcdc90149a41126c4b846c2 Qix--node-simple-swizzle-bad4af4/000077500000000000000000000000001506131452100170145ustar00rootroot00000000000000Qix--node-simple-swizzle-bad4af4/.editorconfig000066400000000000000000000003471506131452100214750ustar00rootroot00000000000000root = 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 Qix--node-simple-swizzle-bad4af4/.gitignore000066400000000000000000000000621506131452100210020ustar00rootroot00000000000000*.sw[a-p] /node_modules/ npm-debug.log /coverage/ Qix--node-simple-swizzle-bad4af4/.istanbul.yml000066400000000000000000000000731506131452100214360ustar00rootroot00000000000000instrumentation: excludes: - test.js - test/**/* Qix--node-simple-swizzle-bad4af4/.travis.yml000066400000000000000000000004401506131452100211230ustar00rootroot00000000000000language: 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 Qix--node-simple-swizzle-bad4af4/LICENSE000066400000000000000000000020651506131452100200240ustar00rootroot00000000000000The 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. Qix--node-simple-swizzle-bad4af4/README.md000066400000000000000000000032651506131452100203010ustar00rootroot00000000000000> **NOTE:** ⚠️ **Don't use this package in new projects.** It is a **huge anti-pattern** and will only confuse and annoy people who use whatever code you write with it. I wrote this in a time when Javascript and Node.js were still pretty experimental and clever things like this weren't frowned upon. I've also learned a LOT about proper API design since I wrote this package. DO. NOT. USE. THIS. PACKAGE. If you're reaching for it, please *really* reconsider your API's design. --- # 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). Qix--node-simple-swizzle-bad4af4/index.js000066400000000000000000000010731506131452100204620ustar00rootroot00000000000000'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)); }; }; Qix--node-simple-swizzle-bad4af4/package.json000066400000000000000000000013261506131452100213040ustar00rootroot00000000000000{ "name": "simple-swizzle", "description": "Simply swizzle your arguments", "version": "0.2.4", "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" } } Qix--node-simple-swizzle-bad4af4/test/000077500000000000000000000000001506131452100177735ustar00rootroot00000000000000Qix--node-simple-swizzle-bad4af4/test/test.coffee000066400000000000000000000027421506131452100221300ustar00rootroot00000000000000should = 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]