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

vrm

v0.1.2

Published

Coerces, validates and prettifies vehicle registration marks (VRMs)

Downloads

364

Readme

vrm

Coerces, validates and prettifies vehicle registration marks (VRMs). Presently, only UK DVLA registration plate formats are supported. Please open an issue if you'd like to see support added for other driving authorities' formats - I'd be keen to work with you to enable this.

import VRM from 'vrm';

console.log(VRM.coerce('Lbo7 se0')); // => [{ format: 'gb_2001', vrm: 'LB07SEO', prettyVrm: 'LB07 SEO' }]
console.log(VRM.coerce('Lbo7 se0', ['gb_2001'])); // => [{ format: 'gb_2001', vrm: 'LB07SEO', prettyVrm: 'LB07 SEO' }]
console.log(VRM.coerce('Lbo7 se0', ['gb_1903'])); // => []
console.log(VRM.info('LB07SEO')); // => { format: 'gb_2001', vrm: 'LB07SEO', prettyVrm: 'LB07 SEO' }
console.log(VRM.info('LB07SEO', 'gb_2001')); // => { format: 'gb_2001', vrm: 'LB07SEO', prettyVrm: 'LB07 SEO' }
console.log(VRM.info('LB07SEO', 'gb_1903')); // => null

Installation

$ npm install vrm

API

VRM.coerce(input[, allowedFormats])

Coerces the input into a set of possible VRMs which the input could represent. See more information below about why this is needed.

The returned array contains the VRM details for each given format, sorted in order of likelihood, where the most likely format is the first value.

If the allowed formats are specified, coercion will be limited to these formats. Any other formats will not be checked.

Returns an empty array if the input is invalid or cannot be coerced into any of the formats checked.

Throws if any of the allowed formats are not known.

VRM.info(normalizedVRM[, format])

Verifies that the given VRM matches one of the known formats and returns the relevant VRM details. Only normalized VRMs are accepted.

If the format is specified, only that format is checked.

Returns null if the VRM does not match any of the formats checked.

Throws if the provided format is not known.

Notes

Formats

The known formats are referenced as the following strings:

  • gb_1903 - AB 1234 - the first number-plates issued under the "Motor Car Act"
  • gb_1932 - ABC 123 - after the above format began to run out
  • gb_1963 - ABC 123A - ditto
  • gb_1983 - A123 ABC - ditto
  • gb_2001 - AB12 ABC - the current GB format
  • ni_1903 - AZ 1234 - roughly equivalent to gb_1903
  • ni_1966 - AAZ 1234 - similar to gb_1932, the current NI format
  • diplomatic - 123 D 123 - used for diplomats (D) and accredited personnel (X)
  • military - AB 12 AB - used for military vehicles

VRM Details

The VRM details objects returned include the following information:

{
	format: 'gb_2001', // required, string - format referenced as-above
	vrm: 'LB07SEO', // required, string - vrm in upper case, no spaces, no special chars, etc.
	prettyVrm: 'LB07 SEO', // optional, string - vrm spaced as legally defined
}

More information is likely to be added to this object over time. These changes would not be considered as 'breaking'.

Coercion

UK registration plates use a particular official typeface which was designed by Charles Wright. Bizarrely, it uses exactly the same physical shape for I and 1, and for O and 0. This means that the exact VRM can be ambiguous and people often mistype the VRM into forms. Additionally, it presents some difficulties for automatic number plate recognition (ANPR) systems.

The coerce method handles this. It returns an array because (occasionally) multiple formats can be possible.

The returned array is ordered with the original input first if it is valid, followed by the other valid options with the newer formats coming first. This behavior could change though, so don't rely on it.

Possible Additions

If there is demand for it, two other bits of functionality could be provided:

  • normalization: normalizing an arbitrary string input without coercing it (this happens internally anyway)
  • extending info: exposing the data contained within a given VRM - e.g. the 2001 UK format contains information about the area and year of registration

Data Sources

Support

Please open an issue on this repository.

Authors

License

MIT licensed - see LICENSE file