lib/builders/create.js
function performCreate(builder, path, data, callback) {
  var client = builder.client;
  var zk = client.zk;
  var firstTime = true;

  client.retryLoop(exec, callback);

  function exec(cb) {
    if (firstTime && builder.protection) {
      findProtectedNode(builder, path, createIfNotExist);
    }
    else {
      createIfNotExist();
    }

    firstTime = false;

    function createIfNotExist(err, nodePath) {
      if (err) {
        var args = operationArguments(builder, path, data);
        return cb(new ExecutionError('create', args, err));
      }
      else if (nodePath) {
        return cb(null, nodePath);
      }

      zk.create(path, data, builder.acls, builder.mode, afterCreate);
    }

    function afterCreate(err, nodePath) {
      if (nodePath) {
        cb(null, nodePath);
      }
      else if (err.getCode() === Exception.NO_NODE && builder.createParents) {
        utils.mkdirs(zk, path, false, null, createIfNotExist);
      }
      else {
        var args = operationArguments(builder, path, data);
        cb(new ExecutionError('create', args, err));
      }
    }
  }
}
function performCreate(builder, path, data, callback) {
  var client = builder.client;
  var zk = client.zk;
  var firstTime = true;

  client.retryLoop(exec, callback);

  function exec(cb) {
    if (firstTime && builder.protection) {
      findProtectedNode(builder, path, createIfNotExist);
    }
    else {
      createIfNotExist();
    }

    firstTime = false;

    function createIfNotExist(err, nodePath) {
      if (err) {
        var args = operationArguments(builder, path, data);
        return cb(new ExecutionError('create', args, err));
      }
      else if (nodePath) {
        return cb(null, nodePath);
      }

      zk.create(path, data, builder.acls, builder.mode, afterCreate);
    }

    function afterCreate(err, nodePath) {
      if (nodePath) {
        cb(null, nodePath);
      }
      else if (err.getCode() === Exception.NO_NODE && builder.createParents) {
        utils.mkdirs(zk, path, false, null, createIfNotExist);
      }
      else {
        var args = operationArguments(builder, path, data);
        cb(new ExecutionError('create', args, err));
      }
    }
  }
}
function performCreate ( builder , path , data , callback ) { var client = builder . client ; var zk = client . zk ; var firstTime = true ; client . retryLoop ( exec , callback ) ; function exec ( cb ) { if ( firstTime && builder . protection ) { findProtectedNode ( builder , path , createIfNotExist ) ; } else { createIfNotExist ( ) ; } firstTime = false ; function createIfNotExist ( err , nodePath ) { if ( err ) { var args = operationArguments ( builder , path , data ) ; return cb ( new ExecutionError ( 'create' , args , err ) ) ; } else if ( nodePath ) { return cb ( null , nodePath ) ; } zk . create ( path , data , builder . acls , builder . mode , afterCreate ) ; } function afterCreate ( err , nodePath ) { if ( nodePath ) { cb ( null , nodePath ) ; } else if ( err . getCode ( ) === Exception . NO_NODE && builder . createParents ) { utils . mkdirs ( zk , path , false , null , createIfNotExist ) ; } else { var args = operationArguments ( builder , path , data ) ; cb ( new ExecutionError ( 'create' , args , err ) ) ; } } } }
Create node and it's parents if needed.

@param {CreateBuilder} builder
@param {String} path Node path
@param {Buffer} data Node data
@param {Function} callback Callback function: <code>(err)</code>
Create node and it s parents if needed .