2.4.2 • Published 11 months ago

@typinghare/extrum v2.4.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Extrum

Get Started

Create a MyConfig interface and a MyConfigMetadata interface, then create a data collection.

import { DataCollection, Datum } from '@typinghare/extrum'

interface MyConfig {
    username: string,
    fontSize: number
}

interface MyConfigMetadata {
    label: string
    optionList?: any[]
}

const dataCollection = new DataCollection<MyConfig, MyConfigMetadata>({
    username: Datum.of('TypingHare').setMetadata({
        label: 'The username of the user.',
    }),
    fontSize: Datum.of(16).setMetadata({
        label: 'The font size.',
        optionList: [12, 16, 20],
    }),
})

Get values from the data collection and set values.

const username = dataCollection.getValue('username')     // TypingHare 
const fontSize = dataCollection.getValue('fontSize')     // 16

dataCollection.setValue('username', 'James Chan')
dataCollection.setValue('fontSize', 20)

Get and set metadata.

dataCollection.getDatum('username').meta('label')
dataCollection.getDatum('fontSize').meta('optionList')

dataCollection.getDatum('username').meta('label')
dataCollection.getDatum('fontSize').meta('optionList', [8, 12, 16, 20, 24])
2.4.1

11 months ago

2.4.0

11 months ago

2.4.2

11 months ago

2.3.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago