How to use the d.js function in d

To help you get started, we’ve selected a few d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bbottema / js-epub-maker / dist / js-epub-maker.js View on Github external
module.exports = function ajax(url, data) {
        var deferred = D();
    	try {
    		var x = new (XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
    		x.open(data ? 'POST' : 'GET', url, 1);
    		x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    		x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    		x.onreadystatechange = function () {
    			x.readyState > 3 && deferred.resolve({ 'data': x.responseText, 'xhr': x });
    		};
    		x.send(data)
    	} catch (e) {
    		console.error(e);
    	    deferred.reject(e);
    	}
    	return deferred.promise;
    };
}());
github bbottema / js-epub-maker / src / js / template-builders / idpf-wasteland-builder.js View on Github external
this.make = function(epubConfig) {
            console.debug('building epub', epubConfig);
            var zip = new JSZip();
            
            var deferred = D();
            D.all(
                addMimetype(zip),
                addContainerInfo(zip, epubConfig),
                addManifestOpf(zip, epubConfig),
                addCover(zip, epubConfig),
                addEpub2Nav(zip, epubConfig),
                addEpub3Nav(zip, epubConfig),
                addStylesheets(zip, epubConfig),
                addContent(zip, epubConfig)
            ).then(function() {
                deferred.resolve(zip);
            });
            
            return deferred.promise;
        };
github bbottema / js-epub-maker / dist / js-epub-maker.js View on Github external
function addStylesheets(zip, epubConfig) {
            var deferred = D();
            if(epubConfig.stylesheet.url) {
                return ajax(epubConfig.stylesheet.url).then(function(result) {
                    epubConfig.styles = result.data;
                    compileAndAddCss();
                });
            } else {
                compileAndAddCss();
            }
            return deferred.promise;

            function compileAndAddCss() {
                var styles = {
                    original: epubConfig.stylesheet.replaceOriginal ? '' : templates.css,
                    custom: epubConfig.styles
                };
                zip.folder('EPUB').folder('css').file('main.css', compile('{{{original}}}{{{custom}}}', styles, true));
github bbottema / js-epub-maker / dist / js-epub-maker.js View on Github external
function addFiles(zip, epubConfig) {
            var deferred_list = [];
            for(var i = 0; i < epubConfig.additionalFiles.length; i++) {
                var file = epubConfig.additionalFiles[i];
                var deferred = new D();
                JSZipUtils.getBinaryContent(file.url, (function(file, deferred) {
                    return function(err, data) {
                        if(!err) {
                            zip.folder('EPUB').folder(file.folder).file(file.filename, data, { binary: true });
                            deferred.resolve('');
                        } else {
                            deferred.reject(err);
                        }
                    };
                })(file, deferred));
                deferred_list.push(deferred.promise);
            }
            return D.all(deferred_list);
        }
github malko / node-promised-redmine / lib / redmine.js View on Github external
, getAllSince: function(what, since, params){
		since.toISOString && (since = since.toISOString());
		params || (params = {} );
		params.sort = 'updated_on:desc';
		params.limit || (params.limit=100);
		var self = this
			, d = D()
			, res = []
			, getNext = function getNext(data){
				var fulfilled=false;
				data[what].forEach(function(v){
					if( since >= v.updated_on ){
						fulfilled=true;
					}
					fulfilled || res.push(v);
				});
				if( (!fulfilled) && (data.total_count > (data.limit+data.offset)) ){
						params.offset = data.limit+data.offset;
						params.limit = data.limit;
						return self.get(what, params).success(getNext).rethrow(d.reject);
				}
				return d.resolve(res);
			}
github bbottema / js-epub-maker / src / js / template-builders / idpf-wasteland-builder.js View on Github external
function addStylesheets(zip, epubConfig) {
            var deferred = D();
            if (epubConfig.stylesheet.url) {
                return ajax(epubConfig.stylesheet.url).then(function(result) {
                    epubConfig.styles = result.data;
                    compileAndAddCss();
                });
            } else {
                compileAndAddCss();
            }
            return deferred.promise;
            
            function compileAndAddCss() {
                var styles = {
                    original: epubConfig.stylesheet.replaceOriginal ? '' : templates.css,
                    custom: epubConfig.styles
                };
                zip.folder('EPUB').file(epubConfig.slug + '.css', compile('{{{original}}}{{{custom}}}', styles, true));
github malko / node-promised-redmine / lib / redmine.js View on Github external
, request: function(method, path, params){
		params || (params = {});

		var self = this
			, d = D()
			, keyPass  = keyPassphrases[this.keyPassId]
			, retry = params.retry || {}
			, verbose = this.verbose
			, impersonation
			, options
			, req
		;
		if (params.retry) {
			delete params.retry;
		}
		retry.count || (retry.count = 1);
		retry.maxTry || (retry.maxTry = self.maxTry);
		retry.maxDelay || (retry.maxDelay = self.maxDelay);

		if (params.impersonate) {
			impersonation = params.impersonate;
github bbottema / js-epub-maker / dist / js-epub-maker.js View on Github external
function addCover(zip, epubConfig) {
            var deferred = D();
            
            if (epubConfig.coverUrl) {
                JSZipUtils.getBinaryContent(epubConfig.coverUrl, function (err, data) {
                    if (!err) {
                        var ext = epubConfig.coverUrl.substr(epubConfig.coverUrl.lastIndexOf('.') + 1);
                        zip.folder('EPUB').file(epubConfig.slug + '-cover.' + ext, data, { binary: true });
                        deferred.resolve('');
                    } else {
                        deferred.reject(err);
                    }
                });
            } else {
                deferred.resolve(true);
            }
            return deferred.promise;
        }
github bbottema / js-epub-maker / src / js / template-builders / idpf-wasteland-builder.js View on Github external
function addCover(zip, epubConfig) {
            var deferred = D();
            
            if (epubConfig.coverUrl) {
                JSZipUtils.getBinaryContent(epubConfig.coverUrl, function (err, data) {
                    if (!err) {
                        var ext = epubConfig.coverUrl.substr(epubConfig.coverUrl.lastIndexOf('.') + 1);
                        zip.folder('EPUB').file(epubConfig.slug + '-cover.' + ext, data, { binary: true });
                        deferred.resolve('');
                    } else {
                        deferred.reject(err);
                    }
                });
            } else {
                deferred.resolve(true);
            }
            return deferred.promise;
        }
github bbottema / js-epub-maker / dist / js-epub-maker.js View on Github external
function addStylesheets(zip, epubConfig) {
            var deferred = D();
            if (epubConfig.stylesheet.url) {
                return ajax(epubConfig.stylesheet.url).then(function(result) {
                    epubConfig.styles = result.data;
                    compileAndAddCss();
                });
            } else {
                compileAndAddCss();
            }
            return deferred.promise;
            
            function compileAndAddCss() {
                var styles = {
                    original: epubConfig.stylesheet.replaceOriginal ? '' : templates.css,
                    custom: epubConfig.styles
                };
                zip.folder('EPUB').file(epubConfig.slug + '.css', compile('{{{original}}}{{{custom}}}', styles, true));

d

Property descriptor factory

ISC
Latest version published 10 months ago

Package Health Score

68 / 100
Full package analysis