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

@appbaseio/reactivecore

Package Overview
Dependencies
Maintainers
4
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appbaseio/reactivecore - npm Package Compare versions

Comparing version 9.12.2 to 9.12.3

2

lib/utils/suggestions.js

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

Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _diacritics=require('./diacritics');var _diacritics2=_interopRequireDefault(_diacritics);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}var flatten=function flatten(arr){return arr.reduce(function(flat,toFlatten){return flat.concat(Array.isArray(toFlatten)?flatten(toFlatten):toFlatten);},[]);};var extractSuggestion=function extractSuggestion(val){switch(typeof val){case'string':return val;case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};function replaceDiacritics(s){var str=s?String(s):'';for(var i=0;i<str.length;i++){var currentChar=str.charAt(i);if(_diacritics2.default[currentChar]){str=str.replaceAll(currentChar,_diacritics2.default[currentChar]);}}return str;}function escapeRegExp(){var string=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return string.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');}var getPredictiveSuggestions=function getPredictiveSuggestions(_ref){var suggestions=_ref.suggestions,currentValue=_ref.currentValue,wordsToShowAfterHighlight=_ref.wordsToShowAfterHighlight;var suggestionMap={};if(currentValue){var currentValueTrimmed=currentValue.trim();var parsedSuggestion=suggestions.reduce(function(agg,_ref2){var label=_ref2.label,rest=_objectWithoutProperties(_ref2,['label']);var parsedContent=new DOMParser().parseFromString(label,'text/html').documentElement.textContent;var regexString='^('+escapeRegExp(currentValueTrimmed)+')\\w+';var regex=new RegExp(regexString,'i');var regexExecution=regex.exec(parsedContent);if(!regexExecution){regexString='^('+escapeRegExp(currentValueTrimmed)+')';regex=new RegExp(regexString,'i');regexExecution=regex.exec(parsedContent);}if(regexExecution){var matchedString=parsedContent.slice(regexExecution.index,parsedContent.length);var highlightedWord=matchedString.slice(currentValueTrimmed.length).split(' ').slice(0,wordsToShowAfterHighlight+1).join(' ');var suggestionPhrase=currentValueTrimmed+'<mark class="highlight">'+highlightedWord+'</mark>';var suggestionValue=''+currentValueTrimmed+highlightedWord;if(!suggestionMap[suggestionPhrase]){suggestionMap[suggestionPhrase]=1;return[].concat(_toConsumableArray(agg),[_extends({},rest,{label:suggestionPhrase,value:suggestionValue,isPredictiveSuggestion:true})]);}return agg;}return agg;},[]);return parsedSuggestion;}return[];};var getSuggestions=function getSuggestions(_ref3){var fields=_ref3.fields,suggestions=_ref3.suggestions,currentValue=_ref3.currentValue,_ref3$suggestionPrope=_ref3.suggestionProperties,suggestionProperties=_ref3$suggestionPrope===undefined?[]:_ref3$suggestionPrope,_ref3$showDistinctSug=_ref3.showDistinctSuggestions,showDistinctSuggestions=_ref3$showDistinctSug===undefined?false:_ref3$showDistinctSug,_ref3$enablePredictiv=_ref3.enablePredictiveSuggestions,enablePredictiveSuggestions=_ref3$enablePredictiv===undefined?false:_ref3$enablePredictiv,_ref3$wordsToShowAfte=_ref3.wordsToShowAfterHighlight,wordsToShowAfterHighlight=_ref3$wordsToShowAfte===undefined?2:_ref3$wordsToShowAfte,enableSynonyms=_ref3.enableSynonyms;var suggestionsList=[];var labelsList=[];var skipWordMatch=false;var populateSuggestionsList=function populateSuggestionsList(val,parsedSource,source){var isWordMatch=skipWordMatch||currentValue.trim().split(' ').some(function(term){return replaceDiacritics(val).toLowerCase().includes(replaceDiacritics(term));});if(isWordMatch&&!labelsList.includes(val)||source._promoted){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(parsedSource.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,parsedSource[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);if(showDistinctSuggestions){return true;}}return false;};var parseField=function parseField(parsedSource){var field=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var source=arguments.length>2&&arguments[2]!==undefined?arguments[2]:parsedSource;if(typeof parsedSource==='object'){var fieldNodes=field.split('.');var label=parsedSource[fieldNodes[0]];if(parsedSource[field]){var topLabel=parsedSource[field];var val=extractSuggestion(topLabel);if(val&&typeof val==='string'){return populateSuggestionsList(val,parsedSource,source);}}if(Array.isArray(label)){if(label.length>1){label=label.filter(function(i){return i&&i.toString().toLowerCase().includes(currentValue.toString().toLowerCase());});}label=label[0];}if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);parseField(label,children,source);}else{var _val=extractSuggestion(label);if(_val){return populateSuggestionsList(_val,parsedSource,source);}}}}return false;};var traverseSuggestions=function traverseSuggestions(){if(showDistinctSuggestions){suggestions.forEach(function(item){fields.every(function(field){return parseField(item,field);});});}else{suggestions.forEach(function(item){fields.forEach(function(field){parseField(item,field);});});}};traverseSuggestions();if(suggestionsList.length<suggestions.length&&!skipWordMatch&&enableSynonyms){skipWordMatch=true;traverseSuggestions();}if(enablePredictiveSuggestions){var predictiveSuggestions=getPredictiveSuggestions({suggestions:suggestionsList,currentValue:currentValue,wordsToShowAfterHighlight:wordsToShowAfterHighlight});suggestionsList=predictiveSuggestions;}return suggestionsList;};exports.default=getSuggestions;
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _diacritics=require('./diacritics');var _diacritics2=_interopRequireDefault(_diacritics);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}var flatten=function flatten(arr){return arr.reduce(function(flat,toFlatten){return flat.concat(Array.isArray(toFlatten)?flatten(toFlatten):toFlatten);},[]);};var extractSuggestion=function extractSuggestion(val){switch(typeof val){case'string':return val;case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};function replaceDiacritics(s){var str=s?String(s):'';for(var i=0;i<str.length;i++){var currentChar=str.charAt(i);if(_diacritics2.default[currentChar]){str=str.replaceAll(currentChar,_diacritics2.default[currentChar]);}}return str;}function escapeRegExp(){var string=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return string.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');}var getPredictiveSuggestions=function getPredictiveSuggestions(_ref){var suggestions=_ref.suggestions,currentValue=_ref.currentValue,wordsToShowAfterHighlight=_ref.wordsToShowAfterHighlight;var suggestionMap={};if(currentValue){var currentValueTrimmed=currentValue.trim();var parsedSuggestion=suggestions.reduce(function(agg,_ref2){var label=_ref2.label,rest=_objectWithoutProperties(_ref2,['label']);var parsedContent=new DOMParser().parseFromString(label,'text/html').documentElement.textContent;var regexString='^('+escapeRegExp(currentValueTrimmed)+')\\w+';var regex=new RegExp(regexString,'i');var regexExecution=regex.exec(parsedContent);if(!regexExecution){regexString='^('+escapeRegExp(currentValueTrimmed)+')';regex=new RegExp(regexString,'i');regexExecution=regex.exec(parsedContent);}if(regexExecution){var matchedString=parsedContent.slice(regexExecution.index,parsedContent.length);var highlightedWord=matchedString.slice(currentValueTrimmed.length).split(' ').slice(0,wordsToShowAfterHighlight+1).join(' ');var suggestionPhrase=currentValueTrimmed+'<mark class="highlight">'+highlightedWord+'</mark>';var suggestionValue=''+currentValueTrimmed+highlightedWord;if(!suggestionMap[suggestionPhrase]){suggestionMap[suggestionPhrase]=1;return[].concat(_toConsumableArray(agg),[_extends({},rest,{label:suggestionPhrase,value:suggestionValue,isPredictiveSuggestion:true})]);}return agg;}return agg;},[]);return parsedSuggestion;}return[];};var getSuggestions=function getSuggestions(_ref3){var fields=_ref3.fields,suggestions=_ref3.suggestions,currentValue=_ref3.currentValue,_ref3$suggestionPrope=_ref3.suggestionProperties,suggestionProperties=_ref3$suggestionPrope===undefined?[]:_ref3$suggestionPrope,_ref3$showDistinctSug=_ref3.showDistinctSuggestions,showDistinctSuggestions=_ref3$showDistinctSug===undefined?false:_ref3$showDistinctSug,_ref3$enablePredictiv=_ref3.enablePredictiveSuggestions,enablePredictiveSuggestions=_ref3$enablePredictiv===undefined?false:_ref3$enablePredictiv,_ref3$wordsToShowAfte=_ref3.wordsToShowAfterHighlight,wordsToShowAfterHighlight=_ref3$wordsToShowAfte===undefined?2:_ref3$wordsToShowAfte,enableSynonyms=_ref3.enableSynonyms;var suggestionsList=[];var labelsList=[];var skipWordMatch=false;var populateSuggestionsList=function populateSuggestionsList(val,parsedSource,source){var isWordMatch=skipWordMatch||currentValue.trim().split(' ').some(function(term){return replaceDiacritics(val).toLowerCase().includes(replaceDiacritics(term));});if(isWordMatch&&!labelsList.includes(val)||source._promoted){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(parsedSource.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,parsedSource[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);if(showDistinctSuggestions){return true;}}return false;};var parseField=function parseField(parsedSource){var field=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var source=arguments.length>2&&arguments[2]!==undefined?arguments[2]:parsedSource;if(typeof parsedSource==='object'){var fieldNodes=field.split('.');var label=parsedSource[fieldNodes[0]];if(parsedSource[field]){var topLabel=parsedSource[field];var val=extractSuggestion(topLabel);if(val&&typeof val==='string'){return populateSuggestionsList(val,parsedSource,source);}}if(Array.isArray(label)){if(label.length>1){label=label.filter(function(i){return i&&i.toString().toLowerCase().includes(currentValue.toString().toLowerCase());});}label=label[0];}if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);parseField(label,children,source);}else{var _val=extractSuggestion(label);if(_val){return populateSuggestionsList(_val,parsedSource,source);}}}}return false;};var traverseSuggestions=function traverseSuggestions(){suggestions.forEach(function(item){fields.forEach(function(field){parseField(item,field);});});};traverseSuggestions();if(suggestionsList.length<suggestions.length&&!skipWordMatch&&enableSynonyms){skipWordMatch=true;traverseSuggestions();}if(enablePredictiveSuggestions){var predictiveSuggestions=getPredictiveSuggestions({suggestions:suggestionsList,currentValue:currentValue,wordsToShowAfterHighlight:wordsToShowAfterHighlight});suggestionsList=predictiveSuggestions;}if(showDistinctSuggestions){var idMap={};var filteredSuggestions=[];suggestionsList.forEach(function(suggestion){if(suggestion.source&&suggestion.source._id){if(!idMap[suggestion.source._id]){filteredSuggestions.push(suggestion);idMap[suggestion.source._id]=true;}}});return filteredSuggestions;}return suggestionsList;};exports.default=getSuggestions;
{
"name": "@appbaseio/reactivecore",
"version": "9.12.2",
"version": "9.12.3",
"description": "Core architecture of reactive UI libraries",

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

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