lib/zookeeper.js
function createParentPath(client, path, callback) {
  var parentDir = path.substring(0, path.lastIndexOf('/'));

  debug('createParentPath: "%s"', parentDir);

  if (parentDir.length != 0) {
    client.create(parentDir, function(err) {
      if (err) {
        if (err.code === NO_NODE) {
          return createParentPath(client, parentDir, function(err) {
            if (err) return callback(err);

            createParentPath(client, path, callback);
          });
        } else if (err.code !== NODE_EXISTS)
          return callback(err);
      }
      callback(null, path);
    });
  } else
    callback(null, path);
}
function createParentPath(client, path, callback) {
  var parentDir = path.substring(0, path.lastIndexOf('/'));

  debug('createParentPath: "%s"', parentDir);

  if (parentDir.length != 0) {
    client.create(parentDir, function(err) {
      if (err) {
        if (err.code === NO_NODE) {
          return createParentPath(client, parentDir, function(err) {
            if (err) return callback(err);

            createParentPath(client, path, callback);
          });
        } else if (err.code !== NODE_EXISTS)
          return callback(err);
      }
      callback(null, path);
    });
  } else
    callback(null, path);
}
function createParentPath ( client , path , callback ) { var parentDir = path . substring ( 0 , path . lastIndexOf ( '/' ) ) ; debug ( 'createParentPath: "%s"' , parentDir ) ; if ( parentDir . length != 0 ) { client . create ( parentDir , function ( err ) { if ( err ) { if ( err . code === NO_NODE ) { return createParentPath ( client , parentDir , function ( err ) { if ( err ) return callback ( err ) ; createParentPath ( client , path , callback ) ; } ) ; } else if ( err . code !== NODE_EXISTS ) return callback ( err ) ; } callback ( null , path ) ; } ) ; } else callback ( null , path ) ; }
Create the parent path

@param {ZkClient} client
@param {String} path
@param {Function} callback
Create the parent path