Skip to content

Commit

Permalink
Update development methodologies to the current year
Browse files Browse the repository at this point in the history
  • Loading branch information
queicherius committed Sep 25, 2018
1 parent 9b46f58 commit d37d6fb
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 79 deletions.
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

6 changes: 1 addition & 5 deletions .gitignore 100644 → 100755
Expand Up @@ -3,10 +3,6 @@ npm-debug.log*

# Coverage directories
coverage/
.nyc_output/

# Compiled code
build/

# Dependencies
node_modules/
Expand All @@ -19,4 +15,4 @@ node_modules/

# Operating System
.DS_Store
Thumbs.db
Thumbs.db
22 changes: 0 additions & 22 deletions .npmignore

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml 100644 → 100755
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "6"
- "8"
after_script: "$(npm bin)/codecov"
branches:
only:
- master
- /^greenkeeper.*$/
- /^greenkeeper.*$/
Empty file modified LICENCE 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion README.md 100644 → 100755
Expand Up @@ -18,7 +18,7 @@ This module can be used for Node.js as well as browsers using [Browserify](https
### Basic usage

```js
import flow from 'promise-control-flow'
const flow = require('promise-control-flow')

// Note: promisesArray expects to be built out of *functions*
// that return promises, because else the promises start
Expand Down
9 changes: 4 additions & 5 deletions package.json 100644 → 100755
Expand Up @@ -2,11 +2,9 @@
"name": "promise-control-flow",
"version": "1.2.4",
"description": "Wrapping the contra library to support promises (parallel/series)",
"main": "./build/index.js",
"main": "./src/index.js",
"scripts": {
"build": "abc build",
"test": "abc test && abc lint",
"version": "abc build"
"test": "jest --coverage && standard"
},
"author": "queicherius@gmail.com",
"license": "MIT",
Expand All @@ -19,6 +17,7 @@
"is-function": "^1.0.1"
},
"devDependencies": {
"abc-environment": "^2.0.0"
"jest": "^23.6.0",
"standard": "^12.0.1"
}
}
10 changes: 5 additions & 5 deletions src/index.js 100644 → 100755
@@ -1,15 +1,15 @@
import concurrent from 'contra/concurrent'
import isFunction from 'is-function'
const concurrent = require('contra/concurrent')
const isFunction = require('is-function')

export default {series, parallel}
module.exports = { series, parallel }

// Work on the tasks in series (one by one)
export function series (promiseFunctions, silenceErrors = false) {
function series (promiseFunctions, silenceErrors = false) {
return parallel(promiseFunctions, 1, silenceErrors)
}

// Work on the tasks in parallel, with a optional concurrency limit
export function parallel (promiseFunctions, limit = Infinity, silenceErrors = false) {
function parallel (promiseFunctions, limit = Infinity, silenceErrors = false) {
const contraMethod = (tasks, callback) => concurrent(tasks, limit, callback)
return generatePromise(promiseFunctions, contraMethod, silenceErrors)
}
Expand Down
49 changes: 24 additions & 25 deletions tests/index.spec.js 100644 → 100755
@@ -1,6 +1,5 @@
/* eslint-env node, mocha */
import {expect} from 'chai'
import module from '../src/index.js'
/* eslint-env jest */
const flow = require('../src/index.js')

function timeoutPromise (ms, throwError = false) {
return () => new Promise((resolve, reject) => {
Expand All @@ -23,9 +22,9 @@ describe('promise-control-flow', () => {
timeoutPromise(100)
]

let timestamps = await module.parallel(promises)
expect(timestamps[1] - timestamps[0]).to.be.below(25)
expect(timestamps[2] - timestamps[1]).to.be.below(25)
let timestamps = await flow.parallel(promises)
expect(timestamps[1] - timestamps[0]).toBeLessThan(25)
expect(timestamps[2] - timestamps[1]).toBeLessThan(25)
})

it('can work on promises in parallel with a limit', async () => {
Expand All @@ -36,10 +35,10 @@ describe('promise-control-flow', () => {
timeoutPromise(100)
]

let timestamps = await module.parallel(promises, 2)
expect(timestamps[1] - timestamps[0]).to.be.below(25)
expect(timestamps[2] - timestamps[1]).to.be.above(95)
expect(timestamps[3] - timestamps[2]).to.be.below(25)
let timestamps = await flow.parallel(promises, 2)
expect(timestamps[1] - timestamps[0]).toBeLessThan(25)
expect(timestamps[2] - timestamps[1]).toBeGreaterThan(95)
expect(timestamps[3] - timestamps[2]).toBeLessThan(25)
})

it('can work on promises in series', async () => {
Expand All @@ -49,9 +48,9 @@ describe('promise-control-flow', () => {
timeoutPromise(100)
]

let timestamps = await module.series(promises)
expect(timestamps[1] - timestamps[0]).to.be.above(95)
expect(timestamps[2] - timestamps[1]).to.be.above(95)
let timestamps = await flow.series(promises)
expect(timestamps[1] - timestamps[0]).toBeGreaterThan(95)
expect(timestamps[2] - timestamps[1]).toBeGreaterThan(95)
})

it('can catch the promise error for parallel', async () => {
Expand All @@ -63,12 +62,12 @@ describe('promise-control-flow', () => {

let err
try {
await module.parallel(promises)
await flow.parallel(promises)
} catch (e) {
err = e
}

expect(err.message).to.equal('Error')
expect(err.message).toEqual('Error')
})

it('can catch the promise error for series', async () => {
Expand All @@ -80,12 +79,12 @@ describe('promise-control-flow', () => {

let err
try {
await module.series(promises)
await flow.series(promises)
} catch (e) {
err = e
}

expect(err.message).to.equal('Error')
expect(err.message).toEqual('Error')
})

it('can work on promises as an object', async () => {
Expand All @@ -96,8 +95,8 @@ describe('promise-control-flow', () => {
three: () => promiseFunc('three-result')
}

let result = await module.parallel(promises)
expect(result).to.deep.equal({
let result = await flow.parallel(promises)
expect(result).toEqual({
one: 'one-result',
two: 'two-result',
three: 'three-result'
Expand All @@ -116,8 +115,8 @@ describe('promise-control-flow', () => {
three: () => promiseFunc('three-result')
}

let result = await module.parallel(promises, false, true)
expect(result).to.deep.equal({
let result = await flow.parallel(promises, false, true)
expect(result).toEqual({
one: 'one-result',
two: null,
three: 'three-result'
Expand All @@ -136,8 +135,8 @@ describe('promise-control-flow', () => {
() => promiseFunc('three-result')
]

let result = await module.series(promises, true)
expect(result).to.deep.equal([
let result = await flow.series(promises, true)
expect(result).toEqual([
'one-result',
null,
'three-result'
Expand All @@ -151,11 +150,11 @@ describe('promise-control-flow', () => {

let err
try {
await module.parallel(promises)
await flow.parallel(promises)
} catch (e) {
err = e
}

expect(err.message).to.equal('One of the supplied promise functions is not a function')
expect(err.message).toEqual('One of the supplied promise functions is not a function')
})
})

0 comments on commit d37d6fb

Please sign in to comment.