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

ahau-fixtures

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahau-fixtures - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

77

lib/create-whakapapa-tree.js

@@ -12,13 +12,42 @@ const pull = require('pull-stream')

const queue = Pushable()
const authors = { add: ['*'] }
const createPerson = (cb) => {
// start
console.time('create-whakapapa-tree')
// make initial profile
createPerson((err, profileId) => {
if (err) return cb(err)
queue.push(profileId)
// create a view which points to that profile (focus)
ssb.whakapapa.view.create(
{
name: 'bulk-' + N,
focus: profileId,
authors,
recps: [groupId]
},
(err, viewId) => {
if (err) return cb(err)
// build a whakapapa below that profile
createTree((err) => err ? cb(err) : cb(null, viewId))
}
)
})
//
function createPerson (cb) {
ssb.profile.person.group.create(
{ preferredName: String(++profileCount), authors, recps: [groupId] },
{
preferredName: String(++profileCount),
authors,
recps: [groupId]
},
cb
)
}
const createChild = (parentId, cb) => {
function createChild (parentId, cb) {
if (profileCount >= N) return cb(null)

@@ -28,2 +57,3 @@

if (err) return cb(err)
process.stdout.write('.')

@@ -33,4 +63,10 @@ queue.push(childId)

ssb.whakapapa.child.create(
{ parent: parentId, child: childId },
{ relationshipType: 'birth', recps: [groupId] },
{
parent: parentId,
child: childId
},
{
relationshipType: 'birth',
recps: [groupId]
},
cb

@@ -41,17 +77,3 @@ )

// start
console.time('create-whakapapa-tree')
createPerson((err, profileId) => {
if (err) throw err
queue.push(profileId)
ssb.whakapapa.view.create({ name: 'bulk-' + N, focus: profileId, authors, recps: [groupId] }, (err, viewId) => {
if (err) throw err
createTree(viewId)
})
})
function createTree (viewId) {
function createTree (cb) {
pull(

@@ -61,17 +83,16 @@ queue,

let numberOfChildren = Math.floor(Math.random() * 7)
if (queue.length === 0 && numberOfChildren === 0) numberOfChildren++
if (queue.buffer.length === 0 && numberOfChildren === 0) numberOfChildren++
return new Array(numberOfChildren).fill(parentId)
}),
paraMap(createChild, 4),
paraMap(createChild, 3),
pull.take(N - 1),
pull.collect((err) => {
if (err) throw err
if (err) return cb(err)
console.log('DONE')
console.timeEnd('create-whakapapa-tree')
console.log('profileCount', profileCount)
console.log('profiles:', profileCount)
cb(null, viewId)
cb(null)
})

@@ -78,0 +99,0 @@ )

{
"name": "ahau-fixtures",
"version": "1.0.1",
"version": "1.0.2",
"description": "a generator of mock ahau databases",

@@ -5,0 +5,0 @@ "main": "index.js",

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