2.3.0 • Published 3 months ago

@typinghare/extrum v2.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 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').getMeta('label')
dataCollection.getDatum('fontSize').getMeta('optionList')

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

3 months ago

2.2.0

4 months ago

2.1.0

4 months ago

2.0.1

5 months ago

2.0.0

6 months ago

1.1.0

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago