UNPKG
@ezdevlol/memfs
Version:
latest (4.23.0)
4.23.0
In-memory file-system with Node's fs API.
github.com/streamich/memfs
streamich/memfs
@ezdevlol/memfs
/
lib
/
crud-to-cas
/
util.js
9 lines
(8 loc)
•
281 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
export
const
hashToLocation
= (
hash
) => {
if
(hash.
length
<
20
)
throw
new
TypeError
(
'Hash is too short'
);
const
lastTwo = hash.
slice
(-
2
);
const
twoBeforeLastTwo = hash.
slice
(-
4
, -
2
);
const
folder = [lastTwo, twoBeforeLastTwo];
return
[folder, hash]; };