{"id":17482916,"url":"https://github.com/creationix/proto","last_synced_at":"2025-04-10T02:43:41.031Z","repository":{"id":843107,"uuid":"567594","full_name":"creationix/proto","owner":"creationix","description":"Adds nice utilities to Object.prototype for JavaScript using Object.defineProperty","archived":false,"fork":false,"pushed_at":"2010-08-13T23:59:59.000Z","size":96,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T04:14:01.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/creationix.png","metadata":{"files":{"readme":"README.markdown","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":"2010-03-18T01:45:50.000Z","updated_at":"2023-09-08T16:26:33.000Z","dependencies_parsed_at":"2022-08-16T11:10:08.992Z","dependency_job_id":null,"html_url":"https://github.com/creationix/proto","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Fproto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Fproto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Fproto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Fproto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creationix","download_url":"https://codeload.github.com/creationix/proto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248145365,"owners_count":21055113,"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-10-18T23:47:48.051Z","updated_at":"2025-04-10T02:43:40.999Z","avatar_url":"https://github.com/creationix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proto\n\nThis simple js library adds four functions to Object.prototype.  Since this only modifies global objects and doesn't export any structures, you don't need the return value when calling `require('proto')`.\n\n## Object.prototype\n\nAll functions added to `Object.prototype` are usable from any object in JavaScript.\n\n### Object.prototype.forEach(callback[, thisObject])\n\nThis is the most useful of the additions.  It allows you to forEach over an `Object` instance's local properties and values just like you can already do with `Array` instances.\n\n    require('proto');\n    ({name: \"Tim\", age: 28}).forEach(function (value, key) {\n      console.log(key + \" = \" + JSON.stringify(value));\n    });\n\n### Object.prototype.map(callback[, thisObject])\n\nThis works like forEach, except returns an `Array` instance with the returned values of the function calls.\n\n    require('proto');\n    var pairs = ({name: \"Tim\", age: 28}).map(function (value, key) {\n      return key + \" = \" + value;\n    });\n    // pairs is [\"name = Tim\", \"age = 28\"]\n\n### Object.prototype.new(args...)\n\nCreates a new version of the current object and calls it's `initialize` function if one exists with the same arguments passed to new.\n\n    require('proto');\n    var Rectangle = {\n      initialize: function initialize(width, height) {\n        this.width = width;\n        this.height = height;\n      },\n      get area() {\n        return this.width * this.height;\n      }\n    };\n\n    var rect = Rectangle.new(2, 4);\n    console.log(rect.area);\n\n### Object.prototype.extend(newObject)\n\nSets the current object as the prototype to the passed in object and returns the new passed in object.\n\n    // Assuming the code from above\n    var Square = Rectangle.extend({\n      initialize: function initialize(side) {\n        this.width = side;\n        this.height = side;\n      }\n    });\n    var square = Square.new(15);\n    console.log(square.area);\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreationix%2Fproto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreationix%2Fproto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreationix%2Fproto/lists"}