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

@algolia/recommend-core

Package Overview
Dependencies
Maintainers
64
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/recommend-core - npm Package Compare versions

Comparing version 1.0.0-experimental.3 to 1.0.0-experimental.4

2

dist/umd/index.js

@@ -1,3 +0,3 @@

/*! @algolia/recommend-core 1.0.0-experimental.3 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/ui-components */
/*! @algolia/recommend-core 1.0.0-experimental.4 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/ui-components */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-core"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){var t=e.fallbackFilters,r=e.recommendations,o=e.threshold;if(0===r.length)return t;var c=r.filter((function(e){return e.score>o})).map((function(e){var t=e.objectID,r=e.score;return"objectID:".concat(t,"<score=").concat(100*r,">")}));return[].concat(n(c),n(t))}function c(e){return function(t){switch(t){case"bought-together":return c=(n=e).fallbackFilters,a=n.recommendations,i=n.threshold,0===c.length?{facetFilters:[a.filter((function(e){return e.score>i})).map((function(e){return"objectID:".concat(e.objectID)}))]}:{optionalFilters:o({fallbackFilters:c,recommendations:a,threshold:i})};case"related-products":return{optionalFilters:o({fallbackFilters:(r=e).fallbackFilters,recommendations:r.recommendations,threshold:r.threshold})};default:throw new Error("Unknown model: ".concat(JSON.stringify(t),"."))}var r,n,c,a,i}}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?a(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e){var t=function(e){return i(i({fallbackFilters:[],maxRecommendations:0,threshold:0,transformItems:function(e){return e}},e),{},{searchParameters:i({analytics:!1,analyticsTags:["alg-recommend_".concat(e.model)],clickAnalytics:!1,enableABTest:!1,filters:e.objectIDs.map((function(e){return"NOT objectID:".concat(e)})).join(" AND "),ruleContexts:e.objectIDs.map((function(t){return"alg-recommend_".concat(e.model,"_").concat(t)})),typoTolerance:!1},e.searchParameters)})}(e);return t.searchClient.addAlgoliaAgent("recommend-core","1.0.0-experimental.2"),t.searchClient.initIndex(function(e,t){switch(e){case"bought-together":return"ai_recommend_bought-together_".concat(t);case"related-products":return"ai_recommend_related-products_".concat(t);default:throw new Error("Unknown model: ".concat(JSON.stringify(e),"."))}}(t.model,t.indexName)).getObjects(t.objectIDs).then((function(e){var r=e.results.map((function(e){var t;return null!==(t=null==e?void 0:e.recommendations)&&void 0!==t?t:[]}));return t.searchClient.search(r.map((function(e){var r,n,o,a,l,s=(r={fallbackFilters:t.fallbackFilters,maxRecommendations:t.maxRecommendations,recommendationsCount:e.length},n=r.fallbackFilters,o=r.maxRecommendations,a=r.recommendationsCount,l=n.length>0,0===a?l?o:0:l?o:o>0?Math.min(a,o):a),u=s>0?Math.ceil(s/t.objectIDs.length):s,f=c({fallbackFilters:t.fallbackFilters,recommendations:e,threshold:t.threshold})(t.model);return{indexName:t.indexName,params:i(i(i({hitsPerPage:u},f),t.searchParameters),{},{facetFilters:(f.facetFilters||[]).concat(t.searchParameters.facetFilters||[]),optionalFilters:(f.optionalFilters||[]).concat(t.searchParameters.optionalFilters||[])})}}))).then((function(e){var o,c,a=function(e,t){var r=n(t);return r.sort(e),r}((function(e,t){return(e.__recommendScore||0)<(t.__recommendScore||0)?1:-1}),(o="objectID",c=e.results.flatMap((function(e){return e.hits.map((function(n,o){var c,a=r.flat().find((function(e){return e.objectID===n.objectID}));return i(i({},n),{},{__indexName:t.indexName,__queryID:e.queryID,__position:o+1,__recommendScore:null!==(c=null==a?void 0:a.score)&&void 0!==c?c:null})}))})),n(new Map(c.map((function(e){return[e[o],e]}))).values()))).slice(0,t.maxRecommendations>0?t.maxRecommendations:void 0);return{recommendations:t.transformItems(a)}}))})).catch((function(){return{recommendations:[]}}))}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?s(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?f(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}e.getFrequentlyBoughtTogether=function(e){return l(u(u({},e),{},{fallbackFilters:[],model:"bought-together"}))},e.getRecommendations=l,e.getRelatedProducts=function(e){return l(m(m({},e),{},{model:"related-products"}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@algolia/recommend-core",
"version": "1.0.0-experimental.3",
"version": "1.0.0-experimental.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/algolia/ui-components",

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