Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as Topo from '..';
import * as Lab from '@hapi/lab';
const { expect } = Lab.types;
// new Topo.Sorter()
const morning = new Topo.Sorter();
morning.add('Nap', { after: ['breakfast', 'prep'] })
morning.add(['Make toast', 'Pour juice'], { before: 'breakfast', group: 'prep' });
morning.add('Eat breakfast', { group: 'breakfast' });
const afternoon = new Topo.Sorter();
afternoon.add('Eat lunch', { after: ['afternoon', 'prep'], sort: 2 });
expect.type(new Topo.Sorter());
// sorter.add()
import * as Address from '..';
import * as Lab from '@hapi/lab';
const { expect } = Lab.types;
// errors
expect.type(Address.errors.FORBIDDEN_UNICODE);
// domain.analyze()
Address.domain.analyze('example.com');
Address.domain.analyze('example.com', { minDomainSegments: 3, allowUnicode: false });
Address.domain.analyze('example.com', { tlds: false });
Address.domain.analyze('example.com', { tlds: true });
Address.domain.analyze('example.com', { tlds: { allow: new Set('x') } });
Address.domain.analyze('example.com', { tlds: { allow: new Set('x') } });
Address.domain.analyze('example.com', { tlds: { allow: true } });
import * as Boom from '..';
import * as Lab from '@hapi/lab';
const { expect } = Lab.types;
class X {
x: number;
constructor(value: number) {
this.x = value;
}
};
const decorate = new X(1);
// new Boom.Boom()
import * as Lab from '@hapi/lab';
import * as Teamwork from '..';
const { expect } = Lab.types;
// Constructor tests
expect.type(new Teamwork.Team());
expect.type(new Teamwork.Team({ meetings: 2 }));
expect.error(new Teamwork.Team({ foo: true }));
expect.error(new Teamwork.Team({ meetings: 'foo' }));
expect.type>(new Teamwork.Team().work);
// Attend tests
expect.type(new Teamwork.Team().attend());
expect.type(new Teamwork.Team().attend(new Error()));
expect.type(new Teamwork.Team().attend('foo'));
import * as Http from 'http';
import * as Net from 'net';
import * as Code from '@hapi/code';
import * as Lab from '@hapi/lab';
import * as Wreck from '..';
const { expect } = Lab.types;
// Provision server
const server = Http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Some payload');
});
await new Promise((resolve) => server.listen(0, resolve));
const address = server.address() as Net.AddressInfo;
const url = `http://localhost:${address.port}`;
// request()
import * as Hoek from '..';
import * as Lab from '@hapi/lab';
const { expect } = Lab.types;
interface Foo {
a?: number;
b?: string;
};
interface Bar {
b?: string;
c?: boolean;
};
// deepEqual()
Hoek.deepEqual('some', 'some');
import * as Cryptiles from '..';
import * as Lab from '@hapi/lab';
const { expect } = Lab.types;
// randomString()
Cryptiles.randomString(256);
Cryptiles.randomString(5 * 5);
expect.type(Cryptiles.randomString(128))
expect.error(Cryptiles.randomString('some'));
expect.error(Cryptiles.randomString(true));
expect.error(Cryptiles.randomString({ foo: true }));
expect.error(Cryptiles.randomString(128, 256));
// randomDigits()
import * as Iron from '..';
import * as Lab from '@hapi/lab';
const Cryptiles = require('@hapi/cryptiles');
const { expect } = Lab.types;
const password = 'some_not_random_password_that_is_also_long_enough';
const buffer = Cryptiles.randomBits(256);
const defaults = {
encryption: {
saltBits: 256,
algorithm: 'aes-256-cbc',
iterations: 1,
minPasswordlength: 32
},
integrity: {
saltBits: 256,