This commit is contained in:
cupcakearmy 2021-11-02 18:02:21 +01:00
parent a35a32ea2b
commit 6101a1b34f
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
8 changed files with 4675 additions and 6480 deletions

View File

@ -34,6 +34,6 @@ generate('{character}_{english}')</pre
</div> </div>
</div> </div>
</main> </main>
<script src="./main.ts"></script> <script type="module" src="./main.ts"></script>
</body> </body>
</html> </html>

View File

@ -1,8 +1,9 @@
* { * {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol';
} }
main{ main {
padding: 4rem 1rem; padding: 4rem 1rem;
text-align: center; text-align: center;
} }
@ -15,11 +16,11 @@ main > div {
pre { pre {
text-align: left; text-align: left;
padding: 1em .5em; padding: 1em 0.5em;
border-radius: 1.5em; border-radius: 1.5em;
} }
h2 span{ h2 span {
color: #3273dc; color: #3273dc;
margin: 0 0.5rem; margin: 0 0.5rem;
} }

View File

@ -1,4 +1,4 @@
import 'bulma/css/bulma' import 'bulma/css/bulma.css'
import { showAvailableLists, generate } from '../' import { showAvailableLists, generate } from '../'
const input = window.document.getElementById('format') as HTMLInputElement const input = window.document.getElementById('format') as HTMLInputElement

View File

@ -1,6 +1,6 @@
{ {
"name": "canihazusername", "name": "canihazusername",
"version": "2.1.1", "version": "2.2.0",
"description": "username generator. typed, simple and customizable", "description": "username generator. typed, simple and customizable",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -15,6 +15,8 @@
}, },
"scripts": { "scripts": {
"generate": "git submodule update && node ./generate/wordlist.js", "generate": "git submodule update && node ./generate/wordlist.js",
"dev": "tsc -w",
"build": "tsc",
"docs": "tsc && parcel build --target docs demo/index.html ", "docs": "tsc && parcel build --target docs demo/index.html ",
"docs:dev": "parcel --target docs demo/index.html", "docs:dev": "parcel --target docs demo/index.html",
"prepublishOnly": "rm -rf ./dist && tsc" "prepublishOnly": "rm -rf ./dist && tsc"
@ -36,9 +38,8 @@
}, },
"homepage": "https://github.com/CupCakeArmy/canihazusername#readme", "homepage": "https://github.com/CupCakeArmy/canihazusername#readme",
"devDependencies": { "devDependencies": {
"bulma": "^0.9", "bulma": "^0.9.3",
"parcel": "^2.0.0-nightly.626", "parcel": "^2.0.0",
"ts-node-dev": "^1", "typescript": "^4.4.4"
"typescript": "^4"
} }
} }

4555
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ const DEFAULT_OPTIONS = {
} }
function randomElementFromArray<T>(arr: T[]): T { function randomElementFromArray<T>(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)] return arr[Math.floor(Math.random() * arr.length)]!
} }
export function showAvailableLists(): string[] { export function showAvailableLists(): string[] {
@ -24,7 +24,9 @@ export function generate(
const match = /\{.*?\}/.exec(format) const match = /\{.*?\}/.exec(format)
if (match === null) break if (match === null) break
const keys = match[0] const m0 = match[0]
if (!m0) throw new Error('Invalid match')
const keys = m0
.slice(1, -1) .slice(1, -1)
.split('|') .split('|')
.map((key) => key.trim()) .map((key) => key.trim())
@ -32,7 +34,7 @@ export function generate(
const lists = keys.map((key) => (Array.isArray(combined[key]) ? combined[key] : [])) const lists = keys.map((key) => (Array.isArray(combined[key]) ? combined[key] : []))
const flattened = lists.reduce((acc, val) => acc.concat(val), []) const flattened = lists.reduce((acc, val) => acc.concat(val), [])
const value: string = flattened.length > 0 ? randomElementFromArray(flattened) : '' const value: string = flattened.length > 0 ? randomElementFromArray(flattened) : ''
format = format.replace(match[0], value) format = format.replace(m0, value)
} }
return format return format

View File

@ -2,72 +2,100 @@
"compilerOptions": { "compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */ /* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */ /* Projects */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "lib": [], /* Specify library files to be included in the compilation. */ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "checkJs": true, /* Report errors in .js files. */ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */ /* Language and Environment */
"strict": true /* Enable all strict type-checking options. */, "target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"strictNullChecks": true /* Enable strict null checks. */, // "jsx": "preserve", /* Specify what JSX code is generated. */
"strictFunctionTypes": true /* Enable strict checking of function types. */, // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
"strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */, // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
"strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Additional Checks */ /* Modules */
// "noUnusedLocals": true, /* Report errors on unused locals. */ "module": "commonjs" /* Specify what module code is generated. */,
// "noUnusedParameters": true, /* Report errors on unused parameters. */ "rootDir": "./src" /* Specify the root folder within your source files. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */, // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */, // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
"noPropertyAccessFromIndexSignature": true /* Require undeclared properties from index signatures to use element accesses. */, // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
/* Module Resolution Options */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true, "resolveJsonModule": true /* Enable importing .json files */,
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* Source Map Options */ /* JavaScript Support */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
"declarationMap": true /* Create sourcemaps for d.ts files. */,
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"removeComments": true /* Disable emitting comments. */,
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Experimental Options */ /* Interop Constraints */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Advanced Options */ /* Type Checking */
"skipLibCheck": true /* Skip type checking of declaration files. */, "strict": true /* Enable all strict type-checking options. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */,
"strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */,
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
"strictBindCallApply": true /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */,
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
"noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */,
"useUnknownInCatchVariables": true /* Type catch clause variables as 'unknown' instead of 'any'. */,
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
"exactOptionalPropertyTypes": true /* Interpret optional property types as written, rather than adding 'undefined'. */,
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
"noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */,
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
"noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type */,
"allowUnusedLabels": true /* Disable error reporting for unused labels. */,
"allowUnreachableCode": true /* Disable error reporting for unreachable code. */,
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}, },
"include": ["./src"] "include": ["src"]
} }

6392
yarn.lock

File diff suppressed because it is too large Load Diff