MCPcopy Index your code
hub / github.com/fontsource/fontsource / findClosest

Function findClosest

packages/cli/src/utils.ts:47–55  ·  view source on GitHub ↗
(arr: number[], num: number)

Source from the content-addressed store, hash-verified

45
46// Insert a weight array to find the closest number given num - used for index.css gen
47const findClosest = (arr: number[], num: number): number => {
48 // Array of absolute values showing diff from target number
49 const indexArr = arr.map((weight) => Math.abs(Number(weight) - num));
50 // Find smallest diff
51 const min = Math.min(...indexArr);
52 const closest = arr[indexArr.indexOf(min)];
53
54 return closest;
55};
56
57const licenseMap = {
58 'apache license, version 2.0': 'Apache-2.0',

Callers 5

sassMetadataFunction · 0.90
packagerCustomFunction · 0.90
generateV2CSSFunction · 0.90
generateVariableCSSFunction · 0.90
generateIconStaticCSSFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected