Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jabis Sevón
/
gun-multiserver
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
621198f3
authored
2020-04-17 12:20:36 +0200
by
Lorenzo Mangani
Committed by
GitHub
2020-04-17 12:20:36 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Create mem.js
1 parent
d47cdfa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
mem.js
mem.js
0 → 100644
View file @
621198f
(
function
()
{
var
Gun
=
typeof
window
!==
"undefined"
?
window
.
Gun
:
require
(
"gun"
);
Gun
.
on
(
"opt"
,
function
(
ctx
)
{
this
.
to
.
next
(
ctx
);
var
opt
=
ctx
.
opt
;
if
(
ctx
.
once
)
{
return
;
}
var
graph
=
ctx
.
graph
,
acks
=
{},
count
=
0
,
to
;
ctx
.
on
(
"put"
,
function
(
at
)
{
this
.
to
.
next
(
at
);
Gun
.
graph
.
is
(
at
.
put
,
null
,
null
);
if
(
!
at
[
"@"
])
{
acks
[
at
[
"#"
]]
=
true
;
}
// only ack non-acks.
count
+=
1
;
if
(
count
>=
(
opt
.
batch
||
10000
))
{
return
flush
();
}
if
(
to
)
{
return
;
}
to
=
setTimeout
(
flush
,
opt
.
wait
||
1
);
});
ctx
.
on
(
"get"
,
function
(
at
)
{
// this.to.next(at); //What does this do?
var
lex
=
at
.
get
,
soul
,
data
,
opt
,
u
;
if
(
!
lex
||
!
(
soul
=
lex
[
"#"
]))
{
return
;
}
var
field
=
lex
[
"."
];
if
(
data
&&
field
)
{
data
=
Gun
.
state
.
to
(
data
,
field
);
}
ctx
.
on
(
"in"
,
{
"@"
:
at
[
"#"
],
put
:
Gun
.
graph
.
node
(
data
)
});
});
var
wait
;
var
flush
=
function
()
{
if
(
wait
)
{
return
;
}
wait
=
true
;
clearTimeout
(
to
);
to
=
false
;
var
ack
=
acks
;
acks
=
{};
};
});
})();
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment