Skip to content

Commit

Permalink
Merge pull request #86 from QuickCorp/v2.3
Browse files Browse the repository at this point in the history
V2.3
  • Loading branch information
jeanmachuca committed Aug 18, 2021
2 parents 0cbe876 + ef0ed9c commit 9cc3656
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion QCObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"matrix3d",
"unique",
"uniqueId",
"shortCode"
"shortCode",
"NamespaceRef"
];
var _ret_;
if (_protected_symbols.includes(this.name)) {
Expand Down Expand Up @@ -438,6 +439,21 @@
};
var ComplexStorageCache = function(params) {
var object, load, alternate;
if (typeof localStorage === "undefined"){
/* Polyfill for localStorage */
var localStorage = {
getItem (name) {
return (Object.hasOwnProperty.call(this, name))?(this[name]):(null);
},
setItem (name, value) {
this[name] = value;
},
removeItem (name) {
delete this[name];
}
};
/* end Polyfill for localStorage */
}
object = params.index;
load = params.load;
alternate = params.alternate;
Expand Down Expand Up @@ -1286,6 +1302,18 @@
return "Package(namespace, classes) { [QCObjects native code] }";
};

/**
* Declare Namespace
*
* @param {String} packageName
* @param {Object} package
*/
var NamespaceRef = function (namespace){
let package = Package(namespace);
let classes = package.filter(c=>isQCObjects_Class(c)).map(c=>{return {[c.__definition.__classType]:c}}).reduce ((a, b)=> Object.assign(a, b));
return namespace.split(".").map(c=>{return {[c]:classes}}).reverse().reduce ( (a, b) => {b[Object.keys(b)]=a;return b;} );
};


/**
* Imports a script with the package nomenclature
Expand Down Expand Up @@ -2854,6 +2882,7 @@
Export(_DataStringify);
Export(isQCObjects_Class);
Export(isQCObjects_Object);
Export(NamespaceRef);

asyncLoad(function() {

Expand Down

0 comments on commit 9cc3656

Please sign in to comment.