New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

snap-shot-core

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snap-shot-core - npm Package Compare versions

Comparing version

to
9.0.0

4

package.json
{
"name": "snap-shot-core",
"description": "Save / load named snapshots, useful for tests",
"version": "8.1.0",
"version": "9.0.0",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",

@@ -105,3 +105,3 @@ "bugs": "https://github.com/bahmutov/snap-shot-core/issues",

"pre-git": "3.17.1",
"semantic-release": "15.13.3",
"semantic-release": "15.13.12",
"shelljs": "0.8.3",

@@ -108,0 +108,0 @@ "simple-commit-message": "4.0.3",

@@ -48,2 +48,9 @@ 'use strict'

/**
* Returns the name of the snapshot when it is saved.
* Could be either an exact string or a combination of the spec name and index
*/
const savedSnapshotName = ({ exactSpecName, specName, index }) =>
exactSpecName || formKey(specName, index)
function restore (options) {

@@ -100,3 +107,3 @@ if (!options) {

const key = exactSpecName || formKey(specName, index)
const key = savedSnapshotName({ exactSpecName, specName, index })
debug('key "%s"', key)

@@ -110,2 +117,6 @@ if (!(key in snapshots)) {

/**
* Stores new snapshot value if possible.
* Returns the key for the value
*/
function storeValue (options) {

@@ -153,3 +164,3 @@ const file = options.file

)
const key = exactSpecName || formKey(specName, index)
const key = savedSnapshotName({ exactSpecName, specName, index })
snapshots[key] = value

@@ -179,2 +190,4 @@

}
return key
}

@@ -191,3 +204,3 @@

}) {
const key = exactSpecName || formKey(specName, index)
const key = savedSnapshotName({ exactSpecName, specName, index })
throw new Error(

@@ -209,2 +222,6 @@ 'Cannot store new snapshot value\n' +

/**
* Returns object with "value" property (stored value)
* and "key" (formed snapshot name).
*/
function core (options) {

@@ -264,3 +281,3 @@ la(is.object(options), 'missing options argument', options)

}
debug(`file "${fileParameter} spec "${specName}`)
debug(`file "${fileParameter}" spec "${specName}"`)

@@ -290,2 +307,15 @@ const setOrCheckValue = any => {

const value = strip(any)
const key = savedSnapshotName({ exactSpecName, specName, index })
la(
is.unemptyString(key),
'expected snapshot key to be a string',
key,
'exact spec name',
exactSpecName,
'spec name',
specName,
'index',
index
)
const expected = findStoredValue({

@@ -323,3 +353,7 @@ file: fileParameter,

})
return storedValue
return {
value: storedValue,
key
}
}

@@ -335,3 +369,6 @@

})
return expected
return {
value: expected,
key
}
}

@@ -358,3 +395,5 @@

prune,
throwCannotSaveOnCI
throwCannotSaveOnCI,
savedSnapshotName,
storeValue
}