{"id":26643700,"url":"https://github.com/kosich/js-functional-playground","last_synced_at":"2025-03-24T20:34:44.999Z","repository":{"id":24859491,"uuid":"28274866","full_name":"kosich/js-functional-playground","owner":"kosich","description":null,"archived":false,"fork":false,"pushed_at":"2014-12-21T22:36:14.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-07T12:01:47.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/kosich.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}},"created_at":"2014-12-20T18:12:50.000Z","updated_at":"2024-05-07T12:01:47.412Z","dependencies_parsed_at":"2022-08-03T05:15:19.946Z","dependency_job_id":null,"html_url":"https://github.com/kosich/js-functional-playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-functional-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-functional-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-functional-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-functional-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kosich","download_url":"https://codeload.github.com/kosich/js-functional-playground/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245349267,"owners_count":20600802,"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":[],"created_at":"2025-03-24T20:34:42.614Z","updated_at":"2025-03-24T20:34:44.976Z","avatar_url":"https://github.com/kosich.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-functional-playground\n\ntests with functional paradigm aspects of ES\n\n## Currying\n\n### Simple currying\n\nThis implementation of currying is pretty simple and will evaluate\npassed function as soon as enough arguments passed (equal to \u003cyourFunction\u003e.length)\n\n```javascript\n    var curry = require('/src/currying/simple-curry.js').curry;\n\n    // ...\n\n    function add(a, b, c){\n        return a + b + c;\n    }\n\n    // options : ignore the fn.length\n    var cAdd = curry( add );\n    // will evaluate when enought args passed\n    console.log( cAdd( 28, 11 )( 3 ) ); // = 42\n```\n\n### Advanced currying\n\nAdvanced currying function provides additional option to accept\nfunctions with no predefined number of arguments. So it wont be\ncalled once passed enough arguments\n\n```javascript\n    var curry = require('/src/currying/curry.js').curry;\n    \n    // ...\n    \n    function multy( initial ){\n        var args = Array.prototype.splice.call(arguments, 1);\n        return args.reduce( function( a, b ){\n            return a * b;\n        }, initial || 0);\n    }\n\n    // curry fn, and set options : ignore the fn.length\n    var cMultyBy2 = curry( multy , { lengthBased : false } )(2);\n    // ... ergo evaluate only after call with empty args\n    console.log( cMultyBy2( 5 )( 2 )(  ) ); // = 20\n```\n\nAlso theres an option to deal with `this` in function body.\nFor this to happen one should call currying like follows:\n\n```javascript\nvar entity = {\n    value : 2,\n    method : function(a, b, c){\n        return this.value + a + b + c;\n    }\n};\nvar _addWithThis = curry.call(entity, entity.method);\nassert.equal(8, _addWithThis(1, 2)(3) );\n```\n\nAlso supports `valueOf` (even with `this`).\n\nMore to see in `/test/currying/curry-test.js`\n\n## Memoization\n\nTo be covered with tests and described...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosich%2Fjs-functional-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkosich%2Fjs-functional-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosich%2Fjs-functional-playground/lists"}