style(format): add sorting imports plugin and fix eslint config (#625)

* Add prettier sort

* Fix prettier setting in eslint

* Apply prettier

* Fix depdencies

* Add .yarn folder in excludes of vitest

* Revert pick I don't know why this is changed
This commit is contained in:
Dayong Lee 2024-10-01 14:00:45 +09:00 committed by GitHub
parent 8f7e0960cb
commit 23aa7db57d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
200 changed files with 865 additions and 782 deletions

View File

@ -1,14 +0,0 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "lf",
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}

18
.prettierrc.cjs Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: false,
bracketSpacing: true,
endOfLine: 'lf',
jsxSingleQuote: false,
printWidth: 120,
proseWrap: 'preserve',
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
plugins: [require.resolve('@trivago/prettier-plugin-sort-imports')],
importOrder: ['^vitest', '^es-toolkit', '<THIRD_PARTY_MODULES>', '^@(.*)$', '^[.]/', '^[.]{2,}/'],
importOrderSortSpecifiers: true,
importOrderCaseInsensitive: true,
};

View File

@ -1,47 +1,38 @@
import { DocNodeFunction } from "@deno/doc"; import { DocNodeFunction } from '@deno/doc';
import { formatParam } from "./nodes/param.ts"; import { formatParam } from './nodes/param.ts';
import { formatTypeParam } from "./nodes/type-param.ts"; import { formatTypeParam } from './nodes/type-param.ts';
import { formatType } from "./nodes/type.ts"; import { formatType } from './nodes/type.ts';
import { FormatOption } from "./options.ts"; import { FormatOption } from './options.ts';
export function formatFunctionDoc( export function formatFunctionDoc(node: DocNodeFunction, options: FormatOption = {}): string {
node: DocNodeFunction, let result = '';
options: FormatOption = {},
): string {
let result = "";
if (node.functionDef.isAsync) { if (node.functionDef.isAsync) {
result += "async "; result += 'async ';
} }
result += "function"; result += 'function';
if (node.functionDef.isGenerator) { if (node.functionDef.isGenerator) {
result += "*"; result += '*';
} }
result += " "; result += ' ';
result += node.name; result += node.name;
if (node.functionDef.typeParams.length > 0) { if (node.functionDef.typeParams.length > 0) {
result += "<"; result += '<';
result += node.functionDef.typeParams.map((p) => result += node.functionDef.typeParams.map(p => formatTypeParam(p, options)).join(', ');
formatTypeParam(p, options) result += '>';
).join(
", ",
);
result += ">";
} }
result += "("; result += '(';
result += node.functionDef.params.map((p) => formatParam(p, options)).join( result += node.functionDef.params.map(p => formatParam(p, options)).join(', ');
", ", result += ')';
);
result += ")";
if (node.functionDef.returnType != null) { if (node.functionDef.returnType != null) {
result += ": "; result += ': ';
result += formatType(node.functionDef.returnType, options); result += formatType(node.functionDef.returnType, options);
} }

View File

@ -1,24 +1,21 @@
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatReadonly( export function formatReadonly(node: { readonly?: boolean | '+' | '-' }, options: FormatOption): string {
node: { readonly?: boolean | "+" | "-" },
options: FormatOption,
): string {
if (!options.display?.readonly) { if (!options.display?.readonly) {
return ""; return '';
} }
switch (node.readonly) { switch (node.readonly) {
case true: { case true: {
return "readonly "; return 'readonly ';
} }
case "+": { case '+': {
return "+readonly "; return '+readonly ';
} }
case "-": { case '-': {
return "-readonly "; return '-readonly ';
} }
} }
return ""; return '';
} }

View File

@ -1,20 +1,17 @@
import { LiteralCallSignatureDef } from "@deno/doc"; import { LiteralCallSignatureDef } from '@deno/doc';
import { formatParam } from "./param.ts"; import { formatParam } from './param.ts';
import { formatType } from "./type.ts"; import { formatType } from './type.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatCallSignatureDef( export function formatCallSignatureDef(node: LiteralCallSignatureDef, options: FormatOption) {
node: LiteralCallSignatureDef, let result = '';
options: FormatOption,
) {
let result = "";
result += "("; result += '(';
result += node.params.map((param) => formatParam(param, options)).join(", "); result += node.params.map(param => formatParam(param, options)).join(', ');
result += ")"; result += ')';
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }

View File

@ -1,17 +1,17 @@
import { DecoratorDef } from "@deno/doc"; import { DecoratorDef } from '@deno/doc';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
// eslint-disable-next-line // eslint-disable-next-line
export function formatDecorator(node: DecoratorDef, _: FormatOption) { export function formatDecorator(node: DecoratorDef, _: FormatOption) {
let result = ""; let result = '';
result += "@"; result += '@';
result += node.name; result += node.name;
if (node.args != null && node.args.length > 0) { if (node.args != null && node.args.length > 0) {
result += "("; result += '(';
result += node.args.join(", "); result += node.args.join(', ');
result += ")"; result += ')';
} }
return result; return result;

View File

@ -1,23 +1,20 @@
import { LiteralIndexSignatureDef } from "@deno/doc"; import { LiteralIndexSignatureDef } from '@deno/doc';
import { formatReadonly } from "../helpers/readonly.ts"; import { formatParam } from './param.ts';
import { formatParam } from "./param.ts"; import { formatType } from './type.ts';
import { formatType } from "./type.ts"; import { formatReadonly } from '../helpers/readonly.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatIndexSignatureDef( export function formatIndexSignatureDef(node: LiteralIndexSignatureDef, options: FormatOption) {
node: LiteralIndexSignatureDef, let result = '';
options: FormatOption,
) {
let result = "";
result += formatReadonly(node, options); result += formatReadonly(node, options);
result += "["; result += '[';
result += node.params.map((p) => formatParam(p, options)).join(", "); result += node.params.map(p => formatParam(p, options)).join(', ');
result += "]"; result += ']';
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }

View File

@ -1,10 +1,10 @@
import { LiteralMethodDef } from "@deno/doc"; import { LiteralMethodDef } from '@deno/doc';
import { formatParam } from "./param.ts"; import { formatParam } from './param.ts';
import { formatType } from "./type.ts"; import { formatType } from './type.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatMethodDef(node: LiteralMethodDef, options: FormatOption) { export function formatMethodDef(node: LiteralMethodDef, options: FormatOption) {
let result = ""; let result = '';
if (node.computed) { if (node.computed) {
result += `[${node.name}]`; result += `[${node.name}]`;
@ -13,15 +13,15 @@ export function formatMethodDef(node: LiteralMethodDef, options: FormatOption) {
} }
if (node.optional) { if (node.optional) {
result += "?"; result += '?';
} }
result += "("; result += '(';
result += node.params.map((x) => formatParam(x, options)).join(", "); result += node.params.map(x => formatParam(x, options)).join(', ');
result += ")"; result += ')';
if (node.returnType != null) { if (node.returnType != null) {
result += ": "; result += ': ';
result += formatType(node.returnType, options); result += formatType(node.returnType, options);
} }

View File

@ -1,27 +1,27 @@
import { ObjectPatPropDef } from "@deno/doc"; import { ObjectPatPropDef } from '@deno/doc';
import { formatParam } from "./param.ts"; import { formatParam } from './param.ts';
export function formatObjectPatProp(node: ObjectPatPropDef) { export function formatObjectPatProp(node: ObjectPatPropDef) {
switch (node.kind) { switch (node.kind) {
case "keyValue": { case 'keyValue': {
return node.key; return node.key;
} }
case "assign": { case 'assign': {
let result = ""; let result = '';
result += node.key; result += node.key;
if (node.value != null) { if (node.value != null) {
result += " = "; result += ' = ';
result += node.value; result += node.value;
} }
return result; return result;
} }
case "rest": { case 'rest': {
let result = ""; let result = '';
result += "..."; result += '...';
result += formatParam(node.arg); result += formatParam(node.arg);
return result; return result;

View File

@ -1,7 +1,7 @@
import { ParamDef } from "@deno/doc"; import { ParamDef } from '@deno/doc';
import { formatType } from "./type.ts"; import { formatObjectPatProp } from './object-pat-prop.ts';
import { formatObjectPatProp } from "./object-pat-prop.ts"; import { formatType } from './type.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatParam(node: ParamDef, options: FormatOption): string { export function formatParam(node: ParamDef, options: FormatOption): string {
if (node.decorators != null) { if (node.decorators != null) {
@ -9,89 +9,89 @@ export function formatParam(node: ParamDef, options: FormatOption): string {
} }
switch (node.kind) { switch (node.kind) {
case "array": { case 'array': {
let result = ""; let result = '';
result += "["; result += '[';
result += node.elements result += node.elements
.filter((x) => x != null) .filter(x => x != null)
.map((item) => { .map(item => {
return formatParam(item!, options); return formatParam(item!, options);
}) })
.join(", "); .join(', ');
result += "]"; result += ']';
if (node.optional) { if (node.optional) {
result += "?"; result += '?';
} }
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }
return result; return result;
} }
case "assign": { case 'assign': {
let result = ""; let result = '';
result += formatParam(node.left, options); result += formatParam(node.left, options);
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }
return result; return result;
} }
case "identifier": { case 'identifier': {
let result = ""; let result = '';
result += node.name; result += node.name;
if (node.optional) { if (node.optional) {
result += "?"; result += '?';
} }
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }
return result; return result;
} }
case "object": { case 'object': {
let result = ""; let result = '';
result += "{"; result += '{';
result += node.props.map((prop) => formatObjectPatProp(prop)).join(", "); result += node.props.map(prop => formatObjectPatProp(prop)).join(', ');
result += "}"; result += '}';
if (node.optional) { if (node.optional) {
result += "?"; result += '?';
} }
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }
return result; return result;
} }
case "rest": { case 'rest': {
let result = ""; let result = '';
result += "..."; result += '...';
result += formatParam(node.arg, options); result += formatParam(node.arg, options);
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }

View File

@ -1,13 +1,10 @@
import { LiteralPropertyDef } from "@deno/doc"; import { LiteralPropertyDef } from '@deno/doc';
import { formatType } from "./type.ts"; import { formatType } from './type.ts';
import { formatReadonly } from "../helpers/readonly.ts"; import { formatReadonly } from '../helpers/readonly.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatPropertyDef( export function formatPropertyDef(node: LiteralPropertyDef, options: FormatOption) {
node: LiteralPropertyDef, let result = '';
options: FormatOption,
) {
let result = "";
result += formatReadonly(node, options); result += formatReadonly(node, options);
@ -18,11 +15,11 @@ export function formatPropertyDef(
} }
if (node.optional) { if (node.optional) {
result += "?"; result += '?';
} }
if (node.tsType != null) { if (node.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.tsType, options); result += formatType(node.tsType, options);
} }

View File

@ -1,22 +1,19 @@
import { TsTypeParamDef } from "@deno/doc"; import { TsTypeParamDef } from '@deno/doc';
import { FormatOption } from "../options.ts"; import { formatType } from './type.ts';
import { formatType } from "./type.ts"; import { FormatOption } from '../options.ts';
export function formatTypeParam( export function formatTypeParam(node: TsTypeParamDef, options: FormatOption) {
node: TsTypeParamDef, let result = '';
options: FormatOption,
) {
let result = "";
result += node.name; result += node.name;
if (node.constraint != null) { if (node.constraint != null) {
result += " extends "; result += ' extends ';
result += formatType(node.constraint, options); result += formatType(node.constraint, options);
} }
if (node.default != null) { if (node.default != null) {
result += " = "; result += ' = ';
result += formatType(node.default, options); result += formatType(node.default, options);
} }

View File

@ -1,199 +1,190 @@
import { TsTypeDef } from "@deno/doc"; import { TsTypeDef } from '@deno/doc';
import { formatTypeParam } from "./type-param.ts"; import { formatCallSignatureDef } from './call-signature.ts';
import { formatParam } from "./param.ts"; import { formatIndexSignatureDef } from './index-signature.ts';
import { formatCallSignatureDef } from "./call-signature.ts"; import { formatMethodDef } from './method.ts';
import { formatMethodDef } from "./method.ts"; import { formatParam } from './param.ts';
import { formatPropertyDef } from "./property.ts"; import { formatPropertyDef } from './property.ts';
import { formatReadonly } from "../helpers/readonly.ts"; import { formatTypeParam } from './type-param.ts';
import { formatIndexSignatureDef } from "./index-signature.ts"; import { formatReadonly } from '../helpers/readonly.ts';
import { FormatOption } from "../options.ts"; import { FormatOption } from '../options.ts';
export function formatType( export function formatType(node: TsTypeDef, options: FormatOption): string {
node: TsTypeDef,
options: FormatOption,
): string {
switch (node.kind) { switch (node.kind) {
case "array": { case 'array': {
switch (node.array.kind) { switch (node.array.kind) {
case "union": case 'union':
case "intersection": case 'intersection':
return `Array<${formatType(node.array, options)}>`; return `Array<${formatType(node.array, options)}>`;
} }
return `${formatType(node.array, options)}[]`; return `${formatType(node.array, options)}[]`;
} }
case "conditional": { case 'conditional': {
let result = ""; let result = '';
result += formatType(node.conditionalType.checkType, options); result += formatType(node.conditionalType.checkType, options);
result += " extends "; result += ' extends ';
result += formatType(node.conditionalType.extendsType, options); result += formatType(node.conditionalType.extendsType, options);
result += " ? "; result += ' ? ';
result += formatType(node.conditionalType.trueType, options); result += formatType(node.conditionalType.trueType, options);
result += " : "; result += ' : ';
result += formatType(node.conditionalType.falseType, options); result += formatType(node.conditionalType.falseType, options);
return result; return result;
} }
case "infer": { case 'infer': {
let result = ""; let result = '';
result += "infer "; result += 'infer ';
result += formatTypeParam(node.infer.typeParam, options); result += formatTypeParam(node.infer.typeParam, options);
return result; return result;
} }
case "importType": { case 'importType': {
let result = ""; let result = '';
result += "import("; result += 'import(';
result += node.importType.specifier; result += node.importType.specifier;
result += ")"; result += ')';
if (node.importType.qualifier != null) { if (node.importType.qualifier != null) {
result += "."; result += '.';
result += node.importType.qualifier; result += node.importType.qualifier;
} }
if (node.importType.typeParams != null) { if (node.importType.typeParams != null) {
result += "<"; result += '<';
result += node.importType.typeParams.map((param) => result += node.importType.typeParams.map(param => formatType(param, options)).join(', ');
formatType(param, options) result += '>';
)
.join(", ");
result += ">";
} }
return result; return result;
} }
case "fnOrConstructor": { case 'fnOrConstructor': {
let result = ""; let result = '';
if (node.fnOrConstructor.constructor) { if (node.fnOrConstructor.constructor) {
result += "new "; result += 'new ';
} }
result += "("; result += '(';
result += node.fnOrConstructor.params.map((param) => result += node.fnOrConstructor.params.map(param => formatParam(param, options)).join(', ');
formatParam(param, options) result += ')';
)
.join(", ");
result += ")";
result += " => "; result += ' => ';
result += formatType(node.fnOrConstructor.tsType, options); result += formatType(node.fnOrConstructor.tsType, options);
return result; return result;
} }
case "indexedAccess": { case 'indexedAccess': {
let result = ""; let result = '';
result += formatType(node.indexedAccess.objType, options); result += formatType(node.indexedAccess.objType, options);
result += "["; result += '[';
result += formatType(node.indexedAccess.indexType, options); result += formatType(node.indexedAccess.indexType, options);
result += "]"; result += ']';
return result; return result;
} }
case "intersection": { case 'intersection': {
return node.intersection.map((u) => formatType(u, options)).join(" & "); return node.intersection.map(u => formatType(u, options)).join(' & ');
} }
case "mapped": { case 'mapped': {
let result = ""; let result = '';
result += formatReadonly(node.mappedType, options); result += formatReadonly(node.mappedType, options);
result += "["; result += '[';
if (node.mappedType.typeParam.constraint != null) { if (node.mappedType.typeParam.constraint != null) {
result += node.mappedType.typeParam.name; result += node.mappedType.typeParam.name;
result += " in "; result += ' in ';
result += formatType(node.mappedType.typeParam.constraint, options); result += formatType(node.mappedType.typeParam.constraint, options);
} else { } else {
result += formatTypeParam(node.mappedType.typeParam, options); result += formatTypeParam(node.mappedType.typeParam, options);
} }
if (node.mappedType.nameType != null) { if (node.mappedType.nameType != null) {
result += " as "; result += ' as ';
result += formatType(node.mappedType.nameType, options); result += formatType(node.mappedType.nameType, options);
} }
result += "]"; result += ']';
switch (node.mappedType.optional) { switch (node.mappedType.optional) {
case true: { case true: {
result += "?"; result += '?';
break; break;
} }
case "+": { case '+': {
result += "+?"; result += '+?';
break; break;
} }
case "-": { case '-': {
result += "-?"; result += '-?';
break; break;
} }
} }
if (node.mappedType.tsType != null) { if (node.mappedType.tsType != null) {
result += ": "; result += ': ';
result += formatType(node.mappedType.tsType, options); result += formatType(node.mappedType.tsType, options);
} }
return result; return result;
} }
case "keyword": { case 'keyword': {
return node.keyword; return node.keyword;
} }
case "literal": { case 'literal': {
switch (node.literal.kind) { switch (node.literal.kind) {
case "boolean": { case 'boolean': {
if (node.literal.boolean) { if (node.literal.boolean) {
return "true"; return 'true';
} else { } else {
return "false"; return 'false';
} }
} }
case "string": { case 'string': {
return node.literal.string; return node.literal.string;
} }
case "template": { case 'template': {
let result = ""; let result = '';
result += "`"; result += '`';
for (const tsType of node.literal.tsTypes) { for (const tsType of node.literal.tsTypes) {
if (tsType.kind === "literal") { if (tsType.kind === 'literal') {
if (tsType.literal.kind === "string") { if (tsType.literal.kind === 'string') {
result += tsType.literal.string; result += tsType.literal.string;
continue; continue;
} }
} }
result += "${"; result += '${';
result += formatType(tsType, options); result += formatType(tsType, options);
result += "}"; result += '}';
} }
result += "`"; result += '`';
return result; return result;
} }
case "number": { case 'number': {
return node.literal.number.toString(); return node.literal.number.toString();
} }
case "bigInt": { case 'bigInt': {
return node.literal.string; return node.literal.string;
} }
} }
@ -201,75 +192,66 @@ export function formatType(
throw new Error(`Not reachable`); throw new Error(`Not reachable`);
} }
case "optional": { case 'optional': {
return `${formatType(node.optional, options)}?`; return `${formatType(node.optional, options)}?`;
} }
case "parenthesized": { case 'parenthesized': {
return `(${formatType(node.parenthesized, options)})`; return `(${formatType(node.parenthesized, options)})`;
} }
case "rest": { case 'rest': {
return `...${formatType(node.rest, options)}`; return `...${formatType(node.rest, options)}`;
} }
case "this": { case 'this': {
return `this`; return `this`;
} }
case "tuple": { case 'tuple': {
let result = ""; let result = '';
result += "["; result += '[';
result += node.tuple.map((item) => formatType(item, options)).join(", "); result += node.tuple.map(item => formatType(item, options)).join(', ');
result += "]"; result += ']';
return result; return result;
} }
case "typeLiteral": { case 'typeLiteral': {
let result = ""; let result = '';
result += "{ "; result += '{ ';
result += node.typeLiteral.callSignatures.map((sig) => result += node.typeLiteral.callSignatures.map(sig => formatCallSignatureDef(sig, options)).join('; ');
formatCallSignatureDef(sig, options) result += node.typeLiteral.methods.map(m => formatMethodDef(m, options)).join('; ');
).join("; "); result += node.typeLiteral.properties.map(p => formatPropertyDef(p, options)).join('; ');
result += node.typeLiteral.methods.map((m) => formatMethodDef(m, options)) result += node.typeLiteral.indexSignatures
.join( .map(indexSignature => formatIndexSignatureDef(indexSignature, options))
"; ", .join('; ');
);
result += node.typeLiteral.properties.map((p) =>
formatPropertyDef(p, options)
)
.join("; ");
result += node.typeLiteral.indexSignatures.map((indexSignature) =>
formatIndexSignatureDef(indexSignature, options)
)
.join("; ");
result += result += " }"; result += result += ' }';
result += "}"; result += '}';
return result; return result;
} }
case "typeOperator": { case 'typeOperator': {
let result = ""; let result = '';
switch (node.typeOperator.operator) { switch (node.typeOperator.operator) {
case "readonly": { case 'readonly': {
if (!options.display?.readonly) { if (!options.display?.readonly) {
break; break;
} }
result += node.typeOperator.operator; result += node.typeOperator.operator;
result += " "; result += ' ';
break; break;
} }
default: { default: {
result += node.typeOperator.operator; result += node.typeOperator.operator;
result += " "; result += ' ';
break; break;
} }
} }
@ -279,32 +261,29 @@ export function formatType(
return result; return result;
} }
case "typeQuery": { case 'typeQuery': {
return `typeof ${node.typeQuery}`; return `typeof ${node.typeQuery}`;
} }
case "typeRef": { case 'typeRef': {
let result = ""; let result = '';
result += node.typeRef.typeName; result += node.typeRef.typeName;
if (node.typeRef.typeParams != null) { if (node.typeRef.typeParams != null) {
result += "<"; result += '<';
result += node.typeRef.typeParams.map((p) => formatType(p, options)) result += node.typeRef.typeParams.map(p => formatType(p, options)).join(', ');
.join( result += '>';
", ",
);
result += ">";
} }
return result; return result;
} }
case "union": { case 'union': {
return node.union.map((u) => formatType(u, options)).join(" | "); return node.union.map(u => formatType(u, options)).join(' | ');
} }
case "typePredicate": { case 'typePredicate': {
return node.repr; return node.repr;
} }
} }

View File

@ -1,25 +1,24 @@
import "@std/dotenv/load"; import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { doc, DocNode } from "@deno/doc"; import { doc, DocNode } from '@deno/doc';
import { differenceWith, groupBy } from "@es-toolkit/es-toolkit"; import { differenceWith, groupBy } from '@es-toolkit/es-toolkit';
import path from "node:path"; import '@std/dotenv/load';
import { fileURLToPath } from "node:url"; import { render as renderEN } from './operations/render/en.ts';
import { toDocumentationItem } from "./operations/toDocumentationItem.ts"; import { render as renderJA } from './operations/render/ja.ts';
import { render as renderEN } from "./operations/render/en.ts"; import { render as renderKO } from './operations/render/ko.ts';
import { render as renderKO } from "./operations/render/ko.ts"; import { RenderOptions } from './operations/render/types.ts';
import { render as renderZH } from "./operations/render/zh_hans.ts"; import { render as renderZH } from './operations/render/zh_hans.ts';
import { render as renderJA } from "./operations/render/ja.ts"; import { toDocumentationItem } from './operations/toDocumentationItem.ts';
import { translate } from "./operations/translate.ts"; import { translate } from './operations/translate.ts';
import { DocumentationItem } from "./types/DocumentationItem.ts"; import { DocumentationItem } from './types/DocumentationItem.ts';
import { Locale } from "./types/Locale.ts"; import { Locale } from './types/Locale.ts';
import { RenderOptions } from "./operations/render/types.ts";
// eslint-disable-next-line // eslint-disable-next-line
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
const basePath = path.resolve(__dirname, "..", "..", "src"); const basePath = path.resolve(__dirname, '..', '..', 'src');
const openAiApiKey = Deno.env.get("OPENAI_API_KEY")!; const openAiApiKey = Deno.env.get('OPENAI_API_KEY')!;
if (openAiApiKey == null) { if (openAiApiKey == null) {
throw new Error(`OPENAI_API_KEY is not provided.`); throw new Error(`OPENAI_API_KEY is not provided.`);
@ -29,43 +28,35 @@ type DocumentationItems = Array<{ docPath: string; item: DocumentationItem }>;
type DocumentationPaths = Record<Locale, string>; type DocumentationPaths = Record<Locale, string>;
async function run() { async function run() {
const docsRoot = path.resolve(__dirname, "..", "..", "docs"); const docsRoot = path.resolve(__dirname, '..', '..', 'docs');
const docsPaths: DocumentationPaths = { const docsPaths: DocumentationPaths = {
en: path.join(docsRoot, "reference"), en: path.join(docsRoot, 'reference'),
ko: path.join(docsRoot, "ko", "reference"), ko: path.join(docsRoot, 'ko', 'reference'),
ja: path.join(docsRoot, "ja", "reference"), ja: path.join(docsRoot, 'ja', 'reference'),
zh_hans: path.join(docsRoot, "zh_hans", "reference"), zh_hans: path.join(docsRoot, 'zh_hans', 'reference'),
}; };
const items = toDocumentationItems( const items = toDocumentationItems(await doc(`file:${path.join(basePath, 'index.ts')}`));
await doc(`file:${path.join(basePath, "index.ts")}`),
);
await renderDocs(docsPaths, items); await renderDocs(docsPaths, items);
const compatItems = differenceWith( const compatItems = differenceWith(
toDocumentationItems( toDocumentationItems(await doc(`file:${path.join(basePath, 'compat', 'index.ts')}`)),
await doc(`file:${path.join(basePath, "compat", "index.ts")}`),
),
items, items,
(x, y) => x.item.name === y.item.name, (x, y) => x.item.name === y.item.name
); );
await renderDocs(docsPaths, compatItems, { compat: true }); await renderDocs(docsPaths, compatItems, { compat: true });
} }
async function renderDocs( async function renderDocs(docsPaths: DocumentationPaths, items: DocumentationItems, options: RenderOptions = {}) {
docsPaths: DocumentationPaths,
items: DocumentationItems,
options: RenderOptions = {},
) {
for (const { docPath, item } of items) { for (const { docPath, item } of items) {
console.log(`> Doc: ${docPath}`); console.log(`> Doc: ${docPath}`);
const enPath = path.join(docsPaths.en, docPath); const enPath = path.join(docsPaths.en, docPath);
if (!await exists(enPath)) { if (!(await exists(enPath))) {
console.log(`> Generating English docs for for: ${docPath}`); console.log(`> Generating English docs for for: ${docPath}`);
await Deno.mkdir(path.dirname(enPath), { recursive: true }); await Deno.mkdir(path.dirname(enPath), { recursive: true });
await Deno.writeTextFile(enPath, renderEN(item, options)); await Deno.writeTextFile(enPath, renderEN(item, options));
@ -73,27 +64,27 @@ async function renderDocs(
const koPath = path.join(docsPaths.ko, docPath); const koPath = path.join(docsPaths.ko, docPath);
if (!await exists(koPath)) { if (!(await exists(koPath))) {
console.log(`> Generating Korean docs for for: ${docPath}`); console.log(`> Generating Korean docs for for: ${docPath}`);
const translated = await translate(item, "ko", { openAiApiKey }); const translated = await translate(item, 'ko', { openAiApiKey });
await Deno.mkdir(path.dirname(koPath), { recursive: true }); await Deno.mkdir(path.dirname(koPath), { recursive: true });
await Deno.writeTextFile(koPath, renderKO(translated, options)); await Deno.writeTextFile(koPath, renderKO(translated, options));
} }
const jaPath = path.join(docsPaths.ja, docPath); const jaPath = path.join(docsPaths.ja, docPath);
if (!await exists(jaPath)) { if (!(await exists(jaPath))) {
console.log(`> Generating Japanese docs for for: ${docPath}`); console.log(`> Generating Japanese docs for for: ${docPath}`);
const translated = await translate(item, "ja", { openAiApiKey }); const translated = await translate(item, 'ja', { openAiApiKey });
await Deno.mkdir(path.dirname(jaPath), { recursive: true }); await Deno.mkdir(path.dirname(jaPath), { recursive: true });
await Deno.writeTextFile(jaPath, renderJA(translated, options)); await Deno.writeTextFile(jaPath, renderJA(translated, options));
} }
const zhPath = path.join(docsPaths.zh_hans, docPath); const zhPath = path.join(docsPaths.zh_hans, docPath);
if (!await exists(zhPath)) { if (!(await exists(zhPath))) {
console.log(`> Generating Simplified Chinese docs for for: ${docPath}`); console.log(`> Generating Simplified Chinese docs for for: ${docPath}`);
const translated = await translate(item, "zh_hans", { openAiApiKey }); const translated = await translate(item, 'zh_hans', { openAiApiKey });
await Deno.mkdir(path.dirname(zhPath), { recursive: true }); await Deno.mkdir(path.dirname(zhPath), { recursive: true });
await Deno.writeTextFile(zhPath, renderZH(translated, options)); await Deno.writeTextFile(zhPath, renderZH(translated, options));
} }
@ -113,15 +104,15 @@ async function exists(path: string): Promise<boolean> {
} }
function toDocumentationItems(docs: DocNode[]): DocumentationItems { function toDocumentationItems(docs: DocNode[]): DocumentationItems {
const entries = Object.entries(groupBy(docs, (x) => x.name)); const entries = Object.entries(groupBy(docs, x => x.name));
return entries return entries
.filter(([name, entries]) => { .filter(([name, entries]) => {
if (name === "") { if (name === '') {
return false; return false;
} }
if (entries.some((x) => x.kind !== "class" && x.kind !== "function")) { if (entries.some(x => x.kind !== 'class' && x.kind !== 'function')) {
return false; return false;
} }
@ -129,10 +120,7 @@ function toDocumentationItems(docs: DocNode[]): DocumentationItems {
}) })
.map(([name, entries]) => { .map(([name, entries]) => {
const sourcePath = fileURLToPath(entries[0].location.filename); const sourcePath = fileURLToPath(entries[0].location.filename);
const docPath: string = path.relative(basePath, sourcePath).replace( const docPath: string = path.relative(basePath, sourcePath).replace(/.ts$/g, '.md');
/.ts$/g,
".md",
);
return { return {
docPath: docPath, docPath: docPath,

View File

@ -1,15 +1,10 @@
import { DocumentationItem } from "../../types/DocumentationItem.ts"; import { RenderOptions } from './types.ts';
import { RenderOptions } from "./types.ts"; import { DocumentationItem } from '../../types/DocumentationItem.ts';
export function render(item: DocumentationItem, options: RenderOptions = {}) { export function render(item: DocumentationItem, options: RenderOptions = {}) {
return [ return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)]
title(item.name), .filter(x => x != null)
compatNotice(options), .join('\n\n');
item.description,
signature(item),
examples(item),
]
.filter((x) => x != null).join("\n\n");
} }
function title(name: string) { function title(name: string) {
@ -31,12 +26,7 @@ When imported from \`es-toolkit/compat\`, it behaves exactly like lodash and pro
} }
function signature(item: DocumentationItem) { function signature(item: DocumentationItem) {
return [ return ['## Signature', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n');
"## Signature",
symbolInterface(item),
parameters(item),
returns(item),
].filter((x) => x != null).join("\n\n");
} }
function symbolInterface(item: DocumentationItem): string { function symbolInterface(item: DocumentationItem): string {
@ -55,10 +45,7 @@ function parameters(item: DocumentationItem) {
return ` return `
### Parameters ### Parameters
${ ${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')}
item.parameters.map((p) => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`)
.join("\n")
}
`.trim(); `.trim();
} }
@ -91,7 +78,7 @@ function examples(item: DocumentationItem) {
## Examples ## Examples
\`\`\`typescript \`\`\`typescript
${item.exampleCodes.join("\n\n")} ${item.exampleCodes.join('\n\n')}
\`\`\` \`\`\`
`.trim(); `.trim();
} }

View File

@ -1,15 +1,10 @@
import { DocumentationItem } from "../../types/DocumentationItem.ts"; import { RenderOptions } from './types.ts';
import { RenderOptions } from "./types.ts"; import { DocumentationItem } from '../../types/DocumentationItem.ts';
export function render(item: DocumentationItem, options: RenderOptions = {}) { export function render(item: DocumentationItem, options: RenderOptions = {}) {
return [ return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)]
title(item.name), .filter(x => x != null)
compatNotice(options), .join('\n\n');
item.description,
signature(item),
examples(item),
]
.filter((x) => x != null).join("\n\n");
} }
function title(name: string) { function title(name: string) {
@ -31,14 +26,9 @@ function compatNotice(options: RenderOptions) {
} }
function signature(item: DocumentationItem) { function signature(item: DocumentationItem) {
return [ return ['## インターフェース', symbolInterface(item), parameters(item), returns(item)]
"## インターフェース", .filter(x => x != null)
symbolInterface(item), .join('\n\n');
parameters(item),
returns(item),
]
.filter((x) => x != null)
.join("\n\n");
} }
function symbolInterface(item: DocumentationItem): string { function symbolInterface(item: DocumentationItem): string {
@ -57,10 +47,7 @@ function parameters(item: DocumentationItem) {
return ` return `
### ###
${ ${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')}
item.parameters.map((p) => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`)
.join("\n")
}
`.trim(); `.trim();
} }
@ -85,7 +72,7 @@ function examples(item: DocumentationItem) {
## ##
\`\`\`typescript \`\`\`typescript
${item.exampleCodes.join("\n\n")} ${item.exampleCodes.join('\n\n')}
\`\`\` \`\`\`
`.trim(); `.trim();
} }

View File

@ -1,15 +1,10 @@
import { DocumentationItem } from "../../types/DocumentationItem.ts"; import { RenderOptions } from './types.ts';
import { RenderOptions } from "./types.ts"; import { DocumentationItem } from '../../types/DocumentationItem.ts';
export function render(item: DocumentationItem, options: RenderOptions = {}) { export function render(item: DocumentationItem, options: RenderOptions = {}) {
return [ return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)]
title(item.name), .filter(x => x != null)
compatNotice(options), .join('\n\n');
item.description,
signature(item),
examples(item),
]
.filter((x) => x != null).join("\n\n");
} }
function title(name: string) { function title(name: string) {
@ -31,12 +26,7 @@ function compatNotice(options: RenderOptions) {
} }
function signature(item: DocumentationItem) { function signature(item: DocumentationItem) {
return [ return ['## 인터페이스', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n');
"## 인터페이스",
symbolInterface(item),
parameters(item),
returns(item),
].filter((x) => x != null).join("\n\n");
} }
function symbolInterface(item: DocumentationItem): string { function symbolInterface(item: DocumentationItem): string {
@ -55,10 +45,7 @@ function parameters(item: DocumentationItem) {
return ` return `
### ###
${ ${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')}
item.parameters.map((p) => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`)
.join("\n")
}
`.trim(); `.trim();
} }
@ -83,7 +70,7 @@ function examples(item: DocumentationItem) {
## ##
\`\`\`typescript \`\`\`typescript
${item.exampleCodes.join("\n\n")} ${item.exampleCodes.join('\n\n')}
\`\`\` \`\`\`
`.trim(); `.trim();
} }

View File

@ -1,15 +1,10 @@
import { DocumentationItem } from "../../types/DocumentationItem.ts"; import { RenderOptions } from './types.ts';
import { RenderOptions } from "./types.ts"; import { DocumentationItem } from '../../types/DocumentationItem.ts';
export function render(item: DocumentationItem, options: RenderOptions = {}) { export function render(item: DocumentationItem, options: RenderOptions = {}) {
return [ return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)]
title(item.name), .filter(x => x != null)
compatNotice(options), .join('\n\n');
item.description,
signature(item),
examples(item),
]
.filter((x) => x != null).join("\n\n");
} }
function title(name: string) { function title(name: string) {
@ -31,8 +26,7 @@ function compatNotice(options: RenderOptions) {
} }
function signature(item: DocumentationItem) { function signature(item: DocumentationItem) {
return ["## 签名", symbolInterface(item), parameters(item), returns(item)] return ['## 签名', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n');
.filter((x) => x != null).join("\n\n");
} }
function symbolInterface(item: DocumentationItem): string { function symbolInterface(item: DocumentationItem): string {
@ -51,10 +45,7 @@ function parameters(item: DocumentationItem) {
return ` return `
### ###
${ ${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')}
item.parameters.map((p) => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`)
.join("\n")
}
`.trim(); `.trim();
} }
@ -79,7 +70,7 @@ function examples(item: DocumentationItem) {
## ##
\`\`\`typescript \`\`\`typescript
${item.exampleCodes.join("\n\n")} ${item.exampleCodes.join('\n\n')}
\`\`\` \`\`\`
`.trim(); `.trim();
} }

View File

@ -1,18 +1,9 @@
import { import { DocNode, JsDocTag, JsDocTagDocRequired, JsDocTagParam, JsDocTagReturn } from '@deno/doc';
DocNode, import { formatClassDoc } from '../formatters/class.ts';
JsDocTag, import { formatFunctionDoc } from '../formatters/function.ts';
JsDocTagDocRequired, import { DocumentationItem } from '../types/DocumentationItem.ts';
JsDocTagParam,
JsDocTagReturn,
} from "@deno/doc";
import { DocumentationItem } from "../types/DocumentationItem.ts";
import { formatFunctionDoc } from "../formatters/function.ts";
import { formatClassDoc } from "../formatters/class.ts";
export function toDocumentationItem( export function toDocumentationItem(symbolName: string, docs: DocNode[]): DocumentationItem {
symbolName: string,
docs: DocNode[],
): DocumentationItem {
const lastDoc = docs.at(-1) ?? docs.at(0); const lastDoc = docs.at(-1) ?? docs.at(0);
const tags = lastDoc?.jsDoc?.tags ?? []; const tags = lastDoc?.jsDoc?.tags ?? [];
@ -20,7 +11,7 @@ export function toDocumentationItem(
if (description == null) { if (description == null) {
throw new Error( throw new Error(
`No description provided for ${symbolName} (${lastDoc?.location.filename}:${lastDoc?.location.line}:${lastDoc?.location.col}).`, `No description provided for ${symbolName} (${lastDoc?.location.filename}:${lastDoc?.location.line}:${lastDoc?.location.col}).`
); );
} }
@ -40,10 +31,10 @@ function toSignature(symbolName: string, docs: DocNode[]) {
} }
switch (docs[0].kind) { switch (docs[0].kind) {
case "function": { case 'function': {
return toFunctionSignature(symbolName, docs); return toFunctionSignature(symbolName, docs);
} }
case "class": { case 'class': {
return toClassSignature(symbolName, docs); return toClassSignature(symbolName, docs);
} }
} }
@ -53,45 +44,36 @@ function toSignature(symbolName: string, docs: DocNode[]) {
function toFunctionSignature(symbolName: string, docs: DocNode[]) { function toFunctionSignature(symbolName: string, docs: DocNode[]) {
return docs return docs
.map((doc) => { .map(doc => {
if (doc.kind !== "function") { if (doc.kind !== 'function') {
throw new Error( throw new Error(`Unsupported document type in ${symbolName}: ${doc.kind}`);
`Unsupported document type in ${symbolName}: ${doc.kind}`,
);
} }
return `${formatFunctionDoc(doc, { display: { readonly: false } })};`; return `${formatFunctionDoc(doc, { display: { readonly: false } })};`;
}) })
.join("\n"); .join('\n');
} }
function toClassSignature(symbolName: string, docs: DocNode[]) { function toClassSignature(symbolName: string, docs: DocNode[]) {
return docs return docs
.map((doc) => { .map(doc => {
if (doc.kind !== "class") { if (doc.kind !== 'class') {
throw new Error( throw new Error(`Unsupported document type in ${symbolName}: ${doc.kind}`);
`Unsupported document type in ${symbolName}: ${doc.kind}`,
);
} }
return `${formatClassDoc(doc, { display: { readonly: false } })}`; return `${formatClassDoc(doc, { display: { readonly: false } })}`;
}) })
.join("\n"); .join('\n');
} }
function toParameters( function toParameters(symbolName: string, tags: JsDocTag[]): DocumentationItem['parameters'] {
symbolName: string, const parameters = tags.filter((tag): tag is JsDocTagParam => tag.kind === 'param');
tags: JsDocTag[],
): DocumentationItem["parameters"] {
const parameters = tags.filter((tag): tag is JsDocTagParam =>
tag.kind === "param"
);
if (parameters.length === 0) { if (parameters.length === 0) {
return null; return null;
} }
return parameters.map((param) => { return parameters.map(param => {
if (param.name == null) { if (param.name == null) {
throw new Error(`parameter name is not provided in ${symbolName}.`); throw new Error(`parameter name is not provided in ${symbolName}.`);
} }
@ -107,17 +89,13 @@ function toParameters(
return { return {
name: param.name, name: param.name,
type: param.type, type: param.type,
document: param.doc.replace(/^- /g, ""), document: param.doc.replace(/^- /g, ''),
}; };
}); });
} }
function toReturns( function toReturns(symbolName: string, tags: JsDocTag[]): DocumentationItem['returns'] {
symbolName: string, const returns = tags.filter((x): x is JsDocTagReturn => x.kind === 'return')[0];
tags: JsDocTag[],
): DocumentationItem["returns"] {
const returns =
tags.filter((x): x is JsDocTagReturn => x.kind === "return")[0];
if (returns == null) { if (returns == null) {
return null; return null;
@ -129,18 +107,16 @@ function toReturns(
return { return {
type: returns.type ?? null, type: returns.type ?? null,
document: returns.doc.replace(/^- /g, ""), document: returns.doc.replace(/^- /g, ''),
}; };
} }
function toExampleCodes(tags: JsDocTag[]) { function toExampleCodes(tags: JsDocTag[]) {
const examples = tags.filter((x): x is JsDocTagDocRequired => const examples = tags.filter((x): x is JsDocTagDocRequired => x.kind === 'example');
x.kind === "example"
);
if (examples.length === 0) { if (examples.length === 0) {
return []; return [];
} }
return examples.map((x) => x.doc.trim()); return examples.map(x => x.doc.trim());
} }

View File

@ -1,7 +1,7 @@
import { pick, toMerged } from "@es-toolkit/es-toolkit"; import OpenAI from 'openai';
import OpenAI from "openai"; import { pick, toMerged } from '@es-toolkit/es-toolkit';
import { DocumentationItem } from "../types/DocumentationItem.ts"; import { DocumentationItem } from '../types/DocumentationItem.ts';
import { Locale } from "../types/Locale.ts"; import { Locale } from '../types/Locale.ts';
interface TranslateOptions { interface TranslateOptions {
openAiApiKey: string; openAiApiKey: string;
@ -10,7 +10,7 @@ interface TranslateOptions {
export async function translate( export async function translate(
doc: DocumentationItem, doc: DocumentationItem,
locale: Locale, locale: Locale,
{ openAiApiKey }: TranslateOptions, { openAiApiKey }: TranslateOptions
): Promise<DocumentationItem> { ): Promise<DocumentationItem> {
const client = new OpenAI({ const client = new OpenAI({
apiKey: openAiApiKey, apiKey: openAiApiKey,
@ -18,10 +18,10 @@ export async function translate(
const item = { const item = {
description: doc.description, description: doc.description,
parameters: doc.parameters?.map((param) => { parameters: doc.parameters?.map(param => {
return pick(param, ["document"]); return pick(param, ['document']);
}), }),
returns: pick(doc.returns! ?? {}, ["document"]), returns: pick(doc.returns! ?? {}, ['document']),
}; };
const prompt = ` const prompt = `
@ -39,8 +39,8 @@ ${JSON.stringify(item, null, 2)}
`; `;
const response = await client.chat.completions.create({ const response = await client.chat.completions.create({
model: "gpt-4o", model: 'gpt-4o',
messages: [{ role: "user", content: prompt }], messages: [{ role: 'user', content: prompt }],
}); });
const translatedItem = response.choices[0].message.content; const translatedItem = response.choices[0].message.content;

View File

@ -2,13 +2,11 @@ export interface DocumentationItem {
name: string; name: string;
description: string; description: string;
signature: string; signature: string;
parameters: parameters: Array<{
| Array<{ name: string;
name: string; type: string;
type: string; document: string;
document: string; }> | null;
}>
| null;
returns: { returns: {
type: string | null; type: string | null;
document: string; document: string;

View File

@ -1 +1 @@
export type Locale = "en" | "ko" | "ja" | "zh_hans"; export type Locale = 'en' | 'ko' | 'ja' | 'zh_hans';

View File

@ -1,8 +1,8 @@
import type { API, FileInfo } from 'jscodeshift'; import type { API, FileInfo } from 'jscodeshift';
import { formatBrokenSyntax } from './_internal/formatter/brokenSyntax'; import { formatBrokenSyntax } from './_internal/formatter/brokenSyntax';
import { transformAssert } from './_internal/transform/assert';
import { transformImport } from './_internal/transform/import'; import { transformImport } from './_internal/transform/import';
import { transformLodashStable } from './_internal/transform/lodashStable'; import { transformLodashStable } from './_internal/transform/lodashStable';
import { transformAssert } from './_internal/transform/assert';
export default function transform(file: FileInfo, { jscodeshift }: API) { export default function transform(file: FileInfo, { jscodeshift }: API) {
try { try {

View File

@ -8,9 +8,7 @@
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs", "prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib", "typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true, "typescript.enablePromptUseWorkspaceTsdk": true,
"deno.enablePaths": [ "deno.enablePaths": ["./.scripts/docs"],
"./.scripts/docs"
],
"deno.config": "./.scripts/docs/deno.json", "deno.config": "./.scripts/docs/deno.json",
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true, "editor.formatOnSave": true,

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { filter as filterToolkit } from 'es-toolkit/compat'; import { filter as filterToolkit } from 'es-toolkit/compat';
import { filter as filterLodash } from 'lodash'; import { filter as filterLodash } from 'lodash';
import { bench, describe } from 'vitest';
const arr = [ const arr = [
{ a: 0, b: true }, { a: 0, b: true },

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { initial as initialLodash } from 'lodash';
import { initial as initialToolkit } from 'es-toolkit'; import { initial as initialToolkit } from 'es-toolkit';
import { initial as initialLodash } from 'lodash';
// Helper function to generate a large array // Helper function to generate a large array
function generateLargeArray(size) { function generateLargeArray(size) {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { invert as invertByLodash } from 'lodash';
import { invert as invertByToolkit } from 'es-toolkit'; import { invert as invertByToolkit } from 'es-toolkit';
import { invert as invertByLodash } from 'lodash';
const object: { [key: string]: string } = {}; const object: { [key: string]: string } = {};
for (let i = 0; i < 10000; i++) { for (let i = 0; i < 10000; i++) {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { isFinite as isFiniteToolkit } from 'es-toolkit/compat'; import { isFinite as isFiniteToolkit } from 'es-toolkit/compat';
import { isFinite as isFiniteLodash } from 'lodash'; import { isFinite as isFiniteLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('isFinite', () => { describe('isFinite', () => {
bench('es-toolkit/isFinite', () => { bench('es-toolkit/isFinite', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { isRegExp as isRegExpToolkit } from 'es-toolkit/predicate';
import { isRegExp as isRegExpToolkitCompat } from 'es-toolkit/compat'; import { isRegExp as isRegExpToolkitCompat } from 'es-toolkit/compat';
import { isRegExp as isRegExpToolkit } from 'es-toolkit/predicate';
import { isRegExp as isRegExpLodash } from 'lodash'; import { isRegExp as isRegExpLodash } from 'lodash';
describe('isRegExp', () => { describe('isRegExp', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { isString as isStringToolkit } from 'es-toolkit/predicate';
import { isString as isStringToolkitCompat } from 'es-toolkit/compat'; import { isString as isStringToolkitCompat } from 'es-toolkit/compat';
import { isString as isStringToolkit } from 'es-toolkit/predicate';
import { isString as isStringLodash } from 'lodash'; import { isString as isStringLodash } from 'lodash';
describe('isString', () => { describe('isString', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { isSymbol as isSymbolToolkit } from 'es-toolkit/predicate';
import { isSymbol as isSymbolToolkitCompat } from 'es-toolkit/compat'; import { isSymbol as isSymbolToolkitCompat } from 'es-toolkit/compat';
import { isSymbol as isSymbolToolkit } from 'es-toolkit/predicate';
import { isSymbol as isSymbolLodash } from 'lodash'; import { isSymbol as isSymbolLodash } from 'lodash';
describe('isSymbol', () => { describe('isSymbol', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { omitBy as omitByToolkit } from 'es-toolkit'; import { omitBy as omitByToolkit } from 'es-toolkit';
import { omitBy as omitByLodash } from 'lodash'; import { omitBy as omitByLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('omitBy', () => { describe('omitBy', () => {
bench('es-toolkit/omitBy', () => { bench('es-toolkit/omitBy', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { once as onceToolkit } from 'es-toolkit'; import { once as onceToolkit } from 'es-toolkit';
import { once as onceLodash } from 'lodash'; import { once as onceLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('once', () => { describe('once', () => {
bench('es-toolkit/once', () => { bench('es-toolkit/once', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { property as propertyToolkit } from 'es-toolkit/compat'; import { property as propertyToolkit } from 'es-toolkit/compat';
import { property as propertyLodash } from 'lodash'; import { property as propertyLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('property', () => { describe('property', () => {
bench('es-toolkit/property', () => { bench('es-toolkit/property', () => {

View File

@ -1,4 +1,4 @@
import { describe, bench } from 'vitest'; import { bench, describe } from 'vitest';
import { set as setToolkitCompat } from 'es-toolkit/compat'; import { set as setToolkitCompat } from 'es-toolkit/compat';
import { set as lodashSet } from 'lodash'; import { set as lodashSet } from 'lodash';

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { some as someToolkit } from 'es-toolkit/compat'; import { some as someToolkit } from 'es-toolkit/compat';
import { some as someLodash } from 'lodash'; import { some as someLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('some', () => { describe('some', () => {
bench('es-toolkit/some', () => { bench('es-toolkit/some', () => {

View File

@ -1,7 +1,7 @@
import { bench, describe } from 'vitest';
import { startCase as startCaseToolkit } from 'es-toolkit'; import { startCase as startCaseToolkit } from 'es-toolkit';
import { startCase as startCaseToolkitCompat } from 'es-toolkit/compat'; import { startCase as startCaseToolkitCompat } from 'es-toolkit/compat';
import { startCase as startCaseLodash } from 'lodash'; import { startCase as startCaseLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('startCase', () => { describe('startCase', () => {
bench('es-toolkit/startCase', () => { bench('es-toolkit/startCase', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { fill as fillLodash } from 'lodash';
import { toFilled as toFilledToolkit } from 'es-toolkit'; import { toFilled as toFilledToolkit } from 'es-toolkit';
import { fill as fillLodash } from 'lodash';
describe('fill function performance comparison', () => { describe('fill function performance comparison', () => {
bench('es-toolkit/toFilled', () => { bench('es-toolkit/toFilled', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { union as unionToolkit } from 'es-toolkit'; import { union as unionToolkit } from 'es-toolkit';
import { union as unionLodash } from 'lodash'; import { union as unionLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('union', () => { describe('union', () => {
bench('es-toolkit/union', () => { bench('es-toolkit/union', () => {

View File

@ -1,7 +1,7 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { uniqBy as uniqByToolkit } from 'es-toolkit'; import { uniqBy as uniqByToolkit } from 'es-toolkit';
import { uniqBy as uniqByLodash } from 'lodash';
import { randomInt } from 'crypto'; import { randomInt } from 'crypto';
import { uniqBy as uniqByLodash } from 'lodash';
describe('uniqBy, small arrays', () => { describe('uniqBy, small arrays', () => {
bench('es-toolkit/uniqBy', () => { bench('es-toolkit/uniqBy', () => {

View File

@ -1,7 +1,7 @@
import { bench, describe } from 'vitest'; import { bench, describe } from 'vitest';
import { uniqWith as uniqWithToolkit } from 'es-toolkit'; import { uniqWith as uniqWithToolkit } from 'es-toolkit';
import { uniqWith as uniqWithLodash } from 'lodash';
import { randomInt } from 'crypto'; import { randomInt } from 'crypto';
import { uniqWith as uniqWithLodash } from 'lodash';
describe('uniqWith, small arrays', () => { describe('uniqWith, small arrays', () => {
bench('es-toolkit/uniqWith', () => { bench('es-toolkit/uniqWith', () => {

View File

@ -1,4 +1,4 @@
import { describe, bench } from 'vitest'; import { bench, describe } from 'vitest';
import { unset as unsetToolkitCompat } from 'es-toolkit/compat'; import { unset as unsetToolkitCompat } from 'es-toolkit/compat';
import { unset as unsetLodash } from 'lodash'; import { unset as unsetLodash } from 'lodash';

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { unzipWith as unzipWithToolkit } from 'es-toolkit'; import { unzipWith as unzipWithToolkit } from 'es-toolkit';
import { unzipWith as unzipWithLodash } from 'lodash'; import { unzipWith as unzipWithLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('unzipWith', () => { describe('unzipWith', () => {
bench('es-toolkit/unzipWith', () => { bench('es-toolkit/unzipWith', () => {

View File

@ -1,6 +1,6 @@
import { bench, describe } from 'vitest';
import { xorWith as xorWithToolkit } from 'es-toolkit'; import { xorWith as xorWithToolkit } from 'es-toolkit';
import { xorWith as xorWithLodash } from 'lodash'; import { xorWith as xorWithLodash } from 'lodash';
import { bench, describe } from 'vitest';
describe('xorWith', () => { describe('xorWith', () => {
bench('es-toolkit/xorWith', () => { bench('es-toolkit/xorWith', () => {

View File

@ -40,20 +40,10 @@ const ids = titles.map(title => title.toLowerCase().replaceAll('"', '').replace(
</script> </script>
<template> <template>
<template <template v-for="(category, index) in categories" :key="category">
v-for="(category, index) in categories" <h3 :id="ids[index]" tabindex="-1">
:key="category"
>
<h3
:id="ids[index]"
tabindex="-1"
>
{{ titles[index] }} {{ titles[index] }}
<a <a class="header-anchor" :href="`#${ids[index]}`" :aria-label="`Permalink to ${ids[index]}`" />
class="header-anchor"
:href="`#${ids[index]}`"
:aria-label="`Permalink to ${ids[index]}`"
/>
</h3> </h3>
<table tabindex="0"> <table tabindex="0">
<thead> <thead>
@ -63,16 +53,9 @@ const ids = titles.map(title => title.toLowerCase().replaceAll('"', '').replace(
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr <tr v-for="item in data[category]" :key="item.name">
v-for="item in data[category]"
:key="item.name"
>
<td> <td>
<a <a :href="`https://lodash.com/docs/4.17.15#${item.name}`" target="_blank" rel="noopener noreferrer">{{
:href="`https://lodash.com/docs/4.17.15#${item.name}`"
target="_blank"
rel="noopener noreferrer"
>{{
item.name item.name
}}</a> }}</a>
</td> </td>

View File

@ -1,11 +1,11 @@
import { defineConfig } from 'vitepress';
import container from 'markdown-it-container'; import container from 'markdown-it-container';
import { defineConfig } from 'vitepress';
import { renderSandbox } from 'vitepress-plugin-sandpack'; import { renderSandbox } from 'vitepress-plugin-sandpack';
import { en } from './en.mts'; import { en } from './en.mts';
import { ko } from './ko.mts';
import { ja } from './ja.mts'; import { ja } from './ja.mts';
import { zh_hans } from './zh_hans.mts'; import { ko } from './ko.mts';
import { shared } from './shared.mts'; import { shared } from './shared.mts';
import { zh_hans } from './zh_hans.mts';
export default defineConfig({ export default defineConfig({
...shared, ...shared,

View File

@ -1,7 +1,7 @@
import { type DefaultTheme, defineConfig } from 'vitepress';
import { sortByText } from './libs/sortByText.mts';
import { getSidebarItems } from './libs/getSidebarItems.mts';
import path from 'node:path'; import path from 'node:path';
import { type DefaultTheme, defineConfig } from 'vitepress';
import { getSidebarItems } from './libs/getSidebarItems.mts';
import { sortByText } from './libs/sortByText.mts';
const docsRoot = path.resolve(import.meta.dirname, '..'); const docsRoot = path.resolve(import.meta.dirname, '..');

View File

@ -1,7 +1,7 @@
import { type DefaultTheme, defineConfig } from 'vitepress';
import { sortByText } from './libs/sortByText.mts';
import { getSidebarItems } from './libs/getSidebarItems.mts';
import path from 'node:path'; import path from 'node:path';
import { type DefaultTheme, defineConfig } from 'vitepress';
import { getSidebarItems } from './libs/getSidebarItems.mts';
import { sortByText } from './libs/sortByText.mts';
const docsRoot = path.resolve(import.meta.dirname, '..'); const docsRoot = path.resolve(import.meta.dirname, '..');

View File

@ -1,6 +1,6 @@
import { readdirSync } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import functions from './functions.json'; import functions from './functions.json';
import { readdirSync } from 'fs';
export default { export default {
load() { load() {

View File

@ -1,6 +1,6 @@
import { DefaultTheme } from 'vitepress';
import path from 'node:path';
import glob from 'fast-glob'; import glob from 'fast-glob';
import path from 'node:path';
import { DefaultTheme } from 'vitepress';
export function getSidebarItems(docsRoot: string, ...parts: string[]): DefaultTheme.SidebarItem[] { export function getSidebarItems(docsRoot: string, ...parts: string[]): DefaultTheme.SidebarItem[] {
const files = glob.sync(path.join(docsRoot, ...parts, '*')); const files = glob.sync(path.join(docsRoot, ...parts, '*'));

View File

@ -1,7 +1,7 @@
import { type DefaultTheme, defineConfig } from 'vitepress';
import { sortByText } from './libs/sortByText.mts';
import path from 'node:path'; import path from 'node:path';
import { type DefaultTheme, defineConfig } from 'vitepress';
import { getSidebarItems } from './libs/getSidebarItems.mts'; import { getSidebarItems } from './libs/getSidebarItems.mts';
import { sortByText } from './libs/sortByText.mts';
const docsRoot = path.resolve(import.meta.dirname, '..'); const docsRoot = path.resolve(import.meta.dirname, '..');

View File

@ -1,10 +1,10 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import jsdoc from 'eslint-plugin-jsdoc'; import jsdoc from 'eslint-plugin-jsdoc';
import prettier from 'eslint-config-prettier';
import pluginVue from 'eslint-plugin-vue';
import noForOfArrayPlugin from 'eslint-plugin-no-for-of-array'; import noForOfArrayPlugin from 'eslint-plugin-no-for-of-array';
import prettier from 'eslint-plugin-prettier/recommended';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import pluginJs from '@eslint/js';
export default [ export default [
{ {

View File

@ -137,17 +137,20 @@
"@eslint/js": "^9.9.0", "@eslint/js": "^9.9.0",
"@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6", "@rollup/plugin-typescript": "^11.1.6",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/broken-link-checker": "^0", "@types/broken-link-checker": "^0",
"@types/eslint": "^9", "@types/eslint": "^9",
"@types/jscodeshift": "^0.11.11", "@types/jscodeshift": "^0.11.11",
"@types/node": "^20.12.11", "@types/node": "^20.12.11",
"@types/tar": "^6.1.13", "@types/tar": "^6.1.13",
"@vitest/coverage-istanbul": "^1.5.2", "@vitest/coverage-istanbul": "^1.5.2",
"@vue/compiler-sfc": "^3.5.10",
"broken-link-checker": "^0.7.8", "broken-link-checker": "^0.7.8",
"eslint": "^9.9.0", "eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.2", "eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-no-for-of-array": "^0.0.1", "eslint-plugin-no-for-of-array": "^0.0.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.28.0", "eslint-plugin-vue": "^9.28.0",
"execa": "^9.3.0", "execa": "^9.3.0",
"globals": "^15.9.0", "globals": "^15.9.0",
@ -162,6 +165,11 @@
"typescript-eslint": "^8.1.0", "typescript-eslint": "^8.1.0",
"vitest": "^1.5.2" "vitest": "^1.5.2"
}, },
"dependenciesMeta": {
"@trivago/prettier-plugin-sort-imports@4.3.0": {
"unplugged": true
}
},
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"prepack": "yarn build", "prepack": "yarn build",

View File

@ -1,12 +1,11 @@
// @ts-check // @ts-check
import fs from 'node:fs'; import fs from 'node:fs';
import { createRequire } from 'node:module'; import { createRequire } from 'node:module';
import { dirname, join } from 'node:path'; import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import dtsPlugin from 'rollup-plugin-dts';
import terserPlugin from '@rollup/plugin-terser'; import terserPlugin from '@rollup/plugin-terser';
import tsPlugin from '@rollup/plugin-typescript'; import tsPlugin from '@rollup/plugin-typescript';
import dtsPlugin from 'rollup-plugin-dts';
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { compact } from './compact'; import { compact } from './compact';
describe('compact', () => { describe('compact', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { isSubset } from './isSubset'; import { isSubset } from './isSubset';
describe('isSubset', () => { describe('isSubset', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { orderBy } from './orderBy'; import { orderBy } from './orderBy';
describe('orderBy', () => { describe('orderBy', () => {

View File

@ -1,4 +1,4 @@
import { describe, expect, it, expectTypeOf } from 'vitest'; import { describe, expect, expectTypeOf, it } from 'vitest';
import { partition } from './partition'; import { partition } from './partition';
describe('partition', () => { describe('partition', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { sortBy } from './sortBy'; import { sortBy } from './sortBy';
describe('sortBy', () => { describe('sortBy', () => {

View File

@ -1,5 +1,7 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { takeWhile } from './takeWhile'; // adjust the import path as necessary import { takeWhile } from './takeWhile';
// adjust the import path as necessary
describe('takeWhile', () => { describe('takeWhile', () => {
it('should return elements while the predicate is true', () => { it('should return elements while the predicate is true', () => {

View File

@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { unzip } from './unzip'; import { unzip } from './unzip';
describe('unzip', () => { describe('unzip', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { compareValues } from './compareValues'; import { compareValues } from './compareValues';
describe('compareValues', () => { describe('compareValues', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { getTag } from './getTag'; import { getTag } from './getTag';
describe('getTag function', () => { describe('getTag function', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { isKey } from './isKey'; import { isKey } from './isKey';
describe('isKey', () => { describe('isKey', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { toArgs } from './toArgs'; import { toArgs } from './toArgs';
describe('toArgs', () => { describe('toArgs', () => {

View File

@ -1,5 +1,5 @@
import { chunk } from './chunk.ts';
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { chunk } from './chunk.ts';
/** /**
* @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/chunk.spec.js#L1 * @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/chunk.spec.js#L1

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { difference } from './difference'; import { difference } from './difference';
import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE';
/** /**
* @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/difference-methods.spec.js#L1 * @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/difference-methods.spec.js#L1

View File

@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { every } from './every'; import { every } from './every';
import { identity } from '../_internal/identity';
import { empties } from '../_internal/empties'; import { empties } from '../_internal/empties';
import { stubTrue } from '../_internal/stubTrue'; import { identity } from '../_internal/identity';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
describe('every', () => { describe('every', () => {
it('should return true for array with all elements passing predicate', () => { it('should return true for array with all elements passing predicate', () => {

View File

@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { falsey } from '../_internal/falsey';
import { fill } from './fill.ts'; import { fill } from './fill.ts';
import { falsey } from '../_internal/falsey';
describe('fill', () => { describe('fill', () => {
it('should use a default `start` of `0` and a default `end` of `length`', () => { it('should use a default `start` of `0` and a default `end` of `length`', () => {

View File

@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { empties } from '../_internal/empties';
import { find } from './find'; import { find } from './find';
import { empties } from '../_internal/empties';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
describe('find', () => { describe('find', () => {

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { findLastIndex } from './findLastIndex'; import { findLastIndex } from './findLastIndex';
import { falsey } from '../_internal/falsey';
import { slice } from '../_internal/slice'; import { slice } from '../_internal/slice';
import { stubZero } from '../_internal/stubZero'; import { stubZero } from '../_internal/stubZero';
import { falsey } from '../_internal/falsey';
describe('findLastIndex', () => { describe('findLastIndex', () => {
const objects = [ const objects = [

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { flatten } from './flatten'; import { flatten } from './flatten';
import { args } from '../_internal/args'; import { args } from '../_internal/args';

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { flattenDeep } from './flattenDeep'; import { flattenDeep } from './flattenDeep';
import { args } from '../_internal/args'; import { args } from '../_internal/args';

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { flattenDepth } from './flattenDepth'; import { flattenDepth } from './flattenDepth';
import { args } from '../_internal/args'; import { args } from '../_internal/args';

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { head, first } from '../index'; import { first, head } from '../index';
/** /**
* @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/head.spec.js#L1 * @see https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/test/head.spec.js#L1

View File

@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest';
import { includes } from './includes'; import { includes } from './includes';
import { describe, it, expect } from 'vitest';
import { stubFalse } from '../_internal/stubFalse';
import { empties } from '../_internal/empties';
import { toArgs } from '../_internal/toArgs';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { empties } from '../_internal/empties';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { stubFalse } from '../_internal/stubFalse';
import { toArgs } from '../_internal/toArgs';
describe('includes', () => { describe('includes', () => {
Object.entries({ Object.entries({

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { orderBy } from './orderBy.ts'; import { orderBy } from './orderBy.ts';
import { falsey } from '../_internal/falsey.ts';
import { zipObject } from '../../array/zipObject.ts'; import { zipObject } from '../../array/zipObject.ts';
import { partialRight } from '../../function/partialRight.ts'; import { partialRight } from '../../function/partialRight.ts';
import { falsey } from '../_internal/falsey.ts';
describe('orderBy', () => { describe('orderBy', () => {
class Pair { class Pair {

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { size } from './size';
import { falsey } from '../_internal/falsey'; import { falsey } from '../_internal/falsey';
import { toArgs } from '../_internal/toArgs'; import { toArgs } from '../_internal/toArgs';
import { size } from './size';
const args = toArgs([1, 2, 3]); const args = toArgs([1, 2, 3]);
/** /**

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { some } from './some'; import { some } from './some';
import { empties } from '../_internal/empties';
import { identity } from '../_internal/identity'; import { identity } from '../_internal/identity';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../_internal/stubFalse';
import { empties } from '../_internal/empties';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../_internal/stubTrue';
describe('some', () => { describe('some', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { attempt } from './attempt'; import { attempt } from './attempt';
import { isEqual } from '../../predicate/isEqual'; import { isEqual } from '../../predicate/isEqual';

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { bind } from './bind'; import { bind } from './bind';
import { isEqual } from '../../predicate/isEqual'; import { isEqual } from '../../predicate/isEqual';

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { bindKey } from './bindKey'; import { bindKey } from './bindKey';
describe('bindKey', () => { describe('bindKey', () => {

View File

@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { curry } from './curry';
import { bind } from './bind'; import { bind } from './bind';
import { curry } from './curry';
import { partial } from '../../function/partial'; import { partial } from '../../function/partial';
import { partialRight } from '../../function/partialRight'; import { partialRight } from '../../function/partialRight';

View File

@ -1,8 +1,8 @@
import { describe, expect, it, vi } from 'vitest'; import { describe, expect, it, vi } from 'vitest';
import { debounce } from './debounce'; import { debounce } from './debounce';
import { noop } from '../../function/noop';
import { delay } from '../../promise/delay'; import { delay } from '../../promise/delay';
import { identity } from '../_internal/identity'; import { identity } from '../_internal/identity';
import { noop } from '../../function/noop';
describe('debounce', () => { describe('debounce', () => {
it('should debounce function calls', async () => { it('should debounce function calls', async () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { rearg } from './rearg'; import { rearg } from './rearg';
describe('rearg', () => { describe('rearg', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { rest } from './rest'; import { rest } from './rest';
describe('rest', () => { describe('rest', () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { spread } from './spread'; import { spread } from './spread';
describe('spread', () => { describe('spread', () => {

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { throttle } from './throttle'; import { throttle } from './throttle';
import { noop } from '../../function/noop';
import { delay } from '../../promise/delay'; import { delay } from '../../promise/delay';
import { identity } from '../_internal/identity'; import { identity } from '../_internal/identity';
import { noop } from '../../function/noop';
describe('throttle', () => { describe('throttle', () => {
it('should throttle a function', async () => { it('should throttle a function', async () => {

View File

@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest'; import { describe, expect, it } from 'vitest';
import { parseInt } from './parseInt'; import { parseInt } from './parseInt';
describe('parseInt', () => { describe('parseInt', () => {

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import { random } from './random';
import { uniq } from '../../array/uniq'; import { uniq } from '../../array/uniq';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../_internal/stubTrue';
import { random } from './random';
import { describe, expect, it } from 'vitest';
describe('random', () => { describe('random', () => {
const array = Array.from({ length: 100 }); const array = Array.from({ length: 100 });

View File

@ -1,6 +1,6 @@
import { clamp } from './clamp.ts';
import { random as randomToolkit } from '../../math/random.ts'; import { random as randomToolkit } from '../../math/random.ts';
import { randomInt as randomIntToolkit } from '../../math/randomInt.ts'; import { randomInt as randomIntToolkit } from '../../math/randomInt.ts';
import { clamp } from './clamp.ts';
/** /**
* Generate a random number within 0 and 1. * Generate a random number within 0 and 1.

View File

@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { cloneDeep } from './cloneDeep'; import { cloneDeep } from './cloneDeep';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { LARGE_ARRAY_SIZE } from '../_internal/LARGE_ARRAY_SIZE';
import { stubTrue } from '../_internal/stubTrue'; import { stubTrue } from '../_internal/stubTrue';
describe('cloneDeep', () => { describe('cloneDeep', () => {

View File

@ -1,6 +1,6 @@
import { falsey } from '../_internal/falsey';
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { fromPairs } from './fromPairs'; import { fromPairs } from './fromPairs';
import { falsey } from '../_internal/falsey';
describe('fromPairs', () => { describe('fromPairs', () => {
it('should convert an array of key-value pairs into an object', () => { it('should convert an array of key-value pairs into an object', () => {

View File

@ -1,7 +1,7 @@
import type { Get } from './get.types.ts';
import { isDeepKey } from '../_internal/isDeepKey.ts'; import { isDeepKey } from '../_internal/isDeepKey.ts';
import { toKey } from '../_internal/toKey.ts'; import { toKey } from '../_internal/toKey.ts';
import { toPath } from '../util/toPath.ts'; import { toPath } from '../util/toPath.ts';
import type { Get } from './get.types.ts';
/** /**
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead. * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

View File

@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { toArgs } from '../_internal/toArgs';
import { has } from './has'; import { has } from './has';
import { stubTrue } from '../_internal/stubTrue';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { args } from '../_internal/args'; import { args } from '../_internal/args';
import { symbol } from '../_internal/symbol';
import { stubFalse } from '../_internal/stubFalse'; import { stubFalse } from '../_internal/stubFalse';
import { stubTrue } from '../_internal/stubTrue';
import { symbol } from '../_internal/symbol';
import { toArgs } from '../_internal/toArgs';
describe('has', () => { describe('has', () => {
it(`should check for own properties`, () => { it(`should check for own properties`, () => {

View File

@ -1,7 +1,7 @@
import { isDeepKey } from '../_internal/isDeepKey.ts'; import { isDeepKey } from '../_internal/isDeepKey.ts';
import { isIndex } from '../_internal/isIndex.ts'; import { isIndex } from '../_internal/isIndex.ts';
import { toPath } from '../util/toPath.ts';
import { isArguments } from '../predicate/isArguments.ts'; import { isArguments } from '../predicate/isArguments.ts';
import { toPath } from '../util/toPath.ts';
/** /**
* Checks if a given path exists within an object. * Checks if a given path exists within an object.

View File

@ -1,6 +1,6 @@
import { property } from './property.ts';
import { mapKeys as mapKeysToolkit } from '../../object/mapKeys.ts'; import { mapKeys as mapKeysToolkit } from '../../object/mapKeys.ts';
import { identity } from '../_internal/identity.ts'; import { identity } from '../_internal/identity.ts';
import { property } from './property.ts';
/** /**
* Creates a new object with the same values as the given object, but with keys generated * Creates a new object with the same values as the given object, but with keys generated

View File

@ -1,6 +1,6 @@
import { property } from './property.ts';
import { mapValues as mapValuesToolkit } from '../../object/mapValues.ts'; import { mapValues as mapValuesToolkit } from '../../object/mapValues.ts';
import { identity } from '../_internal/identity.ts'; import { identity } from '../_internal/identity.ts';
import { property } from './property.ts';
/** /**
* Creates a new object with the same keys as the given object, but with values generated * Creates a new object with the same keys as the given object, but with values generated

View File

@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { merge } from './merge'; import { merge } from './merge';
import { args } from '../_internal/args';
import { isArguments } from '../predicate/isArguments';
import { typedArrays } from '../_internal/typedArrays';
import { range } from '../../math/range'; import { range } from '../../math/range';
import { stubTrue } from '../_internal/stubTrue';
import { isEqual } from '../../predicate/isEqual'; import { isEqual } from '../../predicate/isEqual';
import { args } from '../_internal/args';
import { stubTrue } from '../_internal/stubTrue';
import { typedArrays } from '../_internal/typedArrays';
import { isArguments } from '../predicate/isArguments';
describe('merge', () => { describe('merge', () => {
it('should merge `source` into `object`', () => { it('should merge `source` into `object`', () => {

View File

@ -1,5 +1,5 @@
import { noop } from '../../function/noop.ts';
import { mergeWith } from './mergeWith.ts'; import { mergeWith } from './mergeWith.ts';
import { noop } from '../../function/noop.ts';
/** /**
* Merges the properties of one or more source objects into the target object. * Merges the properties of one or more source objects into the target object.

Some files were not shown because too many files have changed in this diff Show More