GithubHelp home page GithubHelp logo

justjavac / deno-vendors Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 34 KB

List of vendor prefixes known to the web platform

License: MIT License

TypeScript 85.50% JavaScript 14.50%
deno-vendors vendors deno deno-module deno-mod deno-modules web prefix

deno-vendors's Introduction

deno-vendors

tag Build Status license

List of vendor prefixes known to the web platform.

List of (real) vendor prefixes known to the web platform. From Wikipedia and the CSS 2.1 spec.

† — real, as in, mso- and prince- are not included because they are not valid.

data from wooorm/vendors

Usage

import { vendors } from "https://deno.land/x/vendors/mod.ts";

console.log(vendors);

Output:

> [
>  "ah",
>  "apple",
>  "atsc",
>  "epub",
>  "fx",
>  "hp",
>  "khtml",
>  "moz",
>  "ms",
>  "o",
>  "rim",
>  "ro",
>  "tc",
>  "wap",
>  "webkit",
>  "xv",
> ]

You can also check if something is a correct Vendor by using isVendor().

import { isVendor } from "https://deno.land/x/vendors/mod.ts";

console.log(isVendor("ms"));
console.log(isVendor("blah"));

Output:

> true
> false

Instead of running isVendor() if you need to assign a variable to a supposed string that is a vendor, you can just set the type of the variable to Vendor. Thankfully, the TypeScript compiler will make sure that your variable is one of the valid vendors.

import { Vendor } from "https://deno.land/x/vendors/mod.ts";

const myVendor: Vendor = "o";

No output because it's valid!

Here is an example of what would happen if our variable isn't a valid Vendor:

import { Vendor } from "https://deno.land/x/vendors/mod.ts";

const myBadVendor1: Vendor = "";
const myBadVendor2: Vendor = 24;

Here are the two errors in the output

> error: TS2322 [ERROR]: Type '""' is not assignable to type '"ah" | "apple" | "atsc" | "epub" | "fx" | "hp" | "khtml" | "moz" | "ms" | "o" | "rim" | "ro" | "tc" | "wap" | "webkit" | "xv"'.
> const myBadVendor1: Vendor = "";
>       ~~~~~~~~~~~~
>
> TS2322 [ERROR]: Type '24' is not assignable to type '"ah" | "apple" | "atsc" | "epub" | "fx" | "hp" | "khtml" | "moz" | "ms" | "o" | "rim" | "ro" | "tc" | "wap" | "webkit" | "xv"'.
> const myBadVendor2: Vendor = 24;
>       ~~~~~~~~~~~~

License

deno-vendors is released under the MIT License. See the bundled LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.