Skip to content

Return vendor prefixed functions/methods of a given DOM/JavaScript API if normal standard method is not found.

License

Notifications You must be signed in to change notification settings

unshiftio/prefixes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prefixes

Made by unshiftVersion npmBuild StatusDependenciesCoverage StatusIRC channel

Prefixes a simple function which searches a given object for possible prefixed instances of functions and methods. This allows you to easily figure out which API's you should be using. Even if prefixes are available it will still prefer a standard over a prefix so you can easily write future proof code.

Install

The module is intended for browser usage, but it should also work fine in Node.js but there are no prefixes there, so it's quite useless if you're building a node.js only application.

npm install --save prefixes

Usage

The module is exported with a single interface, which is the prefixes function:

'use strict';

var prefixes = require('prefixes');

Once you have required the prefixes module you can start searching for prefixed API's. The function accepts 2 arguments:

  • what String, The standard name of the property or function. If you are searching WebSocket constructors this should just be WebSocket with the proper casing.
  • where Object, The object we need to search in. This can be a JavaScript object but also a global, window or document. Defaults to global.
var found = prefixes('WebSocket'); // Finds mozWebSocket or WebSocket

If no match is found we will return an undefined.

License

MIT

About

Return vendor prefixed functions/methods of a given DOM/JavaScript API if normal standard method is not found.

Resources

License

Stars

Watchers

Forks

Packages

No packages published