How to use createStream method in wpt

Best JavaScript code snippet using wpt

test.factory.js

Source:test.factory.js Github

copy

Full Screen

...71 t.end();72 function badValue( value ) {73 return function badValue() {74 var createStream = factory();75 createStream( value, 10, 5 );76 };77 }78});79tape( 'the function throws an error if provided a population size which is not a nonnegative integer (parameters)', function test( t ) {80 var values;81 var i;82 values = [83 -1.0,84 -0.5,85 0.5,86 NaN,87 '5',88 null,89 true,90 false,91 void 0,92 [],93 {},94 function noop() {}95 ];96 for ( i = 0; i < values.length; i++ ) {97 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );98 }99 t.end();100 function badValue( value ) {101 return function badValue() {102 var createStream = factory( value, 10, 5 );103 createStream();104 };105 }106});107tape( 'the function throws an error if provided a sub-population size which is not a nonnegative integer', function test( t ) {108 var values;109 var i;110 values = [111 -1.0,112 -0.5,113 0.5,114 NaN,115 '5',116 null,117 true,118 false,119 void 0,120 [],121 {},122 function noop() {}123 ];124 for ( i = 0; i < values.length; i++ ) {125 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );126 }127 t.end();128 function badValue( value ) {129 return function badValue() {130 var createStream = factory();131 createStream( 20, value, 5 );132 };133 }134});135tape( 'the function throws an error if provided a sub-population size which is not a nonnegative integer (parameters)', function test( t ) {136 var values;137 var i;138 values = [139 -1.0,140 -0.5,141 0.5,142 NaN,143 '5',144 null,145 true,146 false,147 void 0,148 [],149 {},150 function noop() {}151 ];152 for ( i = 0; i < values.length; i++ ) {153 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );154 }155 t.end();156 function badValue( value ) {157 return function badValue() {158 var createStream = factory( 20, value, 5 );159 createStream();160 };161 }162});163tape( 'the function throws an error if the number of draws is not a nonnegative integer', function test( t ) {164 var values;165 var i;166 values = [167 -1.0,168 -0.5,169 0.5,170 NaN,171 '5',172 null,173 true,174 false,175 void 0,176 [],177 {},178 function noop() {}179 ];180 for ( i = 0; i < values.length; i++ ) {181 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );182 }183 t.end();184 function badValue( value ) {185 return function badValue() {186 var createStream = factory();187 createStream( 20, 10, value );188 };189 }190});191tape( 'the function throws an error if the number of draws is not a nonnegative integer (parameters)', function test( t ) {192 var values;193 var i;194 values = [195 -1.0,196 -0.5,197 0.5,198 NaN,199 '5',200 null,201 true,202 false,203 void 0,204 [],205 {},206 function noop() {}207 ];208 for ( i = 0; i < values.length; i++ ) {209 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );210 }211 t.end();212 function badValue( value ) {213 return function badValue() {214 var createStream = factory( 20, 10, value );215 createStream();216 };217 }218});219tape( 'the function throws an error if the number of draws exceeds the total population size', function test( t ) {220 var values;221 var i;222 values = [223 [ 2, 3, 6 ],224 [ 3, 1, 5 ],225 [ 10, 10, 21 ]226 ];227 for ( i = 0; i < values.length; i++ ) {228 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );229 }230 t.end();231 function badValue( arr ) {232 return function badValue() {233 var createStream = factory();234 createStream( arr[0], arr[1], arr[2] );235 };236 }237});238tape( 'the function throws an error if the number of draws exceeds the total population size (parameters)', function test( t ) {239 var values;240 var i;241 values = [242 [ 2, 3, 6 ],243 [ 3, 1, 5 ],244 [ 10, 10, 21 ]245 ];246 for ( i = 0; i < values.length; i++ ) {247 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );248 }249 t.end();250 function badValue( arr ) {251 return function badValue() {252 var createStream = factory( arr[0], arr[1], arr[2] );253 createStream();254 };255 }256});257tape( 'the function throws an error if the subpopulation size exceeds the total population size', function test( t ) {258 var values;259 var i;260 values = [261 [ 9, 12, 6 ],262 [ 3, 9, 5 ],263 [ 40, 50, 21 ]264 ];265 for ( i = 0; i < values.length; i++ ) {266 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );267 }268 t.end();269 function badValue( arr ) {270 return function badValue() {271 var createStream = factory();272 createStream( arr[0], arr[1], arr[2] );273 };274 }275});276tape( 'the function throws an error if the subpopulation size exceeds the total population size (parameters)', function test( t ) {277 var values;278 var i;279 values = [280 [ 9, 12, 6 ],281 [ 3, 9, 5 ],282 [ 40, 50, 21 ]283 ];284 for ( i = 0; i < values.length; i++ ) {285 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );286 }287 t.end();288 function badValue( arr ) {289 return function badValue() {290 var createStream = factory( arr[0], arr[1], arr[2] );291 createStream();292 };293 }294});295tape( 'the function returns a function which throws an error if provided an options argument which is not an object', function test( t ) {296 var values;297 var i;298 values = [299 '5',300 5,301 true,302 false,303 void 0,304 null,305 NaN,306 function noop() {},307 []308 ];309 for ( i = 0; i < values.length; i++ ) {310 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );311 }312 t.end();313 function badValue( value ) {314 return function badValue() {315 var createStream = factory( value );316 createStream( 20, 10, 7 );317 };318 }319});320tape( 'the function returns a function which throws an error if provided an options argument which is not an object (parameters)', function test( t ) {321 var values;322 var i;323 values = [324 '5',325 5,326 NaN,327 true,328 false,329 void 0,330 null,331 [],332 function noop() {}333 ];334 for ( i = 0; i < values.length; i++ ) {335 t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] );336 }337 t.end();338 function badValue( value ) {339 return function badValue() {340 var createStream = factory( 20, 10, 7, value );341 createStream();342 };343 }344});345tape( 'the function returns a function which throws an error if provided an invalid `iter` option', function test( t ) {346 var values;347 var i;348 values = [349 'abc',350 -5,351 3.14,352 null,353 true,354 false,355 void 0,356 NaN,357 [],358 {},359 function noop() {}360 ];361 for ( i = 0; i < values.length; i++ ) {362 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );363 }364 t.end();365 function badValue( value ) {366 return function badValue() {367 var createStream = factory({368 'iter': value369 });370 createStream( 20, 10, 7 );371 };372 }373});374tape( 'the function returns a function which throws an error if provided an invalid `iter` option (parameters)', function test( t ) {375 var values;376 var i;377 values = [378 'abc',379 -5,380 3.14,381 null,382 true,383 false,384 void 0,385 NaN,386 [],387 {},388 function noop() {}389 ];390 for ( i = 0; i < values.length; i++ ) {391 t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );392 }393 t.end();394 function badValue( value ) {395 return function badValue() {396 var createStream = factory( 20, 10, 7, {397 'iter': value398 });399 createStream();400 };401 }402});403tape( 'if provided a `prng` option which is not a function, the function returns a function which throws an error', function test( t ) {404 var values;405 var i;406 values = [407 '5',408 3.14,409 NaN,410 true,411 false,412 null,413 void 0,414 [],415 {}416 ];417 for ( i = 0; i < values.length; i++ ) {418 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );419 }420 t.end();421 function badValue( value ) {422 return function badValue() {423 var createStream = factory({424 'prng': value425 });426 createStream( 20, 10, 7 );427 };428 }429});430tape( 'if provided a `prng` option which is not a function, the function returns a function which throws an error (parameters)', function test( t ) {431 var values;432 var i;433 values = [434 '5',435 3.14,436 NaN,437 true,438 false,439 null,440 void 0,441 [],442 {}443 ];444 for ( i = 0; i < values.length; i++ ) {445 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );446 }447 t.end();448 function badValue( value ) {449 return function badValue() {450 var createStream = factory( 20, 10, 7, {451 'prng': value452 });453 createStream();454 };455 }456});457tape( 'if provided a `copy` option which is not a boolean, the function returns a function which throws an error', function test( t ) {458 var values;459 var i;460 values = [461 '5',462 5,463 NaN,464 null,465 void 0,466 {},467 [],468 function noop() {}469 ];470 for ( i = 0; i < values.length; i++ ) {471 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );472 }473 t.end();474 function badValue( value ) {475 return function badValue() {476 var createStream = factory({477 'copy': value478 });479 createStream( 20, 10, 7 );480 };481 }482});483tape( 'if provided a `copy` option which is not a boolean, the function returns a function which throws an error (parameters)', function test( t ) {484 var values;485 var i;486 values = [487 '5',488 5,489 NaN,490 null,491 void 0,492 {},493 [],494 function noop() {}495 ];496 for ( i = 0; i < values.length; i++ ) {497 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );498 }499 t.end();500 function badValue( value ) {501 return function badValue() {502 var createStream = factory( 20, 10, 7, {503 'copy': value504 });505 createStream();506 };507 }508});509tape( 'if provided a `seed` which is not a positive integer or a non-empty array-like object, the function returns a function which throws an error', function test( t ) {510 var values;511 var i;512 values = [513 '5',514 3.14,515 0.0,516 -5.0,517 NaN,518 true,519 false,520 null,521 void 0,522 {},523 [],524 function noop() {}525 ];526 for ( i = 0; i < values.length; i++ ) {527 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );528 }529 t.end();530 function badValue( value ) {531 return function badValue() {532 var createStream = factory({533 'seed': value534 });535 createStream( 20, 10, 7 );536 };537 }538});539tape( 'if provided a `seed` which is not a positive integer or a non-empty array-like object, the function returns a function which throws an error (parameters)', function test( t ) {540 var values;541 var i;542 values = [543 '5',544 3.14,545 0.0,546 -5.0,547 NaN,548 true,549 false,550 null,551 void 0,552 {},553 [],554 function noop() {}555 ];556 for ( i = 0; i < values.length; i++ ) {557 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );558 }559 t.end();560 function badValue( value ) {561 return function badValue() {562 var createStream = factory( 20, 10, 7, {563 'seed': value564 });565 createStream();566 };567 }568});569tape( 'the function returns a function which throws a range error if provided a `seed` which is an integer greater than the maximum unsigned 32-bit integer', function test( t ) {570 var values;571 var i;572 values = [573 UINT32_MAX + 1,574 UINT32_MAX + 2,575 UINT32_MAX + 3576 ];577 for ( i = 0; i < values.length; i++ ) {578 t.throws( badValue( values[i] ), RangeError, 'throws a range error when provided '+values[i] );579 }580 t.end();581 function badValue( value ) {582 return function badValue() {583 var createStream = factory({584 'seed': value585 });586 createStream( 20, 10, 7 );587 };588 }589});590tape( 'the function returns a function which throws a range error if provided a `seed` which is an integer greater than the maximum unsigned 32-bit integer (parameters)', function test( t ) {591 var values;592 var i;593 values = [594 UINT32_MAX + 1,595 UINT32_MAX + 2,596 UINT32_MAX + 3597 ];598 for ( i = 0; i < values.length; i++ ) {599 t.throws( badValue( values[i] ), RangeError, 'throws a range error when provided '+values[i] );600 }601 t.end();602 function badValue( value ) {603 return function badValue() {604 var createStream = factory( 20, 10, 7, {605 'seed': value606 });607 createStream();608 };609 }610});611tape( 'if provided a `state` option which is not a Uint32Array, the function returns a function which throws an error', function test( t ) {612 var values;613 var i;614 values = [615 '5',616 5,617 NaN,618 true,619 false,620 null,621 void 0,622 {},623 [],624 function noop() {}625 ];626 for ( i = 0; i < values.length; i++ ) {627 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );628 }629 t.end();630 function badValue( value ) {631 return function badValue() {632 var createStream = factory({633 'state': value634 });635 createStream( 20, 10, 7 );636 };637 }638});639tape( 'if provided a `state` option which is not a Uint32Array, the function returns a function which throws an error (parameters)', function test( t ) {640 var values;641 var i;642 values = [643 '5',644 5,645 NaN,646 true,647 false,648 null,649 void 0,650 {},651 [],652 function noop() {}653 ];654 for ( i = 0; i < values.length; i++ ) {655 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );656 }657 t.end();658 function badValue( value ) {659 return function badValue() {660 var createStream = factory( 20, 10, 7, {661 'state': value662 });663 createStream();664 };665 }666});667tape( 'if provided an invalid `state` option, the function returns a function which throws an error', function test( t ) {668 var values;669 var i;670 values = [671 new Uint32Array( 0 ),672 new Uint32Array( 10 ),673 new Uint32Array( 100 )674 ];675 for ( i = 0; i < values.length; i++ ) {676 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );677 }678 t.end();679 function badValue( value ) {680 return function badValue() {681 var createStream = factory({682 'state': value683 });684 createStream( 20, 10, 7 );685 };686 }687});688tape( 'if provided an invalid `state` option, the function returns a function which throws an error (parameters)', function test( t ) {689 var values;690 var i;691 values = [692 new Uint32Array( 0 ),693 new Uint32Array( 10 ),694 new Uint32Array( 100 )695 ];696 for ( i = 0; i < values.length; i++ ) {697 t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] );698 }699 t.end();700 function badValue( value ) {701 return function badValue() {702 var createStream = factory( 20, 10, 7, {703 'state': value704 });705 createStream();706 };707 }708});709tape( 'if provided an invalid readable stream option, the function returns a function which throws an error', function test( t ) {710 var values;711 var i;712 values = [713 '5',714 -5,715 NaN,716 true,717 false,718 null,719 void 0,720 {},721 [],722 function noop() {}723 ];724 for ( i = 0; i < values.length; i++ ) {725 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );726 }727 t.end();728 function badValue( value ) {729 return function badValue() {730 var createStream = factory({731 'highWaterMark': value732 });733 createStream( 20, 10, 7 );734 };735 }736});737tape( 'if provided an invalid readable stream option, the function returns a function which throws an error (parameters)', function test( t ) {738 var values;739 var i;740 values = [741 '5',742 -5,743 NaN,744 true,745 false,746 null,747 void 0,748 {},749 [],750 function noop() {}751 ];752 for ( i = 0; i < values.length; i++ ) {753 t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );754 }755 t.end();756 function badValue( value ) {757 return function badValue() {758 var createStream = factory( 20, 10, 7, {759 'highWaterMark': value760 });761 createStream();762 };763 }764});765tape( 'the function returns a factory function which creates stream instances', function test( t ) {766 var createStream;767 var i;768 createStream = factory();769 for ( i = 0; i < 10; i++ ) {770 t.equal( createStream( 20, 10, 7 ) instanceof RandomStream, true, 'returns a stream instance' );771 }772 t.end();773});774tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) {775 var createStream;776 var i;777 createStream = factory( {} );778 for ( i = 0; i < 10; i++ ) {779 t.equal( createStream( 20, 10, 7 ) instanceof RandomStream, true, 'returns a stream instance' );780 }781 t.end();782});783tape( 'the function returns a factory function which creates stream instances (parameters)', function test( t ) {784 var createStream;785 var i;786 createStream = factory( 20, 10, 7 );787 for ( i = 0; i < 10; i++ ) {788 t.equal( createStream() instanceof RandomStream, true, 'returns a stream instance' );789 }790 t.end();791});792tape( 'the function returns a factory function which creates stream instances (parameters + options)', function test( t ) {793 var createStream;794 var i;795 createStream = factory( 20, 10, 7, {} );796 for ( i = 0; i < 10; i++ ) {797 t.equal( createStream() instanceof RandomStream, true, 'returns a stream instance' );798 }799 t.end();...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1var fs = require("fs");2var files = require("./files");3var files_m = require("./files_m");4const path = require('path');5const diretorio = path.basename(__dirname);6const { exec } = require("child_process");7module.exports = async function (name) {8 let dir = name;9 var readlineSync = require('readline-sync');10 console.log('Selecione opção para o banco');11 banco = ['MongoDB - Mongoose', 'Mysql - Sequelize'],12 index = readlineSync.keyInSelect(banco, 'Quais das opções?');13 if(banco[index] == 'MongoDB - Mongoose') {14 console.log('Criando sua API com MongoDB...');15 if (!fs.existsSync(diretorio+'/'+dir)){16 //criar o diretorio raiz17 fs.mkdirSync(dir);18 var createStream = fs.createWriteStream(dir+"/app.js");19 createStream.write(files.app);20 createStream = fs.createWriteStream(dir+"/.env");21 createStream.write(files.mongo);22 23 createStream = fs.createWriteStream(dir+"/README.md");24 createStream = fs.createWriteStream(dir+"/LICENSE");25 createStream = fs.createWriteStream(dir+"/package.json");26 createStream.write(files.package);27 createStream = fs.createWriteStream(dir+"/serverless.yml");28 createStream.write(files.serverless);29 fs.mkdirSync(dir+"/src");30 fs.mkdirSync(dir+"/src/app");31 createStream = fs.createWriteStream(dir+"/src/app/index.js");32 createStream.write(files.index);33 fs.mkdirSync(dir+"/src/config");34 35 createStream = fs.createWriteStream(dir+"/src/config/config.js");36 createStream.write(files.config);37 38 createStream = fs.createWriteStream(dir+"/src/config/database.js");39 createStream.write(files.database);40 41 fs.mkdirSync(dir+"/src/app/models");42 createStream = fs.createWriteStream(dir+"/src/app/models/index.js");43 createStream.write(files.model);44 45 fs.mkdirSync(dir+"/src/app/controllers");46 fs.mkdirSync(dir+"/src/app/constants");47 fs.mkdirSync(dir+"/src/app/helpers");48 fs.mkdirSync(dir+"/src/app/middlewares");49 fs.mkdirSync(dir+"/src/app/routes");50 fs.mkdirSync(dir+"/src/app/tests");51 createStream = fs.createWriteStream(dir+"/src/app/routes/index.js");52 createStream.write(files.routes);53 fs.mkdirSync(dir+"/src/app/utils");54 createStream.end();55 console.log('Iniciando a instalação das dependência no seu projeto...');56 exec('npm install', {cwd: dir}, (err, stdout, stderr) => {57 console.log(stdout)58 console.log(stderr)59 console.log('Projeto criado com sucesso.');60 console.log('Execute os seguintes comandos para rodar sua aplicação.\n');61 console.log('- cd ' + dir);62 console.log('- npm run dev \n');63 });64 } else {65 throw Error("Nome de diretório já existente");66 }67 } else if(banco[index] == 'Mysql - Sequelize'){68 console.log('Criando sua API com Mysql...');69 if (!fs.existsSync(diretorio+'/'+dir)){70 //criar o diretorio raiz71 fs.mkdirSync(dir);72 var createStream = fs.createWriteStream(dir+"/app.js");73 createStream.write(files_m.app);74 createStream = fs.createWriteStream(dir+"/.env");75 createStream.write(files_m.env);76 77 createStream = fs.createWriteStream(dir+"/.sequelizerc");78 createStream.write(files_m.sequelize);79 createStream = fs.createWriteStream(dir+"/README.md");80 createStream = fs.createWriteStream(dir+"/LICENSE");81 createStream = fs.createWriteStream(dir+"/package.json");82 createStream.write(files_m.package);83 createStream = fs.createWriteStream(dir+"/serverless.yml");84 createStream.write(files.serverless);85 fs.mkdirSync(dir+"/src");86 fs.mkdirSync(dir+"/src/config");87 createStream = fs.createWriteStream(dir+"/src/config/database.js");88 createStream.write(files_m.database);89 fs.mkdirSync(dir+"/src/database");90 fs.mkdirSync(dir+"/src/database/migrations");91 fs.mkdirSync(dir+"/src/database/seeders");92 fs.mkdirSync(dir+"/src/app");93 createStream = fs.createWriteStream(dir+"/src/app/index.js");94 createStream.write(files_m.index);95 fs.mkdirSync(dir+"/src/app/utils");96 fs.mkdirSync(dir+"/src/app/tests");97 fs.mkdirSync(dir+"/src/app/routes");98 createStream = fs.createWriteStream(dir+"/src/app/routes/index.js");99 createStream.write(files.routes);100 fs.mkdirSync(dir+"/src/app/models");101 createStream = fs.createWriteStream(dir+"/src/app/models/index.js");102 createStream.write(files_m.models);103 fs.mkdirSync(dir+"/src/app/middlewares");104 fs.mkdirSync(dir+"/src/app/helpers");105 fs.mkdirSync(dir+"/src/app/controllers");106 fs.mkdirSync(dir+"/src/app/constants");107 createStream.end();108 console.log('Iniciando a instalação das dependência no seu projeto...');109 exec('npm install', {cwd: dir}, (err, stdout, stderr) => {110 console.log(stdout)111 console.log(stderr)112 console.log('Projeto criado com sucesso.');113 console.log('Execute os seguintes comandos para rodar sua aplicação.\n');114 console.log('- cd ' + dir);115 console.log('- npm run dev \n');116 });117 } else {118 throw Error("Nome de diretório já existente");119 }120 } else {121 console.log('Criação cancelada com sucesso!');122 }...

Full Screen

Full Screen

01rfs.ts

Source:01rfs.ts Github

copy

Full Screen

...6describe("rfs", () => {7 describe("new", () => {8 let rfs: any;9 before(done => {10 rfs = createStream("test.log", { mode: parseInt("666", 8) });11 rfs.end(done);12 });13 it("RFS", () => eq(rfs instanceof RotatingFileStream, true));14 it("Writable", () => eq(rfs instanceof Writable, true));15 it("std filename generator first time", () => eq(rfs.generator(null), "test.log"));16 it("std filename generator later times", () => eq(rfs.generator(new Date("1976-01-23 14:45"), 4), "19760123-1445-04-test.log"));17 });18 describe("no options", () => {19 before(done => createStream("test.log").end(done));20 it("no error", () => eq(true, true));21 });22 describe("wrong calls", () => {23 const encodingError = RangeError('The "test" encoding is not supported');24 if(Number(process.version.match(/^v(\d+)/)[1]) < 11) encodingError.name = "RangeError [ERR_ENCODING_NOT_SUPPORTED]";25 it("wrong filename type", () => ex(() => createStream({} as string), Error('The "filename" argument must be one of type string or function. Received type object')));26 it("wrong options type", () => ex(() => createStream("test.log", "test.log" as unknown), Error('The "options" argument must be of type object. Received type string')));27 it("unknown option", () => ex(() => createStream("test.log", { test: true } as any), Error("Unknown option: test")));28 it("no compress value", () => ex(() => createStream("test.log", { compress: false }), Error("A value for 'options.compress' must be specified")));29 it("wrong compress type", () => ex(() => createStream("test.log", { compress: 23 } as any), Error("Don't know how to handle 'options.compress' type: number")));30 it("wrong compress method", () => ex(() => createStream("test.log", { compress: "test" }), Error("Don't know how to handle compression method: test")));31 it("wrong interval type", () => ex(() => createStream("test.log", { interval: 23 } as any), Error("Don't know how to handle 'options.interval' type: number")));32 it("wrong path type", () => ex(() => createStream("test.log", { path: 23 } as any), Error("Don't know how to handle 'options.path' type: number")));33 it("wrong size type", () => ex(() => createStream("test.log", { size: 23 } as any), Error("Don't know how to handle 'options.size' type: number")));34 it("wrong size type", () => ex(() => createStream("test.log", { size: "test" }), Error("Unknown 'options.size' format: test")));35 it("wrong size number", () => ex(() => createStream("test.log", { size: "-23B" }), Error("A positive integer number is expected for 'options.size'")));36 it("missing size unit", () => ex(() => createStream("test.log", { size: "23" }), Error("Missing unit for 'options.size'")));37 it("wrong size unit", () => ex(() => createStream("test.log", { size: "23test" }), Error("Unknown 'options.size' unit: t")));38 it("wrong interval seconds number", () => ex(() => createStream("test.log", { interval: "23s" }), Error("An integer divider of 60 is expected as seconds for 'options.interval'")));39 it("wrong interval minutes number", () => ex(() => createStream("test.log", { interval: "23m" }), Error("An integer divider of 60 is expected as minutes for 'options.interval'")));40 it("wrong interval hours number", () => ex(() => createStream("test.log", { interval: "23h" }), Error("An integer divider of 24 is expected as hours for 'options.interval'")));41 it("string rotate value", () => ex(() => createStream("test.log", { rotate: "test" } as any), Error("'rotate' option must be a positive integer number")));42 it("negative rotate value", () => ex(() => createStream("test.log", { rotate: -23 }), Error("'rotate' option must be a positive integer number")));43 it("wrong history", () => ex(() => createStream("test.log", { history: {} } as any), Error("Don't know how to handle 'options.history' type: object")));44 it("wrong maxFiles", () => ex(() => createStream("test.log", { maxFiles: {} } as any), Error("'maxFiles' option must be a positive integer number")));45 it("negative maxFiles", () => ex(() => createStream("test.log", { maxFiles: -23 }), Error("'maxFiles' option must be a positive integer number")));46 it("wrong maxSize", () => ex(() => createStream("test.log", { maxSize: "-23B" }), Error("A positive integer number is expected for 'options.size'")));47 it("wrong encoding", () => ex(() => createStream("test.log", { encoding: "test" as BufferEncoding }), encodingError));48 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var file = fs.createWriteStream(path.join(__dirname, 'output.txt'));5var wiki = wptools.page('Albert Einstein')6 .format('json')7 .get()8 .createStream()9 .pipe(file);

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const es = require('event-stream');5const csv = require('fast-csv');6const csvWriter = require('csv-write-stream');7const writer = csvWriter({ headers: ["page", "url", "description", "image"] });8const csvStream = csv.createWriteStream({ headers: true }),9 writableStream = fs.createWriteStream("output.csv");10writableStream.on("finish", function () {11 console.log("DONE!");12});13var stream = wptools.pageStream('test');14stream.pipe(es.mapSync(function (page) {15 if (page.data && page.data.infobox && page.data.infobox.image) {16 var image = page.data.infobox.image;17 var image_url = image.url;18 var image_description = image.description;19 var image_page = image.page;20 csvStream.write({21 });22 }23}));24stream.on('end', function () {25 csvStream.end();26 csvStream.pipe(writableStream);27});28stream.on('error', function (err) {29 console.log(err);30});31const wptools = require('wptools');32const fs = require('fs');33const path = require('path');34const es = require('event-stream');35const csv = require('fast-csv');36const csvWriter = require('csv-write-stream');37const writer = csvWriter({ headers: ["page", "url", "description", "image"] });38const csvStream = csv.createWriteStream({ headers: true }),39 writableStream = fs.createWriteStream("output.csv");40writableStream.on("finish", function () {41 console.log("DONE!");42});43var stream = wptools.pageReadStream('test');44stream.pipe(es.mapSync(function (page) {45 if (page.data && page.data.infobox && page.data.infobox.image) {46 var image = page.data.infobox.image;47 var image_url = image.url;48 var image_description = image.description;49 var image_page = image.page;50 csvStream.write({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var request = require('request');4var request = request.defaults({ encoding: null });5var page = wptools.page('Barack_Obama').getStream();6page.pipe(fs.createWriteStream('Obama.txt'));7console.log('done');8var wptools = require('wptools');9var fs = require('fs');10var request = require('request');11var request = request.defaults({ encoding: null });12var page = wptools.page('Barack_Obama').getStream();13page.pipe(fs.createWriteStream('Obama.txt'));14console.log('done');15var wptools = require('wptools');16var fs = require('fs');17var request = require('request');18var request = request.defaults({ encoding: null });19var page = wptools.page('Barack_Obama').getStream();20page.pipe(fs.createWriteStream('Obama.txt'));21console.log('done');22var wptools = require('wptools');23var fs = require('fs');24var request = require('request');25var request = request.defaults({ encoding: null });26var page = wptools.page('Barack_Obama').getStream();27page.pipe(fs.createWriteStream('Obama.txt'));28console.log('done');29var wptools = require('wptools');30var fs = require('fs');31var request = require('request');32var request = request.defaults({ encoding: null });33var page = wptools.page('Barack_Obama').getStream();34page.pipe(fs.createWriteStream('Obama.txt'));35console.log('done');36var wptools = require('wptools');37var fs = require('fs');38var request = require('request');39var request = request.defaults({ encoding: null });40var page = wptools.page('Barack_Obama').getStream();41page.pipe(fs.createWriteStream('Obama.txt'));42console.log('done');

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptools = require('wptools');3var page = wptools.page('Albert Einstein');4var stream = fs.createWriteStream('AlbertEinstein.txt');5page.createStream().pipe(stream);6var fs = require('fs');7var wptools = require('wptools');8var page = wptools.page('Albert Einstein');9var stream = fs.createWriteStream('AlbertEinstein.txt');10page.createStream().pipe(stream);11var fs = require('fs');12var wptools = require('wptools');13var page = wptools.page('Albert Einstein');14var stream = fs.createWriteStream('AlbertEinstein.txt');15page.createStream().pipe(stream);16var fs = require('fs');17var wptools = require('wptools');18var page = wptools.page('Albert Einstein');19var stream = fs.createWriteStream('AlbertEinstein.txt');20page.createStream().pipe(stream);21var fs = require('fs');22var wptools = require('wptools');23var page = wptools.page('Albert Einstein');24var stream = fs.createWriteStream('AlbertEinstein.txt');25page.createStream().pipe(stream);26var fs = require('fs');27var wptools = require('wptools');28var page = wptools.page('Albert Einstein');29var stream = fs.createWriteStream('AlbertEinstein.txt');30page.createStream().pipe(stream);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var stream = fs.createWriteStream("infobox.json");4var page = wptools.page('Albert Einstein');5page.createStream()6 .pipe(stream);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful