nodejs and python helper symlinks

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-07-17 02:00:01 +00:00
parent fa5333e60f
commit 16ef5ecad1
6 changed files with 48 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env node
// https://cirosantilli.com/linux-kernel-module-cheat#node-js
const util = require('util');
class MyClassUtilInspectCustom {
constructor(a, b) {
this.a = a;
this.b = b;
}
[util.inspect.custom]() {
return `my type is MyClassUtilInspectCustom and a is ${this.a} and b is ${this.b}`;
}
}
let my_object = new MyClassUtilInspectCustom(1, 2);
console.log(util.inspect(my_object));
console.log(my_object);
console.log(my_object.toString());
class MyClassToString {
constructor(a, b) {
this.a = a;
this.b = b;
}
toString() {
return `my type is MyClassToString and a is ${this.a} and b is ${this.b}`;
}
}
my_object = new MyClassToString(1, 2);
console.log(util.inspect(my_object));
console.log(my_object);
console.log(my_object.toString());