File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -2168,6 +2168,35 @@ H5P.trim = function (value) {
21682168 // So should we make this function deprecated?
21692169} ;
21702170
2171+ /**
2172+ * Recursive function that detects deep empty structures.
2173+ *
2174+ * @param {* } value
2175+ * @returns {bool }
2176+ */
2177+ H5P . isEmpty = value => {
2178+ if ( ! value && value !== 0 && value !== false ) {
2179+ return true ; // undefined, null, NaN and empty strings.
2180+ }
2181+ else if ( Array . isArray ( value ) ) {
2182+ for ( let i = 0 ; i < value . length ; i ++ ) {
2183+ if ( ! H5P . isEmpty ( value [ i ] ) ) {
2184+ return false ; // Array contains a non-empty value
2185+ }
2186+ }
2187+ return true ; // Empty array
2188+ }
2189+ else if ( typeof value === 'object' ) {
2190+ for ( let prop in value ) {
2191+ if ( value . hasOwnProperty ( prop ) && ! H5P . isEmpty ( value [ prop ] ) ) {
2192+ return false ; // Object contains a non-empty value
2193+ }
2194+ }
2195+ return true ; // Empty object
2196+ }
2197+ return false ;
2198+ } ;
2199+
21712200/**
21722201 * Check if JavaScript path/key is loaded.
21732202 *
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ import { CorePath } from '@singletons/path';
3131 */
3232export class CoreH5PCore {
3333
34+ static readonly API_VERSION = {
35+ majorVersion : 1 ,
36+ minorVersion : 26 ,
37+ } ;
38+
3439 static readonly STYLES = [
3540 'styles/h5p.css' ,
3641 'styles/h5p-confirmation-dialog.css' ,
You can’t perform that action at this time.
0 commit comments