Update std.js

This commit is contained in:
Namhyeon Go 2022-04-29 16:11:49 +09:00 committed by GitHub
parent ea41064aed
commit ef7f6fb0e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -251,6 +251,20 @@ function addslashes(s) {
; ;
}; };
function cartesian(arr) {
return arr.reduce(function(a, b) {
return a.map(function(x) {
return b.map(function(y) {
return x.concat([y]);
})
}).reduce(function(a, b) {
return a.concat(b);
}, []);
}, [
[]
]);
};
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Private APIs / Utility functions // Private APIs / Utility functions
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -371,4 +385,6 @@ exports.require = global.require;
exports.Event = StdEvent; exports.Event = StdEvent;
exports.EventableObject = StdEventableObject; exports.EventableObject = StdEventableObject;
exports.alert = alert; exports.alert = alert;
exports.cartesian = cartesian;