Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alanshaw/pail

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alanshaw/pail - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

5

dist/src/crdt.d.ts

@@ -11,3 +11,3 @@ /**

* head: import('./clock').EventLink<EventData>[]
* event: import('./clock').EventBlockView<EventData>
* event?: import('./clock').EventBlockView<EventData>
* } & import('./index').ShardDiff} Result

@@ -75,5 +75,6 @@ */

head: import('./clock').EventLink<EventData>[];
event: import('./clock').EventBlockView<EventData>;
event?: import("multiformats").BlockView<Clock.EventView<EventData>, number, number, 1> | undefined;
} & Pail.ShardDiff;
import * as Pail from './index.js';
import * as Clock from './clock.js';
//# sourceMappingURL=crdt.d.ts.map

6

package.json
{
"name": "@alanshaw/pail",
"version": "0.3.3",
"version": "0.3.4",
"description": "DAG based key value store.",

@@ -101,7 +101,7 @@ "main": "src/index.js",

"cli-color": "^2.0.3",
"multiformats": "^11.0.1",
"multiformats": "^12.1.1",
"sade": "^1.8.1"
},
"devDependencies": {
"c8": "^7.12.0",
"c8": "^8.0.1",
"mocha": "^10.2.0",

@@ -108,0 +108,0 @@ "nanoid": "^4.0.0",

@@ -8,3 +8,3 @@ # pail

* 📖 [Read the SPEC](https://hackmd.io/@alanshaw/pail).
* 📖 [Read the SPEC](https://github.com/web3-storage/specs/blob/460b6511979a52ec9870f307695ee3f0b3860f81/kv.md).
* 🎬 [Watch the Presentation](https://youtu.be/f-BrtpYKZfg).

@@ -22,5 +22,6 @@

import { ShardBlock, put, get, del } from '@alanshaw/pail'
import { MemoryBlockstore } from '@alanshaw/pail/block'
// Initialize a new bucket
const blocks = new Blockstore() // like https://npm.im/blockstore-core
const blocks = new MemoryBlockstore()
const init = await ShardBlock.create() // empty root shard

@@ -42,8 +43,9 @@ await blocks.put(init.cid, init.bytes)

```
# Contributing
## Contributing
Feel free to join in. All welcome. [Open an issue](https://github.com/alanshaw/pail/issues)!
# License
## License
Dual-licensed under [MIT or Apache 2.0](https://github.com/alanshaw/pail/blob/main/LICENSE.md)

@@ -17,3 +17,3 @@ import * as Clock from './clock.js'

* head: import('./clock').EventLink<EventData>[]
* event: import('./clock').EventBlockView<EventData>
* event?: import('./clock').EventBlockView<EventData>
* } & import('./index').ShardDiff} Result

@@ -54,2 +54,3 @@ */

/** @type {EventFetcher<EventData>} */
const events = new EventFetcher(blocks)

@@ -87,2 +88,7 @@ const ancestor = await findCommonAncestor(events, head)

const result = await Pail.put(blocks, root, key, value, options)
// if we didn't change the pail we're done
if (result.root.toString() === root.toString()) {
return { root, additions: [], removals: [], head }
}
for (const a of result.additions) {

@@ -89,0 +95,0 @@ mblocks.putSync(a.cid, a.bytes)

@@ -99,2 +99,7 @@ import {

// if no change in the target then we're done
if (child.cid.toString() === target.cid.toString()) {
return { root, additions: [], removals: [] }
}
additions.push(child)

@@ -101,0 +106,0 @@

@@ -40,2 +40,5 @@ import { Block, encode, decode } from 'multiformats/block'

/** @type {WeakMap<Uint8Array, ShardBlockView>} */
const decodeCache = new WeakMap()
/**

@@ -48,3 +51,5 @@ * @param {Shard} value

const { cid, bytes } = await encode({ value, codec: cbor, hasher: sha256 })
return new ShardBlock({ cid, value, bytes, prefix: prefix ?? '' })
const block = new ShardBlock({ cid, value, bytes, prefix: prefix ?? '' })
decodeCache.set(block.bytes, block)
return block
}

@@ -58,2 +63,4 @@

export async function decodeShardBlock (bytes, prefix) {
const block = decodeCache.get(bytes)
if (block) return block
const { cid, value } = await decode({ bytes, codec: cbor, hasher: sha256 })

@@ -60,0 +67,0 @@ if (!Array.isArray(value)) throw new Error(`invalid shard: ${cid}`)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc