Utils 
This is an overview of all the utility functions bound to the shopware global object. Utility functions provide many useful shortcuts for common tasks, see how to use them in your plugin here. Or see the code that registers them here
General functions 
| Function | Description | Link | 
|---|---|---|
| createId | Returns a uuid string in hex format. Generated with uuid | link | 
| throttle | Creates a throttledfunction that only invokesfuncat most once per everywaitmilliseconds. | link | 
| debounce | Creates a debouncedfunction that delays invokingfuncuntil afterwaitmilliseconds have elapsed since the last time thedebouncedfunction was invoked. | link | 
| flow | Creates a function that returns the result of invoking the given functions with the thisbinding of the created function, where each successive invocation is supplied the return value of the previous. | link | 
| get | Gets the value at pathofobject | link | 
Object 
| Function | Description | Link | 
|---|---|---|
| deepCopyObject | Deep copy an object | |
| hasOwnProperty | Shorthand method for Object.prototype.hasOwnProperty | |
| getObjectDiff | Gets a simple recursive diff of two objects. Does not consider an entity schema or entity related logic. | |
| getArrayChanges | Check if the compared array has changes. | |
| cloneDeep | Creates recursively a clone of value. | link | 
| merge | This method is like _.assign except that it recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. | link | 
| mergeWith | This method is like _.merge except that it accepts customizer which is invoked to produce the merged values of the destination and source properties. | link | 
| deepMergeObject | Deep merge two objects | |
| get | Gets the value at pathofobject | link | 
| set | Sets the value at pathofobject | link | 
| pick | Creates an object composed of the picked objectproperties. | link | 
Debug 
| Function | Description | 
|---|---|
| warn | General logging function which provides a unified style of log messages for developers. Please keep the log in mind. Messages will be displayed in the developer console when they're running the application in development mode. | 
| debug | The same as warnbut instead ofconsole.warnit usesconsole.error. | 
Format 
| Function | Description | 
|---|---|
| currency | Converts a number to a formatted currency. Especially helpful for template filters. | 
| date | Formats a Date object to a localized string with the native Intl.DateTimeFormatmethod | 
| fileSize | Formats a number of bytes to a string with a unit | 
| md5 | Generates a md5 hash with md5-es of a given value. | 
Dom 
| Function | Description | 
|---|---|
| getScrollbarHeight | Returns the scrollbar height of an HTML element. | 
| getScrollbarWidth | Returns the scrollbar width of an HTML element. | 
| copyToClipboard | Uses the browser's copy function to copy a string | 
String 
| Function | Description | Link | 
|---|---|---|
| capitalizeString | Converts the first character of stringto upper case and the remaining to lower case. | link | 
| camelCase | Converts stringto camel case. | link | 
| kebabCase | Converts stringto kebab case. | link | 
| snakeCase | Converts stringto snake case. | link | 
| md5 | Generates a md5 hash with md5-es of a given value. | |
| isEmptyOrSpaces | Gets if the content of the string is really empty. This does also removes any whitespaces that might exist in the text. | |
| isUrl | Checks if the provided value is a URL | |
| isValidIp | Checks if the provided value is an IP with this Regex | 
Type 
| Function | Description | Link | 
|---|---|---|
| isObject | Checks if valueis the language type ofObject. (e.g. arrays, functions, objects, regexes,new Number(0), andnew String('')) | link | 
| isPlainObject | Checks if valueis a plain object, that is, an object created by theObjectconstructor or one with a[[Prototype]]ofnull. | link | 
| isEmpty | Checks if valueis an empty object, collection, map, or set. | link | 
| isRegExp | Checks if valueis classified as aRegExpobject. | link | 
| isArray | Checks if valueis classified as anArrayobject. | link | 
| isFunction | Checks if valueis classified as aFunctionobject. | link | 
| isDate | Checks if valueis classified as aDateobject. | link | 
| isString | Checks if valueis classified as aStringprimitive or object. | link | 
| isBoolean | Checks if value is classified as a booleanprimitive or object. | link | 
| isEqual | Performs a deep comparison between two values to determine if they are equivalent. | link | 
| isNumber | Checks if valueis classified as a Number primitive or object. | link | 
| isUndefined | Checks if valueisundefined. | link | 
FileReader 
| Function | Description | Link | 
|---|---|---|
| readAsArrayBuffer | Reads a fileas anArrayBuffer | link | 
| readAsDataURL | Reads a fileas aData-URL | link | 
| readAsText | Reads a fileastext | link | 
| getNameAndExtensionFromFile | Gets the nameandextensionfrom a file | |
| getNameAndExtensionFromUrl | Gets the nameandextensionfrom a URL | 
Sort 
| Function | Description | 
|---|---|
| afterSort | Sorts the elements by their after id property chain | 
Array 
| Function | Description | Link | 
|---|---|---|
| flattenDeep | Recursively flattens array. | link | 
| remove | Removes all elements from arraythat predicate returns truthy for and returns an array of the removed elements | link | 
| slice | Creates a slice of arrayfromstartup to, but not including,end. | link | 
| uniqBy | This method is like _.uniqexcept that it acceptsiterateewhich is invoked for each element inarrayto generate the criterion by which uniqueness is computed. | link |