Skip to content

Commit 6d68b8e

Browse files
author
Pankaj Doharey
committed
Updates version and makes ES6 compatible
1 parent dd138d6 commit 6d68b8e

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A lightweight (~3KB minified) library that combines the power of jQuery-like DOM
66
## Installation
77

88
```bash
9-
npm install _query-js
9+
npm install underquery
1010
```
1111

1212
## Core Usage
@@ -37,7 +37,15 @@ _('.button')
3737

3838
### ES6 Module
3939
```javascript
40-
import _ from '_query-js';
40+
41+
// ES6 import
42+
import _ from 'underquery';
43+
44+
// CommonJS require
45+
const _ = require('underquery');
46+
47+
// Browser script tag
48+
<script src="node_modules/underquery/dist/_query.min.js"></script>
4149
```
4250

4351
## Quick Examples

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
{
22
"name": "underquery",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A lightweight jQuery + Underscore inspired library for DOM manipulation and collection handling",
55
"main": "dist/_query.min.js",
6-
"module": "src/_query.js",
6+
"module": "dist/_query.js",
7+
"exports": {
8+
".": {
9+
"import": "./dist/_query.js",
10+
"require": "./dist/_query.min.js"
11+
}
12+
},
713
"files": [
814
"dist",
915
"README.md"
1016
],
1117
"scripts": {
18+
"build": "mkdir -p dist && cp src/_query.js dist/ && cp src/_query.min.js dist/",
19+
"prepublishOnly": "npm run build"
1220
},
1321
"keywords": [
1422
"dom",
@@ -21,13 +29,5 @@
2129
"lightweight"
2230
],
2331
"author": "Your Name <[email protected]>",
24-
"license": "MIT",
25-
"repository": {
26-
"type": "git",
27-
"url": "git+https://github.com/metacritical/_Q"
28-
},
29-
"bugs": {
30-
"url": "https://github.com/metacritical/_Q/issues"
31-
},
32-
"homepage": "https://github.com/metacritical/_Q#readme"
32+
"license": "MIT"
3333
}

src/_query.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
constructor() {
2-
3-
} _ = (function() {
1+
const _ = (function() {
42
/**
53
* Main Query constructor function
64
* @param {string|array|object} input - Input selector string, array or object
@@ -268,9 +266,22 @@ constructor() {
268266
Q.VERSION = '1.0.0';
269267
Q.NAME = '_Query';
270268

271-
//_ and _Q globally callable fn.
272-
window._ = Q;
273-
window._Q = Q;
269+
//_ and _Q globally
270+
// window._ = Q;
271+
// window._Q = Q;
274272

275273
return Q;
276274
})();
275+
276+
277+
// ES6 module Export support.
278+
if (typeof module !== 'undefined' && module.exports) {
279+
module.exports = Q;
280+
} else if (typeof define === 'function' && define.amd) {
281+
define(function() { return Q; });
282+
} else if (typeof window !== 'undefined') {
283+
window._ = Q;
284+
window._Q = Q;
285+
}
286+
287+
export default Q;

0 commit comments

Comments
 (0)