npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ancient-cursor

v0.2.10

Published

Abstract container of data synchronization.

Downloads

58

Readme

Ancient Cursor

Abstract container of data synchronization.

NPM Build Status Codacy Badge Read the Docs

Install

npm i --save ancient-cursor

About

In most popular realisations of pubsub next abstractions (query, content, transport, source, storage) are stirred or combined, what, for example, makes dependence from current environment or makes schemes for data required.

  • Query may be in any form.
  • No need for schemes in content. Use it as desired.
  • Cursor knows nothing about transport. It have events with data, which should be tracked, and something will make decisions about transporting. (we recommend ancient-channels and ancient-peer)
  • No dependency from source of data. It may be database-client or query-lang executor (like GraphQL). (we recommend ancient-asket)
  • Use any database as storage. (we recommend ancient-tracker)

Path

We use this term around all the package. It may be like this

  • _.get path syntax: 'a[1].c' or ['a', 1, 'c']
  • _.get + _.match syntax: ['a', { b:2 }, 'c'].

Bundle

"Box" for data-changings with functions and parsers to work with it.

Example

import {
  bundleParsers,
} from 'ancient-cursor/lib/bundle';

const container = { data: { a:[{ b:3, c:4 }] } };
bundleParsers.extend(container, {
  type: 'extend',
  path: 'a.0',
  value: { d: 6 },
});
container.data; // { a:[{ b:3, c:4, d:6 }] }

More bundles

Cursor

Simple capsule to actualize remote data. With cursor.exec() you can send query to remote data source. All changes apply using bundles as external stand-alone instructions what and where to change, when called cursor.apply () function. cursor.apply() emits 'changed' event, where you can use watch() to listen changes by specified path.

Example

import {
  Cursor,
  watch,
} from '../lib/cursor';

let changed = false;
let watched = false;
const cursor = new Cursor(); 

cursor.on('exec', ({ cursor }) => {
  // Here is transportation logic and after executing cursor.query by remote data-source may be called cursor.apply();
  cursor.apply({
    type: 'set',
    path: '',
    value: { a: [{ b: { c: 'd' } }] },
  });
});
cursor.exec('some query');

cursor.on('changed', ({ bundleChanges }) => {
  changed = true;
  watch(bundleChanges, 'b', () => {
    watched = true;
  });
});

cursor.data // { a: [{ b: { c: 'd' } }] }
cursor.apply({
  type: 'set',
  path: 'a.0',
  value: { d: { e: 'f' } },
});
cursor.data // { a: [{ d: { e: 'f' } }] }
triggered; // true;
watched; // false

cursor.apply({
  type: 'extend',
  path: '',
  value: { b: 123 },
});
cursor.data // { a: [{ d: { e: 'f' } }], b: 123 }
watched; // true

Stackable-cursor

Extends Cursor with queue funcionality.

Example

import {
  StackableCursor,
} from '../lib/stackable-cursor';

  const cursor = new StackableCursor();
  cursor.exec(undefined, { a: [{ b: { c: 123 } }] });

  cursor.apply({ indexInStack: 2, type: 'extend', path: 'a.0.b', value: {d: 234} });
  cursor.bundlesStack.length; // 1
  cursor.nextBundleIndex; // 0
  cursor.data; // { a: [{ b: { c: 123 } }] }

  cursor.apply({ indexInStack: 0, type: 'set', path: 'a.0.b.c', value: 456 });
  cursor.bundlesStack.length; // 1
  cursor.nextBundleIndex; // 1
  cursor.data; // { a: [{ b: { c: 456 } }] }

  cursor.apply({ indexInStack: 1, type: 'set', path: 'a.0.b.c', value: 345 });
  cursor.bundlesStack.length; // 0
  cursor.nextBundleIndex; // 3
  cursor.data; // { a: [{ b: { c: 345, d: 234 } }] }