How to use do - 10 common examples

To help you get started, we’ve selected a few do 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 zz85 / timeliner / src / ui_number.js View on Github external
cursor: 'ns-resize',
		width: '40px',
		margin: 0,
		marginRight: '10px',
		appearance: 'none',
		outline: 'none',
		border: 0,
		background: 'none',
		borderBottom: '1px dotted '+ Theme.c,
		color: Theme.c
	});

	var me = this;
	var state, value = 0, unchanged_value;

	this.onChange = new Do();

	span.addEventListener('change', function(e) {
		console.log('input changed', span.value);
		value = parseFloat(span.value, 10);

		fireChange();
	});

	handleDrag(span, onDown, onMove, onUp);

	function onUp(e) {
		if (e.moved) fireChange();
		else {
			// single click
			span.focus();
		}
github tengge1 / ShadowEditor / ShadowEditor.Web / assets / js / timeliner.js View on Github external
cursor: 'ns-resize',
				width: '40px',
				margin: 0,
				marginRight: '10px',
				appearance: 'none',
				outline: 'none',
				border: 0,
				background: 'none',
				borderBottom: '1px dotted ' + Theme.c,
				color: Theme.c
			});

			var me = this;
			var state, value = 0, unchanged_value;

			this.onChange = new Do();

			span.addEventListener('change', function (e) {
				console.log('input changed', span.value);
				value = parseFloat(span.value, 10);

				fireChange();
			});

			// Allow keydown presses in inputs, don't allow parent to block them
			span.addEventListener('keydown', function (e) {
				e.stopPropagation();
			})

			span.addEventListener('focus', function (e) {
				span.setSelectionRange(0, span.value.length);
			})
github creationix / howtonode.org / articles / do-it-fast / continuable_based.js View on Github external
function errorHandler(error) {
  throw error;
}

var Do = require('do');
// Convert `readFile` from fs to use continuable style.
var fs = Do.convert(require('fs'), ['readFile']);

function safeRead(filename) { return function (callback, errback) {
  fs.readFile(filename)(callback, function (error) {
    if (error.errno === process.ENOENT) {
      callback("");
    } else {
      errback(error);
    }
  })
}}

safeRead(__filename)(console.log, errorHandler);
github tentone / nunuStudio / source / lib / timeliner.js View on Github external
scrolltrackHeight = h - 2;
		scrolltrack.style.height = scrolltrackHeight + 'px' ;
	};

	// Moves scrollbar to position by Percentage
	this.setPosition = function(p) {
		p = Math.max(Math.min(1, p), 0);
		var emptyTrack = scrolltrackHeight - bar_length;
		bar_y = p * emptyTrack;
		scrollbar.style.top = bar_y + 'px';
	};

	this.setLength(1);
	this.setPosition(0);
	this.onScroll = new SimpleEvent();

	var mouse_down_grip;

	function onDown(event) {
		event.preventDefault();

		if (event.target == scrollbar) {
			mouse_down_grip = event.clientY;
			document.addEventListener('mousemove', onMove, false);
			document.addEventListener('mouseup', onUp, false);
		} else {
			if (event.clientY < bar_y) {
				me.onScroll.fire('pageup');
			} else if (event.clientY > (bar_y + bar_length)) {
				me.onScroll.fire('pagedown');
			}
github tengge1 / ShadowEditor / ShadowEditor.Web / assets / js / timeliner.js View on Github external
scrolltrackHeight = h - 2;
				scrolltrack.style.height = scrolltrackHeight + 'px';
			};

			// Moves scrollbar to position by Percentage
			this.setPosition = function (p) {
				p = Math.max(Math.min(1, p), 0);
				var emptyTrack = scrolltrackHeight - bar_length;
				bar_y = p * emptyTrack;
				scrollbar.style.top = bar_y + 'px';
			};

			this.setLength(1);
			this.setPosition(0);
			this.onScroll = new SimpleEvent();

			var mouse_down_grip;

			function onDown(event) {
				event.preventDefault();

				if (event.target == scrollbar) {
					mouse_down_grip = event.clientY;
					document.addEventListener('mousemove', onMove, false);
					document.addEventListener('mouseup', onUp, false);
				} else {
					if (event.clientY < bar_y) {
						me.onScroll.fire('pageup');
					} else if (event.clientY > (bar_y + bar_length)) {
						me.onScroll.fire('pagedown');
					}
github zz85 / timeliner / timeliner.js View on Github external
scrolltrackHeight = h - 2;
		scrolltrack.style.height = scrolltrackHeight + 'px' ;
	};

	// Moves scrollbar to position by Percentage
	this.setPosition = function(p) {
		p = Math.max(Math.min(1, p), 0);
		var emptyTrack = scrolltrackHeight - bar_length;
		bar_y = p * emptyTrack;
		scrollbar.style.top = bar_y + 'px';
	};

	this.setLength(1);
	this.setPosition(0);
	this.onScroll = new SimpleEvent();

	var mouse_down_grip;

	function onDown(event) {
		event.preventDefault();

		if (event.target == scrollbar) {
			mouse_down_grip = event.clientY;
			document.addEventListener('mousemove', onMove, false);
			document.addEventListener('mouseup', onUp, false);
		} else {
			if (event.clientY < bar_y) {
				me.onScroll.fire('pageup');
			} else if (event.clientY > (bar_y + bar_length)) {
				me.onScroll.fire('pagedown');
			}
github creationix / node-blog / build.js View on Github external
// Load some libraries
require.paths.unshift(__dirname + "/vendor");
var Haml = require('haml'),
    Markdown = require('markdown'),
    md5 = require('md5').md5,
    Do = require('do'),
    fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile', 'writeFile']),
    sys = Do.convert(require('sys'), ['exec']);

var ARTICLE_DIR = __dirname + '/data/articles',
    AUTHOR_DIR = __dirname + '/data/authors',
    SKIN_DIR = __dirname + '/data/skin',
    PUBLIC_DIR = __dirname + '/public';

var Filters = {

  // Extends markdown by allowing properties at the top.
  markdown: function (markdown) {
    var match;
    var props = {};
    while(match = markdown.match(/^([a-z]+):\s*(.*)\s*\n/i)) {
      var name = match[1].toLowerCase(),
          value = match[2];
github creationix / node-blog / build.js View on Github external
// Load some libraries
require.paths.unshift(__dirname + "/vendor");
var Haml = require('haml'),
    Markdown = require('markdown'),
    md5 = require('md5').md5,
    Do = require('do'),
    fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile', 'writeFile']),
    sys = Do.convert(require('sys'), ['exec']);

var ARTICLE_DIR = __dirname + '/data/articles',
    AUTHOR_DIR = __dirname + '/data/authors',
    SKIN_DIR = __dirname + '/data/skin',
    PUBLIC_DIR = __dirname + '/public';

var Filters = {

  // Extends markdown by allowing properties at the top.
  markdown: function (markdown) {
    var match;
    var props = {};
    while(match = markdown.match(/^([a-z]+):\s*(.*)\s*\n/i)) {
      var name = match[1].toLowerCase(),
          value = match[2];
      markdown = markdown.substr(match[0].length);
github creationix / howtonode.org / articles / do-it-fast / loaddir.js View on Github external
function errorHandler(error) {
  throw error;
}

var Do = require('do');
var fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile']);

// Checks the `stat` of a file path and outputs the file contents if it's
// a real file
function loadFile(path, callback, errback) {
  fs.stat(path)(function (stat) {
    
    // Output undefined when the path isn't a regular file
    if (!stat.isFile()) {
      callback();
      return;
    }

    // Pass through the read to regular files as is.
    fs.readFile(path, 'utf8')(callback, errback)

  }, errback);
github thisandagain / turtle / lib / language.js View on Github external
block = checkevalblock(block);

        while (tf()) {
          self.execute(block);
      }
    };
    self.routines["while"].noeval = true;

    self.routines["do.until"] = function(block, tf) {
        block = checkevalblock(block);

        do {
          self.execute(block);
      } while (!tf());
    };
    self.routines["do.until"].noeval = true;

    self.routines["until"] = function(tf, block) {
        block = checkevalblock(block);

        while (!tf()) {
          self.execute(block);
      }
    };
    self.routines["until"].noeval = true;

      // Not Supported: case
      // Not Supported: cond


      //
      // 8.2 Template-based Iteration

do

The simplest way to manage asynchronicity

MIT
Latest version published 11 months ago

Package Health Score

59 / 100
Full package analysis