- You should have the
CMakeFiles.txt
and thesrc
folder to start.
The CMakeFiles.txt:
cmake_minimum_required(VERSION 3.4...3.18)
project(pimymath)
/* eslint @typescript-eslint/no-explicit-any: off -- need to have any here for the factory */ | |
namespace Factory { | |
const map_: Map<string, any> = new Map() | |
export const bind = (obj: any, name: string = '') => { | |
name.length === 0 ? map_.set(obj.name, obj) : map_.set(name, obj) | |
} |
// -------------------------------------------------------- | |
const create = (Type: any, params: any) => new Type(params) | |
// -------------------------------------------------------- | |
// Example | |
class A { | |
private a = 0 | |
private b = 0 |
const zip = arrays => { | |
return Array.apply(null, Array(arrays[0].length)).map( (_,i) => arrays.map( array => array[i] ) ) | |
} | |
// ----------- testing | |
const A = [1, 2, 3, 4] | |
const B = [5, 6, 7, 8] | |
const C = [9, 4, 3, 2] |
const forEach = (as, cb) => { | |
// necessary tests: | |
// - as is an array and all items in as are arrays | |
// - length of all arrays in as are the same | |
as[0].forEach( (serie, i) => cb( as.map( serie => serie[i] ), i, as) ) | |
} | |
// ---------------- testing | |
const A = [1, 2, 3, 4] |
A small multi-threaded C++ library (so, does not include any main) compiled with emscripten and pthread running under the main thread in the browser, a web worker or using node.js
.
Note: Emscripten will produce lib.js
.
Running this lib in the main thread is fine but, obviously, block the main thread. Running it using a web worker leads no error with modification of the worker script (see below)
Run fine except that it prevents Node app from ever exiting.
/** | |
* ------------------------------------------------------------ | |
* Show how convenient it is to use classes instead of a bunch | |
* of C functions. | |
* | |
* Part of the OOP course for PhD students and Researchers. | |
* | |
* Contact: [email protected] | |
* ------------------------------------------------------------ | |
*/ |