Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
style: reformat source files
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Feb 8, 2021
1 parent 2fe5743 commit 39767d0
Show file tree
Hide file tree
Showing 14 changed files with 8,560 additions and 8,765 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
version: 2
jobs:
build_12.18.2:
build_14.15.4:
docker:
- image: 'circleci/node:12.18.2'
- image: circleci/node:14.15.4
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- 'v1-dependencies-{{ checksum "package.json" }}'
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: 'v1-dependencies-{{ checksum "package.json" }}'
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm test
build_latest:
docker:
- image: 'circleci/node:latest'
- image: circleci/node:latest
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- 'v1-dependencies-{{ checksum "package.json" }}'
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: 'v1-dependencies-{{ checksum "package.json" }}'
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm test
workflows:
version: 2
workflow:
jobs:
- build_12.18.2
- build_14.15.4
- build_latest
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_size = 2
indent_style = tab
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand All @@ -20,4 +20,4 @@ indent_style = ignore
insert_final_newline = ignore

[MakeFile]
indent_style = tab
indent_style = space
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
],
"rules": {
"prettier/prettier": [
"error"
"error",
{
"endOfLine": "auto"
}
]
}
}
24 changes: 8 additions & 16 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"useTabs": true,
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100,
"overrides": [
{
"files": "*.md",
"options": {
"useTabs": false
}
}
]
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"useTabs": false,
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100
}
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,11 @@ assert.deepEqual(ctx.stack, ['fn1', 'final handler'])

[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/co-compose/master.svg?style=for-the-badge&logo=circleci
[circleci-url]: https://circleci.com/gh/poppinss/co-compose 'circleci'

[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"

[npm-image]: https://img.shields.io/npm/v/co-compose.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/co-compose 'npm'

[license-image]: https://img.shields.io/npm/l/co-compose?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md 'license'

[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/poppinss/co-compose?label=Synk%20Vulnerabilities&style=for-the-badge
[synk-url]: https://snyk.io/test/github/poppinss/co-compose?targetFile=package.json "synk"
[synk-url]: https://snyk.io/test/github/poppinss/co-compose?targetFile=package.json 'synk'
130 changes: 65 additions & 65 deletions benchmarks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ const suite = new Suite()
*/
const middleware = new Middleware()
const middlewareStack = [
async function one(next) {
await next()
},
async function two(next) {
await next()
},
async function three(next) {
await next()
},
async function four(next) {
await next()
},
async function one(next) {
await next()
},
async function two(next) {
await next()
},
async function three(next) {
await next()
},
async function four(next) {
await next()
},
]
middleware.register(middlewareStack)

Expand All @@ -33,37 +33,37 @@ middleware.register(middlewareStack)
*/
const series = Fastseries({ results: true })
const seriesStack = [
function one(_, next) {
next(null)
},
function two(_, next) {
next(null)
},
function three(_, next) {
next(null)
},
function four(_, next) {
next(null)
},
function one(_, next) {
next(null)
},
function two(_, next) {
next(null)
},
function three(_, next) {
next(null)
},
function four(_, next) {
next(null)
},
]

const middieStack = [
function one() {
arguments[2](null)
},
function two() {
arguments[2](null)
},
function three() {
arguments[2](null)
},
function four() {
arguments[2](null)
},
function one() {
arguments[2](null)
},
function two() {
arguments[2](null)
},
function three() {
arguments[2](null)
},
function four() {
arguments[2](null)
},
]

const middie = new Middie(function runner() {
arguments[3].deferred.resolve()
arguments[3].deferred.resolve()
})
middie.use(middieStack[0])
middie.use(middieStack[1])
Expand All @@ -73,31 +73,31 @@ middie.use(middieStack[3])
const req = new IncomingMessage(new Socket())

suite
.add('Co Compose', {
defer: true,
fn(deferred: Deferred) {
middleware
.runner()
.run([])
.then(() => deferred.resolve())
},
})
.add('fastseries', {
defer: true,
fn(deferred: Deferred) {
series({}, seriesStack, 42, () => deferred.resolve())
},
})
.add('middie', {
defer: true,
fn(deferred: Deferred) {
middie.run(req, {}, { deferred })
},
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run({ async: true })
.add('Co Compose', {
defer: true,
fn(deferred: Deferred) {
middleware
.runner()
.run([])
.then(() => deferred.resolve())
},
})
.add('fastseries', {
defer: true,
fn(deferred: Deferred) {
series({}, seriesStack, 42, () => deferred.resolve())
},
})
.add('middie', {
defer: true,
fn(deferred: Deferred) {
middie.run(req, {}, { deferred })
},
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
})
.run({ async: true })
3 changes: 1 addition & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"core": false,
"ts": true,
"license": "MIT",
"services": [
"circleci"
],
"minNodeVersion": "12.18.2",
"minNodeVersion": "14.15.4",
"probotApps": [
"stale",
"lock"
Expand Down
52 changes: 26 additions & 26 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
;(async function () {
const Middleware = require('..').Middleware
const Middleware = require('..').Middleware

class Middleware1 {
async handle(ctx, next) {
ctx.stack.push('fn1')
await next()
}
}
class Middleware1 {
async handle(ctx, next) {
ctx.stack.push('fn1')
await next()
}
}

class Middleware2 {
async handle(ctx, next) {
ctx.stack.push('fn2')
await next()
}
}
class Middleware2 {
async handle(ctx, next) {
ctx.stack.push('fn2')
await next()
}
}

const middleware = new Middleware()
const ctx = {
stack: [],
}
const middleware = new Middleware()
const ctx = {
stack: [],
}

middleware.register([Middleware1, Middleware2])
middleware.register([Middleware1, Middleware2])

await middleware
.runner()
.executor(async function (MiddlewareClass, params) {
const instance = new MiddlewareClass()
await instance.handle(...params)
})
.run([ctx])
await middleware
.runner()
.executor(async function (MiddlewareClass, params) {
const instance = new MiddlewareClass()
await instance.handle(...params)
})
.run([ctx])

console.log(ctx)
console.log(ctx)
})()
2 changes: 1 addition & 1 deletion japaFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ require('@adonisjs/require-ts/build/register')

const { configure } = require('japa')
configure({
files: ['test/**/*.spec.ts'],
files: ['test/**/*.spec.ts'],
})
Loading

0 comments on commit 39767d0

Please sign in to comment.