File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -20,24 +20,24 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020import type { BomRef } from '../models'
2121
2222export class BomRefDiscriminator {
23- readonly #originalValues: ReadonlyMap < BomRef , string | undefined >
23+ readonly #originalValues: ReadonlyArray < readonly [ BomRef , string | undefined ] >
2424
2525 readonly #prefix: string
2626
2727 constructor ( bomRefs : Iterable < BomRef > , prefix : string = 'BomRef' ) {
28- this . #originalValues = new Map (
29- Array . from ( bomRefs , r => [ r , r . value ] )
30- )
28+ this . #originalValues = Array . from ( bomRefs , r => [ r , r . value ] )
3129 this . #prefix = prefix
3230 }
3331
3432 get prefix ( ) : string {
3533 return this . #prefix
3634 }
3735
38- /** Iterate over the bomRefs. */
39- [ Symbol . iterator ] ( ) : IterableIterator < BomRef > {
40- return this . #originalValues. keys ( )
36+ /** Iterate over the {@link BomRef}s. */
37+ * [ Symbol . iterator ] ( ) : IterableIterator < BomRef > {
38+ for ( const [ bomRef ] of this . #originalValues) {
39+ yield bomRef
40+ }
4141 }
4242
4343 discriminate ( ) : void {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020import * as spdxExpressionParse from 'spdx-expression-parse'
2121
2222/* @ts -expect-error: TS6059 -- this works as long as the file/path is available in dist-package. */
23- import { enum as _spdxSpecEnum } from '../res/schema/spdx.SNAPSHOT.schema.json' assert { type : 'json' }
23+ import { enum as _spdxSpecEnum } from '../res/schema/spdx.SNAPSHOT.schema.json' assert { type : 'json' }
2424
2525/**
2626 * One of the known SPDX licence identifiers.
@@ -33,9 +33,9 @@ export type SpdxId = string
3333
3434const spdxIds : ReadonlySet < SpdxId > = new Set ( _spdxSpecEnum )
3535
36- const spdxLowerToActual : ReadonlyMap < string , SpdxId > = new Map (
36+ const spdxLowerToActual : Readonly < Record < string , SpdxId > > = Object . freeze ( Object . fromEntries (
3737 _spdxSpecEnum . map ( spdxId => [ spdxId . toLowerCase ( ) , spdxId ] )
38- )
38+ ) )
3939
4040export function isSupportedSpdxId ( value : SpdxId | any ) : value is SpdxId {
4141 return spdxIds . has ( value )
@@ -44,7 +44,7 @@ export function isSupportedSpdxId (value: SpdxId | any): value is SpdxId {
4444/** Try to convert a `string`-like to a valid/known {@link SpdxId}. */
4545export function fixupSpdxId ( value : string | any ) : SpdxId | undefined {
4646 return typeof value === 'string' && value . length > 0
47- ? spdxLowerToActual . get ( value . toLowerCase ( ) )
47+ ? spdxLowerToActual [ value . toLowerCase ( ) ]
4848 : undefined
4949}
5050
You can’t perform that action at this time.
0 commit comments