-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from swansontec/typescript
Typescript
- Loading branch information
Showing
18 changed files
with
443 additions
and
136 deletions.
There are no files selected for viewing
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,17 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
extends: [ | ||
'standard-kit/lint', | ||
'standard-kit/lint/typescript' | ||
], | ||
parserOptions: { | ||
project: path.resolve(__dirname, './tsconfig.json'), | ||
tsconfigRootDir: __dirname | ||
}, | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-var': 'error', | ||
'prettier/prettier': 'error' | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
.nyc_output | ||
/coverage | ||
/lib | ||
/node_modules | ||
# Build output: | ||
.nyc_output/ | ||
coverage/ | ||
lib/ | ||
|
||
# Package managers: | ||
node_modules/ | ||
npm-debug.log | ||
package-lock.json | ||
yarn-error.log | ||
|
||
# Editors: | ||
.DS_Store | ||
.idea/ | ||
.vscode/ |
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,12 @@ | ||
{ | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"extension": [ | ||
".ts" | ||
], | ||
"require": [ | ||
"sucrase/register" | ||
], | ||
"all": true | ||
} |
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,34 +1,40 @@ | ||
import babel from 'rollup-plugin-babel' | ||
import filesize from 'rollup-plugin-filesize' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import { uglify } from 'rollup-plugin-uglify' | ||
|
||
import packageJson from './package.json' | ||
|
||
const extensions = ['.ts'] | ||
const babelOpts = { | ||
babelrc: false, | ||
extensions, | ||
include: ['src/**/*'], | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
exclude: ['transform-regenerator'], | ||
loose: true | ||
} | ||
] | ||
], | ||
'@babel/typescript' | ||
] | ||
} | ||
const resolveOpts = { extensions } | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.js', | ||
input: 'src/index.ts', | ||
output: [ | ||
{ file: packageJson.module, format: 'esm', sourceMap: true }, | ||
{ file: packageJson.main, format: 'cjs', sourceMap: true } | ||
], | ||
plugins: [babel(babelOpts)] | ||
plugins: [resolve(resolveOpts), babel(babelOpts)] | ||
}, | ||
{ | ||
input: 'src/index.js', | ||
input: 'src/index.ts', | ||
output: { file: 'lib/index.min.js', format: 'iife', name: 'rfc4648' }, | ||
plugins: [babel(babelOpts), uglify(), filesize()] | ||
plugins: [resolve(resolveOpts), babel(babelOpts), uglify(), filesize()] | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,96 @@ | ||
/* eslint-disable @typescript-eslint/strict-boolean-expressions */ | ||
|
||
import { | ||
Encoding, | ||
ParseOptions, | ||
StringifyOptions, | ||
parse, | ||
stringify | ||
} from './codec' | ||
|
||
const base16Encoding: Encoding = { | ||
chars: '0123456789ABCDEF', | ||
bits: 4 | ||
} | ||
|
||
const base32Encoding: Encoding = { | ||
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', | ||
bits: 5 | ||
} | ||
|
||
const base32HexEncoding: Encoding = { | ||
chars: '0123456789ABCDEFGHIJKLMNOPQRSTUV', | ||
bits: 5 | ||
} | ||
|
||
const base64Encoding: Encoding = { | ||
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', | ||
bits: 6 | ||
} | ||
|
||
const base64UrlEncoding: Encoding = { | ||
chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_', | ||
bits: 6 | ||
} | ||
|
||
export const base16 = { | ||
parse(string: string, opts?: ParseOptions): Uint8Array { | ||
return parse(string.toUpperCase(), base16Encoding, opts) | ||
}, | ||
|
||
stringify(data: ArrayLike<number>, opts?: StringifyOptions): string { | ||
return stringify(data, base16Encoding, opts) | ||
} | ||
} | ||
|
||
export const base32 = { | ||
parse(string: string, opts: ParseOptions = {}): Uint8Array { | ||
return parse( | ||
opts.loose | ||
? string | ||
.toUpperCase() | ||
.replace(/0/g, 'O') | ||
.replace(/1/g, 'L') | ||
.replace(/8/g, 'B') | ||
: string, | ||
base32Encoding, | ||
opts | ||
) | ||
}, | ||
|
||
stringify(data: ArrayLike<number>, opts?: StringifyOptions): string { | ||
return stringify(data, base32Encoding, opts) | ||
} | ||
} | ||
|
||
export const base32hex = { | ||
parse(string: string, opts?: ParseOptions): Uint8Array { | ||
return parse(string, base32HexEncoding, opts) | ||
}, | ||
|
||
stringify(data: ArrayLike<number>, opts?: StringifyOptions): string { | ||
return stringify(data, base32HexEncoding, opts) | ||
} | ||
} | ||
|
||
export const base64 = { | ||
parse(string: string, opts?: ParseOptions): Uint8Array { | ||
return parse(string, base64Encoding, opts) | ||
}, | ||
|
||
stringify(data: ArrayLike<number>, opts?: StringifyOptions): string { | ||
return stringify(data, base64Encoding, opts) | ||
} | ||
} | ||
|
||
export const base64url = { | ||
parse(string: string, opts?: ParseOptions): Uint8Array { | ||
return parse(string, base64UrlEncoding, opts) | ||
}, | ||
|
||
stringify(data: ArrayLike<number>, opts?: StringifyOptions): string { | ||
return stringify(data, base64UrlEncoding, opts) | ||
} | ||
} | ||
|
||
export const codec = { parse, stringify } |
Oops, something went wrong.