lib/elements.js
function refract(value) {
  if (value instanceof Element) {
    return value;
  }

  if (typeof value === 'string') {
    return new StringElement(value);
  }

  if (typeof value === 'number') {
    return new NumberElement(value);
  }

  if (typeof value === 'boolean') {
    return new BooleanElement(value);
  }

  if (value === null) {
    return new NullElement();
  }

  if (Array.isArray(value)) {
    return new ArrayElement(value.map(refract));
  }

  if (typeof value === 'object') {
    const element = new ObjectElement(value);
    return element;
  }

  return value;
}
function refract(value) {
  if (value instanceof Element) {
    return value;
  }

  if (typeof value === 'string') {
    return new StringElement(value);
  }

  if (typeof value === 'number') {
    return new NumberElement(value);
  }

  if (typeof value === 'boolean') {
    return new BooleanElement(value);
  }

  if (value === null) {
    return new NullElement();
  }

  if (Array.isArray(value)) {
    return new ArrayElement(value.map(refract));
  }

  if (typeof value === 'object') {
    const element = new ObjectElement(value);
    return element;
  }

  return value;
}
function refract ( value ) { if ( value instanceof Element ) { return value ; } if ( typeof value === 'string' ) { return new StringElement ( value ) ; } if ( typeof value === 'number' ) { return new NumberElement ( value ) ; } if ( typeof value === 'boolean' ) { return new BooleanElement ( value ) ; } if ( value === null ) { return new NullElement ( ) ; } if ( Array . isArray ( value ) ) { return new ArrayElement ( value . map ( refract ) ) ; } if ( typeof value === 'object' ) { const element = new ObjectElement ( value ) ; return element ; } return value ; }
Refracts a JSON type to minim elements
@param value
@returns {Element}
Refracts a JSON type to minim elements