npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lrud-bam

v8.0.0

Published

Left, Right, Up, Down. A spatial navigation library for devices with input via directional controls

Downloads

14

Readme

LRUD Build Status

A spatial navigation library for devices with input via directional controls

:nut_and_bolt: Maintenance Mode :nut_and_bolt:

LRUD is now in maintenance mode; existing bugs will be fixed, but new features will not be added. A new library called LRUD Spatial is now available to the Open Source community.

Upgrading from V2

v3 is a major rewrite, covering many new features. However, it unfortunately breaks some backwards compatibility.

We are currently in the process of writing more detailed docs for an upgrade process. However, the main things to note at the minute at;

  • changes in events, which ones are emitted and what they are emitted with
  • removal of grid in favour of isIndexAligned behaviour

Getting Started

git clone [email protected]:bbc/lrud.git lrud
cd lrud
npm install

Lrud is written in Typescript and makes use of mitt.

Usage

npm install lrud
const { Lrud } = require('Lrud')

// create an instance, register some nodes and assign a default focus
var navigation = new Lrud()
navigation
  .registerNode('root', { orientation: 'vertical' })
  .registerNode('item-a', { parent: 'root', isFocusable: true })
  .registerNode('item-b', { parent: 'root', isFocusable: true })
  .assignFocus('item-a')

// handle a key event
document.addEventListener('keypress', (event) => {
  navigation.handleKeyEvent(event)
});

// Lrud will output an event when it handles a move
navigation.on('move', (moveEvent) => {
  myApp.doSomethingOnNodeFocus(moveEvent.enter)
})

See usage docs for details full API details.

For more "full" examples, covering common use cases, check the recipes

Running the tests

All code is written in Typescript, so we make use of a tsconfig.json and jest.config.js to ensure tests run correctly.

Test files are split up fairly arbitrarily, aiming to have larger sets of tests broken into their own file.

npm test

To run a specific test file, use npx jest from the project root.

npx jest src/lrud.test.js

You can also run all the tests with verbose output. This is useful for listing out test scenarios to ensure that behaviour is covered.

npm run test:verbose

You can also run all the tests with coverage output

npm run test:coverage

Several of the tests have associated diagrams, in order to better explain what is being tested. These can be found in ./docs/test-diagrams.

We also have a specific test file (src/build.test.js) in order to ensure that we haven't broken the Typescript/rollup.js build.

Versioning

npm version <patch:minor:major>
npm publish

Built with

Inspiration

Alternatives

License

LRUD is part of the BBC TAL libraries, and available to everyone under the terms of the Apache 2 open source licence (Apache-2.0). Take a look at the LICENSE file in the code.

Copyright (c) 2018 BBC