# @kiruse/domops

> A minimalist's interpretation of jQuery for DOM traversal & manipulation only.

Latest version **0.1.5** (published 2021-09-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @kiruse/domops
pnpm add @kiruse/domops
yarn add @kiruse/domops
bun add @kiruse/domops
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2021-09-30 |
| First published | 2021-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 83.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kiruse |
| Maintainers | kiruse |
| Keywords | jquery, DOM, traversal, manipulation |

## Links

- npm: https://www.npmjs.com/package/@kiruse/domops
- Repository: https://github.com/Kiruse/domops.js
- Homepage: https://github.com/Kiruse/domops.js#readme
- Issues: https://github.com/Kiruse/domops.js/issues
- npm.io page: https://npm.io/package/@kiruse/domops

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2021-09-30
- 0.1.4 — 2021-09-27
- 0.1.3 — 2021-09-27
- 0.1.1 — 2021-09-05
- 0.1.0 — 2021-08-31

## README

# domops.js
A minimalist's interpretation of jQuery for DOM traversal &amp; manipulation.

- [domops.js](#domopsjs)
- [setup](#setup)
- [embedding](#embedding)
- [usage](#usage)
  - [web scraping with puppeteer](#web-scraping-with-puppeteer)
- [license](#license)

# setup

There's different ways to acquire a copy of domops:

* via NPM: `npm i --save domops`
* via Releases

Currently, domops is not deployed to any CDN.


# embedding

**domops** requires a DOM and can thus only be used in a browser-like environment, such as [Electron](https://www.electronjs.org/) or an actual browser.

In the browser, one may include it as such:

```html
<!-- UMD -->
<script src="<path_to_domops>/miniuqery.js"></script>
<script>
    "use strict";
    const $ = domops;
    // ...
</script>

<!-- ESModules -->
<script type="module">
    import $ from './path_to/domops.esm.js';
    // ...
</script>
```

Personally, I prefer packaging it with [Webpack](https://webpack.js.org) or other web bundlers. For this, you'd simply import it like so:

```javascript
// using ESModules
import domops from 'domops';

// using CommonJS
const domops = require('domops');
```

And the bundler will handle the rest.


# usage

*TODO*

## web scraping with puppeteer
Unfortunately, domops requires a DOM. You may use it with [node-dom](https://www.npmjs.com/package/node-dom), or with the more popular [Puppeteer](https://github.com/puppeteer/puppeteer/). While the former is suited for an assortment of tasks, *Puppeteer* is certainly more thoroughly tested and will be able to handle any task that its associated Chrome version can - albeit at the cost of increased complexity. *domops*'s unit tests are written with *Puppeteer*.

**Example**
In node:
```javascript
const puppeteer = require('puppeteer');

(async function() {
    const browser = await puppeteer.launch();
    const context = browser.defaultBrowserContext();
    const page    = await context.newPage();
    
    // load web page by URL - include protocol
    await page.goto('https://google.com');
    
    // inject domops library via URL or local file path
    await page.addScriptTag({url: '<url_to_domops>'});
    await page.addScriptTag({path: './node_modules/domops/domops.js'});
    
    const logosize = await page.evaluate(() => {
        // execute web scraping code in the context of the browser page
        const $logo = domops('#hplogo');
        return {
            width:  parseFloat($logo.style('width')[0]),
            height: parseFloat($logo.style('height')[0]),
        }
    });
})();
```

# license

MIT License

Copyright (c) 2021 Kiruse

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---
_Source: https://npm.io/package/@kiruse/domops · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
