How to use the property-expr.split function in property-expr

To help you get started, we’ve selected a few property-expr 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 jquense / react-formal / src / utils / paths.js View on Github external
export function inPath(basePath, childPath) {
  if (basePath === childPath) return true

  var partsA = prop.split(basePath) || []
    , partsB = prop.split(childPath) || []

  if (partsA.length > partsB.length)
    return false

  return partsA.every(
    (part, idx) => clean(part) === clean(partsB[idx]))
}
github jquense / react-formal / src / util / update.js View on Github external
module.exports = function update(model, path, value) {
  var parts = prop.split(path)
    , newModel = copy(model)
    , part, islast;

  if ( newModel === undefined )
    newModel = IS_ARRAY.test(parts[0]) ? [] : {}

  var current = newModel

  for (var idx = 0; idx < parts.length; idx++) {
    islast = idx === (parts.length - 1)
    part = paths.clean(parts[idx])

    if ( islast )
      current[part] = value
    
    else {
github jquense / yup / lib / object.js View on Github external
fields[key]._deps && fields[key]._deps.forEach(function (node) {
      //eslint-disable-line no-loop-func
      node = split(node)[0];

      if (! ~nodes.indexOf(node)) nodes.push(node);

      if (! ~excludes.indexOf('' + key + '-' + node)) edges.push([key, node]);
    });
  }
github jquense / topeka / src / updateIn.js View on Github external
export default function update(model, path, value) {
  var parts = prop.split(path)
    , newModel = copy(model)
    , part, islast;

  if (newModel == null)
    newModel = IS_ARRAY.test(parts[0]) ? [] : {}

  var current = newModel

  for (var idx = 0; idx < parts.length; idx++) {
    islast = idx === (parts.length - 1)
    part = clean(parts[idx])

    if (islast)
      current[part] = value

    else {
github jquense / yup / src / util / sortFields.js View on Github external
function addNode(depPath, key) {
    var node = split(depPath)[0];

    if (!~nodes.indexOf(node)) nodes.push(node);

    if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
  }
github jquense / react-formal / src / utils / paths.js View on Github external
export function inPath(basePath, childPath) {
  if (basePath === childPath) return true

  var partsA = prop.split(basePath) || []
    , partsB = prop.split(childPath) || []

  if (partsA.length > partsB.length)
    return false

  return partsA.every(
    (part, idx) => clean(part) === clean(partsB[idx]))
}

property-expr

tiny util for getting and setting deep object props safely

MIT
Latest version published 10 months ago

Package Health Score

68 / 100
Full package analysis