Ghost
New
pippinmole
/
ghost
public
forked from
ghost/ghost
Source code of Ghost - On Ghost
Star
0
Fork
0
Code
Issues
0
Pull requests
0
main
76
branches
Go to file
t
Code
ghost
apps
api
src
lib
git
protocol
pkt-line.ts
api: put pure code under lib/ in folders named for what they hold
297713a
5 days ago
10 lines · 339 B
1
export
const
FLUSH_PACKET
=
'
0000
'
;
2
3
/**
4 hex digits of total length, then the payload.
*/
4
export
function
pktLine
(
payload
5
const
data
=
6
return
Buffer
.
concat
7
Buffer
.
from
((
data
8
data
,
9
])
;
10
}
:
string
|
Buffer
)
{
typeof
payload
===
'
string
'
?
Buffer
.
from
(
payload
)
:
payload
;
([
.
length
+
4
)
.
toString
(
16
)
.
padStart
(
4
,
'
0
'
)
,
'
ascii
'
)
,