{"id":13657698,"url":"https://github.com/WebReflection/caller-of","last_synced_at":"2025-04-24T08:30:33.780Z","repository":{"id":6973255,"uuid":"8226379","full_name":"WebReflection/caller-of","owner":"WebReflection","description":"The tiniest yet most powerful JS utility ever :D","archived":false,"fork":false,"pushed_at":"2015-04-01T23:54:41.000Z","size":372,"stargazers_count":104,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T05:23:41.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebReflection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-15T21:18:33.000Z","updated_at":"2025-01-06T18:51:17.000Z","dependencies_parsed_at":"2022-09-01T06:01:44.184Z","dependency_job_id":null,"html_url":"https://github.com/WebReflection/caller-of","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/WebReflection%2Fcaller-of","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcaller-of/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcaller-of/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcaller-of/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/caller-of/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250591862,"owners_count":21455449,"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-08-02T05:00:48.835Z","updated_at":"2025-04-24T08:30:33.516Z","avatar_url":"https://github.com/WebReflection.png","language":"HTML","readme":"caller-of\n=========\n\nThe tiniest yet most powerful JS utility ever :D\n\n```JavaScript\n/** WTFPL Style License */\nfunction callerOf(c) {return c.call.bind(c)}\n```\n\n### What Does Above Code Do\nHere is what we usually do\n```JavaScript\nobject.hasOwnProperty(key)\n```\nHere is what `callerOf` create\n```JavaScript\nhasOwnProperty(object, key)\n```\nso we can borrow any method at any time and reuse it in a minifier friendly way.\n\n```JavaScript\nvar bind = callerOf(Function.bind);\n\n// easy log\nvar log = bind(console.log, console);\nlog('it works');\n\n// common borrowed methods\nvar\n  has = callerOf({}.hasOwnProperty),\n  whoIs = callerOf({}.toString),\n  forEach = callerOf([].forEach),\n  slice = callerOf([].slice);\n\nhas({a:1}, \"a\"); // true\nhas({a:1}, \"toString\"); // false\n\nwhoIs([]);    // \"[object Array]\"\nwhoIs(false); // \"[object Boolean]\"\n\nslice(document.querySelectorAll(\"*\")); // array\n(function (obj){\n  var args = slice(arguments, 1);\n}());\n\nforEach(document.getElementsByTagName(\"body\"), log);\n```\n\n### Compatibility\nEvery JavaScript engine I know, included IE.\n\nFor *node.js* simply `npm install caller-of` then `var callerOf = require('caller-of')`\n\n### What If No Function.prototype.bind\nYou can use this tiny yet working polyfill ^_^\n```JavaScript\n// 139 bytes gzipped\n/*! (C) WebReflection, Mit Style License */\n(function (P) {\n  'use strict';\n  if (!P.bind) {\n    P.bind = function (s) {\n      var\n        c = this,\n        l = [].slice,\n        a = l.call(arguments, 1);\n      return function bind() {\n        return c.apply(s, a.concat(l.call(arguments)));\n      };\n    };\n  }\n}(Function.prototype));\n```","funding_links":[],"categories":["HTML"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebReflection%2Fcaller-of","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWebReflection%2Fcaller-of","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWebReflection%2Fcaller-of/lists"}