Skip to content

Commit a20ae77

Browse files
committed
deps: update prettier
1 parent ee278d9 commit a20ae77

5 files changed

Lines changed: 66 additions & 63 deletions

File tree

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"@types/jest": "^27.0.2",
5555
"jest": "^27.4.5",
5656
"microbundle": "^0.15.0",
57-
"prettier": "^2.8.4",
57+
"prettier": "^2.8.8",
5858
"ts-jest": "^27.1.2",
59-
"typescript": "^5.0.0-beta"
59+
"typescript": "^5.0.4"
6060
}
6161
}

src/patterns.ts

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,14 @@ export function array<
128128

129129
return { matched, selections };
130130
},
131-
getSelectionKeys: () => args.length === 0 ? [] : getSelectionKeys(args[0]),
131+
getSelectionKeys: () =>
132+
args.length === 0 ? [] : getSelectionKeys(args[0]),
132133
};
133134
},
134135
*[Symbol.iterator]() {
135-
yield Object.assign(
136-
args.length === 0
137-
? array()
138-
: array(args[0]),
139-
{ [symbols.isVariadic]: true }
140-
);
136+
yield Object.assign(args.length === 0 ? array() : array(args[0]), {
137+
[symbols.isVariadic]: true,
138+
});
141139
},
142140
};
143141
}
@@ -152,9 +150,7 @@ export function array<
152150
* match(value)
153151
* .with({ users: P.set(P.string) }, () => 'will match Set<string>')
154152
*/
155-
export function set<
156-
input,
157-
>(): SetP<input, unknown>;
153+
export function set<input>(): SetP<input, unknown>;
158154
export function set<
159155
input,
160156
const p extends Pattern<WithDefault<UnwrapSet<input>, unknown>>
@@ -189,19 +185,20 @@ export function set<
189185

190186
return { matched, selections };
191187
},
192-
getSelectionKeys: () => args.length === 0 ? [] : getSelectionKeys(args[0]),
188+
getSelectionKeys: () =>
189+
args.length === 0 ? [] : getSelectionKeys(args[0]),
193190
};
194191
},
195192
};
196193
}
197194

198195
const setEvery = <T>(set: Set<T>, predicate: (value: T) => boolean) => {
199196
for (const value of set) {
200-
if (predicate(value)) continue
201-
return false
197+
if (predicate(value)) continue;
198+
return false;
202199
}
203-
return true
204-
}
200+
return true;
201+
};
205202

206203
/**
207204
* `P.set(subpattern)` takes a sub pattern and returns a pattern that matches
@@ -218,12 +215,14 @@ export function map<
218215
input,
219216
const pkey extends Pattern<WithDefault<UnwrapMapKey<input>, unknown>>,
220217
const pvalue extends Pattern<WithDefault<UnwrapMapValue<input>, unknown>>
221-
>(patternKey: pkey, patternValue: pvalue): MapP<input, pkey, pvalue>
218+
>(patternKey: pkey, patternValue: pvalue): MapP<input, pkey, pvalue>;
222219
export function map<
223220
input,
224221
const pkey extends Pattern<WithDefault<UnwrapMapKey<input>, unknown>>,
225222
const pvalue extends Pattern<WithDefault<UnwrapMapValue<input>, unknown>>
226-
>(...args: [patternKey?: pkey, patternValue?: pvalue]): MapP<input, pkey, pvalue> {
223+
>(
224+
...args: [patternKey?: pkey, patternValue?: pvalue]
225+
): MapP<input, pkey, pvalue> {
227226
return {
228227
[symbols.matcher]() {
229228
return {
@@ -242,37 +241,39 @@ export function map<
242241

243242
if (args.length === 0) return { matched: true };
244243
if (args.length === 1) {
245-
throw new Error(`\`P.map\` wasn\'t given enough arguments. Expected (key, value), received ${args[0]?.toString()}`)
244+
throw new Error(
245+
`\`P.map\` wasn\'t given enough arguments. Expected (key, value), received ${args[0]?.toString()}`
246+
);
246247
}
247-
const [patternKey, patternValue] = args
248+
const [patternKey, patternValue] = args;
248249

249-
const matched = mapEvery(value, (v, k) =>{
250-
const keyMatch = matchPattern(patternKey, k, selector)
251-
const valueMatch = matchPattern(patternValue, v, selector)
252-
return keyMatch && valueMatch
250+
const matched = mapEvery(value, (v, k) => {
251+
const keyMatch = matchPattern(patternKey, k, selector);
252+
const valueMatch = matchPattern(patternValue, v, selector);
253+
return keyMatch && valueMatch;
253254
});
254255

255256
return { matched, selections };
256257
},
257258
getSelectionKeys: () =>
258259
args.length === 0
259260
? []
260-
: [
261-
...getSelectionKeys(args[0]),
262-
...getSelectionKeys(args[1])
263-
]
261+
: [...getSelectionKeys(args[0]), ...getSelectionKeys(args[1])],
264262
};
265263
},
266264
};
267265
}
268266

269-
const mapEvery = <K, T>(map: Map<K, T>, predicate: (value: T, key: K) => boolean) => {
267+
const mapEvery = <K, T>(
268+
map: Map<K, T>,
269+
predicate: (value: T, key: K) => boolean
270+
) => {
270271
for (const [key, value] of map.entries()) {
271272
if (predicate(value, key)) continue;
272273
return false;
273274
}
274275
return true;
275-
}
276+
};
276277

277278
/**
278279
* `P.intersection(...patterns)` returns a pattern which matches
@@ -340,9 +341,10 @@ export function union<
340341
const selector = (key: string, value: any) => {
341342
selections[key] = value;
342343
};
343-
flatMap(patterns as readonly UnknownPattern[], getSelectionKeys).forEach((key) =>
344-
selector(key, undefined)
345-
);
344+
flatMap(
345+
patterns as readonly UnknownPattern[],
346+
getSelectionKeys
347+
).forEach((key) => selector(key, undefined));
346348
const matched = (patterns as readonly UnknownPattern[]).some((p) =>
347349
matchPattern(p, value, selector)
348350
);
@@ -367,10 +369,9 @@ export function union<
367369
* )
368370
*/
369371

370-
export function not<
371-
input,
372-
const p extends Pattern<input> | UnknownPattern
373-
>(pattern: p): NotP<input, p> {
372+
export function not<input, const p extends Pattern<input> | UnknownPattern>(
373+
pattern: p
374+
): NotP<input, p> {
374375
return {
375376
[symbols.matcher]: () => ({
376377
match: <I>(value: I | input) => ({
@@ -633,7 +634,9 @@ export function instanceOf<T extends AnyConstructor>(
633634
* )
634635
*/
635636
export function typed<input>(): {
636-
array<const p extends Pattern<UnwrapArray<input>>>(pattern: p): ArrayP<input, p>;
637+
array<const p extends Pattern<UnwrapArray<input>>>(
638+
pattern: p
639+
): ArrayP<input, p>;
637640

638641
optional<const p extends Pattern<input>>(pattern: p): OptionalP<input, p>;
639642

src/types/Match.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export type Match<
205205

206206
/**
207207
* `.returnType<T>()` Lets you specific a return type for all your code branches.
208-
*
208+
*
209209
* [Read documentation for `.returnType()` on GitHub](https://github.com/gvergnaud/ts-pattern#returnType)
210210
* */
211211
returnType: [inferredOutput] extends [never]

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,10 +4098,10 @@ prelude-ls@~1.1.2:
40984098
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz"
40994099
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
41004100

4101-
prettier@2.8.4:
4102-
version "2.8.4"
4103-
resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz"
4104-
integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==
4101+
prettier@2.8.8:
4102+
version "2.8.8"
4103+
resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz"
4104+
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
41054105

41064106
pretty-bytes@^3.0.0:
41074107
version "3.0.1"
@@ -4753,10 +4753,10 @@ typescript@^4.1.3, typescript@>=2.4.0:
47534753
resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz"
47544754
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==
47554755

4756-
typescript@^5.0.0-beta, "typescript@>=3.8 <5.0":
4757-
version "5.0.0-beta"
4758-
resolved "https://registry.npmjs.org/typescript/-/typescript-5.0.0-beta.tgz"
4759-
integrity sha512-+SSabbSXG5mtF+QGdV9uXXt9Saq1cSyI6hSG7znhaLoquleJpnmfkwSxFngK9c2fWWi1W/263TuzXQOsIcdjjA==
4756+
"typescript@>=3.8 <5.0", typescript@5.0.4:
4757+
version "5.0.4"
4758+
resolved "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz"
4759+
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
47604760

47614761
unbox-primitive@^1.0.1:
47624762
version "1.0.1"

0 commit comments

Comments
 (0)