-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): criando novos tipos de ferrramento para o projeto
- Loading branch information
1 parent
315c986
commit c2c3690
Showing
4 changed files
with
50 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
export interface IError extends Error { | ||
stack?: string; | ||
} |
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,6 @@ | ||
|
||
import { IError } from "#interfaces/Utils"; | ||
|
||
export type StringBase64 = Buffer; | ||
export type Debug = (e: IError) => void; | ||
export type ToBase64 = (s: StringBase64) => string; |
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,37 @@ | ||
import * as util from 'util'; | ||
|
||
export interface IError extends Error { | ||
stack?: string; | ||
} | ||
interface UtilsIdentityFn<Type> { | ||
(arg: Array<Type>): Array<Type>; | ||
} | ||
|
||
export type StringBase64 = Buffer; | ||
export type Debug = (e: IError) => void; | ||
export type ToBase64 = (s: StringBase64) => string; | ||
|
||
export const debug: Debug = (e: IError) => { | ||
if (e.stack) { | ||
util.debug(e + '\n' + e.stack); | ||
} else { | ||
util.debug(util.inspect(e)); | ||
} | ||
}; | ||
export const toBase64: UtilsIdentityFn<string> = (s: string[]) => { | ||
switch(s.length % 3) { | ||
case 1: | ||
s += ' '; | ||
break; | ||
case 2: | ||
s += ' '; | ||
break; | ||
default: | ||
} | ||
|
||
return Buffer.from(s).toString('base64').replace(/\//g, '_').replace(/\+/g, '-'); | ||
} | ||
|
||
function identity<Type>(arg: Type): Type { | ||
return arg; | ||
} |