function e(t) {
  this.content = t;
}
e.prototype = {
  constructor: e,
  find: function(t) {
    for (var n = 0; n < this.content.length; n += 2)
      if (this.content[n] === t) return n;
    return -1;
  },
  // :: (string) → ?any
  // Retrieve the value stored under `key`, or return undefined when
  // no such key exists.
  get: function(t) {
    var n = this.find(t);
    return n == -1 ? void 0 : this.content[n + 1];
  },
  // :: (string, any, ?string) → OrderedMap
  // Create a new map by replacing the value of `key` with a new
  // value, or adding a binding to the end of the map. If `newKey` is
  // given, the key of the binding will be replaced with that key.
  update: function(t, n, r) {
    var i = r && r != t ? this.remove(r) : this, o = i.find(t), c = i.content.slice();
    return o == -1 ? c.push(r || t, n) : (c[o + 1] = n, r && (c[o] = r)), new e(c);
  },
  // :: (string) → OrderedMap
  // Return a map with the given key removed, if it existed.
  remove: function(t) {
    var n = this.find(t);
    if (n == -1) return this;
    var r = this.content.slice();
    return r.splice(n, 2), new e(r);
  },
  // :: (string, any) → OrderedMap
  // Add a new key to the start of the map.
  addToStart: function(t, n) {
    return new e([t, n].concat(this.remove(t).content));
  },
  // :: (string, any) → OrderedMap
  // Add a new key to the end of the map.
  addToEnd: function(t, n) {
    var r = this.remove(t).content.slice();
    return r.push(t, n), new e(r);
  },
  // :: (string, string, any) → OrderedMap
  // Add a key after the given key. If `place` is not found, the new
  // key is added to the end.
  addBefore: function(t, n, r) {
    var i = this.remove(n), o = i.content.slice(), c = i.find(t);
    return o.splice(c == -1 ? o.length : c, 0, n, r), new e(o);
  },
  // :: ((key: string, value: any))
  // Call the given function for each key/value pair in the map, in
  // order.
  forEach: function(t) {
    for (var n = 0; n < this.content.length; n += 2)
      t(this.content[n], this.content[n + 1]);
  },
  // :: (union<Object, OrderedMap>) → OrderedMap
  // Create a new map by prepending the keys in this map that don't
  // appear in `map` before the keys in `map`.
  prepend: function(t) {
    return t = e.from(t), t.size ? new e(t.content.concat(this.subtract(t).content)) : this;
  },
  // :: (union<Object, OrderedMap>) → OrderedMap
  // Create a new map by appending the keys in this map that don't
  // appear in `map` after the keys in `map`.
  append: function(t) {
    return t = e.from(t), t.size ? new e(this.subtract(t).content.concat(t.content)) : this;
  },
  // :: (union<Object, OrderedMap>) → OrderedMap
  // Create a map containing all the keys in this map that don't
  // appear in `map`.
  subtract: function(t) {
    var n = this;
    t = e.from(t);
    for (var r = 0; r < t.content.length; r += 2)
      n = n.remove(t.content[r]);
    return n;
  },
  // :: () → Object
  // Turn ordered map into a plain object.
  toObject: function() {
    var t = {};
    return this.forEach(function(n, r) {
      t[n] = r;
    }), t;
  },
  // :: number
  // The amount of keys in this map.
  get size() {
    return this.content.length >> 1;
  }
};
e.from = function(t) {
  if (t instanceof e) return t;
  var n = [];
  if (t) for (var r in t) n.push(r, t[r]);
  return new e(n);
};
export {
  e as default
};
//# sourceMappingURL=index.js.map
