{"id":28223882,"url":"https://github.com/ngarbezza/oow","last_synced_at":"2025-06-11T19:30:22.751Z","repository":{"id":45451489,"uuid":"148794310","full_name":"ngarbezza/oow","owner":"ngarbezza","description":"An experiment to make JS more object-oriented. NPM package: @pmoo/oow","archived":false,"fork":false,"pushed_at":"2024-09-26T09:54:16.000Z","size":134,"stargazers_count":4,"open_issues_count":15,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-18T08:11:21.630Z","etag":null,"topics":["hacktoberfest","javascript","oop","polymorphism"],"latest_commit_sha":null,"homepage":"","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/ngarbezza.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-09-14T13:43:17.000Z","updated_at":"2024-09-26T09:53:42.000Z","dependencies_parsed_at":"2024-02-13T00:25:17.064Z","dependency_job_id":"64958bf3-3fe9-40b1-9aba-bad23c609538","html_url":"https://github.com/ngarbezza/oow","commit_stats":{"total_commits":102,"total_committers":6,"mean_commits":17.0,"dds":"0.11764705882352944","last_synced_commit":"b736ed0072e68f38ef2dfbefa38f1ac28e070bdf"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ngarbezza/oow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngarbezza%2Foow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngarbezza%2Foow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngarbezza%2Foow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngarbezza%2Foow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngarbezza","download_url":"https://codeload.github.com/ngarbezza/oow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngarbezza%2Foow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259325231,"owners_count":22841042,"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":["hacktoberfest","javascript","oop","polymorphism"],"created_at":"2025-05-18T08:10:29.176Z","updated_at":"2025-06-11T19:30:22.741Z","avatar_url":"https://github.com/ngarbezza.png","language":"JavaScript","readme":"# OOW\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nAn \"Object-Oriented way\" for JS (methods that should exist by default). The idea is to add more OO\nexperience, especially suited for teaching OOP. **Not intended for production usage.**\n\n## Installation\n\n`npm install @pmoo/oow`\n\n**Supported Node versions**: 18.x or higher (versions with active and security support\nlisted [here](https://endoflife.date/nodejs))\n\n## Extensions\n\n### Summary\n\n| object or objects affected  | class or instance | extension method             | comment                                                                                                             |\n|:----------------------------|:------------------|:-----------------------------|:--------------------------------------------------------------------------------------------------------------------|\n| `Object`                    | instance          | `childResponsibility()`      | mark a method as _abstract_ (to be used on objects)                                                                 |\n|                             |                   | `subclassResponsibility()`   | mark a method as _abstract_ (to be used on classes)                                                                 |\n|                             |                   | `class()`                    | returns the receiver's class                                                                                        |\n|                             |                   | `isString()`                 | `true` if the receiver is a `String`, `false` otherwise                                                             |\n| `Function`                  | instance          | `value(...args)`             | evaluates the function with the given arguments, equivalent to `apply` with the first argument being `undefined`    |\n|                             |                   | `new(...args)`               | to be able to write `Class.new()` as equivalent to `new Class()`                                                    |\n| `Date`                      | class             | `today()`                    | returns today's date                                                                                                |\n|                             |                   | `tomorrow()`                 | returns tomorrow's date                                                                                             |\n|                             |                   | `yesterday()`                | returns yesterday's date                                                                                            |\n|                             | instance          | `day()`                      | returns the day number                                                                                              |\n|                             |                   | `monthNumber()`              | returns the month number (from 1 to 12)                                                                             |\n|                             |                   | `year()`                     | returns the year number (4 digits)                                                                                  |\n| `Array`                     | class             | `with(...objects)`           | returns a new instance with the given objects                                                                       |\n|                             | instance          | `add(anObject)`              | adds one element, equivalent to `push(anObject)`                                                                    |\n|                             |                   | `remove(anObject)`           | removes an element from the collection                                                                              |\n|                             |                   | `equals(anArray)`            | equality comparison (elements one by one)                                                                           |\n|                             |                   | `clear()`                    | removes all the elements                                                                                            |\n| `String`                    | instance          | `filter(condition)`          | filters letters that match the given condition                                                                      |\n|                             |                   | `forEach(function)`          | iterates over every letter evaluating the given function                                                            |\n|                             |                   | `equals(aString)`            | equality comparison, equivalent to `===`                                                                            |\n|                             |                   | `reverse()`                  | returns the reversed version of the receiver                                                                        |\n| `Set`                       | class             | `with(...objects)`           | returns a new instance with the given objects                                                                       |\n|                             | instance          | `dimension()`                | returns the collection size, equivalent to calling the `size` property                                              |\n|                             |                   | `includes(anObject)`         | check for element inclusion, equivalent to `has(anObject)`                                                          |\n|                             |                   | `equals(aSet)`               | equality comparison, based on mutual inclusion                                                                      |\n|                             |                   | `filter(condition)`          | filters all the elements matching the given condition                                                               |\n|                             |                   | `map(function)`              | returns a new `Set` with the result of applying a function to every element in the collection                       |\n|                             |                   | `remove(anObject)`           | removes an object, equivalent to `delete(anObject)`                                                                 |\n|                             |                   | `union(aSet)`                | returns a new `Set` representing the union of the receiver and the argument                                         |\n|                             |                   | `intersection(aSet)`         | returns a new `Set` representing the intersection of the receiver and the argument                                  |\n| `Array` and `Set`           | instance          | `compact()`                  | returns a new instance without `null` and `undefined` values                                                        |\n|                             |                   | `removeAll()`                | removes all the elements, equivalent to `clear()`                                                                   |\n| `Array` and `String`        | instance          | `at(position)`               | returns the n-th element, equivalent to using `collection[n]`                                                       |\n|                             |                   | `dimension()`                | returns the collection size, equivalent to call the `length` property                                               |\n|                             |                   | `first()`                    | returns the first element                                                                                           |\n|                             |                   | `second()`                   | returns the second element                                                                                          |\n|                             |                   | `third()`                    | returns the third element                                                                                           |\n|                             |                   | `last()`                     | returns the last element                                                                                            |\n|                             |                   | `take(n)`                    | returns a new collection with the first n elements                                                                  |\n|                             |                   | `drop(n)`                    | returns a new collection discarding the first n elements                                                            |\n|                             |                   | `occurrencesOf(anObject)`    | returns how many times an object appears in the collection                                                          |\n|                             |                   | `allButFirst()`              | returns a copy of the collection except for the first element                                                       |\n|                             |                   | `allButLast()`               | returns a copy of the collection except for the last element                                                        |\n| `Array`, `Set` and `String` | instance          | `isEmpty()`                  | returns if the collection is empty                                                                                  |\n|                             |                   | `notEmpty()`                 | returns if the collection is not empty                                                                              |\n|                             |                   | `any(condition)`             | returns `true` if any element matches the given condition                                                           |\n|                             |                   | `all(condition)`             | returns `true` if all elements match the given condition                                                            |\n|                             |                   | `includesAllOf(collection)`  | returns `true` if the collection includes all the elements from the argument                                        |\n|                             |                   | `count(condition)`           | returns how many elements match the given condition                                                                 |\n|                             |                   | `atRandom()`                 | returns a random element                                                                                            |\n|                             |                   | `sample()`                   | returns a random element, equivalent to `atRandom()`                                                                |\n|                             |                   | `asArray()`                  | returns a new `Array` with all the collection elements                                                              |\n|                             |                   | `asSet()`                    | returns a new `Set` with all the collection elements                                                                |\n| `Number`                    | instance          | `isDivisibleBy(aNumber)`     | returns `true` if the receiver is divisible by the argument                                                         |\n|                             |                   | `isOdd()`                    | returns `true` if the receiver is odd                                                                               |\n|                             |                   | `isEven()`                   | returns `true` if the receiver is even                                                                              |\n|                             |                   | `isPositive()`               | returns `true` if the receiver is positive                                                                          |\n|                             |                   | `isNegative()`               | returns `true` if the receiver is negative                                                                          |\n|                             |                   | `isBetween(minimum,maximum)` | returns `true` if the receiver is between the first and the second arguments                                        |\n|                             |                   | `timesRepeat(aFunction)`     | call aFunction as many times as the receiver of the message                                                         |\n\n\nTo see how all the available extensions are being used, please have a look at the tests inside the `test` folder.\n\n### Collections\n\n`Array`, `String` and `Set` are classes that have very few methods in common, even though\nthey are all collections. For instance, `Set` has `size` and Array has `length`. So this\nlibrary defines some common behavior to make sure we can have more polymorphism.\n\nMost of the added message names are inspired by Smalltalk (`isEmpty`, `includesAllOf`, `at`)\nand Ruby (`take`, `drop`, `compact`).\n\n#### Polymorphism achieved so far\n\nAmong many of the messages added to the collection protocols, these are the messages that some collections have by default but others don't:\n\n* `add(obj)` works for `Array` and `Set` (we added the `Array` version)\n* `includes(obj)` works for `Array` and `Set` (we added the `Set` version)\n* `filter(condition)` works for every collection (we added the `String` and `Set` versions)\n* `forEach(function)` works for every collection (we added the `String` version)\n* `reverse()` works for `Array` and `String` (we added the `String` version)\n* `clear()` works for `Array` and `Set` (we added the `Array` version)\n\n### `Date`\n\nWorking with `Date` is not so easy so there are also helper methods like `monthNumber` that\nreturns a number from 1 to 12.\n\n## New Objects\n\n### `Point`\n\n`Point` class represents an (x, y) pair. You can access its parts by sending `x()` and `y()` messages. Instances of this class are immutable.\n\n### `DayOfMonth`\n\n`DayOfMonth` represents a day in a month, not specific to a year, like \"November 9th\". The `day()` and `monthNumber()` messages can be used to access the information. Instances of this class are immutable. \n\n### `MonthOfYear`\n\n`MonthOfYear` represents a month in a specific year like \"May of 2020\". The `monthNumber()` and `year()` messages can be used to access the information. Instances of this class are immutable. \n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/federicostulich\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/51274964?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003efedericostulich\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ngarbezza/oow/commits?author=federicostulich\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/ngarbezza/oow/commits?author=federicostulich\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/davidgonzalezjs\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/31224430?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003edavidgonzalezjs\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ngarbezza/oow/commits?author=davidgonzalezjs\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/ngarbezza/oow/commits?author=davidgonzalezjs\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/ngarbezza/oow/commits?author=davidgonzalezjs\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngarbezza%2Foow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngarbezza%2Foow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngarbezza%2Foow/lists"}