Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

[FEATURE/FIX] Ensuring NodeJS 12 Compatibility #315

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions benchmarks/construction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ const SIZES_IN_KB = [
10,
100,
1000,
10000,
10000
]

const bufferTimesInMS = []
const displayLayerTimesInMS = []

for (let sizeInKB of SIZES_IN_KB) {
let text = helpers.getRandomText(sizeInKB)
let buffer = new TextBuffer({text})
for (const sizeInKB of SIZES_IN_KB) {
const text = helpers.getRandomText(sizeInKB)
let buffer = new TextBuffer({ text })

let t0 = Date.now()
const t0 = Date.now()
for (let i = 0; i < TRIAL_COUNT; i++) {
buffer = new TextBuffer({text})
buffer = new TextBuffer({ text })
buffer.getTextInRange([[0, 0], [50, 0]])
}

let t1 = Date.now()
const t1 = Date.now()
for (let i = 0; i < TRIAL_COUNT; i++) {
let displayLayer = buffer.addDisplayLayer({})
const displayLayer = buffer.addDisplayLayer({})
displayLayer.getScreenLines(0, 50)
}

let t2 = Date.now()
const t2 = Date.now()
bufferTimesInMS.push((t1 - t0) / TRIAL_COUNT)
displayLayerTimesInMS.push((t2 - t1) / TRIAL_COUNT)
}

function getMillisecondsPerMegabyte(timesInMS) {
function getMillisecondsPerMegabyte (timesInMS) {
const series = timesInMS.map((time, i) => [SIZES_IN_KB[i], time * 1024])
const slownessRegression = regression('linear', series)
return slownessRegression.equation[0]
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/helpers.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const WORDS = require('../spec/helpers/words')
const Random = require('random-seed')
const random = new Random(Date.now())
const {Point, Range} = require('..')
const { Point, Range } = require('..')

exports.getRandomText = function (sizeInKB) {
const goalLength = Math.round(sizeInKB * 1024)

let length = 0
let lines = []
const lines = []
let currentLine = ''
let lastLineStartIndex = 0
// const lastLineStartIndex = 0
let goalLineLength = random(100)

for (;;) {
Expand All @@ -22,7 +22,7 @@ exports.getRandomText = function (sizeInKB) {
goalLineLength = random(100)
}

let choice = random(10)
const choice = random(10)
if (choice < 2) {
length++
currentLine += '\t'
Expand All @@ -34,7 +34,7 @@ exports.getRandomText = function (sizeInKB) {
length++
currentLine += ' '
}
word = WORDS[random(WORDS.length)]
const word = WORDS[random(WORDS.length)]
length += word.length
currentLine += word
}
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/mutation.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const helpers = require('./helpers')
const TextBuffer = require('..')

let text = helpers.getRandomText(100)
let buffer = new TextBuffer({text})
let displayLayer = buffer.addDisplayLayer({})
const text = helpers.getRandomText(100)
const buffer = new TextBuffer({ text })
// const displayLayer = buffer.addDisplayLayer({})

let t0 = Date.now()
const t0 = Date.now()

for (let i = 0; i < 1000; i++) {
buffer.setTextInRange(
Expand All @@ -14,7 +14,7 @@ for (let i = 0; i < 1000; i++) {
)
}

let t1 = Date.now()
const t1 = Date.now()

console.log('Mutation')
console.log('------------')
Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"description": "A container for large mutable strings with annotated regions",
"main": "./lib/text-buffer",
"scripts": {
"prepublish": "npm run clean && npm run compile && npm run lint && npm run docs",
"prepare": "npm run clean && npm run compile && npm run lint && npm run docs",
"docs": "node script/generate-docs",
"clean": "rimraf lib api.json",
"compile": "coffee --no-header --output lib --compile src && cpy src/*.js lib/",
"lint": "coffeelint -r src spec && standard src/*.js spec/*.js",
"clean": "npx rimraf lib api.json",
"compile": "npx coffee --no-header --output lib --compile src && npx cpy src/*.js lib/",
"lint": "npx coffeelint -r src spec && npx standard src/*.js spec/*.js",
"test": "node script/test",
"ci": "npm run compile && npm run lint && npm run test && npm run bench",
"bench": "node benchmarks/index"
Expand All @@ -23,39 +23,39 @@
"atomTestRunner": "atom-jasmine2-test-runner",
"license": "MIT",
"devDependencies": {
"atom-jasmine2-test-runner": "^1.0.0",
"coffee-cache": "^0.2.0",
"coffee-script": "^1.10.0",
"coffeelint": "1.16.0",
"cpy-cli": "^1.0.1",
"dedent": "^0.6.0",
"atom-jasmine2-test-runner": "^2.99.1",
"dedent": "^0.7.0",
"donna": "^1.0.16",
"electron": "^1.7.11",
"jasmine": "^2.4.1",
"jasmine-core": "^2.4.1",
"electron": "^6.0.4",
"jasmine": "^3.4.0",
"jasmine-core": "^3.4.0",
"joanna": "0.0.11",
"json-diff": "^0.3.1",
"random-seed": "^0.2.0",
"regression": "^1.2.1",
"rimraf": "~2.2.2",
"standard": "^10.0.3",
"tello": "^1.0.7",
"temp": "^0.8.3",
"yargs": "^6.5.0"
"json-diff": "^0.5.4",
"random-seed": "^0.3.0",
"regression": "^2.0.1",
"tello": "^1.2.0",
"temp": "^0.9.0",
"yargs": "^14.0.0"
},
"dependencies": {
"cpy-cli": "^2.0.0",
"coffee-cache": "^1.0.2",
"coffee-script": "^1.12.7",
"coffeelint": "2.1.0",
"delegato": "^1.0.0",
"diff": "^2.2.1",
"emissary": "^1.0.0",
"event-kit": "^2.4.0",
"fs-admin": "^0.5.0",
"fs-plus": "^3.0.0",
"diff": "^4.0.1",
"emissary": "^1.3.3",
"event-kit": "^2.5.3",
"fs-admin": "^0.9.0",
"fs-plus": "^3.1.1",
"grim": "^2.0.2",
"mkdirp": "^0.5.1",
"pathwatcher": "^8.1.0",
"rimraf": "~3.0.0",
"serializable": "^1.0.3",
"superstring": "2.4.0",
"underscore-plus": "^1.0.0"
"standard": "^14.0.2",
"superstring": "git+https://[email protected]/atom/superstring.git#59c92f",
"underscore-plus": "^1.7.0"
},
"standard": {
"env": {
Expand Down
Loading