Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
ancient-cursor
Advanced tools
Abstract container of data synchronization.
npm i --save ancient-cursor
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.content
. Use it as desired.transport
. It have events with data, which should be tracked, and something will make decisions about transporting. (we recommend ancient-channels and ancient-peer)source
of data. It may be database-client or query-lang executor (like GraphQL). (we recommend ancient-asket)storage
. (we recommend ancient-tracker)We use this term around all the package. It may be like this
'a[1].c'
or ['a', 1, 'c']
['a', { b:2 }, 'c']
."Box" for data-changings with functions and parsers to work with it.
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 }] }
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.
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
Extends Cursor
with queue funcionality.
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 } }] }
FAQs
Abstract container of data synchronization.
The npm package ancient-cursor receives a total of 3 weekly downloads. As such, ancient-cursor popularity was classified as not popular.
We found that ancient-cursor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.