initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

21
node_modules/scule/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Pooya Parsa <pooya@pi0.io>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

93
node_modules/scule/README.md generated vendored Normal file
View File

@@ -0,0 +1,93 @@
# 🧵 Scule
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]
[![bundle][bundle-src]][bundle-href]
<!-- ![](.github/banner.svg) -->
## Install
Install using npm or yarn:
```bash
npm i scule
# or
yarn add scule
```
Import:
```js
// CommonJS
const { pascalCase } = require('scule')
// ESM
import { pascalCase } from 'scule'
```
**Notice:** You may need to transpile package for legacy environments
## Utils
### `pascalCase(str)`
Splits string and joins by PascalCase convention (`foo-bar` => `FooBar`)
**Remarks:**
- If an uppercase letter is followed by other uppercase letters (like `FooBAR`), they are preserved
### `camelCase`
Splits string and joins by camelCase convention (`foo-bar` => `fooBar`)
### `kebabCase(str)`
Splits string and joins by kebab-case convention (`fooBar` => `foo-bar`)
**Remarks:**
- It does **not** preserve case
### `snakeCase`
Splits string and joins by snake_case convention (`foo-bar` => `foo_bar`)
### `upperFirst(str)`
Converts first character to upper case
### `lowerFirst(str)`
Converts first character to lower case
### `splitByCase(str, splitters?)`
- Splits string by the splitters provided (default: `['-', '_', '/', '.]`)
- Splits when case changes from lower to upper or upper to lower
- Ignores numbers for case changes
- Case is preserved in returned value
- Is an irreversible function since splitters are omitted
## License
[MIT](./LICENSE)
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/scule?style=flat-square
[npm-version-href]: https://npmjs.com/package/scule
[npm-downloads-src]: https://img.shields.io/npm/dm/scule?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/scule
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/scule/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/scule/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/scule/main?style=flat-square
[codecov-href]: https://codecov.io/gh/unjs/scule
[bundle-src]: https://img.shields.io/bundlephobia/minzip/scule?style=flat-square
[bundle-href]: https://bundlephobia.com/result?p=scule

77
node_modules/scule/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,77 @@
'use strict';
const NUMBER_CHAR_RE = /\d/;
const STR_SPLITTERS = ["-", "_", "/", "."];
function isUppercase(char = "") {
if (NUMBER_CHAR_RE.test(char)) {
return void 0;
}
return char.toUpperCase() === char;
}
function splitByCase(string_, separators) {
const splitters = separators ?? STR_SPLITTERS;
const parts = [];
if (!string_ || typeof string_ !== "string") {
return parts;
}
let buff = "";
let previousUpper;
let previousSplitter;
for (const char of string_) {
const isSplitter = splitters.includes(char);
if (isSplitter === true) {
parts.push(buff);
buff = "";
previousUpper = void 0;
continue;
}
const isUpper = isUppercase(char);
if (previousSplitter === false) {
if (previousUpper === false && isUpper === true) {
parts.push(buff);
buff = char;
previousUpper = isUpper;
continue;
}
if (previousUpper === true && isUpper === false && buff.length > 1) {
const lastChar = buff[buff.length - 1];
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
buff = lastChar + char;
previousUpper = isUpper;
continue;
}
}
buff += char;
previousUpper = isUpper;
previousSplitter = isSplitter;
}
parts.push(buff);
return parts;
}
function upperFirst(string_) {
return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
}
function lowerFirst(string_) {
return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
}
function pascalCase(string_) {
return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => upperFirst(p)).join("");
}
function camelCase(string_) {
return lowerFirst(pascalCase(string_));
}
function kebabCase(string_, joiner) {
return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
}
function snakeCase(string_) {
return kebabCase(string_, "_");
}
exports.camelCase = camelCase;
exports.isUppercase = isUppercase;
exports.kebabCase = kebabCase;
exports.lowerFirst = lowerFirst;
exports.pascalCase = pascalCase;
exports.snakeCase = snakeCase;
exports.splitByCase = splitByCase;
exports.upperFirst = upperFirst;

31
node_modules/scule/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
declare type Splitter = "-" | "_" | "/" | ".";
declare type FirstOfString<S extends string> = S extends `${infer F}${string}` ? F : never;
declare type RemoveFirstOfString<S extends string> = S extends `${string}${infer R}` ? R : never;
declare type IsUpper<S extends string> = S extends Uppercase<S> ? true : false;
declare type IsLower<S extends string> = S extends Lowercase<S> ? true : false;
declare type SameLetterCase<X extends string, Y extends string> = IsUpper<X> extends IsUpper<Y> ? true : IsLower<X> extends IsLower<Y> ? true : false;
declare type CapitalizedWords<T extends readonly string[], Accumulator extends string = ""> = T extends readonly [infer F extends string, ...infer R extends string[]] ? CapitalizedWords<R, `${Accumulator}${Capitalize<F>}`> : Accumulator;
declare type JoinLowercaseWords<T extends readonly string[], Joiner extends string, Accumulator extends string = ""> = T extends readonly [infer F extends string, ...infer R extends string[]] ? Accumulator extends "" ? JoinLowercaseWords<R, Joiner, `${Accumulator}${Lowercase<F>}`> : JoinLowercaseWords<R, Joiner, `${Accumulator}${Joiner}${Lowercase<F>}`> : Accumulator;
declare type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
declare type RemoveLastOfArray<T extends any[]> = T extends [...infer F, any] ? F : never;
declare type SplitByCase<T, Separator extends string = Splitter, Accumulator extends unknown[] = []> = string extends Separator ? string[] : T extends `${infer F}${infer R}` ? [LastOfArray<Accumulator>] extends [never] ? SplitByCase<R, Separator, [F]> : LastOfArray<Accumulator> extends string ? R extends "" ? SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : SameLetterCase<F, FirstOfString<R>> extends true ? F extends Separator ? FirstOfString<R> extends Separator ? SplitByCase<R, Separator, [...Accumulator, ""]> : IsUpper<FirstOfString<R>> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...Accumulator, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, ""]> : SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : IsLower<F> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, F]> : never : Accumulator extends [] ? T extends "" ? [] : string[] : Accumulator;
declare type PascalCase<T> = string extends T ? string : string[] extends T ? string : T extends string ? SplitByCase<T> extends readonly string[] ? CapitalizedWords<SplitByCase<T>> : never : T extends readonly string[] ? CapitalizedWords<T> : never;
declare type CamelCase<T> = string extends T ? string : string[] extends T ? string : Uncapitalize<PascalCase<T>>;
declare type JoinByCase<T, Joiner extends string> = string extends T ? string : string[] extends T ? string : T extends string ? SplitByCase<T> extends readonly string[] ? JoinLowercaseWords<SplitByCase<T>, Joiner> : never : T extends readonly string[] ? JoinLowercaseWords<T, Joiner> : never;
declare function isUppercase(char?: string): boolean | undefined;
declare function splitByCase<T extends string>(string_: T): SplitByCase<T>;
declare function splitByCase<T extends string, Separator extends readonly string[]>(string_: T, separators: Separator): SplitByCase<T, Separator[number]>;
declare function upperFirst<S extends string>(string_: S): Capitalize<S>;
declare function lowerFirst<S extends string>(string_: S): Uncapitalize<S>;
declare function pascalCase(): "";
declare function pascalCase<T extends string | readonly string[]>(string_: T): PascalCase<T>;
declare function camelCase(): "";
declare function camelCase<T extends string | readonly string[]>(string_: T): CamelCase<T>;
declare function kebabCase(): "";
declare function kebabCase<T extends string | readonly string[]>(string_: T): JoinByCase<T, "-">;
declare function kebabCase<T extends string | readonly string[], Joiner extends string>(string_: T, joiner: Joiner): JoinByCase<T, Joiner>;
declare function snakeCase(): "";
declare function snakeCase<T extends string | readonly string[]>(string_: T): JoinByCase<T, "_">;
export { camelCase, isUppercase, kebabCase, lowerFirst, pascalCase, snakeCase, splitByCase, upperFirst };

68
node_modules/scule/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,68 @@
const NUMBER_CHAR_RE = /\d/;
const STR_SPLITTERS = ["-", "_", "/", "."];
function isUppercase(char = "") {
if (NUMBER_CHAR_RE.test(char)) {
return void 0;
}
return char.toUpperCase() === char;
}
function splitByCase(string_, separators) {
const splitters = separators ?? STR_SPLITTERS;
const parts = [];
if (!string_ || typeof string_ !== "string") {
return parts;
}
let buff = "";
let previousUpper;
let previousSplitter;
for (const char of string_) {
const isSplitter = splitters.includes(char);
if (isSplitter === true) {
parts.push(buff);
buff = "";
previousUpper = void 0;
continue;
}
const isUpper = isUppercase(char);
if (previousSplitter === false) {
if (previousUpper === false && isUpper === true) {
parts.push(buff);
buff = char;
previousUpper = isUpper;
continue;
}
if (previousUpper === true && isUpper === false && buff.length > 1) {
const lastChar = buff[buff.length - 1];
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
buff = lastChar + char;
previousUpper = isUpper;
continue;
}
}
buff += char;
previousUpper = isUpper;
previousSplitter = isSplitter;
}
parts.push(buff);
return parts;
}
function upperFirst(string_) {
return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
}
function lowerFirst(string_) {
return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
}
function pascalCase(string_) {
return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => upperFirst(p)).join("");
}
function camelCase(string_) {
return lowerFirst(pascalCase(string_));
}
function kebabCase(string_, joiner) {
return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
}
function snakeCase(string_) {
return kebabCase(string_, "_");
}
export { camelCase, isUppercase, kebabCase, lowerFirst, pascalCase, snakeCase, splitByCase, upperFirst };

41
node_modules/scule/package.json generated vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "scule",
"version": "1.0.0",
"description": "String case utils",
"repository": "unjs/scule",
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./*": "./*"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "vitest",
"lint": "eslint --ext .ts .",
"prepublishOnly": "pnpm build",
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
"test": "pnpm lint && vitest run --coverage"
},
"devDependencies": {
"@types/node": "^18.11.9",
"@vitest/coverage-c8": "^0.25.2",
"eslint": "^8.27.0",
"eslint-config-unjs": "^0.0.2",
"standard-version": "^9.5.0",
"typescript": "^4.8.4",
"unbuild": "^0.9.4",
"vitest": "^0.25.2"
},
"packageManager": "pnpm@7.16.0"
}