Skip to content

Returns native console object or a stub with "empty" functions.

Notifications You must be signed in to change notification settings

eskypl/glide-console-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glide ConsoleAdapter

JavaScript stub for a native console object. Checks if there is a native window.console or console object and if not, assigns an object with empty functions to it. The module returns whatever is set to window.console (native object or stub). Useful to silence possible errors that might happen on different environments (where global window.console object is not available).

Instalation

npm install glide-console-adapter --save

Configuration

Minimal configuration for RequireJS is needed. RequireJS paths config variable has to include property console-adapter with given path to script.

Development and Build

Following code should be used in development and build.

require.config({
  paths: {
    'console-adapter': 'node_modules/glide-console-adapter/adapter'
  }
});

Usage

define([
  'console-adapter'
], function (console) {
	console.log('abc');
});
define([
  'console-adapter'
], function () {
	window.console.log('abc');
});

About

Returns native console object or a stub with "empty" functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published