Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #143 from atom/super-duper-ts
Browse files Browse the repository at this point in the history
Super duper TS
  • Loading branch information
Nathan Sobo authored Oct 3, 2018
2 parents 3d228b7 + 97db0f2 commit 0d3618a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions memo_js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const replicaId = 1;
const tree = new WorkTree(replicaId);
tree.appendBaseEntries([
{ depth: 1, name: "a", type: "Directory" },
{ depth: 2, name: "b", type: "File" },
{ depth: 1, name: "c", type: "File" },
{ depth: 2, name: "b", type: "Text" },
{ depth: 1, name: "c", type: "Text" }
])
```

Expand All @@ -37,7 +37,7 @@ a/b
c
```

Since the application may need to perform I/O in order to fetch the base entries, you are free to start using the work tree before they are fully populated. You can also populate the base entries in a streaming fashion by calling `appendBaseEntries` multiple times and ensuring that the entries passed to each call pick up from the last entry passed in the previous call. If
Since the application may need to perform I/O in order to fetch the base entries, you are free to start using the work tree before they are fully populated. You can also populate the base entries in a streaming fashion by calling `appendBaseEntries` multiple times and ensuring that the entries passed to each call pick up from the last entry passed in the previous call.

For now, Memo has no internal concept of commits. Application code will need to arrange for all replicas to build on top of the same commit state and see the exact same base entries. When a participant wishes to commit, you'll need to coordinate building up a new work tree on top of the new state. We plan to handle more commit-related logic directly within the library in the future.

Expand All @@ -57,7 +57,7 @@ If you have not finished populating the base entries via `appendBaseEntries`, so
To list the work tree's current paths, call `entries`. This will return an array of entries arranged in a depth-first order, similar to the argument to `appendBaseEntries`. For example, the base entries populated above could be retrieved as follows:

```js
for entry of tree.entries() {
for (entry of tree.entries()) {
console.log(entry.depth, entry.name, entry.type);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ function applyOps(tree, ops, openEditors) {
// Perform these steps synchronously:
const baseVersion = tree.getVersion();
const fixupOps = tree.applyOps(ops);
for editor of openEditors {
for (editor of openEditors) {
applyChanges(editor, tree.changesSince(editor.bufferId, baseVersion));
}

Expand Down
38 changes: 19 additions & 19 deletions memo_js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@ function request(req: any) {
}
}

type FileId = string;
type BufferId = string;
type Version = object;
type Operation = string;
export type FileId = string;
export type BufferId = string;
export type Version = object;
export type Operation = string;

enum FileType {
export enum FileType {
Directory = "Directory",
File = "File"
Text = "Text"
}

enum FileStatus {
export enum FileStatus {
New = "New",
Renamed = "Renamed",
Removed = "Removed",
Modified = "Modified",
Unchanged = "Unchanged"
}

interface BaseEntry {
depth: number;
name: string;
type: FileType;
export interface BaseEntry {
readonly depth: number;
readonly name: string;
readonly type: FileType;
}

interface Entry {
depth: number;
fileId: FileId;
type: FileType;
name: string;
status: FileStatus;
visible: boolean;
export interface Entry {
readonly depth: number;
readonly fileId: FileId;
readonly type: FileType;
readonly name: string;
readonly status: FileStatus;
readonly visible: boolean;
}

class WorkTree {
export class WorkTree {
private static rootFileId: FileId;
private id: number;

Expand Down

0 comments on commit 0d3618a

Please sign in to comment.