upstream merge

This commit is contained in:
Zev Spitz
2018-02-05 08:20:02 +02:00
621 changed files with 17979 additions and 121147 deletions
+6
View File
@@ -1590,6 +1590,12 @@
"sourceRepoURL": "https://github.com/sourcelair/xterm.js/",
"asOfVersion": "3.0.0"
},
{
"libraryName": "yFiles for HTML",
"typingsPackageName": "yfiles",
"sourceRepoURL": "none",
"asOfVersion": "2.1.0"
},
{
"libraryName": "zetapush-js",
"typingsPackageName": "zetapush-js",
@@ -0,0 +1,44 @@
const collectionToArray = <T>(col: any) => { // tslint:disable-line no-unnecessary-generics
const results: T[] = [];
const enumerator = new Enumerator<T>(col);
enumerator.moveFirst();
while (!enumerator.atEnd()) {
results.push(enumerator.item());
enumerator.moveNext();
}
return results;
};
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787925(v=vs.85).aspx
(() => {
const enumUsers = (label: string) => {
const volume = new ActiveXObject('Microsoft.DiskQuota');
volume.Initialize(label, true);
collectionToArray<DiskQuotaTypeLibrary.DIDiskQuotaUser>(volume).forEach(x => {
// Use the QuotaUser object to retrieve or set one or more of the user's disk quota properties
});
};
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787916(v=vs.85).aspx
(() => {
const volume = new ActiveXObject('Microsoft.DiskQuota');
volume.Initialize('MYDISK', true);
ActiveXObject.on(volume, 'OnUserNameChanged', ['pUser'], p => {
// Code to handle the event.
});
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787904(v=vs.85).aspx
(() => {
const dqc = new ActiveXObject('Microsoft.DiskQuota');
dqc.Initialize('MYDISK', true);
const findName = (name: string) => {
try {
return dqc.FindUser(name);
} catch { }
try {
return dqc.FindUser(dqc.TranslateLogonNameToSID(name));
} catch { }
};
})();
+152
View File
@@ -0,0 +1,152 @@
// Type definitions for DiskQuotaTypeLibrary 1.0
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773938(v=vs.85).aspx
// Definitions by: Zev Spitz <https://github.com/zspitz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.5
declare namespace DiskQuotaTypeLibrary {
// tslint:disable-next-line no-const-enum
const enum AccountStatusConstants {
dqAcctDeleted = 2,
dqAcctInvalid = 3,
dqAcctResolved = 0,
dqAcctUnavailable = 1,
dqAcctUnknown = 4,
dqAcctUnresolved = 5,
}
// tslint:disable-next-line no-const-enum
const enum QuotaStateConstants {
dqStateDisable = 0,
dqStateEnforce = 2,
dqStateTrack = 1,
}
// tslint:disable-next-line no-const-enum
const enum UserNameResolutionConstants {
dqResolveAsync = 2,
dqResolveNone = 0,
dqResolveSync = 1,
}
/** Automation interface for DiskQuotaUser */
class DIDiskQuotaUser {
private 'DiskQuotaTypeLibrary.DIDiskQuotaUser_typekey': DIDiskQuotaUser;
private constructor();
/** Name of user's account container */
readonly AccountContainerName: string;
/** Status of user's account */
readonly AccountStatus: AccountStatusConstants;
/** User's display name */
readonly DisplayName: string;
/** Unique ID number */
readonly ID: number;
/** Invalidate data cached in user object */
Invalidate(): void;
/** User's logon account name */
readonly LogonName: string;
/** User's quota limit (bytes) */
QuotaLimit: number;
/** User's quota limit (text) */
readonly QuotaLimitText: string;
/** User's quota warning threshold (bytes) */
QuotaThreshold: number;
/** User's quota warning threshold (text) */
readonly QuotaThresholdText: string;
/** Quota charged to user (bytes) */
readonly QuotaUsed: number;
/** Quota charged to user (text) */
readonly QuotaUsedText: string;
}
/** Microsoft Disk Quota */
class DiskQuotaControl {
private 'DiskQuotaTypeLibrary.DiskQuotaControl_typekey': DiskQuotaControl;
private constructor();
/** Add a user quota entry by Name */
AddUser(LogonName: string): DIDiskQuotaUser;
/** Default quota limit applied to new volume users (byte value) */
DefaultQuotaLimit: number;
/** Default quota limit applied to new volume users (text string) */
readonly DefaultQuotaLimitText: string;
/** Default warning threshold applied to new volume users (byte value) */
DefaultQuotaThreshold: number;
/** Default warning threshold applied to new volume users (text string) */
readonly DefaultQuotaThresholdText: string;
/** Delete a user quota entry */
DeleteUser(pUser: DIDiskQuotaUser): void;
/** Find a user quota entry by Name */
FindUser(LogonName: string): DIDiskQuotaUser;
/** Promote a user quota entry to the head of the name resolution queue */
GiveUserNameResolutionPriority(pUser: DIDiskQuotaUser): void;
/** Initialize the quota control object for a specified volume */
Initialize(path: string, bReadWrite: boolean): void;
/** Invalidate the cache of user name information */
InvalidateSidNameCache(): void;
/** Write event log entry when user exceeds quota limit */
LogQuotaLimit: boolean;
/** Write event log entry when user exceeds quota warning threshold */
LogQuotaThreshold: boolean;
/** Indicates if quota information is out of date */
readonly QuotaFileIncomplete: boolean;
/** Indicates if quota information is being rebuilt */
readonly QuotaFileRebuilding: boolean;
/** State of the volume's disk quota system */
QuotaState: QuotaStateConstants;
/** Terminate the user name resolution thread */
ShutdownNameResolution(): void;
/** Translates a user logon name to a security ID */
TranslateLogonNameToSID(LogonName: string): string;
/** Control the resolution of user Security IDs to user Names */
UserNameResolution: UserNameResolutionConstants;
}
}
interface ActiveXObject {
on(
obj: DiskQuotaTypeLibrary.DiskQuotaControl, event: 'OnUserNameChanged', argNames: ['pUser'], handler: (
this: DiskQuotaTypeLibrary.DiskQuotaControl, parameter: {readonly pUser: DiskQuotaTypeLibrary.DIDiskQuotaUser}) => void): void;
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
}
interface ActiveXObjectNameMap {
'Microsoft.DiskQuota': DiskQuotaTypeLibrary.DiskQuotaControl;
}
interface EnumeratorConstructor {
new(col: DiskQuotaTypeLibrary.DiskQuotaControl): Enumerator<DiskQuotaTypeLibrary.DIDiskQuotaUser>;
}
interface SafeArray<T = any> {
_brand: SafeArray<T>;
}
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es5", "scripthost"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"activex-diskquota-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -0,0 +1,12 @@
// https://msdn.microsoft.com/en-us/library/aa752044(v=vs.85).aspx
(() => {
const ie = new ActiveXObject('InternetExplorer.Application');
ie.Navigate('http://contoso.com');
ie.Visible = true;
})();
let obj1 = new ActiveXObject('ShellNameSpace.ShellNameSpace');
let obj2 = new ActiveXObject('Shell.UIHelper');
let obj3 = new ActiveXObject('Shell.Explorer');
+1577
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es5", "scripthost"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"activex-shdocvw-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+489
View File
@@ -0,0 +1,489 @@
/// <reference types="activex-iwshruntimelibrary" />
const shell = new ActiveXObject('Shell.Application');
const getWindowsFolder = () => shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfWINDOWS);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537735(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
if (!folder) { return; }
const folderItem = folder.ParseName('system.ini');
if (!folderItem) { return; }
shell.AddToRecent(folderItem.Path);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx
(() => {
const folder = shell.BrowseForFolder(0, 'Example', 0, Shell32.ShellSpecialFolderConstants.ssfWINDOWS);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537736(v=vs.85).aspx
const canStartStop = shell.CanStartStopService('service name');
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774069(v=vs.85).aspx
shell.ControlPanelItem('desk.cpl');
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774073(v=vs.85).aspx
shell.Explore('C:\\');
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537737(v=vs.85).aspx
const explorerPolicy = shell.ExplorerPolicy('ValueName');
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537739(v=vs.85).aspx
const settingValue = shell.GetSetting(Shell32.SettingKey.SSF_SHOWALLOBJECTS);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537740(v=vs.85).aspx
const processorLevel = shell.GetSystemInformation('ProcessorLevel');
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537741(v=vs.85).aspx
const isRestricted = shell.IsRestricted('system', 'undockwithoutlogon');
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537742(v=vs.85).aspx
const isServiceRunning = shell.IsServiceRunning('Themes');
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774086(v=vs.85).aspx
shell.Open(Shell32.ShellSpecialFolderConstants.ssfWINDOWS);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537743(v=vs.85).aspx
shell.ServiceStart('Messenger', true);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537744(v=vs.85).aspx
shell.ServiceStop('Messenger', true);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537745(v=vs.85).aspx
shell.ShellExecute("notepad.exe", "", "", "open", Shell32.ShellExecuteShow.Normal);
// https://msdn.microsoft.com/en-us/library/windows/desktop/gg537746(v=vs.85).aspx?cs-save-lang=1&cs-lang=jscript#code-snippet-1
shell.ShowBrowserBar(Shell32.ExplorerBarCLSID.Favorites, true);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774107(v=vs.85).aspx
const wshShell = new ActiveXObject('WScript.Shell');
wshShell.Popup(shell.Windows().Count);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx
shell.NameSpace(`c:\\windows`)!.CopyHere('c:\\autoexec.bat');
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
(() => {
const folder = shell.NameSpace('c:\\windows');
const folderItem = folder ? folder.ParseName('clock.avi') : undefined;
if (folder && folderItem) {
const info = folder.GetDetailsOf(folderItem, Shell32.FileSystemDetails.Type);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787874(v=vs.85).aspx
shell.NameSpace('c:\\windows')!.MoveHere('c:\\temp.txt', Shell32.FileOperationFlag.FOF_NOCONFIRMATION);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787876(v=vs.85).aspx
shell.NameSpace('c:\\')!.NewFolder('TestFolder');
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787858(v=vs.85).aspx
(() => {
const folder = shell.NameSpace("\\\\server\\share\\folder");
const offlineStatus = folder ? folder.OfflineStatus : undefined;
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787880(v=vs.85).aspx
(() => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfPROGRAMS);
WScript.Echo(folder!.ParentFolder.Title);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787860(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787816(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787850(v=vs.85).aspx
(() => {
const folder = shell.NameSpace('C:\\WINDOWS');
const folderItem = folder ? folder.Self : undefined;
if (folderItem) {
const verbs = folderItem.Verbs();
folderItem.InvokeVerb();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787812(v=vs.85).aspx
(() => {
const parentFolder = getWindowsFolder();
const folderItem = parentFolder ? parentFolder.ParseName('system32') : undefined;
const folder = folderItem ? folderItem.GetFolder : undefined;
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787814(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787824(v=vs.85).aspx
(() => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfPROGRAMS);
const folderItem = folder ? folder.ParseName('Internet Explorer.lnk') : undefined;
if (folderItem && folderItem.IsLink) {
const link = folderItem.GetLink;
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787818(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787819(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787821(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder ? folder.Self : undefined;
if (folderItem) {
const isBrowsable = folderItem.IsBrowsable;
const isFileSystem = folderItem.IsFileSystem;
const isFolder = folderItem.IsFolder;
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787825(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder!.ParseName('notepad.exe');
if (folderItem) {
const oldDate = folderItem.ModifyDate;
folderItem.ModifyDate = new Date(1900, 1, 1, 18, 5).getVarDate();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787827(v=vs.85).aspx
(() => {
const rootFolder = shell.NameSpace('C:\\');
const folderItem = rootFolder ? rootFolder.ParseName('autoexec.bat') : undefined;
if (folderItem) {
const oldName = folderItem.Name;
folderItem.Name = 'test.bat';
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787829(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder ? folder.Self : undefined;
const parent = folderItem ? folderItem.Parent : undefined;
if (parent) {
WScript.Echo('Got parent object');
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787844(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder ? folder.Self : undefined;
const path = folderItem ? folderItem.Path : '';
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787846(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder!.ParseName('notepad.exe');
const size = folderItem ? folderItem.Size : undefined;
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787848(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
if (folder) {
WScript.Echo(folder.Self.Type);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787798(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItems = folder ? folder.Items() : undefined;
const count = folderItems ? folderItems.Count : undefined;
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787794(v=vs.85).aspx
(() => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDRIVES);
if (folder) {
folder.Items().InvokeVerbEx();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774170(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774174(v=vs.85).aspx
(() => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfPROGRAMS);
const verbs = folder ? folder.Self.Verbs() : undefined;
if (verbs) {
const verb = verbs.Item(0);
WScript.Echo(verb.Name);
verb.DoIt();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787787(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
if (folder) {
const folderItems = folder.Items();
WScript.Echo(folderItems.Count);
folderItems.Filter(Shell32.ShellFolderEnumerationFlags.SHCONTF_NONFOLDERS, '*.txt');
WScript.Echo(folderItems.Count);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787791(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774162(v=vs.85).aspx
(() => {
const echoFirstVerbName = (folder: Shell32.Folder3 | null) => {
if (!folder) { return; }
const verbs = folder.Items().Verbs;
WScript.Echo(verbs.Item(0).Name);
};
let folder = getWindowsFolder();
echoFirstVerbName(folder);
folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfCONTROLS);
echoFirstVerbName(folder);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774158(v=vs.85).aspx
(() => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfCONTROLS);
if (folder) {
const verbs = folder.Self.Verbs();
WScript.Echo(verbs.Count);
}
})();
const getIELink = () => {
const folder = shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfPROGRAMS);
const folderItem = folder ? folder.ParseName('Internet Explorer.lnk') : undefined;
return {
link: folderItem ? folderItem.GetLink : undefined,
folderItem
};
};
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773990(v=vs.85).aspx
(() => {
const { link, folderItem } = getIELink();
if (link && folderItem) {
WScript.Echo(link.GetIconLocation(folderItem.Path));
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773996(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
link.Resolve(Shell32.ShellLinkResolveFlags.NoUI);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773998(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
link.Description = 'New Description';
link.Save();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774002(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
link.SetIconLocation(link.Path, 1);
link.Save();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773986(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
WScript.Echo(link.Arguments);
link.Arguments = '/s';
link.Save();
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773988(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
WScript.Echo(link.Description);
link.Description = 'Test';
link.Save();
}
})();
const parseHotkey = (hotkey: number) => {
// missing implementation
return {
shift: false,
ctrl: false,
alt: false,
extended: false,
hotkey
};
};
const buildHotkey = (hotkey: number, shift: boolean = false, ctrl: boolean = false, alt: boolean = false, extended: boolean = false) => {
// missing implementation
return 0;
};
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773992(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
const { hotkey } = parseHotkey(link.Hotkey);
WScript.Echo(hotkey);
link.Hotkey = buildHotkey(4);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773994(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
WScript.Echo(link.Path);
link.Path = 'C:\\Program Files\\IE\\IEXPLORE.EXE';
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774006(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
WScript.Echo(link.ShowCommand);
link.ShowCommand = Shell32.LinkShowWindowState.Normal;
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774008(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
WScript.Echo(link.WorkingDirectory);
link.WorkingDirectory = '';
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774115(v=vs.85).aspx
(() => {
const { link } = getIELink();
if (link) {
const target = link.Target;
if (target) {
WScript.Echo(target.Size);
}
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774055(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder ? folder.ParseName('notepad.exe') : undefined;
if (folderItem) {
WScript.Echo(folderItem.ExtendedProperty('infotip'));
}
const wordDoc = shell.NameSpace('C:\\')!.ParseName('test.doc');
if (wordDoc) {
const FMTID_SummaryInfo = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}";
const PID_TITLE = "2";
const PID_AUTHOR = "4";
const SCID_TITLE = `${FMTID_SummaryInfo} ${PID_TITLE}`;
const SCID_AUTHOR = `${FMTID_SummaryInfo} ${PID_AUTHOR}`;
const docTitle = wordDoc.ExtendedProperty(SCID_TITLE);
const docAuthor = wordDoc.ExtendedProperty(SCID_AUTHOR);
}
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774057(v=vs.85).aspx
(() => {
const folder = getWindowsFolder();
const folderItem = folder ? folder.ParseName('notepad.exe') : undefined;
if (folderItem) {
folderItem.InvokeVerbEx("open", "c:\\autoexec.bat");
}
})();
const collectionToArray = <T>(col: any): T[] => { // tslint:disable-line no-unnecessary-generics
const results: T[] = [];
const enumerator = new Enumerator<T>(col);
enumerator.moveFirst();
while (!enumerator.atEnd()) {
results.push(enumerator.item());
enumerator.moveNext();
}
return results;
};
interface String {
endsWith(searchString: string, length?: number): boolean;
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(search, this_len) {
if (this_len === undefined || this_len > this.length) {
this_len = this.length;
}
return this.substring(this_len - search.length, this_len) === search;
};
}
// shell.Windows() includes items other than Explorer windows, such as Internet Explorer tabs
const getExplorerWindows = () =>
collectionToArray<SHDocVw.InternetExplorer>(shell.Windows())
.filter(x => x.FullName.toLowerCase().endsWith('explorer.exe'));
const getFolderViews = () =>
getExplorerWindows()
.map(x => x.Document as Shell32.ShellFolderView);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774045(v=vs.85).aspx
(() => {
getFolderViews().forEach(x =>
ActiveXObject.on(x, 'SelectionChanged', function(this: Shell32.ShellFolderView) {
WScript.Echo(`Selection change in ${this.Folder.Title} -- count: ${this.SelectedItems().Count}`);
})
);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773970(v=vs.85).aspx
WScript.Echo(shell.Windows().Item().Path);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb773969(v=vs.85).aspx
WScript.Echo(shell.Windows().Count);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774043(v=vs.85).aspx
(() => {
getFolderViews().forEach(x =>
WScript.Echo(`${x.Folder.Title} -- ${x.SelectedItems().Count} selected items`)
);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774047(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774022(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774053(v=vs.85).aspx
(() => {
const folderView = getExplorerWindows()[0].Document as Shell32.ShellFolderView;
const folder = folderView.Folder;
if (folder) {
const folderItem = folder.Self;
folderView.SelectItem(folder.Self, Shell32.ShellFolderViewSelectItem.Focus);
}
WScript.Echo(folderView.ViewOptions);
})();
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774020(v=vs.85).aspx
(() => {
const folderView = getExplorerWindows()[0].Document as Shell32.ShellFolderView;
const focusedItem = folderView.FocusedItem;
if (focusedItem) {
WScript.Echo(`Focused item in first Excplorer window -- ${focusedItem.Path}`);
}
})();
(() => {
const router = new ActiveXObject('Shell.FolderView');
const folder = getFolderViews()[0];
router.SetFolderView(folder);
ActiveXObject.on(router, 'EnumDone', () => WScript.Echo('Current folder view was finisehd enumerating'));
ActiveXObject.on(router, 'SelectionChanged', () => WScript.Echo('Selection changed in current folder view'));
// the folder view monitored by the ShellFolderViewOC object can be changed via SetFolderView without disconnecting and reconnecting the handlers
})();
+1016
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es5", "scripthost"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"activex-shell-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+2
View File
@@ -110,6 +110,8 @@ declare namespace adone {
export function require(path: string): object;
export const package: object;
export function sprintf(format: string, ...args: any[]): string;
namespace I {
interface Runtime {
term: object; // TODO
+271 -1
View File
@@ -1,5 +1,275 @@
declare namespace adone {
namespace application {
function run(app: object, ignoreArgs?: boolean): Promise<void>;
namespace I {
type ArgumentType = ((x: string, index: number) => any) | RegExp;
interface ArgumentInfo {
name: string | string[];
action?: "store"
| "store_const"
| "store_true"
| "store_false"
| "append"
| "count"
| "set";
nargs?: number | "+" | "*" | "?"
type?: ArgumentType | ArgumentType[];
verify?: (args: any, opts: any) => boolean; // TODO
required?: boolean;
description?: string;
help?: string;
holder?: string | string[];
appendDefaultMessage?: boolean;
appendChoicesHelpMessage?: boolean;
default?: any;
enabled?: boolean;
}
interface Group {
name: string;
description?: string;
}
interface MainCommandInfo {
arguments?: Array<ArgumentInfo | string>;
options?: Array<ArgumentInfo | string>;
description?: string;
optionsGroups?: Group[];
blindMode?: boolean;
match?: (name: string) => boolean;
handler?: (args: object, opts: object) => void;
}
interface CommandInfo extends MainCommandInfo {
name?: string | string[];
group?: string;
}
interface ApplicationInfo {
name?: string;
description?: string;
subsystems?: SubsystemInfo[];
commandsGroups?: Group[]
}
interface SubsystemInfo {
name: string;
description?: string;
subsystem: string;
transpile?: boolean;
group?: string;
}
}
function DSubsystem(info?: I.ApplicationInfo): (...args: any[]) => void;
function DApplication(info?: I.ApplicationInfo): (...args: any[]) => void;
function DCliCommand(info?: I.CommandInfo): (...args: any[]) => void;
function DMainCliCommand(info?: I.MainCommandInfo): (...args: any[]) => void;
namespace I {
interface LoadSubsystemOptions {
name?: string,
description?: string,
group?: string,
transpile?: boolean
}
interface CommonAddSubsystemInfo {
name?: string,
useFilename?: boolean
description?: string,
group?: string,
configureArgs?: any[]
transpile?: boolean,
bind?: boolean | string
}
interface AddSubsystemInfo extends CommonAddSubsystemInfo {
subsystem: Subsystem | string,
}
interface SysInfo {
name: string;
description: string;
group: string;
configureArgs: any[];
instance: Subsystem;
path: string | null;
}
interface SysInfoWithPath extends SysInfo {
path: string;
}
interface SysInfoNoPath extends SysInfo {
path: null;
}
interface AddSubsystemsFromOptions extends CommonAddSubsystemInfo {
filter?: string[] | ((file: string) => boolean | Promise<boolean>)
}
}
class Subsystem extends event.AsyncEmitter {
constructor(options?: { name?: string });
readonly name?: string;
readonly root?: Subsystem;
setRoot(root: Subsystem): void;
readonly parent?: Subsystem;
readonly state: number;
readonly isOwned: boolean;
setState(state: number): void;
waitForState(expectedState: number, timeout?: number): Promise<void>;
configure(): void;
initialize(): void;
uninitialize(): void;
configureSubsystems(): Promise<void>;
uninitializeSubsystems(): Promise<void>;
reinitializeSubsystems(): Promise<void>;
configureSubsystem(name: string): Promise<void>;
loadSubsystem(subsystem: string | Subsystem, options?: I.LoadSubsystemOptions): Promise<void>;
unloadSubsystem(name: string): Promise<void>;
initializeSubsystem(name: string): Promise<void>;
uninitializeSubsystem(name: string): Promise<void>;
reinitializeSubsystem(name: string): Promise<void>;
getSubsystem(name: string): Subsystem;
hasSubsystem(name: string): boolean;
hasSubsystems(): boolean;
addSubsystem(info: I.AddSubsystemInfo & { subsystem: Subsystem }): I.SysInfoNoPath;
addSubsystem(info: I.AddSubsystemInfo & { subsystem: string }): I.SysInfoWithPath;
addSubsystemsFrom(path: string, options?: I.AddSubsystemsFromOptions): I.SysInfoWithPath;
instantiateSubsystem(subsystem: string | Subsystem, options?: {
transpile?: boolean
}): Subsystem;
deleteSubsystem(name: string, force?: boolean): void;
getSubsystemInfo(name: string): I.SysInfo;
getSubsystems(): I.SysInfo[];
}
namespace I {
interface ReportOptions {
events?: string;
signal?: string;
filename?: string;
directory?: string;
}
}
class Application extends Subsystem {
readonly isMain: boolean;
main(): void;
enableReport(opts?: I.ReportOptions): void;
reportEnabled(): boolean;
run(): Promise<void>;
exit(code?: number): Promise<void>;
exitOnSignal(...names: string[]): void;
removeProcesshandlers(): void;
_uncaughtException(err: any): void;
_unhandledRejection(reson: any, p: Promise<any>): void;
_rejectionHandled(p: Promise<any>): void;
_signalExit(sigName: string): void;
}
namespace I {
interface Command {
// ?
}
interface Argument {
// ?
}
interface PositionalArgument extends Argument {
// ?
}
interface OptionalArgument extends Argument {
// ?
}
interface DefineCommandFromSubsystemOptions {
name?: string;
description?: string;
group?: string;
subsystem: string | Subsystem;
configureArgs?: any[];
lazily?: boolean;
transpile?: boolean;
}
}
class CliApplication extends Application {
run(options?: { ignoreArgs?: boolean }): Promise<void>;
getVersion(): Promise<string | undefined>;
exposeCliInterface(ctxId?: string): void;
readonly mainCommand: I.Command;
defineMainCommand(schema: I.MainCommandInfo): this;
defineArguments(schema: I.MainCommandInfo): this;
defineCommand(schema: I.CommandInfo): I.Command;
defineCommandFromSubsystem(options?: I.DefineCommandFromSubsystemOptions): void;
defineOption(schema: I.ArgumentInfo): void;
defineOptionsGroup(schema: I.Group): void;
defineCommandsGroup(schema: I.Group): void;
option(path: string, options?: { value?: boolean }): any;
}
function run(app: Application, ignoreArgs?: boolean): Promise<void>;
function runCli(app: CliApplication, ignoreArgs?: boolean): Promise<void>;
}
}
+1 -1
View File
@@ -448,7 +448,7 @@ declare namespace adone {
isCompressed(): boolean;
}
interface ZipFile<StringType> extends event.EventEmitter {
interface ZipFile<StringType> extends event.Emitter {
/**
* true until close() is called; then it's false
*/
+47 -87
View File
@@ -38,7 +38,7 @@ declare namespace adone {
proxyExcludedKeys: string[];
}
type PossibleTypes = util.I.PossibleTypes | "array";
type PossibleTypes = meta.I.PossibleTypes | "array";
type UseFunction = (fn: () => void) => assertion;
@@ -53,18 +53,10 @@ declare namespace adone {
* Throws an AssertionError, like node.js
*/
fail(actual?: any, expected?: any, message?: string, operator?: any): void;
/**
* Asserts that value is truthy
*/
isOk(value: any, message?: string): void;
/**
* Asserts that value is truthy
*/
ok(value: any, message?: string): void;
/**
* Asserts that value is falsy
*/
isNotOk(value: any, message?: string): void;
/**
* Asserts that value is falsy
*/
@@ -104,51 +96,51 @@ declare namespace adone {
/**
* Asserts that value > above
*/
isAbove(value: any, above: any, message?: string): void;
above(value: any, above: any, message?: string): void;
/**
* Asserts that value >= atLeast
*/
isAtLeast(value: any, atLeast: any, message?: string): void;
atLeast(value: any, atLeast: any, message?: string): void;
/**
* Asserts that value < below
*/
isBelow(value: any, below: any, message?: string): void;
below(value: any, below: any, message?: string): void;
/**
* Asserts that value <= atMost
*/
isAtMost(value: any, atMost: any, message?: string): void;
atMost(value: any, atMost: any, message?: string): void;
/**
* Asserts that value is true
*/
isTrue(value: any, message?: string): void;
true(value: any, message?: string): void;
/**
* Asserts that value is not true
*/
isNotTrue(value: any, message?: string): void;
notTrue(value: any, message?: string): void;
/**
* Asserts that value is false
*/
isFalse(value: any, message?: string): void;
false(value: any, message?: string): void;
/**
* Asserts that value is not false
*/
isNotFalse(value: any, message?: string): void;
notFalse(value: any, message?: string): void;
/**
* Asserts that value is null
*/
isNull(value: any, message?: string): void;
null(value: any, message?: string): void;
/**
* Asserts that valus is not null
*/
isNotNull(value: any, message?: string): void;
notNull(value: any, message?: string): void;
/**
* Asserts that value is NaN
*/
isNaN(value: any, message?: string): void;
NaN(value: any, message?: string): void;
/**
* Asserts that value is not NaN
*/
isNotNaN(value: any, message?: string): void;
NotNaN(value: any, message?: string): void;
/**
* Asserts that value is neither null nor undefined
*/
@@ -160,63 +152,63 @@ declare namespace adone {
/**
* Asserts that value is undefined
*/
isUndefined(value: any, message?: string): void;
undefined(value: any, message?: string): void;
/**
* Asserts that value is not undefined
*/
isDefined(value: any, message?: string): void;
defined(value: any, message?: string): void;
/**
* Asserts that value is a function
*/
isFunction(value: any, message?: string): void;
function(value: any, message?: string): void;
/**
* Asserts that value is not a function
*/
isNotFunction(value: any, message?: string): void;
notFunction(value: any, message?: string): void;
/**
* Asserts that value is an object of type Object
*/
isObject(value: any, message?: string): void;
object(value: any, message?: string): void;
/**
* Asserts that value is not an object of type Object
*/
isNotObject(value: any, message?: string): void;
notObject(value: any, message?: string): void;
/**
* Asserts that value is an array
*/
isArray(value: any, message?: string): void;
array(value: any, message?: string): void;
/**
* Asserts that value is not an array
*/
isNotArray(value: any, message?: string): void;
notArray(value: any, message?: string): void;
/**
* Asserts that value is a string
*/
isString(value: any, message?: string): void;
string(value: any, message?: string): void;
/**
* Asserts that value is not a string
*/
isNotString(value: any, message?: string): void;
notString(value: any, message?: string): void;
/**
* Asserts that value is a number
*/
isNumber(value: any, message?: string): void;
number(value: any, message?: string): void;
/**
* Asserts that value is not a number
*/
isNotNumber(value: any, message?: string): void;
notNumber(value: any, message?: string): void;
/**
* Asserts that value is a finite number
*/
isFinite(value: any, message?: string): void;
finite(value: any, message?: string): void;
/**
* Asserts that value is a boolean
*/
isBoolean(value: any, message?: string): void;
boolean(value: any, message?: string): void;
/**
* Asserts that value is not a boolean
*/
isNotBoolean(value: any, message?: string): void;
notBoolean(value: any, message?: string): void;
/**
* Asserts that value's type is `type`
*/
@@ -562,66 +554,34 @@ declare namespace adone {
* Throws an error if value is truthy
*/
ifError(value: any): void;
/**
* Asserts that object is extensible
*/
isExtensible(object: object, message?: string): void;
/**
* Asserts that object is extensible
*/
extensible(object: object, message?: string): void;
/**
* Asserts that object is not extensible
*/
isNotExtensible(object: object, message?: string): void;
/**
* Asserts that object is not extensible
*/
notExtensible(object: object, message?: string): void;
/**
* Asserts that object is sealed
*/
isSealed(object: object, message?: string): void;
/**
* Asserts that object is sealed
*/
sealed(object: object, message?: string): void;
/**
* Asserts that object is not sealed
*/
isNotSealed(object: object, message?: string): void;
/**
* Asserts that object is not sealed
*/
notSealed(object: object, message?: string): void;
/**
* Asserts that object is frozen
*/
isFrozen(object: object, message?: string): void;
/**
* Asserts that object is frozen
*/
frozen(object: object, message?: string): void;
/**
* Asserts that object is not frozen
*/
isNotFrozen(object: object, message?: string): void;
/**
* Asserts that object is not frozen
*/
notFrozen(object: object, message?: string): void;
/**
* Asserts that value is empty
*/
isEmpty(value: any, message?: string): void;
/**
* Asserts that value is empty
*/
empty(value: any, message?: string): void;
/**
* Asserts that value is not empty
*/
isNotEmpty(value: any, message?: string): void;
/**
* Asserts that value is not empty
*/
@@ -710,43 +670,43 @@ declare namespace adone {
/**
* Asserts that the target is non-strictly equal to true
*/
ok: this;
ok(): this;
/**
* Asserts that the target is true
*/
true: this;
true(): this;
/**
* Asserts that the target is false
*/
false: this;
false(): this;
/**
* Asserts that the target is null
*/
null: this;
null(): this;
/**
* Asserts that the target is undefined
*/
undefined: this;
undefined(): this;
/**
* Asserts that the target is NaN
*/
NaN: this;
NaN(): this;
/**
* Asserts that the target is neither null nor undefined
*/
exist: this;
exist(): this;
/**
* Asserts that the target is empty
*/
empty: this;
empty(): this;
/**
* Asserts that the target is an arguments object
*/
arguments: this;
arguments(): this;
/**
* Asserts that the target is an arguments object
*/
Arguments: this;
Arguments(): this;
/**
* Asserts that the target is strictly equal to value(===)
*/
@@ -976,26 +936,26 @@ declare namespace adone {
/**
* Asserts that the target is extensible
*/
extensible: this;
extensible(): this;
/**
* Asserts that the target is sealed
*/
sealed: this;
sealed(): this;
/**
* Asserts that the target is frozen
*/
frozen: this;
frozen(): this;
/**
* Asserts that the target is a finite number
*/
finite: this;
finite(): this;
}
interface MockAssertions extends Assertion {
/**
* Asserts that the spy has been called
*/
called: this;
called(): this;
/**
* Asserts that the spy has been called n times
*/
@@ -1003,15 +963,15 @@ declare namespace adone {
/**
* Asserts that the spy has been called once
*/
calledOnce: this;
calledOnce(): this;
/**
* Asserts that the spy has been called twice
*/
calledTwice: this;
calledTwice(): this;
/**
* Asserts that the spy has been been called with `new`
*/
calledThrice: this;
calledThrice(): this;
/**
* Asserts that the spy has been called before anotherSpy
*/
@@ -1059,7 +1019,7 @@ declare namespace adone {
}
}
class AssertionError extends x.Exception {
class AssertionError extends exception.Exception {
constructor(message?: string, props?: object, ssf?: object)
}
+28 -6
View File
@@ -30,7 +30,12 @@ declare namespace adone {
* or an array of String and Number objects that serve as a whitelist
* for selecting/filtering the properties of the value object to be included in the JSON string
*/
replacer?: I.Replacer
replacer?: I.Replacer,
/**
* Wheter to append a newline
*/
newline?: boolean
}): Buffer;
/**
@@ -84,6 +89,8 @@ declare namespace adone {
*/
function decode(buf: collection.I.ByteArray.Wrappable): any;
function tryDecode(buf: collection.ByteArray): any;
namespace I {
type Type = string | number; // ?
type DecodeFunction = (buf: collection.ByteArray) => any;
@@ -153,6 +160,8 @@ declare namespace adone {
* Represents a MessagePack serializer
*/
class Serializer {
constructor(initialCapacity?: number);
/**
* Encoder instance
*/
@@ -211,6 +220,8 @@ declare namespace adone {
* x.Exception, Error, Date, Map, Set, math.Long
*/
const serializer: Serializer;
function registerCommonTypesFor(s: Serializer): void;
}
/**
@@ -244,21 +255,32 @@ declare namespace adone {
* Base64 encoder
*/
namespace base64 {
namespace I {
interface DecodeOptions {
buffer?: boolean;
encoding?: string;
}
interface EncodeOptions {
buffer?: boolean;
}
}
/**
* Encodes a string/Buffer to base64
*/
function encode(str: string | Buffer, options: { buffer: false }): string;
function encode(str: string | Buffer, options?: { buffer?: true }): Buffer;
function encode(str: string | Buffer, options: I.EncodeOptions & { buffer: false }): string;
function encode(str: string | Buffer, options?: I.EncodeOptions): Buffer;
/**
* Decodes base64 string/buffer into a buffer
*/
function decode(str: string | Buffer, options: { buffer: true }): Buffer;
function decode(str: string | Buffer, options: I.DecodeOptions & { buffer: true }): Buffer;
/**
* Decodes base64 string/buffer into a string
*/
function decode(str: string | Buffer, options?: { buffer?: false }): string;
function decode(str: string | Buffer, options?: I.DecodeOptions): string;
function encodeVLQ(value: number): string;
@@ -560,7 +582,7 @@ declare namespace adone {
/**
* Represents a YAML exception
*/
class Exception extends adone.x.Exception {
class Exception extends adone.exception.Exception {
reason: string;
mark: Mark;
+26 -3
View File
@@ -1,25 +1,48 @@
declare namespace adone {
namespace event {
class EventEmitter {
static listenerCount(emitter: EventEmitter, event: string | symbol): number;
namespace I {
interface PropagateEventsEnder {
end(): void;
}
}
class Emitter {
static listenerCount(emitter: Emitter, event: string | symbol): number;
static defaultMaxListeners: number;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string | symbol): Array<(...args: any[]) => any>;
emit(event: string | symbol, ...args: any[]): boolean;
eventNames(): Array<string | symbol>;
listenerCount(type: string | symbol): number;
propagateEvents(dest: Emitter, events: string[]): I.PropagateEventsEnder;
static propagateEvents(source: Emitter, dest: Emitter, events: string[]): I.PropagateEventsEnder;
}
class AsyncEmitter extends EventEmitter {
class AsyncEmitter extends Emitter {
constructor(concurrency?: number);
setConcurrency(max?: number): this;
+1 -1
View File
@@ -1,5 +1,5 @@
declare namespace adone {
namespace x {
namespace exception {
class Exception extends Error {
constructor(message?: string | Error, captureStackTrace?: boolean);
}
+3 -3
View File
@@ -152,7 +152,7 @@ declare namespace adone {
type SymbolicFile = File;
/* tslint:disable-next-line:no-empty-interface */
interface Stream<S, T = File> extends stream.CoreStream<S, T> {
interface Stream<S, T = File> extends stream.core.Stream<S, T> {
//
}
}
@@ -160,7 +160,7 @@ declare namespace adone {
export const File: I.FileConstructor;
namespace I {
type CoreStreamSource = stream.I.CoreStream.Source<any, File>;
type CoreStreamSource = stream.core.I.Source<any, File>;
interface LocalStreamConstructorOptions {
/**
@@ -586,7 +586,7 @@ declare namespace adone {
/**
* Read JSON manifests written out by revisionHash
*/
manifest?: File[] | stream.CoreStream<any, File>,
manifest?: File[] | stream.core.Stream<any, File>,
/**
* Modify the name of the unreved files before using them
+382 -186
View File
@@ -22,6 +22,14 @@ declare namespace adone {
function readlink(path: string | Buffer | I.URL, options: { encoding: null }): Promise<Buffer>;
function readlink(path: string | Buffer | I.URL, options?: { encoding?: I.Encoding }): Promise<string>;
/**
* Reads the value of a symbolic link
*/
function readlinkSync(path: string | Buffer | I.URL, encoding: null): Buffer;
function readlinkSync(path: string | Buffer | I.URL, encoding: I.Encoding): string;
function readlinkSync(path: string | Buffer | I.URL, options: { encoding: null }): Buffer;
function readlinkSync(path: string | Buffer | I.URL, options?: { encoding?: I.Encoding }): string;
/**
* Deletes a name and possibly the file it refers to
*/
@@ -32,6 +40,21 @@ declare namespace adone {
*/
function unlinkSync(path: string | Buffer | I.URL): void;
/**
* Changes the file system timestamps of the object referenced by path
*/
function utimes(path: string | Buffer | I.URL, atime: number | string | Date, mtime: number | string | Date): Promise<void>;
/**
* Changes the file system timestamps of the object referenced by path
*/
function utimesSync(path: string | Buffer | I.URL, atime: number | string | Date, mtime: number | string | Date): void;
/**
* Changes the file system timestamps of the object referenced by path
*/
function utimesMillis(path: string | Buffer | I.URL, atime: number, mtime: number): Promise<void>;
/**
* Changes permissions of a file
*/
@@ -42,6 +65,11 @@ declare namespace adone {
*/
function chown(path: string | Buffer | I.URL, uid: number, gid: number): Promise<void>;
/**
* Changes ownership recursively for a given path
*/
function chownr(path: string | Buffer | I.URL, uid: number, gid: number): Promise<void>;
/**
* Deletes a directory
*/
@@ -63,6 +91,87 @@ declare namespace adone {
function readdirSync(path: string | Buffer | I.URL, options: { encoding: null }): Buffer[];
function readdirSync(path: string | Buffer | I.URL, options?: { encoding?: I.Encoding }): string[];
namespace I {
interface ReaddirpEntry {
/**
* filename
*/
name: string;
/**
* full path to a file
*/
fullPath: string;
/**
* relative path to a file
*/
path: string;
/**
* relative path to the parent dir
*/
parentDir: string;
/**
* full path to the parent dir
*/
fullParentDir: string;
/**
* file stats
*/
stat: fs.I.Stats;
}
type ReaddirpFilter = string | ((entry: ReaddirpEntry) => boolean);
interface ReaddirpOptions {
/**
* filter for files
*/
fileFilter?: ReaddirpFilter | ReaddirpFilter[];
/**
* filter for directories
*/
directoryFilter?: ReaddirpFilter | ReaddirpFilter[];
/**
* maximum recursion depth
*
* Infinity by default
*/
depth?: number;
/**
* whether to emit files
*
* true by default
*/
files?: boolean;
/**
* whether to emit directories
*
* true by default
*/
directories?: boolean;
/**
* whether to use lstat for stating
*
* false by default
*/
lstat?: boolean;
}
}
/**
* Traverses the given path
*/
function readdirp(root: string | Buffer | I.URL, options?: I.ReaddirpOptions): stream.core.Stream<never, I.ReaddirpEntry>;
/**
* Gets file status, identical to stat, except that if pathname is a symbolic link,
* then it returns information about the link itself, not the file that it refers to
@@ -117,6 +226,15 @@ declare namespace adone {
flag?: I.Flag
}): Promise<void>;
/**
* Appends data to a file, creating the file if it does not yet exist
*/
function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: {
encoding?: I.Encoding,
mode?: number,
flag?: I.Flag
}): void;
/**
* Tests a user's permissions for the file or directory specified by path
*/
@@ -154,6 +272,14 @@ declare namespace adone {
cwd?: string
}): Promise<void>;
/**
* Recursively deletes empty directiries inside the given directory
*/
function rmEmpty(path: string, options?: {
cwd?: string;
filter?: (filename: string) => boolean
}): Promise<void>;
namespace I {
interface Access {
read: boolean;
@@ -460,12 +586,12 @@ declare namespace adone {
/**
* Copies this from this directory to the given path
*/
copyTo(destPath: string, options?: I.CopyOptions): Promise<void>;
copyTo(destPath: string, options?: I.CopyToOptions): Promise<void>;
/**
* Copies files from the given path to this directory
*/
copyFrom(srcPath: string, options?: I.CopyOptions): Promise<void>;
copyFrom(srcPath: string, options?: I.CopyToOptions): Promise<void>;
/**
* Creates a new directory with the given path
@@ -560,7 +686,7 @@ declare namespace adone {
/**
* Represents a file that supports random access
*/
class RandomAccessFile extends event.EventEmitter {
class RandomAccessFile extends event.Emitter {
constructor(filename: string, options?: I.RandomAccessFile.ConstructorOptions);
/**
@@ -602,7 +728,7 @@ declare namespace adone {
/**
* Represents an abstract random access reader
*/
class AbstractRandomAccessReader extends event.EventEmitter {
class AbstractRandomAccessReader extends event.Emitter {
/**
* Increments the reference counter
*/
@@ -826,7 +952,7 @@ declare namespace adone {
}>;
}
type Stream<T> = stream.CoreStream<never, T>;
type Stream<T> = stream.core.Stream<never, T>;
interface EmitterConstructor {
new(pattern: string, optons: Options, callback?: (error: any, matches: string[]) => void): Emitter;
@@ -835,7 +961,7 @@ declare namespace adone {
prototype: Emitter;
}
interface Emitter extends event.EventEmitter {
interface Emitter extends event.Emitter {
isIgnored(path: string): boolean;
/**
@@ -999,7 +1125,7 @@ declare namespace adone {
/**
* Represents a file watcher
*/
class Watcher extends event.EventEmitter {
class Watcher extends event.Emitter {
constructor(options?: I.Watcher.ConstructorOptions);
/**
@@ -1128,214 +1254,209 @@ declare namespace adone {
function whichSync(cmd: string, options?: I.Which.Options): string;
/**
* Functions to work with files using file descriptors
* Opens and possibly creates a file
*/
namespace fd {
/**
* Opens and possibly create a file
*/
function open(path: string | Buffer | I.URL, flags: I.Flag | number, mode?: number): Promise<I.FD>;
function open(path: string | Buffer | I.URL, flags: I.Flag | number, mode?: number): Promise<I.FD>;
/**
* Opens and possibly create a file
*/
function openSync(path: string | Buffer | I.URL, flags: I.Flag | number, mode?: number): I.FD;
/**
* Opens and possibly creates a file
*/
function openSync(path: string | Buffer | I.URL, flags: I.Flag | number, mode?: number): I.FD;
/**
* Closes a file descriptor
*/
function close(fd: I.FD): Promise<void>;
/**
* Closes a file descriptor
*/
function close(fd: I.FD): Promise<void>;
/**
* Closes a file descriptor
*/
function closeSync(fd: I.FD): void;
/**
* Closes a file descriptor
*/
function closeSync(fd: I.FD): void;
/**
* Changes the file timestamps of a file referenced by the supplied file descriptor
*/
function utimes(fd: I.FD, atime: number, mtime: number): Promise<void>;
/**
* Changes the file timestamps of a file referenced by the supplied file descriptor
*/
function futimes(fd: I.FD, atime: number, mtime: number): Promise<void>;
/**
* Changes the file timestamps of a file referenced by the supplied file descriptor
*/
function utimesSync(fd: I.FD, atime: number, mtime: number): void;
/**
* Changes the file timestamps of a file referenced by the supplied file descriptor
*/
function futimesSync(fd: I.FD, atime: number, mtime: number): void;
/**
* Gets file status
*/
function stat(fd: I.FD): Promise<I.Stats>;
/**
* Gets file status
*/
function fstat(fd: I.FD): Promise<I.Stats>;
/**
* Gets file status
*/
function statSync(fd: I.FD): I.Stats;
/**
* Gets file status
*/
function fstatSync(fd: I.FD): I.Stats;
/**
* Truncates a file to a specified length
*/
function truncate(fd: I.FD, length?: number): Promise<void>;
/**
* Truncates a file to a specified length
*/
function ftruncate(fd: I.FD, length?: number): Promise<void>;
/**
* Truncates a file to a specified length
*/
function truncateSync(fd: I.FD, length?: number): void;
/**
* Truncates a file to a specified length
*/
function ftruncateSync(fd: I.FD, length?: number): void;
/**
* Read data from the file specified by fd
*/
function read(
fd: I.FD,
/**
* Read data from the file specified by fd
* The buffer that the data will be written to
*/
function read(
fd: I.FD,
/**
* The buffer that the data will be written to
*/
buffer: Buffer | Uint8Array,
/**
* The offset in the buffer to start writing at
*/
offset: number,
/**
* An integer specifying the number of bytes to read
*/
length: number,
/**
* An argument specifying where to begin reading from in the file
*/
position: number
): Promise<number>;
function readSync(
fd: I.FD,
/**
* The buffer that the data will be written to
*/
buffer: Buffer | Uint8Array,
/**
* The offset in the buffer to start writing at
*/
offset: number,
/**
* An integer specifying the number of bytes to read
*/
length: number,
/**
* An argument specifying where to begin reading from in the file
*/
position: number
): number;
buffer: Buffer | Uint8Array,
/**
* Writes buffer to the file specified by fd
* The offset in the buffer to start writing at
*/
function write(
fd: I.FD,
buffer: Buffer | Uint8Array,
/**
* Determines the part of the buffer to be written
*/
offset?: number,
/**
* An integer specifying the number of bytes to write
*/
length?: number,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number
): Promise<number>;
offset: number,
/**
* Writes string to the file specified by fd
* An integer specifying the number of bytes to read
*/
function write(
fd: I.FD,
string: string,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number,
/**
* The expected string encoding
*/
encoding?: I.Encoding
): Promise<number>;
length: number,
/**
* Writes buffer to the file specified by fd
* An argument specifying where to begin reading from in the file
*/
function writeSync(
fd: I.FD,
buffer: Buffer | Uint8Array,
/**
* Determines the part of the buffer to be written
*/
offset?: number,
/**
* An integer specifying the number of bytes to write
*/
length?: number,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number
): number;
position: number
): Promise<number>;
function readSync(
fd: I.FD,
/**
* Writes string to the file specified by fd
* The buffer that the data will be written to
*/
function writeSync(
fd: I.FD,
string: string,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number,
/**
* The expected string encoding
*/
encoding?: I.Encoding
): number;
buffer: Buffer | Uint8Array,
/**
* The offset in the buffer to start writing at
*/
offset: number,
/**
* An integer specifying the number of bytes to read
*/
length: number,
/**
* An argument specifying where to begin reading from in the file
*/
position: number
): number;
/**
* Writes buffer to the file specified by fd
*/
function write(
fd: I.FD,
buffer: Buffer | Uint8Array,
/**
* Synchronizes a file's in-core state with storage
* Determines the part of the buffer to be written
*/
function sync(fd: I.FD): Promise<void>;
offset?: number,
/**
* An integer specifying the number of bytes to write
*/
length?: number,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number
): Promise<number>;
/**
* Writes string to the file specified by fd
*/
function write(
fd: I.FD,
string: string,
/**
* Synchronizes a file's in-core state with storage
* The offset from the beginning of the file where this data should be written
*/
function syncSync(fd: I.FD): void;
position?: number,
/**
* The expected string encoding
*/
encoding?: I.Encoding
): Promise<number>;
/**
* Writes buffer to the file specified by fd
*/
function writeSync(
fd: I.FD,
buffer: Buffer | Uint8Array,
/**
* Changes ownership of a file
* Determines the part of the buffer to be written
*/
function chown(fd: I.FD, uid: number, gid: number): Promise<void>;
offset?: number,
/**
* An integer specifying the number of bytes to write
*/
length?: number,
/**
* The offset from the beginning of the file where this data should be written
*/
position?: number
): number;
/**
* Writes string to the file specified by fd
*/
function writeSync(
fd: I.FD,
string: string,
/**
* Changes ownership of a file
* The offset from the beginning of the file where this data should be written
*/
function chownSync(fd: I.FD, uid: number, gid: number): void;
position?: number,
/**
* The expected string encoding
*/
encoding?: I.Encoding
): number;
/**
* Changes permissions of a file
*/
function chmod(fd: I.FD, mode: number): Promise<void>;
/**
* Synchronizes a file's in-core state with storage
*/
function fsync(fd: I.FD): Promise<void>;
/**
* Changes permissions of a file
*/
function chmodSync(fd: I.FD, mode: number): void;
/**
* Synchronizes a file's in-core state with storage
*/
function fsyncSync(fd: I.FD): void;
/**
* Repositions read/write file offset
*/
function seek(fd: I.FD, offset: number, whence: number): Promise<number>;
/**
* Changes ownership of a file
*/
function fchown(fd: I.FD, uid: number, gid: number): Promise<void>;
/**
* Applies or removes an advisory lock on an open file
*/
function lock(fd: I.FD, flags: "sh" | "ex" | "shnb" | "exnb" | "un" | number): Promise<void>;
}
/**
* Changes ownership of a file
*/
function fchownSync(fd: I.FD, uid: number, gid: number): void;
/**
* Changes permissions of a file
*/
function fchmod(fd: I.FD, mode: number): Promise<void>;
/**
* Changes permissions of a file
*/
function fchmodSync(fd: I.FD, mode: number): void;
/**
* Repositions read/write file offset
*/
function seek(fd: I.FD, offset: number, whence: number): Promise<number>;
/**
* Applies or removes an advisory lock on an open file
*/
function flock(fd: I.FD, flags: "sh" | "ex" | "shnb" | "exnb" | "un" | number): Promise<void>;
namespace constants {
const F_OK: number;
@@ -1475,12 +1596,63 @@ declare namespace adone {
function existsSync(path: string | Buffer | I.URL): boolean;
/**
* Creates a new directory and any necessary subdirectories
* Creates a new directory
*/
function mkdir(path: string, mode?: number): Promise<void>;
/**
* Creates a new directory
*/
function mkdirSync(path: string, mode?: number): Promise<void>;
/**
* Creates a new directory and any necessary subdirectories
*/
function mkdirp(path: string, mode?: number): Promise<void>;
/**
* Creates a new directory and any necessary subdirectories
*/
function mkdirpSync(path: string, mode?: number): Promise<void>;
namespace I {
interface CopyOptions {
/**
* regexp or function against which each filename is tested whether to copy it or not
*/
filter?: RegExp | ((src: string, dst: string) => boolean);
/**
* transform function which applies when files are streamed
*/
transform?(
readStream: NodeJS.ReadableStream,
writeStream: NodeJS.WritableStream,
file: {
name: string,
mode: number,
mtime: Date,
atime: Date,
stats: adone.fs.I.Stats
}
): void;
/**
* Whether to overwrite destination files if they exist.
*
* true by default
*/
clobber?: boolean; // ???
/**
* Whether to overwrite destination files if they exist.
*
* true by default
*/
overwrite?: boolean;
}
interface CopyToOptions {
/**
* Do not replace existing files
*/
@@ -1494,10 +1666,15 @@ declare namespace adone {
}
/**
* Copies all files from src to dst
* Recursively copies all the files from src to dst
*/
function copy(src: string, dst: string, options?: I.CopyOptions): Promise<void>;
/**
* Copies all files from src to dst
*/
function copyTo(src: string, dst: string, options?: I.CopyToOptions): Promise<void>;
/**
* Renames a file
*/
@@ -1514,8 +1691,32 @@ declare namespace adone {
/**
* Returns the last lines of a file
*
* @param path path to a file
* @param n number of lines to return
*/
function tail(path: string, n: number, options?: { separator?: string, chunkLength?: number }): Promise<Buffer[]>;
function tail(path: string, n: number, options?: {
/**
* Line separator
*
* By default "\r\n" for windows and "\n" for others
*/
separator?: string,
/**
* The number of bytes to read at once
*
* By default 4096
*/
chunkLength?: number
/**
* Position from which to start reading (from the end)
*
* By default stats.size of the file
*/
pos?: number
}): Promise<Buffer[]>;
namespace I {
interface StatVFS {
@@ -1667,11 +1868,6 @@ declare namespace adone {
*/
function lookup(path: string): Promise<string>;
/**
* Recursively changes ownership of files
*/
function chownr(path: string, uid: number, gid: number): Promise<void>;
namespace I.TailWatcher {
interface ConstructorOptions {
/**
@@ -1709,7 +1905,7 @@ declare namespace adone {
* Represents an event emitter that watches for a file growing,
* emits "line" event for each new line in a file
*/
class TailWatcher extends event.EventEmitter {
class TailWatcher extends event.Emitter {
constructor(filename: string, options?: I.TailWatcher.ConstructorOptions);
/**
+161 -38
View File
@@ -6,13 +6,13 @@ declare namespace adone {
/**
* Checks whether the given object is `null`
*/
function _null(obj: any): boolean;
function _null(obj: any): obj is null;
export { _null as null };
/**
* Checks whether the given object is `undefined`
*/
export function undefined(obj: any): boolean;
export function undefined(obj: any): obj is undefined;
/**
* Checks whether the given object is nither `undefined` nor `null`
@@ -22,52 +22,54 @@ declare namespace adone {
/**
* Checks whether the given object is either `undefined` or `null`
*/
export function nil(obj: any): boolean;
export function nil(obj: any): obj is undefined | null;
/**
* Checks whether the given object is a number
*/
export function number(obj: any): boolean;
export function number(obj: any): obj is number;
/**
* Checks whether the given object is a finite number or a string represents a finite number
*/
export function numeral(obj: any): boolean;
export function numeral(obj: number): obj is number;
export function numeral(obj: string): obj is string;
export function numeral(obj: any): obj is number | string;
/**
* Checks whether the given object is either +Infinity or -Inginity
*/
export function infinite(obj: any): boolean;
export function infinite(obj: any): obj is number;
/**
* Checks whether the given object is an odd number
*/
export function odd(obj: any): boolean;
export function odd(obj: any): obj is number;
/**
* Checks whether the given object is an even number
*/
export function even(obj: any): boolean;
export function even(obj: any): obj is number;
/**
* Checks whether the given object is a float
*/
export function float(obj: any): boolean;
export function float(obj: any): obj is number;
/**
* Checks whether the given object is -0
*/
export function negativeZero(obj: any): boolean;
export function negativeZero(obj: any): obj is number;
/**
* Checks whether the given object is a string
*/
export function string(obj: any): boolean;
export function string(obj: any): obj is string;
/**
* Checks whether the given object is an empty string
* Checks whether the given object is an empty string, i.e. a string with only whitespace characters
*/
export function emptyString(obj: any): boolean;
export function emptyString(obj: any): obj is string;
/**
* Checks whether the first string is a substring of the second string from the given offset
@@ -87,7 +89,7 @@ declare namespace adone {
/**
* Checks whether the given object is a boolean
*/
export function boolean(obj: any): boolean;
export function boolean(obj: any): obj is boolean;
/**
* Checks whether the given object is a string with ".json" extension or an object
@@ -215,7 +217,7 @@ declare namespace adone {
/**
* Checks whether the given string is a glob
*/
export function glob(str: string): boolean;
export function glob(str: any): str is string;
/**
* Checks whether the given path is not a dot-file path (.secret)
@@ -236,7 +238,7 @@ declare namespace adone {
/**
* Checks whether the given object is a promise
*/
export function promise(obj: any): boolean;
export function promise(obj: any): obj is PromiseLike<any>;
/**
* Checks whether the given string is a valid date-string
@@ -246,7 +248,7 @@ declare namespace adone {
/**
* Checks whether the given object is a buffer
*/
export function buffer(obj: any): boolean;
export function buffer(obj: any): obj is Buffer;
/**
* Checks whether the given object is a callback function, i.e. it has a common function name
@@ -266,27 +268,27 @@ declare namespace adone {
/**
* Checks whether the given object is a finite number
*/
export function finite(obj: any): boolean;
export function finite(obj: any): obj is number;
/**
* Checks whether the given object is an integer
*/
export function integer(obj: any): boolean;
export function integer(obj: any): obj is number;
/**
* Checks whether the given object is a safe integer
*/
export function safeInteger(obj: any): boolean;
export function safeInteger(obj: any): obj is number;
/**
* Checks whether the given object is an array
*/
export function array(obj: any): boolean;
export function array(obj: any): obj is any[];
/**
* Checks whether the given object is a Uint8 array
*/
export function uint8Array(obj: any): boolean;
export function uint8Array(obj: any): obj is Uint8Array;
/**
* Checks whether the given object is an adone configuration
@@ -296,22 +298,22 @@ declare namespace adone {
/**
* Checks whether the given object is an instance of adone.math.Long
*/
export function long(obj: any): boolean;
export function long(obj: any): obj is adone.math.Long;
/**
* Checks whether the given object is an instance of adone.math.BigNumber
*/
export function bigNumber(obj: any): boolean;
export function bigNumber(obj: any): obj is adone.math.BigNumber;
/**
* Checks whether the given object is an instance of adone.collection.ByteArray
*/
export function byteArray(obj: any): boolean;
export function byteArray(obj: any): obj is adone.collection.ByteArray;
/**
* Checks whether the given object is an instance of adone.datetime
*/
export function datetime(obj: any): boolean;
export function datetime(obj: any): obj is adone.I.datetime.Datetime;
export function transform(obj: any): boolean;
@@ -498,17 +500,17 @@ declare namespace adone {
/**
* Checks whether the given object is an array buffer
*/
export function arrayBuffer(obj: any): boolean;
export function arrayBuffer(obj: any): obj is ArrayBuffer;
/**
* Checks whether the given object is an array buffer view
*/
export function arrayBufferView(obj: any): boolean;
export function arrayBufferView(obj: any): obj is ArrayBufferView;
/**
* Checks whether the given object is a date
*/
export function date(obj: any): boolean;
export function date(obj: any): obj is Date;
/**
* Checks whether the given object is an error, instance of Error
@@ -518,27 +520,22 @@ declare namespace adone {
/**
* Checks whether the given object is a map
*/
export function map(obj: any): boolean;
export function map(obj: any): obj is Map<any, any>;
/**
* Checks whether the given object is a regexp
*/
export function regexp(obj: any): boolean;
export function regexp(obj: any): obj is RegExp;
/**
* Checks whether the given object is a set
*/
export function set(obj: any): boolean;
export function set(obj: any): obj is Set<any>;
/**
* Checks whether the given object is a symbol
*/
export function symbol(obj: any): boolean;
/**
* Checks whether the given buffer a valid UTF-8 encoded text
*/
export function validUTF8(obj: Buffer): boolean;
export function symbol(obj: any): obj is symbol;
/**
* Checks whether the given object is a vault valuable
@@ -549,5 +546,131 @@ declare namespace adone {
* Checks whether the given object is an adone task
*/
export function task(obj: any): boolean;
namespace I {
interface FQDNOptions {
/**
* Whether to require top-level domain, default `true`
*/
requireTld?: boolean;
/**
* Whether to allow underscores("_"), default `false`
*/
allowUnderscores?: boolean;
/**
* Whether to allow trailing dot, default `false`
*/
allowTrailingDot?: boolean;
}
}
/**
* Checks whether the given object(string) is a fully qualified domain name (e.g. domain.com).
*/
export function fqdn(obj: any, options?: I.FQDNOptions): obj is string;
/**
* Checks whether the given object(string) is a url
*/
export function url(obj: any, options?: I.FQDNOptions & {
/**
* List of valid protocols.
* Used when requireValidProtocol is `true`.
* Default ["http", "https", "ftp"]
*/
protocols?: string[],
/**
* Whether to require protocol, default `true`
*/
requireProtocol?: boolean,
/**
* Whether to require host, default `true`
*/
requireHost?: boolean,
/**
* Whether to require valid protocol defined in `protocols` options, default `true`
*/
requireValidProtocol?: boolean,
/**
* Whether to allow urls like "//example.com", default `false`
*/
allowProtocolRelativeUrls?: boolean
}): obj is string;
/**
* Checks whether the given object(string) is a valid email address
*/
export function email(obj: any, options?: {
/**
* Whether to allow email addresses with display names ("Name <local@domain>"")
*/
allowDisplayName?: boolean,
/**
* Whether to require display name
*/
requireDisplayName?: boolean,
/**
* Whether to allow UTF8 characters in the local part
*/
allowUtf8LocalPart?: boolean,
/**
* Whether to require top-level domain, default `true`
*/
requireTld?: boolean
}): obj is string;
/**
* Checks whether the given object is a valid IPv4 address
*/
export function ip(obj: any, version: 4): boolean;
/**
* Checks whether the given object is a valid IPv6 address
*/
export function ip(obj: any, version: 6): boolean;
/**
* Checks whether the given object in a valid IPv4 or IPv6 address
*/
export function ip(obj: any): boolean;
/**
* Checks whether the given object is a valid UUIDv1 identifier
*/
export function uuid(obj: any, version: 1): obj is string;
/**
* Checks whether the given object is a valid UUIDv2 identifier
*/
export function uuid(obj: any, version: 2): obj is string;
/**
* Checks whether the given object is a valid UUIDv3 identifier
*/
export function uuid(obj: any, version: 3): obj is string;
/**
* Checks whether the given object is a valid UUIDv4 identifier
*/
export function uuid(obj: any, version: 4): obj is string;
/**
* Checks whether the given object is a valid UUIDv5 identifier
*/
export function uuid(obj: any, version: 5): obj is string;
/**
* Checks whether the given object is a valid UUID identifier (v1, v2, v3, v4 or v5)
*/
export function uuid(obj: any, version?: "all"): obj is string;
}
}
+13
View File
@@ -0,0 +1,13 @@
declare namespace adone {
namespace meta {
namespace I {
type PossibleTypes = "object" | "class" | "null" | "global" | "Array" | "RegExp" | "Date"
| "Promise" | "Set" | "Map" | "WeakSet" | "DataView" | "Map Iterator" | "Set Iterator"
| "Array Iterator" | "String Iterator" | "Object" | "function" | "boolean" | "number"
| "undefined" | "string" | "symbol";
}
function typeOf(obj: any): I.PossibleTypes;
function typeOf(obj: any): string;
}
}
+31
View File
@@ -125,5 +125,36 @@ declare namespace adone {
*/
function _finally<T>(promise: Promise<T>, onFinally?: (...args: any[]) => void): Promise<T>;
export { _finally as finally };
namespace I {
type ResolvableProps<T> = object & {[K in keyof T]: PromiseLike<T[K]> | T[K]};
}
/**
* Returns a promise that is fulfilled when all the object's values are fulfilled
*/
export function props<T>(obj: I.ResolvableProps<T>): Promise<T>;
namespace I {
interface _RetryOptions {
max: number;
timeout: number;
match: (string | RegExp | Error) | Array<string | RegExp | Error>;
backOffBase: number;
backOffExponent: number;
report: (message: string, options: _RetryOptions, err: any) => void;
name: string;
}
type RetryOptions = Partial<_RetryOptions>;
}
export function retry<T>(fn: (info: { current: number }) => PromiseLike<T> | T, options?: number | I.RetryOptions): Promise<T>;
}
}
+22 -2
View File
@@ -94,6 +94,11 @@ declare namespace adone {
* Mark this block as exclusive
*/
skip: DescribeFunction;
/**
* Mark this block as todo
*/
todo: DescribeFunction;
}
interface TestOptions {
@@ -146,6 +151,11 @@ declare namespace adone {
* Mark this test as exclusive
*/
skip: TestFunction;
/**
* Mark this test as todo
*/
todo: TestFunction;
}
interface HookRuntimeContext {
@@ -172,7 +182,7 @@ declare namespace adone {
| "end before each hook" | "end after each hook"
| "end before test hook" | "end after test hook";
interface Emitter extends event.EventEmitter {
interface Emitter extends event.Emitter {
on(event: "enter block", listener: (event: { block: Block }) => void): this;
on(event: "exit block", listener: (event: { block: Block }) => void): this;
on(event: "start test", listener: (event: { block: Block, test: Test }) => void): this;
@@ -267,6 +277,11 @@ declare namespace adone {
*/
only(): this;
/**
* Marks this test as todo
*/
todo(): this;
/**
* Returns the timeout of the test
*/
@@ -355,6 +370,11 @@ declare namespace adone {
*/
only(): this;
/**
* Marks this block as todo
*/
todo(): this;
/**
* Returns the timeout of the block
*/
@@ -1423,7 +1443,7 @@ declare namespace adone {
/**
* Requires the value to be of the given type
*/
typeOf(type: adone.util.I.PossibleTypes): Matcher;
typeOf(type: adone.meta.I.PossibleTypes): Matcher;
typeOf(type: string): Matcher;
/**
+208 -206
View File
@@ -1,223 +1,225 @@
declare namespace adone {
namespace stream {
namespace I.CoreStream {
interface ConstructorOptions<S, T> {
/**
* Whether the initial stream is asynchronous
*/
async?: boolean;
namespace core {
namespace I {
interface ConstructorOptions<S, T> {
/**
* Whether the initial stream is asynchronous
*/
async?: boolean;
/**
* Whether the initial stream is synchronous
*/
sync?: boolean;
/**
* Whether the initial stream is synchronous
*/
sync?: boolean;
/**
* The initial transform (passthrough is default)
*/
transform?: TransformFunction<S, T>;
/**
* The initial transform (passthrough is default)
*/
transform?: TransformFunction<S, T>;
/**
* The initial flush function
*/
flush?: FlushFunction<T>;
/**
* The initial flush function
*/
flush?: FlushFunction<T>;
}
type Source<S, T> = S[] | Stream<S, T>;
interface TransformContext<T> {
/**
* Pushes the given value into the stream
*/
push(value: T): boolean;
}
type TransformFunction<S, T> = (this: TransformContext<T>, value: S) => void;
type FlushFunction<T> = (this: TransformContext<T>) => void;
}
type Source<S, T> = S[] | CoreStream<S, T>;
/**
* Represents a chain of transform streams
*/
class Stream<S = any, T = S> implements PromiseLike<T[]> {
constructor(source?: I.Source<S, T>, options?: I.ConstructorOptions<S, T>);
/**
* Writes the given value into the stream
*/
write(value: S): boolean;
interface TransformContext<T> {
/**
* Pushes the given value into the stream
*/
push(value: T): boolean;
/**
* Ends the stream
*/
end(): this;
/**
* Destroys the stream
*/
destroy(): this;
/**
* Pauses the stream
*/
pause(): this;
/**
* Resumes the stream
*/
resume(): this;
/**
* Whether the stream is paused
*/
isPaused(): boolean;
/**
* Whether the stream is ended
*/
isEnded(): boolean;
/**
* Pipes this stream to another
*/
pipe<T>(stream: T, options?: { end?: boolean }): T;
/**
* Adds a new synchronous transform stream into the chain
*/
throughSync<R>(transform: I.TransformFunction<T, R>, flush?: I.FlushFunction<R>): Stream<S, R>;
/**
* Adds a new asynchronous transform stream into the chain
*/
throughAsync<R>(transform: I.TransformFunction<T, R>, flush?: I.FlushFunction<R>): Stream<S, R>;
/**
* Adds a new transform stream into the chain
*/
through<R>(transform: I.TransformFunction<T, R>, flush?: I.FlushFunction<R>): Stream<S, R>;
/**
* Adds a new map transform into the chain.
*
* Note: synchronous functions create a synchronous transform.
* If your function returns a promise use an asynchronous function if you don't want to pass a promise through the stream
*/
map<R>(callback: (value: T) => R | Promise<R>): Stream<S, R>;
/**
* Adds a new conditional map transform into the chain
*/
mapIf<R>(condition: (value: T) => boolean | Promise<boolean>, callback: (value: T) => R): Stream<S, T | R>;
/**
* Adds a new filter transform into the chain
*/
filter(callback: (value: T) => boolean | Promise<boolean>): this;
/**
* Adds a new transform that calls the given callback for each value from the stream.
*
* This method resumes the stream.
*/
forEach(callback: (value: T) => void, options?: {
/**
* Whethe to wait for asynchronous functions (await)
*/
wait?: boolean,
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that calls the given callback when the underlying stream ends.
*
* This method resumes the stream.
*/
done(callback: () => void, options?: {
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that gather all the read values into an array and calls the given callback
* when the underlying stream ends.
*
* This method resumes the stream.
*/
toArray(callback: (result: T[]) => void, options?: {
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that filters the values by their uniqueness
*
* @param prop callback that calculates value's hash which is used in uniqueness checks
*/
unique(prop?: (value: T) => any): this;
/**
* Adds a new transform that filters the values using the given given function with ability to restore the filtered values
*/
stash(name: string, filter: (value: T) => boolean): this;
stash(filter: (value: T) => boolean): this;
/**
* Adds a new transform that restores the previous stashed values
*/
unstash(name?: string): Stream<S, T>; // ??
/**
* Flattens all the read array values
*/
flatten(): Stream<S, T>; // ??
/**
* Merges the given stream into a core stream
*/
static merge<S = any, T = S>(streams: Array<Stream<any, any> | nodestd.stream.Transform | nodestd.stream.Readable | nodestd.stream.Duplex>, options?: {
/**
* Whether to end the stream when all the given streams end
*/
end?: boolean,
/**
* Options for the initial core stream
*/
sourceOptions?: I.ConstructorOptions<S, T>
}): Stream<S, T>;
/**
* Creates a promise that will be fulfilled with an array of all the emitted values or the first occurred error.
*
* This method resumes the stream.
*/
then<T1 = T[], T2 = never>(onResolve?: (value: T[]) => T1 | PromiseLike<T1>, onReject?: (reason: any) => T2 | PromiseLike<T2>): Promise<T1 | T2>;
/**
* Creates a promise that will be fulfilled with an array of all the emitted values or the first occurred error.
*
* This method resumes the stream.
*/
catch<T1 = never>(onReject?: (reason: any) => T1 | PromiseLike<T1>): Promise<T[] | T1>;
}
type TransformFunction<S, T> = (this: TransformContext<T>, value: S) => void;
type FlushFunction<T> = (this: TransformContext<T>) => void;
/**
* Creates a CoreStream instance
*/
function create<S = any, T = S>(source?: I.Source<S, T>, options?: I.ConstructorOptions<S, T>): Stream<S, T>;
}
/**
* Represents a chain of transform streams
*/
class CoreStream<S = any, T = S> implements PromiseLike<T[]> {
constructor(source?: I.CoreStream.Source<S, T>, options?: I.CoreStream.ConstructorOptions<S, T>);
/**
* Writes the given value into the stream
*/
write(value: S): boolean;
/**
* Pushes the given value into the stream
*/
push(value: T): boolean;
/**
* Ends the stream
*/
end(): this;
/**
* Destroys the stream
*/
destroy(): this;
/**
* Pauses the stream
*/
pause(): this;
/**
* Resumes the stream
*/
resume(): this;
/**
* Whether the stream is paused
*/
isPaused(): boolean;
/**
* Whether the stream is ended
*/
isEnded(): boolean;
/**
* Pipes this stream to another
*/
pipe<T>(stream: T, options?: { end?: boolean }): T;
/**
* Adds a new synchronous transform stream into the chain
*/
throughSync<R>(transform: I.CoreStream.TransformFunction<T, R>, flush?: I.CoreStream.FlushFunction<R>): CoreStream<S, R>;
/**
* Adds a new asynchronous transform stream into the chain
*/
throughAsync<R>(transform: I.CoreStream.TransformFunction<T, R>, flush?: I.CoreStream.FlushFunction<R>): CoreStream<S, R>;
/**
* Adds a new transform stream into the chain
*/
through<R>(transform: I.CoreStream.TransformFunction<T, R>, flush?: I.CoreStream.FlushFunction<R>): CoreStream<S, R>;
/**
* Adds a new map transform into the chain.
*
* Note: synchronous functions create a synchronous transform.
* If your function returns a promise use an asynchronous function if you don't want to pass a promise through the stream
*/
map<R>(callback: (value: T) => R | Promise<R>): CoreStream<S, R>;
/**
* Adds a new conditional map transform into the chain
*/
mapIf<R>(condition: (value: T) => boolean | Promise<boolean>, callback: (value: T) => R): CoreStream<S, T | R>;
/**
* Adds a new filter transform into the chain
*/
filter(callback: (value: T) => boolean | Promise<boolean>): this;
/**
* Adds a new transform that calls the given callback for each value from the stream.
*
* This method resumes the stream.
*/
forEach(callback: (value: T) => void, options?: {
/**
* Whethe to wait for asynchronous functions (await)
*/
wait?: boolean,
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that calls the given callback when the underlying stream ends.
*
* This method resumes the stream.
*/
done(callback: () => void, options?: {
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that gather all the read values into an array and calls the given callback
* when the underlying stream ends.
*
* This method resumes the stream.
*/
toArray(callback: (result: T[]) => void, options?: {
/**
* Passthrough the read values, by default it eats everything
*/
passthrough?: boolean
}): this;
/**
* Adds a new transform that filters the values by their uniqueness
*
* @param prop callback that calculates value's hash which is used in uniqueness checks
*/
unique(prop?: (value: T) => any): this;
/**
* Adds a new transform that filters the values using the given given function with ability to restore the filtered values
*/
stash(name: string, filter: (value: T) => boolean): this;
stash(filter: (value: T) => boolean): this;
/**
* Adds a new transform that restores the previous stashed values
*/
unstash(name?: string): CoreStream<S, T>; // ??
/**
* Flattens all the read array values
*/
flatten(): CoreStream<S, T>; // ??
/**
* Merges the given stream into a core stream
*/
static merge<S = any, T = S>(streams: Array<CoreStream<any, any> | nodestd.stream.Transform | nodestd.stream.Readable | nodestd.stream.Duplex>, options?: {
/**
* Whether to end the stream when all the given streams end
*/
end?: boolean,
/**
* Options for the initial core stream
*/
sourceOptions?: I.CoreStream.ConstructorOptions<S, T>
}): CoreStream<S, T>;
/**
* Creates a promise that will be fulfilled with an array of all the emitted values or the first occurred error.
*
* This method resumes the stream.
*/
then<T1 = T[], T2 = never>(onResolve?: (value: T[]) => T1 | PromiseLike<T1>, onReject?: (reason: any) => T2 | PromiseLike<T2>): Promise<T1 | T2>;
/**
* Creates a promise that will be fulfilled with an array of all the emitted values or the first occurred error.
*
* This method resumes the stream.
*/
catch<T1 = never>(onReject?: (reason: any) => T1 | PromiseLike<T1>): Promise<T[] | T1>;
}
/**
* Creates a CoreStream instance
*/
function core<S = any, T = S>(source?: I.CoreStream.Source<S, T>, options?: I.CoreStream.ConstructorOptions<S, T>): CoreStream<S, T>;
}
}
+701 -139
View File
@@ -16,10 +16,6 @@ declare namespace adone {
function functionName(fn: (...args: any[]) => any): string;
function mapArguments(argmap: (...args: any[]) => any): (...args: any[]) => any;
function mapArguments(argmap: number): <T>(...args: T[]) => T[];
function mapArguments(...args: any[]): <T>(x: T) => T;
namespace I {
interface ParseMsResult {
days: number;
@@ -33,8 +29,6 @@ declare namespace adone {
function pluralizeWord(str: string, plural?: string, count?: number): string;
function functionParams(func: (...args: any[]) => any): string[];
function randomChoice<T>(arrayLike: ArrayLike<T>, from?: number, to?: number): T;
function shuffleArray<T>(array: T[]): T[];
@@ -70,19 +64,8 @@ declare namespace adone {
function globParent(str: string): string;
namespace I {
interface ByResult<S, T, R> {
(a: S, b: S): R;
compare(a: T, b: T): R;
by(a: S): T;
}
}
function by<S, T, R>(by: (a: S) => T, compare?: (a: T, b: T) => R): I.ByResult<S, T, R>;
function toFastProperties(object: object): object;
function stripBom(x: string): string;
namespace I {
interface SortKeysOptions {
deep?: boolean;
@@ -118,12 +101,42 @@ declare namespace adone {
namespace I {
interface CloneOptions {
/**
* Clone recursively
*
* `true` by default
*/
deep?: boolean;
/**
* Clone non-plain object, they will be plain objects
*
* `false` by default
*/
nonPlainObjects?: boolean;
/**
* Clone only enumerable properties
*
* `true` by default
*/
onlyEnumerable?: boolean;
}
}
function clone(object: object, options?: I.CloneOptions): object;
function toUTF8Array(str: string): number[];
class Cloner {
/**
* Clones the given object
*/
clone(obj: any, options?: I.CloneOptions): any;
/**
* Returns a clone function that is binded to this cloner
*/
binding(): (obj: any, options?: I.CloneOptions) => any;
}
function clone(object: any, options?: I.CloneOptions): any;
function asyncIter<T>(array: T[], iter: (elem: T, index: number, cb: () => void) => any, cb: () => void): void;
@@ -150,20 +163,31 @@ declare namespace adone {
function assignDeep<T>(target: T, ...sources: object[]): T;
namespace I {
interface MatchOptions {
interface MatchPathOptions {
index?: boolean;
start?: number;
end?: number;
dot?: boolean;
}
}
function match(criteria: any, options?: I.MatchOptions): (value: any, options?: I.MatchOptions) => number | boolean;
function match(criteria: any, value: any, options?: I.MatchOptions): number | boolean;
function matchPath(criteria: any, options?: I.MatchPathOptions): (value: any, options?: I.MatchPathOptions) => number | boolean;
function matchPath(criteria: any, value: any, options?: I.MatchPathOptions): number | boolean;
namespace I {
class Sorter {
edges: string[];
add(item: string, deps: string | string[]): void;
sort(): string[];
clear(): void;
}
interface ToposortFunction {
<T>(edges: Array<[T, T]>): T[];
array<T>(nodes: T[], edges: Array<[T, T]>): T[];
(edges: Array<[string, string]>): string[];
array(nodes: string[], edges: Array<[string, string]>): string[];
Sorter: typeof Sorter;
}
}
const toposort: I.ToposortFunction;
@@ -188,16 +212,6 @@ declare namespace adone {
}
function jsesc(argument: any, options?: I.JSEscOptions): string;
namespace I {
type PossibleTypes = "object" | "class" | "null" | "global" | "Array" | "RegExp" | "Date"
| "Promise" | "Set" | "Map" | "WeakSet" | "DataView" | "Map Iterator" | "Set Iterator"
| "Array Iterator" | "String Iterator" | "Object" | "function" | "boolean" | "number"
| "undefined" | "string" | "symbol";
}
function typeOf(obj: any): I.PossibleTypes;
function typeOf(obj: any): string;
namespace memcpy {
function utou(target: Buffer, targetOffset: number, source: Buffer, sourceStart: number, sourceEnd: number): number;
function atoa(target: ArrayBuffer, targetOffset: number, source: ArrayBuffer, sourceStart: number, sourceEnd: number): number;
@@ -217,12 +231,12 @@ declare namespace adone {
function v1(options?: I.V1Options): string;
function v1(options: I.V1Options, buf: any[], offset?: number): number[];
function v4(options?: any): string;
function v4(options: any, buf: any[], offset?: number): number[];
function v3(name: string | number[], namespace: string | number[]): string;
function v3(name: string | number[], namespace: string | number[], buf: any[], offset?: number): number[];
function v4(options?: any): string;
function v4(options: any, buf: any[], offset?: number): number[];
function v5(name: string | number[], namespace: string | number[]): string;
function v5(name: string | number[], namespace: string | number[], buf: any[], offset?: number): number[];
}
@@ -237,40 +251,6 @@ declare namespace adone {
}
function delegate(object: object, property: string): I.Delegator;
namespace I {
interface GlobExpOptions {
nocomment?: boolean;
nonegate?: boolean;
nobrace?: boolean;
noglobstar?: boolean;
nocase?: boolean;
dot?: boolean;
noext?: boolean;
matchBase?: boolean;
flipNegate?: boolean;
}
}
class GlobExp {
constructor(pattern: string, options?: I.GlobExpOptions);
hasMagic(): boolean;
static hasMagic(pattern: string, options?: I.GlobExpOptions): boolean;
expandBraces(): string[];
static expandBraces(pattern: string, options?: I.GlobExpOptions): string[];
makeRe(): RegExp;
static makeRe(pattern: string, options?: I.GlobExpOptions): RegExp;
static test(p: string, pattern: string, options?: I.GlobExpOptions): boolean;
test(p: string): boolean;
}
namespace iconv {
// TODO: need to normalize source code
}
@@ -278,9 +258,6 @@ declare namespace adone {
namespace sqlstring {
function escapeId(val: string | string[], forbidQualified?: boolean): string;
function dateToString(date: any, timeZone?: string): string;
function arrayToList(array: any[]): string;
function bufferToString(buffer: Buffer): string;
function objectToValues(object: object, timeZone?: string): string;
function escape(value: any, stringifyObjects?: boolean, timeZone?: string): string;
function format(sql: string, values?: any, stringifyObjects?: boolean, timeZone?: string): string;
}
@@ -316,49 +293,71 @@ declare namespace adone {
}
const binarySearch: I.BinarySearchFunction;
/**
* buffer tools
*/
namespace buffer {
function concat(list: Buffer[], totalLength: number): Buffer;
function mask(buffer: Buffer, mask: Buffer, output: Buffer, offset: number, length: number): void;
function unmask(buffer: Buffer, mask: Buffer): void;
/**
* Converts the given Buffer to ArrayBuffer
*/
function toArrayBuffer(buf: Buffer): ArrayBuffer;
/**
* Returns a new buffer that represents a^b
*
* If the lengths are not equal, it assumes missing bytes as 0x00
*
* @param length length of the result buffer. max(a.length, b.length) by default
*/
function xor(a: Buffer, b: Buffer, length?: number): Buffer;
}
function shebang(str: string): string | null;
class ReInterval {
constructor(callback: (...args: any[]) => void, interval: number, args?: any[]);
reschedule(interval: number): void;
clear(): void;
destroy(): void;
}
class RateLimiter {
constructor(tokensPerInterval?: number, interval?: number, fireImmediately?: boolean);
removeTokens(count: number): Promise<number>;
tryRemoveTokens(count: number): boolean;
getTokensRemaining(): number;
}
namespace I {
interface ThrottleOptions {
max?: number;
interval?: number;
ordered?: boolean;
waitForReturn?: boolean;
interface ReInterval {
reschedule(interval: number): void;
clear(): void;
destroy(): void;
}
}
function throttle<R>(fn: () => R, options?: I.ThrottleOptions): () => Promise<R>;
function throttle<T1, R>(fn: (a: T1) => R, options?: I.ThrottleOptions): (a: T1) => Promise<R>;
function throttle<T1, T2, R>(fn: (a: T1, b: T2) => R, options?: I.ThrottleOptions): (a: T1, b: T2) => Promise<R>;
function throttle<T1, T2, T3, R>(fn: (a: T1, b: T2, c: T3) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3) => Promise<R>;
function throttle<T1, T2, T3, T4, R>(fn: (a: T1, b: T2, c: T3, d: T4) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3, d: T4) => Promise<R>;
function throttle<T1, T2, T3, T4, T5, R>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => R, options?: I.ThrottleOptions): (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise<R>;
function throttle<R>(fn: (...args: any[]) => R, options?: I.ThrottleOptions): (...args: any[]) => Promise<R>;
function reinterval(callback: (...args: any[]) => void, interval: number, args?: any[]): I.ReInterval;
namespace throttle {
namespace I {
interface Options {
max?: number;
interval?: number;
ordered?: boolean;
waitForReturn?: boolean;
onDone?: () => void;
drop?: boolean;
dropLast?: boolean;
}
}
function create<R>(fn: () => R, options?: I.Options): () => Promise<R>;
function create<T1, R>(fn: (a: T1) => R, options?: I.Options): (a: T1) => Promise<R>;
function create<T1, T2, R>(fn: (a: T1, b: T2) => R, options?: I.Options): (a: T1, b: T2) => Promise<R>;
function create<T1, T2, T3, R>(fn: (a: T1, b: T2, c: T3) => R, options?: I.Options): (a: T1, b: T2, c: T3) => Promise<R>;
function create<T1, T2, T3, T4, R>(fn: (a: T1, b: T2, c: T3, d: T4) => R, options?: I.Options): (a: T1, b: T2, c: T3, d: T4) => Promise<R>;
function create<T1, T2, T3, T4, T5, R>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => R, options?: I.Options): (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise<R>;
function create<R>(fn: (...args: any[]) => R, options?: I.Options): (...args: any[]) => Promise<R>;
class RateLimiter {
constructor(tokensPerInterval?: number, interval?: number, fireImmediately?: boolean);
removeTokens(count: number): Promise<number>;
tryRemoveTokens(count: number): boolean;
getTokensRemaining(): number;
}
const DROPPED: symbol;
}
namespace I.fakeClock {
interface Timer {
@@ -475,36 +474,6 @@ declare namespace adone {
function lowerBoundKey<T>(range: I.Range<T>): T | undefined;
}
/**
* Utils for uid/gid
*/
namespace userid {
/**
* Returns uid by the given username
*/
function uid(username: string): { uid: number, gid: number };
/**
* Returns gid by the given groupname
*/
function gid(groupname: string): number;
/**
* Returns username by the given uid
*/
function username(uid: number): string;
/**
* Returns groupname by the given gid
*/
function groupname(gid: number): string;
/**
* Returns gids the given user belongs
*/
function gids(username: string): number[];
}
/**
* Represents a log file rotator
*/
@@ -572,5 +541,598 @@ declare namespace adone {
function debounce<T1, T2, T3, T4, R>(fn: (a: T1, b: T2, c: T3, d: T4) => R, timeout: number, options?: I.DebounceOptions): (a: T1, b: T2, c: T3, d: T4) => R;
function debounce<T1, T2, T3, T4, T5, R>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => R, timeout: number, options?: I.DebounceOptions): (a: T1, b: T2, c: T3, d: T4, e: T5) => R;
function debounce<R>(fn: (...args: any[]) => R, timeout: number, options?: I.DebounceOptions): (...args: any[]) => R;
/**
* Finds difference between the given arrays
*/
function arrayDiff<T = any>(...arrays: T[][]): T[];
namespace I {
type FillRangeTransform = () => void;
interface FillRangeOptions {
/**
* The increment to use for the range. Can be used with letters or numbers
*/
step?: number;
/**
* By default, null is returned when an invalid range is passed.
* Enable this option to throw a RangeError on invalid ranges
*
* false by default
*/
strictRanges?: boolean;
/**
* Cast all returned values to strings.
*
* By default, integers are returned as numbers.
*/
stringify?: boolean;
/**
* Create a regex-compatible source string, instead of expanding values to an array.
*
* false by default
*/
toRegex?: boolean;
/**
* Customize each value in the returned array (or string)
*/
transform?: FillRangeTransform;
}
}
/**
* Expands numbers and letters
*/
function fillRange(from: number, to: number, options: I.FillRangeOptions & { toRegex: true }): string;
function fillRange(from: number, to: number, options: I.FillRangeOptions & { stringify: true }): string[];
function fillRange(from: number, to: number, options?: I.FillRangeOptions): number[];
function fillRange(from: string, to: string, options: I.FillRangeOptions & { toRegex: true }): string;
function fillRange(from: string, to: string, options?: I.FillRangeOptions): string[];
function fillRange(from: string | number, to: string | number, options: I.FillRangeOptions & { toRegex: true }): string;
function fillRange(from: string | number, to: string | number, options?: I.FillRangeOptions): Array<string | number>;
namespace inflection {
function singularizeWord(str: string, singular?: string): string;
function pluralizeWord(str: string, plural?: string): string;
function underscore(str: string, allUpperCase?: boolean): string;
}
function machineId(original?: boolean): Promise<string>;
namespace I {
interface MergeOptions {
plainObjects?: boolean;
allowPrototypes?: boolean;
}
}
function merge(target: any, source: any, options?: I.MergeOptions): any;
function omit(obj: any, props: ((v: string) => boolean) | string[] | string): object;
function parseTime(val: number): number;
function parseTime(val: any): number | null;
function pick(obj: any, props: Iterable<any>): object;
// pool: TODO
namespace querystring {
function escape(str: string): string;
const formats: {
RFC1738: "RFC1738"
RFC3986: "RFC3986",
default: string,
formatters: {
RFC1738(val: string): string,
RFC3986(val: string): string
}
};
namespace I {
interface ParseOptions {
ignoreQueryPrefix?: boolean;
delimiter?: string;
depth?: number;
arrayLimit?: number;
parseArrays?: boolean;
decoder?: (str: string, defaultDecoder: (str: string) => string) => string;
allowDots?: boolean;
plainObjects?: boolean;
allowPrototypes?: boolean;
parameterLimit?: number;
strictNullHandling?: boolean;
}
interface StringifyOptions {
delimiter?: string;
strictNullHandling?: boolean;
skipNulls?: boolean;
encode?: boolean;
encoder?: (str: string) => any;
filter?: Array<string | number> | ((prefix: string, value: any) => any);
arrayFormat?: "indices" | "brackets" | "repeat";
indices?: boolean;
sort?: (a: any, b: any) => number;
serializeDate?: (d: Date) => string;
format?: "RFC1738" | "RFC3986";
encodeValuesOnly?: boolean;
addQueryPrefix?: boolean;
allowDots?: boolean;
}
}
function parse(str: string, options?: I.ParseOptions): any;
function stringify(obj: any, options?: I.StringifyOptions): string;
function unescape(str: string): string;
}
namespace I {
interface RegexNotOptions {
contains?: boolean;
}
}
function regexNot(pattern: string, options?: I.RegexNotOptions): RegExp;
function repeat<T>(item: T, n: number): T[];
// retry: TODO
function signalNameToCode(signame: string): number;
function splitBuffer(buf: string | Buffer, splitBuf: string | Buffer, includeDelim?: boolean): Buffer[];
namespace I {
type SplitStringSplitFunction = (token: {
val: string;
idx: number;
arr: string[];
str: string;
}) => void;
interface SplitStringOptions {
braces?: object | boolean;
keepEscaping?: boolean;
keepQuotes?: boolean;
keepDoubleQuotes?: boolean;
keepSingleQuotes?: boolean;
separator?: string;
split?: SplitStringSplitFunction;
}
}
function splitString(str: string): string[];
function splitString(str: string, options: I.SplitStringOptions): string[];
function splitString(str: string, splitter: I.SplitStringSplitFunction): string[];
function splitString(str: string, options: I.SplitStringOptions, splitter: I.SplitStringSplitFunction): string[];
// terraformer: TODO
namespace I {
interface ToRegexOptions {
contains?: boolean;
negate?: boolean;
nocase?: boolean;
flags?: string;
cache?: boolean;
}
}
function toRegex(patterns: string | string[], options?: I.ToRegexOptions): RegExp;
namespace I {
interface ToRegexRangeOptions {
capture?: boolean;
shorthand?: boolean;
relaxZeros?: boolean;
}
}
function toRegexRange(min: string | number, max: string | number, options?: I.ToRegexRangeOptions): RegExp;
namespace xorDistance {
function compare(a: Buffer, b: Buffer): boolean;
function create(a: Buffer, b: Buffer): Buffer;
function gt(a: Buffer, b: Buffer): boolean;
function lt(a: Buffer, b: Buffer): boolean;
function eq(a: Buffer, b: Buffer): boolean;
}
namespace I {
interface BracesOptions {
/**
* Generate an "expanded" brace pattern (this option is unncessary with the `.expand` method, which does the same thing).
*
* @default undefined
*/
expand?: boolean;
/**
* Enabled by default.
*
* @default true
*/
optimize?: boolean;
/**
* Duplicates are removed by default. To keep duplicates, pass `{nodupes: false}` on the options
*
* @default true
*/
nodupes?: boolean;
/**
* When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize)
* when the difference between the range minimum and range maximum exceeds the `rangeLimit`.
* This is to prevent huge ranges from freezing your application.
*
* You can set this to any number, or change `options.rangeLimit` to `Inifinity` to disable this altogether.
*
* @default 250
*/
rangeLimit?: number;
/**
* Customize range expansion.
*
* @default undefined
*/
transform?: (str: string) => string;
/**
* In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, `a{1,3}` will match the letter `a` one to three times.
*
* Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists)
*
* The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers)
* are defined in the given pattern, and not to try to expand them as lists.
*
* @default undefined
*/
quantifiers?: boolean;
/**
* Strip backslashes that were used for escaping from the result.
*
* @default undefined
*/
unescape?: boolean;
}
interface BracesFunction {
(pattern: string, options?: BracesOptions): string[];
expand(pattern: string, options?: BracesOptions): string[];
MAX_LENGTH: number;
clearCache(): void;
resizeCache(newSize: number): void;
getCache(): object; // TODO
makeRe(pattern: string, options?: BracesOptions): RegExp;
}
}
const braces: I.BracesFunction;
namespace I {
interface MatchOptions {
/**
* Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`.
*
* @default false
*/
basename?: boolean;
/**
* Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression.
* Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**.
* Instead, the star is treated the same as an other star.
*
* @default true
*/
bash?: boolean;
/**
* Disable regex and function memoization.
*
* @default undefined
*/
cache?: boolean;
/**
* Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`.
*
* @default false
*/
dot?: boolean;
/**
* Similar to the `--failglob` behavior in Bash, throws an error when no matches are found.
*
* @default undefined
*/
failglob?: boolean;
/**
* String or array of glob patterns to match files to ignore.
*
* @default undefined
*/
ignore?: string | string[];
/**
* Alias for [options.basename](#options-basename).
*/
matchBase?: boolean;
/**
* Disable expansion of brace patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nobrace`.
*
* @default undefined
*/
nobrace?: boolean;
/**
* Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch).
*
* @default undefined
*/
nocase?: boolean;
/**
* Remove duplicate elements from the result array.
*
* @default undefined
*/
nodupes?: boolean;
/**
* Disable extglob support, so that extglobs are regarded as literal characters.
*
* @default undefined
*/
noext?: boolean;
/**
* Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match.
*
* @default undefined
*/
nonegate?: boolean;
/**
* Disable matching with globstars (`**`).
*
* @default undefined
*/
noglobstar?: boolean;
/**
* Alias for [options.nullglob](#options-nullglob).
*/
nonull?: boolean;
/**
* If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array.
* Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`.
*
* @default undefined
*/
nullglob?: boolean;
/**
* Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon), to customize parsers or compilers.
*
* @default undefined
*/
snapdragon?: object;
/**
* Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods.
*
* _(Note that sourcemaps are currently not enabled for brace patterns)_
*/
sourcemap?: boolean;
/**
* Remove backslashes from returned matches.
*
* @default undefined
*/
unescape?: boolean;
/**
* Convert path separators on returned files to posix/unix-style forward slashes.
*
* @default true
*/
unixify?: boolean;
}
interface MatchFunction {
/**
* The main function takes a list of strings and one or more glob patterns to use for matching.
*
* @param list A list of strings to match
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns an array of matches
*/
(list: string[], patterns: string | string[], options?: MatchOptions): string[];
/**
* Similar to the main function, but `pattern` must be a string.
*
* @param list Array of strings to match
* @param pattern Glob pattern to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns an array of matches
*/
match(list: string[], pattern: string, options?: MatchOptions): string[];
/**
* Returns true if the specified `string` matches the given glob `pattern`.
*
* @param string String to match
* @param pattern Glob pattern to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if the string matches the glob pattern.
*/
isMatch(string: string, pattern: string, options?: MatchOptions): boolean;
/**
* Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
*
* @param list The string or array of strings to test. Returns as soon as the first match is found.
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if any patterns match `str`
*/
some(list: string | string[], patterns: string | string[], options?: MatchOptions): boolean;
/**
* Returns true if every string in the given `list` matches any of the given glob `patterns`.
*
* @param list The string or array of strings to test.
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if any patterns match `str`
*/
every(list: string | string[], patterns: string | string[], options?: MatchOptions): boolean;
/**
* Returns true if **any** of the given glob `patterns` match the specified `string`.
*
* @param str The string to test.
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if any patterns match `str`
*/
any(str: string | string[], patterns: string | string[], options?: MatchOptions): boolean;
/**
* Returns true if **all** of the given `patterns` match the specified string.
*
* @param str The string to test.
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if any patterns match `str`
*/
all(str: string | string[], patterns: string | string[], options?: MatchOptions): boolean;
/**
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
*
* @param list Array of strings to match.
* @param patterns One or more glob pattern to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns an array of strings that **do not match** the given patterns.
*/
not(list: string[], patterns: string | string[], options?: MatchOptions): string[];
/**
* Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
*
* @param str The string to match.
* @param patterns Glob pattern to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns true if the patter matches any part of `str`.
*/
contains(str: string, patterns: string | string[], options?: MatchOptions): boolean;
/**
* Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys.
* If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead.
*
* @param object The object with keys to filter.
* @param patterns One or more glob patterns to use for matching.
* @param options See available options for changing how matches are performed
* @returns Returns an object with only keys that match the given patterns.
*/
matchKeys<T>(object: T, patterns: string | string[], options?: MatchOptions): Partial<T>;
/**
* Returns a memoized matcher function from the given glob `pattern` and `options`.
* The returned function takes a string to match as its only argument and returns true if the string is a match.
*
* @param pattern Glob pattern
* @param options See available options for changing how matches are performed.
* @returns Returns a matcher function.
*/
matcher(pattern: string | string[], options?: MatchOptions): (str: string) => boolean;
/**
* Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
*
* @param pattern Glob pattern to use for matching.
* @param string String to match
* @param options See available options for changing how matches are performed
* @returns Returns an array of captures if the string matches the glob pattern, otherwise `null`.
*/
capture(pattern: string, string: string, options?: MatchOptions): string[] | null;
/**
* Create a regular expression from the given glob `pattern`.
*
* @param pattern A glob pattern to convert to regex.
* @param options See available options for changing how matches are performed.
* @returns Returns a regex created from the given pattern.
*/
makeRe(pattern: string, options?: MatchOptions): RegExp;
/**
* Expand the given brace `pattern`.
*
* @param pattern String with brace pattern to expand.
* @param options Any options to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options.
*/
braces(pattern: string, options?: MatchOptions): string[];
/**
* Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST.
*
* @param pattern Glob pattern to parse and compile.
* @param options Any options to change how parsing and compiling is performed.
* @returns Returns an object with the parsed AST, compiled string and optional source map.
*/
create(pattern: string, options?: MatchOptions): object;
/**
* Parse the given `str` with the given `options`.
*
* @returns Returns an AST
*/
parse(str: string, options?: MatchOptions): object;
/**
* Compile the given `ast` or string with the given `options`.
*
* @returns Returns an object that has an `output` property with the compiled string.
*/
compile(ast: object | string, options?: MatchOptions): object;
MAX_LENGTH: number;
clearCache(): void;
resizeCache(newSize: number): void;
getCache(): object; // TODO
}
}
const match: I.MatchFunction;
}
}
+1
View File
@@ -18,6 +18,7 @@
/// <reference path="./glosses/fs.d.ts" />
/// <reference path="./glosses/is.d.ts" />
/// <reference path="./glosses/math/index.d.ts" />
/// <reference path="./glosses/meta.d.ts" />
/// <reference path="./glosses/promise.d.ts" />
/// <reference path="./glosses/shani.d.ts" />
/// <reference path="./glosses/shani-global.d.ts" />
File diff suppressed because it is too large Load Diff
+90 -90
View File
@@ -3,9 +3,9 @@ namespace assertionTests {
namespace assertionInterface {
namespace exception {
const a: adone.x.Exception = new assertion.AssertionError();
const b: adone.x.Exception = new assertion.AssertionError("hello");
const c: adone.x.Exception = new assertion.AssertionError("hello", { actual: 2, expected: 3 }, () => {});
const a: adone.exception.Exception = new assertion.AssertionError();
const b: adone.exception.Exception = new assertion.AssertionError("hello");
const c: adone.exception.Exception = new assertion.AssertionError("hello", { actual: 2, expected: 3 }, () => {});
}
namespace config {
@@ -38,11 +38,11 @@ namespace assertionTests {
assert.fail(1, 2, "hello");
assert.fail(1, 2, "hello", "<");
assert.isOk(1);
assert.isOk(1, "hello");
assert.ok(1);
assert.ok(1, "hello");
assert.isNotOk(1);
assert.isNotOk(1, "hello");
assert.notOk(1);
assert.notOk(1, "hello");
assert.equal(1, 2);
assert.equal(1, 2, "hello");
@@ -68,38 +68,38 @@ namespace assertionTests {
assert.notDeepEqual(1, 2);
assert.notDeepEqual(1, 2, "hello");
assert.isAbove(1, 2);
assert.isAbove(1, 2, "hello");
assert.above(1, 2);
assert.above(1, 2, "hello");
assert.isAtLeast(1, 2);
assert.isAtLeast(1, 2, "hello");
assert.atLeast(1, 2);
assert.atLeast(1, 2, "hello");
assert.isBelow(1, 2);
assert.isBelow(1, 2, "hello");
assert.below(1, 2);
assert.below(1, 2, "hello");
assert.isAtMost(1, 2);
assert.isAtMost(1, 2, "hello");
assert.atMost(1, 2);
assert.atMost(1, 2, "hello");
assert.isTrue(1);
assert.isTrue(1, "hello");
assert.true(1);
assert.true(1, "hello");
assert.isNotTrue(1);
assert.isNotTrue(1, "hello");
assert.notTrue(1);
assert.notTrue(1, "hello");
assert.isFalse(1);
assert.isFalse(1, "hello");
assert.false(1);
assert.false(1, "hello");
assert.isNotFalse(1);
assert.isNotFalse(1, "hello");
assert.notFalse(1);
assert.notFalse(1, "hello");
assert.isNull(1);
assert.isNull(1, "hello");
assert.null(1);
assert.null(1, "hello");
assert.isNaN(1);
assert.isNaN(1, "hello");
assert.NaN(1);
assert.NaN(1, "hello");
assert.isNotNaN(1);
assert.isNotNaN(1, "hello");
assert.NotNaN(1);
assert.NotNaN(1, "hello");
assert.exists(1);
assert.exists(1, "hello");
@@ -107,49 +107,49 @@ namespace assertionTests {
assert.notExists(1);
assert.notExists(1, "hello");
assert.isUndefined(1);
assert.isUndefined(1, "hello");
assert.undefined(1);
assert.undefined(1, "hello");
assert.isDefined(1);
assert.isDefined(1, "hello");
assert.defined(1);
assert.defined(1, "hello");
assert.isFunction(1);
assert.isFunction(1, "hello");
assert.function(1);
assert.function(1, "hello");
assert.isNotFunction(1);
assert.isNotFunction(1, "hello");
assert.notFunction(1);
assert.notFunction(1, "hello");
assert.isObject(1);
assert.isObject(1, "hello");
assert.object(1);
assert.object(1, "hello");
assert.isNotObject(1);
assert.isNotObject(1, "hello");
assert.notObject(1);
assert.notObject(1, "hello");
assert.isArray(1);
assert.isArray(1, "hello");
assert.array(1);
assert.array(1, "hello");
assert.isNotArray(1);
assert.isNotArray(1, "hello");
assert.notArray(1);
assert.notArray(1, "hello");
assert.isString(1, "hello");
assert.string(1, "hello");
assert.isNotString(1);
assert.isNotString(1, "hello");
assert.notString(1);
assert.notString(1, "hello");
assert.isNumber(1);
assert.isNumber(1, "hello");
assert.number(1);
assert.number(1, "hello");
assert.isNotNumber(1);
assert.isNotNumber(1, "hello");
assert.notNumber(1);
assert.notNumber(1, "hello");
assert.isFinite(1);
assert.isFinite(1, "hello");
assert.finite(1);
assert.finite(1, "hello");
assert.isBoolean(1);
assert.isBoolean(1, "hello");
assert.boolean(1);
assert.boolean(1, "hello");
assert.isNotBoolean(1);
assert.isNotBoolean(1, "hello");
assert.notBoolean(1);
assert.notBoolean(1, "hello");
assert.typeOf(1, "string");
assert.typeOf(1, "number", "hello");
@@ -457,26 +457,26 @@ namespace assertionTests {
assert.ifError(1);
assert.isExtensible({});
assert.isExtensible({}, "hello");
assert.extensible({});
assert.extensible({}, "hello");
assert.isNotExtensible({});
assert.isNotExtensible({}, "hello");
assert.notExtensible({});
assert.notExtensible({}, "hello");
assert.isSealed({});
assert.isSealed({}, "hello");
assert.sealed({});
assert.sealed({}, "hello");
assert.isNotSealed({});
assert.isNotSealed({}, "hello");
assert.notSealed({});
assert.notSealed({}, "hello");
assert.isFrozen({});
assert.isFrozen({}, "hello");
assert.frozen({});
assert.frozen({}, "hello");
assert.isNotFrozen({});
assert.isNotFrozen({}, "hello");
assert.notFrozen({});
assert.notFrozen({}, "hello");
assert.isEmpty({});
assert.isEmpty({}, "hello");
assert.empty({});
assert.empty({}, "hello");
}
const { expect } = assertion;
@@ -499,16 +499,16 @@ namespace assertionTests {
expect(1).to.contain(2, "hello").and;
expect(1).but.contains(2).and;
expect(1).but.contains(2, "hello").and;
expect(1).to.ok.not.ok;
expect(1).to.be.true.but.false;
expect(1).to.be.false.but.true;
expect(1).to.be.null.and.null;
expect(1).to.be.undefined.and.true;
expect(1).to.be.NaN.and.null;
expect(1).to.exist.and.be.null;
expect(1).to.be.empty.and.true;
expect(1).to.be.arguments.and.a("number");
expect(1).to.be.Arguments.and.false;
expect(1).to.ok().and.a("string");
expect(1).to.be.true().but.false();
expect(1).to.be.false().but.true();
expect(1).to.be.null().and.null();
expect(1).to.be.undefined().and.true();
expect(1).to.be.NaN().and.null();
expect(1).to.exist().and.be.null();
expect(1).to.be.empty().and.true();
expect(1).to.be.arguments().and.a("number");
expect(1).to.be.Arguments().and.false();
expect(1).to.be.equal(2).and;
expect(1).to.be.equal(2, "hello").and;
expect(1).but.equals(2).and;
@@ -624,19 +624,19 @@ namespace assertionTests {
expect(() => {}).but.decreases({}, "a", "hello").and;
expect(() => {}).to.decreases({}).by(2).and;
expect(() => {}).to.decreases({}).by(2, "hello").and;
expect({}).to.be.extensible.and;
expect({}).to.be.sealed.and;
expect({}).to.be.frozen.and;
expect({}).to.be.finite.and;
expect({}).to.be.extensible().and;
expect({}).to.be.sealed().and;
expect({}).to.be.frozen().and;
expect({}).to.be.finite().and;
namespace mockTests {
const s1 = adone.shani.util.spy();
const s2 = adone.shani.util.spy();
expect(s1).to.have.been.called;
expect(s1).to.have.been.calledOnce;
expect(s1).to.have.been.calledTwice;
expect(s1).to.have.been.calledThrice;
expect(s1).to.have.been.called();
expect(s1).to.have.been.calledOnce();
expect(s1).to.have.been.calledTwice();
expect(s1).to.have.been.calledThrice();
expect(s1).to.have.callCount(100);
expect(s1).to.have.been.calledBefore(s2);
expect(s1).to.have.been.calledAfter(s2);
+7
View File
@@ -11,6 +11,7 @@ namespace dataTests {
{ const a: Buffer = json.encode(1, { replacer: ["a", "b", "c"] }); }
{ const a: Buffer = json.encode(1, { replacer: (k: string, v: any) => null }); }
{ const a: Buffer = json.encode(1, { space: " " }); }
{ const a: Buffer = json.encode(1, { newline: true }); }
json.decode("123");
json.decode(Buffer.from("123"));
@@ -52,6 +53,8 @@ namespace dataTests {
mpak.decode(new Uint8Array(10));
mpak.decode(new ArrayBuffer(10));
mpak.tryDecode(new adone.collection.ByteArray());
new mpak.Encoder([]);
new mpak.Encoder([{
type: 10,
@@ -73,6 +76,9 @@ namespace dataTests {
new mpak.Decoder([]).decode(new ArrayBuffer(10));
new mpak.Decoder([]).tryDecode(adone.collection.ByteArray.wrap("hello"));
new mpak.Serializer();
new mpak.Serializer(100);
mpak.registerCommonTypesFor(new mpak.Serializer());
{ const a: adone.data.mpak.Encoder = new mpak.Serializer().encoder; }
{ const a: adone.data.mpak.Decoder = new mpak.Serializer().decoder; }
{ const a: adone.data.mpak.Serializer = new mpak.Serializer().registerEncoder(10, (x) => true, (x) => new adone.collection.ByteArray(10)); }
@@ -125,6 +131,7 @@ namespace dataTests {
{ const a: string = base64.decode("string", {}); }
{ const a: string = base64.decode("string", { buffer: false }); }
{ const a: Buffer = base64.decode("string", { buffer: true }); }
{ const a: string = base64.decode("string", { encoding: "utf8" }); }
{ const a: string = base64.encodeVLQ(123); }
{ const a: number = base64.decodeVLQ("H"); }
+37 -27
View File
@@ -1,76 +1,86 @@
namespace eventsTests {
namespace EventEmitter {
namespace static {
const a: number = adone.event.EventEmitter.listenerCount(new adone.event.EventEmitter(), "event");
const b: number = adone.event.EventEmitter.defaultMaxListeners;
const a: number = adone.event.Emitter.listenerCount(new adone.event.Emitter(), "event");
const b: number = adone.event.Emitter.defaultMaxListeners;
}
namespace addListener {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().addListener("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().addListener(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().addListener("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().addListener(Symbol("event"), () => { });
}
namespace on {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().on("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().on(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().on("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().on(Symbol("event"), () => { });
}
namespace once {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().once("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().once(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().once("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().once(Symbol("event"), () => { });
}
namespace prependListener {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().prependListener("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().prependListener(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().prependListener("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().prependListener(Symbol("event"), () => { });
}
namespace prependOnceListener {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().prependOnceListener("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().prependOnceListener(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().prependOnceListener("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().prependOnceListener(Symbol("event"), () => { });
}
namespace removeListener {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().removeListener("event", () => { });
const b: adone.event.EventEmitter = new adone.event.EventEmitter().removeListener(Symbol("event"), () => { });
const a: adone.event.Emitter = new adone.event.Emitter().removeListener("event", () => { });
const b: adone.event.Emitter = new adone.event.Emitter().removeListener(Symbol("event"), () => { });
}
namespace removeAllListeners {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().removeAllListeners("event");
const b: adone.event.EventEmitter = new adone.event.EventEmitter().removeAllListeners(Symbol("event"));
const a: adone.event.Emitter = new adone.event.Emitter().removeAllListeners("event");
const b: adone.event.Emitter = new adone.event.Emitter().removeAllListeners(Symbol("event"));
}
namespace setMaxListeners {
const a: adone.event.EventEmitter = new adone.event.EventEmitter().setMaxListeners(10);
const a: adone.event.Emitter = new adone.event.Emitter().setMaxListeners(10);
}
namespace getMaxListeners {
const a: number = new adone.event.EventEmitter().getMaxListeners();
const a: number = new adone.event.Emitter().getMaxListeners();
}
namespace listeners {
const a: Array<(...args: any[]) => any> = new adone.event.EventEmitter().listeners("event");
const b: Array<(...args: any[]) => any> = new adone.event.EventEmitter().listeners(Symbol("event"));
const a: Array<(...args: any[]) => any> = new adone.event.Emitter().listeners("event");
const b: Array<(...args: any[]) => any> = new adone.event.Emitter().listeners(Symbol("event"));
}
namespace emit {
const a: boolean = new adone.event.EventEmitter().emit("event", 1, 2, 3);
const b: boolean = new adone.event.EventEmitter().emit(Symbol("event"), 1, 2, 3);
const a: boolean = new adone.event.Emitter().emit("event", 1, 2, 3);
const b: boolean = new adone.event.Emitter().emit(Symbol("event"), 1, 2, 3);
}
namespace eventNames {
const a: Array<string | symbol> = new adone.event.EventEmitter().eventNames();
const b: Array<string | symbol> = new adone.event.EventEmitter().eventNames();
const a: Array<string | symbol> = new adone.event.Emitter().eventNames();
const b: Array<string | symbol> = new adone.event.Emitter().eventNames();
}
namespace listenerCount {
const a: number = new adone.event.EventEmitter().listenerCount("event");
const b: number = new adone.event.EventEmitter().listenerCount(Symbol("event"));
const a: number = new adone.event.Emitter().listenerCount("event");
const b: number = new adone.event.Emitter().listenerCount(Symbol("event"));
}
namespace propagateEvents {
const e = new adone.event.Emitter().propagateEvents(new adone.event.Emitter(), ["a"]);
e.end();
}
namespace staticPropagateEvents {
const e = adone.event.Emitter.propagateEvents(new adone.event.Emitter(), new adone.event.Emitter(), ["a"]);
e.end();
}
}
namespace AsyncEmitter {
const a: adone.event.EventEmitter = new adone.event.AsyncEmitter();
const a: adone.event.Emitter = new adone.event.AsyncEmitter();
new adone.event.AsyncEmitter(10);
namespace setConcurrency {
+34 -34
View File
@@ -1,36 +1,36 @@
namespace ExcetpionsTests {
{ const a: Error = new adone.x.Exception(); }
{ const a: Error = new adone.x.Exception("message"); }
{ const a: Error = new adone.x.Exception(new Error()); }
{ const a: Error = new adone.x.Exception(new Error(), true); }
{ const a: adone.x.Exception = new adone.x.Runtime(); }
{ const a: adone.x.Exception = new adone.x.IncompleteBufferError(); }
{ const a: adone.x.Exception = new adone.x.NotImplemented(); }
{ const a: adone.x.Exception = new adone.x.IllegalState(); }
{ const a: adone.x.Exception = new adone.x.NotValid(); }
{ const a: adone.x.Exception = new adone.x.Unknown(); }
{ const a: adone.x.Exception = new adone.x.NotExists(); }
{ const a: adone.x.Exception = new adone.x.Exists(); }
{ const a: adone.x.Exception = new adone.x.Empty(); }
{ const a: adone.x.Exception = new adone.x.InvalidAccess(); }
{ const a: adone.x.Exception = new adone.x.NotSupported(); }
{ const a: adone.x.Exception = new adone.x.InvalidArgument(); }
{ const a: adone.x.Exception = new adone.x.InvalidNumberOfArguments(); }
{ const a: adone.x.Exception = new adone.x.NotFound(); }
{ const a: adone.x.Exception = new adone.x.Timeout(); }
{ const a: adone.x.Exception = new adone.x.Incorrect(); }
{ const a: adone.x.Exception = new adone.x.NotAllowed(); }
{ const a: adone.x.Exception = new adone.x.LimitExceeded(); }
{ const a: adone.x.Exception = new adone.x.Encoding(); }
{ const a: adone.x.Exception = new adone.x.Network(); }
{ const a: adone.x.Exception = new adone.x.Bind(); }
{ const a: adone.x.Exception = new adone.x.Connect(); }
{ const a: adone.x.Exception = new adone.x.Database(); }
{ const a: adone.x.Exception = new adone.x.DatabaseInitialization(); }
{ const a: adone.x.Exception = new adone.x.DatabaseOpen(); }
{ const a: adone.x.Exception = new adone.x.DatabaseRead(); }
{ const a: adone.x.Exception = new adone.x.DatabaseWrite(); }
{ const a: adone.x.Exception = new adone.x.NetronIllegalState(); }
{ const a: adone.x.Exception = new adone.x.NetronPeerDisconnected(); }
{ const a: adone.x.Exception = new adone.x.NetronTimeout(); }
{ const a: Error = new adone.exception.Exception(); }
{ const a: Error = new adone.exception.Exception("message"); }
{ const a: Error = new adone.exception.Exception(new Error()); }
{ const a: Error = new adone.exception.Exception(new Error(), true); }
{ const a: adone.exception.Exception = new adone.exception.Runtime(); }
{ const a: adone.exception.Exception = new adone.exception.IncompleteBufferError(); }
{ const a: adone.exception.Exception = new adone.exception.NotImplemented(); }
{ const a: adone.exception.Exception = new adone.exception.IllegalState(); }
{ const a: adone.exception.Exception = new adone.exception.NotValid(); }
{ const a: adone.exception.Exception = new adone.exception.Unknown(); }
{ const a: adone.exception.Exception = new adone.exception.NotExists(); }
{ const a: adone.exception.Exception = new adone.exception.Exists(); }
{ const a: adone.exception.Exception = new adone.exception.Empty(); }
{ const a: adone.exception.Exception = new adone.exception.InvalidAccess(); }
{ const a: adone.exception.Exception = new adone.exception.NotSupported(); }
{ const a: adone.exception.Exception = new adone.exception.InvalidArgument(); }
{ const a: adone.exception.Exception = new adone.exception.InvalidNumberOfArguments(); }
{ const a: adone.exception.Exception = new adone.exception.NotFound(); }
{ const a: adone.exception.Exception = new adone.exception.Timeout(); }
{ const a: adone.exception.Exception = new adone.exception.Incorrect(); }
{ const a: adone.exception.Exception = new adone.exception.NotAllowed(); }
{ const a: adone.exception.Exception = new adone.exception.LimitExceeded(); }
{ const a: adone.exception.Exception = new adone.exception.Encoding(); }
{ const a: adone.exception.Exception = new adone.exception.Network(); }
{ const a: adone.exception.Exception = new adone.exception.Bind(); }
{ const a: adone.exception.Exception = new adone.exception.Connect(); }
{ const a: adone.exception.Exception = new adone.exception.Database(); }
{ const a: adone.exception.Exception = new adone.exception.DatabaseInitialization(); }
{ const a: adone.exception.Exception = new adone.exception.DatabaseOpen(); }
{ const a: adone.exception.Exception = new adone.exception.DatabaseRead(); }
{ const a: adone.exception.Exception = new adone.exception.DatabaseWrite(); }
{ const a: adone.exception.Exception = new adone.exception.NetronIllegalState(); }
{ const a: adone.exception.Exception = new adone.exception.NetronPeerDisconnected(); }
{ const a: adone.exception.Exception = new adone.exception.NetronTimeout(); }
}
+188 -34
View File
@@ -11,6 +11,15 @@ namespace fsTests {
fs.readlink("file", null).then((x: Buffer) => x);
fs.readlink("file", "hex").then((x: string) => x);
fs.readlink("file").then((x: string) => x);
fs.readlinkSync("file");
fs.readlinkSync(Buffer.from("file"));
fs.readlinkSync(new URL("file://file"));
{ const a: string = fs.readlinkSync("file", {}); }
{ const a: string = fs.readlinkSync("file", { encoding: "utf8" }); }
{ const a: Buffer = fs.readlinkSync("file", { encoding: null }); }
{ const a: Buffer = fs.readlinkSync("file", null); }
{ const a: string = fs.readlinkSync("file", "hex"); }
{ const a: string = fs.readlinkSync("file"); }
}
namespace unlinkTests {
@@ -22,6 +31,24 @@ namespace fsTests {
fs.unlinkSync(new URL("file://file"));
}
namespace utimesTests {
fs.utimes("hello", 100, 100).then(() => {});
fs.utimes(Buffer.from("hello"), 100, 100).then(() => {});
fs.utimes(new URL("hello"), 100, 100).then(() => {});
fs.utimes("hello", "100", "100").then(() => {});
fs.utimes("hello", new Date(100), new Date(100)).then(() => {});
fs.utimesSync("hello", 100, 100);
fs.utimesSync(Buffer.from("hello"), 100, 100);
fs.utimesSync(new URL("hello"), 100, 100);
fs.utimesSync("hello", "100", "100");
fs.utimesSync("hello", new Date(100), new Date(100));
fs.utimesMillis("hello", 100, 100);
fs.utimesMillis(Buffer.from("hello"), 100, 100);
fs.utimesMillis(new URL("hello"), 100, 100);
}
namespace chmodTests {
fs.chmod("file", 0o333).then(() => {});
fs.chmod(Buffer.from("file"), 0o333).then(() => {});
@@ -60,6 +87,87 @@ namespace fsTests {
const e: Buffer[] = fs.readdirSync("file", { encoding: null });
}
namespace readdirpTests {
fs.readdirp("hello").forEach((entry) => {
{ const a: string = entry.fullParentDir; }
{ const a: string = entry.fullPath; }
{ const a: string = entry.name; }
{ const a: string = entry.parentDir; }
{ const a: string = entry.path; }
{ const a: adone.fs.I.Stats = entry.stat; }
});
fs.readdirp(Buffer.from("hello"));
fs.readdirp(new URL("hello"));
fs.readdirp("hello", {});
fs.readdirp("hello", { depth: 100 });
fs.readdirp("hello", { directories: true });
fs.readdirp("hello", { directoryFilter: () => true });
fs.readdirp("hello", {
directoryFilter: (entry) => {
{ const a: string = entry.fullParentDir; }
{ const a: string = entry.fullPath; }
{ const a: string = entry.name; }
{ const a: string = entry.parentDir; }
{ const a: string = entry.path; }
{ const a: adone.fs.I.Stats = entry.stat; }
return true;
}
});
fs.readdirp("hello", {
directoryFilter: [(entry) => {
{ const a: string = entry.fullParentDir; }
{ const a: string = entry.fullPath; }
{ const a: string = entry.name; }
{ const a: string = entry.parentDir; }
{ const a: string = entry.path; }
{ const a: adone.fs.I.Stats = entry.stat; }
return true;
}]
});
fs.readdirp("hello", {
directoryFilter: ["*"]
});
fs.readdirp("hello", {
directoryFilter: "*"
});
fs.readdirp("hello", { fileFilter: () => true });
fs.readdirp("hello", {
fileFilter: (entry) => {
{ const a: string = entry.fullParentDir; }
{ const a: string = entry.fullPath; }
{ const a: string = entry.name; }
{ const a: string = entry.parentDir; }
{ const a: string = entry.path; }
{ const a: adone.fs.I.Stats = entry.stat; }
return true;
}
});
fs.readdirp("hello", {
fileFilter: [(entry) => {
{ const a: string = entry.fullParentDir; }
{ const a: string = entry.fullPath; }
{ const a: string = entry.name; }
{ const a: string = entry.parentDir; }
{ const a: string = entry.path; }
{ const a: adone.fs.I.Stats = entry.stat; }
return true;
}]
});
fs.readdirp("hello", {
fileFilter: ["*"]
});
fs.readdirp("hello", {
fileFilter: "*"
});
fs.readdirp("hello", {
files: false
});
fs.readdirp("hello", {
lstat: true
});
}
namespace lstatTests {
fs.lstat("file").then((x: nodestd.fs.Stats) => {});
fs.lstat(Buffer.from("file")).then((x: nodestd.fs.Stats) => {});
@@ -119,6 +227,15 @@ namespace fsTests {
fs.appendFile("file", "hello", { encoding: "utf8" }).then(() => {});
fs.appendFile("file", "hello", { mode: 0o755 }).then(() => {});
fs.appendFile("file", "hello", { flag: "w" }).then(() => {});
fs.appendFileSync("file", "hello");
fs.appendFileSync(Buffer.from("file"), "hello");
fs.appendFileSync(10, "hello");
fs.appendFileSync("file", Buffer.from("hello"));
fs.appendFileSync("file", "hello", {});
fs.appendFileSync("file", "hello", { encoding: "utf8" });
fs.appendFileSync("file", "hello", { mode: 0o755 });
fs.appendFileSync("file", "hello", { flag: "w" });
}
namespace accessTests {
@@ -153,6 +270,12 @@ namespace fsTests {
fs.rm("file", { cwd: __dirname }).then((x) => {});
}
namespace rmEmptyTests {
fs.rmEmpty("file").then(() => {});
fs.rmEmpty("file", { cwd: "a" }).then(() => {});
fs.rmEmpty("file", { filter: (filename) => filename.charCodeAt(0) === 100 }).then(() => {});
}
namespace ModeTests {
const stat = fs.statSync("file");
const mode = new fs.Mode(stat);
@@ -513,37 +636,36 @@ namespace fsTests {
}
namespace fdTests {
const { fd } = fs;
fd.open("hello", "r+").then((x: number) => {});
fd.open(Buffer.from("hello"), "r+").then((x: number) => {});
fd.open(new URL("file://hello"), "r+").then((x: number) => {});
{ const a: number = fd.openSync("hello", "r+"); }
{ const a: number = fd.openSync(Buffer.from("hello"), "r+"); }
{ const a: number = fd.openSync(new URL("file://hello"), "r+"); }
fd.close(10).then(() => {});
fd.closeSync(10);
fd.utimes(10, 100500, 100500).then(() => {});
fd.utimesSync(10, 100500, 100500);
fd.stat(10).then((x: adone.fs.I.Stats) => {});
{ const a: adone.fs.I.Stats = fd.statSync(10); }
fd.truncate(10).then(() => {});
fd.truncate(10, 10).then(() => {});
fd.truncateSync(10);
fd.truncateSync(10, 10);
fd.read(10, Buffer.alloc(10), 0, 10, 10).then((x: number) => {});
{ const a: number = fd.readSync(10, Buffer.alloc(10), 0, 10, 10); }
fd.write(10, Buffer.alloc(10), 0, 10, 10).then((x: number) => {});
{ const a: number = fd.writeSync(10, Buffer.alloc(10), 0, 10, 10); }
fd.write(10, "hello", 10, "utf8").then((x: number) => {});
{ const a: number = fd.writeSync(10, "hello", 10, "utf8"); }
fd.sync(10).then(() => {});
fd.syncSync(10);
fd.chown(10, 0, 0).then(() => {});
fd.chownSync(10, 0, 0);
fd.chmod(10, 0o755).then(() => {});
fd.chmodSync(10, 0o755);
fd.seek(10, 100, 0).then((x: number) => {});
fd.lock(10, "sh").then(() => {});
fs.open("hello", "r+").then((x: number) => {});
fs.open(Buffer.from("hello"), "r+").then((x: number) => {});
fs.open(new URL("file://hello"), "r+").then((x: number) => {});
{ const a: number = fs.openSync("hello", "r+"); }
{ const a: number = fs.openSync(Buffer.from("hello"), "r+"); }
{ const a: number = fs.openSync(new URL("file://hello"), "r+"); }
fs.close(10).then(() => {});
fs.closeSync(10);
fs.futimes(10, 100500, 100500).then(() => {});
fs.futimesSync(10, 100500, 100500);
fs.fstat(10).then((x: adone.fs.I.Stats) => {});
{ const a: adone.fs.I.Stats = fs.fstatSync(10); }
fs.ftruncate(10).then(() => {});
fs.ftruncate(10, 10).then(() => {});
fs.ftruncateSync(10);
fs.ftruncateSync(10, 10);
fs.read(10, Buffer.alloc(10), 0, 10, 10).then((x: number) => {});
{ const a: number = fs.readSync(10, Buffer.alloc(10), 0, 10, 10); }
fs.write(10, Buffer.alloc(10), 0, 10, 10).then((x: number) => {});
{ const a: number = fs.writeSync(10, Buffer.alloc(10), 0, 10, 10); }
fs.write(10, "hello", 10, "utf8").then((x: number) => {});
{ const a: number = fs.writeSync(10, "hello", 10, "utf8"); }
fs.fsync(10).then(() => {});
fs.fsyncSync(10);
fs.fchown(10, 0, 0).then(() => {});
fs.fchownSync(10, 0, 0);
fs.fchmod(10, 0o755).then(() => {});
fs.fchmodSync(10, 0o755);
fs.seek(10, 100, 0).then((x: number) => {});
fs.flock(10, "sh").then(() => {});
}
namespace constantsTests {
@@ -668,13 +790,44 @@ namespace fsTests {
namespace mkdirTests {
fs.mkdir("/path/to/some/dir").then(() => {});
fs.mkdir("/path/to/some/dir", 0o755).then(() => {});
fs.mkdirSync("/path/to/some/dir").then(() => {});
fs.mkdirSync("/path/to/some/dir", 0o755).then(() => {});
}
namespace mkdirTests {
fs.mkdirp("/path/to/some/dir").then(() => {});
fs.mkdirp("/path/to/some/dir", 0o755).then(() => {});
fs.mkdirpSync("/path/to/some/dir").then(() => {});
fs.mkdirpSync("/path/to/some/dir", 0o755).then(() => {});
}
namespace copyTests {
fs.copy("a", "b").then(() => {});
fs.copy("a", "b", {}).then(() => {});
fs.copy("a", "b", { cwd: "/tmp" }).then(() => {});
fs.copy("a", "b", { ignoreExisting: true }).then(() => {});
fs.copy("a", "b", {});
fs.copy("a", "b", { clobber: true }).then(() => {});
fs.copy("a", "b", { overwrite: true }).then(() => {});
fs.copy("a", "b", { filter: /asd/ }).then(() => {});
fs.copy("a", "b", { filter: () => true }).then(() => {});
fs.copy("a", "b", { filter: (a) => a.charCodeAt(0) === 100 }).then(() => {});
fs.copy("a", "b", {
transform(r, w, file) {
file.atime.getDay();
file.mtime.getDay();
file.mode.toExponential();
file.name.charCodeAt(0);
file.stats.atimeMs.toExponential();
r.pipe(w);
}
}).then(() => {});
}
namespace copyTests {
fs.copyTo("a", "b").then(() => {});
fs.copyTo("a", "b", {});
fs.copyTo("a", "b", { cwd: "/tmp" }).then(() => {});
fs.copyTo("a", "b", { ignoreExisting: true }).then(() => {});
}
namespace renameTests {
@@ -689,6 +842,7 @@ namespace fsTests {
fs.tail("file", 10, {}).then((x: Buffer[]) => {});
fs.tail("file", 10, { separator: "\n" }).then((x: Buffer[]) => {});
fs.tail("file", 10, { chunkLength: 4096 }).then((x: Buffer[]) => {});
fs.tail("file", 10, { pos: 10 }).then((x: Buffer[]) => {});
}
namespace statVFSTests {
+409 -113
View File
@@ -1,115 +1,411 @@
namespace isTests {
{ const a: boolean = adone.is.null({}); }
{ const a: boolean = adone.is.undefined({}); }
{ const a: boolean = adone.is.exist({}); }
{ const a: boolean = adone.is.nil({}); }
{ const a: boolean = adone.is.number({}); }
{ const a: boolean = adone.is.numeral({}); }
{ const a: boolean = adone.is.infinite({}); }
{ const a: boolean = adone.is.odd({}); }
{ const a: boolean = adone.is.even({}); }
{ const a: boolean = adone.is.float({}); }
{ const a: boolean = adone.is.negativeZero({}); }
{ const a: boolean = adone.is.string({}); }
{ const a: boolean = adone.is.emptyString({}); }
{ const a: boolean = adone.is.substring("abc", "abcdef"); }
{ const a: boolean = adone.is.substring("abc", "abcdef", 0); }
{ const a: boolean = adone.is.prefix("abc", "abcdef"); }
{ const a: boolean = adone.is.suffix("def", "abbdef"); }
{ const a: boolean = adone.is.boolean({}); }
{ const a: boolean = adone.is.json({}); }
{ const a: boolean = adone.is.object({}); }
{ const a: boolean = adone.is.plainObject({}); }
{ const a: boolean = adone.is.class({}); }
{ const a: boolean = adone.is.emptyObject({}); }
{ const a: boolean = adone.is.propertyOwned({}, "a"); }
{ const a: boolean = adone.is.propertyDefined({}, "a"); }
{ const a: boolean = adone.is.conforms({}, {}); }
{ const a: boolean = adone.is.conforms({}, {}, true); }
{ const a: boolean = adone.is.arrayLikeObject({}); }
{ const a: boolean = adone.is.inArray(1, [1, 2, 3]); }
{ const a: boolean = adone.is.inArray(1, [1, 2, 3], 0); }
{ const a: boolean = adone.is.inArray(1, [1, 2, 3], 0, (a, b) => a === b); }
{ const a: boolean = adone.is.sameType({}, {}); }
{ const a: boolean = adone.is.primitive({}); }
{ const a: boolean = adone.is.equalArrays([], []); }
{ const a: boolean = adone.is.deepEqual({}, {}); }
{ const a: boolean = adone.is.shallowEqual({}, {}); }
{ const a: boolean = adone.is.stream({}); }
{ const a: boolean = adone.is.writableStream({}); }
{ const a: boolean = adone.is.readableStream({}); }
{ const a: boolean = adone.is.duplexStream({}); }
{ const a: boolean = adone.is.transformStream({}); }
{ const a: boolean = adone.is.utf8(Buffer.alloc(10)); }
{ const a: boolean = adone.is.win32PathAbsolute("abc"); }
{ const a: boolean = adone.is.posixPathAbsolute("abc"); }
{ const a: boolean = adone.is.pathAbsolute("abc"); }
{ const a: boolean = adone.is.glob("abc"); }
{ const a: boolean = adone.is.dotfile("abc"); }
{ const a: boolean = adone.is.function(() => { }); }
{ const a: boolean = adone.is.asyncFunction(async () => { }); }
{ const a: boolean = adone.is.promise({}); }
{ const a: boolean = adone.is.validDate("07.08.2017"); }
{ const a: boolean = adone.is.buffer({}); }
{ const a: boolean = adone.is.callback({}); }
{ const a: boolean = adone.is.generator({}); }
{ const a: boolean = adone.is.nan({}); }
{ const a: boolean = adone.is.finite({}); }
{ const a: boolean = adone.is.integer({}); }
{ const a: boolean = adone.is.safeInteger({}); }
{ const a: boolean = adone.is.array({}); }
{ const a: boolean = adone.is.uint8Array({}); }
{ const a: boolean = adone.is.configuration({}); }
{ const a: boolean = adone.is.long({}); }
{ const a: boolean = adone.is.bigNumber({}); }
{ const a: boolean = adone.is.byteArray({}); }
{ const a: boolean = adone.is.datetime({}); }
{ const a: boolean = adone.is.transform({}); }
{ const a: boolean = adone.is.subsystem({}); }
{ const a: boolean = adone.is.application({}); }
{ const a: boolean = adone.is.logger({}); }
{ const a: boolean = adone.is.coreStream({}); }
{ const a: boolean = adone.is.fastStream({}); }
{ const a: boolean = adone.is.fastLocalStream({}); }
{ const a: boolean = adone.is.fastLocalMapStream({}); }
{ const a: boolean = adone.is.genesisNetron({}); }
{ const a: boolean = adone.is.genesisPeer({}); }
{ const a: boolean = adone.is.netronAdapter({}); }
{ const a: boolean = adone.is.netron({}); }
{ const a: boolean = adone.is.netronPeer({}); }
{ const a: boolean = adone.is.netronDefinition({}); }
{ const a: boolean = adone.is.netronDefinitions({}); }
{ const a: boolean = adone.is.netronReference({}); }
{ const a: boolean = adone.is.netronInterface({}); }
{ const a: boolean = adone.is.netronContext({}); }
{ const a: boolean = adone.is.netronIMethod({}, "hello"); }
{ const a: boolean = adone.is.netronIProperty({}, "hello"); }
{ const a: boolean = adone.is.netronStub({}); }
{ const a: boolean = adone.is.netronRemoteStub({}); }
{ const a: boolean = adone.is.netronStream({}); }
{ const a: boolean = adone.is.iterable({}); }
{ const a: boolean = adone.is.windows; }
{ const a: boolean = adone.is.linux; }
{ const a: boolean = adone.is.freebsd; }
{ const a: boolean = adone.is.darwin; }
{ const a: boolean = adone.is.sunos; }
{ const a: boolean = adone.is.uppercase("abc"); }
{ const a: boolean = adone.is.lowercase("abc"); }
{ const a: boolean = adone.is.digits("012"); }
{ const a: boolean = adone.is.identifier("someMethod"); }
{ const a: boolean = adone.is.binaryExtension("mp3"); }
{ const a: boolean = adone.is.binaryPath("a.mp3"); }
{ const a: boolean = adone.is.ip4("192.168.1.1"); }
{ const a: boolean = adone.is.ip6("::192.168.1.1"); }
{ const a: boolean = adone.is.arrayBuffer({}); }
{ const a: boolean = adone.is.arrayBufferView({}); }
{ const a: boolean = adone.is.date({}); }
{ const a: boolean = adone.is.error({}); }
{ const a: boolean = adone.is.map({}); }
{ const a: boolean = adone.is.regexp({}); }
{ const a: boolean = adone.is.set({}); }
{ const a: boolean = adone.is.symbol({}); }
{ const a: boolean = adone.is.validUTF8(Buffer.from("hello")); }
{ const a: boolean = adone.is.vaultValuable({}); }
{ const a: boolean = adone.is.task({}); }
const {
is
} = adone;
{
const a: boolean = is.null({});
const b: any = 2;
if (is.null(b)) {
const c: null = b;
}
}
{
const a: boolean = is.undefined({});
const b: any = 2;
if (is.undefined(b)) {
const c: undefined = b;
}
}
{ const a: boolean = is.exist({}); }
{
const a: boolean = is.nil({});
const b: any = 2;
if (is.nil(b)) {
const c: null | undefined = b;
}
}
{
const a: boolean = is.number({});
const b: any = 2;
if (is.number(b)) {
b.toExponential();
}
}
{
const a: boolean = is.numeral({});
const b: any = 2;
if (is.numeral(b)) {
const c: string | number = b;
}
}
{
const a: boolean = is.infinite({});
const b: any = 2;
if (is.infinite(b)) {
b.toPrecision();
}
}
{
const a: boolean = is.odd({});
const b: any = 2;
if (is.odd(b)) {
b.toFixed(2);
}
}
{
const a: boolean = is.even({});
const b: any = 2;
if (is.even(b)) {
b.toFixed(2);
}
}
{
const a: boolean = is.float({});
const b: any = 2;
if (is.float(b)) {
b.toFixed();
}
}
{
const a: boolean = is.negativeZero({});
const b: any = 2;
if (is.negativeZero(b)) {
b.toFixed();
}
}
{
const a: boolean = is.string({});
const b: any = 2;
if (is.string(b)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.emptyString({});
const b: any = 2;
if (is.emptyString(b)) {
b.charCodeAt(0);
}
}
{ const a: boolean = is.substring("abc", "abcdef"); }
{ const a: boolean = is.substring("abc", "abcdef", 0); }
{ const a: boolean = is.prefix("abc", "abcdef"); }
{ const a: boolean = is.suffix("def", "abbdef"); }
{
const a: boolean = is.boolean({});
const b: any = 2;
if (is.boolean(b)) {
b === true;
}
}
{ const a: boolean = is.json({}); }
{ const a: boolean = is.object({}); }
{ const a: boolean = is.plainObject({}); }
{ const a: boolean = is.class({}); }
{ const a: boolean = is.emptyObject({}); }
{ const a: boolean = is.propertyOwned({}, "a"); }
{ const a: boolean = is.propertyDefined({}, "a"); }
{ const a: boolean = is.conforms({}, {}); }
{ const a: boolean = is.conforms({}, {}, true); }
{ const a: boolean = is.arrayLikeObject({}); }
{ const a: boolean = is.inArray(1, [1, 2, 3]); }
{ const a: boolean = is.inArray(1, [1, 2, 3], 0); }
{ const a: boolean = is.inArray(1, [1, 2, 3], 0, (a, b) => a === b); }
{ const a: boolean = is.sameType({}, {}); }
{ const a: boolean = is.primitive({}); }
{ const a: boolean = is.equalArrays([], []); }
{ const a: boolean = is.deepEqual({}, {}); }
{ const a: boolean = is.shallowEqual({}, {}); }
{ const a: boolean = is.stream({}); }
{ const a: boolean = is.writableStream({}); }
{ const a: boolean = is.readableStream({}); }
{ const a: boolean = is.duplexStream({}); }
{ const a: boolean = is.transformStream({}); }
{ const a: boolean = is.utf8(Buffer.alloc(10)); }
{ const a: boolean = is.win32PathAbsolute("abc"); }
{ const a: boolean = is.posixPathAbsolute("abc"); }
{ const a: boolean = is.pathAbsolute("abc"); }
{
const a: boolean = is.glob("abc");
const b: any = 2;
if (is.glob(b)) {
b.charCodeAt(0);
}
}
{ const a: boolean = is.dotfile("abc"); }
{ const a: boolean = is.function(() => { }); }
{ const a: boolean = is.asyncFunction(async () => { }); }
{
const a: boolean = is.promise({});
const b: any = 2;
if (is.promise(b)) {
b.then(() => {});
}
const c = Promise.resolve(2);
if (is.promise(c)) {
c.then((x) => x.toFixed(2));
}
}
{ const a: boolean = is.validDate("07.08.2017"); }
{
const a: boolean = is.buffer({});
const b: any = 2;
if (is.buffer(b)) {
b.writeDoubleBE(10, 10);
}
}
{ const a: boolean = is.callback({}); }
{ const a: boolean = is.generator({}); }
{ const a: boolean = is.nan({}); }
{
const a: boolean = is.finite({});
const b: any = 2;
if (is.finite(b)) {
b.toFixed();
}
}
{
const a: boolean = is.integer({});
const b: any = 2;
if (is.integer(b)) {
b.toFixed();
}
}
{
const a: boolean = is.safeInteger({});
const b: any = 2;
if (is.safeInteger(b)) {
b.toFixed();
}
}
{
const a: boolean = is.array({});
const b: any = 2;
if (is.array(b)) {
b.length + b[0];
}
const c = [1, 2, 3];
if (is.array(c)) {
c[0].toFixed(0);
}
}
{
const a: boolean = is.uint8Array({});
const b: any = 2;
if (is.uint8Array(b)) {
b.copyWithin(1, 2);
}
}
{ const a: boolean = is.configuration({}); }
{
const a: boolean = is.long({});
const b: any = 2;
if (is.long(b)) {
b.getHighBitsUnsigned();
}
}
{
const a: boolean = is.bigNumber({});
const b: any = 2;
if (is.bigNumber(b)) {
b.add(b).isBitSet(10);
}
}
{
const a: boolean = is.byteArray({});
const b: any = 2;
if (is.byteArray(b)) {
b.toBuffer();
}
}
{
const a: boolean = is.datetime({});
const b: any = 2;
if (is.datetime(b)) {
b.add(2, "hours");
}
}
{ const a: boolean = is.transform({}); }
{ const a: boolean = is.subsystem({}); }
{ const a: boolean = is.application({}); }
{ const a: boolean = is.logger({}); }
{ const a: boolean = is.coreStream({}); }
{ const a: boolean = is.fastStream({}); }
{ const a: boolean = is.fastLocalStream({}); }
{ const a: boolean = is.fastLocalMapStream({}); }
{ const a: boolean = is.genesisNetron({}); }
{ const a: boolean = is.genesisPeer({}); }
{ const a: boolean = is.netronAdapter({}); }
{ const a: boolean = is.netron({}); }
{ const a: boolean = is.netronPeer({}); }
{ const a: boolean = is.netronDefinition({}); }
{ const a: boolean = is.netronDefinitions({}); }
{ const a: boolean = is.netronReference({}); }
{ const a: boolean = is.netronInterface({}); }
{ const a: boolean = is.netronContext({}); }
{ const a: boolean = is.netronIMethod({}, "hello"); }
{ const a: boolean = is.netronIProperty({}, "hello"); }
{ const a: boolean = is.netronStub({}); }
{ const a: boolean = is.netronRemoteStub({}); }
{ const a: boolean = is.netronStream({}); }
{ const a: boolean = is.iterable({}); }
{ const a: boolean = is.windows; }
{ const a: boolean = is.linux; }
{ const a: boolean = is.freebsd; }
{ const a: boolean = is.darwin; }
{ const a: boolean = is.sunos; }
{ const a: boolean = is.uppercase("abc"); }
{ const a: boolean = is.lowercase("abc"); }
{ const a: boolean = is.digits("012"); }
{ const a: boolean = is.identifier("someMethod"); }
{ const a: boolean = is.binaryExtension("mp3"); }
{ const a: boolean = is.binaryPath("a.mp3"); }
{ const a: boolean = is.ip4("192.168.1.1"); }
{ const a: boolean = is.ip6("::192.168.1.1"); }
{
const a: boolean = is.arrayBuffer({});
const b: any = 2;
if (is.arrayBuffer(b)) {
b.slice(10);
}
}
{
const a: boolean = is.arrayBufferView({});
const b: any = 2;
if (is.arrayBufferView(b)) {
b.byteLength + b.byteOffset;
}
}
{
const a: boolean = is.date({});
const b: any = 2;
if (is.date(b)) {
b.getMonth() + b.getDate();
}
}
{ const a: boolean = is.error({}); }
{
const a: boolean = is.map({});
const b: any = 2;
if (is.map(b)) {
b.has("asd");
b.set(1, 2);
b.set("1", 2);
}
}
{
const a: boolean = is.regexp({});
const b: any = 2;
if (is.regexp(b)) {
b.test("hello");
}
}
{
const a: boolean = is.set({});
const b: any = 2;
if (is.set(b)) {
b.add("h");
b.has(1);
}
}
{ const a: boolean = is.symbol({}); }
{ const a: boolean = is.vaultValuable({}); }
{ const a: boolean = is.task({}); }
{
const a: boolean = is.fqdn(1);
const b: any = 2;
if (is.fqdn(b)) {
b.charCodeAt(0);
}
if (is.fqdn(b, {})) {
b.charCodeAt(0);
}
is.fqdn(1, {
allowTrailingDot: false
});
is.fqdn(1, {
allowUnderscores: false
});
is.fqdn(1, {
requireTld: true
});
}
{
const a: boolean = is.email(1);
const b: any = 2;
if (is.email(b)) {
b.charCodeAt(0);
}
if (is.email(b, {})) {
b.charCodeAt(0);
}
is.email(1, {
allowDisplayName: false
});
is.email(1, {
allowUtf8LocalPart: false
});
is.email(1, {
requireDisplayName: false
});
is.email(1, {
requireTld: false
});
}
{
const a: boolean = is.uuid(2);
const b: any = 2;
if (is.uuid(b)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, "all");
const b: any = 2;
if (is.uuid(b, "all")) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, "all");
const b: any = 2;
if (is.uuid(b, "all")) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, 1);
const b: any = 2;
if (is.uuid(b, 1)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, 2);
const b: any = 2;
if (is.uuid(b, 2)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, 3);
const b: any = 2;
if (is.uuid(b, 2)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, 4);
const b: any = 2;
if (is.uuid(b, 2)) {
b.charCodeAt(0);
}
}
{
const a: boolean = is.uuid(2, 5);
const b: any = 2;
if (is.uuid(b, 2)) {
b.charCodeAt(0);
}
}
}
+7
View File
@@ -0,0 +1,7 @@
namespace metaTests {
const { meta } = adone;
namespace typeOf {
const a: string = meta.typeOf(1);
}
}
+30
View File
@@ -106,4 +106,34 @@ namespace promiseTests {
namespace _finally {
promise.finally(Promise.resolve(2), () => 2).then((x: number) => {});
}
namespace props {
promise.props({ a: Promise.resolve(2) }).then((x) => x.a);
}
namespace retry {
promise.retry((info) => {
{ const a: number = info.current; }
});
promise.retry(() => {}, {});
promise.retry(() => {}, { backOffBase: 1000 });
promise.retry(() => {}, { backOffExponent: 2 });
promise.retry(() => {}, { match: "a" });
promise.retry(() => {}, { match: ["a"] });
promise.retry(() => {}, { match: [/abc/] });
promise.retry(() => {}, { match: /abc/ });
promise.retry(() => {}, { match: [new Error()] });
promise.retry(() => {}, { match: new Error() });
promise.retry(() => {}, { max: 100 });
promise.retry(() => {}, { name: "asd" });
promise.retry(() => {}, {
report(msg: string, opts) {
opts.backOffBase < 100;
}
});
promise.retry(() => {}, {
timeout: 100
});
}
}
+72 -72
View File
@@ -2,82 +2,82 @@ namespace streamsTests {
const { stream } = adone;
namespace CoreStreamTests {
const { CoreStream } = stream;
const { core: { Stream } } = stream;
new CoreStream();
new CoreStream(undefined);
new CoreStream(undefined, {});
new CoreStream(undefined, { async: true });
new CoreStream(undefined, { sync: true });
new CoreStream(undefined, {
new Stream();
new Stream(undefined);
new Stream(undefined, {});
new Stream(undefined, { async: true });
new Stream(undefined, { sync: true });
new Stream(undefined, {
transform(x) {
this.push(x);
}
});
new CoreStream(undefined, {
new Stream(undefined, {
flush() {
this.push(1);
}
});
new CoreStream([]);
new CoreStream(new CoreStream([]));
new Stream([]);
new Stream(new Stream([]));
{ const a: boolean = new CoreStream().write(1); }
{ const a: boolean = new CoreStream().push(1); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().end(); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().destroy(); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().pause(); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().resume(); }
{ const a: boolean = new CoreStream().isPaused(); }
{ const a: boolean = new CoreStream().isEnded(); }
{ const a: nodestd.stream.Transform = new CoreStream().pipe(new adone.std.stream.Transform()); }
{ const a: adone.stream.CoreStream<any, number> = new CoreStream().throughSync(function () { this.push(1); }); }
{ const a: adone.stream.CoreStream<any, number> = new CoreStream().throughSync(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.CoreStream<any, number> = new CoreStream().throughAsync(function () { this.push(1); }); }
{ const a: adone.stream.CoreStream<any, number> = new CoreStream().throughAsync(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.CoreStream<any, number> = new CoreStream().through(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.CoreStream<number, string> = new CoreStream<number, number>([1, 2, 3]).map((x) => `${x}`); }
{ const a: adone.stream.CoreStream<any, number | string> = new CoreStream<string, string>().mapIf((x) => x === "1", () => 1); }
{ const a: adone.stream.CoreStream<any, number | string> = new CoreStream<number, string>().mapIf(async (x) => x === "1", () => 1); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().filter((x) => x === 1); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().filter(async (x) => x === 1); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().forEach(async (x) => x === 1); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().forEach(async (x) => x === 1, {}); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().forEach(async (x) => x === 1, { passthrough: true }); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().forEach(async (x) => x === 1, { wait: true }); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().done(() => {}); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().done(() => {}, {}); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().done(() => {}, { passthrough: true }); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().toArray((x: any[]) => {}); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().toArray((x: any[]) => {}, {}); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().toArray((x: any[]) => {}, { passthrough: true }); }
{ const a: adone.stream.CoreStream<number, string> = new CoreStream<number, string>().unique(); }
{ const a: adone.stream.CoreStream<number, number> = new CoreStream<number, number>().unique((x) => x + 1); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().stash((x) => x === 1); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().stash("hello", (x) => x === 1); }
{ const a: adone.stream.CoreStream<number, string> = new CoreStream().unstash("hello"); }
{ const a: adone.stream.CoreStream<any, any> = new CoreStream().unstash(); }
{ const a: adone.stream.CoreStream<any, string> = new CoreStream().flatten(); }
{ const a: Promise<any[]> = new CoreStream().then(); }
{ const a: Promise<string> = new CoreStream().then(() => "1"); }
{ const a: Promise<number> = new CoreStream().then(() => 1, () => 2); }
{ const a: Promise<any[]> = new CoreStream().catch(); }
{ const a: Promise<number[] | number> = new CoreStream<number, number>().catch(() => 1); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([new CoreStream()]); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([new adone.std.stream.Readable()]); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([new adone.std.stream.Transform()]); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([new adone.std.stream.Transform()]); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([new adone.std.stream.Duplex()]); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], {}); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { end: true }); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { sourceOptions: {} }); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { sourceOptions: { async: true } }); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { sourceOptions: { sync: false } }); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { sourceOptions: { transform(x) { this.push(x); } } }); }
{ const a: adone.stream.CoreStream<any, any> = CoreStream.merge([], { sourceOptions: { flush() { this.push(1); } } }); }
{ const a: boolean = new Stream().write(1); }
{ const a: boolean = new Stream().push(1); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().end(); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().destroy(); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().pause(); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().resume(); }
{ const a: boolean = new Stream().isPaused(); }
{ const a: boolean = new Stream().isEnded(); }
{ const a: nodestd.stream.Transform = new Stream().pipe(new adone.std.stream.Transform()); }
{ const a: adone.stream.core.Stream<any, number> = new Stream().throughSync(function () { this.push(1); }); }
{ const a: adone.stream.core.Stream<any, number> = new Stream().throughSync(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.core.Stream<any, number> = new Stream().throughAsync(function () { this.push(1); }); }
{ const a: adone.stream.core.Stream<any, number> = new Stream().throughAsync(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.core.Stream<any, number> = new Stream().through(function () { this.push(1); }, function () { this.push(1); }); }
{ const a: adone.stream.core.Stream<number, string> = new Stream<number, number>([1, 2, 3]).map((x) => `${x}`); }
{ const a: adone.stream.core.Stream<any, number | string> = new Stream<string, string>().mapIf((x) => x === "1", () => 1); }
{ const a: adone.stream.core.Stream<any, number | string> = new Stream<number, string>().mapIf(async (x) => x === "1", () => 1); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().filter((x) => x === 1); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().filter(async (x) => x === 1); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().forEach(async (x) => x === 1); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().forEach(async (x) => x === 1, {}); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().forEach(async (x) => x === 1, { passthrough: true }); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().forEach(async (x) => x === 1, { wait: true }); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().done(() => {}); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().done(() => {}, {}); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().done(() => {}, { passthrough: true }); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().toArray((x: any[]) => {}); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().toArray((x: any[]) => {}, {}); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().toArray((x: any[]) => {}, { passthrough: true }); }
{ const a: adone.stream.core.Stream<number, string> = new Stream<number, string>().unique(); }
{ const a: adone.stream.core.Stream<number, number> = new Stream<number, number>().unique((x) => x + 1); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().stash((x) => x === 1); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().stash("hello", (x) => x === 1); }
{ const a: adone.stream.core.Stream<number, string> = new Stream().unstash("hello"); }
{ const a: adone.stream.core.Stream<any, any> = new Stream().unstash(); }
{ const a: adone.stream.core.Stream<any, string> = new Stream().flatten(); }
{ const a: Promise<any[]> = new Stream().then(); }
{ const a: Promise<string> = new Stream().then(() => "1"); }
{ const a: Promise<number> = new Stream().then(() => 1, () => 2); }
{ const a: Promise<any[]> = new Stream().catch(); }
{ const a: Promise<number[] | number> = new Stream<number, number>().catch(() => 1); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([new Stream()]); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([new adone.std.stream.Readable()]); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([new adone.std.stream.Transform()]); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([new adone.std.stream.Transform()]); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([new adone.std.stream.Duplex()]); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], {}); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { end: true }); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { sourceOptions: {} }); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { sourceOptions: { async: true } }); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { sourceOptions: { sync: false } }); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { sourceOptions: { transform(x) { this.push(x); } } }); }
{ const a: adone.stream.core.Stream<any, any> = Stream.merge([], { sourceOptions: { flush() { this.push(1); } } }); }
(async () => {
const res = await new CoreStream([1, 2, 3, 4, 5])
const res = await new Stream([1, 2, 3, 4, 5])
.map((x: number) => `${x}`)
.mapIf((x: string) => x[0] === "1", (x) => x.slice(1))
.map((x) => [x, x, x])
@@ -91,13 +91,13 @@ namespace streamsTests {
}
namespace coreTests {
{ const a: adone.stream.CoreStream<any, any> = stream.core(); }
{ const a: adone.stream.CoreStream<number, number> = stream.core([1, 2, 3]); }
{ const a: adone.stream.CoreStream<any, any> = stream.core(stream.core([])); }
{ const a: adone.stream.CoreStream<any, any> = stream.core(undefined, {}); }
{ const a: adone.stream.CoreStream<any, any> = stream.core(undefined, { async: true }); }
{ const a: adone.stream.CoreStream<any, any> = stream.core(undefined, { sync: false }); }
{ const a: adone.stream.CoreStream<any, number> = stream.core<string, number>(undefined, { transform(x) { this.push(Number(x)); } }); }
{ const a: adone.stream.CoreStream<any, number> = stream.core(undefined, { flush() { this.push(1); } }); }
{ const a: adone.stream.core.Stream<any, any> = stream.core.create(); }
{ const a: adone.stream.core.Stream<number, number> = stream.core.create([1, 2, 3]); }
{ const a: adone.stream.core.Stream<any, any> = stream.core.create(stream.core.create([])); }
{ const a: adone.stream.core.Stream<any, any> = stream.core.create(undefined, {}); }
{ const a: adone.stream.core.Stream<any, any> = stream.core.create(undefined, { async: true }); }
{ const a: adone.stream.core.Stream<any, any> = stream.core.create(undefined, { sync: false }); }
{ const a: adone.stream.core.Stream<any, number> = stream.core.create<string, number>(undefined, { transform(x) { this.push(Number(x)); } }); }
{ const a: adone.stream.core.Stream<any, number> = stream.core.create(undefined, { flush() { this.push(1); } }); }
}
}
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -15,7 +15,8 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true
},
"files": [
"index.d.ts",
@@ -23,6 +24,7 @@
"glosses/math/index.d.ts",
"glosses/math/matrix.d.ts",
"glosses/math/simd.d.ts",
"glosses/meta.d.ts",
"glosses/std.d.ts",
"glosses/utils.d.ts",
"glosses/assertion.d.ts",
@@ -43,9 +45,11 @@
"adone-tests.ts",
"test/index.ts",
"test/index-import.ts",
"test/glosses/application.ts",
"test/glosses/math/index.ts",
"test/glosses/math/matrix.ts",
"test/glosses/math/simd.ts",
"test/glosses/meta.ts",
"test/glosses/std.ts",
"test/glosses/utils.ts",
"test/glosses/assertion.ts",
+162 -162
View File
@@ -289,25 +289,25 @@ foo.then((x) => {
// $q signature tests
namespace TestQ {
interface TResult {
interface AbcObject {
a: number;
b: string;
c: boolean;
}
interface TValue {
interface EfObject {
e: number;
f: boolean;
}
interface TOther {
interface GhObject {
g: string;
h: number;
}
const tResult: TResult = null;
const promiseTResult: angular.IPromise<TResult> = null;
const tValue: TValue = null;
const promiseTValue: angular.IPromise<TValue> = null;
const tOther: TOther = null;
const promiseTOther: angular.IPromise<TOther> = null;
const abcObject: AbcObject = null;
const abcObjectPromise: angular.IPromise<AbcObject> = null;
const efObject: EfObject = null;
const efObjectPromise: angular.IPromise<EfObject> = null;
const ghObject: GhObject = null;
const ghObjectPromise: angular.IPromise<GhObject> = null;
const $q: angular.IQService = null;
const promiseAny: angular.IPromise<any> = null;
@@ -316,11 +316,11 @@ namespace TestQ {
// $q constructor
{
let result: angular.IPromise<TResult>;
result = new $q<TResult>((resolve: (value: TResult) => any) => {});
result = new $q<TResult>((resolve: (value: TResult) => any, reject: (value: any) => any) => {});
result = $q<TResult>((resolve: (value: TResult) => any) => {});
result = $q<TResult>((resolve: (value: TResult) => any, reject: (value: any) => any) => {});
let result: angular.IPromise<AbcObject>;
result = new $q<AbcObject>((resolve: (value: AbcObject) => any) => {});
result = new $q<AbcObject>((resolve: (value: AbcObject) => any, reject: (value: any) => any) => {});
result = $q<AbcObject>((resolve: (value: AbcObject) => any) => {});
result = $q<AbcObject>((resolve: (value: AbcObject) => any, reject: (value: any) => any) => {});
}
// $q.all
@@ -332,8 +332,8 @@ namespace TestQ {
$q.all([1, $q.when(2), '3']).then(([ n1, n2, n3 ]) => n1.toFixed() + n2.toFixed() + n3.slice(1));
}
{
let result: angular.IPromise<TResult[]>;
result = $q.all<TResult>([promiseAny, promiseAny]);
let result: angular.IPromise<AbcObject[]>;
result = $q.all<AbcObject>([promiseAny, promiseAny]);
}
{
let result: angular.IPromise<{[id: string]: any; }>;
@@ -356,13 +356,13 @@ namespace TestQ {
// $q.defer
{
let result: angular.IDeferred<TResult>;
result = $q.defer<TResult>();
result.resolve(tResult);
let result: angular.IDeferred<AbcObject>;
result = $q.defer<AbcObject>();
result.resolve(abcObject);
const anyValue: any = null;
result.reject(anyValue);
result.promise.then(result => {
return $q.resolve<TResult>(result);
return $q.resolve<AbcObject>(result);
});
}
@@ -380,10 +380,10 @@ namespace TestQ {
result = $q.resolve();
}
{
let result: angular.IPromise<TResult>;
result = $q.resolve<TResult>(tResult);
result = $q.resolve<TResult>(promiseTResult);
const result2: angular.IPromise<TResult | TOther> = $q.resolve<TResult | TOther>(Math.random() > 0.5 ? tResult : promiseTOther);
let result: angular.IPromise<AbcObject>;
result = $q.resolve<AbcObject>(abcObject);
result = $q.resolve<AbcObject>(abcObjectPromise);
const result2: angular.IPromise<AbcObject | GhObject> = $q.resolve<AbcObject | GhObject>(Math.random() > 0.5 ? abcObject : ghObjectPromise);
}
// $q.when
@@ -392,32 +392,32 @@ namespace TestQ {
result = $q.when();
}
{
let result: angular.IPromise<TResult>;
let resultOther: angular.IPromise<TResult | TOther>;
let result: angular.IPromise<AbcObject>;
let resultOther: angular.IPromise<AbcObject | GhObject>;
result = $q.when<TResult>(tResult);
result = $q.when<TResult>(promiseTResult);
result = $q.when<AbcObject>(abcObject);
result = $q.when<AbcObject>(abcObjectPromise);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any, (any) => any);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObject);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObject, (any) => any);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObject, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any);
result = $q.when<AbcObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject, (any) => any);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObjectPromise);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObjectPromise, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObjectPromise);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObjectPromise, (any) => any);
result = $q.when<AbcObject, EfObject>(efObject, (result: EfObject) => abcObjectPromise, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any);
result = $q.when<AbcObject, EfObject>(efObjectPromise, (result: EfObject) => abcObjectPromise);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObject);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObject, (any) => any);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObjectPromise);
resultOther = $q.when<AbcObject, GhObject, EfObject>(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObjectPromise, (any) => any);
}
}
@@ -440,41 +440,41 @@ httpFoo.then((response: ng.IHttpResponse<any>) => {
// Deferred signature tests
namespace TestDeferred {
const any: any = null;
const anything: any = null;
interface TResult {
interface AbcObject {
a: number;
b: string;
c: boolean;
}
const tResult: TResult = null;
const abcObject: AbcObject = null;
const deferred: angular.IDeferred<TResult> = null;
const deferred: angular.IDeferred<AbcObject> = null;
// deferred.resolve
{
let result: void;
result = deferred.resolve();
result = deferred.resolve(tResult);
result = deferred.resolve(abcObject);
}
// deferred.reject
{
let result: void;
result = deferred.reject();
result = deferred.reject(any);
result = deferred.reject(anything);
}
// deferred.notify
{
let result: void;
result = deferred.notify();
result = deferred.notify(any);
result = deferred.notify(anything);
}
// deferred.promise
{
let result: angular.IPromise<TResult>;
let result: angular.IPromise<AbcObject>;
result = deferred.promise;
}
}
@@ -517,139 +517,139 @@ namespace TestInjector {
// Promise signature tests
namespace TestPromise {
const any: any = null;
const anything: any = null;
interface TResult {
kind: 'result';
interface AbcObject {
kind: 'abc';
a: number;
b: string;
c: boolean;
}
interface TOther {
kind: 'other';
interface DefObject {
kind: 'def';
d: number;
e: string;
f: boolean;
}
function isTResult(x: TResult | TOther): x is TResult {
return x.kind === 'result';
function isAbcObject(x: AbcObject | DefObject): x is AbcObject {
return x.kind === 'abc';
}
const tresult: TResult = null;
const tresultPromise: ng.IPromise<TResult> = null;
const tresultHttpPromise: ng.IHttpPromise<TResult> = null;
const abcObject: AbcObject = null;
const abcObjectPromise: ng.IPromise<AbcObject> = null;
const abcObjectHttpPromise: ng.IHttpPromise<AbcObject> = null;
const tother: TOther = null;
const totherPromise: ng.IPromise<TOther> = null;
const totherHttpPromise: ng.IHttpPromise<TOther> = null;
const defObject: DefObject = null;
const defObjectPromise: ng.IPromise<DefObject> = null;
const defObjectHttpPromise: ng.IHttpPromise<DefObject> = null;
const promise: angular.IPromise<TResult> = null;
const promise: angular.IPromise<AbcObject> = null;
const $q: angular.IQService = null;
const reject = $q.reject();
const rejectedPromise = $q.reject();
// promise.then
// $ExpectType IPromise<any>
promise.then(result => any);
promise.then(result => anything);
// $ExpectType IPromise<any>
promise.then(result => any, any => any);
promise.then(result => anything, any => any);
// $ExpectType IPromise<any>
promise.then(result => any, any => any, any => any);
promise.then(result => anything, any => any, any => any);
// $ExpectType IPromise<never>
promise.then(result => reject);
promise.then(result => rejectedPromise);
// $ExpectType IPromise<never>
promise.then(result => reject, any => reject);
promise.then(result => rejectedPromise, any => rejectedPromise);
// $ExpectType IPromise<never>
promise.then(result => reject, any => reject, any => any);
promise.then(result => rejectedPromise, any => rejectedPromise, any => any);
// $ExpectType IPromise<TResult>
// $ExpectType IPromise<AbcObject>
promise.then(result => result);
// $ExpectType IPromise<TResult>
promise.then(result => tresult);
// $ExpectType IPromise<TResult>
promise.then(result => tresultPromise);
// $ExpectType IPromise<AbcObject>
promise.then(result => abcObject);
// $ExpectType IPromise<AbcObject>
promise.then(result => abcObjectPromise);
// $ExpectType IPromise<any>
promise.then(result => result, any => any);
// $ExpectType IPromise<number | TResult>
// $ExpectType IPromise<number | AbcObject>
promise.then(result => result, any => Math.random());
// $ExpectType IPromise<any>
promise.then(result => result, any => any, any => any);
// $ExpectType IPromise<number | TResult>
// $ExpectType IPromise<number | AbcObject>
promise.then(result => result, any => Math.random(), any => any);
// $ExpectType IPromise<TResult>
promise.then(result => result, any => reject, any => any);
// $ExpectType IPromise<AbcObject>
promise.then(result => result, any => rejectedPromise, any => any);
// $ExpectType IPromise<TResult>
promise.then(result => anyOf2(reject, result));
// $ExpectType IPromise<TResult>
promise.then(result => anyOf3(result, tresultPromise, reject));
// $ExpectType IPromise<TResult>
// $ExpectType IPromise<AbcObject>
promise.then(result => anyOf2(rejectedPromise, result));
// $ExpectType IPromise<AbcObject>
promise.then(result => anyOf3(result, abcObjectPromise, rejectedPromise));
// $ExpectType IPromise<AbcObject>
promise.then(
result => anyOf3(reject, result, tresultPromise),
reason => anyOf3(reject, tresult, tresultPromise)
result => anyOf3(rejectedPromise, result, abcObjectPromise),
reason => anyOf3(rejectedPromise, abcObject, abcObjectPromise)
);
// $ExpectType IPromise<IHttpResponse<TResult>>
promise.then(result => tresultHttpPromise);
// $ExpectType IPromise<IHttpResponse<AbcObject>>
promise.then(result => abcObjectHttpPromise);
// $ExpectType IPromise<TResult | TOther>
promise.then(result => result, any => tother);
// $ExpectType IPromise<AbcObject | DefObject>
promise.then(result => result, any => defObject);
// These are broken and seemingly can't be made to work
// with the current limitations of TypeScript.
// xExpectType IPromise<TResult | TOther>
// promise.then(result => anyOf2(result, totherPromise));
// xExpectType IPromise<TResult | TOther>
// promise.then(result => anyOf3(reject, result, totherPromise));
// xExpectType IPromise<TResult | TOther>
// xExpectType IPromise<AbcObject | DefObject>
// promise.then(result => anyOf2(result, defObjectPromise));
// xExpectType IPromise<AbcObject | DefObject>
// promise.then(result => anyOf3(rejectedPromise, result, defObjectPromise));
// xExpectType IPromise<AbcObject | DefObject>
// const a4 = promise.then(
// result => anyOf3(reject, result, totherPromise),
// reason => anyOf3(reject, tother, tresultPromise)
// result => anyOf3(rejectedPromise, result, defObjectPromise),
// reason => anyOf3(rejectedPromise, defObject, abcObjectPromise)
// );
// $ExpectType IPromise<TResult | TOther>
promise.then<TResult | TOther, TResult>(result =>
anyOf3(tresultPromise, result, totherPromise)
// $ExpectType IPromise<AbcObject | DefObject>
promise.then<AbcObject | DefObject, AbcObject>(result =>
anyOf3(abcObjectPromise, result, defObjectPromise)
);
// $ExpectType IPromise<TResult | TOther>
promise.then(result => result, any => tother, any => any);
// $ExpectType IPromise<TResult | TOther>
promise.then(result => tresultPromise, any => totherPromise);
// $ExpectType IPromise<TResult | TOther>
promise.then(result => tresultPromise, any => totherPromise, any => any);
// $ExpectType IPromise<IHttpResponse<TResult> | IHttpResponse<TOther>>
promise.then(result => tresultHttpPromise, any => totherHttpPromise);
// $ExpectType IPromise<IHttpResponse<TResult> | IHttpResponse<TOther>>
promise.then(result => tresultHttpPromise, any => totherHttpPromise, any => any);
// $ExpectType IPromise<AbcObject | DefObject>
promise.then(result => result, any => defObject, any => any);
// $ExpectType IPromise<AbcObject | DefObject>
promise.then(result => abcObjectPromise, any => defObjectPromise);
// $ExpectType IPromise<AbcObject | DefObject>
promise.then(result => abcObjectPromise, any => defObjectPromise, any => any);
// $ExpectType IPromise<IHttpResponse<AbcObject> | IHttpResponse<DefObject>>
promise.then(result => abcObjectHttpPromise, any => defObjectHttpPromise);
// $ExpectType IPromise<IHttpResponse<AbcObject> | IHttpResponse<DefObject>>
promise.then(result => abcObjectHttpPromise, any => defObjectHttpPromise, any => any);
// $ExpectType IPromise<TOther>
promise.then(result => tother);
// $ExpectType IPromise<DefObject>
promise.then(result => defObject);
// $ExpectType IPromise<any>
promise.then(result => tother, any => any);
promise.then(result => defObject, any => any);
// $ExpectType IPromise<any>
promise.then(result => tother, any => any, any => any);
// $ExpectType IPromise<TOther>
promise.then(result => totherPromise);
promise.then(result => defObject, any => any, any => any);
// $ExpectType IPromise<DefObject>
promise.then(result => defObjectPromise);
// $ExpectType IPromise<any>
promise.then(result => totherPromise, any => any);
promise.then(result => defObjectPromise, any => any);
// $ExpectType IPromise<any>
promise.then(result => totherPromise, any => any, any => any);
// $ExpectType IPromise<IHttpResponse<TOther>>
promise.then(result => totherHttpPromise);
promise.then(result => defObjectPromise, any => any, any => any);
// $ExpectType IPromise<IHttpResponse<DefObject>>
promise.then(result => defObjectHttpPromise);
// $ExpectType IPromise<any>
promise.then(result => totherHttpPromise, any => any);
promise.then(result => defObjectHttpPromise, any => any);
// $ExpectType IPromise<any>
promise.then(result => totherHttpPromise, any => any, any => any);
promise.then(result => defObjectHttpPromise, any => any, any => any);
// $ExpectType IPromise<boolean>
promise
.then(result => tresult, any => tother)
.then(ambiguous => (isTResult(ambiguous) ? ambiguous.c : ambiguous.f));
.then(result => abcObject, any => defObject)
.then(ambiguous => (isAbcObject(ambiguous) ? ambiguous.c : ambiguous.f));
// promise.then + $q.reject:
@@ -668,38 +668,38 @@ namespace TestPromise {
// $ExpectType IPromise<any>
promise.catch(err => err);
// $ExpectType IPromise<any>
promise.catch(err => any);
// $ExpectType IPromise<TResult>
promise.catch(err => tresult);
// $ExpectType IPromise<TResult>
promise.catch(err => anyOf2(tresult, reject));
// $ExpectType IPromise<TResult>
promise.catch(err => anyOf3(tresult, tresultPromise, reject));
// $ExpectType IPromise<TResult>
promise.catch(err => tresultPromise);
// $ExpectType IPromise<TResult | IHttpResponse<TResult>>
promise.catch(err => tresultHttpPromise);
// $ExpectType IPromise<TResult | TOther>
promise.catch(err => tother);
// $ExpectType IPromise<TResult | TOther>
promise.catch(err => totherPromise);
// $ExpectType IPromise<TResult | IHttpResponse<TOther>>
promise.catch(err => totherHttpPromise);
promise.catch(err => anything);
// $ExpectType IPromise<AbcObject>
promise.catch(err => abcObject);
// $ExpectType IPromise<AbcObject>
promise.catch(err => anyOf2(abcObject, rejectedPromise));
// $ExpectType IPromise<AbcObject>
promise.catch(err => anyOf3(abcObject, abcObjectPromise, rejectedPromise));
// $ExpectType IPromise<AbcObject>
promise.catch(err => abcObjectPromise);
// $ExpectType IPromise<AbcObject | IHttpResponse<AbcObject>>
promise.catch(err => abcObjectHttpPromise);
// $ExpectType IPromise<AbcObject | DefObject>
promise.catch(err => defObject);
// $ExpectType IPromise<AbcObject | DefObject>
promise.catch(err => defObjectPromise);
// $ExpectType IPromise<AbcObject | IHttpResponse<DefObject>>
promise.catch(err => defObjectHttpPromise);
// $ExpectType IPromise<boolean>
promise
.catch(err => tother)
.catch(err => defObject)
.then(
ambiguous => (isTResult(ambiguous) ? ambiguous.c : ambiguous.f)
ambiguous => (isAbcObject(ambiguous) ? ambiguous.c : ambiguous.f)
);
// promise.finally
// $ExpectType IPromise<TResult>
promise.finally(() => any);
// $ExpectType IPromise<TResult>
promise.finally(() => tresult);
// $ExpectType IPromise<TResult>
promise.finally(() => tother);
// $ExpectType IPromise<AbcObject>
promise.finally(() => anything);
// $ExpectType IPromise<AbcObject>
promise.finally(() => abcObject);
// $ExpectType IPromise<AbcObject>
promise.finally(() => defObject);
}
function test_angular_forEach() {
@@ -726,12 +726,12 @@ let elementReadyFn = angular.element(() => {
// $timeout signature tests
namespace TestTimeout {
interface TResult {
interface AbcObject {
a: number;
b: string;
c: boolean;
}
const fnTResult: (...args: any[]) => TResult = null;
const abcObjectFn: (...args: any[]) => AbcObject = null;
const promiseAny: angular.IPromise<any> = null;
const $timeout: angular.ITimeoutService = null;
@@ -746,13 +746,13 @@ namespace TestTimeout {
result = $timeout(1, true);
}
{
let result: angular.IPromise<TResult>;
result = $timeout(fnTResult);
result = $timeout(fnTResult, 1);
result = $timeout(fnTResult, 1, true);
result = $timeout(fnTResult, 1, true, 1);
result = $timeout(fnTResult, 1, true, 1, '');
result = $timeout(fnTResult, 1, true, 1, '', true);
let result: angular.IPromise<AbcObject>;
result = $timeout(abcObjectFn);
result = $timeout(abcObjectFn, 1);
result = $timeout(abcObjectFn, 1, true);
result = $timeout(abcObjectFn, 1, true, 1);
result = $timeout(abcObjectFn, 1, true, 1, '');
result = $timeout(abcObjectFn, 1, true, 1, '', true);
}
// $timeout.cancel
+69
View File
@@ -1,5 +1,6 @@
import * as blessed from "blessed";
import { readFileSync } from "fs";
import { inspect } from "util";
let screen: blessed.Widgets.Screen = null;
@@ -743,3 +744,71 @@ setTimeout(() => {
table.setData(data1);
screen.render();
}, 3000);
// https://github.com/chjj/blessed/blob/master/test/program-mouse.js
const program = blessed.program({
dump: __dirname + '/logs/mouse.log'
});
// program.setMouse({
// allMotion: true,
// //utfMouse: true
// urxvtMouse: true
// }, true);
program.alternateBuffer();
program.enableMouse();
program.hideCursor();
program.setMouse({ sendFocus: true }, true);
program.on('mouse', function(data) {
program.cup(data.y, data.x);
program.write(' ');
program.cup(0, 0);
program.write(inspect(data));
});
program.on('resize', function(data) {
setTimeout(function() {
program.clear();
program.cup(0, 0);
program.write(inspect({ cols: program.cols, rows: program.rows }));
}, 200);
});
process.on('SIGWINCH', function(data) {
setTimeout(function() {
program.cup(1, 0);
program.write(inspect({ winch: true, cols: program.cols, rows: program.rows }));
}, 200);
});
program.on('focus', function(data) {
program.clear();
program.cup(0, 0);
program.write('FOCUSIN');
});
program.on('blur', function(data) {
program.clear();
program.cup(0, 0);
program.write('FOCUSOUT');
});
program.key(['q', 'escape', 'C-c'], function() {
program.showCursor();
program.disableMouse();
program.normalBuffer();
process.exit(0);
});
program.on('keypress', function(ch, data) {
if (data.name === 'mouse') return;
program.clear();
program.cup(0, 0);
program.write(inspect(data));
});
program.clear();
+425 -4
View File
@@ -7,13 +7,433 @@
/// <reference types="node" />
import { EventEmitter } from "events";
import { Writable, Readable } from "stream";
import * as stream from "stream";
import * as child_process from "child_process";
export class BlessedProgram {
hideCursor: () => void;
move: any;
showCursor: any;
export interface IBlessedProgramOptions {
input?: Readable;
output?: Writable;
log?: string;
dump?: boolean;
zero?: boolean;
buffer?: boolean;
terminal?: string;
term?: string;
tput?: string;
debug?: boolean;
resizeTimeout?: boolean;
}
export class BlessedProgram extends EventEmitter {
type: string;
options: IBlessedProgramOptions;
input: Readable;
output: Writable;
zero: boolean;
useBuffer: boolean;
x: number;
y: number;
savedX: number;
savedY: number;
cols: number;
rows: number;
scrollTop: number;
scrollBottom: number;
isOSXTerm: boolean;
isiTerm2: boolean;
isXFCE: boolean;
isTerminator: boolean;
isLXDE: boolean;
isVTE: boolean;
isRxvt: boolean;
isXterm: boolean;
tmux: boolean;
tmuxVersion: number;
constructor(options?: IBlessedProgramOptions);
log(): boolean;
debug(): boolean;
setupDump(): void;
setupTput(): void;
setTerminal(terminal: string): void;
has(name: string): boolean;
term(is: string): boolean;
listen(): void;
destroy(): void;
key(key: string|string[], listener: Function): void;
onceKey(key: string|string[], listener: Function): void;
unKey(key: string|string[], listener: Function): void;
removeKey(key: string|string[], listener: Function): void;
bindMouse(): void;
enableGpm(): void;
disableGpm(): void;
bindResponse(): void;
response(name: string, text: string, callback: Function, noBypass?: boolean): boolean;
response(name: string, callback?: Function): boolean;
write(text: string): boolean;
flush(): void;
print(text: string, attr?: boolean): boolean;
echo(text: string, attr?: boolean): boolean;
setx(x: number): boolean;
sety(y: number): boolean;
move(x: number, y: number): boolean;
omove(x: number, y: number): void;
rsetx(x: number): boolean;
rsety(y: number): boolean;
rmove(x: number, y: number): void;
simpleInsert(ch: string, i?: number, attr?: boolean): boolean;
repeat(ch: string, i?: number): string;
copyToClipboard(text: string): boolean;
cursorShape(shape: string, blink?: boolean): boolean;
cursorColor(color: string): boolean;
cursorReset(): boolean;
resetCursor(): boolean;
getTextParams(param: string, callback: Function): boolean;
getCursorColor(callback: Function): boolean;
nul(): boolean;
bell(): boolean;
bel(): boolean;
vtab(): boolean;
form(): boolean;
ff(): boolean;
backspace(): boolean;
kbs(): boolean;
tab(): boolean;
ht(): boolean;
shiftOut(): boolean;
shiftIn(): boolean;
return(): boolean;
cr(): boolean;
feed(): boolean;
newline(): boolean;
nl(): boolean;
index(): boolean;
ind(): boolean;
reverseIndex(): boolean;
reverse(): boolean;
ri(): boolean;
nextLine(): boolean;
reset(): boolean;
tabSet(): boolean;
saveCursor(key: string): boolean;
sc(key: string): boolean;
restoreCursor(key?: string, hide?: boolean): boolean;
rc(key?: string, hide?: boolean): boolean;
lsaveCursor(key?: string): void;
lrestoreCursor(key?: string, hide?: boolean): void;
lineHeight(): boolean;
charset(val?: string, level?: number): boolean;
enter_alt_charset_mode(): boolean;
as(): boolean;
smacs(): boolean;
exit_alt_charset_mode(): boolean;
ae(): boolean;
rmacs(): boolean;
setG(val: number): boolean;
setTitle(title: string): boolean;
resetColors(param?: string): boolean;
dynamicColors(param?: string): boolean;
selData(a: string, b: string): boolean;
cursorUp(param?: number): boolean;
cuu(param?: number): boolean;
up(param?: number): boolean;
cursorDown(param?: number): boolean;
cud(param?: number): boolean;
down(param?: number): boolean;
cursorForward(param?: number): boolean;
cuf(param?: number): boolean;
right(param?: number): boolean;
forward(param?: number): boolean;
cursorBackward(param?: number): boolean;
cub(param?: number): boolean;
left(param?: number): boolean;
back(param?: number): boolean;
cursorPos(row?: number, col?: number): boolean;
cup(row?: number, col?: number): boolean;
pos(row?: number, col?: number): boolean;
eraseInDisplay(param?: string): boolean;
ed(param?: string): boolean;
clear(): boolean;
eraseInLine(param?: string): boolean;
el(param?: string): boolean;
charAttributes(param: string, val?: boolean): boolean;
charAttributes(param: string[], val?: boolean): boolean;
setForeground(color: string, val?: boolean): boolean;
fg(color: string, val?: boolean): boolean;
setBackground(color: string, val?: boolean): boolean;
bg(color: string, val?: boolean): boolean;
deviceStatuses(param?: string, callback?: Function, dec?: boolean, noBypass?: boolean): boolean;
dsr(param?: string, callback?: Function, dec?: boolean, noBypass?: boolean): boolean;
getCursor(callback: Function): boolean;
saveReportedCursor(callback: Function): void;
restoreReportedCursor: () => boolean;
insertChars(param?: number): boolean;
ich(param?: number): boolean;
cursorNextLine(param?: number): boolean;
cnl(param?: number): boolean;
cursorPrecedingLine(param?: number): boolean;
cpl(param?: number): boolean;
cursorCharAbsolute(param?: number): boolean;
cha(param?: number): boolean;
insertLines(param?: number): boolean;
il(param?: number): boolean;
deleteLines(param?: number): boolean;
dl(param?: number): boolean;
deleteChars(param?: number): boolean;
dch(param?: number): boolean;
eraseChars(param?: number): boolean;
ech(param?: number): boolean;
charPosAbsolute(param?: number): boolean;
hpa(param?: number): boolean;
HPositionRelative(param?: number): boolean;
sendDeviceAttributes(param?: number, callback?: Function): boolean;
da(param?: number, callback?: Function): boolean;
linePosAbsolute(param?: number): boolean;
vpa(param?: number): boolean;
VPositionRelative(param?: number): boolean;
vpr(param?: number): boolean;
HVPosition(row?: number, col?: number): boolean;
hvp(row?: number, col?: number): boolean;
setMode(...args: string[]): boolean;
sm(...args: string[]): boolean;
decset(...args: string[]): boolean;
showCursor(): boolean;
alternateBuffer(): boolean;
smcup(): boolean;
alternate(): boolean;
resetMode(...args: string[]): boolean;
rm(...args: string[]): boolean;
decrst(...args: string[]): boolean;
hideCursor(): boolean;
civis(): boolean;
vi(): boolean;
cursor_invisible(): boolean;
dectcemh(): boolean;
normalBuffer(): boolean;
rmcup(): boolean;
enableMouse(): void;
disableMouse(): void;
setMouse(opt?: {}, enable?: boolean): void;
setScrollRegion(top: number, bottom: number): boolean;
csr(top: number, bottom: number): boolean;
decstbm(top: number, bottom: number): boolean;
saveCursorA(): boolean;
scA(): boolean;
restoreCursorA(): boolean;
rcA(): boolean;
cursorForwardTab(param?: number): boolean;
cht(param?: number): boolean;
scrollUp(param?: number): boolean;
su(param?: number): boolean;
scrollDown(param?: number): boolean;
sd(param?: number): boolean;
initMouseTracking(...args: string[]): boolean;
resetTitleModes(...args: string[]): boolean;
cursorBackwardTab(param?: number): boolean;
cbt(param?: number): boolean;
repeatPrecedingCharacter(param?: number): boolean;
rep(param?: number): boolean;
tabClear(param?: number): boolean;
tbc(param?: number): boolean;
mediaCopy(...args: string[]): boolean;
mc(...args: string[]): boolean;
mc0(): boolean;
print_screen(): boolean;
ps(): boolean;
mc5(): boolean;
prtr_on(): boolean;
po(): boolean;
mc4(): boolean;
prtr_off(): boolean;
pf(): boolean;
mc5p(): boolean;
prtr_non(): boolean;
p0(): boolean;
setResources(...args: string[]): boolean;
disableModifieres(...args: string[]): boolean;
setPointerMode(...args: string[]): boolean;
softReset(): boolean;
rs2(): boolean;
decstr(): boolean;
requestAnsiMode(param?: number): boolean;
decrqm(param?: number): boolean;
requestPrivateMode(param?: number): boolean;
decrqmp(param?: number): boolean;
setConformanceLevel(...args: string[]): boolean;
decscl(...args: string[]): boolean;
loadLEDs(param?: number): boolean;
decll(param?: number): boolean;
setCursorStyle(param?: string): boolean;
decscursr(param?: string): boolean;
setCharProtectionAttr(param?: number): boolean;
decsca(param?: number): boolean;
restorePrivateValues(...args: string[]): boolean;
setAttrInRectangle(...args: string[]): boolean;
deccara(...args: string[]): boolean;
savePrivateValues(...args: string[]): boolean;
manipulateWindow(...args: any[]): boolean;
getWindowSize(callback?: Function): boolean;
reverseAttrInRectangle(...args: string[]): boolean;
decrara(...args: string[]): boolean;
setTitleModeFeature(...args: string[]): boolean;
setWarningBellVolume(param?: number): boolean;
decswbv(param?: number): boolean;
setMarginBellVolume(param?: number): boolean;
copyRectangle(...args: string[]): boolean;
deccra(...args: string[]): boolean;
enableFilterRectangle(...args: string[]): boolean;
decefr(...args: string[]): boolean;
requestParameters(param?: number): boolean;
decreqtparm(param: number): boolean;
selectChangeExtent(param?: number): boolean;
decsace(param?: number): boolean;
fillRectangle(...args: string[]): boolean;
decfra(...args: string[]): boolean;
enableLocatorReporting(...args: string[]): boolean;
decelr(...args: string[]): boolean;
eraseRectangle(...args: string[]): boolean;
decera(...args: string[]): boolean;
setLocatorEvents(...args: string[]): boolean;
decsle(...args: string[]): boolean;
selectiveEraseRectangle(...args: string[]): boolean;
decsera(...args: string[]): boolean;
requestLocatorPosition(param?: string, callback?: Function): boolean;
reqmp(param?: string, callback?: Function): boolean;
req_mouse_pos(param?: string, callback?: Function): boolean;
decrqlp(param?: string, callback?: Function): boolean;
insertColumns(...args: string[]): boolean;
decic(...args: string[]): boolean;
deleteColumns(...args: string[]): boolean;
decdc(...args: string[]): boolean;
out(param: string, ...args: any[]): boolean;
sigtstp(callback?: Function): boolean;
pause(callback?: Function): Function;
resume: () => void;
}
export namespace Widgets {
@@ -3024,6 +3444,7 @@ export function message(options?: Widgets.MessageOptions): Widgets.MessageElemen
export function loading(options?: Widgets.LoadingOptions): Widgets.LoadingElement;
export function log(options?: Widgets.LogOptions): Widgets.Log;
export function progressbar(options?: Widgets.ProgressBarOptions): Widgets.ProgressBarElement;
export function program(options?: Widgets.IScreenOptions): BlessedProgram;
export function terminal(options?: Widgets.TerminalOptions): Widgets.TerminalElement;
export function layout(options?: Widgets.LayoutOptions): Widgets.LayoutElement;
export function escape(item: any): any;
+1 -1
View File
@@ -44,7 +44,7 @@
* d. target es6, latest "es20xx", e.g. "es2017"
*/
import * as Bluebird from "bluebird";
import Bluebird = require("bluebird");
declare global {
/*
@@ -0,0 +1,25 @@
// basic usage
$(document).ready(() => {
$.bootstrapGrowl('Message to show in alert');
});
// with options example
let offsetOptions: BootstrapGrowlIfightcrime.OffsetOption = {
from: 'top',
amount: 20
};
let options: BootstrapGrowlIfightcrime.Options = {
ele: 'body',
type: 'info',
offset: offsetOptions,
align: 'right',
width: 250,
delay: 4000,
allow_dismiss: true,
stackup_spacing: 10
};
$(document).ready(() => {
$.bootstrapGrowl('Alert with options', options);
});
+78
View File
@@ -0,0 +1,78 @@
// Type definitions for Bootstrap Growl Ifightcrime 1.1
// Project: https://github.com/ifightcrime/bootstrap-growl
// Definitions by: Anderson Friaça <https://github.com/AndersonFriaca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace BootstrapGrowlIfightcrime {
type OffsetPositionType = 'top' | 'bottom';
type AlertType = 'info' | 'danger' | 'success' | 'warning' | string | null;
type AlignType = 'left' | 'center' | 'right';
interface OffsetOption {
/**
* Position: top or bottom
*/
from?: OffsetPositionType;
/**
* Offset amount
*/
amount?: number;
}
interface Options {
/**
* Which element to append to
*/
ele?: string;
/**
* Values of (null, 'info', 'danger', 'success', 'warning') or another value
*/
type?: AlertType;
/**
* Offset Options
*/
offset?: OffsetOption;
/**
* 'left', 'right', or 'center'
*/
align?: AlignType;
/**
* Integer
*/
width?: number;
/**
* Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
*/
delay?: number;
/**
* If true then will display a cross to close the popup.
*/
allow_dismiss?: boolean;
/**
* Spacing between consecutively stacked growls.
*/
stackup_spacing?: number;
}
}
interface JQueryStatic {
/**
* Show standard Bootstrap alerts into hovering "Growl-like" notifications
* @param message to show.
* @param options should be an options object.
* @returns The element.
*/
bootstrapGrowl: (message: string, options?: BootstrapGrowlIfightcrime.Options) => JQuery;
}
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bootstrap-growl-ifightcrime-tests.ts"
]
}
@@ -0,0 +1 @@
{"extends": "dtslint/dt.json"}
+42
View File
@@ -0,0 +1,42 @@
import * as React from "react";
import { Config, render, markdown, Catalog, ReactSpecimen, Page } from "catalog";
const config: Config = {
title: 'Test',
pages: [
{
path: '/',
title: 'Introduction',
content: '/patd/to/file.md',
},
{
path: '/materials',
title: 'Materials',
pages: [
{
path: '/materials/typeface',
title: 'Typeface',
component: <Page />,
},
],
},
],
useBrowserHistory: true,
basePath: '/doc',
responsiveSizes: [
{ name: 'large', width: 978, height: 1100 },
{ name: 'medium', width: 640, height: 900 },
{ name: 'small', width: 471, height: 700 },
],
};
render(config, document.body);
<Catalog {...config} />;
markdown`
# Test
${<ReactSpecimen>
<div />
</ReactSpecimen>}
`;
+108
View File
@@ -0,0 +1,108 @@
// Type definitions for catalog 2.1
// Project: https://github.com/interactivethings/catalog/
// Definitions by: Peter Gassner <https://github.com/grossbart>, Tomas Carnecky <https://github.com/wereHamster>
// Definitions: https://github.com/interactivethings/catalog/
// TypeScript Version: 2.3
import * as React from "react";
// Configuration
// XXX: Can not name this 'Page' because there's already a 'Page'
// component here.
export interface ConfigPage {
path: string;
title: string;
content?: any;
component?: any;
pages?: ConfigPage[];
}
export interface ConfigResponsiveSize {
name: string;
width: number;
height: number;
}
export interface Config {
title: string;
pages: ConfigPage[];
useBrowserHistory?: boolean;
basePath?: string;
responsiveSizes?: ConfigResponsiveSize[];
}
export function render(config: Config, element: HTMLElement): void;
export function configure(config: any): any;
export function configureRoutes(config: any): any;
export function configureJSXRoutes(config: any): any;
export function pageLoader(f: () => Promise<any>): any;
export function markdown(...x: any[]): JSX.Element;
// Components
export interface DefaultCatalogProps extends React.Props<{}> {
span?: number;
theme?: any;
}
export class Card extends React.Component<DefaultCatalogProps> {}
export class Page extends React.Component<DefaultCatalogProps> {}
export interface SpanProps extends DefaultCatalogProps {
style?: any;
}
export class Span extends React.Component<SpanProps> {}
// Specimens
export class AudioSpecimen extends React.Component<DefaultCatalogProps> {}
export interface CodeSpecimenProps extends DefaultCatalogProps {
rawBody: string;
collapsed: boolean;
lang: string;
raw: boolean;
}
export class CodeSpecimen extends React.Component<CodeSpecimenProps> {}
export interface ColorSpecimenProps extends DefaultCatalogProps {
value: string;
name: string;
}
export class ColorSpecimen extends React.Component<ColorSpecimenProps> {}
export interface ColorPaletteSpecimenProps extends DefaultCatalogProps {
colors: Array<{name?: string, value: string}>;
horizontal?: boolean;
}
export class ColorPaletteSpecimen extends React.Component<ColorPaletteSpecimenProps> {}
export class HtmlSpecimen extends React.Component<DefaultCatalogProps> {}
export class HintSpecimen extends React.Component<DefaultCatalogProps> {}
export class ImageSpecimen extends React.Component<DefaultCatalogProps> {}
export interface TypeSpecimenProps extends DefaultCatalogProps {
color?: string;
font: string;
headings: string[] | number[];
style?: string;
weight: string;
}
export class TypeSpecimen extends React.Component<TypeSpecimenProps> {}
export class DownloadSpecimen extends React.Component<DefaultCatalogProps> {}
export interface ReactSpecimenProps extends DefaultCatalogProps {
noSource?: boolean;
plain?: boolean;
light?: boolean;
dark?: boolean;
frame?: boolean;
state?: any;
responsive?: boolean | string | string[];
}
export class ReactSpecimen extends React.Component<ReactSpecimenProps> {}
export class VideoSpecimen extends React.Component<DefaultCatalogProps> {}
export class Catalog extends React.Component<Config> {}
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"catalog-tests.tsx"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+4 -2
View File
@@ -1,6 +1,8 @@
// Type definitions for cleave.js 1.0
// Type definitions for cleave.js 1.1
// Project: https://github.com/nosir/cleave.js
// Definitions by: C Lentfort <https://github.com/clentfort>, J Giancono <https://github.com/jasongi-at-sportsbet>
// Definitions by: C Lentfort <https://github.com/clentfort>,
// J Giancono <https://github.com/jasongi-at-sportsbet>,
// Alex Shakun <https://github.com/sashashakun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
+1
View File
@@ -6,6 +6,7 @@ type InitHandler = (owner: React.ReactInstance) => void;
interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
onInit?: InitHandler;
options: CleaveOptions;
htmlRef?: (i: any) => void;
}
declare var Cleave: React.ComponentClass<Props>;
+38
View File
@@ -0,0 +1,38 @@
import * as d3Fetch from 'd3-fetch';
import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv';
interface MyType {
foo: string;
}
const url = 'foo.bar';
const init: RequestInit = {};
let p1: Promise<Blob> = d3Fetch.blob(url);
p1 = d3Fetch.blob(url, init);
let p2: Promise<ArrayBuffer> = d3Fetch.buffer(url);
p2 = d3Fetch.buffer(url, init);
let p3: Promise<HTMLImageElement> = d3Fetch.image(url);
p3 = d3Fetch.image(url, init);
let p4: Promise<any> = d3Fetch.json(url);
p4 = d3Fetch.json(url, init);
let myString: Promise<string>;
myString = d3Fetch.text(url);
myString = d3Fetch.text(url, init);
const parseRow = (d: {}) => {
const myType: MyType = { foo: 'foo' };
return myType;
};
let promise2: Promise<DSVParsedArray<MyType>>;
promise2 = d3Fetch.csv<MyType>(url);
promise2 = d3Fetch.csv<MyType>(url, init);
promise2 = d3Fetch.csv<MyType>(url, init, parseRow);
promise2 = d3Fetch.dsv<MyType>(';', url);
promise2 = d3Fetch.dsv<MyType>(';', url, init);
promise2 = d3Fetch.dsv<MyType>(';', url, init, parseRow);
promise2 = d3Fetch.tsv<MyType>(url);
promise2 = d3Fetch.tsv<MyType>(url, init);
promise2 = d3Fetch.tsv<MyType>(url, init, parseRow);
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for d3-fetch 1.0
// Project: https://d3js.org/d3-fetch/
// Definitions by: Hugues Stefanski <https://github.com/ledragon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv';
/** Fetches the binary file at the specified input URL as a Blob. If init is specified, it is passed along to the underlying call to fetch. */
export function blob(url: string, init?: RequestInit): Promise<Blob>;
/** Fetches the binary file at the specified input URL as an ArrayBuffer. If init is specified, it is passed along to the underlying call to fetch. */
export function buffer(url: string, init?: RequestInit): Promise<ArrayBuffer>;
/** Equivalent to d3.dsv with the comma character as the delimiter. */
export function csv<ParsedRow extends DSVRowAny>(
url: string,
init?: RequestInit,
row?: (d: DSVRowAny) => ParsedRow
): Promise<DSVParsedArray<ParsedRow>>;
/** Fetches the DSV file at the specified input URL. */
export function dsv<ParsedRow extends DSVRowAny>(
delimiter: string,
url: string,
init?: RequestInit,
row?: (d: DSVRowAny) => ParsedRow
): Promise<DSVParsedArray<ParsedRow>>;
/** Fetches the image at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */
export function image(url: string, init?: RequestInit): Promise<HTMLImageElement>;
/** Fetches the json file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */
export function json(url: string, init?: RequestInit): Promise<{}>;
/** Fetches the text file at the specified input URL. If init is specified, it is passed along to the underlying call to fetch. */
export function text(url: string, init?: RequestInit): Promise<string>;
/** Equivalent to d3.dsv with the tab character as the delimiter. */
export function tsv<ParsedRow extends DSVRowAny>(
url: string,
init?: RequestInit,
row?: (d: DSVRowAny) => ParsedRow
): Promise<DSVParsedArray<ParsedRow>>;
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
@@ -19,6 +19,6 @@
},
"files": [
"index.d.ts",
"yfiles-tests.ts"
"d3-fetch-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+12 -3
View File
@@ -17,6 +17,7 @@ import { HierarchyPointLink, HierarchyPointNode } from 'd3-hierarchy';
let context: CanvasRenderingContext2D | null = document.querySelector('canvas')!.getContext('2d');
let num: number;
let padAngleMaybe: number | undefined;
let pathStringMaybe: string | null;
// -----------------------------------------------------------------------------------
@@ -28,7 +29,7 @@ interface ArcDatum {
oRadius: number;
sAngle: number;
eAngle: number;
pAngle: number;
pAngle?: number;
}
const arcDefaultDatum: d3Shape.DefaultArcObject = {
@@ -39,6 +40,13 @@ const arcDefaultDatum: d3Shape.DefaultArcObject = {
padAngle: 0.03
};
const arcReducedDefaultDatum: d3Shape.DefaultArcObject = {
innerRadius: 40,
outerRadius: 60,
startAngle: 0,
endAngle: Math.PI / 2
};
const arcDatum: ArcDatum = {
iRadius: 40,
oRadius: 60,
@@ -48,6 +56,7 @@ const arcDatum: ArcDatum = {
};
let accessorArcDatumNumber: (this: any, d: ArcDatum, ...args: any[]) => number;
let accessorArcDatumNumberOrUndefined: (this: any, d: ArcDatum, ...args: any[]) => number | undefined;
let accessorArcDatumNumberOrNull: ((this: any, d: ArcDatum, ...args: any[]) => number) | null;
// DefaultArcObject interface ========================================================
@@ -64,7 +73,7 @@ num = defaultArcObject.innerRadius;
num = defaultArcObject.outerRadius;
num = defaultArcObject.startAngle;
num = defaultArcObject.endAngle;
num = defaultArcObject.padAngle;
padAngleMaybe = defaultArcObject.padAngle;
// arc(...) create Arc generator =====================================================
@@ -134,7 +143,7 @@ canvasArc = canvasArc.padAngle(0);
svgArc = svgArc.padAngle(d => {
return d.pAngle; // datum type is ArcDatum
});
accessorArcDatumNumber = svgArc.padAngle();
accessorArcDatumNumberOrUndefined = svgArc.padAngle();
// padRadius(...) ----------------------------------------------------------------------
+5 -5
View File
@@ -32,9 +32,9 @@ export interface DefaultArcObject {
*/
endAngle: number;
/**
* Pad angle of arcin radians.
* Optional. Pad angle of arcin radians.
*/
padAngle: number;
padAngle?: number;
}
/**
@@ -230,7 +230,7 @@ export interface Arc<This, Datum> {
* Returns the current pad angle accessor, which defaults to a function returning the padAngle property
* of the first argument passed into it, or false if no data are passed in or the property is not defined.
*/
padAngle(): (this: This, d: Datum, ...args: any[]) => number;
padAngle(): (this: This, d: Datum, ...args: any[]) => number | undefined;
/**
* Sets the pad angle to the specified number and returns this arc generator.
*
@@ -248,7 +248,7 @@ export interface Arc<This, Datum> {
*
* @param angle Constant angle in radians.
*/
padAngle(angle: number): this;
padAngle(angle: number | undefined): this;
/**
* Sets the pad angle to the specified function and returns this arc generator.
*
@@ -267,7 +267,7 @@ export interface Arc<This, Datum> {
* @param angle An accessor function returning a number in radians to be used as an angle. The accessor function is invoked in the same "this" context as the generator was invoked in and
* receives the same arguments that were passed into the arc generator.
*/
padAngle(angle: (this: This, d: Datum, ...args: any[]) => number): this;
padAngle(angle: (this: This, d: Datum, ...args: any[]) => number | undefined): this;
/**
* Returns the current pad radius accessor, which defaults to null, indicating that the pad radius should be automatically computed as sqrt(innerRadius * innerRadius + outerRadius * outerRadius).
+9
View File
@@ -0,0 +1,9 @@
import * as ed2curve from 'ed2curve';
import * as nacl from 'tweetnacl';
const myKeyPair = nacl.sign.keyPair();
const newPublicKey = ed2curve.convertPublicKey(myKeyPair.publicKey);
const newSecretKey = ed2curve.convertSecretKey(myKeyPair.secretKey);
const newKeyPair = ed2curve.convertKeyPair(myKeyPair);
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for ed2curve 0.2
// Project: https://github.com/dchest/ed2curve-js
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import { BoxKeyPair, SignKeyPair } from "tweetnacl";
export as namespace ed2curve;
/**
* Converts Ed25519 public key to Curve25519 public key.
* montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
*/
export function convertPublicKey(publicKey: SignKeyPair["publicKey"]): BoxKeyPair["publicKey"] | null;
/** Converts Ed25519 secret key to Curve25519 secret key. */
export function convertSecretKey(secretKey: SignKeyPair["secretKey"]): BoxKeyPair["secretKey"] | null;
/** Converts Ed25519 key pair to Curve25519 key pair. */
export function convertKeyPair(keyPair: SignKeyPair): BoxKeyPair;
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"tweetnacl": "^1.0.0"
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ed2curve-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1,4 +1,4 @@
import * as Component from "@egjs/component";
import Component = require("@egjs/component");
import { AnimationManager } from "./AnimationManager";
import { EventManager } from "./EventManager";
import { InterruptManager } from "./InterruptManager";
+1 -6
View File
@@ -166,12 +166,7 @@ async () => {
};
async () => {
const result = await Facebook.logInWithReadPermissionsAsync('appId');
if (result.type === 'success') {
result.expires;
result.token;
}
const { type, expires, token } = await Facebook.logInWithReadPermissionsAsync("appId");
};
() => (
+5 -7
View File
@@ -729,13 +729,11 @@ export namespace Facebook {
permissions?: string[];
behavior?: 'web' | 'native' | 'browser' | 'system';
}
type Response = {
type: 'success';
token: string;
expires: number;
} | {
type: 'cancel';
};
interface Response {
type: 'cancel' | 'success';
token?: string;
expires?: number;
}
function logInWithReadPermissionsAsync(appId: string, options?: Options): Promise<Response>;
}
+1 -6
View File
@@ -159,12 +159,7 @@ async () => {
};
async () => {
const result = await Facebook.logInWithReadPermissionsAsync('appId');
if (result.type === 'success') {
result.expires;
result.token;
}
const { type, expires, token } = await Facebook.logInWithReadPermissionsAsync("appId");
};
() => (
+5 -7
View File
@@ -726,13 +726,11 @@ export namespace Facebook {
permissions?: string[];
behavior?: 'web' | 'native' | 'browser' | 'system';
}
type Response = {
type: 'success';
token: string;
expires: number;
} | {
type: 'cancel';
};
interface Response {
type: 'cancel' | 'success';
token?: string;
expires?: number;
}
function logInWithReadPermissionsAsync(appId: string, options?: Options): Promise<Response>;
}
@@ -37,3 +37,34 @@ app.use((req, res, next) => {
res.end('welcome to the session demo. refresh!');
}
});
// Custom Session Store
class MyStore extends session.Store {
private sessions: { [sid: string]: string };
constructor() {
super();
this.sessions = {};
}
get = (sid: string, callback: (err: any, session: Express.SessionData) => void): void => {
callback(null, JSON.parse(this.sessions[sid]));
}
set = (sid: string, session: Express.Session, callback: (err: any) => void): void => {
this.sessions[sid] = JSON.stringify(session);
callback(null);
}
destroy = (sid: string, callback: (err: any) => void): void => {
this.sessions[sid] = undefined;
this.sessions = JSON.parse(JSON.stringify(this.sessions));
callback(null);
}
}
app.use(session({
secret: 'keyboard cat',
store: new MyStore()
}));
+4 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for express-session 1.15
// Project: https://www.npmjs.org/package/express-session
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>, Jacob Bogers <https://github.com/jacobbogers>
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>, Jacob Bogers <https://github.com/jacobbogers>, Naoto Yokoyama <https://github.com/builtinnya>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -64,7 +64,7 @@ declare namespace session {
}
interface BaseMemoryStore {
get: (sid: string, callback: (err: any, session: Express.Session) => void) => void;
get: (sid: string, callback: (err: any, session: Express.SessionData) => void) => void;
set: (sid: string, session: Express.Session, callback: (err: any) => void) => void;
destroy: (sid: string, callback: (err: any) => void) => void;
length?: (callback: (err: any, length: number) => void) => void;
@@ -78,7 +78,7 @@ declare namespace session {
load: (sid: string, fn: (err: any, session: Express.Session) => any) => void;
createSession: (req: express.Request, sess: Express.SessionData) => void;
get: (sid: string, callback: (err: any, session: Express.Session) => void) => void;
get: (sid: string, callback: (err: any, session: Express.SessionData) => void) => void;
set: (sid: string, session: Express.Session, callback: (err: any) => void) => void;
destroy: (sid: string, callback: (err: any) => void) => void;
all: (callback: (err: any, obj: { [sid: string]: Express.SessionData; }) => void) => void;
@@ -87,7 +87,7 @@ declare namespace session {
}
class MemoryStore implements BaseMemoryStore {
get: (sid: string, callback: (err: any, session: Express.Session) => void) => void;
get: (sid: string, callback: (err: any, session: Express.SessionData) => void) => void;
set: (sid: string, session: Express.Session, callback: (err: any) => void) => void;
destroy: (sid: string, callback: (err: any) => void) => void;
all: (callback: (err: any, obj: { [sid: string]: Express.Session; }) => void) => void;
+1 -1
View File
@@ -15,7 +15,7 @@
/// <reference types="serve-static" />
import * as bodyParser from "body-parser";
import * as serveStatic from "serve-static";
import serveStatic = require("serve-static");
import * as core from "express-serve-static-core";
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as Store from "./FluxStore";
import Store = require("./FluxStore");
declare namespace FluxReduceStore { }
+1
View File
@@ -84,6 +84,7 @@ export interface Props {
options?: Options | ((maps: Maps) => Options);
margin?: any[];
debounced?: boolean;
draggable?: boolean;
layerTypes?: string[];
onClick?(value: ClickEventValue): any;
onChange?(value: ChangeEventValue): any;
+31 -24
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/rwaldron/johnny-five
// Definitions by: Toshiya Nakakura <https://github.com/nakakura>
// Zoltan Ujvary <https://github.com/ujvzolee>
// Simon Colmer <https://github.com/workshop2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="node"/>
@@ -290,30 +291,6 @@ export declare class IMU {
}
export declare module IR {
export interface MotionOption {
pin: number | string;
}
export class Motion {
constructor(option: number | MotionOption);
on(event: string, cb: () => void): this;
on(event: "data", cb: (data: any) => void): this;
on(event: "motionstart", cb: () => void): this;
on(event: "motionend", cb: () => void): this;
on(event: "calibrated", cb: () => void): this;
}
export interface PloximityOption {
pin: number | string;
controller: string;
}
export class Proximity {
constructor(option: number | PloximityOption);
on(event: string, cb: () => void): this;
on(event: "data", cb: (data: any) => void): this;
on(event: "change", cb: () => void): this;
}
export interface ArrayOption {
pins: Array<number> | Array<string>;
@@ -521,6 +498,19 @@ export declare module Led {
}
}
export interface MotionOption {
pin: number | string;
}
export class Motion {
constructor(option: number | MotionOption);
on(event: string, cb: () => void): this;
on(event: "data", cb: (data: any) => void): this;
on(event: "motionstart", cb: () => void): this;
on(event: "motionend", cb: () => void): this;
on(event: "calibrated", cb: () => void): this;
}
export interface MotorOption {
pins: any;
current?: any;
@@ -629,6 +619,23 @@ export declare class Ping {
constructor(option: number | PingOption);
}
export declare interface ProximityOption {
pin: number | string;
controller: string;
}
export declare interface ProximityData {
cm: number;
in: number;
}
export declare class Proximity {
constructor(option: number | ProximityOption);
on(event: string, cb: () => void): this;
on(event: "data", cb: (data: ProximityData) => void): this;
on(event: "change", cb: () => void): this;
}
export interface RelayOption {
pin: number | string;
type?: string;
+3 -3
View File
@@ -71,14 +71,14 @@ board.on('ready', function(){
freq: 100 // optional
});
var motion = new five.IR.Motion(7);
var motion = new five.Motion(7);
// Options object with pin property
var motion = new five.IR.Motion({
var motion = new five.Motion({
pin: 7
});
var proximity = new five.IR.Proximity({
var proximity = new five.Proximity({
controller: "GP2Y0A21YK",
pin: "A0"
});
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for jquery-awesome-cursor 0.3
// Project: https://jwarby.github.io/jquery-awesome-cursor
// Definitions by: Zsolt Kovács <https://github.com/zskovacs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace JQueryAwesomeCursor {
type flip = "horizontal" | "vertical" | "both";
type cssHandler = (name: string) => void;
interface Options {
color?: string;
size?: number;
hotspot?: number[] | string;
flip?: flip;
rotate?: number;
outline?: string;
font?: Font;
}
interface Font {
family: string;
cssClass: string | cssHandler;
}
}
interface JQueryStatic {
awesomeCursor(icon: string, options?: JQueryAwesomeCursor.Options): JQuery;
}
interface JQuery {
awesomeCursor(icon: string, options?: JQueryAwesomeCursor.Options): JQuery;
}
@@ -0,0 +1,64 @@
// Default
jQuery.awesomeCursor('pencil');
// Color
jQuery.awesomeCursor('pencil', {
color: '#ff0000'
});
// Size
jQuery.awesomeCursor('pencil', {
size: 32
});
// Hotspot
jQuery.awesomeCursor('pencil', {
hotspot: [0, 17]
});
jQuery.awesomeCursor('pencil', {
hotspot: 'bottom left'
});
// Flip
jQuery.awesomeCursor('pencil', {
flip: 'horizontal'
});
jQuery.awesomeCursor('pencil', {
flip: 'vertical'
});
jQuery.awesomeCursor('pencil', {
flip: 'both'
});
// Rotate
jQuery.awesomeCursor('pencil', {
rotate: 45
});
// Outline
jQuery.awesomeCursor('pencil', {
outline: 'red'
});
// Different font
jQuery.awesomeCursor('brush', {
font: {
family: 'typicons',
cssClass: 'typcn typcn-%s'
}
});
jQuery.awesomeCursor('brush', {
font: {
family: 'typicons',
cssClass: (name) => {
return 'typcn typcn-' + name;
}
}
});
// Mixed
jQuery.awesomeCursor('long-arrow-left', {
color: 'red',
hotspot: 'top left',
rotate: 45,
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jquery-awesome-cursor-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+4 -1
View File
@@ -1,6 +1,8 @@
// Type definitions for jQuery Mask Plugin 1.14
// Project: https://igorescobar.github.io/jQuery-Mask-Plugin/
// Definitions by: Anže Videnič <https://github.com/avidenic>, Igor Escobar <http://www.igorescobar.com/>
// Definitions by: Anže Videnič <https://github.com/avidenic>
// Igor Escobar <http://www.igorescobar.com/>
// Anderson Friaça <https://github.com/AndersonFriaca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -25,6 +27,7 @@ declare namespace jQueryMask {
selectOnFocus?: boolean;
reverse?: boolean;
clearIfNotMatch?: boolean;
placeholder?: string;
onComplete?(value: string, e: Event, $element: JQuery, options: Options): void;
onKeyPress?(value: string, e: Event, $element: JQuery, options: Options): void;
onChange?(value: string, e: Event, $element: JQuery, options: Options): void;
@@ -27,6 +27,9 @@ $(document).ready(() => {
placeholder: "__/__/____"
}
});
$('.placeholder2').mask("00/00/0000", {
placeholder: "__/__/____"
});
$('.fallback').mask("00r00r0000", {
translation: {
r: {
+112
View File
@@ -0,0 +1,112 @@
// Type definitions for jQuery Tags Input Plugin 1.3
// Project: https://github.com/xoxco/jQuery-Tags-Input
// Definitions by: Anderson Friaça <https://github.com/AndersonFriaca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare namespace jQueryTagsInput {
interface Options {
/**
* Url for autocomplete
*/
autocomplete_url?: string;
/**
* Autocomplete options
*/
autocomplete?: object;
/**
* Height of tag
*/
height?: string;
/**
* Width of tag
*/
width?: string;
/**
* Interactive tags
*/
interactive?: boolean;
/**
* Placeholder of field when tags is empty
*/
defaultText?: string;
/**
* Callback function on add tag
*/
onAddTag?: (addedValue: string) => void;
/**
* Callback function on remove tag
*/
onRemoveTag?: (removedValue: string) => void;
/**
* Callback function on change list of tags
*/
onChange?: (element: JQuery, changedValue: string) => void;
/**
* Delimiters on tags creation
*/
delimiter?: string[]|string;
/**
* Remove with tag backspace
*/
removeWithBackspace ?: boolean;
/**
* Minimun char length for tag
*/
minChars?: number;
/**
* Max char length for tag
*/
maxChars?: number;
/**
* Placeholder color of tags
*/
placeholderColor?: string;
}
}
interface JQuery {
/**
* Transform input field to work with tags
* @param options for creation
*/
tagsInput(options?: jQueryTagsInput.Options): JQuery;
/**
* Add a new tag to list
* @param tag value
*/
addTag(tag: string): boolean;
/**
* Remove tag with value from list
* @param tag to be removed
*/
removeTag(tag: string): boolean;
/**
* Add a new tags
* @param tags string separated by delimiter
*/
importTags(tags: string): void;
/**
* Verify if tag exists
* @param tag value
*/
tagExist(tag: string): boolean;
}
@@ -0,0 +1,20 @@
// basic usage
$(document).ready(() => {
$('#inputTag').tagsInput();
$('#inputTag').addTag('new tag');
$('#inputTag').tagExist('new tag');
$('inputTag').removeTag('new tag');
$('#inputTag').importTags('tag1, tag2, tag3');
// with options
const options: jQueryTagsInput.Options = {
height: '100px',
width: '300px',
minChars: 3,
maxChars: 0,
onAddTag: (value: string) => {
alert('Tag added: ' + value);
}
};
$('#inputTag').tagsInput(options);
});
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jquery-tags-input-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{"extends": "dtslint/dt.json"}
+4 -3
View File
@@ -31,6 +31,7 @@ interface JQueryColorpickerOptions {
closeOnOutside?: boolean;
color?: string;
colorFormat?: string;
disabled: boolean;
draggable?: boolean;
duration?: string;
format?: string;
@@ -38,7 +39,7 @@ interface JQueryColorpickerOptions {
hsv?: boolean;
inline?: boolean;
inlineFrame?: boolean;
layout?: {[part: string]: number[];};
layout?: { [part: string]: number[]; };
limit?: string;
modal?: boolean;
mode?: string;
@@ -67,7 +68,7 @@ interface JQueryColorpickerStatic {
regional: { [key: string]: string; };
swatches: { [swatch: string]: { [name: string]: JQueryColorpickerStatic.RGB; }; };
writers: { [name: string]: (color: any, that: any) => any; };
Color: { new (r?: number, g?: number, b?: number, a?: number): JQueryColorpickerStatic.Color; };
Color: { new(r?: number, g?: number, b?: number, a?: number): JQueryColorpickerStatic.Color; };
}
declare namespace JQueryColorpickerStatic {
@@ -162,6 +163,6 @@ interface JQuery {
colorpicker(method: "open"): JQuery;
colorpicker(method: string): JQuery;
colorpicker(method: "setColor", color: any): JQuery;
colorpicker(method: string, param: any): JQuery;
colorpicker(method: string, ...params: any[]): JQuery;
colorpicker(options?: JQueryColorpickerOptions): JQuery;
}
@@ -17,6 +17,7 @@ var colorpicker = $("<input type=\"text\"/>").colorpicker({
closeOnOutside: true, // Close the dialog when clicking outside the dialog (not for inline)
color: '#00FF00', // Initial color (for inline only)
colorFormat: 'HEX', // Format string for output color format
disabled: false,
draggable: true, // Make popup dialog draggable if header is visible.
duration: 'fast',
hsv: true, // Show HSV controls and modes
@@ -67,6 +68,7 @@ colorpicker.colorpicker("open");
colorpicker.colorpicker("close");
colorpicker.colorpicker("destroy");
colorpicker.colorpicker("setColor", "#deadbeef");
colorpicker.colorpicker("option", "disabled", true);
// example plugins provided
@@ -94,23 +96,23 @@ $.colorpicker.parts["memory"] = function (inst) {
break;
}
}).bind('contextmenu', function (e) {
e.preventDefault();
});
e.preventDefault();
});
container.append($node);
},
getMemory = function () {
return (<string>(document.cookie.match(/\bcolorpicker-memory=([^;]*)/) || [0, ''])[1]).split(',');
},
setMemory = function () {
var colors = [];
$('> *', container).each(function () {
colors.push(encodeURIComponent($(this).css('backgroundColor')));
});
var expdate = new Date();
expdate.setDate(expdate.getDate() + (365 * 10));
document.cookie = 'colorpicker-memory=' + colors.join() + ";expires=" + expdate.toUTCString();
};
setMemory = function () {
var colors = [];
$('> *', container).each(function () {
colors.push(encodeURIComponent($(this).css('backgroundColor')));
});
var expdate = new Date();
expdate.setDate(expdate.getDate() + (365 * 10));
document.cookie = 'colorpicker-memory=' + colors.join() + ";expires=" + expdate.toUTCString();
};
this.init = function () {
container = $('<div/>')
@@ -195,7 +197,7 @@ $.colorpicker.parsers['CMYK'] = function (color) {
parseInt(m[2], 10) / 255,
parseInt(m[3], 10) / 255,
parseInt(m[4], 10) / 255
);
);
}
};
@@ -206,7 +208,7 @@ $.colorpicker.parsers["#HEX8"] = function (color) {
parseInt(m[2], 16) / 255,
parseInt(m[3], 16) / 255,
parseInt(m[4], 16) / 255
).setAlpha(parseInt(m[1], 16) / 255);
).setAlpha(parseInt(m[1], 16) / 255);
}
};
+13 -11
View File
@@ -3,6 +3,8 @@
// Definitions by: Daniel Imrie-Situnayake <https://github.com/dansitu>, Bill <https://github.com/bkim54>, Michael Haan <https://github.com/sfrooster>, Amiram Korach <https://github.com/amiram>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
// # Classes
export class Client {
constructor(connectionString: string, clientId?: string, options?: ZKOptions, noBatchOptions?: AckBatchOptions, sslOptions?: any);
@@ -88,24 +90,24 @@ export class Offset {
}
export class KeyedMessage {
constructor(key: string, message: string);
constructor(key: string, value: string | Buffer);
}
// # Interfaces
export interface Message {
topic: string;
value: string;
offset?: number;
partition?: number;
highWaterOffset?: number;
key?: string;
}
topic: string;
value: string | Buffer;
offset?: number;
partition?: number;
highWaterOffset?: number;
key?: string;
}
export interface ProducerOptions {
requireAcks?: number;
ackTimeoutMs?: number;
partitionerType?: number;
requireAcks?: number;
ackTimeoutMs?: number;
partitionerType?: number;
}
export interface KafkaClientOptions {
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**
+1 -1
View File
@@ -1,4 +1,4 @@
import * as _ from "../index";
import _ = require("../index");
declare module "../index" {
interface LoDashStatic {
/**

Some files were not shown because too many files have changed in this diff Show More