Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions internal/timeout.js

This file was deleted.

16 changes: 7 additions & 9 deletions net/axios.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable */
const curry2 = require('../internal/curry2')
const curry3 = require('../internal/curry3')
const axios = require('axios')

module.exports = {
get: curry2 (axios.get),
'delete': curry2 (axios.delete),
head: curry2 (axios.head),
options: curry2 (axios.options),
post: curry3 (axios.post),
put: curry3 (axios.put),
patch: curry3 (axios.put)
get: url => options => axios.get(url, options),
'delete': url => options => axios.delete(url, options),
head: url => options => axios.head(url, options),
options: url => options => axios.options(url, options),
post: url => data => options => axios.post(url, data, options),
put: url => data => options => axios.put(url, data, options),
patch: url => data => options => axios.put(url, data, options)
}
23 changes: 8 additions & 15 deletions threading/__tests__/sleep.test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
const sleep = require('../sleep')

describe('threading/sleep', () => {
beforeEach(() => jest.spyOn(global, 'setTimeout').mockImplementation(func => func()))
afterEach(() => global.setTimeout.mockReset())

test('sleep returns value', () => {
expect.assertions(1)
const expected = 888
const actual = sleep(0)(expected)
return expect(actual).resolves.toBe(expected)
})

test('sleep(0) executes immediately', () => {
expect.assertions(1)
const start = new Date()
return sleep(0)().then(() => {
const end = new Date()
expect(end - start).toBeLessThan(100)
})
})

test('sleep(100) executes later', () => {
test('sleep(100000) calls setTimeout with 100000 milliseconds', () => {
expect.assertions(1)
const start = new Date()
return sleep(100)().then(() => {
const end = new Date()
expect(end - start).toBeGreaterThanOrEqual(99)
})
const expected = 1000
sleep(expected)()
const actual = global.setTimeout.mock.calls[0][1]
expect(actual).toBe(expected)
})
})
4 changes: 1 addition & 3 deletions threading/sleep.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable */
const timeout = require('../internal/timeout')

const sleep = milliseconds => value => new Promise (
resolve => timeout (() => resolve (value)) (milliseconds)
resolve => setTimeout(() => resolve(value), milliseconds)
)

module.exports = sleep