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

@maynoothuniversity/moodle-version

v0.1.11

Published

A parser for Moodle version strings

Downloads

6

Readme

@maynoothuniversity/moodle-version

A JavaScript class for parsing Moodle version numbers and release strings.

Moodle version identifiers are a lot more complex than those for other software packages. You'll find three different representations of the version information in common use:

  1. Version Strings — you'll see these short numbers on the offical Moodle download page. They consist of a branch string (e.g. 3.5), an optional release number, e.g. .1, and an optional suffix (dev for developer releases and + for weekly releases). So, version 3.3.6+ is a weekly update to the sixth official release of Moodle 3.3.
  2. Release Strings - you'll see these long version strings in the Moodle admin area. They consist of the version string with the build number appended to the end, e.g. Moodle 3.5+ (Build: 20180614).
  3. Version Numbers - under the hood Moodle represents versions as the date the version was branched in source control in reverse order followed by the release number. So, under the hood Moodle 3.5+ (Build: 20180614) is represented as version 2018051700.

This JavaScript class is here to help!

Install & Import

NodeJS

Install:

npm install --save @maynoothuniversity/moodle-version

Import:

const MoodleVersion = require('@maynoothuniversity/moodle-version');

ES6 Module

// import
import * as MoodleVersion from './dist/index.es.js'

Browser (from CDN)

<!-- Import module, always imported as MoodleVersion -->
<script type="text/javascript" src="">https://cdn.jsdelivr.net/npm/@maynoothuniversity/moodle-version/dist/index.js</script>

Usage

const MoodleVersion = require('@maynoothuniversity/moodle-version');
let mv1;

// create a Moodle Version object from a version string
mv1 = new MoodleVersion('3.5.4+');

// create a Moodle Version object a version number (Moodle's internal represenation)
mv1 = new MoodleVersion('2018051704.05');

// create a Moodle Version object from a release string (as seen in admin GUI)
mv1 = new MoodleVersion('Moodle 3.5.4+ (Build: 20190124)');

// output the version in any format
console.log(mv1.version); // 3.5.4+
console.log(mv1.versionNumber); // 2018051704
console.log(mv1.release); // 3.5.4+ (Build: 20190124)

// interrogate the version
console.log(mv1.branch); // 3.5
console.log(mv1.branchNumber); // 35
console.log(mv1.branchingDate); // 2018-05-17T00:00:00.000Z
console.log(mv1.branchingDateNumber); // 20180517
console.log(mv1.releaseNumber); // 4
console.log(mv1.releaseType); // weekly
console.log(mv1.releaseSuffix); // +
console.log(mv1.buildNumber); // 20190124
console.log(mv1.isStable()); // true
console.log(mv1.isLTS()); // true

// compare versions
const mv2 = new MoodleVersion('3.5.4dev');
console.log(mv1.equals(mv2)); // false
console.log(mv1.sameBranch(mv2)); // true
console.log(mv1.lessThan(mv2)); // false
console.log(mv1.greaterThan(mv2)); // true

API Documentation

Full API documentation is available at bbusschots-mu.github.io/moodle-version.