How to use the @jupyterlab/statedb.StateDB.Connector function in @jupyterlab/statedb

To help you get started, we’ve selected a few @jupyterlab/statedb 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 jupyterlab / jupyterlab / tests / test-statedb / src / statedb.spec.ts View on Github external
it('should allow a merge data transformation', async () => {
      const connector = new StateDB.Connector();
      const k1 = 'foo';
      const v1 = 'bar';
      const k2 = 'baz';
      const v2 = 'qux';

      expect(await connector.fetch(k1)).to.be.undefined;
      expect(await connector.fetch(k2)).to.be.undefined;
      await connector.save(k1, `{ "v": "${v1}"}`);
      expect(JSON.parse(await connector.fetch(k1)).v).to.equal(v1);

      const transform = new PromiseDelegate();
      const db = new StateDB({ connector, transform: transform.promise });
      const transformation: StateDB.DataTransform = {
        type: 'merge',
        contents: { [k2]: v2 }
      };
github jupyterlab / jupyterlab / tests / test-statedb / src / statedb.spec.ts View on Github external
it('should empty the items in a state database', async () => {
      const connector = new StateDB.Connector();
      const db = new StateDB({ connector });

      expect((await connector.list()).ids).to.be.empty;
      await db.save('foo', 'bar');
      expect((await connector.list()).ids).not.to.be.empty;
      await db.clear();
      expect((await connector.list()).ids).to.be.empty;
    });
  });

@jupyterlab/statedb

Package for managing state in Jupyterlab

BSD-3-Clause
Latest version published 4 days ago

Package Health Score

92 / 100
Full package analysis