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

github-languages-client

v1.0.124

Published

NodeJS Client to get languages used on GitHub

Downloads

92

Readme

GitHub Languages Client

GitHub Languages Client codecov npm npm bundle size npm-total-downloads GitHub

A NodeJS client to get languages GitHub knows about for Advanced Search, for example.

advanced-search

Implementation

GitHub maintains a linguist repository that contains a languages.yml file that seems to represent the set of languages that GitHub knows about.

I convert this languages.yml file to a JSON file. 1

I then read from this file when instantiating the GitHubLanguagesClient.

For fuzzy-searching, I use the fuse library.

API

Constructor

The default constructor parameters, used for fuzzy-searching, are

{
  maxPatternLength = 32,
  caseSensitive = false,
  includeScore = false,
  shouldSort = true,
  threshold = 0.6,
  location = 0,
  distance = 100,
  minMatchCharLength = 1,
}

The fuse.io site gives a good explanation of why and how these values are used.

getAllLanguages

This static method returns the complete array of all languages available, and the metadata associated with each language. It essentially returns the src/languages.json file as a JavaScript object.

import GitHubLanguagesClient from 'github-languages-client';

const allLanguages = GitHubLanguagesClient.getAllLanguages();

search

This class method returns fuzzy-search text matching on the language's name, aliases, and extensions.

import GitHubLanguagesClient from 'github-languages-client';

const client = new GitHubLanguagesClient();

const matchingLanguages = client.search('JavaScript');

// {
//   type: 'programming',
//   tmScope: 'source.js',
//   aceMode: 'javascript',
//   codemirrorMode: 'javascript',
//   codemirrorMimeType: 'text/javascript',
//   color: '#f1e05a',
//   aliases: [ 'js', 'node', 'javascript' ],
//   extensions:
//     [ '.js',
//       '._js',
//       '.bones',
//       '.es',
//       '.es6',
//       '.frag',
//       '.gs',
//       '.jake',
//       '.jsb',
//       '.jscad',
//       '.jsfl',
//       '.jsm',
//       '.jss',
//       '.mjs',
//       '.njs',
//       '.pac',
//       '.sjs',
//       '.ssjs',
//       '.xsjs',
//       '.xsjslib' ],
//   filenames: [ 'Jakefile' ],
//   interpreters: [ 'node' ],
//   languageId: 183,
//   name: 'JavaScript',
//   wrap: 'false',
//   searchable: 'true' },
// { type: 'programming',
//   color: '#00a6a6',
//   extensions: [ '.ms', '.mcr' ],
//   tmScope: 'source.maxscript',
//   aceMode: 'text',
//   languageId: 217,
//   name: 'MAXScript',
//   aliases: [ 'maxscript' ],
//   wrap: 'false',
//   searchable: 'true' },
//   etc., etc.

Footnotes