View index.mjs
'use strict';
// node --experimental-modules index.mjs
import fs from 'fs';
import util from 'util';
const readFile = util.promisify(fs.readFile);
const fnThen = (result) => {
View encoder-decoder.js
'use strict';
const {
TextEncoder,
TextDecoder
} = require('util');
let original = 'this is some data';
const encoder = new TextEncoder();
const uint8array = encoder.encode(original);
View index.js
'use strict';
const {
cbFunction,
cbFunctionPromisify
} = require('./modules/util');
const dataError = {error: true, message: 'I am an unicorn !!!'};
const dataResult = {error: false, message: 'I am an unicorn !!!'};
View inspect.js
'use strict';
const {
inspect
} = require('util');
console.log('inspect', inspect(callbackify, { showHidden: true, depth: null , colors: true }));//reusando funcion de ejemplo de callbackify
console.log('inspect Calc', inspect(Calc, { showHidden: true, depth: null, colors: true }));// reusando funcion de ejemplo de inherits
console.log('inspect Calc 2', inspect([Calc, true, 123, 'jesse', undefined, null], { showHidden: true, depth: null, colors: true }));
View index.js
'use strict';
const {
Calc
} = require('./modules/util');
const calc = new Calc();
console.log('calc', Calc);
View format.js
'use strict';
const {
format
} = require('util');
const strFormat = format('%s:%s', 'foo');//%s -> string
console.log('strFormat', strFormat);
const numberFormat = format('%d:%d', 5.2);
View deprecate.js
const {
deprecate
} = require('util');
const myCoolFn = deprecate((name) => {
return `${name} is very cool !!!`;
}, 'myCoolFn is deprecated !!! =(');
module.exports = {
myCoolFn
View debuglog.js
'use strict';
const {
debuglog
} = require('util');
const debuglogFnFoo = debuglog('foo');
const debuglogFnBar = debuglog('bar');
const debuglogFncbfy = debuglog('cbify');
// Multiple comma-separated section names may be specified in the NODE_DEBUG environment variable.
View callbackify.js
'use strict';
const {
callbackify
} = require('util');
const asyncFn = async function (text) {
if (text === true) {
return await Promise.reject(`parce, no me mande un true !!!`);
}
View onename
Verifying that "jessecogollo.id" is my Blockstack ID. https://onename.com/jessecogollo