How to use set-value - 9 common examples

To help you get started, we’ve selected a few set-value 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 oberonamsterdam / redux-updaters / src / createReducer.ts View on Github external
return (state: object = defaultState, action: Action): any => {
        if (state && action.type.substr(0, ACTION_PREFIX.length) === ACTION_PREFIX) {

            const path = formatPath(action.meta ? action.meta.path : '');
            const parts = path.split('.');
            const newState = { ...state };

            // make sure objects don't get mutated by cloning them
            if (parts.length > 1) {
                cloneObjects(newState, parts, 0);
            }

            return setValue(newState, path, action.payload);

        }

        return state;
    };
};
github nativescript-vue / nativescript-vue / platform / nativescript / renderer / ViewNode.js View on Github external
if (XML_ATTRIBUTES.indexOf(key) !== -1) {
        nv[key] = value
      } else {
        // detect expandable attrs for boolean values
        // See https://vuejs.org/v2/guide/components-props.html#Passing-a-Boolean
        if (
          require('@nativescript/core/utils/types').isBoolean(nv[key]) &&
          value === ''
        ) {
          value = true
        }

        if (isAndroid && key.startsWith('android:')) {
          set(nv, key.substr(8), value)
        } else if (isIOS && key.startsWith('ios:')) {
          set(nv, key.substr(4), value)
        } else if (key.endsWith('.decode')) {
          set(
            nv,
            key.slice(0, -7),
            require('@nativescript/core/xml').XmlParser._dereferenceEntities(
              value
            )
          )
        } else {
          set(nv, key, value)
        }
      }
    } catch (e) {
      // ignore
    }
  }
github nativescript-vue / nativescript-vue / platform / nativescript / renderer / ViewNode.js View on Github external
} else {
        // detect expandable attrs for boolean values
        // See https://vuejs.org/v2/guide/components-props.html#Passing-a-Boolean
        if (
          require('@nativescript/core/utils/types').isBoolean(nv[key]) &&
          value === ''
        ) {
          value = true
        }

        if (isAndroid && key.startsWith('android:')) {
          set(nv, key.substr(8), value)
        } else if (isIOS && key.startsWith('ios:')) {
          set(nv, key.substr(4), value)
        } else if (key.endsWith('.decode')) {
          set(
            nv,
            key.slice(0, -7),
            require('@nativescript/core/xml').XmlParser._dereferenceEntities(
              value
            )
          )
        } else {
          set(nv, key, value)
        }
      }
    } catch (e) {
      // ignore
    }
  }
github nativescript-vue / nativescript-vue / platform / nativescript / renderer / ViewNode.js View on Github external
}

        if (isAndroid && key.startsWith('android:')) {
          set(nv, key.substr(8), value)
        } else if (isIOS && key.startsWith('ios:')) {
          set(nv, key.substr(4), value)
        } else if (key.endsWith('.decode')) {
          set(
            nv,
            key.slice(0, -7),
            require('@nativescript/core/xml').XmlParser._dereferenceEntities(
              value
            )
          )
        } else {
          set(nv, key, value)
        }
      }
    } catch (e) {
      // ignore
    }
  }
github tinajs / tina / test / helpers / mina-sandbox / index.js View on Github external
setData (data, callback) {
    let next = clone(this.data)
    for (let key in data) {
      if (key.includes('[') || key.includes('.')) {
        set(next, key, data[key])
      } else {
        next[key] = data[key]
      }
    }
    this.data = next
    if (typeof callback === 'function') {
      callback()
    }
  }
github klembot / chapbook / src / state / index.js View on Github external
export function setDefault(name, value) {
	const previous = get(name);

	log(`Defaulting "${name}" to ${JSON.stringify(value)}`);
	deepSet(defaults, name, value);
	addGlobalProxy(window, name);

	if (previous === null || previous === undefined) {
		event.emit('state-change', {name, value, previous});
	}
}
github klembot / chapbook / src / state / index.js View on Github external
export function set(name, value) {
	const previous = get(name);

	//log(`Setting "${name}" to ${JSON.stringify(value)}`);
	deepSet(vars, name, value);
	addGlobalProxy(window, name);

	const now = get(name);

	if (now !== previous) {
		event.emit('state-change', {name, value: get(name), previous});
	}

	if (get('config.state.autosave')) {
		saveToStorage();
	}
}
github prisma / photonjs / packages / photon-generate / archive / benchmark-sideeffect-set.ts View on Github external
.add('set-value', () => {
    const obj = {
      createUser: {
        data: {
          post: {
            create: {},
          },
        },
      },
    }
    setValue(obj, 'createUser.data.post.create.title', 'String')
  })
  .add('@strikeentco/set', () => {
github alexander-heimbuch / redux-vuex / src / mixin.js View on Github external
Object.keys(bindings).forEach(prop => {
      const getter = bindings[prop]

      if (!getter) {
        return
      }

      set(component._data, prop, getter(state))
    })
  }

set-value

Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis

Popular set-value functions