Skip to content

Commit 5efff60

Browse files
committed
Rename project to next-job
1 parent 3e6fbe6 commit 5efff60

File tree

5 files changed

+37
-33
lines changed

5 files changed

+37
-33
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# smart-next-tick
1+
# next-job
22

3-
[![npm version](https://badge.fury.io/js/smart-next-tick.svg)](https://badge.fury.io/js/smart-next-tick)
3+
[![Build Status](https://travis-ci.org/cnlon/next-job.svg?branch=master)](https://travis-ci.org/cnlon/next-job)
4+
[![npm version](https://badge.fury.io/js/next-job.svg)](https://badge.fury.io/js/next-job)
45
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
56

67
## Another environment agnostic nextTick polyfill
@@ -14,13 +15,13 @@ To be used in environment agnostic modules that need nextTick functionality.
1415
## Installation
1516

1617
```bash
17-
npm install --save smart-next-tick
18+
npm install --save next-job
1819
```
1920

2021
## Syntax
2122

2223
```
23-
nextTick(func[, context, param1, param2, ...])
24+
nextJob(func[, context, param1, param2, ...])
2425
```
2526

2627
**func**
@@ -37,4 +38,4 @@ Additional parameters which are passed through to `func`.
3738

3839
<hr>
3940

40-
Stealed from [Vue.js](https://github.com/vuejs/vue/blob/dev/src/core/util/env.js#L66-L147) and [next-tick](https://github.com/medikoo/next-tick).
41+
Stealed from [Vue.js](https://github.com/vuejs/vue/blob/dev/src/core/util/next-tick.js) and [next-tick](https://github.com/medikoo/next-tick).

nextTick.mjs nextJob.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var callbacks = []
22
var pending = false
3-
function nextTickHandler () {
3+
function nextJobHandler () {
44
pending = false
55
var length = callbacks.length
66
if (length === 0) {
@@ -12,33 +12,33 @@ function nextTickHandler () {
1212
}
1313
}
1414

15-
var callNextTick
15+
var callNextJob
1616
if (typeof process === 'object'
1717
&& process !== null
1818
&& typeof process['nextTick'] === 'function'
1919
) {
20-
callNextTick = process.nextTick
20+
callNextJob = process.nextTick
2121
} else if (typeof MutationObserver !== 'undefined') {
2222
var a = 'a'
2323
var b = 'b'
2424
var value = a
2525
var commentNode = document.createComment(value)
26-
var observer = new MutationObserver(nextTickHandler)
26+
var observer = new MutationObserver(nextJobHandler)
2727
observer.observe(commentNode, {
2828
characterData: true
2929
})
30-
callNextTick = function () {
30+
callNextJob = function () {
3131
value = value === a ? b : a
3232
commentNode.data = value
3333
}
3434
} else {
35-
callNextTick = function (callback) {
35+
callNextJob = function (callback) {
3636
setTimeout(callback, 0)
3737
}
3838
}
3939

4040

41-
export default function nextTick (callback, context) {
41+
module.exports = function nextJob (callback, context) {
4242
var cb = callback
4343
if (context) {
4444
var args = []
@@ -55,5 +55,5 @@ export default function nextTick (callback, context) {
5555
return
5656
}
5757
pending = true
58-
callNextTick(nextTickHandler)
58+
callNextJob(nextJobHandler)
5959
}

nextTick.js nextJob.mjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var callbacks = []
22
var pending = false
3-
function nextTickHandler () {
3+
function nextJobHandler () {
44
pending = false
55
var length = callbacks.length
66
if (length === 0) {
@@ -12,33 +12,33 @@ function nextTickHandler () {
1212
}
1313
}
1414

15-
var callNextTick
15+
var callNextJob
1616
if (typeof process === 'object'
1717
&& process !== null
1818
&& typeof process['nextTick'] === 'function'
1919
) {
20-
callNextTick = process.nextTick
20+
callNextJob = process.nextTick
2121
} else if (typeof MutationObserver !== 'undefined') {
2222
var a = 'a'
2323
var b = 'b'
2424
var value = a
2525
var commentNode = document.createComment(value)
26-
var observer = new MutationObserver(nextTickHandler)
26+
var observer = new MutationObserver(nextJobHandler)
2727
observer.observe(commentNode, {
2828
characterData: true
2929
})
30-
callNextTick = function () {
30+
callNextJob = function () {
3131
value = value === a ? b : a
3232
commentNode.data = value
3333
}
3434
} else {
35-
callNextTick = function (callback) {
35+
callNextJob = function (callback) {
3636
setTimeout(callback, 0)
3737
}
3838
}
3939

4040

41-
module.exports = function nextTick (callback, context) {
41+
export default function nextJob (callback, context) {
4242
var cb = callback
4343
if (context) {
4444
var args = []
@@ -55,5 +55,5 @@ module.exports = function nextTick (callback, context) {
5555
return
5656
}
5757
pending = true
58-
callNextTick(nextTickHandler)
58+
callNextJob(nextJobHandler)
5959
}

package.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
{
2-
"name": "smart-next-tick",
2+
"name": "next-job",
33
"version": "1.1.0",
44
"description": "Another environment agnostic nextTick polyfill",
5-
"main": "nextTick.js",
6-
"module": "nextTick.mjs",
5+
"main": "nextJob.js",
6+
"module": "nextJob.mjs",
77
"scripts": {
88
"test": "node test.js"
99
},
1010
"keywords": [
11+
"job",
12+
"microtask",
1113
"nextTick",
14+
"MutationObserver",
1215
"setTimeout",
1316
"setImmediate"
1417
],
15-
"author": "lon (https://lon.im)",
16-
"license": "MIT",
17-
"homepage": "https://github.com/cnlon/smart-next-tick#readme",
18+
"homepage": "https://github.com/cnlon/next-job#readme",
1819
"repository": {
1920
"type": "git",
20-
"url": "git+https://github.com/cnlon/smart-next-tick.git"
21+
"url": "git+https://github.com/cnlon/next-job.git"
2122
},
2223
"bugs": {
23-
"url": "https://github.com/cnlon/smart-next-tick/issues"
24-
}
24+
"url": "https://github.com/cnlon/next-job/issues"
25+
},
26+
"author": "lon (https://lon.im)",
27+
"license": "MIT"
2528
}

test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const nextTick = require('./nextTick')
1+
const nextJob = require('./nextJob')
22

33

44
const values = []
55

66
values.push(1)
7-
nextTick(() => values.push(2))
7+
nextJob(() => values.push(2))
88
values.push(3)
99

10-
nextTick(() => {
10+
nextJob(() => {
1111
const result = values.toString()
1212
if (result !== '1,3,2') {
1313
throw new Error(`result: ${result}`)

0 commit comments

Comments
 (0)