How to use the trim function in trim

To help you get started, we’ve selected a few trim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / lock-passwordless / src / cred / country_codes.js View on Github external
export function find(str) {
  let query = trim(str);
  let by;
  if (/^\+?\d+$/.test(query)) {
    by = "diallingCode";
    query = query[0] === "+" ? query : `+${query}`;
    query = query.toLowerCase();
  } else if (query.length <= 2) {
    by = "isoCode";
    query = query.toUpperCase()
  } else {
    by = "country";
    query = query.toLowerCase();
  }

  return countryCodes.filter(x => {
    switch(by) {
      case "diallingCode":
github gajus / surgeon / src / parseQuery.js View on Github external
export default (query: string): QueryType => {
  let selector = trim(query);
  let quantifier: QuantifierType;
  let attributeSelector: AttributeSelectorType;
  let propertySelector: PropertySelectorType;

  if (hasQuantifier(selector)) {
    quantifier = getQuantifier(selector);

    if (!quantifier.expression) {
      throw new Error('Unexpected result.');
    }

    selector = trim(selector.slice(0, -1 * quantifier.expression.length));
  } else {
    quantifier = {
      accessor: 0,
      max: 1,
github auth0 / lock-passwordless / src / lock / credentials / password.js View on Github external
validatePassword: function(password) {
    password = trim(password);
    return password.length > 3 ? password : null;
  }
}
github auth0 / lock-passwordless / src / cred / index.js View on Github external
export function validateVcode(vcode) {
  return trim(vcode).length > 0;
}
github gajus / surgeon / src / parseQuery.js View on Github external
} else {
    quantifier = {
      accessor: 0,
      max: 1,
      min: 1
    };
  }

  if (hasPropertySelector(selector)) {
    propertySelector = getPropertySelector(selector);

    selector = trim(selector.slice(0, -1 * propertySelector.expression.length));
  } else if (hasAttributeSelector(selector)) {
    attributeSelector = getAttributeSelector(selector);

    selector = trim(selector.slice(0, -1 * attributeSelector.expression.length));
  }

  return {
    attributeSelector,
    propertySelector,
    quantifier,
    selector
  };
};
github auth0 / lock-passwordless / src / lock / credentials / email.js View on Github external
validateEmail: function(email) {
    var result = emailRegExp.exec(trim(email.toLowerCase()));
    return result && result[0];
  }
}
github auth0 / lock-passwordless / src / cred / index.js View on Github external
export function validateEmail(email) {
  const regExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  const result = regExp.exec(trim(email.toLowerCase()));
  return result && result[0];
}
github auth0 / lock-passwordless / src / gravatar / index.js View on Github external
export function normalizeGravatarEmail(str) {
  return typeof str === "string"
    ? trim(str.toLowerCase())
    : "";
}

trim

Trim string whitespace

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Popular trim functions