'use strict';

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

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var ATTR = {
  BOLD: 'bold',
  ITALIC: 'italic',
  UNDERLINE: 'underline',
  STRIKETHROUGH: 'strikethrough',
  SUPERSCRIPT: 'superscript',
  SUBSCRIPT: 'subscript'
};

exports.ATTR = ATTR;
function hasAttribute(attributes, attr) {
  return attributes && attributes[attr];
}

function hasAttributeFor(attributes) {
  return _lodash2['default'].partial(hasAttribute, attributes);
}

function attributesEqual(attr1, attr2) {
  var normalize = function normalize(a) {
    return _lodash2['default'].pick(a, function (value) {
      return value;
    });
  }; // pick entries where value exists and is truthy
  return _lodash2['default'].isEqual(normalize(attr1), normalize(attr2));
}