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

@sugarcube/source-types

v0.1.7

Published

> Utility functions to deal with different types of sources for Sugarcube.

Downloads

4

Readme

Source Types for Sugarcube

Utility functions to deal with different types of sources for Sugarcube.

CI Status Code Coverage GitHub


@sugarcube/source-types provides utility functions for the Sugarcube Tools distribution. The utility functions can parse, normalize and verify terms in respect to the type of the source. This packages is used across various parts of the Sugarcube distribution, such as Ncube, the Sugarcube Discovery Extension and Sugarcube itself.

Contents

Installation

npm install --save @sugarcube/source-types

Usage

import {sourceType} from "@sugarcube/source-types";

sourceType("I'm gibberish"); // undefined
sourceType("https://youtube.com/watch?v=wer23edsa"); // youtube_video

API

SourceType

A string literal type containig valid source types.

  • telegram_channel
  • twitter_tweet
  • twitter_channel
  • youtube_video
  • youtube_channel
  • http_url

sourceType

Detect the type of a source.

sourceType :: (term?: string) -> SourceType | undefined

isTelegramChannel

Check if a term is a valid Telegram channel.

isTelegramChannel :: (term?: string) -> boolean

isTwitterTweet

Check if a term is a valid Twitter tweet.

isTwitterTweet :: (term?: string) -> boolean

isTwitterFeed

Check if a term is a valid Twitter channel.

isTwitterFeed :: (term?: string) -> boolean

isYoutubeVideo

Check if a term is a valid Youtube video.

isYoutubeVideo :: (term?: string) -> boolean

isYoutubeChannel

Check if a term is a valid Youtube channel.

isYoutubeChannel :: (term?: string) -> boolean

isHttpUrl

Check if a term is a valid HTTP url.

isHttpUrl :: (term?: string) -> boolean

parseTelegramChannel

Extract a Telegram channel from a term.

parseTelegramChannel :: (term?: string) -> string | undefined
parseTelegramChannel("https://t.me/s/soscubamedia"); # soscubamedia
parseTelegramChannel("https://t.me/soscubamedia"); # soscubamedia

Channel names in the form of @soscubamedia are not valid since they are ambiguous with Twitter user handlers.

parseTweetId

Extract a tweet id from a term.

parseTweetId :: (term?: string) -> string | undefined

parseTwitterUser

Extract a Twitter user name from a term.

parseTwitterUser :: (term?: string) -> string | undefined

parseYoutubeVideo

Extract a Youtube video id from a term.

parseYoutubeVideo :: (term?: string) -> string | undefined

parseYoutubeChannel

Extract a Youtube channel id from a term.

parseYoutubeChannel :: (term?: string) -> string | undefined

parseHttpUrl

Parse a term and return a HTTP url.

parseHttpUrl :: (term?: string) -> string | undefined

normalizeTelegramChannelUrl

Parse a Telegram channel from a term and return a normalized Telegram channel URL.

normalizeTelegramChannelUrl :: (term?: string) -> string | undefined

normalizeTwitterTweetUrl

Parse a Twitter tweet id from a term and return a normalized Twitter tweet URL.

normalizeTwitterTweetUrl :: (term?: string) -> string | undefined

normalizeTwitterUserUrl

Parse a Twitter user name from a term and return a normalized Twitter feed URL.

normalizeTwitterUserUrl :: (term?: string) -> string | undefined

normalizeYoutubeVideoUrl

Parse a Youtube Video id from a term and return a normalized Youtube video URL.

normalizeYoutubeVideoUrl :: (term?: string) -> string | undefined

normalizeYoutubeChannelUrl

Parse a Youtube channel id from a term and return a normalized Youtube channel URL.

normalizeYoutubeChannelUrl :: (term?: string) -> string | undefined

normalizeHttpUrl

Turn a term into a well formed HTTP url.

normalizeHttpUrl :: (term?: string) -> string | undefined

License

GPL 3.0 licensed