gruntjs - Calling a function defined outside of the Javascript library -


i working on library. trying modify it, uses custom player instead of html5 player. replaced function calls play() etc calls custom player(say custfunc1()). these calls defined in separate file: custplayer.js.

so in index.html file, first include custplayer.js file , built file.

however problem while building video.js package using grunt, error custfunc1 not defined , grunt not able create video.js library.

now able find out colleague adding /* global custfunc1 */ @ beginning of particular file in package calling custfunc1 resolves issue. grunt build succeeds , works fine.

so want know is:

  1. how resolve issue, since comment in javascript, how treat differently , understand indicating function definition present outside library?

  2. is word global sort of keyword in javascript?

  3. are there other ways of achieving apart mentioned?

  4. on different note, wanted ask if rough equivalent of ?

your javascript being linted part of grunt process, if @ root of project folder should see file .jshintrc or along lines (different depending on linter).

your current settings means linter going through .js files 1 @ time , if comes across variable or function files it's throwing error seeing. can either turn off check or add custfunc1 array of known global variables. in jshint - https://github.com/gruntjs/grunt-contrib-jshint#jshintrc

{   "globals": {     "custfunc1": true   } } 

the globals present in file, add custfunc1: true it.

oh , answer question 1 - comment type syntax tells linter ignore it's settings current file, overriding settings in .jshintrc file.

2 - yes it's setting in jshintrc , adding custfunc1 inside file instead of globally in .jshintrc file.

3 - mentioned above.

4 - never used maker yes believe similar in pre process tool


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -