Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
yjs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sweng-group-15
yjs
Commits
75793d0c
Commit
75793d0c
authored
9 years ago
by
Kevin Jahns
Browse files
Options
Downloads
Patches
Plain Diff
added memory data store
parent
7ec409e0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Connectors/Test.js
+1
-1
1 addition, 1 deletion
src/Connectors/Test.js
src/Operations.js
+45
-0
45 additions, 0 deletions
src/Operations.js
src/y.js
+9
-0
9 additions, 0 deletions
src/y.js
with
55 additions
and
1 deletion
src/Connectors/Test.js
+
1
−
1
View file @
75793d0c
// returns a r
e
ndom element of o
// returns a r
a
ndom element of o
// works on Object, and Array
function
getRandom
(
o
)
{
if
(
o
instanceof
Array
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Operations.js
+
45
−
0
View file @
75793d0c
...
...
@@ -169,5 +169,50 @@ var Struct = {
o
=
yield
*
Struct
.
Insert
.
create
.
call
(
this
,
{},
content
,
o
,
or
,
op
);
}
}
},
Map
:
{
create
:
function
*
(
op
:
Op
){
op
.
start
=
null
;
op
.
end
=
null
;
op
.
struct
=
"
Map
"
;
return
yield
*
Struct
.
Operation
.
create
.
call
(
this
,
op
);
},
requiredOps
:
function
(
op
,
ids
){
if
(
op
.
start
!=
null
)
{
ids
.
push
(
op
.
start
);
}
if
(
op
.
end
!=
null
){
ids
.
push
(
op
.
end
);
}
return
ids
;
},
execute
:
function
*
()
{
// nop
},
ref
:
function
*
(
op
:
Op
,
pos
:
number
)
:
Insert
{
var
o
=
op
.
start
;
while
(
pos
!==
0
||
o
!=
null
)
{
o
=
(
yield
*
this
.
getOperation
(
o
)).
right
;
pos
--
;
}
return
(
o
==
null
)
?
null
:
yield
*
this
.
getOperation
(
o
);
},
map
:
function
*
(
o
:
Op
,
f
:
Function
)
:
Array
<
any
>
{
o
=
o
.
start
;
var
res
=
[];
while
(
o
!=
null
)
{
var
operation
=
yield
*
this
.
getOperation
(
o
);
res
.
push
(
f
(
operation
.
content
));
o
=
operation
.
right
;
}
return
res
;
},
insert
:
function
*
(
op
,
pos
:
number
,
contents
:
Array
<
any
>
)
{
var
o
=
yield
*
Struct
.
List
.
ref
.
call
(
this
,
op
,
pos
);
var
or
=
yield
*
this
.
getOperation
(
o
.
right
);
for
(
var
content
of
contents
)
{
o
=
yield
*
Struct
.
Insert
.
create
.
call
(
this
,
{},
content
,
o
,
or
,
op
);
}
}
}
};
This diff is collapsed.
Click to expand it.
src/y.js
+
9
−
0
View file @
75793d0c
...
...
@@ -8,4 +8,13 @@ class Y { //eslint-disable-line no-unused-vars
transact
(
generator
)
{
this
.
db
.
requestTransaction
(
generator
);
}
destroy
()
{
this
.
connector
.
disconnect
();
this
.
db
.
removeDatabase
();
this
.
connector
=
null
;
this
.
db
=
null
;
this
.
transact
=
function
(){
throw
new
Error
(
"
Remember?, you destroyed this type ;)
"
);
};
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment