From c2f466b03d58dacf2cf1167b833aac5d50289d8d Mon Sep 17 00:00:00 2001 From: Vitaliy Artemov Date: Fri, 29 Nov 2024 01:24:15 +0300 Subject: [PATCH] builtin (fun): fix declarations --- package-lock.json | 4 +- package.json | 2 +- src/builtin/fun/Basic.d.ts | 12 ++--- src/builtin/fun/Compositions.d.ts | 6 +-- src/builtin/fun/Filtering.d.ts | 19 +++---- src/builtin/fun/Indexing.d.ts | 11 ++-- src/builtin/fun/Reducing.d.ts | 26 +++++----- src/builtin/fun/Slicing.d.ts | 75 ++++++++++++---------------- src/builtin/fun/Transformations.d.ts | 12 ++--- 9 files changed, 79 insertions(+), 88 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04e94a3..dc4f0c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tarantoolscript", - "version": "0.30.8", + "version": "0.30.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tarantoolscript", - "version": "0.30.8", + "version": "0.30.9", "license": "MIT", "dependencies": { "@typescript-to-lua/language-extensions": "^1.19.0", diff --git a/package.json b/package.json index d23a5f6..754db18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tarantoolscript", - "version": "0.30.8", + "version": "0.30.9", "author": "Vitaliy Artemov olivera507224@yandex.ru", "description": "TypeScript definitions for Tarantool Lua API.", "repository": { diff --git a/src/builtin/fun/Basic.d.ts b/src/builtin/fun/Basic.d.ts index 150109a..137708d 100644 --- a/src/builtin/fun/Basic.d.ts +++ b/src/builtin/fun/Basic.d.ts @@ -26,9 +26,9 @@ export declare function iter( * @returns `gen`, `param`, `state` – iterator triplet. * @see {@link https://luafun.github.io/basic.html#fun.iter} */ -export declare function iter( - value: AnyTable -): FunIterator; +export declare function iter( + value: Record +): FunIterator; /** * Make `gen`, `param`, `state` iterator from the iterable object. The function is a generalized version of pairs() and ipairs(). @@ -90,9 +90,9 @@ export declare function each( * @param value A map to iterate for. * @see {@link https://luafun.github.io/basic.html#fun.each} */ -export declare function each( - fun: (this: void, ...params: [string, unknown]) => unknown, - value: AnyTable +export declare function each( + fun: (this: void, key: string, value: TValue) => unknown, + value: Record ): void; /** diff --git a/src/builtin/fun/Compositions.d.ts b/src/builtin/fun/Compositions.d.ts index 2affc6d..8065c1a 100644 --- a/src/builtin/fun/Compositions.d.ts +++ b/src/builtin/fun/Compositions.d.ts @@ -68,9 +68,9 @@ export declare function cycle( * @returns A new iterator. * @see {@link https://luafun.github.io/compositions.html#fun.cycle} */ -export declare function cycle( - value: AnyTable -): FunIterator; +export declare function cycle( + value: Record +): FunIterator; /** * Make a new iterator that returns elements from `{gen, param, state}` iterator until the end diff --git a/src/builtin/fun/Filtering.d.ts b/src/builtin/fun/Filtering.d.ts index efe4f6a..f5e8dcf 100644 --- a/src/builtin/fun/Filtering.d.ts +++ b/src/builtin/fun/Filtering.d.ts @@ -33,10 +33,10 @@ export declare function filter( * @returns An iterator. * @see {@link https://luafun.github.io/filtering.html#fun.filter} */ -export declare function filter( - predicate: (this: void, key: string, value: any) => boolean, - value: AnyTable -): FunIterator; +export declare function filter( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record +): FunIterator; /** * Return a new iterator of those elements that satisfy the `predicate`. @@ -114,14 +114,11 @@ export declare function partition( * @returns An iterator pair. * @see {@link https://luafun.github.io/filtering.html#fun.partition} */ -export declare function partition( - predicate: (this: void, key: string, value: any) => boolean, - value: AnyTable +export declare function partition( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record ): LuaMultiReturn< - [ - FunIterator, - FunIterator - ] + [FunIterator, FunIterator] >; /** diff --git a/src/builtin/fun/Indexing.d.ts b/src/builtin/fun/Indexing.d.ts index ec3129e..3947d12 100644 --- a/src/builtin/fun/Indexing.d.ts +++ b/src/builtin/fun/Indexing.d.ts @@ -34,7 +34,10 @@ export declare function index( * @returns The position of element or nil. * @see {@link https://luafun.github.io/indexing.html#fun.index} */ -export declare function index(x: string, value: AnyTable): number?; +export declare function index( + x: string, + value: Record +): number?; /** * The function returns the position of the first symbol in the string which is equal (using `==`) to the query element, @@ -87,9 +90,9 @@ export declare function indexes( * @returns An iterator. * @see {@link https://luafun.github.io/indexing.html#fun.indexes} */ -export declare function indexes( - x: unknown, - value: AnyTable +export declare function indexes( + x: TValue, + value: Record ): FunIterator; /** diff --git a/src/builtin/fun/Reducing.d.ts b/src/builtin/fun/Reducing.d.ts index 57c3a82..12dce79 100644 --- a/src/builtin/fun/Reducing.d.ts +++ b/src/builtin/fun/Reducing.d.ts @@ -25,10 +25,10 @@ export declare function foldl( * @returns Reducing result. * @see {@link https://luafun.github.io/reducing.html#fun.foldl} */ -export declare function foldl( - accfun: (this: void, acc: R, key: string, value: unknown) => R, +export declare function foldl( + accfun: (this: void, acc: R, key: string, value: TValue) => R, initval: R, - value: AnyTable + value: Record ): R; /** @@ -208,9 +208,9 @@ export declare function all( * Returns `true` if all key-value pairs of map satisfy the `predicate`. * @see {@link https://luafun.github.io/reducing.html#fun.all} */ -export declare function all( - predicate: (this: void, key: string, value: unknown) => boolean, - value: AnyTable +export declare function all( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record ): boolean; /** @@ -259,9 +259,9 @@ export declare function any( * The iteration stops on the first such value. * @see {@link https://luafun.github.io/reducing.html#fun.any} */ -export declare function any( - predicate: (this: void, key: string, value: unknown) => boolean, - value: AnyTable +export declare function any( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record ): boolean; /** @@ -359,7 +359,7 @@ export declare function min( * The iterator must be non-null, otherwise error is raised. * @see {@link https://luafun.github.io/reducing.html#fun.min} */ -export declare function min(value: AnyTable): string; +export declare function min(value: Record): string; /** * Return a minimum value from the iterator using `<`. @@ -435,7 +435,7 @@ export declare function min_by< */ export declare function min_by( cmp: (this: void, a: string, b: string) => string, - value: AnyTable + value: Record ): string; /** @@ -483,7 +483,7 @@ export declare function max( * The iterator must be non-null, otherwise error is raised. * @see {@link https://luafun.github.io/reducing.html#fun.max} */ -export declare function max(value: AnyTable): string; +export declare function max(value: Record): string; /** * Return a maximum value from the iterator using `>`. @@ -559,7 +559,7 @@ export declare function max_by< */ export declare function max_by( cmp: (this: void, a: string, b: string) => string, - value: AnyTable + value: Record ): string; /** diff --git a/src/builtin/fun/Slicing.d.ts b/src/builtin/fun/Slicing.d.ts index f6a78fe..ee38159 100644 --- a/src/builtin/fun/Slicing.d.ts +++ b/src/builtin/fun/Slicing.d.ts @@ -32,10 +32,10 @@ export declare function nth( * @returns The n-th key-value pair of map. * @see {@link https://luafun.github.io/slicing.html#fun.nth} */ -export declare function nth( +export declare function nth( n: number, - value: AnyTable -): LuaMultiReturn<[string, unknown] | [undefined]>; + value: Record +): LuaMultiReturn<[string, TValue] | [undefined]>; /** * Return the n-th symbol of string. @@ -87,9 +87,9 @@ export declare function head( * @returns A first key-value pair of map. * @see {@link https://luafun.github.io/slicing.html#fun.head} */ -export declare function head( - value: AnyTable -): LuaMultiReturn<[string, unknown]>; +export declare function head( + value: Record +): LuaMultiReturn<[string, TValue]>; /** * Extract the first symbol of string. If value is empty then an error is raised. @@ -142,9 +142,9 @@ export declare function tail( * @returns `gen`, `param`, `state` iterator without a first element. * @see {@link https://luafun.github.io/slicing.html#fun.tail} */ -export declare function tail( - value: AnyTable -): FunIterator; +export declare function tail( + value: Record +): FunIterator; /** * Return a copy of string without its first symbol. @@ -204,10 +204,10 @@ export declare function take_n( * @returns An iterator on the subsequence of first `n` key-value paris. * @see {@link https://luafun.github.io/slicing.html#fun.take_n} */ -export declare function take_n( +export declare function take_n( n: number, - value: AnyTable -): FunIterator; + value: Record +): FunIterator; /** * Return an iterator on the subsequence of first `n` symbols of string. @@ -272,10 +272,10 @@ export declare function take_while( * @returns An iterator on the subsequence of first key-value pairs satisfying the condition. * @see {@link https://luafun.github.io/slicing.html#fun.take_while} */ -export declare function take_while( - predicate: (this: void, key: string, value: any) => boolean, - value: AnyTable -): FunIterator; +export declare function take_while( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record +): FunIterator; /** * Returns an iterator on the subsequence of first symbols satisfying the condition. @@ -341,10 +341,10 @@ export declare function drop_n( * @returns An iterator after skipping first `n` key-value paris. * @see {@link https://luafun.github.io/slicing.html#fun.drop_n} */ -export declare function drop_n( +export declare function drop_n( n: number, - value: AnyTable -): FunIterator; + value: Record +): FunIterator; /** * Return an iterator after skipping first `n` symbols of string. @@ -409,10 +409,10 @@ export declare function drop_while( * @returns An iterator after skipping the longest prefix of first key-value pairs satisfying the condition. * @see {@link https://luafun.github.io/slicing.html#fun.drop_while} */ -export declare function drop_while( - predicate: (this: void, key: string, value: any) => boolean, - value: AnyTable -): FunIterator; +export declare function drop_while( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record +): FunIterator; /** * Returns an iterator after skipping the longest prefix of first symbols satisfying the condition. @@ -481,14 +481,11 @@ export declare function span( * @returns An iterator pair (first `n` key-value pairs and remainder). * @see {@link https://luafun.github.io/slicing.html#fun.span} */ -export declare function span( +export declare function span( n: number, - value: AnyTable + value: Record ): LuaMultiReturn< - [ - FunIterator, - FunIterator - ] + [FunIterator, FunIterator] >; /** @@ -561,14 +558,11 @@ export declare function span( * @returns An iterator pair. * @see {@link https://luafun.github.io/slicing.html#fun.span} */ -export declare function span( - predicate: (this: void, key: string, value: any) => boolean, - value: AnyTable +export declare function span( + predicate: (this: void, key: string, value: TValue) => boolean, + value: Record ): LuaMultiReturn< - [ - FunIterator, - FunIterator - ] + [FunIterator, FunIterator] >; /** @@ -641,14 +635,11 @@ export declare function split_at( * @returns An iterator pair (first `n` key-value pairs and remainder). * @see {@link https://luafun.github.io/slicing.html#fun.split_at} */ -export declare function split_at( +export declare function split_at( n: number, - value: AnyTable + value: Record ): LuaMultiReturn< - [ - FunIterator, - FunIterator - ] + [FunIterator, FunIterator] >; /** diff --git a/src/builtin/fun/Transformations.d.ts b/src/builtin/fun/Transformations.d.ts index 36b9d62..7e8f974 100644 --- a/src/builtin/fun/Transformations.d.ts +++ b/src/builtin/fun/Transformations.d.ts @@ -50,9 +50,9 @@ export declare function map( * @returns A new iterator. * @see {@link https://luafun.github.io/transformations.html#fun.map} */ -export declare function map( - fun: (this: void, key: string, value: unknown) => TResult, - value: AnyTable +export declare function map( + fun: (this: void, key: string, value: TValue) => TResult, + value: Record ): FunIterator; /** @@ -109,9 +109,9 @@ export declare function enumerate( * @returns A new iterator. * @see {@link https://luafun.github.io/transformations.html#fun.enumerate} */ -export declare function enumerate( - value: AnyTable -): FunIterator; +export declare function enumerate( + value: Record +): FunIterator; /** * Return a new iterator by enumerating all elements of `gen, param, state` iterator starting from `1`.