How to use the ember-changeset/utils/take function in ember-changeset

To help you get started, we’ve selected a few ember-changeset 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 poteto / ember-changeset / addon / index.js View on Github external
cast(allowed /*: Array */ = []) /*: ChangesetDef */ {
      let changes /*: Changes */ = get(this, CHANGES);

      if (isArray(allowed) && allowed.length === 0) {
        return this;
      }

      let changeKeys /*: Array */ = keys(changes);
      let validKeys = emberArray(changeKeys).filter((key /*: string */) => includes(allowed, key));
      let casted = take(changes, validKeys);
      set(this, CHANGES, casted);
      return this;
    },