Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/8area8/domstrict
[ npm library ] wrapper for the "getElement" and "querySelector" methods. Return the element or an error.
https://github.com/8area8/domstrict
npm personnal typescript
Last synced: 3 days ago
JSON representation
[ npm library ] wrapper for the "getElement" and "querySelector" methods. Return the element or an error.
- Host: GitHub
- URL: https://github.com/8area8/domstrict
- Owner: 8area8
- License: mit
- Created: 2019-04-21T17:57:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-03T15:40:13.000Z (over 5 years ago)
- Last Synced: 2024-09-21T13:18:24.059Z (about 2 months ago)
- Topics: npm, personnal, typescript
- Language: TypeScript
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# domstrict
wrapper for the "getElement" and "querySelector" methods. Return the element or an error.
## News
Add the `$base` parameter for query and queryAll.
**Todo**: Create tests and update the documentation.## Installation
```sh
npm install @8area8/domstrict --save
```## Usage
### Javascript
```javascript
var get = require("@8area8/domstrict");
var $element = get.id("foo");
``````sh
- Returns an HTMLElement OR throws an Error.
```### TypeScript
```typescript
import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
``````sh
- Returns an Array OR throws an Error.
```## API
```typescript
class Get {
static id(idName: string): HTMLElement;
static class(idName: string): Element[];
static query(selector: string): Element;
static queryAll(selector: string): Element[];
}
``````typescript
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
``````typescript
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
``````typescript
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
``````typescript
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]
```## Test
```sh
npm run test
```