prefixes

1.0.1 • Public • Published

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.
var found = prefixes('WebSocket'); // Finds mozWebSocket or WebSocket

If no match is found we will return an undefined.

License

MIT

Package Sidebar

Install

npm i prefixes

Weekly Downloads

5

Version

1.0.1

License

MIT

Last publish

Collaborators

  • 3rdeden
  • v1