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.
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
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 searchingWebSocketconstructors this should just beWebSocketwith the proper casing. - where
Object, The object we need to search in. This can be a JavaScript object but also a global,windowordocument. Defaults toglobal.
var found = prefixes('WebSocket'); // Finds mozWebSocket or WebSocketIf no match is found we will return an undefined.
MIT