javascript - Using Q library in browser -


i need use q library (http://documentup.com/kriskowal/q/) in browser. use requirejs load library, don't have idea how this. know how load own module, can't q. has function:

(function (definition) {    //some code here***   // requirejs } else if (typeof define === "function" && define.amd) {   define(definition); 

how can load q , use in module?

you can load q library using script statement in html

<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.1.0/q.js"></script> 

then can access via q variable so:

function square(x) {     return x * x; } function plus1(x) {     return x + 1; }  q.fcall(function () {return 4;}) .then(plus1) .then(square) .then(function(z) {     alert("square of (value+1) = " + z); }); 

see running @ http://jsfiddle.net/uesyd/1/


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -