forked from prettier/prettier
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace `groupBy` * Replace `partition` * Replace `pick` * Move `partition` * Replace `uniqBy` * Replace `fromPairs` * Remove usage from website * Reuse `partition` * Remove from package.json * Fix * Use `ignore.default` * Add `resolveConfig` to `FileInfoOptions` * Explicit tuple types * Make `cache` optional * Fix cosmiconfig type * Use `@ts-expect-error` for private property access * Add type annotation for validate * Fix type errors for `OptionInfo` * Add `@ts-expect-error` * Fix type of `normalizeOptions` * Fix `OptionInfo` type * Add `@ts-expect-error` for `option-normalizer` * Avoid type error * Fix typo * Add types for lodash fns Co-authored-by: fisker Cheung <lionkay@gmail.com>
- Loading branch information
Showing
19 changed files
with
155 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
|
||
/** | ||
* @template Element | ||
* @param {Array<Element>} array | ||
* @param {(value: Element) => boolean} predicate | ||
* @returns {[Array<Element>, Array<Element>]} | ||
*/ | ||
function partition(array, predicate) { | ||
/** @type {[Array<Element>, Array<Element>]} */ | ||
const result = [[], []]; | ||
|
||
for (const value of array) { | ||
result[predicate(value) ? 0 : 1].push(value); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
module.exports = partition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
|
||
/** | ||
* @template {object} Element | ||
* @param {Array<Element>} array | ||
* @param {string | number | symbol} key | ||
* @returns | ||
*/ | ||
function uniqByKey(array, key) { | ||
const result = []; | ||
const seen = new Set(); | ||
|
||
for (const element of array) { | ||
const value = element[key]; | ||
if (!seen.has(value)) { | ||
seen.add(value); | ||
result.push(element); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
module.exports = uniqByKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.