{"id":16747472,"url":"https://github.com/roydukkey/holosun","last_synced_at":"2025-03-16T02:24:15.897Z","repository":{"id":52477773,"uuid":"356409470","full_name":"roydukkey/holosun","owner":"roydukkey","description":"A DOM events API with delegation and type declarations.","archived":false,"fork":false,"pushed_at":"2021-08-13T20:27:12.000Z","size":93,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T18:14:10.540Z","etag":null,"topics":["delegation","ecmascript-modules","event-listener"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roydukkey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["roydukkey"]}},"created_at":"2021-04-09T22:09:50.000Z","updated_at":"2021-04-27T19:58:56.000Z","dependencies_parsed_at":"2022-08-25T03:40:31.812Z","dependency_job_id":null,"html_url":"https://github.com/roydukkey/holosun","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/roydukkey%2Fholosun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roydukkey%2Fholosun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roydukkey%2Fholosun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roydukkey%2Fholosun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roydukkey","download_url":"https://codeload.github.com/roydukkey/holosun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814979,"owners_count":20352077,"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":["delegation","ecmascript-modules","event-listener"],"created_at":"2024-10-13T02:10:04.680Z","updated_at":"2025-03-16T02:24:15.294Z","avatar_url":"https://github.com/roydukkey.png","language":"TypeScript","funding_links":["https://github.com/sponsors/roydukkey"],"categories":[],"sub_categories":[],"readme":"\u003c!--- cspell:ignore ecmascript, holosunon, holosunone, holosunany, holosunoff, holosuntrigger ---\u003e\n# Holosun\n\n[![Release Version](https://img.shields.io/npm/v/holosun.svg)](https://www.npmjs.com/package/holosun)\n[![License](https://img.shields.io/badge/License-Apache%202-blue.svg)](https://github.com/roydukkey/holosun/blob/master/LICENSE)\n\nA DOM events API with delegation and type declarations. Holosun is built to remain completely interoperable with the native events API.\n\n## Usage\n\nThe distribution provided at `./dist/holosun.umd.js` can be used directly in the browser, with the API begin namespaced as a `holosun` global variable.\n\nOr, use the package like any other node package:\n\n```js\n// ES6 module syntax\nimport * as holosun from 'holosun';\nimport { on, off } from 'holosun';\n\n// CommonJS syntax\nconst holosun = require('holosun');\nconst { on, off } = require('holosun');\n```\n\nAlteratively, importing TypeScript directly will allow transpiled code to be optimize, including only the required portions of Holosun.\n\n```js\nimport { on, off } from 'holosun/typescript';\n```\n\nNote: this package includes a proper [ECMAScript module](#ecmascript-modules).\n\n## API Summary\n\n| function | description |\n| --- | --- |\n| [`holosun.on()`](#holosunon) | Attach an event listener that will be called whenever a specified event type is delivered to the given target. |\n| [`holosun.one()`](#holosunone) | Attach an event listener that will be called once whenever each of the specified event types are delivered to the given target. |\n| [`holosun.any()`](#holosunany) | Attach an event listener that will be called once whenever any of the specified event types are delivered to the given target. |\n| [`holosun.off()`](#holosunoff) | Detach event listeners of the specified event types from the given target. |\n| [`holosun.trigger()`](#holosuntrigger) | Executes all listeners attached to the given target for the specified event types. |\n\n## API\n\n### holosun.on()\n\n#### `on (target, types, listener[, useCapture | options])`\nAttach an event listener that will be called whenever a specified event type is delivered to the given target.\n\n#### `on (node, selector, types, listener[, useCapture | options])`\nAttach an event listener that will be called whenever a specified event type is delivered to the given node from specific descendants.\n\n##### Parameters\n| parameter | type | description |\n| --- | --- | --- |\n| `target` | [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) | The target on which the event listener is attached. |\n| `node` | [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) | The node on which the event listener is attached. |\n| `selector` | `string` | A selector string to filter the descendants of the given node that trigger the event. |\n| `types` | `string` | A case-sensitive string representing the [event type](https://developer.mozilla.org/en-US/docs/Web/Events)s to listen for. |\n| `listener` | [`EventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventListener) \\|\u003cbr\u003e[`EventListenerObject`](https://developer.mozilla.org/en-US/docs/Web/API/EventListener) \\|\u003cbr\u003e`null` | The object that receives a notification (an object that implements the [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) interface) when an event of a specified type occurs. This must be an object implementing the EventListener interface, or a function. |\n| `useCapture` | `boolean` | Whether or not events of these types will be dispatched to the registered listener before being dispatched to any target beneath it in the DOM tree. |\n| `options` | [`AddEventListenerOptions`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters) | An options object specifying characteristics about the event listener. |\n\n##### Returns\nThe provided listener when successfully attached; otherwise, `undefined`.\n\n### holosun.one()\n\n#### `one (target, types, listener[, useCapture | options])`\nAttach an event listener that will be called once whenever each of the specified event types are delivered to the given target.\n\n#### `one (node, selector, types, listener[, useCapture | options])`\nAttach an event listener that will be called once whenever each of the specified event types are delivered to the given node from specific descendants.\n\n##### Parameters \u0026 Returns\nSame as [`holosun.on()`](#holosunon).\n\n### holosun.any()\n\n#### `any (target, types, listener[, useCapture | options])`\nAttach an event listener that will be called once whenever any of the specified event types are delivered to the given target.\n\n#### `any (node, selector, types, listener[, useCapture | options])`\nAttach an event listener that will be called once whenever any of the specified event types are delivered to the given node from specific descendants.\n\n##### Parameters \u0026 Returns\nSame as [`holosun.on()`](#holosunon).\n\n### holosun.off()\n\n#### `off (target, types)`\nDetach all event listeners of the specified event types from the given target.\n\n#### `off (target, types, listener[, useCapture | options])`\nDetach an event listener of the specified event types from the given target.\n\n#### `off (node, selector, types)`\nDetach all event listeners of the specified event types from the given node for the specified selector.\n\n#### `off (node, selector, types, listener[, useCapture | options])`\nDetach an event listener of the specified event types from the given node for the specified selector.\n\n##### Parameters\n| parameter | type | description |\n| --- | --- | --- |\n| `target` | [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) | The target from which the event listener is detached. |\n| `node` | [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) | The node from which the event listener is detached. |\n| `selector` | `string` | A selector which should match the one used when attaching event listeners. |\n| `types` | `string` | A case-sensitive string representing the [event type](https://developer.mozilla.org/en-US/docs/Web/Events)s to detach. |\n| `listener` | [`EventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventListener) \\|\u003cbr\u003e[`EventListenerObject`](https://developer.mozilla.org/en-US/docs/Web/API/EventListener) \\|\u003cbr\u003e`null` | The event listener to detach from the event target. |\n| `useCapture` | `boolean` | Whether or not the EventListener to be detached is registered as a capturing listener. |\n| `options` | [`EventListenerOptions`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener#parameters) | An options object specifying characteristics about the event listener. |\n\n##### Returns\n`true` when successfully detached at least one listener; otherwise, `false`.\n\n### holosun.trigger()\n\n#### `trigger (target, types[, options][, useCustomEvent])`\nExecutes all listeners attached to the given target for the specified event types.\n\n##### Parameters\n| parameter | type | description |\n| --- | --- | --- |\n| `target` | [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) | The target on which the specified events are executed. |\n| `types` | `string` | A case-sensitive string representing the [event type](https://developer.mozilla.org/en-US/docs/Web/Events)s to execute. |\n| `options` | [`EventInit`](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event#values) \\| [`CustomEventInit`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#parameters) | An options object specifying characteristics about the triggered event. |\n| `useCustomEvent` | `boolean` | Whether or not to trigger an [event](https://developer.mozilla.org/en-US/docs/Web/Events) or a [custom event](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent). |\n\n##### Returns\nA list of tuples, where the first value is the event type and the second is `true`; unless the event is cancelable and at least one of the event listeners, which received the event, called [`Event.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault), the second value is `false`.\n\n## ECMAScript Modules\n\nThis library comes with [ECMAScript Modules](https://www.ecma-international.org/ecma-262/6.0/#sec-modules) (ESM) support for Node.js versions that support it as well as bundlers like [rollup.js](https://rollupjs.org/guide/en/#tree-shaking) and [webpack](https://webpack.js.org/guides/tree-shaking/) (targeting both, Node.js and browser environments).\n\n## CDN Builds\n\n### ECMAScript Modules\nTo load this module directly into modern browsers that [support loading ECMAScript Modules](https://caniuse.com/#feat=es6-module) you can make use of [jspm](https://jspm.org/):\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { on } from 'https://jspm.dev/holosun';\n  on(document, 'click', () =\u003e {\n    window.location.href = 'https://youtu.be/950sXulKXGs?t=10';\n  });\n\u003c/script\u003e\n```\n\n### UMD\nTo load this module directly into older browsers you can use the [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds from any of the following CDNs.\n\nThese CDNs all provide the entire API as a `holosun` global variable:\n\n```html\n\u003cscript\u003e\n  holosun.on(document, 'click', () =\u003e {\n    window.location.href = 'https://youtu.be/950sXulKXGs?t=10';\n  });\n\u003c/script\u003e\n```\n\n#### Using [UNPKG](https://unpkg.com/browse/holosun/dist/)\n```html\n\u003cscript src=\"https://unpkg.com/holosun@latest/dist/holosun.umd.js\"\u003e\u003c/script\u003e\n```\n\n#### Using [jsDelivr](https://cdn.jsdelivr.net/npm/holosun@latest/dist/)\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/holosun@latest/dist/holosun.umd.js\"\u003e\u003c/script\u003e\n```\n\n## Support Limiters\n\nThese are some of the common limiting issues which are not addressed in this library. You might consider using [`core-js`](https://github.com/zloirock/core-js) when building Holosun into a project.\n\n1. `Element.prototype.matches` is not available in IE, however there is a [polyfill](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#polyfill) available for IE9+.\n1. `Map`, `Set`, `WeakMap`, `WeakSet` is not available before IE 11, there are multiple polyfills.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froydukkey%2Fholosun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froydukkey%2Fholosun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froydukkey%2Fholosun/lists"}