new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"F G A B","2":"J E BC"},B:{"1":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"1":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC rB"},G:{"1":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"1":"nC"},I:{"1":"tB I D oC pC qC rC AC sC tC"},J:{"1":"E A"},K:{"1":"A B C e qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"1":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:2,C:"CSS Counters"};
|
||||
@@ -0,0 +1,491 @@
|
||||
const path = require('path');
|
||||
const test = require('ava');
|
||||
const sh = require('shelljs');
|
||||
const proxyquire = require('proxyquire');
|
||||
const _ = require('lodash');
|
||||
const sinon = require('sinon');
|
||||
const Log = require('../lib/log');
|
||||
const Spinner = require('../lib/spinner');
|
||||
const Config = require('../lib/config');
|
||||
const runTasks = require('../lib/tasks');
|
||||
const Plugin = require('../lib/plugin/Plugin');
|
||||
const { mkTmpDir, gitAdd, getArgs } = require('./util/helpers');
|
||||
const ShellStub = require('./stub/shell');
|
||||
const {
|
||||
interceptUser: interceptGitLabUser,
|
||||
interceptCollaborator: interceptGitLabCollaborator,
|
||||
interceptPublish: interceptGitLabPublish,
|
||||
interceptAsset: interceptGitLabAsset
|
||||
} = require('./stub/gitlab');
|
||||
const {
|
||||
interceptAuthentication: interceptGitHubAuthentication,
|
||||
interceptCollaborator: interceptGitHubCollaborator,
|
||||
interceptCreate: interceptGitHubCreate,
|
||||
interceptAsset: interceptGitHubAsset
|
||||
} = require('./stub/github');
|
||||
|
||||
const noop = Promise.resolve();
|
||||
|
||||
const sandbox = sinon.createSandbox();
|
||||
|
||||
const testConfig = {
|
||||
ci: true,
|
||||
config: false,
|
||||
'disable-metrics': true
|
||||
};
|
||||
|
||||
const log = sandbox.createStubInstance(Log);
|
||||
const spinner = sandbox.createStubInstance(Spinner);
|
||||
spinner.show.callsFake(({ enabled = true, task }) => (enabled ? task() : noop));
|
||||
|
||||
const getContainer = options => {
|
||||
const config = new Config(Object.assign({}, testConfig, options));
|
||||
const shell = new ShellStub({ container: { log, config } });
|
||||
return {
|
||||
log,
|
||||
spinner,
|
||||
config,
|
||||
shell
|
||||
};
|
||||
};
|
||||
|
||||
test.serial.beforeEach(t => {
|
||||
const bare = mkTmpDir();
|
||||
const target = mkTmpDir();
|
||||
sh.pushd('-q', bare);
|
||||
sh.exec(`git init --bare .`);
|
||||
sh.exec(`git clone ${bare} ${target}`);
|
||||
sh.pushd('-q', target);
|
||||
gitAdd('line', 'file', 'Add file');
|
||||
t.context = { bare, target };
|
||||
});
|
||||
|
||||
test.serial.afterEach(() => {
|
||||
sandbox.resetHistory();
|
||||
});
|
||||
|
||||
test.serial('should run tasks without throwing errors', async t => {
|
||||
sh.mv('.git', 'foo');
|
||||
const { name, latestVersion, version } = await runTasks({}, getContainer());
|
||||
t.true(log.obtrusive.firstCall.args[0].includes(`release ${name} (${latestVersion}...${version})`));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
});
|
||||
|
||||
test.serial('should run tasks without package.json', async t => {
|
||||
sh.exec('git tag 1.0.0');
|
||||
gitAdd('line', 'file', 'Add file');
|
||||
const { name } = await runTasks({}, getContainer({ increment: 'major', git: { commit: false } }));
|
||||
t.true(log.obtrusive.firstCall.args[0].includes(`release ${name} (1.0.0...2.0.0)`));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
t.is(log.warn.callCount, 0);
|
||||
{
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), '2.0.0');
|
||||
}
|
||||
});
|
||||
|
||||
test.serial('should disable plugins', async t => {
|
||||
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.2.3');
|
||||
gitAdd('line', 'file', 'Add file');
|
||||
const container = getContainer({ increment: 'minor', git: false, npm: false });
|
||||
const { latestVersion, version } = await runTasks({}, container);
|
||||
t.is(latestVersion, '0.0.0');
|
||||
t.is(version, '0.1.0');
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
});
|
||||
|
||||
test.serial('should run tasks with minimal config and without any warnings/errors', async t => {
|
||||
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.2.3');
|
||||
gitAdd('line', 'file', 'More file');
|
||||
await runTasks({}, getContainer({ increment: 'patch' }));
|
||||
t.true(log.obtrusive.firstCall.args[0].includes('release my-package (1.2.3...1.2.4)'));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), '1.2.4');
|
||||
});
|
||||
|
||||
test.serial('should use pkg.version', async t => {
|
||||
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
||||
await runTasks({}, getContainer({ increment: 'minor' }));
|
||||
t.true(log.obtrusive.firstCall.args[0].includes('release my-package (1.2.3...1.3.0)'));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), '1.3.0');
|
||||
});
|
||||
|
||||
test.serial('should use pkg.version (in sub dir) w/o tagging repo', async t => {
|
||||
gitAdd('{"name":"root-package","version":"1.0.0"}', 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.0.0');
|
||||
sh.mkdir('my-package');
|
||||
sh.pushd('-q', 'my-package');
|
||||
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
||||
const container = getContainer({ increment: 'minor', git: { tag: false } });
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
await runTasks({}, container);
|
||||
t.true(log.obtrusive.firstCall.args[0].endsWith('release my-package (1.2.3...1.3.0)'));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), '1.0.0');
|
||||
const npmArgs = getArgs(exec.args, 'npm');
|
||||
t.is(npmArgs[4], 'npm version 1.3.0 --no-git-tag-version');
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should ignore version in pkg.version and use git tag instead', async t => {
|
||||
gitAdd('{"name":"my-package","version":"0.0.0"}', 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.1.1');
|
||||
gitAdd('line', 'file', 'More file');
|
||||
await runTasks({}, getContainer({ increment: 'minor', npm: { ignoreVersion: true } }));
|
||||
t.true(log.obtrusive.firstCall.args[0].includes('release my-package (1.1.1...1.2.0)'));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), '1.2.0');
|
||||
});
|
||||
|
||||
test.serial('should release all the things (basic)', async t => {
|
||||
const { bare, target } = t.context;
|
||||
const project = path.basename(bare);
|
||||
const pkgName = path.basename(target);
|
||||
const owner = path.basename(path.dirname(bare));
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
sh.exec('git tag 1.0.0');
|
||||
const sha = gitAdd('line', 'file', 'More file');
|
||||
|
||||
interceptGitHubAuthentication();
|
||||
interceptGitHubCollaborator({ owner, project });
|
||||
interceptGitHubCreate({
|
||||
owner,
|
||||
project,
|
||||
body: { tag_name: '1.0.1', name: 'Release 1.0.1', body: `* More file (${sha})`, prerelease: false }
|
||||
});
|
||||
|
||||
const container = getContainer({
|
||||
github: { release: true, pushRepo: `https://github.com/${owner}/${project}` },
|
||||
npm: { name: pkgName }
|
||||
});
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
||||
|
||||
t.deepEqual(npmArgs, [
|
||||
'npm ping',
|
||||
'npm whoami',
|
||||
`npm show ${pkgName}@latest version`,
|
||||
`npm access ls-collaborators ${pkgName}`,
|
||||
'npm version 1.0.1 --no-git-tag-version',
|
||||
'npm publish . --tag latest'
|
||||
]);
|
||||
|
||||
t.true(log.obtrusive.firstCall.args[0].endsWith(`release ${pkgName} (1.0.0...1.0.1)`));
|
||||
t.true(log.log.firstCall.args[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
||||
t.true(log.log.secondCall.args[0].endsWith(`https://github.com/${owner}/${project}/releases/tag/1.0.1`));
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should release all the things (pre-release, github, gitlab)', async t => {
|
||||
const { bare, target } = t.context;
|
||||
const project = path.basename(bare);
|
||||
const pkgName = path.basename(target);
|
||||
const owner = path.basename(path.dirname(bare));
|
||||
const url = `https://gitlab.com/${owner}/${project}`;
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
sh.exec('git tag v1.0.0');
|
||||
const sha = gitAdd('line', 'file', 'More file');
|
||||
sh.exec('git push --follow-tags');
|
||||
|
||||
interceptGitHubAuthentication();
|
||||
interceptGitHubCollaborator({ owner, project });
|
||||
interceptGitHubCreate({
|
||||
owner,
|
||||
project,
|
||||
body: {
|
||||
tag_name: 'v1.1.0-alpha.0',
|
||||
name: 'Release 1.1.0-alpha.0',
|
||||
body: `Notes for ${pkgName} [v1.1.0-alpha.0]: ${sha}`,
|
||||
prerelease: true
|
||||
}
|
||||
});
|
||||
interceptGitHubAsset({ owner, project, body: 'lineline' });
|
||||
|
||||
interceptGitLabUser({ owner });
|
||||
interceptGitLabCollaborator({ owner, project });
|
||||
interceptGitLabAsset({ owner, project });
|
||||
interceptGitLabPublish({
|
||||
owner,
|
||||
project,
|
||||
body: {
|
||||
name: 'Release 1.1.0-alpha.0',
|
||||
tag_name: 'v1.1.0-alpha.0',
|
||||
description: `Notes for ${pkgName}: ${sha}`,
|
||||
assets: {
|
||||
links: [
|
||||
{
|
||||
name: 'file',
|
||||
url: `${url}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c/file`
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const container = getContainer({
|
||||
increment: 'minor',
|
||||
preRelease: 'alpha',
|
||||
git: {
|
||||
changelog: 'git log --pretty=format:%h ${latestTag}...HEAD',
|
||||
commitMessage: 'Release ${version} for ${name} (from ${latestVersion})',
|
||||
tagAnnotation: '${repo.owner} ${repo.repository} ${repo.project}'
|
||||
},
|
||||
github: {
|
||||
release: true,
|
||||
pushRepo: `https://github.com/${owner}/${project}`,
|
||||
releaseNotes: 'echo Notes for ${name} [v${version}]: ${changelog}',
|
||||
assets: ['file']
|
||||
},
|
||||
gitlab: {
|
||||
release: true,
|
||||
pushRepo: url,
|
||||
releaseNotes: 'echo Notes for ${name}: ${changelog}',
|
||||
assets: ['file']
|
||||
},
|
||||
npm: { name: pkgName }
|
||||
});
|
||||
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
||||
t.deepEqual(npmArgs, [
|
||||
'npm ping',
|
||||
'npm whoami',
|
||||
`npm show ${pkgName}@latest version`,
|
||||
`npm access ls-collaborators ${pkgName}`,
|
||||
'npm version 1.1.0-alpha.0 --no-git-tag-version',
|
||||
'npm publish . --tag alpha'
|
||||
]);
|
||||
|
||||
const { stdout: commitMessage } = sh.exec('git log --oneline --format=%B -n 1 HEAD');
|
||||
t.is(commitMessage.trim(), `Release 1.1.0-alpha.0 for ${pkgName} (from 1.0.0)`);
|
||||
|
||||
const { stdout: tagName } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(tagName.trim(), 'v1.1.0-alpha.0');
|
||||
|
||||
const { stdout: tagAnnotation } = sh.exec('git for-each-ref refs/tags/v1.1.0-alpha.0 --format="%(contents)"');
|
||||
t.is(tagAnnotation.trim(), `${owner} ${owner}/${project} ${project}`);
|
||||
|
||||
t.true(log.obtrusive.firstCall.args[0].endsWith(`release ${pkgName} (1.0.0...1.1.0-alpha.0)`));
|
||||
t.true(log.log.firstCall.args[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
||||
t.true(log.log.secondCall.args[0].endsWith(`https://github.com/${owner}/${project}/releases/tag/v1.1.0-alpha.0`));
|
||||
t.true(log.log.thirdCall.args[0].endsWith(`${project}/-/releases`));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should publish pre-release without pre-id with different npm.tag', async t => {
|
||||
const { target } = t.context;
|
||||
const pkgName = path.basename(target);
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
sh.exec('git tag v1.0.0');
|
||||
|
||||
const container = getContainer({ increment: 'major', preRelease: true, npm: { name: pkgName, tag: 'next' } });
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
||||
t.deepEqual(npmArgs, [
|
||||
'npm ping',
|
||||
'npm whoami',
|
||||
`npm show ${pkgName}@latest version`,
|
||||
`npm access ls-collaborators ${pkgName}`,
|
||||
'npm version 2.0.0-0 --no-git-tag-version',
|
||||
'npm publish . --tag next'
|
||||
]);
|
||||
|
||||
const { stdout } = sh.exec('git describe --tags --match=* --abbrev=0');
|
||||
t.is(stdout.trim(), 'v2.0.0-0');
|
||||
t.true(log.obtrusive.firstCall.args[0].endsWith(`release ${pkgName} (1.0.0...2.0.0-0)`));
|
||||
t.true(log.log.firstCall.args[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
||||
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should handle private package correctly, bump lockfile', async t => {
|
||||
const { target } = t.context;
|
||||
const pkgName = path.basename(target);
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package.json', 'Add package.json');
|
||||
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package-lock.json', 'Add package-lock.json');
|
||||
|
||||
const container = getContainer({ npm: { name: pkgName, private: true } });
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
||||
t.deepEqual(npmArgs, ['npm version 1.0.1 --no-git-tag-version']);
|
||||
t.true(log.obtrusive.firstCall.args[0].endsWith(`release ${pkgName} (1.0.0...1.0.1)`));
|
||||
t.is(log.warn.lastCall.args[0], 'Skip publish: package is private.');
|
||||
t.regex(log.log.firstCall.args[0], /Done \(in [0-9]+s\.\)/);
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should initially publish non-private scoped npm package privately', async t => {
|
||||
const { target } = t.context;
|
||||
const pkgName = path.basename(target);
|
||||
gitAdd(`{"name":"@scope/${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
|
||||
const container = getContainer({ npm: { name: pkgName } });
|
||||
|
||||
const exec = sinon.stub(container.shell, 'exec').callThrough();
|
||||
exec.withArgs(`npm show @scope/${pkgName}@latest version`).rejects();
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
||||
t.is(npmArgs[5], 'npm publish . --tag latest');
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should use pkg.publishConfig.registry', async t => {
|
||||
const { target } = t.context;
|
||||
const pkgName = path.basename(target);
|
||||
const registry = 'https://my-registry.com';
|
||||
|
||||
gitAdd(
|
||||
JSON.stringify({
|
||||
name: pkgName,
|
||||
version: '1.2.3',
|
||||
publishConfig: { registry }
|
||||
}),
|
||||
'package.json',
|
||||
'Add package.json'
|
||||
);
|
||||
|
||||
const container = getContainer();
|
||||
|
||||
const exec = sinon.spy(container.shell, 'exec');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const npmArgs = getArgs(exec.args, 'npm');
|
||||
t.is(npmArgs[0], `npm ping --registry ${registry}`);
|
||||
t.is(npmArgs[1], `npm whoami --registry ${registry}`);
|
||||
t.true(container.log.log.firstCall.args[0].endsWith(`${registry}/package/${pkgName}`));
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
|
||||
test.serial('should propagate errors', async t => {
|
||||
const config = {
|
||||
hooks: {
|
||||
'before:init': 'some-failing-command'
|
||||
}
|
||||
};
|
||||
const container = getContainer(config);
|
||||
|
||||
await t.throwsAsync(runTasks({}, container), { message: /some-failing-command/ });
|
||||
|
||||
t.is(log.error.callCount, 1);
|
||||
});
|
||||
|
||||
{
|
||||
class MyPlugin extends Plugin {}
|
||||
const statics = { isEnabled: () => true, disablePlugin: () => null };
|
||||
const options = { '@global': true, '@noCallThru': true };
|
||||
const runTasks = proxyquire('../lib/tasks', {
|
||||
'my-plugin': Object.assign(MyPlugin, statics, options)
|
||||
});
|
||||
|
||||
test.serial('should run all hooks', async t => {
|
||||
gitAdd(`{"name":"hooked","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
||||
const hooks = {};
|
||||
['before', 'after'].forEach(prefix => {
|
||||
['version', 'git', 'npm', 'my-plugin'].forEach(ns => {
|
||||
['init', 'beforeBump', 'bump', 'beforeRelease', 'release', 'afterRelease'].forEach(cycle => {
|
||||
hooks[`${prefix}:${cycle}`] = `echo ${prefix}:${cycle}`;
|
||||
hooks[`${prefix}:${ns}:${cycle}`] = `echo ${prefix}:${ns}:${cycle}`;
|
||||
});
|
||||
});
|
||||
});
|
||||
const container = getContainer({ plugins: { 'my-plugin': {} }, hooks });
|
||||
const exec = sinon.spy(container.shell, 'execFormattedCommand');
|
||||
|
||||
await runTasks({}, container);
|
||||
|
||||
const commands = _.flatten(exec.args).filter(arg => typeof arg === 'string' && arg.startsWith('echo'));
|
||||
|
||||
t.deepEqual(commands, [
|
||||
'echo before:init',
|
||||
'echo before:my-plugin:init',
|
||||
'echo after:my-plugin:init',
|
||||
'echo before:npm:init',
|
||||
'echo after:npm:init',
|
||||
'echo before:git:init',
|
||||
'echo after:git:init',
|
||||
'echo before:version:init',
|
||||
'echo after:version:init',
|
||||
'echo after:init',
|
||||
'echo before:beforeBump',
|
||||
'echo before:my-plugin:beforeBump',
|
||||
'echo after:my-plugin:beforeBump',
|
||||
'echo before:npm:beforeBump',
|
||||
'echo after:npm:beforeBump',
|
||||
'echo before:git:beforeBump',
|
||||
'echo after:git:beforeBump',
|
||||
'echo before:version:beforeBump',
|
||||
'echo after:version:beforeBump',
|
||||
'echo after:beforeBump',
|
||||
'echo before:bump',
|
||||
'echo before:my-plugin:bump',
|
||||
'echo after:my-plugin:bump',
|
||||
'echo before:npm:bump',
|
||||
'echo after:npm:bump',
|
||||
'echo before:git:bump',
|
||||
'echo after:git:bump',
|
||||
'echo before:version:bump',
|
||||
'echo after:version:bump',
|
||||
'echo after:bump',
|
||||
'echo before:beforeRelease',
|
||||
'echo before:my-plugin:beforeRelease',
|
||||
'echo after:my-plugin:beforeRelease',
|
||||
'echo before:npm:beforeRelease',
|
||||
'echo after:npm:beforeRelease',
|
||||
'echo before:git:beforeRelease',
|
||||
'echo after:git:beforeRelease',
|
||||
'echo before:version:beforeRelease',
|
||||
'echo after:version:beforeRelease',
|
||||
'echo after:beforeRelease',
|
||||
'echo before:release',
|
||||
'echo before:npm:release',
|
||||
'echo after:npm:release',
|
||||
'echo before:git:release',
|
||||
'echo after:git:release',
|
||||
'echo before:version:release',
|
||||
'echo after:version:release',
|
||||
'echo before:my-plugin:release',
|
||||
'echo after:my-plugin:release',
|
||||
'echo after:release',
|
||||
'echo before:afterRelease',
|
||||
'echo before:npm:afterRelease',
|
||||
'echo after:npm:afterRelease',
|
||||
'echo before:git:afterRelease',
|
||||
'echo after:git:afterRelease',
|
||||
'echo before:version:afterRelease',
|
||||
'echo after:version:afterRelease',
|
||||
'echo before:my-plugin:afterRelease',
|
||||
'echo after:my-plugin:afterRelease',
|
||||
'echo after:afterRelease'
|
||||
]);
|
||||
|
||||
exec.restore();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/every"));
|
||||
//# sourceMappingURL=every.js.map
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Operator } from './Operator';
|
||||
import { Observable } from './Observable';
|
||||
import { Subscriber } from './Subscriber';
|
||||
import { Subscription } from './Subscription';
|
||||
import { Observer, SubscriptionLike, TeardownLogic } from './types';
|
||||
/**
|
||||
* @class SubjectSubscriber<T>
|
||||
*/
|
||||
export declare class SubjectSubscriber<T> extends Subscriber<T> {
|
||||
protected destination: Subject<T>;
|
||||
constructor(destination: Subject<T>);
|
||||
}
|
||||
/**
|
||||
* A Subject is a special type of Observable that allows values to be
|
||||
* multicasted to many Observers. Subjects are like EventEmitters.
|
||||
*
|
||||
* Every Subject is an Observable and an Observer. You can subscribe to a
|
||||
* Subject, and you can call next to feed values as well as error and complete.
|
||||
*
|
||||
* @class Subject<T>
|
||||
*/
|
||||
export declare class Subject<T> extends Observable<T> implements SubscriptionLike {
|
||||
observers: Observer<T>[];
|
||||
closed: boolean;
|
||||
isStopped: boolean;
|
||||
hasError: boolean;
|
||||
thrownError: any;
|
||||
constructor();
|
||||
/**@nocollapse
|
||||
* @deprecated use new Subject() instead
|
||||
*/
|
||||
static create: Function;
|
||||
lift<R>(operator: Operator<T, R>): Observable<R>;
|
||||
next(value?: T): void;
|
||||
error(err: any): void;
|
||||
complete(): void;
|
||||
unsubscribe(): void;
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_trySubscribe(subscriber: Subscriber<T>): TeardownLogic;
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_subscribe(subscriber: Subscriber<T>): Subscription;
|
||||
/**
|
||||
* Creates a new Observable with this Subject as the source. You can do this
|
||||
* to create customize Observer-side logic of the Subject and conceal it from
|
||||
* code that uses the Observable.
|
||||
* @return {Observable} Observable that the Subject casts to
|
||||
*/
|
||||
asObservable(): Observable<T>;
|
||||
}
|
||||
/**
|
||||
* @class AnonymousSubject<T>
|
||||
*/
|
||||
export declare class AnonymousSubject<T> extends Subject<T> {
|
||||
protected destination?: Observer<T>;
|
||||
constructor(destination?: Observer<T>, source?: Observable<T>);
|
||||
next(value: T): void;
|
||||
error(err: any): void;
|
||||
complete(): void;
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_subscribe(subscriber: Subscriber<T>): Subscription;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.00342,"53":0.02739,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.01712,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.06848,"79":0.00342,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.00342,"103":0.00342,"104":0.00342,"105":0.01712,"106":0.00342,"107":0.00685,"108":0.0993,"109":0.07533,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0.00342,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0.00685,"50":0,"51":0,"52":0,"53":0.01027,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00342,"69":0,"70":0,"71":0,"72":0.00342,"73":0,"74":0.00342,"75":0,"76":0,"77":0.02054,"78":0.00342,"79":0.22598,"80":0.00685,"81":0.00685,"83":0.00685,"84":0.00342,"85":0.00685,"86":0.00342,"87":0.04794,"88":0.01027,"89":0.00342,"90":0.00342,"91":0.00342,"92":0.03424,"93":0,"94":0.03082,"95":0.00342,"96":0.01027,"97":0.00685,"98":0.00685,"99":0.02054,"100":0.02054,"101":0.00685,"102":0.00685,"103":0.03766,"104":0.03082,"105":0.01712,"106":0.03424,"107":0.06506,"108":4.21152,"109":4.05744,"110":0.00342,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0.00685,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0.00342,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0.00685,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.0137,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.01027,"80":0,"81":0,"82":0.00342,"83":0,"84":0.00342,"85":0.0137,"86":0,"87":0,"88":0.00342,"89":0,"90":0,"91":0,"92":0.00342,"93":0.26022,"94":0.73274,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0.00342,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00342,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0.02397,"108":0.23626,"109":0.16435},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.02397,"15":0.00685,_:"0","3.1":0,"3.2":0,"5.1":0.03424,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.00342,"13.1":0.01712,"14.1":0.01712,"15.1":0.00685,"15.2-15.3":0.01027,"15.4":0.0137,"15.5":0.02397,"15.6":0.05478,"16.0":0.01712,"16.1":0.03424,"16.2":0.06848,"16.3":0.00342},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.00125,"6.0-6.1":0,"7.0-7.1":0.01124,"8.1-8.4":0,"9.0-9.2":0.00125,"9.3":0.00999,"10.0-10.2":0,"10.3":0.10619,"11.0-11.2":0.0025,"11.3-11.4":0.00375,"12.0-12.1":0.00125,"12.2-12.5":0.49222,"13.0-13.1":0.005,"13.2":0.005,"13.3":0.02124,"13.4-13.7":0.04622,"14.0-14.4":0.24861,"14.5-14.8":0.40977,"15.0-15.1":0.10244,"15.2-15.3":0.0887,"15.4":0.20363,"15.5":0.53095,"15.6":1.08438,"16.0":1.94014,"16.1":3.74161,"16.2":2.33866,"16.3":0.29358},P:{"4":0.32769,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.0512,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0.06144,"12.0":0.01024,"13.0":0.07168,"14.0":0.09216,"15.0":0.0512,"16.0":0.1024,"17.0":0.21505,"18.0":0.31745,"19.0":3.42029},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00774,"4.4":0,"4.4.3-4.4.4":0.03253},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.01027,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0.27619},Q:{"13.1":0},O:{"0":0.26962},H:{"0":0.6786},L:{"0":68.52557},S:{"2.5":0}};
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operators/distinctUntilKeyChanged"));
|
||||
//# sourceMappingURL=distinctUntilKeyChanged.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"publishBehavior.js","sources":["../../../src/internal/operators/publishBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,MAAM,UAAU,eAAe,CAAI,KAAQ;IACzC,OAAO,UAAC,MAAqB,IAAK,OAAA,SAAS,CAAC,IAAI,eAAe,CAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAA6B,EAA5E,CAA4E,CAAC;AACjH,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
import 'rxjs-compat/add/operator/mergeAll';
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Subscriber } from '../Subscriber';
|
||||
export function defaultIfEmpty(defaultValue = null) {
|
||||
return (source) => source.lift(new DefaultIfEmptyOperator(defaultValue));
|
||||
}
|
||||
class DefaultIfEmptyOperator {
|
||||
constructor(defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
call(subscriber, source) {
|
||||
return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
|
||||
}
|
||||
}
|
||||
class DefaultIfEmptySubscriber extends Subscriber {
|
||||
constructor(destination, defaultValue) {
|
||||
super(destination);
|
||||
this.defaultValue = defaultValue;
|
||||
this.isEmpty = true;
|
||||
}
|
||||
_next(value) {
|
||||
this.isEmpty = false;
|
||||
this.destination.next(value);
|
||||
}
|
||||
_complete() {
|
||||
if (this.isEmpty) {
|
||||
this.destination.next(this.defaultValue);
|
||||
}
|
||||
this.destination.complete();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=defaultIfEmpty.js.map
|
||||
@@ -0,0 +1,40 @@
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class BlockLogical extends Declaration {
|
||||
/**
|
||||
* Use old syntax for -moz- and -webkit-
|
||||
*/
|
||||
prefixed (prop, prefix) {
|
||||
if (prop.includes('-start')) {
|
||||
return prefix + prop.replace('-block-start', '-before')
|
||||
}
|
||||
return prefix + prop.replace('-block-end', '-after')
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property name by spec
|
||||
*/
|
||||
normalize (prop) {
|
||||
if (prop.includes('-before')) {
|
||||
return prop.replace('-before', '-block-start')
|
||||
}
|
||||
return prop.replace('-after', '-block-end')
|
||||
}
|
||||
}
|
||||
|
||||
BlockLogical.names = [
|
||||
'border-block-start',
|
||||
'border-block-end',
|
||||
'margin-block-start',
|
||||
'margin-block-end',
|
||||
'padding-block-start',
|
||||
'padding-block-end',
|
||||
'border-before',
|
||||
'border-after',
|
||||
'margin-before',
|
||||
'margin-after',
|
||||
'padding-before',
|
||||
'padding-after'
|
||||
]
|
||||
|
||||
module.exports = BlockLogical
|
||||
@@ -0,0 +1,22 @@
|
||||
// determining low-bandwidth via navigator.connection
|
||||
|
||||
// There are two iterations of the navigator.connection interface:
|
||||
|
||||
// The first is present in Android 2.2+ and only in the Browser (not WebView)
|
||||
// : docs.phonegap.com/en/1.2.0/phonegap_connection_connection.md.html#connection.type
|
||||
// : davidbcalhoun.com/2010/using-navigator-connection-android
|
||||
|
||||
// The second is specced at dev.w3.org/2009/dap/netinfo/ and perhaps landing in WebKit
|
||||
// : bugs.webkit.org/show_bug.cgi?id=73528
|
||||
|
||||
// unknown devices are assumed as fast
|
||||
// for more rigorous network testing, consider boomerang.js: github.com/bluesmoon/boomerang/
|
||||
|
||||
Modernizr.addTest('lowbandwidth', function() {
|
||||
|
||||
var connection = navigator.connection || { type: 0 }; // polyfill
|
||||
|
||||
return connection.type == 3 || // connection.CELL_2G
|
||||
connection.type == 4 || // connection.CELL_3G
|
||||
/^[23]g$/.test(connection.type); // string value in new spec
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
import 'rxjs-compat/add/operator/windowTime';
|
||||
@@ -0,0 +1,451 @@
|
||||
# is [](https://travis-ci.org/sindresorhus/is)
|
||||
|
||||
> Type check values: `is.string('🦄') //=> true`
|
||||
|
||||
<img src="header.gif" width="182" align="right">
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install @sindresorhus/is
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const is = require('@sindresorhus/is');
|
||||
|
||||
is('🦄');
|
||||
//=> 'string'
|
||||
|
||||
is(new Map());
|
||||
//=> 'Map'
|
||||
|
||||
is.number(6);
|
||||
//=> true
|
||||
```
|
||||
|
||||
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used to infer the correct type inside if-else statements.
|
||||
|
||||
```ts
|
||||
import is from '@sindresorhus/is';
|
||||
|
||||
const padLeft = (value: string, padding: string | number) => {
|
||||
if (is.number(padding)) {
|
||||
// `padding` is typed as `number`
|
||||
return Array(padding + 1).join(' ') + value;
|
||||
}
|
||||
|
||||
if (is.string(padding)) {
|
||||
// `padding` is typed as `string`
|
||||
return padding + value;
|
||||
}
|
||||
|
||||
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
||||
}
|
||||
|
||||
padLeft('🦄', 3);
|
||||
//=> ' 🦄'
|
||||
|
||||
padLeft('🦄', '🌈');
|
||||
//=> '🌈🦄'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### is(value)
|
||||
|
||||
Returns the type of `value`.
|
||||
|
||||
Primitives are lowercase and object types are camelcase.
|
||||
|
||||
Example:
|
||||
|
||||
- `'undefined'`
|
||||
- `'null'`
|
||||
- `'string'`
|
||||
- `'symbol'`
|
||||
- `'Array'`
|
||||
- `'Function'`
|
||||
- `'Object'`
|
||||
|
||||
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
|
||||
|
||||
### is.{method}
|
||||
|
||||
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
|
||||
|
||||
#### Primitives
|
||||
|
||||
##### .undefined(value)
|
||||
##### .null(value)
|
||||
##### .string(value)
|
||||
##### .number(value)
|
||||
##### .boolean(value)
|
||||
##### .symbol(value)
|
||||
|
||||
#### Built-in types
|
||||
|
||||
##### .array(value)
|
||||
##### .function(value)
|
||||
##### .buffer(value)
|
||||
##### .object(value)
|
||||
|
||||
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
||||
|
||||
##### .numericString(value)
|
||||
|
||||
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`.
|
||||
|
||||
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
||||
|
||||
##### .regExp(value)
|
||||
##### .date(value)
|
||||
##### .error(value)
|
||||
##### .nativePromise(value)
|
||||
##### .promise(value)
|
||||
|
||||
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
|
||||
|
||||
##### .generator(value)
|
||||
|
||||
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
|
||||
|
||||
##### .generatorFunction(value)
|
||||
|
||||
##### .asyncFunction(value)
|
||||
|
||||
Returns `true` for any `async` function that can be called with the `await` operator.
|
||||
|
||||
```js
|
||||
is.asyncFunction(async () => {});
|
||||
// => true
|
||||
|
||||
is.asyncFunction(() => {});
|
||||
// => false
|
||||
```
|
||||
|
||||
##### .boundFunction(value)
|
||||
|
||||
Returns `true` for any `bound` function.
|
||||
|
||||
```js
|
||||
is.boundFunction(() => {});
|
||||
// => true
|
||||
|
||||
is.boundFunction(function () {}.bind(null));
|
||||
// => true
|
||||
|
||||
is.boundFunction(function () {});
|
||||
// => false
|
||||
```
|
||||
|
||||
##### .map(value)
|
||||
##### .set(value)
|
||||
##### .weakMap(value)
|
||||
##### .weakSet(value)
|
||||
|
||||
#### Typed arrays
|
||||
|
||||
##### .int8Array(value)
|
||||
##### .uint8Array(value)
|
||||
##### .uint8ClampedArray(value)
|
||||
##### .int16Array(value)
|
||||
##### .uint16Array(value)
|
||||
##### .int32Array(value)
|
||||
##### .uint32Array(value)
|
||||
##### .float32Array(value)
|
||||
##### .float64Array(value)
|
||||
|
||||
#### Structured data
|
||||
|
||||
##### .arrayBuffer(value)
|
||||
##### .sharedArrayBuffer(value)
|
||||
##### .dataView(value)
|
||||
|
||||
#### Emptiness
|
||||
|
||||
##### .emptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is 0.
|
||||
|
||||
##### .nonEmptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyStringOrWhitespace(value)
|
||||
|
||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||
|
||||
##### .emptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is 0.
|
||||
|
||||
##### .nonEmptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
||||
|
||||
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
||||
|
||||
```js
|
||||
const object1 = {};
|
||||
|
||||
Object.defineProperty(object1, 'property1', {
|
||||
value: 42,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
is.emptyObject(object1);
|
||||
// => true
|
||||
```
|
||||
|
||||
##### .nonEmptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
||||
|
||||
##### .emptySet(value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptySet(Value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
||||
|
||||
##### .emptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
||||
|
||||
#### Miscellaneous
|
||||
|
||||
##### .directInstanceOf(value, class)
|
||||
|
||||
Returns `true` if `value` is a direct instance of `class`.
|
||||
|
||||
```js
|
||||
is.directInstanceOf(new Error(), Error);
|
||||
//=> true
|
||||
|
||||
class UnicornError extends Error {}
|
||||
|
||||
is.directInstanceOf(new UnicornError(), Error);
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .urlInstance(value)
|
||||
|
||||
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
||||
|
||||
```js
|
||||
const url = new URL('https://example.com');
|
||||
|
||||
is.urlInstance(url);
|
||||
//=> true
|
||||
```
|
||||
|
||||
### .url(value)
|
||||
|
||||
Returns `true` if `value` is a URL string.
|
||||
|
||||
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
||||
|
||||
```js
|
||||
const url = 'https://example.com';
|
||||
|
||||
is.url(url);
|
||||
//=> true
|
||||
|
||||
is.url(new URL(url));
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .truthy(value)
|
||||
|
||||
Returns `true` for all values that evaluate to true in a boolean context:
|
||||
|
||||
```js
|
||||
is.truthy('🦄');
|
||||
//=> true
|
||||
|
||||
is.truthy(undefined);
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .falsy(value)
|
||||
|
||||
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
|
||||
|
||||
##### .nan(value)
|
||||
##### .nullOrUndefined(value)
|
||||
##### .primitive(value)
|
||||
|
||||
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
|
||||
|
||||
##### .integer(value)
|
||||
|
||||
##### .safeInteger(value)
|
||||
|
||||
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||
|
||||
##### .plainObject(value)
|
||||
|
||||
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||
|
||||
##### .iterable(value)
|
||||
##### .asyncIterable(value)
|
||||
##### .class(value)
|
||||
|
||||
Returns `true` for instances created by a class.
|
||||
|
||||
##### .typedArray(value)
|
||||
|
||||
##### .arrayLike(value)
|
||||
|
||||
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
|
||||
|
||||
```js
|
||||
is.arrayLike(document.forms);
|
||||
//=> true
|
||||
|
||||
function foo() {
|
||||
is.arrayLike(arguments);
|
||||
//=> true
|
||||
}
|
||||
foo();
|
||||
```
|
||||
|
||||
##### .inRange(value, range)
|
||||
|
||||
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
|
||||
|
||||
```js
|
||||
is.inRange(3, [0, 5]);
|
||||
is.inRange(3, [5, 0]);
|
||||
is.inRange(0, [-2, 2]);
|
||||
```
|
||||
|
||||
##### .inRange(value, upperBound)
|
||||
|
||||
Check if `value` (number) is in the range of `0` to `upperBound`.
|
||||
|
||||
```js
|
||||
is.inRange(3, 10);
|
||||
```
|
||||
|
||||
##### .domElement(value)
|
||||
|
||||
Returns `true` if `value` is a DOM Element.
|
||||
|
||||
##### .nodeStream(value)
|
||||
|
||||
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
|
||||
is.nodeStream(fs.createReadStream('unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .observable(value)
|
||||
|
||||
Returns `true` if `value` is an `Observable`.
|
||||
|
||||
```js
|
||||
const {Observable} = require('rxjs');
|
||||
|
||||
is.observable(new Observable());
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .infinite(value)
|
||||
|
||||
Check if `value` is `Infinity` or `-Infinity`.
|
||||
|
||||
##### .even(value)
|
||||
|
||||
Returns `true` if `value` is an even integer.
|
||||
|
||||
##### .odd(value)
|
||||
|
||||
Returns `true` if `value` is an odd integer.
|
||||
|
||||
##### .any(predicate, ...values)
|
||||
|
||||
Returns `true` if **any** of the input `values` returns true in the `predicate`:
|
||||
|
||||
```js
|
||||
is.any(is.string, {}, true, '🦄');
|
||||
//=> true
|
||||
|
||||
is.any(is.boolean, 'unicorns', [], new Map());
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .all(predicate, ...values)
|
||||
|
||||
Returns `true` if **all** of the input `values` returns true in the `predicate`:
|
||||
|
||||
```js
|
||||
is.all(is.object, {}, new Map(), new Set());
|
||||
//=> true
|
||||
|
||||
is.all(is.string, '🦄', [], 'unicorns');
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why yet another type checking module?
|
||||
|
||||
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
|
||||
|
||||
- Includes both type methods and ability to get the type
|
||||
- Types of primitives returned as lowercase and object types as camelcase
|
||||
- Covers all built-ins
|
||||
- Unsurprising behavior
|
||||
- Well-maintained
|
||||
- Comprehensive test suite
|
||||
|
||||
For the ones I found, pick 3 of these.
|
||||
|
||||
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
||||
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
|
||||
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
|
||||
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
|
||||
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
||||
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
|
||||
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
|
||||
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
|
||||
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
|
||||
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
|
||||
|
||||
|
||||
## Created by
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Giora Guttsait](https://github.com/gioragutt)
|
||||
- [Brandon Smith](https://github.com/brandon93s)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
const Readable = require('stream').Readable;
|
||||
const lowercaseKeys = require('lowercase-keys');
|
||||
|
||||
class Response extends Readable {
|
||||
constructor(statusCode, headers, body, url) {
|
||||
if (typeof statusCode !== 'number') {
|
||||
throw new TypeError('Argument `statusCode` should be a number');
|
||||
}
|
||||
if (typeof headers !== 'object') {
|
||||
throw new TypeError('Argument `headers` should be an object');
|
||||
}
|
||||
if (!(body instanceof Buffer)) {
|
||||
throw new TypeError('Argument `body` should be a buffer');
|
||||
}
|
||||
if (typeof url !== 'string') {
|
||||
throw new TypeError('Argument `url` should be a string');
|
||||
}
|
||||
|
||||
super();
|
||||
this.statusCode = statusCode;
|
||||
this.headers = lowercaseKeys(headers);
|
||||
this.body = body;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
_read() {
|
||||
this.push(this.body);
|
||||
this.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Response;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0.00342,"27":0,"28":0,"29":0,"30":0.00342,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.00342,"48":0,"49":0,"50":0,"51":0,"52":0.01369,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0.00342,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00342,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00342,"92":0,"93":0,"94":0,"95":0,"96":0.00342,"97":0,"98":0,"99":0.00342,"100":0,"101":0,"102":0.00684,"103":0.00342,"104":0.00342,"105":0.00684,"106":0.00684,"107":0.01369,"108":0.6844,"109":0.3114,"110":0.00342,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.00342,"35":0,"36":0,"37":0,"38":0.00342,"39":0,"40":0.00342,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.00342,"48":0,"49":0.01027,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0.00342,"56":0.00342,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0.00342,"66":0,"67":0.00342,"68":0.00342,"69":0.00342,"70":0.00342,"71":0.00342,"72":0.00684,"73":0.00342,"74":0.00342,"75":0,"76":0,"77":0,"78":0.00342,"79":0.01369,"80":0.00684,"81":0.02053,"83":0.00342,"84":0.01027,"85":0.00684,"86":0.01369,"87":0.01027,"88":0.00342,"89":0.00342,"90":0.00342,"91":0.01711,"92":0.01027,"93":0.00342,"94":0.00342,"95":0.01027,"96":0.01027,"97":0.00684,"98":0.00684,"99":0.00342,"100":0.01711,"101":0.00684,"102":0.01711,"103":0.0616,"104":0.01027,"105":0.0308,"106":0.02738,"107":0.07871,"108":3.40147,"109":3.41516,"110":0,"111":0.00342,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0.00342,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.00342,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0.00342,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.08213,"94":0.12661,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00342,"13":0,"14":0,"15":0,"16":0,"17":0.00342,"18":0.01027,"79":0,"80":0,"81":0,"83":0,"84":0.00342,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00684,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0.00342,"106":0.00342,"107":0.0308,"108":0.46881,"109":0.43117},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.00342,"14":0.02738,"15":0.00342,_:"0","3.1":0,"3.2":0,"5.1":0.12661,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0.00684,"12.1":0.01369,"13.1":0.02738,"14.1":0.09239,"15.1":0.01027,"15.2-15.3":0.02053,"15.4":0.0308,"15.5":0.07186,"15.6":0.22243,"16.0":0.02738,"16.1":0.08897,"16.2":0.21901,"16.3":0.01711},G:{"8":0.03044,"3.2":0,"4.0-4.1":0.01268,"4.2-4.3":0.04312,"5.0-5.1":0.00254,"6.0-6.1":0.01268,"7.0-7.1":0.05581,"8.1-8.4":0.03044,"9.0-9.2":0.03551,"9.3":0.11922,"10.0-10.2":0.07864,"10.3":0.22069,"11.0-11.2":0.10908,"11.3-11.4":0.10147,"12.0-12.1":0.11922,"12.2-12.5":1.0933,"13.0-13.1":0.06849,"13.2":0.03551,"13.3":0.17757,"13.4-13.7":0.32469,"14.0-14.4":0.47182,"14.5-14.8":0.91827,"15.0-15.1":0.25113,"15.2-15.3":0.35767,"15.4":0.41348,"15.5":0.91827,"15.6":2.40475,"16.0":3.77963,"16.1":6.3036,"16.2":4.43662,"16.3":0.36274},P:{"4":0.13319,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.18442,"8.2":0,"9.2":0.02049,"10.1":0,"11.1-11.2":0.07172,"12.0":0.03074,"13.0":0.1127,"14.0":0.09221,"15.0":0.07172,"16.0":0.20491,"17.0":0.25614,"18.0":0.23565,"19.0":4.27241},I:{"0":0,"3":0,"4":0.00476,"2.1":0,"2.2":0,"2.3":0.00476,"4.1":0.00793,"4.2-4.3":0.02063,"4.4":0,"4.4.3-4.4.4":0.1301},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.0075,"9":0.00375,"10":0.00375,"11":0.06371,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0.17103},Q:{"13.1":0},O:{"0":0.24339},H:{"0":0.30515},L:{"0":56.91722},S:{"2.5":0}};
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operator/debounce';
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/observeOn"));
|
||||
//# sourceMappingURL=observeOn.js.map
|
||||
@@ -0,0 +1,132 @@
|
||||
/** PURE_IMPORTS_START tslib,_Subscriber,_Observable,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
|
||||
import * as tslib_1 from "tslib";
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { Observable } from '../Observable';
|
||||
import { OuterSubscriber } from '../OuterSubscriber';
|
||||
import { subscribeToResult } from '../util/subscribeToResult';
|
||||
export function delayWhen(delayDurationSelector, subscriptionDelay) {
|
||||
if (subscriptionDelay) {
|
||||
return function (source) {
|
||||
return new SubscriptionDelayObservable(source, subscriptionDelay)
|
||||
.lift(new DelayWhenOperator(delayDurationSelector));
|
||||
};
|
||||
}
|
||||
return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
|
||||
}
|
||||
var DelayWhenOperator = /*@__PURE__*/ (function () {
|
||||
function DelayWhenOperator(delayDurationSelector) {
|
||||
this.delayDurationSelector = delayDurationSelector;
|
||||
}
|
||||
DelayWhenOperator.prototype.call = function (subscriber, source) {
|
||||
return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
|
||||
};
|
||||
return DelayWhenOperator;
|
||||
}());
|
||||
var DelayWhenSubscriber = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(DelayWhenSubscriber, _super);
|
||||
function DelayWhenSubscriber(destination, delayDurationSelector) {
|
||||
var _this = _super.call(this, destination) || this;
|
||||
_this.delayDurationSelector = delayDurationSelector;
|
||||
_this.completed = false;
|
||||
_this.delayNotifierSubscriptions = [];
|
||||
_this.index = 0;
|
||||
return _this;
|
||||
}
|
||||
DelayWhenSubscriber.prototype.notifyNext = function (outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
|
||||
this.destination.next(outerValue);
|
||||
this.removeSubscription(innerSub);
|
||||
this.tryComplete();
|
||||
};
|
||||
DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
|
||||
this._error(error);
|
||||
};
|
||||
DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
|
||||
var value = this.removeSubscription(innerSub);
|
||||
if (value) {
|
||||
this.destination.next(value);
|
||||
}
|
||||
this.tryComplete();
|
||||
};
|
||||
DelayWhenSubscriber.prototype._next = function (value) {
|
||||
var index = this.index++;
|
||||
try {
|
||||
var delayNotifier = this.delayDurationSelector(value, index);
|
||||
if (delayNotifier) {
|
||||
this.tryDelay(delayNotifier, value);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.destination.error(err);
|
||||
}
|
||||
};
|
||||
DelayWhenSubscriber.prototype._complete = function () {
|
||||
this.completed = true;
|
||||
this.tryComplete();
|
||||
this.unsubscribe();
|
||||
};
|
||||
DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
|
||||
subscription.unsubscribe();
|
||||
var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
|
||||
if (subscriptionIdx !== -1) {
|
||||
this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
|
||||
}
|
||||
return subscription.outerValue;
|
||||
};
|
||||
DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
|
||||
var notifierSubscription = subscribeToResult(this, delayNotifier, value);
|
||||
if (notifierSubscription && !notifierSubscription.closed) {
|
||||
var destination = this.destination;
|
||||
destination.add(notifierSubscription);
|
||||
this.delayNotifierSubscriptions.push(notifierSubscription);
|
||||
}
|
||||
};
|
||||
DelayWhenSubscriber.prototype.tryComplete = function () {
|
||||
if (this.completed && this.delayNotifierSubscriptions.length === 0) {
|
||||
this.destination.complete();
|
||||
}
|
||||
};
|
||||
return DelayWhenSubscriber;
|
||||
}(OuterSubscriber));
|
||||
var SubscriptionDelayObservable = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(SubscriptionDelayObservable, _super);
|
||||
function SubscriptionDelayObservable(source, subscriptionDelay) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.source = source;
|
||||
_this.subscriptionDelay = subscriptionDelay;
|
||||
return _this;
|
||||
}
|
||||
SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
|
||||
this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
|
||||
};
|
||||
return SubscriptionDelayObservable;
|
||||
}(Observable));
|
||||
var SubscriptionDelaySubscriber = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(SubscriptionDelaySubscriber, _super);
|
||||
function SubscriptionDelaySubscriber(parent, source) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.parent = parent;
|
||||
_this.source = source;
|
||||
_this.sourceSubscribed = false;
|
||||
return _this;
|
||||
}
|
||||
SubscriptionDelaySubscriber.prototype._next = function (unused) {
|
||||
this.subscribeToSource();
|
||||
};
|
||||
SubscriptionDelaySubscriber.prototype._error = function (err) {
|
||||
this.unsubscribe();
|
||||
this.parent.error(err);
|
||||
};
|
||||
SubscriptionDelaySubscriber.prototype._complete = function () {
|
||||
this.unsubscribe();
|
||||
this.subscribeToSource();
|
||||
};
|
||||
SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
|
||||
if (!this.sourceSubscribed) {
|
||||
this.sourceSubscribed = true;
|
||||
this.unsubscribe();
|
||||
this.source.subscribe(this.parent);
|
||||
}
|
||||
};
|
||||
return SubscriptionDelaySubscriber;
|
||||
}(Subscriber));
|
||||
//# sourceMappingURL=delayWhen.js.map
|
||||
Reference in New Issue
Block a user