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

algoliasearch-helper

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algoliasearch-helper - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

bower.json

5

package.json
{
"name": "algoliasearch-helper",
"version": "1.0.0",
"version": "1.1.0",
"description": "Helper for implementing advanced search features with algolia",

@@ -8,3 +8,3 @@ "main": "index.js",

"watch": "watchify index.js -v -s algoliasearchHelper -o dist/algoliasearch.helper.js",
"build": "browserify index.js -s algoliasearchHelper -o dist/algoliasearch.helper.js",
"build": "browserify index.js -s algoliasearchHelper -o dist/algoliasearch.helper.js && ccjs dist/algoliasearch.helper.js > dist/algoliasearch.helper.min.js",
"minify-build": "uglifyjs dist/algoliasearch.helper.js --mangle --compress=warnings=false > dist/algoliasearch.helper.min.js",

@@ -32,2 +32,3 @@ "dev": "DEBUG=zuul* zuul --no-coverage --local 8080 --ui tape test/run.js",

"bulkify": "1.1.1",
"closurecompiler": "1.5.1",
"eslint": "0.17.1",

@@ -34,0 +35,0 @@ "http-server": "0.8.0",

18

README.md

@@ -41,6 +41,20 @@ # algoliasearch-helper-js

## Examples in action
## How to use this module
http://algolia.github.io/algoliasearch-helper-js/
(See the examples in action)[http://algolia.github.io/algoliasearch-helper-js/]
### Use with NPM
`npm install algoliasearch-helper`
### Use with bower
`bower install algoliasearch-helper`
### Use the CDN
Include this in your page :
`<script src="//cdn.jsdelivr.net/algoliasearch.helper/1.0.0/algoliasearch.helper.min.js"></script>`
## How to contribute

@@ -47,0 +61,0 @@

"use strict";
var extend = require( "./functions/extend" );
/**
* Initialize a new AlgoliaSearchHelper
* @param {AlgoliaSearch} client an AlgoliaSearch client
* @param {string} index the index name to query
* @param {hash} options an associative array defining the hitsPerPage, list of facets and list of disjunctive facets
*/
function AlgoliaSearchHelper( client, index, options ) {
var defaults = {
// list of facets to compute
facets : [],
// list of disjunctive facets to compute
disjunctiveFacets : [],
// number of hits per page
hitsPerPage : 20,
// the default list of facetFilters
defaultFacetFilters : []
};
var defaults = AlgoliaSearchHelper.optionsDefaults;
var optionsWithDefaults = extend( {}, defaults, options );
this.init( client, index, extend( {}, defaults, options ) );
this.client = client;
this.index = index;
this.options = optionsWithDefaults;
this.page = 0;
this.refinements = {};
this.excludes = {};
this.disjunctiveRefinements = {};
this.extraQueries = [];
}
AlgoliaSearchHelper.optionsDefaults = {
// list of facets to compute
facets : [],
// list of disjunctive facets to compute
disjunctiveFacets : [],
// number of hits per page
hitsPerPage : 20,
// the default list of facetFilters
defaultFacetFilters : []
};
AlgoliaSearchHelper.prototype = {

@@ -23,19 +40,2 @@ constructor : AlgoliaSearchHelper,

/**
* Initialize a new AlgoliaSearchHelper
* @param {AlgoliaSearch} client an AlgoliaSearch client
* @param {string} index the index name to query
* @param {hash} options an associative array defining the hitsPerPage, list of facets and list of disjunctive facets
*/
init : function( client, index, options ) {
this.client = client;
this.index = index;
this.options = options;
this.page = 0;
this.refinements = {};
this.excludes = {};
this.disjunctiveRefinements = {};
this.extraQueries = [];
},
/**
* Perform a query

@@ -48,2 +48,9 @@ * @param {string} q the user query

search : function( q, searchCallback, searchParams ) {
// handle .search( q, searchParams, searchCallback )
if ( typeof searchParams === "function" ) {
var tmpCb = searchParams;
searchParams = searchCallback;
searchCallback = tmpCb;
}
this.q = q;

@@ -192,9 +199,4 @@ this.searchCallback = searchCallback;

var refinement = facet + ":" + value;
if ( this.refinements[refinement] ) {
return true;
}
if ( this.disjunctiveRefinements[facet] && this.disjunctiveRefinements[facet][value] ) {
return true;
}
return false;
return this.refinements[refinement] ||
(this.disjunctiveRefinements[facet] && this.disjunctiveRefinements[facet][value]);
},

@@ -210,6 +212,3 @@

var refinement = facet + ":-" + value;
if ( this.excludes[refinement] ) {
return true;
}
return false;
return !!this.excludes[refinement];
},

@@ -216,0 +215,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