Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KB1RD committed Jun 30, 2020
1 parent 99f2cb5 commit e6ec737
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"@babel/plugin-transform-typescript",
{ "allowNamespaces": true, "allowDeclareFields": true }
],
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
],
"env": {
"test": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kb1rd/logootish-js",
"version": "0.4.0",
"version": "0.4.2",
"description": "Logootish algorithm for matrix-notepad",
"main": "dist/@kb1rd/logootish-js.min.js",
"publishConfig": {
Expand Down Expand Up @@ -31,6 +31,7 @@
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.2",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.4",
"@babel/preset-env": "^7.10.2",
"@babel/preset-typescript": "^7.10.1",
"@babel/register": "^7.10.1",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
/** */

import { ListDocumentModel, LogootInt, LogootPosition } from './listmodel'
export { LogootishPosition, LogootPosition } from './listmodel/position'

import { BranchOrder, BranchKey } from './listmodel/branch'
export { ListDocumentModel, LogootInt } from './listmodel'

export { ListDocumentModel, LogootInt, LogootPosition, BranchOrder, BranchKey }
export { BranchOrder, BranchKey } from './listmodel/branch'
22 changes: 18 additions & 4 deletions src/listmodel/branch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DualCompareFunction } from '../compare'

/**
* A type used to identify a branch. This value should be used to look up a
* user-presentable name in another map stored outside of `logootish-js`. This
Expand All @@ -6,8 +8,8 @@
*/
type BranchKey = symbol | string | number

class BranchOrder {
constructor(public readonly order: BranchKey[] = []) {}
class BranchOrder<T extends BranchKey = BranchKey> {
constructor(public readonly order: T[] = []) {}

get length(): number {
return this.order.length
Expand All @@ -18,17 +20,29 @@ class BranchOrder {
* @param br The branch to find the index of
* @return The index of `br`
*/
i(br: BranchKey): number {
i(br: T): number {
if (!this.order.includes(br)) {
this.order.push(br)
return this.order.length - 1
}
return this.order.indexOf(br)
}
b(index: number): BranchKey {
b(index: number): T {
return this.order[index]
}

insertOrdered(br: T, cf: DualCompareFunction<T>): BranchOrder<T> {
const len = this.order.length
for (let i = 0; i < len; i++) {
if (cf(br, this.order[i]) < 0) {
this.order.splice(i, 0, br)
return this
}
}
this.order.push(br)
return this
}

static fromJSON(
// eslint-disable-next-line
json: any[],
Expand Down
2 changes: 2 additions & 0 deletions src/listmodel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
/** */

import 'core-js/features/array/flat-map'

import { DBst } from '../bst'
import { LogootInt } from './int'
import { LogootPosition } from './position'
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
],
"lib": [
"dom",
"es7",
"es2019.array"
"es7"
]
}
38 changes: 37 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@
dependencies:
"@babel/types" "^7.10.1"

"@babel/helper-module-imports@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620"
integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw==
dependencies:
"@babel/types" "^7.10.4"

"@babel/helper-module-imports@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz#7fe39589b39c016331b6b8c3f441e8f0b1419498"
Expand Down Expand Up @@ -320,6 +327,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.1.tgz#ec5a5cf0eec925b66c60580328b122c01230a127"
integrity sha512-fvoGeXt0bJc7VMWZGCAEBEMo/HAjW2mP8apF5eXK0wSqwLAVHAISCWRoLMBMUs2kqeaG77jltVqu4Hn8Egl3nA==

"@babel/helper-plugin-utils@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375"
integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg==

"@babel/helper-regex@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.1.tgz#021cf1a7ba99822f993222a001cc3fec83255b96"
Expand Down Expand Up @@ -393,6 +405,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz#5770b0c1a826c4f53f5ede5e153163e0318e94b5"
integrity sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==

"@babel/helper-validator-identifier@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2"
integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==

"@babel/helper-validator-identifier@^7.9.0", "@babel/helper-validator-identifier@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80"
Expand Down Expand Up @@ -820,6 +837,16 @@
dependencies:
"@babel/helper-plugin-utils" "^7.10.1"

"@babel/plugin-transform-runtime@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.10.4.tgz#594fb53453ea1b6f0779cceb48ce0718a447feb7"
integrity sha512-8ULlGv8p+Vuxu+kz2Y1dk6MYS2b/Dki+NO6/0ZlfSj5tMalfDL7jI/o/2a+rrWLqSXvnadEqc2WguB4gdQIxZw==
dependencies:
"@babel/helper-module-imports" "^7.10.4"
"@babel/helper-plugin-utils" "^7.10.4"
resolve "^1.8.1"
semver "^5.5.1"

"@babel/plugin-transform-shorthand-properties@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.10.1.tgz#e8b54f238a1ccbae482c4dce946180ae7b3143f3"
Expand Down Expand Up @@ -1045,6 +1072,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.10.4.tgz#369517188352e18219981efd156bfdb199fff1ee"
integrity sha512-UTCFOxC3FsFHb7lkRMVvgLzaRVamXuAs2Tz4wajva4WxtVY82eZeaUBtC2Zt95FU9TiznuC0Zk35tsim8jeVpg==
dependencies:
"@babel/helper-validator-identifier" "^7.10.4"
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.8.3", "@babel/types@^7.8.6", "@babel/types@^7.9.0", "@babel/types@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.5.tgz#89231f82915a8a566a703b3b20133f73da6b9444"
Expand Down Expand Up @@ -5953,7 +5989,7 @@ resolve@1.1.7:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

resolve@^1.1.4, resolve@^1.1.6, resolve@^1.12.0, resolve@^1.4.0:
resolve@^1.1.4, resolve@^1.1.6, resolve@^1.12.0, resolve@^1.4.0, resolve@^1.8.1:
version "1.17.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
Expand Down

0 comments on commit e6ec737

Please sign in to comment.