{"id":19659825,"url":"https://github.com/tarabyte/ifyify","last_synced_at":"2025-11-22T00:00:49.695Z","repository":{"id":18765810,"uuid":"21978606","full_name":"Tarabyte/ifyify","owner":"Tarabyte","description":"Collection of functional utils.","archived":false,"fork":false,"pushed_at":"2014-07-21T19:12:38.000Z","size":176,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T22:32:54.013Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tarabyte.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-07-18T11:48:13.000Z","updated_at":"2018-02-09T01:00:46.000Z","dependencies_parsed_at":"2022-08-30T06:00:58.173Z","dependency_job_id":null,"html_url":"https://github.com/Tarabyte/ifyify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarabyte%2Fifyify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarabyte%2Fifyify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarabyte%2Fifyify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarabyte%2Fifyify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tarabyte","download_url":"https://codeload.github.com/Tarabyte/ifyify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240968841,"owners_count":19886382,"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":"2024-11-11T15:44:27.930Z","updated_at":"2025-11-22T00:00:49.592Z","avatar_url":"https://github.com/Tarabyte.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ifyify [![Build Status](https://travis-ci.org/Tarabyte/ifyify.svg?branch=master)](https://travis-ci.org/Tarabyte/ifyify.svg?branch=master)\n======\n\u003e transitive verb; derivation\n\n\u003e To create a new word by adding the suffix \"-ify\" to another word\n\nCollection of non-standard functional utils. You won't find `curry`, `bind` and their friends here. Seeking for those take a look at [Lo Dash](http://lodash.com/) or [Underscore](http://underscorejs.org/).\n\n## How to install\n```\n$ npm install ifyify --save\n```\n\n## Usage\n```javascript\nvar ify = require('ifyify');\n```\n\n### Callbackify\nConverts a function to continuation style. `function(err, arg1, arg2, ..., next)`\n\n- The first argument: error flag;\n- The last argument: next callback (if is of type function);\n- Everything in between is considered to be the function arguments.\n\n```javascript\nfunction add(a, b) {\n    return a + b;\n}\n\nvar wrapped = ify.callbackify(add);\n\nwrapped(false, 1, 2, function(err, res) {\n    console.log(res);\n}); //logs 3\n\n```\n\n### Factorify\nConverts a constructor to a factory that can be called w/o the `new` operator. Also provides `many` method that allows to create multiple instances from a given array of arguments.\n\n```javascript\nfunction Person(name, age) {\n    this.name = name;\n    this.age = age;\n}\n\nPerson.prototype.sayHi = function() {\n    console.log('Hi ' + this.name);\n};\n\n//lets ditch the 'new' keyword\nvar personFactory = ify.factorify(Person);\n\n//now we can create instances without new\nvar joe = personFactory('Joe', 27);\njoe.sayHi(); //logs \"Hi Joe\"\n\n//and even more\n//now we can create an array of instances using .many\nvar people = personFactory.many([['Joe', 27], ['Ann', 31], ['Nicola', 100]]);\npeople[2].sayHi(); //logs \"Hi Nicola\"\n\n```\n\n### Chainify\nConverts a function or an object to chainable style. Given function or object's methods will return the context it was called with.\n\n```javascript\nvar config = {\n    setA: function(a) {\n        this.a = a;\n    },\n    \n    setB: function(b) {\n        this.b = b;\n    }\n},\n    configurable = ify.chainify(config);\n    \nconfigurable.setA(10).setB('B');\n```\n\n`Chainify` checks a function source code for having `return` statements in it. If there is any the given function would remain untouched.\n\n```javascript\nvar config = {\n    getA: function() {\n        return 'a';\n    }\n}, \n    configurable = ify.chainify(config);\n\nconfigurable.getA(); //'a'\n```\n\nIf you have hybrid functions i.e. acting as a getter or setter `chainify` allows to use runtime checking if a function has returned anything (non undefined).\n\n```javascript\nvar config = {\n    a: function(a) {\n        if(a === undefined) { //getter mode\n            return this._a;\n        }\n        \n        this._a = a; //setter mode\n    }\n}, \n    configurable = ify.chainify(config, true); //dynamic checking\n\nconfigurable.a(10).a(); //10\n```\n\n###Arrayify\nA small collection of wrappers for array methods:\n\n- `sortify` sorts a given array\n- `filterify` filters a given array\n- `foreachify` applies function to every element\n- `everyify` checks if a predicate holds for every element\n- `someify` checks if a predicate holds for any element\n- `reduceify` reduces a given array\n- `mapify` maps a given array\n\n```javascript\n//sorting\nvar sortNumerically = ify.sortify(function(a, b) {\n    return a - b;\n});\n\nvar sorted = sortNumerically([1.1, 2, 1, 0.7, 1.5, 3]); //[0.7, 1, 1.1, 1.5, 2, 3]\n\n//filtering\nvar clean = ify.filterify(Boolean);\n\nvar cleaned = clean([1, 0, false, \"2\", undefined]); //[1, \"2\"]\n\n//maping\nvar square = ify.mapify(function(x) {\n    return x * x;\n});\n\nvar squared = square([1, 2, 3]); // [1, 4, 9]\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarabyte%2Fifyify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarabyte%2Fifyify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarabyte%2Fifyify/lists"}