{"id":15389500,"url":"https://github.com/jgarber623/cashcash","last_synced_at":"2025-10-22T21:22:53.936Z","repository":{"id":6101055,"uuid":"54781112","full_name":"jgarber623/CashCash","owner":"jgarber623","description":"A very small DOM library inspired by jQuery.","archived":false,"fork":false,"pushed_at":"2025-02-01T02:39:00.000Z","size":817,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-23T16:03:43.520Z","etag":null,"topics":["dom","dom-library","dom-selection","javascript","jquery","queryselectorall"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@jgarber/cashcash","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/jgarber623.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-26T13:49:17.000Z","updated_at":"2025-01-03T01:28:42.000Z","dependencies_parsed_at":"2023-10-15T12:30:43.166Z","dependency_job_id":"2efa78ec-730e-4456-b6a5-35f7f13f9819","html_url":"https://github.com/jgarber623/CashCash","commit_stats":{"total_commits":262,"total_committers":2,"mean_commits":131.0,"dds":"0.39312977099236646","last_synced_commit":"11f060b52e3e6ca3fd632eedc92182f91665635e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgarber623%2FCashCash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgarber623%2FCashCash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgarber623%2FCashCash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgarber623%2FCashCash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgarber623","download_url":"https://codeload.github.com/jgarber623/CashCash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241175755,"owners_count":19922569,"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":["dom","dom-library","dom-selection","javascript","jquery","queryselectorall"],"created_at":"2024-10-01T15:01:53.785Z","updated_at":"2025-10-22T21:22:53.931Z","avatar_url":"https://github.com/jgarber623.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!IMPORTANT]\n\u003e This project has moved to [codeberg.org/jgarber/CashCash](https://codeberg.org/jgarber/CashCash).\n\n# CashCash\n\n**A very small DOM library inspired by [jQuery](https://jquery.com) that smooths over some of the rough edges in JavaScript's native DOM querying methods.**\n\n[![npm](https://img.shields.io/npm/v/@jgarber/cashcash.svg?logo=npm\u0026style=for-the-badge)](https://www.npmjs.com/package/@jgarber/cashcash)\n[![Downloads](https://img.shields.io/npm/dt/@jgarber/cashcash.svg?logo=npm\u0026style=for-the-badge)](https://www.npmjs.com/package/@jgarber/cashcash)\n[![Build](https://img.shields.io/github/actions/workflow/status/jgarber623/CashCash/ci.yml?branch=main\u0026logo=github\u0026style=for-the-badge)](https://github.com/jgarber623/CashCash/actions/workflows/ci.yml)\n\n\u003e [!NOTE]\n\u003e CashCash is feature complete and will only be updated to address bugs or security issues.\n\n### Key Features\n\n- Uses JavaScript's native [`querySelectorAll`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) method\n- Dependency-free\n- JavaScript module (ESM) support\n\n## Getting CashCash\n\nYou've got a couple options for adding CashCash to your project:\n\n- [Download a release](https://github.com/jgarber623/CashCash/releases) from GitHub and do it yourself _(old school)_.\n- Install using [npm](https://www.npmjs.com/package/@jgarber/cashcash): `npm install @jgarber/cashcash --save`\n- Install using [Yarn](https://yarnpkg.com/en/package/@jgarber/cashcash): `yarn add @jgarber/cashcash`\n\n## Usage\n\nCashCash takes a similar approach to DOM selection as the aforementioned (and insanely popular) jQuery.\n\n```js\nCashCash(\"p\");          // select all `\u003cp\u003e`s on a page\nCashCash(\"#main\");      // select the element with the ID of `main`\nCashCash(\"p\", \"#main\"); // select all `\u003cp\u003e`s within an element with the ID of `main`\n```\n\nCashCash accepts two arguments: a `selector` (a string) and an optional `context` (a string or an `HTMLElement`). For basic DOM selection, you should be fine passing in any supported CSS selector. For more advanced usage, the second `context` argument might prove useful:\n\n```js\nconst divs = CashCash(\"div\");              // select all `\u003cdiv\u003e`s on a page\nconst paragraphs = CashCash(\"p\", divs[0]); // select all `\u003cp\u003e`s within the first `\u003cdiv\u003e`\n```\n\nUnder the covers, CashCash uses the browser's native [`querySelectorAll`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) method and therefore supports the same CSS selectors.\n\nWhen selecting DOM nodes based on the provided `selector` string, CashCash will store references to those selected DOM elements on itself in an array-like fashion for easy access to individual DOM nodes.\n\nGiven the following markup:\n\n```html\n\u003cp\u003eParagraph 1\u003c/p\u003e\n\u003cp\u003eParagraph 2\u003c/p\u003e\n\u003cp\u003eParagraph 3\u003c/p\u003e\n\u003cp\u003eParagraph 4\u003c/p\u003e\n\u003cp\u003eParagraph 5\u003c/p\u003e\n```\n\nYou can do the following:\n\n```js\nconst paragraphs = CashCash(\"p\");\n\nparagraphs.forEach(paragraph =\u003e console.log(paragraph)); // logs `\u003cp\u003eParagraph 1\u003c/p\u003e`, `\u003cp\u003eParagraph 2\u003c/p\u003e`, etc.\n```\n\n### Collection Properties\n\n#### `length`\n\nFor all queries (valid or otherwise), CashCash will return the length (defaulting to `0`) of the queried elements.\n\n```js\nconst thisManyBodyElements = CashCash(\"body\").length; // returns `1`\n```\n\n#### `selector`\n\nAs best as possible, CashCash keeps track of the selector used in a given query, making it available to you by calling:\n\n```js\nconsole.log(CashCash(\"p\").selector);                // logs the string `p`\nconsole.log(CashCash(\"p\", \"#container\").selector);  // logs the string `#container p`\nconsole.log(CashCash(\"p\", document.body).selector); // logs the string `p`\n```\n\n#### `context`\n\nCashCash makes available a reference to the context for a given query (if one is provided and that context is an `HTMLElement`). If no context is given (or if the given context is a string), CashCash will default to `HTMLDocument`.\n\n```js\nconsole.log(CashCash(\"p\").context);                // logs a reference to `HTMLDocument`\nconsole.log(CashCash(\"p\", \"#container\").context);  // logs a reference to `HTMLDocument`\nconsole.log(CashCash(\"p\", document.body).context); // logs a reference to `\u003cbody\u003e`\n\nconst container = CashCash(\"#container\");\n\nconsole.log(CashCash(\"p\", container[0]).context); // logs a reference to `\u003cdiv id=\"container\"\u003e`\n```\n\n### Example\n\nFor a full-featured CashCash demonstration, check out [the demo page](https://jgarber623.github.io/CashCash/example/) and [the example file](https://github.com/jgarber623/CashCash/blob/main/example/index.html).\n\n## Tips and Tricks\n\n### Mimicking jQuery\n\nIf you want to cut down on some typing (and potentially confuse your teammates), you can reassign `CashCash` to `$` to mimic jQuery:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { default as $ } from \"@jgarber/cashcash\";\n\n  const paragraphs = $(\"p\");\n\n  // …\n\u003c/script\u003e\n```\n\n## Browser Support\n\n**CashCash works in modern browsers.** The library makes use of several new(ish) JavaScript features and, in an effort to remain as lightweight and dependency-free as possible, leaves it up to you to choose whether or not to polyfill features for older browsers.\n\n## Acknowledgments\n\nCashCash is inspired by [jQuery](https://jquery.com) and the many micro DOM libraries it inspired (like [Ken Wheeler](http://kenwheeler.github.io)'s [cash](https://github.com/kenwheeler/cash), for instance).\n\nCashCash is written and maintained by [Jason Garber](https://sixtwothree.org) and is another in a growing line of small, curiously-named JavaScript utilities:\n\n- [RadioRadio](https://github.com/jgarber623/RadioRadio), a very small [PubSub](https://en.wikipedia.org/wiki/Publish–subscribe_pattern) library.\n- [RouterRouter](https://github.com/jgarber623/RouterRouter), a very small routing library extracted from [Backbone's Router](http://backbonejs.org/docs/backbone.html#section-185).\n- [TemplateTemplate](https://github.com/jgarber623/TemplateTemplate), a very small `\u003ctemplate\u003e` manipulation library.\n\n## License\n\nCashCash is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgarber623%2Fcashcash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgarber623%2Fcashcash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgarber623%2Fcashcash/lists"}