Socket
Socket
Sign inDemoInstall

gosh

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gosh - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

45

CHANGELOG.md

@@ -10,9 +10,52 @@ # CHANGE LOG

----
## [In Git - targetting v2.1.0](https://github.com/mattwynne/gosh/compare/v2.0.0...master) (Not released)
## [In Git](https://github.com/mattwynne/gosh/compare/v1.0.0...master) (Not released)
### Added
* N/A
### Changed
* N/A
### Deprecated
* N/A
### Removed
* N/A
### Fixed
* N/A
## [v3.0.0](https://github.com/mattwynne/gosh/compare/v2.0.0...v3.0.0)
### Added
* Implicitly add a unique index on the ID field
### Changed
* Changed constructor on DocumentStore to take `makeId` function as a regular argument
### Deprecated
* N/A
### Removed
* N/A
### Fixed
* N/A
## [v2.0.0](https://github.com/mattwynne/gosh/compare/v1.0.0...v2.0.0) (Not released)
### Added
* N/A
### Changed

@@ -19,0 +62,0 @@

16

lib/document_store.js

@@ -9,10 +9,12 @@ 'use strict'

constructor(
{ indices, makeId, valueById } = {
makeId,
{ indices, valueById } = {
indices: null,
makeId: null,
valueById: null,
}
) {
if (!makeId) throw new Error('makeId is required')
this._indices = indices || []
if (typeof makeId !== 'function') throw new Error('makeId is required')
this._indices = indices || [
new MemoryUniqueIndex({ makeId, makeKey: makeId }),
]
this._makeId = makeId

@@ -65,3 +67,3 @@ this._valueById = valueById || new Map()

const indices = this._indices.concat([index])
return new DocumentStore({ indices, makeId, valueById })
return new DocumentStore(makeId, { indices, valueById })
}

@@ -77,3 +79,3 @@

const indices = this._indices.concat([index])
return new DocumentStore({ indices, makeId, valueById })
return new DocumentStore(makeId, { indices, valueById })
}

@@ -89,3 +91,3 @@

const indices = this._indices.concat([index])
return new DocumentStore({ indices, makeId, valueById })
return new DocumentStore(makeId, { indices, valueById })
}

@@ -92,0 +94,0 @@

{
"name": "gosh",
"version": "2.0.0",
"version": "3.0.0",
"description": "Great Object Storage Hooray!",

@@ -5,0 +5,0 @@ "main": "lib/gosh.js",

@@ -21,3 +21,3 @@ 'use strict'

const dave = { name: 'Dave', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -32,3 +32,3 @@ .put(dave)

const dave = { name: 'Dave', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -42,3 +42,3 @@ .put(dave)

const dave = { name: 'Dave', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -53,3 +53,3 @@ .put(dave)

const updatedDave = { name: 'David', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -64,3 +64,3 @@ .put(dave)

it('returns null for an invalid query', () => {
const store = new DocumentStore({ makeId }).withUniqueIndex(
const store = new DocumentStore(makeId).withUniqueIndex(
document => document.name

@@ -74,3 +74,3 @@ )

const sally = { name: 'Sally', uid: '4567' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -91,3 +91,3 @@ .withOptionalUniqueIndex(document => document.age)

const makeId = document => document.name
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withOneToManyIndex(document => document.hair)

@@ -105,3 +105,3 @@ .put(dave)

const makeId = document => document.name
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withOneToManyIndex(document => document.public.toString())

@@ -117,3 +117,3 @@ .put(dave)

const makeId = document => document.name
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withOneToManyIndex(document => document.hair)

@@ -129,3 +129,3 @@ .put(susan)

const makeId = document => document.name
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withOneToManyIndex(document => document.hair)

@@ -144,3 +144,3 @@ .put(dave)

const dave = { name: 'Dave', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -154,3 +154,3 @@ .put(dave)

const dave = { name: 'Dave', uid: '1234' }
const store = new DocumentStore({ makeId })
const store = new DocumentStore(makeId)
.withUniqueIndex(document => document.name)

@@ -167,5 +167,4 @@ .put(dave)

const indices = []
const store = new DocumentStore({
const store = new DocumentStore(makeId, {
indices,
makeId,
})

@@ -180,5 +179,4 @@ .put(dave)

const indices = []
const store = new DocumentStore({
const store = new DocumentStore(makeId, {
indices,
makeId,
})

@@ -185,0 +183,0 @@ .put(dave)

@@ -9,4 +9,3 @@ 'use strict'

const dave = { age: 22, uid: 'abcdef123' }
const makeId = document => document.uid
const store = new DocumentStore({ makeId })
const store = new DocumentStore(document => document.uid)
.withUniqueIndex(document => document.age.toString())

@@ -22,4 +21,3 @@ .put(dave)

const susan = { name: 'Susan', hair: 'grey' }
const makeId = document => document.name
const store = new DocumentStore({ makeId })
const store = new DocumentStore(document => document.name)
.withOneToManyIndex(document => document.hair)

@@ -32,2 +30,10 @@ .put(dave)

})
it('implicitly adds a unique index on the Id', () => {
const dave = { uid: 'abcdef123' }
const store = new DocumentStore(document => document.uid)
.put(dave)
const actual = store.get({ uid: 'abcdef123' })
assert.equal(actual, dave)
})
})
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