1.4.0 • Published 2 months ago

@blockquote-web-components/blockquote-base-meta v1.4.0

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

Lit

BlockquoteBaseMeta is a generic class for sharing information across the DOM tree, inspired by Polymer's iron-meta. It employs the monostate pattern to allow any instance to access the shared information.

The class instances hold the actual data. They must be created before attempting to access them.

BlockquoteBaseMeta uses a Map to store the data. Unlike an Object, a Map allows keys of any type.

Demo

Open in StackBlitz

Usage

import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';

const myDefault = new BlockquoteBaseMeta({
  key: 'basic',
  value: 'foo/bar',
});

console.log(myDefault.byKey('basic')); // foo/bar

Value Getter - String

import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';

const myDefault = new BlockquoteBaseMeta({
  key: 'basic',
  value: 'foo/bar',
});

console.log(myDefault.value); // foo/bar

List Getter - Array

The list getter returns an array of all values stored in the BlockquoteBaseMeta instance.

import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';

const myDefault = new BlockquoteBaseMeta({
  type: 'three',
  key: 'basic',
  value: 'foo/bar',
});

console.log(myDefault.list); // ['foo/bar']

ObjectList Getter - Object

import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';

const myDefault = new BlockquoteBaseMeta({
  type: 'one',
  key: 'basic',
  value: 'foo/bar',
});

console.log(myDefault.objectList); // {basic: 'foo/bar'}

MapList Getter - Map

import { BlockquoteBaseMeta } from '@blockquote-web-components/blockquote-base-meta';

const keyInfo = { id: 'dsfaskj0' };
const myDefault = new BlockquoteBaseMeta({
  type: 'two',
  key: keyInfo,
  value: 'foo/bar',
});

console.log(myDefault.mapList); // Map(1) { { id: 'dsfaskj0' } => 'foo/bar' }

src/BlockquoteBaseMeta.js:

class: BlockquoteBaseMeta

Static Fields
NamePrivacyTypeDefaultDescriptionInherited From
types
uuid
Fields
NamePrivacyTypeDefaultDescriptionInherited From
valueSets value to instance type and key
listReturns a list (Array) of the values for that instance `type`
mapListReturns a list (Map) for that instance `type`
objectListReturns a list (Object) for that instance `type`
typetypeType of Meta
keykeyKey for Meta
Methods
NamePrivacyDescriptionParametersReturnInherited From
byKeyReturns the value of the provided key for that instance `type`key: **

Exports

KindNameDeclarationModulePackage
jsBlockquoteBaseMetaBlockquoteBaseMetasrc/BlockquoteBaseMeta.js

src/index.js:

Exports

KindNameDeclarationModulePackage
jsBlockquoteBaseMetaBlockquoteBaseMeta./BlockquoteBaseMeta.js
1.4.0

2 months ago

1.3.0

2 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.2.0

4 months ago

1.1.5

4 months ago

1.1.4

4 months ago

1.1.3

5 months ago

1.1.1

6 months ago

1.1.2

6 months ago

1.0.19

11 months ago

1.1.0

6 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.22

9 months ago

1.0.21

10 months ago

1.0.20

11 months ago

1.0.23

7 months ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

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