'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var creator = require('../creator.js');
var selector = require('../selector.js');

function constantNull() {
  return null;
}

function selection_insert(name, before) {
  var create = typeof name === "function" ? name : creator.default(name),
      select = before == null ? constantNull : typeof before === "function" ? before : selector.default(before);
  return this.select(function() {
    return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
  });
}

exports.default = selection_insert;
