@appbaseio/reactivecore
Advanced tools
Comparing version 4.2.0 to 4.3.0
@@ -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;};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 _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;}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.toLowerCase();case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};var getSuggestions=function getSuggestions(fields,suggestions,currentValue){var suggestionProperties=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];var suggestionsList=[];var labelsList=[];var populateSuggestionsList=function populateSuggestionsList(val,source){var isWordMatch=currentValue.trim().split(' ').some(function(term){return String(val).includes(term);});if(isWordMatch&&!labelsList.includes(val)){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(source.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,source[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);}};var parseField=function parseField(source,field){if(typeof source==='object'){var fieldNodes=field.split('.');var label=source[fieldNodes[0]];if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);if(Array.isArray(label)){label.forEach(function(arrayItem){parseField(arrayItem,children);});}else{parseField(label,children);}}else{var val=extractSuggestion(label);if(val){if(Array.isArray(val)){val.forEach(function(suggestion){return populateSuggestionsList(suggestion,source);});}else{populateSuggestionsList(val,source);}}}}}};suggestions.forEach(function(item){fields.forEach(function(field){parseField(item._source,field);});});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;};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 _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;}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.toLowerCase();case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};var getSuggestions=function getSuggestions(fields,suggestions,currentValue){var suggestionProperties=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];var suggestionsList=[];var labelsList=[];var populateSuggestionsList=function populateSuggestionsList(val,source){var isWordMatch=currentValue.trim().split(' ').some(function(term){return String(val).toLowerCase().includes(term);});if(isWordMatch&&!labelsList.includes(val)){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(source.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,source[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);}};var parseField=function parseField(source,field){if(typeof source==='object'){var fieldNodes=field.split('.');var label=source[fieldNodes[0]];if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);if(Array.isArray(label)){label.forEach(function(arrayItem){parseField(arrayItem,children);});}else{parseField(label,children);}}else{var val=extractSuggestion(label);if(val){if(Array.isArray(val)){val.forEach(function(suggestion){return populateSuggestionsList(suggestion,source);});}else{populateSuggestionsList(val,source);}}}}}};suggestions.forEach(function(item){fields.forEach(function(field){parseField(item._source,field);});});return suggestionsList;};exports.default=getSuggestions; |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
29
69102
38