{"id":16296503,"url":"https://github.com/f1lt3r/magic-params","last_synced_at":"2025-10-24T09:59:59.128Z","repository":{"id":143888489,"uuid":"125161987","full_name":"F1LT3R/magic-params","owner":"F1LT3R","description":"🐇  magically pass function parameters in any order","archived":false,"fork":false,"pushed_at":"2018-03-22T14:12:42.000Z","size":206,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T05:59:09.473Z","etag":null,"topics":["function","magic","order","params","pass"],"latest_commit_sha":null,"homepage":"https://f1lt3r.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/F1LT3R.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-14T05:51:47.000Z","updated_at":"2018-03-22T14:12:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"30bf43df-1a36-4cb4-b505-cafe0fbb3a14","html_url":"https://github.com/F1LT3R/magic-params","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/F1LT3R/magic-params","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fmagic-params","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fmagic-params/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fmagic-params/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fmagic-params/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/F1LT3R","download_url":"https://codeload.github.com/F1LT3R/magic-params/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/F1LT3R%2Fmagic-params/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280776477,"owners_count":26388950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["function","magic","order","params","pass"],"created_at":"2024-10-10T20:22:59.761Z","updated_at":"2025-10-24T09:59:59.100Z","avatar_url":"https://github.com/F1LT3R.png","language":"JavaScript","readme":"\n# Magic Params\n\n\u003e 🐇  magically pass function parameters in any order\n\n[![Build Status](https://travis-ci.org/F1LT3R/magic-params.svg?branch=master)](https://travis-ci.org/F1LT3R/magic-params)\n[![Coverage Status](https://coveralls.io/repos/github/F1LT3R/magic-params/badge.svg?branch=master)](https://coveralls.io/github/F1LT3R/magic-params?branch=master)\n[![Npm Version](https://img.shields.io/npm/v/magic-params.svg)](https://www.npmjs.com/package/magic-params)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\n\u003cimg alt=\"Bunny rabbit waving magic wand in parenthesis\" src=\"magic-params.png\" align=\"right\"\u003e\n\nMagic-Params is a small Node modules that lets you re-order of the params in your functions, without chaging their value. Magic-Params was designed to support a simplified plugin architecure.\n\nFor example: the following function...\n\n```javascript\nconst fn = (args, in, any, order) =\u003e {}\n```\n\n... will work exactly the same if you re-order the arguments:\n\n```javascript\nconst fn = (any, order, in, args) =\u003e {}\n```\n\nJust pass your params object and function to Magic-Params:\n\n```javascript\nconst magicParams = require('magic-params')\n\nconst fn = (a, b) =\u003e {\n\treturn a + b\n}\n\nconst params = {\n\ta: 2,\n\tb: 2\n}\n\nconst result = magicParms.pass(params, fn)\n// Result = 4\n```\n\n## Passing Arguments\n\n```javascript\nconst magicParams = require('magic-params')\n\nconst params = {\n\ta: 'Hello,',\n\tb: ' world!'\n}\n\n// You can switch the order of the arguments\n\nconst display1 = (a, b) {\n\tconsole.log(a + b)\n}\n\nconst display2 = (b, a) {\n\tconsole.log(a + b)\n}\n\n// The values stay mapped to param names\n\nmagicParams.pass(params, display1)\n// 'Hello, world!'\n\nmagicParams.pass(params, display2)\n// 'Hello, world!'\n```\n\n## Passing Context\n\nYou can pass context with magic params by using the `magicParams.apply()` method:\n\n```javascript\nconst magicParams = require('magic-params')\n\nconst params = {\n\ta: 'Hello,'\n}\n\nconst context = {\n\tb: ' world!'\n}\n\n// The context is available on `this`\n\nconst display = function (a) {\n\tconsole.log(a + this.b)\n}\n\nmagicParams.apply(params, display, context)\n// 'Hello, world!'\n```\n\n## Listing Params\n\nYou can also list params with the `magicParams.list()` method:\n\n```javascript\nconst magicParams = require('magic-params')\n\nconst display = function (a, b) {\n\t...\n}\n\nmagicParams.list(display)\n// Returns array: ['a', 'b']\n```\n\n## Installation\n\n```shell\nyarn add magic-params\n```\n\n## Testing\n\n```shell\nyarn test\n```\n\n## Credits\n\nThanks to [Ben Iconator](https://thenounproject.com/mr.iconator/) and [Anbileru Adaleru](https://thenounproject.com/pronoun/) from NounProject for the rabbit and magic wand vectors used in the magic params logo.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Fmagic-params","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff1lt3r%2Fmagic-params","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff1lt3r%2Fmagic-params/lists"}