Skip to content

Commit

Permalink
lint: remove spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
puzrin committed Dec 1, 2023
1 parent 832b16e commit af07dec
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 176 deletions.
26 changes: 10 additions & 16 deletions benchmark/benchmark.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
/*eslint no-console:0*/
/* eslint-disable no-console */

import { readFileSync, readdirSync } from 'fs'
import util from 'node:util'
import Benchmark from 'benchmark'
import ansi from 'ansi'
const cursor = ansi(process.stdout)
const cursor = ansi(process.stdout)

const IMPLS = []

Expand All @@ -25,28 +25,26 @@ readdirSync(new URL('./samples', import.meta.url)).sort().forEach(sample => {

content.string = readFileSync(filepath, 'utf8')

const title = `(${content.string.length} bytes)`
const title = `(${content.string.length} bytes)`

function onComplete() {
function onComplete () {
cursor.write('\n')
}


const suite = new Benchmark.Suite(title, {

onStart: function onStart() {
onStart: function onStart () {
console.log('\nSample: %s %s', sample, title)
},

onComplete: onComplete

})


IMPLS.forEach(function (impl) {
suite.add(impl.name, {

onCycle: function onCycle(event) {
onCycle: function onCycle (event) {
cursor.horizontalAbsolute()
cursor.eraseLine()
cursor.write(' > ' + event.target)
Expand All @@ -56,12 +54,10 @@ readdirSync(new URL('./samples', import.meta.url)).sort().forEach(sample => {

fn: function () {
impl.code.run(content.string)
return
}
})
})


SAMPLES.push({
name: sample.split('.')[0],
title: title,
Expand All @@ -70,15 +66,14 @@ readdirSync(new URL('./samples', import.meta.url)).sort().forEach(sample => {
})
})


function select(patterns) {
function select (patterns) {
const result = []

if (!(patterns instanceof Array)) {
patterns = [ patterns ]
patterns = [patterns]
}

function checkName(name) {
function checkName (name) {
return patterns.length === 0 || patterns.some(function (regexp) {
return regexp.test(name)
})
Expand All @@ -93,8 +88,7 @@ function select(patterns) {
return result
}


function run(files) {
function run (files) {
const selected = select(files)

if (selected.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/implementations/current-match/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const linkify = linkifyit()

linkify.test('')

export function run(data) {
export function run (data) {
return linkify.match(data)
}
2 changes: 1 addition & 1 deletion benchmark/implementations/current-pretest/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const linkify = linkifyit()

linkify.test('')

export function run(data) {
export function run (data) {
return linkify.pretest(data)
}
2 changes: 1 addition & 1 deletion benchmark/implementations/current-test/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const linkify = linkifyit()

linkify.test('')

export function run(data) {
export function run (data) {
return linkify.test(data)
}
4 changes: 2 additions & 2 deletions benchmark/profile.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node
/*eslint-disable no-console*/
/* eslint-disable no-console */

import { readFileSync } from 'fs'
import linkifyit from '../index.mjs'

const linkify = linkifyit()

// Forse compilation
// Force compilation
linkify.test('')

const data = readFileSync(new URL('/samples/lorem1.txt', import.meta.url), 'utf8')
Expand Down
Loading

0 comments on commit af07dec

Please sign in to comment.