Skip to content

Commit

Permalink
Merge pull request #269 from jamashita/feature/update
Browse files Browse the repository at this point in the history
Merge pull request #263 from jamashita/develop
  • Loading branch information
jamashita authored Apr 17, 2024
2 parents f11817d + 4f43c78 commit ffb0e24
Show file tree
Hide file tree
Showing 85 changed files with 1,163 additions and 3,211 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"packages/**/src/**/*.{ts,tsx}": "eslint --fix --quiet",
"src/**/*.{ts,tsx}": "yarn format && yarn lint",
"package.json": "sort-package-json"
}
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tools]
node = "20.10.0"
node = "20.12.2"
13 changes: 4 additions & 9 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
.husky/
.github/
.husky/
.idea/
coverage/
.editorconfig
.eslintignore
.eslintrc
.lintstagedrc.json
.releaserc.json
babel.config.cjs
biome.json
commitlint.config.cjs
jest.config.cjs
lerna.json
tsconfig.compilation.json
tsconfig.json
tsconfig.build.json
tsconfig.build.tsbuildinfo
vitest.config.ts
**/*.spec.ts
*.log
*.md
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# [1.19.0](https://github.com/jamashita/lluvia/compare/v1.18.0...v1.19.0) (2024-01-17)


### Features

* 🎸 packages update ([44bfd3a](https://github.com/jamashita/lluvia/commit/44bfd3a9f5ef38d52f52991380498c27b6affcea))
* 🎸 packagesu pdated ([3b290b8](https://github.com/jamashita/lluvia/commit/3b290b8f1365f636d2758193728bf7f176ecf7ef))

# [1.18.0](https://github.com/jamashita/lluvia/compare/v1.17.0...v1.18.0) (2024-01-09)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ yarn add @jamashita/lluvia

```
> node -v
v20.10.0
v20.12.2
> npm -v
10.2.3
10.5.0
> yarn -v
1.22.21
Expand Down
35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineWidth": 150
},
"javascript": {
"formatter": {
"enabled": true,
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"trailingComma": "none",
"semicolons": "always",
"arrowParentheses": "always"
},
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jamashita/lluvia",
"version": "1.18.0",
"version": "1.19.0",
"private": false,
"repository": {
"type": "git",
Expand Down Expand Up @@ -57,10 +57,11 @@
],
"scripts": {
"build": "yarn clean && tsc -b tsconfig.compilation.json",
"check": "tsc --noEmit",
"check": "biome check --apply src/*",
"clean": "rimraf dist",
"commit": "git cz",
"format": "eslint --fix 'src/**/*.{ts,tsx}'",
"format": "biome format --write src/*",
"lint": "biome lint --apply src/*",
"prepare": "is-ci || husky install",
"release": "semantic-release",
"test": "vitest",
Expand All @@ -72,9 +73,9 @@
"@jamashita/anden": "2.7.0"
},
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@commitlint/cli": "18.4.4",
"@commitlint/config-conventional": "18.4.4",
"@jamashita/eslint-plugin": "1.99.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/commit-analyzer": "11.1.0",
"@semantic-release/git": "10.0.1",
Expand Down
34 changes: 18 additions & 16 deletions src/address/AAddress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Objet } from '@jamashita/anden/object';
import { BinaryPredicate, ForEach, Mapping, Nullable } from '@jamashita/anden/type';
import { NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import { Address } from './Address.js';
import type { BinaryPredicate, ForEach, Mapping, Nullable } from '@jamashita/anden/type';
import { type NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import type { Address } from './Address.js';

export abstract class AAddress<out V> extends Quantity<void, V> implements Address<V> {
protected readonly address: Map<V | string, V>;
Expand Down Expand Up @@ -55,11 +55,11 @@ export abstract class AAddress<out V> extends Quantity<void, V> implements Addre
protected filterInternal<W extends V = V>(predicate: NarrowingBinaryPredicate<V, W, void>): Map<W | string, W> {
const m: Map<W | string, W> = new Map();

this.address.forEach((value: V) => {
if (predicate(value, undefined)) {
m.set(Quantity.genKey(value), value);
for (const [, v] of this.address) {
if (predicate(v, undefined)) {
m.set(Quantity.genKey(v), v);
}
});
}

return m;
}
Expand All @@ -77,9 +77,9 @@ export abstract class AAddress<out V> extends Quantity<void, V> implements Addre
}

public forEach(foreach: ForEach<void, V>): void {
this.address.forEach((v: V) => {
for (const [, v] of this.address) {
foreach(v);
});
}
}

public get(): null {
Expand All @@ -90,7 +90,9 @@ export abstract class AAddress<out V> extends Quantity<void, V> implements Addre
return this.address.has(Quantity.genKey(value));
}

// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
public iterator(): IterableIterator<[void, V]> {
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
const iterable: Array<[void, V]> = [];

for (const [, v] of this.address) {
Expand All @@ -102,24 +104,24 @@ export abstract class AAddress<out V> extends Quantity<void, V> implements Addre

protected mapInternal<W>(mapping: Mapping<V, W>): Map<W | string, W> {
const m: Map<W | string, W> = new Map();
let i: number = 0;
let i = 0;

this.address.forEach((value: V) => {
const w: W = mapping(value, i);
for (const [, v] of this.address) {
const w: W = mapping(v, i);

m.set(Quantity.genKey(w), w);
i++;
});
}

return m;
}

public serialize(): string {
const props: Array<string> = [];

this.forEach((element: V) => {
props.push(Objet.identify(element));
});
for (const [, v] of this.address) {
props.push(Objet.identify(v));
}

return props.join(', ');
}
Expand Down
6 changes: 3 additions & 3 deletions src/address/Address.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import { NarrowingBinaryPredicate } from '../collection/index.js';
import { ReadonlyAddress } from './ReadonlyAddress.js';
import type { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import type { NarrowingBinaryPredicate } from '../collection/index.js';
import type { ReadonlyAddress } from './ReadonlyAddress.js';

export interface Address<out V> extends ReadonlyAddress<V> {
add(value: V): Address<V>;
Expand Down
52 changes: 27 additions & 25 deletions src/address/AddressUtil.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import { Reject, Resolve, UnaryFunction } from '@jamashita/anden/type';
import { Address } from './Address.js';
import { ReadonlyAddress } from './ReadonlyAddress.js';
import type { Reject, Resolve, UnaryFunction } from '@jamashita/anden/type';
import type { Address } from './Address.js';
import type { ReadonlyAddress } from './ReadonlyAddress.js';

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class AddressUtil {
public static await<V, A extends Address<V>>(address: ReadonlyAddress<PromiseLike<V>>, callback: UnaryFunction<Set<V>, A>): Promise<A> {
export namespace AddressUtil {
export const wait = <V, A extends Address<V>>(address: ReadonlyAddress<PromiseLike<V>>, callback: UnaryFunction<Set<V>, A>): Promise<A> => {
if (address.isEmpty()) {
return Promise.resolve(callback(new Set()));
}

let rejected: boolean = false;
let rejected = false;
const set: Set<V> = new Set();

return new Promise((resolve: Resolve<A>, reject: Reject) => {
address.forEach((value: PromiseLike<V>) => {
value.then((v: V) => {
if (rejected) {
return;
}
for (const value of address.values()) {
value.then(
(v: V) => {
if (rejected) {
return;
}

set.add(v);
set.add(v);

if (set.size === address.size()) {
resolve(callback(set));
}
}, (e: unknown) => {
if (rejected) {
return;
}
if (set.size === address.size()) {
resolve(callback(set));
}
},
(e: unknown) => {
if (rejected) {
return;
}

rejected = true;
rejected = true;

reject(e);
});
});
reject(e);
}
);
}
});
}
};
}
12 changes: 6 additions & 6 deletions src/address/ImmutableAddress.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import { Collection, NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import type { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import { type Collection, type NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import { AAddress } from './AAddress.js';
import { AddressUtil } from './AddressUtil.js';
import { ReadonlyAddress } from './ReadonlyAddress.js';
import type { ReadonlyAddress } from './ReadonlyAddress.js';

export class ImmutableAddress<out V> extends AAddress<V> {
private static readonly EMPTY: ImmutableAddress<unknown> = new ImmutableAddress(new Map());

public static await<V>(address: ReadonlyAddress<PromiseLike<V>>): Promise<ImmutableAddress<V>> {
return AddressUtil.await(address, (values: Set<V>) => {
return AddressUtil.wait(address, (values: Set<V>) => {
return ImmutableAddress.ofSet(values);
});
}
Expand All @@ -34,9 +34,9 @@ export class ImmutableAddress<out V> extends AAddress<V> {
public static ofSet<V>(set: ReadonlySet<V>): ImmutableAddress<V> {
const m: Map<V | string, V> = new Map();

set.forEach((v: V) => {
for (const v of set) {
m.set(Quantity.genKey(v), v);
});
}

return ImmutableAddress.ofInternal(m);
}
Expand Down
12 changes: 6 additions & 6 deletions src/address/MutableAddress.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import { Collection, NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import type { BinaryPredicate, Mapping } from '@jamashita/anden/type';
import { type Collection, type NarrowingBinaryPredicate, Quantity } from '../collection/index.js';
import { AAddress } from './AAddress.js';
import { AddressUtil } from './AddressUtil.js';
import { ReadonlyAddress } from './ReadonlyAddress.js';
import type { ReadonlyAddress } from './ReadonlyAddress.js';

export class MutableAddress<out V> extends AAddress<V> {
public static await<V>(address: ReadonlyAddress<PromiseLike<V>>): Promise<MutableAddress<V>> {
return AddressUtil.await(address, (values: Set<V>) => {
return AddressUtil.wait(address, (values: Set<V>) => {
return MutableAddress.ofSet(values);
});
}
Expand All @@ -28,9 +28,9 @@ export class MutableAddress<out V> extends AAddress<V> {
public static ofSet<V>(set: ReadonlySet<V>): MutableAddress<V> {
const m: Map<V | string, V> = new Map();

set.forEach((v: V) => {
for (const v of set) {
m.set(Quantity.genKey(v), v);
});
}

return MutableAddress.ofInternal(m);
}
Expand Down
4 changes: 2 additions & 2 deletions src/address/ReadonlyAddress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BinaryPredicate, Cloneable, Mapping } from '@jamashita/anden/type';
import { Collection, NarrowingBinaryPredicate } from '../collection/index.js';
import type { BinaryPredicate, Cloneable, Mapping } from '@jamashita/anden/type';
import type { Collection, NarrowingBinaryPredicate } from '../collection/index.js';

export interface ReadonlyAddress<out V> extends Collection<void, V>, Cloneable<ReadonlyAddress<V>> {
filter<W extends V>(predicate: NarrowingBinaryPredicate<V, W, void>): ReadonlyAddress<W>;
Expand Down
Loading

0 comments on commit ffb0e24

Please sign in to comment.