Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add and run standard * standard --fix + tweaks * new Buffer() -> Buffer.from() * Split initialized {const,var} declarations into multiple statements * != -> !== or == -> === * Return statement should not contain assignment * Missing space * Handle error * Add TODO
- Loading branch information
1 parent
8ee3b02
commit 4ada06a
Showing
5 changed files
with
397 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
exports.create = function createEncoding (options) { | ||
options || (options = {}) | ||
|
||
if (options.ttlEncoding) | ||
return options.ttlEncoding | ||
if (options.ttlEncoding) return options.ttlEncoding | ||
|
||
const PATH_SEP = options.separator | ||
, INITIAL_SEP = options.sub ? '' : PATH_SEP | ||
const PATH_SEP = options.separator | ||
const INITIAL_SEP = options.sub ? '' : PATH_SEP | ||
|
||
function encodeElement(e) { | ||
function encodeElement (e) { | ||
// transform dates to timestamp strings | ||
return String(e instanceof Date ? +e : e) | ||
} | ||
|
||
return { | ||
buffer : false | ||
, encode : function (e) { | ||
// TODO: reexamine this with respect to level-sublevel@6's native codecs | ||
if (Array.isArray(e)) | ||
return new Buffer(INITIAL_SEP + e.map(encodeElement).join(PATH_SEP)) | ||
return new Buffer(encodeElement(e)) | ||
} | ||
, decode : function (e) { | ||
// TODO: detect and parse ttl records | ||
return e.toString('utf8') | ||
buffer: false, | ||
encode: function (e) { | ||
// TODO: reexamine this with respect to level-sublevel@6's native codecs | ||
if (Array.isArray(e)) { | ||
return Buffer.from(INITIAL_SEP + e.map(encodeElement).join(PATH_SEP)) | ||
} | ||
return Buffer.from(encodeElement(e)) | ||
}, | ||
decode: function (e) { | ||
// TODO: detect and parse ttl records | ||
return e.toString('utf8') | ||
} | ||
} | ||
} |
Oops, something went wrong.