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

svelte-algolia

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-algolia - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

23

package.json
{
"name": "svelte-algolia",
"version": "0.1.6",
"version": "0.1.7",
"description": "Algolia plugin for Svelte",
"main": "src/index.js",
"module": "src/main.js",
"repository": "https://github.com/janosh/svelte-algolia",

@@ -14,15 +12,16 @@ "homepage": "https://github.com/janosh/svelte-algolia#readme",

"license": "MIT",
"type": "module",
"module": "src/main.js",
"dependencies": {
"algoliasearch": "^4.5.1",
"esm": "^3.2.25"
"algoliasearch": "^4.9.1"
},
"devDependencies": {
"ava": "^3.13.0",
"dotenv": "^8.2.0",
"eslint": "^7.12.1",
"prettier": "^2.1.2"
"ava": "^3.15.0",
"dotenv": "^8.5.0",
"eslint": "^7.25.0",
"prettier": "^2.2.1"
},
"scripts": {
"test": "ava --timeout=2m",
"prepublishOnly": "ava"
"test": "ava --node-arguments='--experimental-json-modules' --timeout=2m",
"prepublishOnly": "yarn test"
},

@@ -40,2 +39,2 @@ "files": [

}
}
}

@@ -7,3 +7,3 @@ <p align="center">

This package was inspired by the official [`gatsby-plugin-algolia`](https://github.com/algolia/gatsby-plugin-algolia).
This package was inspired by [`gatsby-plugin-algolia`](https://github.com/algolia/gatsby-plugin-algolia).

@@ -22,3 +22,3 @@ ## Usage

2. Create an `algoliaConfig`:
2. Create an `algoliaConfig` object:

@@ -38,3 +38,3 @@ ```js

The `getData` function is expected to return an array of objects containing the data you wish to index to Algolia (a product catalog, blog posts, documentation pages, pokémons or whatever). Each object in the data array should have a key named either `id` or `objectID` for Algolia to recognize it and overwrite existing data.
The `getData` function is expected to return an array of objects containing the data you wish to index (a product catalog, blog posts, documentation pages, pokémons or whatever). Each object in the data array should have a key named `id` or `objectID` for Algolia to recognize it and overwrite existing data where appropriate.

@@ -49,3 +49,3 @@ 3. Pass your config to `indexAlgolia`:

You can call this function whenever you like to update your indices. Typically, you would include in every production build of your app.
You can call this function wherever you'd like to update your indices. Typically, you would include this in every production build of your app.

@@ -65,4 +65,4 @@ ## Config Options

settings: {}, // an object of Algolia index settings that applies to all indices
// see https://algolia.com/doc/api-reference/settings-api-parameters
// can be overridden by a settings object passed as part of the indices array:
// see https://algolia.com/doc/api-reference/settings-api-parameters for available options
// can be overridden for individual indices by passing a settings object as part of the indices array:
// indices = [{ name: `pokedex`, ..., settings: { foo: `bar` }}],

@@ -104,2 +104,2 @@ }

PRs are welcome but best [open an issue](https://github.com/janosh/svelte-algolia/issues/new/choose) first to discuss any changes.
PRs are welcome but best [open an issue](https://github.com/janosh/svelte-algolia/issues/new/choose) first to discuss changes.

@@ -12,3 +12,3 @@ /* eslint-disable no-console */

export function deepEqual(x, y) {
return x && y && typeof x === 'object' && typeof x === typeof y
return x && y && typeof x === `object` && typeof x === typeof y
? Object.keys(x).length === Object.keys(y).length &&

@@ -86,13 +86,19 @@ Object.keys(x).every((key) => deepEqual(x[key], y[key]))

const { indexName: name } = index
const tmpIndex = client.initIndex(`${name}_tmp`)
try {
const tmpIndex = client.initIndex(`${name}_tmp`)
// copy settings from old to new index
const settings = await index.getSettings()
await tmpIndex.setSettings(settings)
// copy settings from old to new index
const settings = await index.getSettings()
await tmpIndex.setSettings(settings)
await tmpIndex.saveObjects(data).wait()
// move the tmp index to the existing index, overwrites the latter
await client.moveIndex(`${name}_tmp`, name).wait()
if (config.verbosity > 0)
console.log(`index '${name}': wrote ${data.length} items`)
await tmpIndex.saveObjects(data).wait()
// move the tmp index to the existing index, overwrites the latter
await client.moveIndex(`${name}_tmp`, name).wait()
if (config.verbosity > 0)
console.log(`index '${name}': wrote ${data.length} items`)
} catch (err) {
console.error(err)
// clean up by removing temporary index in case of errors
await client.moveIndex(`${name}_tmp`, name).wait()
}
}

@@ -156,6 +162,9 @@

if (!toIndex.length && !toRemove.length)
if (config.verbosity > 0)
if (config.verbosity > 0) {
if (toIndex.length === 0 && toRemove.length === 0) {
console.log(`index '${name}': no updates necessary; skipping!`)
else if (config.verbosity > 0) console.log(`index '${name}': done updating`)
} else {
console.log(`index '${name}': done updating`)
}
}
}

@@ -162,0 +171,0 @@

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