Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.cloneNames = exports.stringifyNames = exports.hasNameForId = exports.resetIdNames = exports.addNameForId = void 0;

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// @flow

/* These are helpers for the StyleTags to keep track of the injected
 * rule names for each (component) ID that they're keeping track of.
 * They're crucial for detecting whether a name has already been
 * injected.
 * (This excludes rehydrated names) */

/* adds a new ID:name pairing to a names dictionary */
const addNameForId = (names, id, name) => {
  if (name) {
    // eslint-disable-next-line no-param-reassign
    const namesForId = names[id] || (names[id] = Object.create(null));
    namesForId[name] = true;
  }
};
/* resets an ID entirely by overwriting it in the dictionary */


exports.addNameForId = addNameForId;

const resetIdNames = (names, id) => {
  // eslint-disable-next-line no-param-reassign
  names[id] = Object.create(null);
};
/* factory for a names dictionary checking the existance of an ID:name pairing */


exports.resetIdNames = resetIdNames;

const hasNameForId = names => (id, name) => names[id] !== undefined && names[id][name];
/* stringifies names for the html/element output */


exports.hasNameForId = hasNameForId;

const stringifyNames = names => {
  let str = ''; // eslint-disable-next-line guard-for-in

  for (const id in names) {
    str += `${Object.keys(names[id]).join(' ')} `;
  }

  return str.trim();
};
/* clones the nested names dictionary */


exports.stringifyNames = stringifyNames;

const cloneNames = names => {
  const clone = Object.create(null); // eslint-disable-next-line guard-for-in

  for (const id in names) {
    clone[id] = _objectSpread({}, names[id]);
  }

  return clone;
};

exports.cloneNames = cloneNames;