{"id":16760301,"url":"https://github.com/ryanve/fm","last_synced_at":"2025-07-07T16:39:19.140Z","repository":{"id":14239461,"uuid":"16946707","full_name":"ryanve/fm","owner":"ryanve","description":"JavaScript function modulation","archived":false,"fork":false,"pushed_at":"2017-01-24T03:53:22.000Z","size":34,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"gh-pages","last_synced_at":"2025-06-29T20:17:51.276Z","etag":null,"topics":["function","functional-programming","functions","javascript"],"latest_commit_sha":null,"homepage":"https://ryanve.github.io/fm","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jeromeetienne/jquery-qrcode","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-18T11:26:25.000Z","updated_at":"2023-08-08T21:07:09.000Z","dependencies_parsed_at":"2022-09-11T01:51:27.757Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/fm","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/ryanve/fm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ffm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ffm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ffm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ffm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/fm/tar.gz/refs/heads/gh-pages","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ffm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264113587,"owners_count":23559380,"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","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","functional-programming","functions","javascript"],"created_at":"2024-10-13T04:23:04.052Z","updated_at":"2025-07-07T16:39:19.105Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fm\n#### JavaScript function modulation module\n\n```\nnpm install fm --save\n```\n\n## API\n- [\u003cb\u003e.late()\u003c/b\u003e](#late)\n- [\u003cb\u003e.bind()\u003c/b\u003e](#bind)\n- [\u003cb\u003e.partial()\u003c/b\u003e](#partial)\n- [\u003cb\u003e.slice()\u003c/b\u003e](#slice)\n- [\u003cb\u003e.stat()\u003c/b\u003e](#stat)\n- [\u003cb\u003e.flow()\u003c/b\u003e](#flow)\n- [\u003cb\u003e.constant()\u003c/b\u003e](#constant)\n- [\u003cb\u003e.eq()\u003c/b\u003e](#eq)\n- [\u003cb\u003e.got()\u003c/b\u003e](#got)\n- [\u003cb\u003e.mixin()\u003c/b\u003e](#mixin)\n\n* * *\n\n- methods can be used statically or via [OO syntax](#oo)\n\n\u003ca name=\"oo\"\u003e\u003c/a\u003e\n### fm()\n#### `fm(value)` \u0026rarr; OO wrapper\n##### `fm()` inherits from `fm.prototype`\n\n```js\nvar fm = require('fm')\nfm(callback).partial(...arguments)\nfm.prototype.partial.apply(callback, arguments)\n```\n\n### .late()\n#### `fm.late(method)`\n#### `fm(method).late()`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that calls `this[method]`\n\n```js\nfm.late('yes').call({ yes:function() { return 1 } }) // =\u003e 1\nfm.late(0).call([function() { return this.length }]) // =\u003e 1\n```\n\n### .bind()\n#### `fm.bind(callback, scope, ...arguments)`\n#### `fm(callback).bind(scope, ...arguments)`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that calls \u003cvar\u003ecallback\u003c/var\u003e with `this` binded to \u003cvar\u003escope\u003c/var\u003e, and prepends leading \u003cvar\u003earguments\u003c/var\u003e\n\n```js\nfm.bind(callback, scope) // basic bind\nfm.bind(callback, scope, 'a', 'b', 'c') // bind with partial arguments\n```\n\n### .partial()\n#### `fm.partial(callback, ...arguments)`\n#### `fm(callback).partial(...arguments)`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that calls \u003cvar\u003ecallback\u003c/var\u003e with dynamic `this`, and prepends leading \u003cvar\u003earguments\u003c/var\u003e\n\n```js\nfm.partial(fm.got, 'a', 'b')('c') // =\u003e ['a', 'b', 'c']\nfm.partial('got', 'a', 'b').call(fm, 'c') // =\u003e ['a', 'b', 'c']\nfm.prototype.partial.apply(callback, array) // useful for array partials\n```\n\n### .slice()\n#### `fm.slice(callback, begin?, end?)`\n#### `fm(callback).slice(begin?, end?)`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that calls \u003cvar\u003ecallback\u003c/var\u003e with dynamic `this`, and `arguments` sliced by `[].slice`\n\n```js\nfm.slice(function(a, b, c) {}, 0, 2) // =\u003e new function that accepts only 2 args\nfm.slice(fm.bind, 0, 2) // =\u003e version of .bind that ignores extra arguments\nfm.slice(fm.got, 1)('a', 'b', 'c') // =\u003e ['b', 'c']\nfm.slice(fm.got, -2)('a', 'b', 'c') // =\u003e ['b', 'c']\nfm.slice(fm.got, 1, 2)('a', 'b', 'c') // =\u003e ['b']\n```\n\n### .stat()\n#### `fm.stat(method)`\n#### `fm(method).stat()`\n- Convert an instance method into a static one.\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e\n\n```js\nfm.stat([].slice) // =\u003e static slice() function\nfm.stat({}.hasOwnProperty) // =\u003e static has() function\n```\n\n### .flow()\n#### `fm.flow(first, next)`\n#### `fm(first).flow(next)`\n- Create a new function that invokes the next function with the result the first function\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e\n\n```js\nfm.flow(fm.constant(2), fm.constant(3))()// =\u003e 3\n```\n\n### .constant()\n#### `fm.constant(value)`\n#### `fm(value).constant()`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that always returns \u003cvar\u003evalue\u003c/var\u003e regardless of context or arguments\n\n```js\nfm.constant() // =\u003e noop function\nfm.constant()() // =\u003e undefined\nfm.constant(true)() // =\u003e true\n```\n\n### .eq()\n#### `fm.eq(callback, index)`\n#### `fm(callback).eq(index)`\n\u0026rarr; \u003cb\u003efunction\u003c/b\u003e that reduces the arguments passed to \u003cvar\u003ecallback\u003c/var\u003e to the argument at the specified index\n\n\n```js\nfm.eq(Number, 1)(10, 11, 12) // =\u003e 11\nfm.eq(Number, -1)(10, 11, 12) // =\u003e 12\n```\n\n### .got()\n#### `fm.got(...arguments)`\n#### `fm(head).got(...arguments)`\n\u0026rarr; \u003cb\u003earray\u003c/b\u003e of arguments received\n\n```js\nfm.got() // =\u003e []\nfm.got(0, 1, 2) // =\u003e [0, 1, 2]\n```\n\n### .mixin()\n#### `fm.mixin(object)`\n\u0026rarr; \u003cb\u003ethis\u003c/b\u003e\n\n## Coverage\nWorks...everywhere\u003cb\u003e!\u003c/b\u003e Tested in node, Chrome, FF, Opera, IE\n\n## Contribute\n```\nnpm install\nnpm test\n```\n\n## Playground\n[Try `fm` in your browser](http://ryanve.github.io/fm/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Ffm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Ffm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Ffm/lists"}