mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
nodejs and python helper symlinks
This commit is contained in:
36
rootfs_overlay/lkmc/nodejs/object_to_string.js
Executable file
36
rootfs_overlay/lkmc/nodejs/object_to_string.js
Executable 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());
|
||||
Reference in New Issue
Block a user