1.2.1 • Published 8 months ago

key-mapping v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

key-mapping

store key mappings

Usage

import { createKeyMappingNode } from 'key-mapping';

const root = createKeyMappingNode({ key: '' });

root.add({ key: 'A' }).add({
  key: 'B',
  action() {
    console.log('Hello!');
  }
});

root.get('A')?.get('B')?.mapping?.action?.(); // => Hello!

or

import {
  createKeyMappingNode,
  addKeyMappings,
  getKeyMappingNode
} from 'key-mapping';

const root = createKeyMappingNode({ key: '' });

const keyMappings = [
  { key: 'A' },
  {
    key: 'B',
    action() {
      console.log('Hello!');
    }
  }
];

addKeyMappings(keyMappings, root);
getKeyMappingNode(['A', 'B'], root)?.mapping?.action?.(); // => Hello!

License

The MIT license

1.2.1

8 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago