-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove dicer dependency to libs/utils.js (#105)
* fix: Remove dicer dependecny to libs/utils.js * fix * more changes Co-authored-by: Lahiru Maramba <llahiru@gmail.com>
- Loading branch information
1 parent
63a7075
commit f7aef85
Showing
16 changed files
with
257 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict' | ||
|
||
const WritableStream = require('stream').Writable | ||
const inherits = require('util').inherits | ||
|
||
|
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,3 +1,5 @@ | ||
'use strict' | ||
|
||
const inherits = require('util').inherits | ||
const ReadableStream = require('stream').Readable | ||
|
||
|
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,3 +1,5 @@ | ||
'use strict' | ||
|
||
/** | ||
* Copyright Brian White. All rights reserved. | ||
* | ||
|
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict' | ||
|
||
const RE_PLUS = /\+/g | ||
|
||
const HEX = [ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, | ||
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
] | ||
|
||
function Decoder () { | ||
this.buffer = undefined | ||
} | ||
Decoder.prototype.write = function (str) { | ||
// Replace '+' with ' ' before decoding | ||
str = str.replace(RE_PLUS, ' ') | ||
let res = '' | ||
let i = 0; let p = 0; const len = str.length | ||
for (; i < len; ++i) { | ||
if (this.buffer !== undefined) { | ||
if (!HEX[str.charCodeAt(i)]) { | ||
res += '%' + this.buffer | ||
this.buffer = undefined | ||
--i // retry character | ||
} else { | ||
this.buffer += str[i] | ||
++p | ||
if (this.buffer.length === 2) { | ||
res += String.fromCharCode(parseInt(this.buffer, 16)) | ||
this.buffer = undefined | ||
} | ||
} | ||
} else if (str[i] === '%') { | ||
if (i > p) { | ||
res += str.substring(p, i) | ||
p = i | ||
} | ||
this.buffer = '' | ||
++p | ||
} | ||
} | ||
if (p < len && this.buffer === undefined) { res += str.substring(p) } | ||
return res | ||
} | ||
Decoder.prototype.reset = function () { | ||
this.buffer = undefined | ||
} | ||
|
||
module.exports = Decoder |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = function basename (path) { | ||
if (typeof path !== 'string') { return '' } | ||
for (var i = path.length - 1; i >= 0; --i) { // eslint-disable-line no-var | ||
switch (path.charCodeAt(i)) { | ||
case 0x2F: // '/' | ||
case 0x5C: // '\' | ||
path = path.slice(i + 1) | ||
return (path === '..' || path === '.' ? '' : path) | ||
} | ||
} | ||
return (path === '..' || path === '.' ? '' : path) | ||
} |
Oops, something went wrong.