Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A feathery (light), alacritous (fast), extensible DOM abstraction. (Partly based on PlainJS. And faster than jQuery)
At its core it's nothing but a selector that will return an array of HTMLElement
's:
var $popup = dusk('#popup'); // will return a single-element array
var $rows = dusk('.my-table tr'); // will return an array
var $oops = dusk('.non-existing-class'); // will return an empty array
This means it has the same collection of methods as a native array. Pretty cool. And you can pass dusk some strange things as well:
var $itself = dusk(dusk('div')); // dusk recognizes itself
var $list = dusk(document.querySelectorAll('div')); // it turns NodeList's and HTMLCollection's into arrays
var $context = dusk('.class', '#context'); // and it can use a context
dusk implements the Universal Module Definition (UMD), and resides on NPM so that you can really use it any way you want. To include it in your project:
Get it from https://github.com/mjsarfatti/dusk/blob/master/dist/dusk.js
, then include it with:
HTML
<script src="path/to/dusk.js"></script>
AMD
require(['path/to/dusk.js'], function(dusk) {
// ...
});
CommonJS
var dusk = require('path/to/dusk.js');
$ npm install --save dusk
, then:
CommonJS + NPM
var dusk = require('dusk');
ECMAScript 2015
import dusk from 'dusk';
At the moment it ships only one, static, method.
(shamelessly stolen from jQuery)
dusk.DOMReady(function() {
// something to execute on DOM ready
});
But it's already apt to be extended!
const $demo = dusk('#demo');
dusk.fn.plugin1 = function () {
// do something with `this` (remember, it's an array)
return this;
};
dusk.fn.plugin2 = function () {
// do something with `this`
return this;
};
$demo.plugin1().plugin2();
Version 1.1 will include the following:
Events
Classes
It will also include polyfills for matches
and closest
.
This will cover 95% of the use cases. And remember, for all the rest you have PlainJS and the Fetch API.
Ps: of course, if you absolutely need .thirdChild()
you can easily extend the core. In fact, that is the whole purpose of this: a super-lightweight extensible DOM abstraction.
At the moment dusk has been tested on
Version 1.1 will be tested against IE9+ and mobile browsers as well.
dusk is released under the MIT license.
FAQs
A feathery, alacritous DOM abstraction, partly based on PlainJS
The npm package dusk receives a total of 0 weekly downloads. As such, dusk popularity was classified as not popular.
We found that dusk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.