INNER CODE UNIT · TypeScript

applyOverrides

org-formation/org-formation-cli · src/yaml-cfn/index.ts:60

const applyOverrides = (data: any, tag: string, method: string): any => {
  return overrides[tag] ? overrides[tag][method](data) : data;
};

/**
 * Generic tag-creating helper. For the given name of the form 'Fn::Something' (or just
 * 'Something'), creates a js-yaml Type object that can parse and dump this type. It creates it
 * for all types of values, for simplicity and because that's how the official Python version
 * works.
 */
const makeTagTypes = (name: string): yaml.Type[] => {
  const parts = splitOne(name, '::');
  const tag = parts ? parts[1] : name;
  // Translate in the same way for all types, to match Python's generic translation.
  return ['scalar', 'sequence', 'mapping'].map(kind => new yaml.Type('!' + tag, {
    kind: kind as any,
    construct: (data: any): any => ({ [name]: applyOverrides(data, tag, 'parse') }),
    predicate: (obj: any): boolean => checkType(obj, name),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…