INNER CODE UNIT · JavaScript

namespaced

astefanutti/kubebox · lib/client.js:369

function namespaced(strings, namespace) {
  const path = strings[0];
  if (namespace === undefined) {
    return path;
  }
  const i = path.lastIndexOf('/');
  return path.slice(0, i) + '/namespaces/' + namespace + path.slice(i, path.length);
}

function merge(target, ...sources) {
  return sources.reduce((target, source) => mergeSingle(target, source), target);
}

function mergeSingle(target, source) {
  return Object.keys(source).reduce((target, key) => {
    const prop = source[key];
    if (typeof prop === 'object' && Object.prototype.toString.call(prop) === '[object Object]') {
      // Only deep copy Object

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…