Fixed merge Conflict

This commit is contained in:
Daryl LaBar
2016-09-22 10:55:11 -04:00
119 changed files with 16910 additions and 10365 deletions

View File

@@ -0,0 +1,31 @@
/// <reference path="angular-feature-flags.d.ts" />
let myApp = angular.module('myApp', ['feature-flags']);
const flagsData: Array<angular.featureflags.FlagData> = [
{
key: '1',
active: true,
name: 'flag1',
description: 'This is the first flag'
},
{
key: '2',
active: false,
name: 'flag2',
description: 'This is the second flag'
}
];
myApp.config(function (featureFlagsProvider: angular.featureflags.FeatureFlagsProvider) {
featureFlagsProvider.setInitialFlags(flagsData);
});
myApp.run(function ($q: angular.IQService, $http: angular.IHttpService, featureFlags: angular.featureflags.FeatureFlagsService) {
let deferred = $q.defer();
deferred.resolve(flagsData);
featureFlags.set(deferred.promise);
featureFlags.set($http.get('/data/flags.json'));
});

View File

@@ -0,0 +1,38 @@
// Type definitions for angular-feature-flags 1.4.0
// Project: https://github.com/mjt01/angular-feature-flags
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare namespace angular.featureflags {
export interface FlagData {
/**
* Unique key that is used from the markup to resolve whether a flag is active or not.
*/
key: string;
/**
* Boolean value for enabling/disabling the feature
*/
active: boolean;
/**
* A short name of the flag (only visible in the list of flags)
*/
name: string;
/**
* A long description of the flag to further explain the feature being toggled (only visible in the list of flags)
*/
description: string;
}
export interface FeatureFlagsProvider {
setInitialFlags(flags: Array<FlagData>): void;
}
export interface FeatureFlagsService {
set(flagsPromise: angular.IPromise<FlagData> | angular.IHttpPromise<FlagData>): void;
}
}

View File

@@ -132,7 +132,10 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia
});
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => {
$scope['openToast'] = () => $mdToast.show($mdToast.simple().textContent('Hello!'));
$scope['openToast'] = () => {
$mdToast.show($mdToast.simple().textContent('Hello!'));
$mdToast.updateTextContent('New Content');
}
$scope['customToast'] = () => {
var options = {

View File

@@ -177,7 +177,8 @@ declare namespace angular.material {
showSimple(content: string): angular.IPromise<any>;
simple(): ISimpleToastPreset;
build(): IToastPreset<any>;
updateContent(): void;
updateContent(newContent: string): void;
updateTextContent(newContent: string): void
hide(response?: any): void;
cancel(response?: any): void;
}

View File

@@ -400,6 +400,17 @@ declare namespace angular.ui.bootstrap {
* @default 'body'
*/
appendTo?: angular.IAugmentedJQuery;
/**
* A string reference to the component to be rendered that is registered with Angular's compiler. If using a directive, the directive must have `restrict: 'E'` and a template or templateUrl set.
*
* It supports these bindings:
* - `close` - A method that can be used to close a modal, passing a result. The result must be passed in this format: `{$value: myResult}`
* - `dismiss` - A method that can be used to dismiss a modal, passing a result. The result must be passed in this format: `{$value: myRejectedResult}`
* - `modalInstance` - The modal instance. This is the same `$uibModalInstance` injectable found when using `controller`.
* - `resolve` - An object of the modal resolve values. See [UI Router resolves] for details.
*/
component?: string;
}
interface IModalStackService {

View File

@@ -867,6 +867,26 @@ angular.module('docsTabsExample', [])
};
});
angular.module('multiSlotTranscludeExample', [])
.directive('dropDownMenu', function() {
return {
transclude: {
button: 'button',
list: 'ul',
},
link: function(scope, element, attrs, ctrl, transclude) {
// without scope
transclude().appendTo(element);
transclude(clone => clone.appendTo(element));
// with scope
transclude(scope, clone => clone.appendTo(element));
transclude(scope, clone => clone.appendTo(element), element, 'button');
transclude(scope, null, element, 'list').addClass('drop-down-list').appendTo(element);
}
};
});
angular.module('componentExample', [])
.component('counter', {
require: {'ctrl': '^ctrl'},

View File

@@ -1259,7 +1259,7 @@ declare namespace angular {
// This corresponds to $transclude (and also the transclude function passed to link).
interface ITranscludeFunction {
// If the scope is provided, then the cloneAttachFn must be as well.
(scope: IScope, cloneAttachFn: ICloneAttachFunction): JQuery;
(scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
// If one argument is provided, then it's assumed to be the cloneAttachFn.
(cloneAttachFn?: ICloneAttachFunction): JQuery;
}
@@ -1725,7 +1725,7 @@ declare namespace angular {
* Define DOM attribute binding to component properties. Component properties are always bound to the component
* controller and not to the scope.
*/
bindings?: {[binding: string]: string};
bindings?: IComponentBindings;
/**
* Whether transclusion is enabled. Enabled by default.
*/
@@ -1739,6 +1739,10 @@ declare namespace angular {
require?: {[controller: string]: string};
}
interface IComponentBindings {
[binding: string]: string;
}
interface IComponentTemplateFn {
( $element?: JQuery, $attrs?: IAttributes ): string;
}
@@ -1827,6 +1831,10 @@ declare namespace angular {
): void | IDirectivePrePost;
}
interface IDirectiveScope {
[property: string]: string;
}
interface IDirective {
compile?: IDirectiveCompileFn;
controller?: any;
@@ -1848,7 +1856,7 @@ declare namespace angular {
replace?: boolean;
require?: string | string[] | {[controller: string]: string};
restrict?: string;
scope?: boolean | Object;
scope?: boolean | IDirectiveScope;
template?: string | Function;
templateNamespace?: string;
templateUrl?: string | Function;

View File

@@ -92,7 +92,7 @@ interface Auth0LockConstructorOptions {
initialScreen?: "login" | "signUp" | "forgotPassword";
language?: string;
languageDictionary?: any;
loginAfterSignup?: boolean;
loginAfterSignUp?: boolean;
mustAcceptTerms?: boolean;
popupOptions?: Auth0LockPopupOptions;
prefill?: { email?: string, username?: string};

691
aws-sdk/aws-sdk.d.ts vendored
View File

@@ -49,6 +49,51 @@ declare module "aws-sdk" {
stack: string;
}
export interface RetryDelayOption {
base?: number;
customBackoff?: (retryCount: number) => number;
}
export interface Ebs {
SnapshotId?: string;
VolumeSize?: number;
VolumeType?: string;
DeleteOnTermination?: boolean;
Iops?: number;
Encrypted?: boolean;
}
export interface BlockDeviceMapping {
VirtualName?: string;
DeviceName: string;
Ebs?: Ebs;
NoDevice?: boolean;
}
export interface InstanceMonitoring {
SpotPrice?: string;
Enabled?: boolean;
}
export interface Filter {
Name?: string;
Values?: boolean;
}
export interface StepAdjustment {
scalingAdjustment: number;
metricIntervalLowerBound?: number;
metricIntervalUpperBound?: number;
}
export interface Tags {
resourceId?: string;
resourceType?: string;
key: string;
value?: string;
propagateAtLaunch?: boolean;
}
export interface Services {
autoscaling?: any;
cloudformation?: any;
@@ -118,6 +163,37 @@ declare module "aws-sdk" {
region: string;
}
export class CloudFormation {
constructor(options?: CloudFormation.Options);
endpoint: Endpoint;
cancelUpdateStack(params: CloudFormation.CancelUpdateStackParams, callback: (err: AwsError, data: any) => void): void;
continueUpdateRollback(params: CloudFormation.ContinueUpdateRollbackParams, callback: (err: AwsError, data: any) => void): void;
createChangeSet(params: CloudFormation.CreateChangeSetParams, callback: (err: AwsError, data: any) => void): void;
createStack(params: CloudFormation.CreateStackParams, callback: (err: AwsError, data: any) => void): void;
deleteChangeSet(params: CloudFormation.DeleteChangeSetParams, callback: (err: AwsError, data: any) => void): void;
deleteStack(params: CloudFormation.DeleteStackParams, callback: (err: AwsError, data: any) => void): void;
describeAccountLimits(params: CloudFormation.DescribeAccountLimitsParams, callback: (err: AwsError, data: any) => void): void;
describeChangeSet(params: CloudFormation.DescribeChangeSetParams, callback: (err: AwsError, data: any) => void): void;
describeStackEvents(params: CloudFormation.DescribeStackEventsParams, callback: (err: AwsError, data: any) => void): void;
describeStackResource(params: CloudFormation.DescribeStackResourceParams, callback: (err: AwsError, data: any) => void): void;
describeStackResources(params: CloudFormation.DescribeStackResourcesParams, callback: (err: AwsError, data: any) => void): void;
describeStacks(params: CloudFormation.DescribeStacksParams, callback: (err: AwsError, data: any) => void): void;
estimateTemplateCost(params: CloudFormation.EstimateTemplateCostParams, callback: (err: AwsError, data: any) => void): void;
executeChangeSet(params: CloudFormation.ExecuteChangeSetParams, callback: (err: AwsError, data: any) => void): void;
getStackPolicy(params: CloudFormation.GetStackPolicyParams, callback: (err: AwsError, data: any) => void): void;
getTemplate(params: CloudFormation.GetTemplateParams, callback: (err: AwsError, data: any) => void): void;
getTemplateSummary(params: CloudFormation.GetTemplateSummaryParams, callback: (err: AwsError, data: any) => void): void;
listChangeSets(params: CloudFormation.ListChangeSetsParams, callback: (err: AwsError, data: any) => void): void;
listStackResources(params: CloudFormation.ListStackResourcesParams, callback: (err: AwsError, data: any) => void): void;
listStacks(params: CloudFormation.ListStacksParams, callback: (err: AwsError, data: any) => void): void;
setStackPolicy(params: CloudFormation.SetStackPolicyParams, callback: (err: AwsError, data: any) => void): void;
signalResource(params: CloudFormation.SignalResourceParams, callback: (err: AwsError, data: any) => void): void;
updateStack(params: CloudFormation.UpdateStackParams, callback: (err: AwsError, data: any) => void): void;
validateTemplate(params: CloudFormation.ValidateTemplateParams, callback: (err: AwsError, data: any) => void): void;
waitFor(state: string, params: CloudFormation.WaitForParams, callback: (err: AwsError, data: any) => void): void;
}
export class Lambda {
constructor(options?: any);
endpoint: Endpoint;
@@ -147,6 +223,64 @@ declare module "aws-sdk" {
updateFunctionConfiguration(params: Lambda.UpdateFunctionConfigurationParams, callback: (err: AwsError, data: any) => void): void;
}
export class AutoScaling {
constructor(options?: any);
endpoint: Endpoint;
attachInstances(params: AutoScaling.AttachInstancesParams, callback: (err: AwsError, data: any) => void): void;
attachLoadBalancers(params: AutoScaling.AttachLoadBalancersParams, callback: (err: AwsError, data: any) => void): void;
attachLoadBalancerTargetGroups(param: AutoScaling.AttachLoadBalancerTargetGroupsParams, callback: (err: AwsError, data: any) => void): void;
completeLifecycleAction(param: AutoScaling.CompleteLifecycleActionParams, callback: (err: AwsError, data: any) => void): void;
createAutoScalingGroup(param: AutoScaling.CreateAutoScalingGroupParams, callback: (err: AwsError, data: any) => void): void;
createLaunchConfiguration(param: AutoScaling.CreateLaunchConfigurationParams, callback: (err: AwsError, data: any) => void): void;
createOrUpdateTags(param: AutoScaling.CreateOrUpdateTagsParams, callback: (err: AwsError, data: any) => void): void;
deleteAutoScalingGroup(param: AutoScaling.DeleteAutoScalingGroupParams, callback: (err: AwsError, data: any) => void): void;
deleteLaunchConfiguration(param: AutoScaling.DeleteLaunchConfigurationParams, callback: (err: AwsError, data: any) => void): void;
deleteLifecycleHook(param: AutoScaling.DeleteLifecycleHookParams, callback: (err: AwsError, data: any) => void): void;
deleteNotificationConfiguration(param: AutoScaling.DeleteNotificationConfigurationParams, callback: (err: AwsError, data: any) => void): void;
deletePolicy(param: AutoScaling.DeletePolicyParams, callback: (err: AwsError, data: any) => void): void;
deleteScheduledAction(param: AutoScaling.DeleteScheduledActionParams, callback: (err: AwsError, data: any) => void): void;
deleteTags(param: AutoScaling.DeleteTagsParams, callback: (err: AwsError, data: any) => void): void;
describeAccountLimits(callback: (err: AwsError, data: any) => void): void;
describeAdjustmentTypes(callback: (err: AwsError, data: any) => void): void;
describeAutoScalingGroups(param: AutoScaling.DescribeAutoScalingGroupsParams, callback: (err: AwsError, data: any) => void): void;
describeAutoScalingInstances(param: AutoScaling.DescribeAutoScalingInstancesParams, callback: (err: AwsError, data: any) => void): void;
describeAutoScalingNotificationTypes(callback: (err: AwsError, data: any) => void): void;
describeLaunchConfigurations(param: AutoScaling.DescribeLaunchConfigurationsParams, callback: (err: AwsError, data: any) => void): void;
describeLifecycleHooks(param: AutoScaling.DescribeLifecycleHooksParams, callback: (err: AwsError, data: any) => void): void;
describeLifecycleHookTypes(callback: (err: AwsError, data: any) => void): void;
describeLoadBalancers(param: AutoScaling.DescribeLoadBalancersParams, callback: (err: AwsError, data: any) => void): void;
describeLoadBalancerTargetGroups(param: AutoScaling.DescribeLoadBalancerTargetGroupsParams, callback: (err: AwsError, data: any) => void): void;
describeMetricCollectionTypes(callback: (err: AwsError, data: any) => void): void;
describeNotificationConfigurations(param: AutoScaling.DescribeNotificationConfigurationsParams, callback: (err: AwsError, data: any) => void): void;
describePolicies(param: AutoScaling.DescribePoliciesParams, callback: (err: AwsError, data: any) => void): void;
describeScalingActivities(param: AutoScaling.DescribeScalingActivitiesParams, callback: (err: AwsError, data: any) => void): void;
describeScalingProcessTypes(callback: (err: AwsError, data: any) => void): void;
describeScheduledActions(param: AutoScaling.DescribeScheduledActionsParams, callback: (err: AwsError, data: any) => void): void;
describeTags(param: AutoScaling.DescribeTagsParams, callback: (err: AwsError, data: any) => void): void;
describeTerminationPolicyTypes(callback: (err: AwsError, data: any) => void): void;
detachInstances(param: AutoScaling.DetachInstancesParams, callback: (err: AwsError, data: any) => void): void;
detachLoadBalancers(param: AutoScaling.DetachLoadBalancersParams, callback: (err: AwsError, data: any) => void): void;
detachLoadBalancerTargetGroups(param: AutoScaling.DetachLoadBalancerTargetGroupsParams, callback: (err: AwsError, data: any) => void): void;
disableMetricsCollection(param: AutoScaling.DisableMetricsCollectionParams, callback: (err: AwsError, data: any) => void): void;
enableMetricsCollection(param: AutoScaling.EnableMetricsCollectionParams, callback: (err: AwsError, data: any) => void): void;
enterStandby(param: AutoScaling.EnterStandbyParams, callback: (err: AwsError, data: any) => void): void;
executePolicy(param: AutoScaling.ExecutePolicyParams, callback: (err: AwsError, data: any) => void): void;
exitStandby(param: AutoScaling.ExitStandbyParams, callback: (err: AwsError, data: any) => void): void;
putLifecycleHook(param: AutoScaling.PutLifecycleHookParams, callback: (err: AwsError, data: any) => void): void;
putNotificationConfiguration(param: AutoScaling.PutNotificationConfigurationParams, callback: (err: AwsError, data: any) => void): void;
putScalingPolicy(param: AutoScaling.PutScalingPolicyParams, callback: (err: AwsError, data: any) => void): void;
putScheduledUpdateGroupAction(param: AutoScaling.PutScheduledUpdateGroupActionParams, callback: (err: AwsError, data: any) => void): void;
recordLifecycleActionHeartbeat(params: AutoScaling.RecordLifecycleActionHeartbeatParams, callback: (err: AwsError, data: any) => void): void;
resumeProcesses(params: AutoScaling.ResumeProcessesParams, callback: (err: AwsError, data: any) => void): void;
setDesiredCapacity(params: AutoScaling.SetDesiredCapacityParams, callback: (err: AwsError, data: any) => void): void;
setInstanceHealth(params: AutoScaling.SetInstanceHealthParams, callback: (err: AwsError, data: any) => void): void;
setInstanceProtection(params: AutoScaling.SetInstanceProtectionParams, callback: (err: AwsError, data: any) => void): void;
suspendProcesses(params: AutoScaling.SuspendProcessesParams, callback: (err: AwsError, data: any) => void): void;
terminateInstanceInAutoScalingGroup(params: AutoScaling.TerminateInstanceInAutoScalingGroupParams, callback: (err: AwsError, data: any) => void): void;
updateAutoScalingGroup(params: AutoScaling.UpdateAutoScalingGroupParams, callback: (err: AwsError, data: any) => void): void;
}
export class SQS {
constructor(options?: any);
endpoint: Endpoint;
@@ -429,6 +563,214 @@ declare module "aws-sdk" {
// ===========================================================
export module CloudFormation {
export interface CancelUpdateStackParams {
StackName: string;
}
export interface ContinueUpdateRollbackParams {
StackName: string;
}
export interface CreateChangeSetParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL
TemplateURL?: string; // specify either TemplateBody or TemplateURL
UsePreviousTemplate?: boolean;
Parameters?: CloudFormation.Parameter[];
Capabilities?: string[]; // CAPABILITY_IAM | CAPABILITY_NAMED_IAM
ResourceTypes?: string[];
NotificationARNs?: string[];
Tags?: CloudFormation.Tag[];
ChangeSetName: string;
ClientToken?: string;
Description?: string;
}
export interface CreateStackParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL
TemplateURL?: string; // specify either TemplateBody or TemplateURL
Parameters?: CloudFormation.Parameter[];
DisableRollback?: boolean; // cannot specify both DisableRollback and OnFailure
TimeoutInMinutes?: number;
NotificationARNs?: string[];
Capabilities?: string[];
ResourceTypes?: string[];
OnFailure?: string[]; // cannot specify both DisableRollback and OnFailure
// DO_NOTHING | ROLLBACK | DELETE
StackPolicyBody?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
Tags?: CloudFormation.Tag[];
}
export interface DeleteChangeSetParams {
ChangeSetName: string;
StackName?: string;
}
export interface DeleteStackParams {
StackName: string;
RetainResources?: string[];
}
export interface DescribeAccountLimitsParams {
NextToken?: string;
}
export interface DescribeChangeSetParams {
ChangeSetName: string;
StackName?: string;
NextToken?: string;
}
export interface DescribeStackEventsParams {
StackName?: string;
NextToken?: string;
}
export interface DescribeStackResourceParams {
StackName: string;
LogicalResourceId: string;
}
export interface DescribeStackResourcesParams {
StackName?: string; // must specify either StackName or PhysicalResourceId
LogicalResourceId?: string;
PhysicalResourceId?: string; // must specify either StackName or PhysicalResourceId
}
export interface DescribeStacksParams {
StackName?: string;
NextToken?: string;
}
export interface EstimateTemplateCostParams {
TemplateBody?: string; // must specify either TemplateBody or TemplateURL
// if both are passed, only TemplateBody is used
TemplateURL?: string; // must specify either TemplateBody or TemplateURL
Parameters?: CloudFormation.Parameter[];
}
export interface ExecuteChangeSetParams {
ChangeSetName: string;
StackName?: string;
}
export interface GetStackPolicyParams {
StackName: string;
}
export interface GetTemplateParams {
StackName: string;
}
export interface GetTemplateSummaryParams {
// must specify one of the three
TemplateBody?: string;
TemplateURL?: string;
StackName?: string;
}
export interface ListChangeSetsParams {
StackName: string;
NextToken?: string;
}
export interface ListStackResourcesParams {
StackName: string;
NextToken?: string;
}
export interface ListStacksParams {
NextToken?: string;
StackStatusFilter?: string[];
}
export interface SetStackPolicyParams {
StackName: string;
StackPolicyBody?: string; // cannot set both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string; // cannot set both StackPolicyBody and StackPolicyURL
}
export interface SignalResourceParams {
StackName: string;
LogicalResourceId: string;
UniqueId: string;
Status: string; // SUCCESS | FAILURE
}
export interface UpdateStackParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL, not both
TemplateURL?: string; // specify either TemplateBody or TemplateURL, not both
UsePreviousTemplate?: boolean;
StackPolicyDuringUpdateBody?: string; // cannot set both StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL
StackPolicyDuringUpdateURL?: string; // cannot set both StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL
Parameters?: CloudFormation.Parameter[];
Capabilities?: string[]; // CAPABILITY_IAM | CAPABILITY_NAMED_IAM
ResourceTypes?: string[];
StackPolicyBody?: string; // cannot set both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string; // cannot set both StackPolicyBody and StackPolicyURL
NotificationARNs?: string[];
Tags?: CloudFormation.Tag[];
}
export interface ValidateTemplateParams {
TemplateBody?: string; // must pass either TemplateBody or TemplateURL
// if both are specified, only TemplateBody is used
TemplateURL?: string; // must pass either TemplateBody or TemplateURL
}
export interface WaitForParams {
StackName: string;
NextToken?: string;
}
export interface Options {
params?: any;
endpoint?: string;
accessKeyId?: string;
secretAccessKey?: string;
sessionToken?: any;
credentials?: any;
credentialProvider?: any;
region?: string;
maxRetries?: number;
maxRedirects?: number;
sslEnabled?: boolean;
paramValidation?: any;
computeChecksums?: boolean;
convertResponseTypes?: boolean;
correctClockSkew?: boolean;
s3ForcePathStyle?: boolean;
s3BucketEndpoint?: boolean;
s3DisableBodySigning?: boolean;
retryDelayOptions?: any;
httpOptions?: any;
apiVersion?: any;
apiVersions?: any;
logger?: any;
systemClockOffset?: number;
signatureVersion?: string;
signatureCache?: boolean;
}
export interface Parameter {
ParameterKey: string;
ParameterValue: string;
UsePreviousValue?: boolean; // if you specify true, do not specify ParameterValue
}
export interface Tag {
Key: string;
Value: string;
}
}
// ===========================================================
export module Lambda {
export interface AddPermissionParams {
@@ -598,6 +940,355 @@ declare module "aws-sdk" {
}
}
export module AutoScaling {
export interface AutoScalingOptions {
params?: any;
endpoint?: string;
accessKeyId?: string;
secretAccessKey?: string;
sessionToken?: Credentials;
credentials?: Credentials;
credentialProvider?: any;
region?: string;
maxRetries?: number;
maxRedirects?: number;
sslEnabled?: boolean;
paramValidation?: boolean;
computeChecksums?: boolean;
convertResponseTypes?: boolean;
correctClockSkew?: boolean;
s3ForcePathStyle?: boolean;
s3BucketEndpoint?: boolean;
s3DisableBodySigning?: boolean;
retryDelayOptions?: RetryDelayOption;
httpOptions?: HttpOptions;
apiVersion?: string;
apiVersions?: { [serviceName: string]: string };
logger?: Logger;
systemClockOffset?: number;
signatureVersion?: string;
signatureCache?: boolean;
}
export interface AttachInstancesParams {
AutoScalingGroupName: string;
InstanceIds: string[];
}
export interface AttachLoadBalancersParams {
AutoScalingGroupName: string;
LoadBalancerNames: string[];
}
export interface AttachLoadBalancerTargetGroupsParams {
AutoScalingGroupName: string;
TargetGroupARNs: string[];
}
export interface CompleteLifecycleActionParams {
AutoScalingGroupName: string;
LifecycleActionResult: string;
LifecycleHookName: string;
lifecycleActionToken?: string;
InstanceId?: string;
}
export interface CreateAutoScalingGroupParams {
AutoScalingGroupName: string;
MinSize: number;
MaxSize: number;
LaunchConfigurationName?: string;
InstanceId?: string;
DesiredCapacity?: number;
DefaultCooldown?: number;
AvailabilityZones?: string[];
LoadBalancerNames?: string[];
TargetGroupARNs?: string[];
HealthCheckType?: string;
HealthCheckGracePeriod?: number;
PlacementGroup?: string;
VPCZoneIdentifier?: string;
TerminationPolicies?: string;
NewInstancesProtectedFromScaleIn?: boolean;
Tags?: Tags;
}
export interface CreateLaunchConfigurationParams {
LaunchConfigurationName: string;
AssociatePublicIpAddress?: boolean;
ImageId?: string;
KeyName?: string;
SecurityGroups?: string[];
ClassicLinkVPCId?: string;
ClassicLinkVPCSecurityGroups?: string[];
UserData?: string;
InstanceId?: string;
InstanceType?: string;
KernelId?: string;
RamdiskId?: string;
BlockDeviceMappings?: BlockDeviceMapping[];
InstanceMonitoring?: InstanceMonitoring;
SpotPrice?: string;
IamInstanceProfile?: string;
EbsOptimized?: boolean;
PlacementTenancy?: string;
}
export interface CreateOrUpdateTagsParams {
Tags: Tags[];
}
export interface DeleteAutoScalingGroupParams {
AutoScalingGroupName: string;
ForceDelete?: boolean;
}
export interface DeleteLaunchConfigurationParams {
LaunchConfigurationName: string;
}
export interface DeleteLifecycleHookParams {
AutoScalingGroupName: string;
LifecycleHookName: string;
}
export interface DeleteNotificationConfigurationParams {
AutoScalingGroupName: string;
TopicARN: string;
}
export interface DeletePolicyParams {
PolicyName: string;
AutoScalingGroupName?: string;
}
export interface DeleteScheduledActionParams {
AutoScalingGroupName: string;
ScheduledActionName: string;
}
export interface DeleteTagsParams {
Tags: Tags[];
}
export interface DescribeAutoScalingGroupsParams {
AutoScalingGroupName?: string;
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeAutoScalingInstancesParams {
InstanceIds?: string[];
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeLaunchConfigurationsParams {
LaunchConfigurationNames?: string[];
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeLifecycleHooksParams {
AutoScalingGroupName: string;
LifecycleHookNames?: string[];
}
export interface DescribeLoadBalancersParams {
AutoScalingGroupName: string;
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeLoadBalancerTargetGroupsParams {
AutoScalingGroupName: string;
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeNotificationConfigurationsParams {
AutoScalingGroupName?: string;
NextToken?: string;
MaxRecords?: number;
}
export interface DescribePoliciesParams {
AutoScalingGroupName?: string;
PolicyNames?: string[];
PolicyTypes?: string[];
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeScalingActivitiesParams {
AutoScalingGroupName?: string;
ActivityIds?: string[];
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeScheduledActionsParams {
AutoScalingGroupName?: string;
ScheduledActionNames?: string[];
StartTime?: Date;
EndTime?: Date;
NextToken?: string;
MaxRecords?: number;
}
export interface DescribeTagsParams {
Filters?: Filter[];
NextToken?: string;
MaxRecords?: number;
}
export interface DetachInstancesParams {
AutoScalingGroupName: string;
ShouldDecrementDesiredCapacity: boolean;
InstanceIds?: string[];
}
export interface DetachLoadBalancersParams {
AutoScalingGroupName: string;
LoadBalancerNames: string;
}
export interface DetachLoadBalancerTargetGroupsParams {
AutoScalingGroupName: string;
TargetGroupARNs: string[];
}
export interface DisableMetricsCollectionParams {
AutoScalingGroupName: string;
Metrics?: string[];
}
export interface EnableMetricsCollectionParams {
AutoScalingGroupName: string;
Granularity: string;
Metrics?: string[];
}
export interface EnterStandbyParams {
AutoScalingGroupName: string;
ShouldDecrementDesiredCapacity: boolean;
InstanceIds?: string[];
}
export interface ExecutePolicyParams {
PolicyName: string;
AutoScalingGroupName?: string;
HonorCooldown?: boolean;
MetricValue?: number;
BreachThreshold?: number;
}
export interface ExitStandbyParams {
AutoScalingGroupName: string;
InstanceIds?: string[];
}
export interface PutLifecycleHookParams {
AutoScalingGroupName: string;
LifecycleHookName: string;
LifecycleTransition?: string;
RoleARN?: string;
NotificationTargetARN?: string;
NotificationMetadata?: string;
HeartbeatTimeout?: number;
DefaultResult?: string;
}
export interface PutNotificationConfigurationParams {
AutoScalingGroupName: string;
NotificationTypes: string[];
TopicARN: string;
}
export interface PutScalingPolicyParams {
AutoScalingGroupName: string;
AdjustmentType: string;
PolicyName: string;
PolicyType?: string;
MinAdjustmentStep?: number;
MinAdjustmentMagnitude?: number;
ScalingAdjustment?: number;
Cooldown?: number;
MetricAggregationType?: string;
StepAdjustments?: StepAdjustment[];
EstimatedInstanceWarmup: number;
}
export interface PutScheduledUpdateGroupActionParams {
AutoScalingGroupName: string;
ScheduledActionName: string;
Time?: Date;
StartTime?: Date;
EndTime?: Date;
Recurrence?: string;
MinSize?: number;
MaxSize?: number;
DesiredCapacity?: number;
}
export interface RecordLifecycleActionHeartbeatParams {
AutoScalingGroupName: string;
LifecycleHookName: string;
LifecycleActionToken?: string;
InstanceId?: string;
}
export interface ResumeProcessesParams {
AutoScalingGroupName: string;
ScalingProcesses?: string[];
}
export interface SetDesiredCapacityParams {
AutoScalingGroupName: string;
DesiredCapacity: number;
HonorCooldown?: boolean;
}
export interface SetInstanceHealthParams {
HealthStatus: string;
InstanceId: string;
ShouldRespectGracePeriod?: boolean;
}
export interface SetInstanceProtectionParams {
AutoScalingGroupName: string;
InstanceIds: string[];
ProtectedFromScaleIn: boolean;
}
export interface SuspendProcessesParams {
AutoScalingGroupName: string;
ScalingProcesses?: string[];
}
export interface TerminateInstanceInAutoScalingGroupParams {
InstanceId: string;
ShouldDecrementDesiredCapacity: boolean;
}
export interface UpdateAutoScalingGroupParams {
AutoScalingGroupName: string;
LaunchConfigurationName: string;
MinSize: number;
MaxSize: number;
DesiredCapacity: number;
DefaultCooldown: number;
AvailabilityZones: string[];
HealthCheckType: string;
HealthCheckGracePeriod: number;
PlacementGroup: string;
VPCZoneIdentifier: string;
TerminationPolicies: string[];
NewInstancesProtectedFromScaleIn?: boolean;
}
}
export module SQS {
export interface SqsOptions {

View File

@@ -8,7 +8,7 @@ import queries = require('azure-mobile-apps/src/query');
var app = express(),
mobileApp = mobileApps();
// various configuration permutations
// various configuration permutations
mobileApps({
debug: true,
data: {
@@ -17,7 +17,8 @@ mobileApps({
user: '',
database: '',
password: ''
}
},
webhook: { url: 'http://localhost/' }
});
mobileApps({
@@ -29,7 +30,7 @@ mobileApps({
// it would be nice to integrate with winston
mobileApps({ logging: { level: 'silly', transports: [{}] } })
// various custom middleware syntaxes
// various custom middleware syntaxes
mobileApp.use(function (req: any, res: any, next: any) { next(); });
mobileApp.use([function () {}, function () {}]);
mobileApp.use(function () {}, function () {});
@@ -43,6 +44,9 @@ mobileApp.tables.import('tables');
mobileApp.api.add('api', { authorize: true, get: function () {}, delete: function () {} });
mobileApp.api.import('api');
// ensure the mobile app instance can be correctly mounted as an express router
app.use(mobileApp);
// Express.Table, instantiated from the mobile app
var table = mobileApp.table()
table.use(function (req: Express.Request, res: Express.Response, next: any) {
@@ -61,16 +65,18 @@ table.read(function (context: Azure.MobileApps.Context) {
table.insert(function (context: Azure.MobileApps.Context) {
context.query.id = 'anotherId';
context.query.single = true;
context.item.userId = context.user.id;
context.item.userId = context.user.id;
context.push.send('tag', {}, function (error, result) {});
context.push.gcm.send('tag', {}, function (error, result) {});
context.push.apns.send('tag', { payload: { } }, function (error, result) {});
context.push.wns.sendToastText01('tag', '', { headers: { } }, function (error, result) {});
context.next(new Error());
context.next('An error occurred');
});
table.read.use(function () {});
table.read.use([function () {}, function () {}]);
table.read.use(function () {}, function () {});
table.use(function () {}).use(function () {}).read(function () {}).use(function () {})
table.use(function () {}).use(function () {}).read(function () {}).use(function () {});
table.access = undefined;
table.access = 'authenticated';
@@ -79,10 +85,25 @@ table.update.access = 'disabled';
table.delete.access = 'authenticated';
table.insert.access = 'authenticated';
table.filters = [function (query, context) { }];
table.transforms = [function (item, context) { }];
table.hooks = [function (results, context) { }];
table.perUser = true;
table.recordsExpire = { milliseconds: 1, seconds: 1, minutes: 1, hours: 1, days: 1, weeks: 1, months: 1, years: 1 };
table.webhook = { url: 'http://localhost/' }
table.webhook = true;
// Express.Table, instantiated from the static require('azure-mobile-apps').table()
// This is going to be interesting if we ever support more than one provider
var table2 = mobileApps.table();
table2.read(function (context: Azure.MobileApps.Context) {})
table2.read(function (context: Azure.MobileApps.Context) {});
// ApiDefinition, from the static require('azure-mobile-apps').api()
var api2 = mobileApps.api({
get: function (req, res, next) { }
});
api2.post = function (req, res, next) {};
// Logger
logger.silly('test', 'message');
@@ -90,10 +111,10 @@ logger.error('Something happened', new Error());
mobileApps.logger.debug('a debug message')
// Query
queries.create('table').where({ x: 10 }).select('col1,col2');
queries.create('table').where({ x: 10 }).select('col1,col2').includeDeleted().includeTotalCount();
mobileApps.query.create('table');
// custom sql query
// Custom SQL query
mobileApp.api.add('query', { authorize: true, get: (req, res, next) => {
req.azureMobile.data.execute({
sql: "SELECT * FROM TODOITEM WHERE COMPLETE = :complete",
@@ -101,4 +122,4 @@ mobileApp.api.add('query', { authorize: true, get: (req, res, next) => {
{ name: 'complete', value: 1 }
]
}).then(x => {});
}, delete: function () {} });
}, delete: function () {} });

View File

@@ -1,4 +1,4 @@
// Type definitions for azure-mobile-apps v2.0.0-beta3
// Type definitions for azure-mobile-apps v2.1.7
// Project: https://github.com/Azure/azure-mobile-apps-node/
// Definitions by: Microsoft Azure <https://github.com/Azure/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -10,6 +10,7 @@ declare module "azure-mobile-apps" {
interface AzureMobileApps {
(configuration?: Azure.MobileApps.Configuration): Azure.MobileApps.Platforms.Express.MobileApp;
table(): Azure.MobileApps.Platforms.Express.Table;
api(definition?: Azure.MobileApps.ApiDefinition): Azure.MobileApps.ApiDefinition;
logger: Azure.MobileApps.Logger;
query: Azure.MobileApps.Query;
}
@@ -31,7 +32,7 @@ declare namespace Azure.MobileApps {
// the additional Platforms namespace is required to avoid collisions with the main Express namespace
export module Platforms {
export module Express {
interface MobileApp {
interface MobileApp extends Middleware {
configuration: Configuration;
tables: Tables;
table(): Table;
@@ -45,15 +46,7 @@ declare namespace Azure.MobileApps {
import(fileOrFolder: string): void;
}
interface Table {
authorize?: boolean;
access?: AccessType;
autoIncrement?: boolean;
dynamicSchema?: boolean;
name: string;
columns?: any;
schema: string;
interface Table extends TableDefinition {
use(...middleware: Middleware[]): Table;
use(middleware: Middleware[]): Table;
read: TableOperation;
@@ -67,11 +60,9 @@ declare namespace Azure.MobileApps {
(operationHandler: (context: Context) => void): Table;
use(...middleware: Middleware[]): Table;
use(middleware: Middleware[]): Table;
access: AccessType;
access?: AccessType;
}
type AccessType = 'anonymous' | 'authenticated' | 'disabled';
interface Tables {
configuration: Configuration;
add(name: string, definition?: Table | TableDefinition): void;
@@ -136,6 +127,7 @@ declare namespace Azure.MobileApps {
auth?: Configuration.Auth;
cors?: Configuration.Cors;
notifications?: Configuration.Notifications;
webhook?: Webhook;
}
export module Configuration {
@@ -152,6 +144,7 @@ declare namespace Azure.MobileApps {
options?: { encrypt: boolean };
schema?: string;
dynamicSchema?: boolean;
filename?: string;
}
interface Auth {
@@ -167,8 +160,9 @@ declare namespace Azure.MobileApps {
interface LoggingTransport { }
interface Cors {
exposeHeaders: string;
maxAge?: number;
origins: string[];
hostnames: string[];
}
interface Notifications {
@@ -188,7 +182,8 @@ declare namespace Azure.MobileApps {
}
interface QueryJs {
includeTotalCount?: boolean;
includeTotalCount(): QueryJs;
includeDeleted(): QueryJs;
orderBy(properties: string): QueryJs;
orderByDescending(properties: string): QueryJs;
select(properties: string): QueryJs;
@@ -213,6 +208,7 @@ declare namespace Azure.MobileApps {
// general
var nh: Azure.ServiceBus.NotificationHubService;
interface Context {
query: QueryJs;
id: string | number;
@@ -225,6 +221,7 @@ declare namespace Azure.MobileApps {
push: typeof nh;
logger: Logger;
execute(): Thenable<any>;
next(error: string|Error): any;
}
interface ContextData {
@@ -240,15 +237,46 @@ declare namespace Azure.MobileApps {
interface SqlParameterDefinition {
name: string;
value: any;
}
}
interface TableDefinition {
access?: AccessType;
authorize?: boolean;
autoIncrement?: boolean;
dynamicSchema?: boolean;
name?: string;
columns?: any;
databaseTableName?: string;
dynamicSchema?: boolean;
maxTop?: number;
name?: string;
pageSize?: number;
schema?: string;
softDelete?: boolean;
userIdColumn?: string;
filters?: [(query: QueryJs, context: Context) => void | QueryJs];
transforms?: [(item: any, context: Context) => void | any];
hooks?: [(results: any, context: Context) => void];
perUser?: boolean;
recordsExpire?: Duration;
webhook?: Webhook | boolean;
}
type AccessType = 'anonymous' | 'authenticated' | 'disabled';
interface Duration {
milliseconds?: number;
seconds?: number;
minutes?: number;
hours?: number;
days?: number;
weeks?: number;
months?: number;
years?: number;
}
interface Webhook {
url: string;
}
interface ApiDefinition {

24
base16/base16-tests.ts Normal file
View File

@@ -0,0 +1,24 @@
/// <reference path="./base16.d.ts" />
import * as base16 from 'base16';
const colorScheme: base16.ColorScheme = base16.solarized
const scheme: string = colorScheme.scheme
const author: string = colorScheme.author
const base00: string = colorScheme.base00
const base01: string = colorScheme.base01
const base02: string = colorScheme.base02
const base03: string = colorScheme.base03
const base04: string = colorScheme.base04
const base05: string = colorScheme.base05
const base06: string = colorScheme.base06
const base07: string = colorScheme.base07
const base08: string = colorScheme.base08
const base09: string = colorScheme.base09
const base0A: string = colorScheme.base0A
const base0B: string = colorScheme.base0B
const base0C: string = colorScheme.base0C
const base0D: string = colorScheme.base0D
const base0E: string = colorScheme.base0E
const base0F: string = colorScheme.base0F

70
base16/base16.d.ts vendored Normal file
View File

@@ -0,0 +1,70 @@
// Type definitions for base16-js 1.0.0
// Project: https://github.com/gaearon/base16-js
// Definitions by: Alec Hill <https://github.com/alechill>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'base16' {
/**
* Type describing a syntax highlighting scheme as a JS object, as used in redux dev tools
* Based on https://github.com/chriskempson/base16
*/
export interface ColorScheme {
scheme: string
author: string
base00: string
base01: string
base02: string
base03: string
base04: string
base05: string
base06: string
base07: string
base08: string
base09: string
base0A: string
base0B: string
base0C: string
base0D: string
base0E: string
base0F: string
}
// predefined schemes...
export var threezerotwofour: ColorScheme
export var apathy: ColorScheme
export var ashes: ColorScheme
export var atelierDune: ColorScheme
export var atelierForest: ColorScheme
export var atelierHeath: ColorScheme
export var atelierLakeside: ColorScheme
export var atelierSeaside: ColorScheme
export var bespin: ColorScheme
export var brewer: ColorScheme
export var bright: ColorScheme
export var chalk: ColorScheme
export var codeschool: ColorScheme
export var colors: ColorScheme
export var eighties: ColorScheme
export var embers: ColorScheme
export var flat: ColorScheme
export var google: ColorScheme
export var grayscale: ColorScheme
export var greenscreen: ColorScheme
export var harmonic: ColorScheme
export var hopscotch: ColorScheme
export var isotope: ColorScheme
export var marrakesh: ColorScheme
export var monokai: ColorScheme
export var ocean: ColorScheme
export var paraiso: ColorScheme
export var pop: ColorScheme
export var railscasts: ColorScheme
export var shapeshifter: ColorScheme
export var solarized: ColorScheme
export var summerfruit: ColorScheme
export var tomorrow: ColorScheme
export var tube: ColorScheme
export var twilight: ColorScheme
}

2
c3/c3.d.ts vendored
View File

@@ -681,7 +681,7 @@ declare namespace c3 {
* Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
* If undefined returned, the row of that value will be skipped.
*/
value?: (name: string, ratio: number, id: string, index: number) => string;
value?: (value: any, ratio: number, id: string, index: number) => string;
};
/**
* Set custom position for the tooltip. This option can be used to modify the tooltip position by returning object that has top and left.

View File

@@ -0,0 +1,124 @@
/// <reference path="change-emitter.d.ts"/>
import { createChangeEmitter, ChangeEmitterOf0 } from "change-emitter";
function usage() {
// https://github.com/acdlite/change-emitter#usage
const emitter = createChangeEmitter()
// Called `listen` instead of `subscribe` to avoid confusion with observable spec
const unlisten = emitter.listen((...args) => {
console.log(args)
})
emitter.emit(1, 2, 3) // logs `[1, 2, 3]`
unlisten()
emitter.emit(4, 5, 6) // doesn't log
}
function largerExample() {
// https://github.com/acdlite/change-emitter#larger-example
const createStore = (reducer: Function, initialState: any) => {
let state = initialState
const emitter = createChangeEmitter()
function dispatch(action: any) {
state = reducer(state, action)
emitter.emit()
return action
}
function getState() {
return state
}
return {
dispatch,
getState,
subscribe: emitter.listen
}
}
}
function untypedEmitter() {
const { emit, listen } = createChangeEmitter();
const unlisten0 = listen(() => {/* do something */});
const unlisten1 = listen(value => {/* do something with value */});
const unlisten2 = listen((value1, value2) => {/* do something with values */});
const unlistenArgs = listen((...args: any[]) => {/* do something with values */});
emit();
emit("hello");
emit("hello", "world");
emit(1, 2, 3, 4, 5);
unlisten0();
unlisten1();
unlisten2();
unlistenArgs();
}
function emitterOf0Args() {
const { emit, listen }: ChangeEmitterOf0 = createChangeEmitter();
const unlisten = listen(() => { });
// const unlisten = listen(value => {}); // SYNTAX ERROR
emit();
// emit("hello"); // SYNTAX ERROR
unlisten();
}
function emitterOf1Args() {
const { emit, listen } = createChangeEmitter<string>();
const unlisten = listen(value => { value.length });
emit("hello");
unlisten();
}
function emitterOf2Args() {
const { emit, listen } = createChangeEmitter<string, boolean>();
const unlisten = listen((value, success) => { value.length > 0 === success });
emit("hello", true);
unlisten();
}
function emitterOf3Args() {
const { emit, listen } = createChangeEmitter<string, boolean, number>();
const unlisten = listen((value, success, count) => { value.length > count === success });
emit("hello", true, 3);
unlisten();
}
function emitterOf4Args() {
const { emit, listen } = createChangeEmitter<string, boolean, number, Date>();
const unlisten = listen((v1, v2, v3, v4) => { });
emit("hello", true, 3, new Date());
unlisten();
}
function emitterOf5Args() {
const { emit, listen } = createChangeEmitter<string, boolean, number, Date, string>();
const unlisten = listen((v1, v2, v3, v4, v5) => { });
emit("hello", true, 3, new Date(), "world");
unlisten();
}

58
change-emitter/change-emitter.d.ts vendored Normal file
View File

@@ -0,0 +1,58 @@
// Type definitions for change-emitter v0.1.2
// Project: https://github.com/acdlite/change-emitter
// Definitions by: Iskander Sierra <https://github.com/iskandersierra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'change-emitter' {
type Unlisten = () => void;
type Listener = (...args: any[]) => void;
type ListenerOf0 = () => void;
type ListenerOf1<T> = (value: T) => void;
type ListenerOf2<T1, T2> = (value1: T1, value2: T2) => void;
type ListenerOf3<T1, T2, T3> = (value1: T1, value2: T2, value3: T3) => void;
type ListenerOf4<T1, T2, T3, T4> = (value1: T1, value2: T2, value3: T3, value4: T4) => void;
type ListenerOf5<T1, T2, T3, T4, T5> = (value1: T1, value2: T2, value3: T3, value4: T4, value5: T5) => void;
interface ChangeEmitter {
listen(listener: Listener): Unlisten;
emit(...args: any[]): void;
}
interface ChangeEmitterOf1<T> {
listen(listener: ListenerOf1<T>): Unlisten;
emit(value: T): void;
}
interface ChangeEmitterOf0 {
listen(listener: ListenerOf0): Unlisten;
emit(): void;
}
interface ChangeEmitterOf2<T1, T2> {
listen(listener: ListenerOf2<T1, T2>): Unlisten;
emit(value1: T1, value2: T2): void;
}
interface ChangeEmitterOf3<T1, T2, T3> {
listen(listener: ListenerOf3<T1, T2, T3>): Unlisten;
emit(value1: T1, value2: T2, value3: T3): void;
}
interface ChangeEmitterOf4<T1, T2, T3, T4> {
listen(listener: ListenerOf4<T1, T2, T3, T4>): Unlisten;
emit(value1: T1, value2: T2, value3: T3, value4: T4): void;
}
interface ChangeEmitterOf5<T1, T2, T3, T4, T5> {
listen(listener: ListenerOf5<T1, T2, T3, T4, T5>): Unlisten;
emit(value1: T1, value2: T2, value3: T3, value4: T4, value5: T5): void;
}
export function createChangeEmitter(): ChangeEmitter;
export function createChangeEmitter<T>(): ChangeEmitterOf1<T>;
export function createChangeEmitter<T1, T2>(): ChangeEmitterOf2<T1, T2>;
export function createChangeEmitter<T1, T2, T3>(): ChangeEmitterOf3<T1, T2, T3>;
export function createChangeEmitter<T1, T2, T3, T4>(): ChangeEmitterOf4<T1, T2, T3, T4>;
export function createChangeEmitter<T1, T2, T3, T4, T5>(): ChangeEmitterOf5<T1, T2, T3, T4, T5>;
}

View File

@@ -0,0 +1,5 @@
/// <reference path="./concaveman.d.ts" />
import * as concaveman from 'concaveman';
var points = [[10, 20], [30, 12.5]];
var polygon = concaveman(points);

24
concaveman/concaveman.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for concaveman 1.1.0
// Project: https://github.com/mapbox/concaveman
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "concaveman" {
/**
* A very fast 2D concave hull algorithm in JavaScript (generates a general outline of a point set).
*
* @name concaveman
* @param {Array<Array<number>>} points is an array of [x, y] points.
* @param {number} [concavity=2] is a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes.
* @param {number} [lengthThreshold=0] when a segment length is under this threshold, it stops being considered for further detalization. Higher values result in simpler shapes.
* @return {Array<Array<number>>}
* @example
* var points = [[10, 20], [30, 12.5], ...];
* var polygon = concaveman(points);
*
* //=hull
*/
function concaveman(points: number[][], concavity?: number, lengthThreshold?: number): number[][];
namespace concaveman {}
export = concaveman;
}

View File

@@ -95,8 +95,8 @@ interface DropzoneOptions {
uploadprogress?(file:DropzoneFile, progress:number, bytesSent:number):void;
totaluploadprogress?(totalProgress:number, totalBytes:number, totalBytesSent:number):void;
sending?(file:DropzoneFile, xhr:XMLHttpRequest, formData:{}):void;
sendingmultiple?(files:DropzoneFile[], xhr:XMLHttpRequest, formData:{}):void;
sending?(file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData):void;
sendingmultiple?(files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):void;
success?(file: DropzoneFile, response: Object|string): void;
successmultiple?(files:DropzoneFile[], responseText:string):void;
@@ -206,8 +206,8 @@ declare class Dropzone {
on(eventName:"uploadprogress", callback:(file:DropzoneFile, progress:number, bytesSent:number) => any):void;
on(eventName:"totaluploadprogress", callback:(totalProgress:number, totalBytes:number, totalBytesSent:number) => any):void;
on(eventName:"sending", callback:(file:DropzoneFile, xhr:XMLHttpRequest, formData:{}) => any):void;
on(eventName:"sendingmultiple", callback:(files:DropzoneFile[], xhr:XMLHttpRequest, formData:{}) => any):void;
on(eventName:"sending", callback:(file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData) => any):void;
on(eventName:"sendingmultiple", callback:(files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData) => any):void;
on(eventName:"success", callback:(file:DropzoneFile) => any):void;
on(eventName:"successmultiple", callback:(files:DropzoneFile[]) => any):void;
@@ -246,8 +246,8 @@ declare class Dropzone {
emit(eventName:"uploadprogress", file:DropzoneFile, progress:number, bytesSent:number):void;
emit(eventName:"totaluploadprogress", totalProgress:number, totalBytes:number, totalBytesSent:number):void;
emit(eventName:"sending", file:DropzoneFile, xhr:XMLHttpRequest, formData:{}):void;
emit(eventName:"sendingmultiple", files:DropzoneFile[], xhr:XMLHttpRequest, formData:{}):void;
emit(eventName:"sending", file:DropzoneFile, xhr:XMLHttpRequest, formData:FormData):void;
emit(eventName:"sendingmultiple", files:DropzoneFile[], xhr:XMLHttpRequest, formData:FormData):void;
emit(eventName:"success", file:DropzoneFile):void;
emit(eventName:"successmultiple", files:DropzoneFile[]):void;

View File

@@ -690,6 +690,11 @@ declare module 'plugins/dialog' {
* @param {object} context The composition context.
*/
compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext): void;
/**
* Opacity of the blockout. The default is 0.6.
*/
blockoutOpacity?: number;
}
interface Dialog {
@@ -728,7 +733,7 @@ declare module 'plugins/dialog' {
* @param {string} [name] The name of the context to retrieve.
* @returns {DialogContext} True context.
*/
export function getContext(name: string): DialogContext;
export function getContext(name?: string): DialogContext;
/**
* Adds (or replaces) a dialog context.

View File

@@ -650,6 +650,7 @@ declare namespace createjs {
autoReset: boolean;
static buildDate: string;
currentFrame: number;
totalFrames: number;
currentLabel: string;
frameBounds: Rectangle[];
framerate: number;
@@ -662,6 +663,7 @@ declare namespace createjs {
startPosition: number;
static SYNCHED: string;
timeline: Timeline;
duration: number;
static version: string;
// methods

View File

@@ -1,6 +1,6 @@
// Type definitions for elasticsearch
// Project: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html
// Definitions by: Casper Skydt <https://github.com/CasperSkydt/DefinitelyTyped>, Blake Smith <https://github.com/bfsmith/DefinitelyTyped>
// Definitions by: Casper Skydt <https://github.com/CasperSkydt>, Blake Smith <https://github.com/bfsmith>, Dave Dunkin <https://github.com/ddunkin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module Elasticsearch {
@@ -15,14 +15,14 @@ declare module Elasticsearch {
create(params: CreateDocumentParams, callback: (err: any, response: any, status: any) => void): void;
delete(params: DeleteDocumentParams): PromiseLike<any>;
delete(params: DeleteDocumentParams, callback: (error: any, response: any) => void): void;
get(params: GetParams, callback: (error: any, response: any) => void): void;
get<T>(params: GetParams, callback: (error: any, response: GetResponse<T>) => void): void;
get<T>(params: GetParams): PromiseLike<GetResponse<T>>;
index<T>(params: IndexDocumentParams<T>): PromiseLike<any>;
index<T>(params: IndexDocumentParams<T>, callback: (error: any, response: any) => void): void;
mget(params: MGetParams, callback: (error: any, response: any) => void): void;
mget<T>(params: MGetParams): PromiseLike<GetResponse<T>>;
msearch(params: MSearchParams, callback: (error: any, response: any) => void): void;
msearch<T>(params: MSearchParams): PromiseLike<GetResponse<T>>;
mget<T>(params: MGetParams, callback: (error: any, response: MGetResponse<T>) => void): void;
mget<T>(params: MGetParams): PromiseLike<MGetResponse<T>>;
msearch<T>(params: MSearchParams, callback: (error: any, response: MSearchResponse<T>) => void): void;
msearch<T>(params: MSearchParams): PromiseLike<MSearchResponse<T>>;
ping(params: PingParams): PromiseLike<any>;
ping(params: PingParams, callback: (err: any, response: any, status: any) => void): void;
scroll(params: ScrollParams): PromiseLike<any>;
@@ -109,7 +109,7 @@ declare module Elasticsearch {
export interface CreateDocumentParams extends GenericParams {
consistency?: "one" | "quorum" | "all";
parent?: string;
refressh?: boolean;
refresh?: boolean;
routing?: string;
timeout?: number | Date;
timestamp?: number | Date;
@@ -196,7 +196,8 @@ declare module Elasticsearch {
versionType?: string;
}
export interface GetResponse<T> extends GenericParams {
export interface GetResponse<T> {
_index: string;
_type: string;
_id: string;
_version: number;
@@ -279,6 +280,10 @@ declare module Elasticsearch {
search_type?: string;
}
export interface MSearchResponse<T> {
responses?: SearchResponse<T>[];
}
export interface MGetParams extends GenericParams {
fields?: string | string[] | Boolean;
preference?: string;
@@ -290,6 +295,10 @@ declare module Elasticsearch {
type?: string;
}
export interface MGetResponse<T> {
docs?: GetResponse<T>[];
}
export interface IndicesIndexExitsParams extends GenericParams {
index: string | string[] | boolean;
ignoreUnavailable?: boolean;

1
enzyme/enzyme.d.ts vendored
View File

@@ -458,6 +458,7 @@ declare module "enzyme" {
export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
unmount(): ReactWrapper<any, any>;
mount(): ReactWrapper<any, any>;
render(): CheerioWrapper<P, S>;
/**
* Returns a wrapper of the node that matches the provided reference name.

View File

@@ -97,6 +97,10 @@ declare module "express-serve-static-core" {
use: IRouterHandler<this> & IRouterMatcher<this>;
route(prefix: PathParams): IRoute;
/**
* Stack of configured routes
*/
stack: any[];
}
interface IRoute {
@@ -1048,7 +1052,7 @@ declare module "express-serve-static-core" {
routes: any;
/**
* Using to all registered routes in Express Application
* Used to get all registered routes in Express Application
*/
_router: any;
}

View File

@@ -1,101 +1,114 @@
/// <reference path="express.d.ts" />
/// <reference path="../node/node.d.ts" />
import * as express from 'express';
var app = express();
app.engine('jade', require('jade').__express);
app.engine('html', require('ejs').renderFile);
express.static.mime.define({
'application/fx': ['fx']
});
app.use('/static', express.static(__dirname + '/public'));
// simple logger
app.use(function(req, res, next){
console.log('%s %s', req.method, req.url);
next();
});
app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
console.error(err);
next(err);
});
app.get('/', function(req, res){
res.send('hello world');
});
namespace express_tests {
const router = express.Router();
var app = express();
app.engine('jade', require('jade').__express);
app.engine('html', require('ejs').renderFile);
const pathStr : string = 'test';
const pathRE : RegExp = /test/;
const path = true? pathStr : pathRE;
express.static.mime.define({
'application/fx': ['fx']
});
app.use('/static', express.static(__dirname + '/public'));
router.get(path);
router.put(path)
router.post(path);
router.delete(path);
router.get(pathStr);
router.put(pathStr)
router.post(pathStr);
router.delete(pathStr);
router.get(pathRE);
router.put(pathRE)
router.post(pathRE);
router.delete(pathRE);
router.use((req, res, next) => { next(); })
router.route('/users')
.get((req, res, next) => {
let types: string[] = req.accepts();
let type: string | boolean = req.accepts('json');
type = req.accepts(['json', 'text']);
type = req.accepts('json', 'text');
let charsets: string[] = req.acceptsCharsets();
let charset: string | boolean = req.acceptsCharsets('utf-8');
charset = req.acceptsCharsets(['utf-8', 'utf-16']);
charset = req.acceptsCharsets('utf-8', 'utf-16');
let encodings: string[] = req.acceptsEncodings();
let encoding: string | boolean = req.acceptsEncodings('gzip');
encoding = req.acceptsEncodings(['gzip', 'deflate']);
encoding = req.acceptsEncodings('gzip', 'deflate');
let languages: string[] = req.acceptsLanguages();
let language: string | boolean = req.acceptsLanguages('en');
language = req.acceptsLanguages(['en', 'ja']);
language = req.acceptsLanguages('en', 'ja');
res.send(req.query['token']);
// simple logger
app.use(function(req, res, next) {
console.log('%s %s', req.method, req.url);
next();
});
router.get('/user/:id', function(req, res, next) {
if (req.params.id == 0) next('route');
else next();
}, function(req, res, next) {
res.render('regular');
});
app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
console.error(err);
next(err);
});
app.use((req, res, next) => {
// hacky trick, router is just a handler
router(req, res, next);
});
app.use(router);
app.get('/', function(req, res) {
res.send('hello world');
});
app.listen(3000);
const router = express.Router();
const next: express.NextFunction = () => {};
const nextWithArgument: express.NextFunction = (err: any) => {};
/**
* The express.Application is compatible with http.createServer
*/
const pathStr: string = 'test';
const pathRE: RegExp = /test/;
const path = true ? pathStr : pathRE;
router.get(path);
router.put(path)
router.post(path);
router.delete(path);
router.get(pathStr);
router.put(pathStr)
router.post(pathStr);
router.delete(pathStr);
router.get(pathRE);
router.put(pathRE)
router.post(pathRE);
router.delete(pathRE);
router.use((req, res, next) => { next(); })
router.route('/users')
.get((req, res, next) => {
let types: string[] = req.accepts();
let type: string | boolean = req.accepts('json');
type = req.accepts(['json', 'text']);
type = req.accepts('json', 'text');
let charsets: string[] = req.acceptsCharsets();
let charset: string | boolean = req.acceptsCharsets('utf-8');
charset = req.acceptsCharsets(['utf-8', 'utf-16']);
charset = req.acceptsCharsets('utf-8', 'utf-16');
let encodings: string[] = req.acceptsEncodings();
let encoding: string | boolean = req.acceptsEncodings('gzip');
encoding = req.acceptsEncodings(['gzip', 'deflate']);
encoding = req.acceptsEncodings('gzip', 'deflate');
let languages: string[] = req.acceptsLanguages();
let language: string | boolean = req.acceptsLanguages('en');
language = req.acceptsLanguages(['en', 'ja']);
language = req.acceptsLanguages('en', 'ja');
res.send(req.query['token']);
});
router.get('/user/:id', function(req, res, next) {
if (req.params.id == 0) next('route');
else next();
}, function(req, res, next) {
res.render('regular');
});
app.use((req, res, next) => {
// hacky trick, router is just a handler
router(req, res, next);
});
app.use(router);
app.listen(3000);
const next: express.NextFunction = () => { };
}
/***************************
* *
* Test with other modules *
* *
***************************/
import * as http from 'http';
http.createServer(app);
namespace node_tests {
{
// http.createServer can take express application
const app: express.Application = express();
http.createServer(app).listen(5678);
}
}

View File

@@ -14,6 +14,12 @@ FB.getLoginStatus(function(response: fb.AuthResponse) {
console.log(response.authResponse.accessToken);
});
FB.getLoginStatus(function(response: fb.AuthResponse) {
console.log(response);
console.log(response.status);
console.log(response.authResponse.accessToken);
}, true);
FB.getAuthResponse(function(response: fb.AuthResponse) {
console.log(response);
console.log(response.status);

View File

@@ -8,10 +8,11 @@ declare var FB: fb.FacebookStatic;
declare namespace facebook {
interface FacebookStatic {
// api: any;
// AppEvents: any;
// Canvas: any;
// Event: any;
api: any;
AppEvents: any;
Canvas: any;
Event: any;
/**
* The method FB.getAuthResponse() is a synchronous accessor for the current authResponse.
* The synchronous nature of this method is what sets it apart from the other login methods.
@@ -25,7 +26,7 @@ declare namespace facebook {
*
* @param callback function to handle the response.
*/
getLoginStatus(callback: (response: AuthResponse) => void): void;
getLoginStatus(callback: (response: AuthResponse) => void, roundtrip?: boolean ): void;
/**
* The method FB.init() is used to initialize and setup the SDK.
*
@@ -49,8 +50,9 @@ declare namespace facebook {
* @param callback function to handle the response
*/
logout(callback: (response: AuthResponse) => void): void;
// ui: any;
// XFBML: any;
ui: any;
XFBML: any;
}
interface InitParams {

View File

@@ -6,7 +6,7 @@
// Imported from: https://github.com/soywiz/typescript-node-definitions/fs-extra.d.ts via TSD fs-extra definition
///<reference path="../node/node.d.ts"/>
///<reference path="../bluebird/bluebird-2.0.d.ts"/>
///<reference path="../bluebird/bluebird.d.ts"/>
declare module "fs-extra-promise" {
import stream = require("stream");

View File

@@ -1,4 +1,4 @@
// Type definitions for Electron v1.3.5
// Type definitions for Electron v1.3.6
// Project: http://electron.atom.io/
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -62,7 +62,7 @@ declare namespace Electron {
/**
* Emitted when Electron has finished initialization.
*/
on(event: 'ready', listener: Function): this;
on(event: 'ready', listener: (event: Event, launchInfo: Object) => void): this;
/**
* Emitted when all windows have been closed.
*
@@ -218,6 +218,10 @@ declare namespace Electron {
args?: string[],
execPath?: string
}): void;
/**
* @returns Whether Electron has finished initializing.
*/
isReady(): boolean;
/**
* On Linux, focuses on the first visible window.
* On macOS, makes the application the active app.
@@ -1367,6 +1371,12 @@ declare namespace Electron {
}
interface WebPreferences {
/**
* Whether to enable DevTools.
* If it is set to false, can not use BrowserWindow.webContents.openDevTools() to open DevTools.
* Default: true.
*/
devTools?: boolean;
/**
* Whether node integration is enabled.
* Default: true.
@@ -1957,7 +1967,7 @@ declare namespace Electron {
interface CrashReporterStartOptions {
/**
* Default: Electron
* Default: app.getName()
*/
productName?: string;
companyName: string;
@@ -3392,16 +3402,18 @@ declare namespace Electron {
interface Shell {
/**
* Show the given file in a file manager. If possible, select the file.
* @returns Whether the item was successfully shown.
*/
showItemInFolder(fullPath: string): void;
showItemInFolder(fullPath: string): boolean;
/**
* Open the given file in the desktop's default manner.
* @returns Whether the item was successfully shown.
*/
openItem(fullPath: string): void;
openItem(fullPath: string): boolean;
/**
* Open the given external protocol URL in the desktop's default manner
* (e.g., mailto: URLs in the default mail user agent).
* @returns true if an application was available to open the URL, false otherwise.
* @returns Whether an application was available to open the URL.
*/
openExternal(url: string, options?: {
/**
@@ -3412,7 +3424,7 @@ declare namespace Electron {
}): boolean;
/**
* Move the given file to trash.
* @returns boolean status for the operation.
* @returns Whether the item was successfully moved to the trash.
*/
moveItemToTrash(fullPath: string): boolean;
/**

View File

@@ -0,0 +1,362 @@
/// <reference path="gl-matrix-legacy.d.ts" />
// common
var result: number = glMatrix.toRadian(180);
var out: GLM.IArray;
var outVal: number;
var outStr: string;
// vec2
var vecA: GLM.IArray, vecB: GLM.IArray, matA: GLM.IArray;
var vecArray: GLM.IArray;
vecA = [1, 2];
vecB = new Float32Array([3, 4]);
out = [0, 0];
matA = [1, 2, 3, 4, 5, 6];
vecArray = [1, 2, 3, 4, 0, 0];
out = vec2.create();
out = vec2.clone(vecA);
out = vec2.fromValues(1, 2);
out = vec2.copy(out, vecA);
out = vec2.set(out, 1, 2);
out = vec2.add(out, vecA, vecB);
out = vec2.subtract(out, vecA, vecB);
out = vec2.sub(out, vecA, vecB);
out = vec2.multiply(out, vecA, vecB);
out = vec2.mul(out, vecA, vecB);
out = vec2.divide(out, vecA, vecB);
out = vec2.div(out, vecA, vecB);
out = vec2.min(out, vecA, vecB);
out = vec2.max(out, vecA, vecB);
out = vec2.scale(out, vecA, 2);
out = vec2.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec2.distance(vecA, vecB);
outVal = vec2.dist(vecA, vecB);
outVal = vec2.squaredDistance(vecA, vecB);
outVal = vec2.sqrDist(vecA, vecB);
outVal = vec2.length(vecA);
outVal = vec2.len(vecA);
outVal = vec2.squaredLength(vecA);
outVal = vec2.sqrLen(vecA);
out = vec2.negate(out, vecA);
out = vec2.inverse(out, vecA);
out = vec2.normalize(out, vecA);
outVal = vec2.dot(vecA, vecB);
out = vec2.cross(out, vecA, vecB);
out = vec2.lerp(out, vecA, vecB, 0.5);
out = vec2.random(out);
out = vec2.random(out, 5.0);
out = vec2.transformMat2(out, vecA, matA);
out = vec2.transformMat2d(out, vecA, matA);
out = vec2.transformMat3(out, vecA, matA);
out = vec2.transformMat4(out, vecA, matA);
out = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize);
outStr = vec2.str(vecA);
// vec3
var matr: GLM.IArray;
var q: GLM.IArray;
vecA = [1, 2, 3];
vecB = new Float32Array([4, 5, 6]);
out = [0, 0, 0];
vecArray = [1, 2, 3, 4, 5, 6, 0, 0, 0];
matr = [1, 0, 0, 0, 1, 0, 0, 0, 1 ];
out = vec3.create();
out = vec3.clone(vecA);
out = vec3.fromValues(1, 2, 3);
out = vec3.copy(out, vecA);
out = vec3.set(out, 1, 2, 3);
out = vec3.add(out, vecA, vecB);
out = vec3.subtract(out, vecA, vecB);
out = vec3.sub(out, vecA, vecB);
out = vec3.multiply(out, vecA, vecB);
out = vec3.mul(out, vecA, vecB);
out = vec3.divide(out, vecA, vecB);
out = vec3.div(out, vecA, vecB);
out = vec3.min(out, vecA, vecB);
out = vec3.max(out, vecA, vecB);
out = vec3.scale(out, vecA, 2);
out = vec3.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec3.distance(vecA, vecB);
outVal = vec3.dist(vecA, vecB);
outVal = vec3.squaredDistance(vecA, vecB);
outVal = vec3.sqrDist(vecA, vecB);
outVal = vec3.length(vecA);
outVal = vec3.len(vecA);
outVal = vec3.squaredLength(vecA);
outVal = vec3.sqrLen(vecA);
out = vec3.negate(out, vecA);
out = vec3.inverse(out, vecA);
out = vec3.normalize(out, vecA);
outVal = vec3.dot(vecA, vecB);
out = vec3.cross(out, vecA, vecB);
out = vec3.lerp(out, vecA, vecB, 0.5);
out = vec3.random(out);
out = vec3.random(out, 5.0);
out = vec3.rotateX(out, vecA, vecB, Math.PI);
out = vec3.rotateY(out, vecA, vecB, Math.PI);
out = vec3.rotateZ(out, vecA, vecB, Math.PI);
out = vec3.transformMat3(out, vecA, matr);
matr = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ];
out = vec3.transformMat4(out, vecA, matr);
q = [1, 2, 3, 4];
out = vec3.transformQuat(out, vecA, matr);
out = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize);
outVal = vec3.angle(vecA, vecB);
outStr = vec3.str(vecA);
// vec4
var q: GLM.IArray;
vecA = [1, 2, 3, 4];
vecB = new Float32Array([5, 6, 7, 8]);
out = [0, 0, 0, 0];
q = [1, 2, 3, 4];
out = vec4.create();
out = vec4.clone(vecA);
out = vec4.fromValues(1, 2, 3, 4);
out = vec4.copy(out, vecA);
out = vec4.set(out, 1, 2, 3, 4);
out = vec4.add(out, vecA, vecB);
out = vec4.subtract(out, vecA, vecB);
out = vec4.sub(out, vecA, vecB);
out = vec4.multiply(out, vecA, vecB);
out = vec4.mul(out, vecA, vecB);
out = vec4.divide(out, vecA, vecB);
out = vec4.div(out, vecA, vecB);
out = vec4.min(out, vecA, vecB);
out = vec4.max(out, vecA, vecB);
out = vec4.scale(out, vecA, 2);
out = vec4.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec4.distance(vecA, vecB);
outVal = vec4.dist(vecA, vecB);
outVal = vec4.squaredDistance(vecA, vecB);
outVal = vec4.sqrDist(vecA, vecB);
outVal = vec4.length(vecA);
outVal = vec4.len(vecA);
outVal = vec4.squaredLength(vecA);
outVal = vec4.sqrLen(vecA);
out = vec4.negate(out, vecA);
out = vec4.inverse(out, vecA);
out = vec4.normalize(out, vecA);
outVal = vec4.dot(vecA, vecB);
out = vec4.lerp(out, vecA, vecB, 0.5);
out = vec4.random(out);
out = vec4.random(out, 5.0);
matr = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
out = vec4.transformMat4(out, vecA, matr);
out = vec4.transformQuat(out, vecA, q);
vecArray = [1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0];
out = vec4.forEach(vecArray, 0, 0, 0, vec4.normalize);
outStr = vec4.str(vecA);
// mat2
var matB: GLM.IArray, identity: GLM.IArray;
matA = [1, 2, 3, 4];
matB = new Float32Array([5, 6, 7, 8]);
out = [0, 0, 0, 0];
identity = [1, 0, 0, 1];
out = mat2.create();
out = mat2.clone(matA);
out = mat2.copy(out, matA);
out = mat2.identity(out);
out = mat2.transpose(out, matA);
out = mat2.invert(out, matA);
out = mat2.adjoint(out, matA);
outVal = mat2.determinant(matA);
out = mat2.multiply(out, matA, matB);
out = mat2.mul(out, matA, matB);
out = mat2.rotate(out, matA, Math.PI * 0.5);
vecA = [2, 3];
out = mat2.scale(out, matA, vecA);
outStr = mat2.str(matA);
outVal = mat2.frob(matA);
var L = mat2.create();
var D = mat2.create();
var U = mat2.create();
out = mat2.LDU(L, D, U, [4,3,6,3]);
// mat2d
matA = [1, 2, 3, 4, 5, 6];
matB = [7, 8, 9, 10, 11, 12];
out = [0, 0, 0, 0, 0, 0];
identity = [1, 0, 0, 1, 0, 0];
out = mat2d.create();
out = mat2d.clone(matA);
out = mat2d.copy(out, matA);
out = mat2d.identity(out);
out = mat2d.invert(out, matA);
outVal = mat2d.determinant(matA);
out = mat2d.multiply(out, matA, matB);
out = mat2d.mul(out, matA, matB);
out = mat2d.rotate(out, matA, Math.PI * 0.5);
vecA = [2, 3];
out = mat2d.scale(out, matA, vecA);
out = mat2d.translate(out, matA, vecA);
outStr = mat2d.str(matA);
outVal = mat2d.frob(matA);
// mat3
matA = [1, 0, 0, 0, 1, 0, 1, 2, 1];
matB = [1, 0, 0, 0, 1, 0, 3, 4, 1];
out = [0, 0, 0, 0, 0, 0, 0, 0, 0];
identity = [1, 0, 0, 0, 1, 0, 0, 0, 1];
out = mat3.create();
out = mat3.clone(matA);
out = mat3.copy(out, matA);
out = mat3.identity(out);
out = mat3.transpose(out, matA);
out = mat3.invert(out, matA);
out = mat3.adjoint(out, matA);
outVal = mat3.determinant(matA);
out = mat3.multiply(out, matA, matB);
out = mat3.mul(out, matA, matB);
outStr = mat3.str(matA);
outVal = mat3.frob(matA);
matA = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
out = mat3.normalFromMat4(out, matA);
q = [ 0, -0.7071067811865475, 0, 0.7071067811865475 ];
out = mat3.fromQuat(out, q);
out = mat3.normalFromMat4(out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13,14,15,16]);
out = mat3.fromMat4(out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13,14,15,16]);
out = mat3.scale(out, matA, [2,2]);
out = mat3.fromMat2d(out, [1, 2, 3, 4, 5, 6]);
out = mat3.translate(out, matA, [1, 2, 3]);
out = mat3.rotate(out, matA, Math.PI/2);
// mat4
matA = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 2, 3, 1];
matB = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
4, 5, 6, 1];
out = [0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0];
identity = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
out = mat4.create();
out = mat4.clone(matA);
out = mat4.copy(out, matA);
out = mat4.identity(out);
out = mat4.transpose(out, matA);
out = mat4.invert(out, matA);
out = mat4.adjoint(out, matA);
outVal = mat4.determinant(matA);
out = mat4.multiply(out, matA, matB);
out = mat4.mul(out, matA, matB);
out = mat4.translate(out, matA, [4, 5, 6]);
out = mat4.scale(out, matA, [4, 5, 6]);
var rad = Math.PI * 0.5;
var axis = [1, 0, 0];
out = mat4.rotate(out, matA, rad, axis);
out = mat4.rotateX(out, matA, rad);
out = mat4.rotateY(out, matA, rad);
out = mat4.rotateZ(out, matA, rad);
out = mat4.frustum(out, -1, 1, -1, 1, -1, 1);
var fovy = Math.PI * 0.5;
out = mat4.perspective(out, fovy, 1, 0, 1);
out = mat4.ortho(out, -1, 1, -1, 1, -1, 1);
var eye = [0, 0, 1];
var center = [0, 0, -1];
var up = [0, 1, 0];
out = mat4.lookAt(out, eye, center, up);
outStr = mat4.str(matA);
outVal = mat4.frob(matA);
q = [0, 0, 0, 1];
out = mat4.fromRotationTranslation(out, q, [1, 2, 3]);
out = mat4.fromQuat(out, q);
q = [0, 0, 0, 1];
out = mat4.fromRotationTranslationScale(out, q, [1, 2, 3], [1, 2, 3]);
out = mat4.fromQuat(out, q);
// quat
var quatA = [1, 2, 3, 4];
var quatB = [5, 6, 7, 8];
out = [0, 0, 0, 0];
var vec = [1, 1, -1];
var id = [0, 0, 0, 1];
var deg90 = Math.PI / 2;
out = quat.create();
out = quat.clone(quatA);
out = quat.fromValues(1, 2, 3, 4);
out = quat.copy(out, quatA);
out = quat.set(out, 1, 2, 3, 4);
out = quat.identity(out);
out = quat.setAxisAngle(out, [1, 0, 0], Math.PI * 0.5);
out = quat.add(out, quatA, quatB);
out = quat.multiply(out, quatA, quatB);
out = quat.mul(out, quatA, quatB);
out = quat.scale(out, quatA, 2);
outVal = quat.length(quatA);
outVal = quat.len(quatA);
outVal = quat.squaredLength(quatA);
outVal = quat.sqrLen(quatA);
out = quat.normalize(out, quatA);
outVal = quat.dot(out, quatA, quatB);
out = quat.lerp(out, quatA, quatB, 0.5);
out = quat.slerp(out, quatA, quatB, 0.5);
out = quat.invert(out, quatA);
out = quat.conjugate(out, quatA);
outStr = quat.str(quatA);
out = quat.rotateX(out, id, deg90);
out = quat.rotateY(out, id, deg90);
out = quat.rotateZ(out, id, deg90);
matr = [ 1, 0, 0,
0, 0, -1,
0, 1, 0 ];
out = quat.fromMat3(out, matr);
var view = [-1, 0, 0];
up = [ 0, 1, 0];
var right= [ 0, 0,-1];
out = quat.setAxes([], view, right, up);
out = quat.rotationTo(out, [0, 1, 0], [1, 0, 0]);
out = quat.calculateW(out, quatA);

2163
gl-matrix/gl-matrix-legacy.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,362 +1,347 @@
/// <reference path="gl-matrix.d.ts" />
// common
var result: number = glMatrix.toRadian(180);
import {vec2, mat2, mat3, mat4, vec3, vec4, mat2d, quat} from "./gl-matrix";
var out: GLM.IArray;
var outVal: number;
var outBool: boolean;
var outStr: string;
let vecArray = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
let vec2A = vec2.fromValues(1, 2);
let vec2B = vec2.fromValues(3, 4);
let vec3A = vec3.fromValues(1, 2, 3);
let vec3B = vec3.fromValues(3, 4, 5);
let vec4A = vec4.fromValues(1, 2, 3, 4);
let vec4B = vec4.fromValues(3, 4, 5, 6);
let mat2A = mat2.fromValues(1, 2, 3, 4);
let mat2B = mat2.fromValues(1, 2, 3, 4);
let mat2dA = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat2dB = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat3A = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat3B = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat4A = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let mat4B = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let quatA = quat.fromValues(1, 2, 3, 4);
let quatB = quat.fromValues(5, 6, 7, 8);
let outVec2 = vec2.create();
let outVec3 = vec3.create();
let outVec4 = vec4.create();
let outMat2 = mat2.create();
let outMat2d = mat2d.create();
let outMat3 = mat3.create();
let outMat4 = mat4.create();
let outQuat = quat.create();
// vec2
var vecA: GLM.IArray, vecB: GLM.IArray, matA: GLM.IArray;
var vecArray: GLM.IArray;
vecA = [1, 2];
vecB = new Float32Array([3, 4]);
out = [0, 0];
matA = [1, 2, 3, 4, 5, 6];
vecArray = [1, 2, 3, 4, 0, 0];
out = vec2.create();
out = vec2.clone(vecA);
out = vec2.fromValues(1, 2);
out = vec2.copy(out, vecA);
out = vec2.set(out, 1, 2);
out = vec2.add(out, vecA, vecB);
out = vec2.subtract(out, vecA, vecB);
out = vec2.sub(out, vecA, vecB);
out = vec2.multiply(out, vecA, vecB);
out = vec2.mul(out, vecA, vecB);
out = vec2.divide(out, vecA, vecB);
out = vec2.div(out, vecA, vecB);
out = vec2.min(out, vecA, vecB);
out = vec2.max(out, vecA, vecB);
out = vec2.scale(out, vecA, 2);
out = vec2.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec2.distance(vecA, vecB);
outVal = vec2.dist(vecA, vecB);
outVal = vec2.squaredDistance(vecA, vecB);
outVal = vec2.sqrDist(vecA, vecB);
outVal = vec2.length(vecA);
outVal = vec2.len(vecA);
outVal = vec2.squaredLength(vecA);
outVal = vec2.sqrLen(vecA);
out = vec2.negate(out, vecA);
out = vec2.inverse(out, vecA);
out = vec2.normalize(out, vecA);
outVal = vec2.dot(vecA, vecB);
out = vec2.cross(out, vecA, vecB);
out = vec2.lerp(out, vecA, vecB, 0.5);
out = vec2.random(out);
out = vec2.random(out, 5.0);
out = vec2.transformMat2(out, vecA, matA);
out = vec2.transformMat2d(out, vecA, matA);
out = vec2.transformMat3(out, vecA, matA);
out = vec2.transformMat4(out, vecA, matA);
out = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize);
outStr = vec2.str(vecA);
outVec2 = vec2.create();
outVec2 = vec2.clone(vec2A);
outVec2 = vec2.fromValues(1, 2);
outVec2 = vec2.copy(outVec2, vec2A);
outVec2 = vec2.set(outVec2, 1, 2);
outVec2 = vec2.add(outVec2, vec2A, vec2B);
outVec2 = vec2.subtract(outVec2, vec2A, vec2B);
outVec2 = vec2.sub(outVec2, vec2A, vec2B);
outVec2 = vec2.multiply(outVec2, vec2A, vec2B);
outVec2 = vec2.mul(outVec2, vec2A, vec2B);
outVec2 = vec2.divide(outVec2, vec2A, vec2B);
outVec2 = vec2.div(outVec2, vec2A, vec2B);
outVec2 = vec2.ceil(outVec2, vec2A);
outVec2 = vec2.floor(outVec2, vec2A);
outVec2 = vec2.min(outVec2, vec2A, vec2B);
outVec2 = vec2.max(outVec2, vec2A, vec2B);
outVec2 = vec2.round(outVec2, vec2A);
outVec2 = vec2.scale(outVec2, vec2A, 2);
outVec2 = vec2.scaleAndAdd(outVec2, vec2A, vec2B, 0.5);
outVal = vec2.distance(vec2A, vec2B);
outVal = vec2.dist(vec2A, vec2B);
outVal = vec2.squaredDistance(vec2A, vec2B);
outVal = vec2.sqrDist(vec2A, vec2B);
outVal = vec2.length(vec2A);
outVal = vec2.len(vec2A);
outVal = vec2.squaredLength(vec2A);
outVal = vec2.sqrLen(vec2A);
outVec2 = vec2.negate(outVec2, vec2A);
outVec2 = vec2.inverse(outVec2, vec2A);
outVec2 = vec2.normalize(outVec2, vec2A);
outVal = vec2.dot(vec2A, vec2B);
outVec2 = vec2.cross(outVec2, vec2A, vec2B);
outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5);
outVec2 = vec2.random(outVec2);
outVec2 = vec2.random(outVec2, 5.0);
outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A);
outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA);
outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A);
outVec2 = vec2.transformMat4(outVec2, vec2A, mat4A);
vecArray = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize);
outStr = vec2.str(vec2A);
outBool = vec2.exactEquals(vec2A, vec2B);
outBool = vec2.equals(vec2A, vec2B);
outVec2 = vec2.add(outVec2, [0, 1], [2, 3]); // test one method with number array input
// vec3
var matr: GLM.IArray;
var q: GLM.IArray;
vecA = [1, 2, 3];
vecB = new Float32Array([4, 5, 6]);
out = [0, 0, 0];
vecArray = [1, 2, 3, 4, 5, 6, 0, 0, 0];
matr = [1, 0, 0, 0, 1, 0, 0, 0, 1 ];
out = vec3.create();
out = vec3.clone(vecA);
out = vec3.fromValues(1, 2, 3);
out = vec3.copy(out, vecA);
out = vec3.set(out, 1, 2, 3);
out = vec3.add(out, vecA, vecB);
out = vec3.subtract(out, vecA, vecB);
out = vec3.sub(out, vecA, vecB);
out = vec3.multiply(out, vecA, vecB);
out = vec3.mul(out, vecA, vecB);
out = vec3.divide(out, vecA, vecB);
out = vec3.div(out, vecA, vecB);
out = vec3.min(out, vecA, vecB);
out = vec3.max(out, vecA, vecB);
out = vec3.scale(out, vecA, 2);
out = vec3.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec3.distance(vecA, vecB);
outVal = vec3.dist(vecA, vecB);
outVal = vec3.squaredDistance(vecA, vecB);
outVal = vec3.sqrDist(vecA, vecB);
outVal = vec3.length(vecA);
outVal = vec3.len(vecA);
outVal = vec3.squaredLength(vecA);
outVal = vec3.sqrLen(vecA);
out = vec3.negate(out, vecA);
out = vec3.inverse(out, vecA);
out = vec3.normalize(out, vecA);
outVal = vec3.dot(vecA, vecB);
out = vec3.cross(out, vecA, vecB);
out = vec3.lerp(out, vecA, vecB, 0.5);
out = vec3.random(out);
out = vec3.random(out, 5.0);
out = vec3.rotateX(out, vecA, vecB, Math.PI);
out = vec3.rotateY(out, vecA, vecB, Math.PI);
out = vec3.rotateZ(out, vecA, vecB, Math.PI);
out = vec3.transformMat3(out, vecA, matr);
matr = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ];
out = vec3.transformMat4(out, vecA, matr);
q = [1, 2, 3, 4];
out = vec3.transformQuat(out, vecA, matr);
out = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize);
outVal = vec3.angle(vecA, vecB);
outStr = vec3.str(vecA);
outVec3 = vec3.create();
outVec3 = vec3.clone(vec3A);
outVec3 = vec3.fromValues(1, 2, 3);
outVec3 = vec3.copy(outVec3, vec3A);
outVec3 = vec3.set(outVec3, 1, 2, 3);
outVec3 = vec3.add(outVec3, vec3A, vec3B);
outVec3 = vec3.subtract(outVec3, vec3A, vec3B);
outVec3 = vec3.sub(outVec3, vec3A, vec3B);
outVec3 = vec3.multiply(outVec3, vec3A, vec3B);
outVec3 = vec3.mul(outVec3, vec3A, vec3B);
outVec3 = vec3.divide(outVec3, vec3A, vec3B);
outVec3 = vec3.div(outVec3, vec3A, vec3B);
outVec3 = vec3.ceil(outVec3, vec3A);
outVec3 = vec3.floor(outVec3, vec3A);
outVec3 = vec3.min(outVec3, vec3A, vec3B);
outVec3 = vec3.max(outVec3, vec3A, vec3B);
outVec3 = vec3.round(outVec3, vec3A);
outVec3 = vec3.scale(outVec3, vec3A, 2);
outVec3 = vec3.scaleAndAdd(outVec3, vec3A, vec3B, 0.5);
outVal = vec3.distance(vec3A, vec3B);
outVal = vec3.dist(vec3A, vec3B);
outVal = vec3.squaredDistance(vec3A, vec3B);
outVal = vec3.sqrDist(vec3A, vec3B);
outVal = vec3.length(vec3A);
outVal = vec3.len(vec3A);
outVal = vec3.squaredLength(vec3A);
outVal = vec3.sqrLen(vec3A);
outVec3 = vec3.negate(outVec3, vec3A);
outVec3 = vec3.inverse(outVec3, vec3A);
outVec3 = vec3.normalize(outVec3, vec3A);
outVal = vec3.dot(vec3A, vec3B);
outVec3 = vec3.cross(outVec3, vec3A, vec3B);
outVec3 = vec3.lerp(outVec3, vec3A, vec3B, 0.5);
outVec3 = vec3.hermite(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.bezier(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.random(outVec3);
outVec3 = vec3.random(outVec3, 5.0);
outVec3 = vec3.transformMat3(outVec3, vec3A, mat3A);
outVec3 = vec3.transformMat4(outVec3, vec3A, mat4A);
outVec3 = vec3.transformQuat(outVec3, vec3A, quatA);
outVec3 = vec3.rotateX(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateY(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateZ(outVec3, vec3A, vec3B, Math.PI);
vecArray = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize);
outVal = vec3.angle(vec3A, vec3B);
outStr = vec3.str(vec3A);
outBool = vec3.exactEquals(vec3A, vec3B);
outBool = vec3.equals(vec3A, vec3B);
outVec3 = vec3.add(outVec3, [0, 1, 2], [3, 4, 5]); // test one method with number array input
// vec4
var q: GLM.IArray;
vecA = [1, 2, 3, 4];
vecB = new Float32Array([5, 6, 7, 8]);
out = [0, 0, 0, 0];
q = [1, 2, 3, 4];
out = vec4.create();
out = vec4.clone(vecA);
out = vec4.fromValues(1, 2, 3, 4);
out = vec4.copy(out, vecA);
out = vec4.set(out, 1, 2, 3, 4);
out = vec4.add(out, vecA, vecB);
out = vec4.subtract(out, vecA, vecB);
out = vec4.sub(out, vecA, vecB);
out = vec4.multiply(out, vecA, vecB);
out = vec4.mul(out, vecA, vecB);
out = vec4.divide(out, vecA, vecB);
out = vec4.div(out, vecA, vecB);
out = vec4.min(out, vecA, vecB);
out = vec4.max(out, vecA, vecB);
out = vec4.scale(out, vecA, 2);
out = vec4.scaleAndAdd(out, vecA, vecB, 0.5);
outVal = vec4.distance(vecA, vecB);
outVal = vec4.dist(vecA, vecB);
outVal = vec4.squaredDistance(vecA, vecB);
outVal = vec4.sqrDist(vecA, vecB);
outVal = vec4.length(vecA);
outVal = vec4.len(vecA);
outVal = vec4.squaredLength(vecA);
outVal = vec4.sqrLen(vecA);
out = vec4.negate(out, vecA);
out = vec4.inverse(out, vecA);
out = vec4.normalize(out, vecA);
outVal = vec4.dot(vecA, vecB);
out = vec4.lerp(out, vecA, vecB, 0.5);
out = vec4.random(out);
out = vec4.random(out, 5.0);
matr = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
out = vec4.transformMat4(out, vecA, matr);
out = vec4.transformQuat(out, vecA, q);
vecArray = [1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0];
out = vec4.forEach(vecArray, 0, 0, 0, vec4.normalize);
outStr = vec4.str(vecA);
outVec4 = vec4.create();
outVec4 = vec4.clone(vec4A);
outVec4 = vec4.fromValues(1, 2, 3, 4);
outVec4 = vec4.copy(outVec4, vec4A);
outVec4 = vec4.set(outVec4, 1, 2, 3, 4);
outVec4 = vec4.add(outVec4, vec4A, vec4B);
outVec4 = vec4.subtract(outVec4, vec4A, vec4B);
outVec4 = vec4.sub(outVec4, vec4A, vec4B);
outVec4 = vec4.multiply(outVec4, vec4A, vec4B);
outVec4 = vec4.mul(outVec4, vec4A, vec4B);
outVec4 = vec4.divide(outVec4, vec4A, vec4B);
outVec4 = vec4.div(outVec4, vec4A, vec4B);
outVec4 = vec4.ceil(outVec4, vec4A);
outVec4 = vec4.floor(outVec4, vec4A);
outVec4 = vec4.min(outVec4, vec4A, vec4B);
outVec4 = vec4.max(outVec4, vec4A, vec4B);
outVec4 = vec4.scale(outVec4, vec4A, 2);
outVec4 = vec4.scaleAndAdd(outVec4, vec4A, vec4B, 0.5);
outVal = vec4.distance(vec4A, vec4B);
outVal = vec4.dist(vec4A, vec4B);
outVal = vec4.squaredDistance(vec4A, vec4B);
outVal = vec4.sqrDist(vec4A, vec4B);
outVal = vec4.length(vec4A);
outVal = vec4.len(vec4A);
outVal = vec4.squaredLength(vec4A);
outVal = vec4.sqrLen(vec4A);
outVec4 = vec4.negate(outVec4, vec4A);
outVec4 = vec4.inverse(outVec4, vec4A);
outVec4 = vec4.normalize(outVec4, vec4A);
outVal = vec4.dot(vec4A, vec4B);
outVec4 = vec4.lerp(outVec4, vec4A, vec4B, 0.5);
outVec4 = vec4.random(outVec4);
outVec4 = vec4.random(outVec4, 5.0);
outVec4 = vec4.transformMat4(outVec4, vec4A, mat4A);
outVec4 = vec4.transformQuat(outVec4, vec4A, quatA);
vecArray = vec4.forEach(vecArray, 0, 0, 0, vec4.normalize);
outStr = vec4.str(vec4A);
outBool = vec4.exactEquals(vec4A, vec4B);
outBool = vec4.equals(vec4A, vec4B);
outVec4 = vec4.add(outVec4, [0, 1, 2, 3], [4, 5, 6, 7]); // test one method with number array input
// mat2
var matB: GLM.IArray, identity: GLM.IArray;
matA = [1, 2, 3, 4];
matB = new Float32Array([5, 6, 7, 8]);
out = [0, 0, 0, 0];
identity = [1, 0, 0, 1];
out = mat2.create();
out = mat2.clone(matA);
out = mat2.copy(out, matA);
out = mat2.identity(out);
out = mat2.transpose(out, matA);
out = mat2.invert(out, matA);
out = mat2.adjoint(out, matA);
outVal = mat2.determinant(matA);
out = mat2.multiply(out, matA, matB);
out = mat2.mul(out, matA, matB);
out = mat2.rotate(out, matA, Math.PI * 0.5);
vecA = [2, 3];
out = mat2.scale(out, matA, vecA);
outStr = mat2.str(matA);
outVal = mat2.frob(matA);
var L = mat2.create();
var D = mat2.create();
outMat2 = mat2.create();
outMat2 = mat2.clone(mat2A);
outMat2 = mat2.copy(outMat2, mat2A);
outMat2 = mat2.identity(outMat2);
outMat2 = mat2.fromValues(1, 2, 3, 4);
outMat2 = mat2.set(outMat2, 1, 2, 3, 4);
outMat2 = mat2.transpose(outMat2, mat2A);
outMat2 = mat2.invert(outMat2, mat2A);
outMat2 = mat2.adjoint(outMat2, mat2A);
outVal = mat2.determinant(mat2A);
outMat2 = mat2.multiply(outMat2, mat2A, mat2B);
outMat2 = mat2.mul(outMat2, mat2A, mat2B);
outMat2 = mat2.rotate(outMat2, mat2A, Math.PI * 0.5);
outMat2 = mat2.scale(outMat2, mat2A, vec2A);
outMat2 = mat2.fromRotation(outMat2, 0.5);
outMat2 = mat2.fromScaling(outMat2, vec2A);
outStr = mat2.str(mat2A);
outVal = mat2.frob(mat2A);
var L = mat2.create();
var D = mat2.create();
var U = mat2.create();
out = mat2.LDU(L, D, U, [4,3,6,3]);
outMat2 = mat2.LDU(L, D, U, mat2A);
outMat2 = mat2.add(outMat2, mat2A, mat2B);
outMat2 = mat2.subtract(outMat2, mat2A, mat2B);
outMat2 = mat2.sub(outMat2, mat2A, mat2B);
outBool = mat2.exactEquals(mat2A, mat2B);
outBool = mat2.equals(mat2A, mat2B);
outMat2 = mat2.multiplyScalar (outMat2, mat2A, 2);
outMat2 = mat2.multiplyScalarAndAdd (outMat2, mat2A, mat2B, 2);
// mat2d
matA = [1, 2, 3, 4, 5, 6];
matB = [7, 8, 9, 10, 11, 12];
out = [0, 0, 0, 0, 0, 0];
identity = [1, 0, 0, 1, 0, 0];
out = mat2d.create();
out = mat2d.clone(matA);
out = mat2d.copy(out, matA);
out = mat2d.identity(out);
out = mat2d.invert(out, matA);
outVal = mat2d.determinant(matA);
out = mat2d.multiply(out, matA, matB);
out = mat2d.mul(out, matA, matB);
out = mat2d.rotate(out, matA, Math.PI * 0.5);
vecA = [2, 3];
out = mat2d.scale(out, matA, vecA);
out = mat2d.translate(out, matA, vecA);
outStr = mat2d.str(matA);
outVal = mat2d.frob(matA);
outMat2d = mat2d.create();
outMat2d = mat2d.clone(mat2dA);
outMat2d = mat2d.copy(outMat2d, mat2dA);
outMat2d = mat2d.identity(outMat2d);
outMat2d = mat2d.fromValues(1, 2, 3, 4, 5, 6);
outMat2d = mat2d.set(outMat2d, 1, 2, 3, 4, 5, 6);
outMat2d = mat2d.invert(outMat2d, mat2dA);
outVal = mat2d.determinant(mat2dA);
outMat2d = mat2d.multiply(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.mul(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.rotate(outMat2d, mat2dA, Math.PI * 0.5);
outMat2d = mat2d.scale(outMat2d, mat2dA, vec2A);
outMat2d = mat2d.translate(outMat2d, mat2dA, vec2A);
outMat2d = mat2d.fromRotation(outMat2d, 0.5);
outMat2d = mat2d.fromScaling(outMat2d, vec2A);
outMat2d = mat2d.fromTranslation(outMat2d, vec2A);
outStr = mat2d.str(mat2dA);
outVal = mat2d.frob(mat2dA);
outMat2d = mat2d.add(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.subtract(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.sub(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.multiplyScalar (outMat2d, mat2dA, 2);
outMat2d = mat2d.multiplyScalarAndAdd (outMat2d, mat2dA, mat2dB, 2);
outBool = mat2d.exactEquals(mat2dA, mat2dB);
outBool = mat2d.equals(mat2dA, mat2dB);
// mat3
matA = [1, 0, 0, 0, 1, 0, 1, 2, 1];
matB = [1, 0, 0, 0, 1, 0, 3, 4, 1];
out = [0, 0, 0, 0, 0, 0, 0, 0, 0];
identity = [1, 0, 0, 0, 1, 0, 0, 0, 1];
out = mat3.create();
out = mat3.clone(matA);
out = mat3.copy(out, matA);
out = mat3.identity(out);
out = mat3.transpose(out, matA);
out = mat3.invert(out, matA);
out = mat3.adjoint(out, matA);
outVal = mat3.determinant(matA);
out = mat3.multiply(out, matA, matB);
out = mat3.mul(out, matA, matB);
outStr = mat3.str(matA);
outVal = mat3.frob(matA);
matA = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
out = mat3.normalFromMat4(out, matA);
q = [ 0, -0.7071067811865475, 0, 0.7071067811865475 ];
out = mat3.fromQuat(out, q);
out = mat3.normalFromMat4(out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13,14,15,16]);
out = mat3.fromMat4(out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13,14,15,16]);
out = mat3.scale(out, matA, [2,2]);
out = mat3.fromMat2d(out, [1, 2, 3, 4, 5, 6]);
out = mat3.translate(out, matA, [1, 2, 3]);
out = mat3.rotate(out, matA, Math.PI/2);
// mat4
matA = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 2, 3, 1];
matB = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
4, 5, 6, 1];
out = [0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0];
identity = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
out = mat4.create();
out = mat4.clone(matA);
out = mat4.copy(out, matA);
out = mat4.identity(out);
out = mat4.transpose(out, matA);
out = mat4.invert(out, matA);
out = mat4.adjoint(out, matA);
outVal = mat4.determinant(matA);
out = mat4.multiply(out, matA, matB);
out = mat4.mul(out, matA, matB);
out = mat4.translate(out, matA, [4, 5, 6]);
out = mat4.scale(out, matA, [4, 5, 6]);
var rad = Math.PI * 0.5;
var axis = [1, 0, 0];
out = mat4.rotate(out, matA, rad, axis);
out = mat4.rotateX(out, matA, rad);
out = mat4.rotateY(out, matA, rad);
out = mat4.rotateZ(out, matA, rad);
out = mat4.frustum(out, -1, 1, -1, 1, -1, 1);
var fovy = Math.PI * 0.5;
out = mat4.perspective(out, fovy, 1, 0, 1);
out = mat4.ortho(out, -1, 1, -1, 1, -1, 1);
var eye = [0, 0, 1];
var center = [0, 0, -1];
var up = [0, 1, 0];
out = mat4.lookAt(out, eye, center, up);
outStr = mat4.str(matA);
outVal = mat4.frob(matA);
q = [0, 0, 0, 1];
out = mat4.fromRotationTranslation(out, q, [1, 2, 3]);
out = mat4.fromQuat(out, q);
q = [0, 0, 0, 1];
out = mat4.fromRotationTranslationScale(out, q, [1, 2, 3], [1, 2, 3]);
out = mat4.fromQuat(out, q);
outMat3 = mat3.create();
outMat3 = mat3.fromMat4(outMat3, mat4A);
outMat3 = mat3.clone(mat3A);
outMat3 = mat3.copy(outMat3, mat3A);
outMat3 = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
outMat3 = mat3.set(outMat3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
outMat3 = mat3.identity(outMat3);
outMat3 = mat3.transpose(outMat3, mat3A);
outMat3 = mat3.invert(outMat3, mat3A);
outMat3 = mat3.adjoint(outMat3, mat3A);
outVal = mat3.determinant(mat3A);
outMat3 = mat3.multiply(outMat3, mat3A, mat3B);
outMat3 = mat3.mul(outMat3, mat3A, mat3B);
outMat3 = mat3.translate(outMat3, mat3A, vec3A);
outMat3 = mat3.rotate(outMat3, mat3A, Math.PI/2);
outMat3 = mat3.scale(outMat3, mat3A, vec2A);
outMat3 = mat3.fromTranslation(outMat3, vec2A);
outMat3 = mat3.fromRotation(outMat3, Math.PI);
outMat3 = mat3.fromScaling(outMat3, vec2A);
outMat3 = mat3.fromMat2d(outMat3, mat2dA);
outMat3 = mat3.fromQuat(outMat3, quatA);
outMat3 = mat3.normalFromMat4(outMat3, mat4A);
outStr = mat3.str(mat3A);
outVal = mat3.frob(mat3A);
outMat3 = mat3.add(outMat3, mat3A, mat3B);
outMat3 = mat3.subtract(outMat3, mat3A, mat3B);
outMat3 = mat3.sub(outMat3, mat3A, mat3B);
outMat3 = mat3.multiplyScalar (outMat3, mat3A, 2);
outMat3 = mat3.multiplyScalarAndAdd (outMat3, mat3A, mat3B, 2);
outBool = mat3.exactEquals(mat3A, mat3B);
outBool = mat3.equals(mat3A, mat3B);
//mat4
outMat4 = mat4.create();
outMat4 = mat4.clone(mat4A);
outMat4 = mat4.copy(outMat4, mat4A);
outMat4 = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
outMat4 = mat4.set(outMat4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
outMat4 = mat4.identity(outMat4);
outMat4 = mat4.transpose(outMat4, mat4A);
outMat4 = mat4.invert(outMat4, mat4A);
outMat4 = mat4.adjoint(outMat4, mat4A);
outVal = mat4.determinant(mat4A);
outMat4 = mat4.multiply(outMat4, mat4A, mat4B);
outMat4 = mat4.mul(outMat4, mat4A, mat4B);
outMat4 = mat4.translate(outMat4, mat4A, vec3A);
outMat4 = mat4.scale(outMat4, mat4A, vec3A);
outMat4 = mat4.rotate(outMat4, mat4A, Math.PI, vec3A);
outMat4 = mat4.rotateX(outMat4, mat4A, Math.PI);
outMat4 = mat4.rotateY(outMat4, mat4A, Math.PI);
outMat4 = mat4.rotateZ(outMat4, mat4A, Math.PI);
outMat4 = mat4.fromTranslation(outMat4, vec3A);
outMat4 = mat4.fromRotation(outMat4, Math.PI, vec3A);
outMat4 = mat4.fromScaling(outMat4, vec3A);
outMat4 = mat4.fromXRotation(outMat4, Math.PI);
outMat4 = mat4.fromYRotation(outMat4, Math.PI);
outMat4 = mat4.fromZRotation(outMat4, Math.PI);
outMat4 = mat4.fromRotationTranslation(outMat4, quatA, vec3A);
outVec3 = mat4.getTranslation(outVec3, mat4A)
outQuat = mat4.getRotation(outQuat, mat4A)
outMat4 = mat4.fromRotationTranslationScale(outMat4, quatA, vec3A, vec3B);
outMat4 = mat4.fromRotationTranslationScaleOrigin(outMat4, quatA, vec3A, vec3B, vec3A);
outMat4 = mat4.fromQuat(outMat4, quatB);
outMat4 = mat4.frustum(outMat4, -1, 1, -1, 1, -1, 1);
outMat4 = mat4.perspective(outMat4, Math.PI, 1, 0, 1);
outMat4 = mat4.perspectiveFromFieldOfView(outMat4, {upDegrees:Math.PI, downDegrees:-Math.PI, leftDegrees:-Math.PI, rightDegrees:Math.PI}, 1, 0);
outMat4 = mat4.ortho(outMat4, -1, 1, -1, 1, -1, 1);
outMat4 = mat4.lookAt(outMat4, vec3A, vec3B, vec3A);
outStr = mat4.str(mat4A);
outVal = mat4.frob(mat4A);
outMat4 = mat4.add(outMat4, mat4A, mat4B);
outMat4 = mat4.subtract(outMat4, mat4A, mat4B);
outMat4 = mat4.sub(outMat4, mat4A, mat4B);
outMat4 = mat4.multiplyScalar (outMat4, mat4A, 2);
outMat4 = mat4.multiplyScalarAndAdd (outMat4, mat4A, mat4B, 2);
outBool = mat4.exactEquals(mat4A, mat4B);
outBool = mat4.equals(mat4A, mat4B);
// quat
var quatA = [1, 2, 3, 4];
var quatB = [5, 6, 7, 8];
out = [0, 0, 0, 0];
var vec = [1, 1, -1];
var id = [0, 0, 0, 1];
var deg90 = Math.PI / 2;
out = quat.create();
out = quat.clone(quatA);
out = quat.fromValues(1, 2, 3, 4);
out = quat.copy(out, quatA);
out = quat.set(out, 1, 2, 3, 4);
out = quat.identity(out);
out = quat.setAxisAngle(out, [1, 0, 0], Math.PI * 0.5);
out = quat.add(out, quatA, quatB);
out = quat.multiply(out, quatA, quatB);
out = quat.mul(out, quatA, quatB);
out = quat.scale(out, quatA, 2);
outQuat = quat.create();
outQuat = quat.clone(quatA);
outQuat = quat.fromValues(1, 2, 3, 4);
outQuat = quat.copy(outQuat, quatA);
outQuat = quat.set(outQuat, 1, 2, 3, 4);
outQuat = quat.identity(outQuat);
outQuat = quat.rotationTo(outQuat, vec3A, vec3B);
outQuat = quat.setAxes(outQuat, vec3A, vec3B, vec3A);
outQuat = quat.setAxisAngle(outQuat, vec3A, Math.PI * 0.5);
outVal = quat.getAxisAngle (outVec3, quatA);
outQuat = quat.add(outQuat, quatA, quatB);
outQuat = quat.multiply(outQuat, quatA, quatB);
outQuat = quat.mul(outQuat, quatA, quatB);
outQuat = quat.scale(outQuat, quatA, 2);
outVal = quat.length(quatA);
outVal = quat.len(quatA);
outVal = quat.squaredLength(quatA);
outVal = quat.sqrLen(quatA);
out = quat.normalize(out, quatA);
outVal = quat.dot(out, quatA, quatB);
out = quat.lerp(out, quatA, quatB, 0.5);
out = quat.slerp(out, quatA, quatB, 0.5);
out = quat.invert(out, quatA);
out = quat.conjugate(out, quatA);
outQuat = quat.normalize(outQuat, quatA);
outVal = quat.dot(quatA, quatB);
outQuat = quat.lerp(outQuat, quatA, quatB, 0.5);
outQuat = quat.slerp(outQuat, quatA, quatB, 0.5);
outQuat = quat.invert(outQuat, quatA);
outQuat = quat.conjugate(outQuat, quatA);
outStr = quat.str(quatA);
out = quat.rotateX(out, id, deg90);
out = quat.rotateY(out, id, deg90);
out = quat.rotateZ(out, id, deg90);
matr = [ 1, 0, 0,
0, 0, -1,
0, 1, 0 ];
out = quat.fromMat3(out, matr);
var view = [-1, 0, 0];
up = [ 0, 1, 0];
var right= [ 0, 0,-1];
out = quat.setAxes([], view, right, up);
out = quat.rotationTo(out, [0, 1, 0], [1, 0, 0]);
out = quat.calculateW(out, quatA);
outQuat = quat.rotateX(outQuat, quatA, deg90);
outQuat = quat.rotateY(outQuat, quatA, deg90);
outQuat = quat.rotateZ(outQuat, quatA, deg90);
outQuat = quat.fromMat3(outQuat, mat3A);
outQuat = quat.calculateW(outQuat, quatA);
outBool = quat.exactEquals(quatA, quatB);
outBool = quat.equals(quatA, quatB);

View File

@@ -1,346 +0,0 @@
/// <reference path="gl-matrix-typed.d.ts" />
// common
import {vec2, mat2, mat3, mat4, vec3, vec4, glMatrix, mat2d, quat} from "./gl-matrix-typed";
var result: number = glMatrix.toRadian(180);
var outVal: number;
var outBool: boolean;
var outStr: string;
let vecArray = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
let vec2A = vec2.fromValues(1, 2);
let vec2B = vec2.fromValues(3, 4);
let vec3A = vec3.fromValues(1, 2, 3);
let vec3B = vec3.fromValues(3, 4, 5);
let vec4A = vec4.fromValues(1, 2, 3, 4);
let vec4B = vec4.fromValues(3, 4, 5, 6);
let mat2A = mat2.fromValues(1, 2, 3, 4);
let mat2B = mat2.fromValues(1, 2, 3, 4);
let mat2dA = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat2dB = mat2d.fromValues(1, 2, 3, 4, 5, 6);
let mat3A = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat3B = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat4A = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let mat4B = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let quatA = quat.fromValues(1, 2, 3, 4);
let quatB = quat.fromValues(5, 6, 7, 8);
let outVec2 = vec2.create();
let outVec3 = vec3.create();
let outVec4 = vec4.create();
let outMat2 = mat2.create();
let outMat2d = mat2d.create();
let outMat3 = mat3.create();
let outMat4 = mat4.create();
let outQuat = quat.create();
// vec2
outVec2 = vec2.create();
outVec2 = vec2.clone(vec2A);
outVec2 = vec2.fromValues(1, 2);
outVec2 = vec2.copy(outVec2, vec2A);
outVec2 = vec2.set(outVec2, 1, 2);
outVec2 = vec2.add(outVec2, vec2A, vec2B);
outVec2 = vec2.subtract(outVec2, vec2A, vec2B);
outVec2 = vec2.sub(outVec2, vec2A, vec2B);
outVec2 = vec2.multiply(outVec2, vec2A, vec2B);
outVec2 = vec2.mul(outVec2, vec2A, vec2B);
outVec2 = vec2.divide(outVec2, vec2A, vec2B);
outVec2 = vec2.div(outVec2, vec2A, vec2B);
outVec2 = vec2.ceil(outVec2, vec2A);
outVec2 = vec2.floor(outVec2, vec2A);
outVec2 = vec2.min(outVec2, vec2A, vec2B);
outVec2 = vec2.max(outVec2, vec2A, vec2B);
outVec2 = vec2.round(outVec2, vec2A);
outVec2 = vec2.scale(outVec2, vec2A, 2);
outVec2 = vec2.scaleAndAdd(outVec2, vec2A, vec2B, 0.5);
outVal = vec2.distance(vec2A, vec2B);
outVal = vec2.dist(vec2A, vec2B);
outVal = vec2.squaredDistance(vec2A, vec2B);
outVal = vec2.sqrDist(vec2A, vec2B);
outVal = vec2.length(vec2A);
outVal = vec2.len(vec2A);
outVal = vec2.squaredLength(vec2A);
outVal = vec2.sqrLen(vec2A);
outVec2 = vec2.negate(outVec2, vec2A);
outVec2 = vec2.inverse(outVec2, vec2A);
outVec2 = vec2.normalize(outVec2, vec2A);
outVal = vec2.dot(vec2A, vec2B);
outVec2 = vec2.cross(outVec2, vec2A, vec2B);
outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5);
outVec2 = vec2.random(outVec2);
outVec2 = vec2.random(outVec2, 5.0);
outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A);
outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA);
outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A);
outVec2 = vec2.transformMat4(outVec2, vec2A, mat4A);
vecArray = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize);
outStr = vec2.str(vec2A);
outBool = vec2.exactEquals(vec2A, vec2B);
outBool = vec2.equals(vec2A, vec2B);
// vec3
outVec3 = vec3.create();
outVec3 = vec3.clone(vec3A);
outVec3 = vec3.fromValues(1, 2, 3);
outVec3 = vec3.copy(outVec3, vec3A);
outVec3 = vec3.set(outVec3, 1, 2, 3);
outVec3 = vec3.add(outVec3, vec3A, vec3B);
outVec3 = vec3.subtract(outVec3, vec3A, vec3B);
outVec3 = vec3.sub(outVec3, vec3A, vec3B);
outVec3 = vec3.multiply(outVec3, vec3A, vec3B);
outVec3 = vec3.mul(outVec3, vec3A, vec3B);
outVec3 = vec3.divide(outVec3, vec3A, vec3B);
outVec3 = vec3.div(outVec3, vec3A, vec3B);
outVec3 = vec3.ceil(outVec3, vec3A);
outVec3 = vec3.floor(outVec3, vec3A);
outVec3 = vec3.min(outVec3, vec3A, vec3B);
outVec3 = vec3.max(outVec3, vec3A, vec3B);
outVec3 = vec3.round(outVec3, vec3A);
outVec3 = vec3.scale(outVec3, vec3A, 2);
outVec3 = vec3.scaleAndAdd(outVec3, vec3A, vec3B, 0.5);
outVal = vec3.distance(vec3A, vec3B);
outVal = vec3.dist(vec3A, vec3B);
outVal = vec3.squaredDistance(vec3A, vec3B);
outVal = vec3.sqrDist(vec3A, vec3B);
outVal = vec3.length(vec3A);
outVal = vec3.len(vec3A);
outVal = vec3.squaredLength(vec3A);
outVal = vec3.sqrLen(vec3A);
outVec3 = vec3.negate(outVec3, vec3A);
outVec3 = vec3.inverse(outVec3, vec3A);
outVec3 = vec3.normalize(outVec3, vec3A);
outVal = vec3.dot(vec3A, vec3B);
outVec3 = vec3.cross(outVec3, vec3A, vec3B);
outVec3 = vec3.lerp(outVec3, vec3A, vec3B, 0.5);
outVec3 = vec3.hermite(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.bezier(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.random(outVec3);
outVec3 = vec3.random(outVec3, 5.0);
outVec3 = vec3.transformMat3(outVec3, vec3A, mat3A);
outVec3 = vec3.transformMat4(outVec3, vec3A, mat4A);
outVec3 = vec3.transformQuat(outVec3, vec3A, quatA);
outVec3 = vec3.rotateX(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateY(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateZ(outVec3, vec3A, vec3B, Math.PI);
vecArray = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize);
outVal = vec3.angle(vec3A, vec3B);
outStr = vec3.str(vec3A);
outBool = vec3.exactEquals(vec3A, vec3B);
outBool = vec3.equals(vec3A, vec3B);
// vec4
outVec4 = vec4.create();
outVec4 = vec4.clone(vec4A);
outVec4 = vec4.fromValues(1, 2, 3, 4);
outVec4 = vec4.copy(outVec4, vec4A);
outVec4 = vec4.set(outVec4, 1, 2, 3, 4);
outVec4 = vec4.add(outVec4, vec4A, vec4B);
outVec4 = vec4.subtract(outVec4, vec4A, vec4B);
outVec4 = vec4.sub(outVec4, vec4A, vec4B);
outVec4 = vec4.multiply(outVec4, vec4A, vec4B);
outVec4 = vec4.mul(outVec4, vec4A, vec4B);
outVec4 = vec4.divide(outVec4, vec4A, vec4B);
outVec4 = vec4.div(outVec4, vec4A, vec4B);
outVec4 = vec4.ceil(outVec4, vec4A);
outVec4 = vec4.floor(outVec4, vec4A);
outVec4 = vec4.min(outVec4, vec4A, vec4B);
outVec4 = vec4.max(outVec4, vec4A, vec4B);
outVec4 = vec4.scale(outVec4, vec4A, 2);
outVec4 = vec4.scaleAndAdd(outVec4, vec4A, vec4B, 0.5);
outVal = vec4.distance(vec4A, vec4B);
outVal = vec4.dist(vec4A, vec4B);
outVal = vec4.squaredDistance(vec4A, vec4B);
outVal = vec4.sqrDist(vec4A, vec4B);
outVal = vec4.length(vec4A);
outVal = vec4.len(vec4A);
outVal = vec4.squaredLength(vec4A);
outVal = vec4.sqrLen(vec4A);
outVec4 = vec4.negate(outVec4, vec4A);
outVec4 = vec4.inverse(outVec4, vec4A);
outVec4 = vec4.normalize(outVec4, vec4A);
outVal = vec4.dot(vec4A, vec4B);
outVec4 = vec4.lerp(outVec4, vec4A, vec4B, 0.5);
outVec4 = vec4.random(outVec4);
outVec4 = vec4.random(outVec4, 5.0);
outVec4 = vec4.transformMat4(outVec4, vec4A, mat4A);
outVec4 = vec4.transformQuat(outVec4, vec4A, quatA);
vecArray = vec4.forEach(vecArray, 0, 0, 0, vec4.normalize);
outStr = vec4.str(vec4A);
outBool = vec4.exactEquals(vec4A, vec4B);
outBool = vec4.equals(vec4A, vec4B);
// mat2
outMat2 = mat2.create();
outMat2 = mat2.clone(mat2A);
outMat2 = mat2.copy(outMat2, mat2A);
outMat2 = mat2.identity(outMat2);
outMat2 = mat2.fromValues(1, 2, 3, 4);
outMat2 = mat2.set(outMat2, 1, 2, 3, 4);
outMat2 = mat2.transpose(outMat2, mat2A);
outMat2 = mat2.invert(outMat2, mat2A);
outMat2 = mat2.adjoint(outMat2, mat2A);
outVal = mat2.determinant(mat2A);
outMat2 = mat2.multiply(outMat2, mat2A, mat2B);
outMat2 = mat2.mul(outMat2, mat2A, mat2B);
outMat2 = mat2.rotate(outMat2, mat2A, Math.PI * 0.5);
outMat2 = mat2.scale(outMat2, mat2A, vec2A);
outMat2 = mat2.fromRotation(outMat2, 0.5);
outMat2 = mat2.fromScaling(outMat2, vec2A);
outStr = mat2.str(mat2A);
outVal = mat2.frob(mat2A);
var L = mat2.create();
var D = mat2.create();
var U = mat2.create();
outMat2 = mat2.LDU(L, D, U, mat2A);
outMat2 = mat2.add(outMat2, mat2A, mat2B);
outMat2 = mat2.subtract(outMat2, mat2A, mat2B);
outMat2 = mat2.sub(outMat2, mat2A, mat2B);
outBool = mat2.exactEquals(mat2A, mat2B);
outBool = mat2.equals(mat2A, mat2B);
outMat2 = mat2.multiplyScalar (outMat2, mat2A, 2);
outMat2 = mat2.multiplyScalarAndAdd (outMat2, mat2A, mat2B, 2);
// mat2d
outMat2d = mat2d.create();
outMat2d = mat2d.clone(mat2dA);
outMat2d = mat2d.copy(outMat2d, mat2dA);
outMat2d = mat2d.identity(outMat2d);
outMat2d = mat2d.fromValues(1, 2, 3, 4, 5, 6);
outMat2d = mat2d.set(outMat2d, 1, 2, 3, 4, 5, 6);
outMat2d = mat2d.invert(outMat2d, mat2dA);
outVal = mat2d.determinant(mat2dA);
outMat2d = mat2d.multiply(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.mul(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.rotate(outMat2d, mat2dA, Math.PI * 0.5);
outMat2d = mat2d.scale(outMat2d, mat2dA, vec2A);
outMat2d = mat2d.translate(outMat2d, mat2dA, vec2A);
outMat2d = mat2d.fromRotation(outMat2d, 0.5);
outMat2d = mat2d.fromScaling(outMat2d, vec2A);
outMat2d = mat2d.fromTranslation(outMat2d, vec2A);
outStr = mat2d.str(mat2dA);
outVal = mat2d.frob(mat2dA);
outMat2d = mat2d.add(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.subtract(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.sub(outMat2d, mat2dA, mat2dB);
outMat2d = mat2d.multiplyScalar (outMat2d, mat2dA, 2);
outMat2d = mat2d.multiplyScalarAndAdd (outMat2d, mat2dA, mat2dB, 2);
outBool = mat2d.exactEquals(mat2dA, mat2dB);
outBool = mat2d.equals(mat2dA, mat2dB);
// mat3
outMat3 = mat3.create();
outMat3 = mat3.fromMat4(outMat3, mat4A);
outMat3 = mat3.clone(mat3A);
outMat3 = mat3.copy(outMat3, mat3A);
outMat3 = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9);
outMat3 = mat3.set(outMat3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
outMat3 = mat3.identity(outMat3);
outMat3 = mat3.transpose(outMat3, mat3A);
outMat3 = mat3.invert(outMat3, mat3A);
outMat3 = mat3.adjoint(outMat3, mat3A);
outVal = mat3.determinant(mat3A);
outMat3 = mat3.multiply(outMat3, mat3A, mat3B);
outMat3 = mat3.mul(outMat3, mat3A, mat3B);
outMat3 = mat3.translate(outMat3, mat3A, vec3A);
outMat3 = mat3.rotate(outMat3, mat3A, Math.PI/2);
outMat3 = mat3.scale(outMat3, mat3A, vec2A);
outMat3 = mat3.fromTranslation(outMat3, vec2A);
outMat3 = mat3.fromRotation(outMat3, Math.PI);
outMat3 = mat3.fromScaling(outMat3, vec2A);
outMat3 = mat3.fromMat2d(outMat3, mat2dA);
outMat3 = mat3.fromQuat(outMat3, quatA);
outMat3 = mat3.normalFromMat4(outMat3, mat4A);
outStr = mat3.str(mat3A);
outVal = mat3.frob(mat3A);
outMat3 = mat3.add(outMat3, mat3A, mat3B);
outMat3 = mat3.subtract(outMat3, mat3A, mat3B);
outMat3 = mat3.sub(outMat3, mat3A, mat3B);
outMat3 = mat3.multiplyScalar (outMat3, mat3A, 2);
outMat3 = mat3.multiplyScalarAndAdd (outMat3, mat3A, mat3B, 2);
outBool = mat3.exactEquals(mat3A, mat3B);
outBool = mat3.equals(mat3A, mat3B);
//mat4
outMat4 = mat4.create();
outMat4 = mat4.clone(mat4A);
outMat4 = mat4.copy(outMat4, mat4A);
outMat4 = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
outMat4 = mat4.set(outMat4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
outMat4 = mat4.identity(outMat4);
outMat4 = mat4.transpose(outMat4, mat4A);
outMat4 = mat4.invert(outMat4, mat4A);
outMat4 = mat4.adjoint(outMat4, mat4A);
outVal = mat4.determinant(mat4A);
outMat4 = mat4.multiply(outMat4, mat4A, mat4B);
outMat4 = mat4.mul(outMat4, mat4A, mat4B);
outMat4 = mat4.translate(outMat4, mat4A, vec3A);
outMat4 = mat4.scale(outMat4, mat4A, vec3A);
outMat4 = mat4.rotate(outMat4, mat4A, Math.PI, vec3A);
outMat4 = mat4.rotateX(outMat4, mat4A, Math.PI);
outMat4 = mat4.rotateY(outMat4, mat4A, Math.PI);
outMat4 = mat4.rotateZ(outMat4, mat4A, Math.PI);
outMat4 = mat4.fromTranslation(outMat4, vec3A);
outMat4 = mat4.fromRotation(outMat4, Math.PI, vec3A);
outMat4 = mat4.fromScaling(outMat4, vec3A);
outMat4 = mat4.fromXRotation(outMat4, Math.PI);
outMat4 = mat4.fromYRotation(outMat4, Math.PI);
outMat4 = mat4.fromZRotation(outMat4, Math.PI);
outMat4 = mat4.fromRotationTranslation(outMat4, quatA, vec3A);
outVec3 = mat4.getTranslation(outVec3, mat4A)
outQuat = mat4.getRotation(outQuat, mat4A)
outMat4 = mat4.fromRotationTranslationScale(outMat4, quatA, vec3A, vec3B);
outMat4 = mat4.fromRotationTranslationScaleOrigin(outMat4, quatA, vec3A, vec3B, vec3A);
outMat4 = mat4.fromQuat(outMat4, quatB);
outMat4 = mat4.frustum(outMat4, -1, 1, -1, 1, -1, 1);
outMat4 = mat4.perspective(outMat4, Math.PI, 1, 0, 1);
outMat4 = mat4.perspectiveFromFieldOfView(outMat4, {upDegrees:Math.PI, downDegrees:-Math.PI, leftDegrees:-Math.PI, rightDegrees:Math.PI}, 1, 0);
outMat4 = mat4.ortho(outMat4, -1, 1, -1, 1, -1, 1);
outMat4 = mat4.lookAt(outMat4, vec3A, vec3B, vec3A);
outStr = mat4.str(mat4A);
outVal = mat4.frob(mat4A);
outMat4 = mat4.add(outMat4, mat4A, mat4B);
outMat4 = mat4.subtract(outMat4, mat4A, mat4B);
outMat4 = mat4.sub(outMat4, mat4A, mat4B);
outMat4 = mat4.multiplyScalar (outMat4, mat4A, 2);
outMat4 = mat4.multiplyScalarAndAdd (outMat4, mat4A, mat4B, 2);
outBool = mat4.exactEquals(mat4A, mat4B);
outBool = mat4.equals(mat4A, mat4B);
// quat
var deg90 = Math.PI / 2;
outQuat = quat.create();
outQuat = quat.clone(quatA);
outQuat = quat.fromValues(1, 2, 3, 4);
outQuat = quat.copy(outQuat, quatA);
outQuat = quat.set(outQuat, 1, 2, 3, 4);
outQuat = quat.identity(outQuat);
outQuat = quat.rotationTo(outQuat, vec3A, vec3B);
outQuat = quat.setAxes(outQuat, vec3A, vec3B, vec3A);
outQuat = quat.setAxisAngle(outQuat, vec3A, Math.PI * 0.5);
outVal = quat.getAxisAngle (outVec3, quatA);
outQuat = quat.add(outQuat, quatA, quatB);
outQuat = quat.multiply(outQuat, quatA, quatB);
outQuat = quat.mul(outQuat, quatA, quatB);
outQuat = quat.scale(outQuat, quatA, 2);
outVal = quat.length(quatA);
outVal = quat.len(quatA);
outVal = quat.squaredLength(quatA);
outVal = quat.sqrLen(quatA);
outQuat = quat.normalize(outQuat, quatA);
outVal = quat.dot(quatA, quatB);
outQuat = quat.lerp(outQuat, quatA, quatB, 0.5);
outQuat = quat.slerp(outQuat, quatA, quatB, 0.5);
outQuat = quat.invert(outQuat, quatA);
outQuat = quat.conjugate(outQuat, quatA);
outStr = quat.str(quatA);
outQuat = quat.rotateX(outQuat, quatA, deg90);
outQuat = quat.rotateY(outQuat, quatA, deg90);
outQuat = quat.rotateZ(outQuat, quatA, deg90);
outQuat = quat.fromMat3(outQuat, mat3A);
outQuat = quat.calculateW(outQuat, quatA);
outBool = quat.exactEquals(quatA, quatB);
outBool = quat.equals(quatA, quatB);

File diff suppressed because it is too large Load Diff

1697
gl-matrix/gl-matrix.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
// Definitions by: Yang Guan <https://github.com/lookuptable>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/*
* Configuration object of a heatmap

View File

@@ -0,0 +1,21 @@
/// <reference path="../i18next/i18next"/>
/// <reference path="i18next-xhr-backend.d.ts"/>
import * as i18next from 'i18next';
import XHR from 'i18next-xhr-backend';
let options = {
loadPath: '',
addPath: '',
allowMultiLoading: false,
parse: function(data:string) { return data.replace(/a/g, ''); },
crossDomain: false,
withCredentials: false,
ajax: function (url:string, options:Object, callback: Function, data: Object) {}
};
i18next.use(XHR).init({
backend: options
});
let xhr = new XHR(null, options);

View File

@@ -0,0 +1,36 @@
// Type definitions for i18next-xhr-backend 1.2.0
// Project: https://github.com/i18next/i18next-xhr-backend
// Definitions by: Jan Mühlemann <https://github.com/jamuhl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'i18next-xhr-backend' {
interface Interpolator {
interpolate: () => string
}
interface Services {
interpolator: Interpolator
}
interface BackendOptions {
loadPath?: string | Function,
addPath?: string,
allowMultiLoading?: boolean,
parse?: Function,
crossDomain?: boolean,
withCredentials?: boolean,
ajax?: Function
}
export default class Backend {
type: 'backend';
services: Services;
options: BackendOptions;
constructor(services?: Services, options?: BackendOptions);
init(services?: Services, options?: BackendOptions): void;
readMulti(languages: any[], namespaces: any[], callback: Function): void;
read(language: {}, namespace: {}, callback: Function): void;
loadUrl(url: string, callback: Function): void;
create(languages: any[], namespace: string, key: string, fallbackValue: string): void;
}
}

View File

@@ -1,4 +1,5 @@
/// <reference path="jest.d.ts" />
/// <reference path="../node/node.d.ts" />
// Tests based on the Jest website
jest.unmock('../sum');
@@ -37,8 +38,6 @@ describe('fetchCurrentUser', function() {
// unmock is the recommended approach for unmocking...
jest.unmock('../displayUser.js')
// ...but dontMock also still works.
jest.dontMock('jquery');
describe('displayUser', function() {
it('displays a user after a click', function() {
@@ -100,6 +99,157 @@ describe('CheckboxWithLabel', function() {
});
});
jest.runAllTicks();
xdescribe('Hooks and Suits', function () {
let tested: boolean;
beforeEach(function () {
tested = false;
});
afterEach(function () {
tested = true;
});
test('tested', function () {
expect(tested).toBeTruthy();
expect(tested).not.toBeFalsy();
});
fit('tested', function () {
expect(tested).toBeDefined();
expect(tested).not.toBeUndefined();
});
xit('expect null to be null', function () {
expect(null).toBeNull();
});
});
describe('compartion', function () {
var sum: (a: number, b: number) => number = require.requireMock('../sum');
it('compares is 7 + 2 greater than 3', function () {
expect(sum(7, 2)).toBeGreaterThan(3);
});
it('compares is 2 + 7 greater than or equal to 3', function () {
expect(sum(2, 7)).toBeGreaterThanOrEqual(3);
});
it('compares is 3 less than 3 + 4', function () {
expect(3).toBeLessThan(sum(3, 4));
});
it('compares is 3 less than or equal to 4 + 3', function () {
expect(3).toBeLessThanOrEqual(sum(4, 3));
});
it('works sanely with simple decimals', function () {
expect(0.2 + 0.1).toBeCloseTo(0.3, 5);
});
});
describe('toThrow API', function () {
function throwTypeError(): void {
throw new TypeError('toThrow Definition was out of date');
}
it('throws', function () {
expect(throwTypeError()).toThrow();
});
it('throws TypeError', function () {
expect(throwTypeError()).toThrowError(TypeError);
});
it('throws \'Definition was out of date\'', function () {
expect(throwTypeError()).toThrowError(/Definition was out of date/);
});
it('throws \'toThorow Definition was out of date\'', function () {
expect(throwTypeError()).toThrowError('toThrow Definition was out of date');
});
});
describe('missing tests', function () {
it('creates closures', function () {
class Closure<T> {
private arg: T;
public constructor(private fn: (arg: T) => void) {
this.fn = fn;
}
public bind(arg: T): void {
this.arg = arg;
}
public call(): void {
this.fn(this.arg);
}
}
type StringClosure = (arg: string) => void;
let spy: jest.Mock<StringClosure> = jest.fn<StringClosure>();
let closure: Closure<string> = new Closure<string>(spy);
closure.bind('jest');
closure.call();
expect(spy).lastCalledWith('jest');
expect(spy).toBeCalledWith('jest');
expect(jest.isMockFunction(spy)).toBeTruthy();
});
it('tests all mising Mocks functionality', function () {
type FruitsGetter = () => Array<string>;
let mock: jest.Mock<FruitsGetter> = jest.fn<FruitsGetter>();
mock.mockImplementationOnce(() => ['Orange', 'Apple', 'Plum'])
jest.setMock('./../tesks/getFruits', mock);
const getFruits: FruitsGetter = require('./../tesks/getFruits');
expect(getFruits()).toContain('Orange');
mock.mockReturnValueOnce(['Apple', 'Plum']);
expect(mock()).not.toContain('Orange');
mock.mockReturnValue([]); //Deprecated: Use jest.fn(() => value) instead.
mock.mockClear();
let thisMock: jest.Mock<any> = jest.fn<any>().mockReturnThis();
expect(thisMock()).toBe(this);
});
it('creates snapshoter', function () {
jest.disableAutomock();
jest.mock('./render', () => jest.fn((): string => "{Link to: \"facebook\"}"), { virtual: true });
const render: () => string = require('./render');
expect(render()).toMatch(/Link/);
jest.enableAutomock();
});
it('runs only pending timers', function () {
jest.useRealTimers();
setTimeout(() => expect(1).not.toEqual(0), 3000);
jest.runOnlyPendingTimers();
});
it('runs all timers', function () {
jest.clearAllTimers();
jest.useFakeTimers();
setTimeout(() => expect(0).not.toEqual(1), 3000);
jest.runAllTimers();
});
it('cleares cache', function () {
const sum1 = require('../sum');
jest.resetModules();
const sum2 = require('../sum');
expect(sum1).not.toBe(sum2);
})
});
describe('toMatchSnapshot', function () {
it('compares snapshots', function () {
expect({ type: 'a', props: { href: 'https://www.facebook.com/' }, children: [ 'Facebook' ] }).toMatchSnapshot();
});
});
function testInstances() {
var mockFn = jest.fn<Function>();
var a = new mockFn();
@@ -123,3 +273,82 @@ function testMockImplementation() {
mockFn.mock.calls[0][0] === 0; // true
mockFn.mock.calls[1][0] === 1; // true
}
// Test from jest Docs: <http://facebook.github.io/jest/docs/manual-mocks.html#content>
describe('genMockFromModule', function () {
// Interfaces:
interface MockFiles {
[index: string]: string;
}
interface MockedFS {
readdirSync: (dir: string) => string[];
__setMockFiles: (newMockFiles: MockFiles) => void ;
}
// ------------------------------------------------------------------------------------
// FileSummarizer.ts
const fs = require('fs');
function summarizeFilesInDirectorySync(directory: string): string[] {
return fs.readdirSync(directory).map((fileName: string) => ({
fileName,
directory,
}));
}
//export default summarizeFilesInDirectorySync; // For sake of compilation
// ------------------------------------------------------------------------------------
// __mocks__/fs.js
const path = require('path');
const mockedFS: MockedFS = jest.genMockFromModule<MockedFS>('fs');
let mockFiles: any = Object.create(null);
function __setMockFiles(newMockFiles: MockFiles): void {
mockFiles = Object.create(null);
for(const file in newMockFiles) {
const dir: string = path.dirname(file);
if (!mockFiles[dir]) {
mockFiles[dir] = [];
}
mockFiles[dir].push(path.basename(file));
}
}
function readdirSync(directoryPath: string): string[] {
return mockFiles[directoryPath] || [];
}
mockedFS.readdirSync = readdirSync;
mockedFS.__setMockFiles = __setMockFiles;
//export = mockedFS; // For sake of compilation
// ------------------------------------------------------------------------------------
// __tests__/FileSummarizer-test.js
jest.mock('fs');
describe('listFilesInDirectorySync', () => {
const MOCK_FILE_INFO: MockFiles = {
'/path/to/file1.js': 'console.log("file1 contents");',
'/path/to/file2.txt': 'file2 contents',
};
beforeEach(() => {
// Set up some mocked out file info before each test
(require('fs') as MockedFS).__setMockFiles(MOCK_FILE_INFO);
});
it('includes all files in the directory in the summary', () => {
const FileSummarizer: (dir: string) => string[] = require('../FileSummarizer');
const fileSummary = FileSummarizer('/path/to');
expect(fileSummary.length).toBe(2);
});
});
});

263
jest/jest.d.ts vendored
View File

@@ -1,79 +1,150 @@
// Type definitions for Jest 0.9.0
// Type definitions for Jest 15.1.1
// Project: http://facebook.github.io/jest/
// Definitions by: Asana <https://asana.com>
// Definitions by: Asana <https://asana.com>, Ivo Stratev <https://github.com/NoHomey>, jwbay <https://github.com/jwbay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare function afterEach(fn: jest.EmptyFunction): void;
declare function beforeEach(fn: jest.EmptyFunction): void;
declare function describe(name: string, fn: jest.EmptyFunction): void;
declare var beforeAll: jest.Lifecycle;
declare var beforeEach: jest.Lifecycle;
declare var afterAll: jest.Lifecycle;
declare var afterEach: jest.Lifecycle;
declare var describe: jest.Describe;
declare var fdescribe: jest.Describe;
declare var xdescribe: jest.Describe;
declare var it: jest.It;
declare function pit(name: string, fn: jest.EmptyFunction): void;
declare function xdescribe(name: string, fn: jest.EmptyFunction): void;
declare function xit(name: string, fn: jest.EmptyFunction): void;
declare var fit: jest.It;
declare var xit: jest.It;
declare var test: jest.It;
declare var xtest: jest.It;
declare function expect(actual: any): jest.Matchers;
interface NodeRequire {
/** Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not. */
requireActual(moduleName: string): any;
/** Returns a mock module instead of the actual module, bypassing all checks on whether the module should be required normally or not. */
requireMock(moduleName: string): any;
}
declare namespace jest {
function addMatchers(matchers: CustomMatcherFactories): void;
function addMatchers(matchers: jasmine.CustomMatcherFactories): void;
/** Disables automatic mocking in the module loader. */
function autoMockOff(): void;
/** Enables automatic mocking in the module loader. */
function autoMockOn(): void;
/** Removes any pending timers from the timer system. If any timers have been scheduled, they will be cleared and will never have the opportunity to execute in the future. */
function clearAllTimers(): void;
function currentTestPath(): string;
/** Indicates that the module system should never return a mocked version of the specified module, including all of the specificied module's dependencies. */
function deepUnmock(moduleName: string): void;
/** Disables automatic mocking in the module loader. */
function disableAutomock(): void;
function fn<T>(implementation?: Function): Mock<T>;
/** Mocks a module with an auto-mocked version when it is being required. */
function doMock(moduleName: string): void;
/** Indicates that the module system should never return a mocked version of the specified module from require() (e.g. that it should always return the real module). */
function dontMock(moduleName: string): void;
function genMockFromModule<T>(moduleName: string): Mock<T>;
function mock(moduleName: string, factory?: Function): void;
/** Enables automatic mocking in the module loader. */
function enableAutomock(): void;
/** Creates a mock function. Optionally takes a mock implementation. */
function fn<T>(implementation?: Function): Mock<T>;
/** Use the automatic mocking system to generate a mocked version of the given module. */
function genMockFromModule<T>(moduleName: string): T;
/** Returns whether the given function is a mock function. */
function isMockFunction(fn: any): fn is Mock<any>;
/** Mocks a module with an auto-mocked version when it is being required. */
function mock(moduleName: string, factory?: any, options?: MockOptions): void;
/** Resets the module registry - the cache of all required modules. This is useful to isolate modules where local state might conflict between tests. */
function resetModuleRegistry(): void;
/** Resets the module registry - the cache of all required modules. This is useful to isolate modules where local state might conflict between tests. */
function resetModules(): void;
/** Exhausts tasks queued by setImmediate(). */
function runAllImmediates(): void;
/** Exhausts the micro-task queue (usually interfaced in node via process.nextTick). */
function runAllTicks(): void;
/** Exhausts the macro-task queue (i.e., all tasks queued by setTimeout() and setInterval()). */
function runAllTimers(): void;
/** Executes only the macro-tasks that are currently pending (i.e., only the tasks that have been queued by setTimeout() or setInterval() up to this point).
* If any of the currently pending macro-tasks schedule new macro-tasks, those new tasks will not be executed by this call. */
function runOnlyPendingTimers(): void;
/** Explicitly supplies the mock object that the module system should return for the specified module. */
function setMock<T>(moduleName: string, moduleExports: T): void;
/** Indicates that the module system should never return a mocked version of the specified module from require() (e.g. that it should always return the real module). */
function unmock(moduleName: string): void;
/** Instructs Jest to use fake versions of the standard timer functions. */
function useFakeTimers(): void;
/** Instructs Jest to use the real versions of the standard timer functions. */
function useRealTimers(): void;
interface MockOptions {
virtual?: boolean;
}
interface EmptyFunction {
(): void;
}
interface Matchers {
not: Matchers;
toThrow(expected?: any): boolean;
toThrowError(expected?: any): boolean;
toBe(expected: any): boolean;
toEqual(expected: any): boolean;
toBeFalsy(): boolean;
toBeTruthy(): boolean;
toBeNull(): boolean;
toBeDefined(): boolean;
toBeUndefined(): boolean;
toMatch(expected: RegExp): boolean;
toContain(expected: string): boolean;
toBeCloseTo(expected: number, delta: number): boolean;
toBeGreaterThan(expected: number): boolean;
toBeLessThan(expected: number): boolean;
toBeCalled(): boolean;
toBeCalledWith(...args: any[]): boolean;
lastCalledWith(...args: any[]): boolean;
interface DoneCallback {
(...args: any[]): any
fail(error?: string | { message: string }): any;
}
interface ProvidesCallback {
(cb?: DoneCallback): any;
}
interface Lifecycle {
(fn: ProvidesCallback): any;
}
interface It {
(name: string, fn: EmptyFunction): void;
only(name: string, fn: EmptyFunction): void;
(name: string, fn: ProvidesCallback): void;
only: It;
skip: It;
}
interface Mock<T> {
interface Describe {
(name: string, fn: EmptyFunction): void
only: Describe;
skip: Describe;
}
interface Matchers {
not: Matchers;
lastCalledWith(...args: any[]): void;
toBe(expected: any): void;
toBeCalled(): void;
toBeCalledWith(...args: any[]): void;
toBeCloseTo(expected: number, delta: number): void;
toBeDefined(): void;
toBeFalsy(): void;
toBeGreaterThan(expected: number): void;
toBeGreaterThanOrEqual(expected: number): void;
toBeInstanceOf(expected: any): void
toBeLessThan(expected: number): void;
toBeLessThanOrEqual(expected: number): void;
toBeNull(): void;
toBeTruthy(): void;
toBeUndefined(): void;
toContain(expected: any): void;
toEqual(expected: any): void;
toHaveBeenCalled(): boolean;
toHaveBeenCalledTimes(expected: number): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toMatch(expected: string | RegExp): void;
toMatchSnapshot(): void;
toThrow(): void;
toThrowError(error?: string | Constructable | RegExp): void;
}
interface Constructable {
new (...args: any[]): any
}
interface Mock<T> extends Function {
new (): T;
(...args: any[]): any; // TODO please fix this line! added for TypeScript 1.1.0-1 https://github.com/DefinitelyTyped/DefinitelyTyped/pull/2932
(...args: any[]): any;
mock: MockContext<T>;
mockClear(): void;
mockImplementation(fn: Function): Mock<T>;
mockImpl(fn: Function): Mock<T>;
mockImplementationOnce(fn: Function): Mock<T>;
mockReturnThis(): Mock<T>;
mockReturnValue(value: any): Mock<T>;
mockReturnValueOnce(value: any): Mock<T>;
@@ -83,42 +154,138 @@ declare namespace jest {
calls: any[][];
instances: T[];
}
}
//Jest ships with a copy of Jasmine. They monkey-patch its APIs and divergence/deprecation are expected.
//Relevant parts of Jasmine's API are below so they can be changed and removed over time.
//This file can't reference jasmine.d.ts since the globals aren't compatible.
declare function spyOn(object: any, method: string): jasmine.Spy;
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
declare function pending(reason?: string): void;
/** Fails a test when called within one. */
declare function fail(error?: any): void;
declare namespace jasmine {
var clock: () => Clock;
function any(aclass: any): Any;
function anything(): Any;
function arrayContaining(sample: any[]): ArrayContaining;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
function pp(value: any): string;
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
function addMatchers(matchers: CustomMatcherFactories): void;
function stringMatching(value: string | RegExp): Any;
interface Clock {
install(): void;
uninstall(): void;
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
tick(ms: number): void;
mockDate(date?: Date): void;
}
interface Any {
new (expectedClass: any): any;
jasmineMatches(other: any): boolean;
jasmineToString(): string;
}
interface ArrayContaining {
new (sample: any[]): any;
asymmetricMatch(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
}
interface Spy {
(...params: any[]): any;
identity: string;
and: SpyAnd;
calls: Calls;
mostRecentCall: { args: any[]; };
argsForCall: any[];
wasCalled: boolean;
}
interface SpyAnd {
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
callThrough(): Spy;
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
returnValue(val: any): Spy;
/** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */
returnValues(...values: any[]): Spy;
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
callFake(fn: Function): Spy;
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
throwError(msg: string): Spy;
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
stub(): Spy;
}
interface Calls {
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. */
any(): boolean;
/** By chaining the spy with calls.count(), will return the number of times the spy was called */
count(): number;
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index */
argsFor(index: number): any[];
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls */
allArgs(): any[];
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls */
all(): CallInfo[];
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call */
mostRecent(): CallInfo;
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call */
first(): CallInfo;
/** By chaining the spy with calls.reset(), will clears all tracking for a spy */
reset(): void;
}
interface CallInfo {
/** The context (the this) for the call */
object: any;
/** All arguments passed to the call */
args: any[];
/** The return value of the call */
returnValue: any;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherFactory {
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface MatchersUtil {
equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomEqualityTester {
(first: any, second: any): boolean;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcher {
compare<T>(actual: T, expected: T): CustomMatcherResult;
compare(actual: any, expected: any): CustomMatcherResult;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherResult {
pass: boolean;
message: string;
message: string | (() => string);
}
// taken from Jasmine which takes from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
interface ArrayLike<T> {
length: number;
[n: number]: T;

View File

@@ -82,21 +82,21 @@ $(document).ready(function () {
width: "200px"
}
col =
{
data: "",
orderData: [10, 11, 20],
render: "",
}
{
data: "",
orderData: [10, 11, 20],
render: "",
}
col =
{
data: colDataObject,
render: colRenderObject,
}
{
data: colDataObject,
render: colRenderObject,
}
col =
{
data: colDataFunc,
render: colRenderFunc,
}
{
data: colDataFunc,
render: colRenderFunc,
}
//#endregion "Column"
@@ -124,16 +124,16 @@ $(document).ready(function () {
};
colDef =
{
targets: "2",
cellType: "th",
};
{
targets: "2",
cellType: "th",
};
colDef =
{
targets: ["2", 5],
cellType: "th",
};
{
targets: ["2", 5],
cellType: "th",
};
//#endregion "ColumnDef"
@@ -159,7 +159,7 @@ $(document).ready(function () {
var ajaxFunc: DataTables.FunctionAjax = function (data, callback, settings) { };
var ajaxDataFunc: DataTables.FunctionAjaxData = function (data) {
var ajaxDataFunc: DataTables.FunctionAjaxData = function (data, settings) {
return data;
};
@@ -229,41 +229,41 @@ $(document).ready(function () {
config =
{
ajax: ajaxFunc,
deferLoading: [10, 100],
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
order: [0, 'asc'],
orderFixed: [[0, 'asc'], [1, 'asc']],
renderer: {
header: "bootstrap",
pageButton: "jqueryui"
},
search: { "search": "", "smart": true, "regex": false, "caseInsensitive": true },
searchCols: [
null,
{ "search": "", "smart": true, "regex": false, "caseInsensitive": true },
{ "search": "" },
{ "search": "", "smart": true },
null
],
};
{
ajax: ajaxFunc,
deferLoading: [10, 100],
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
order: [0, 'asc'],
orderFixed: [[0, 'asc'], [1, 'asc']],
renderer: {
header: "bootstrap",
pageButton: "jqueryui"
},
search: { "search": "", "smart": true, "regex": false, "caseInsensitive": true },
searchCols: [
null,
{ "search": "", "smart": true, "regex": false, "caseInsensitive": true },
{ "search": "" },
{ "search": "", "smart": true },
null
],
};
config =
{
ajax: {
data: {},
dataSrc: "",
},
};
{
ajax: {
data: {},
dataSrc: "",
},
};
config =
{
ajax: {
data: ajaxDataFunc,
dataSrc: function (data) { },
},
};
{
ajax: {
data: ajaxDataFunc,
dataSrc: function (data) { },
},
};
//#endregion "Settings"
@@ -309,6 +309,8 @@ $(document).ready(function () {
draw = dt.draw(true);
draw.$("");
var initSettings = dt.init();
var off = dt.off("event");
off = dt.off("event", function () { });
off.$("");
@@ -385,11 +387,11 @@ $(document).ready(function () {
var select = $('<select />')
.appendTo('body')
.on('change', function () {
dt
.column(0)
.search($(this).val())
.draw();
});
dt
.column(0)
.search($(this).val())
.draw();
});
// Get the search data for the first column and add to the select list
var data = dt
.cells('', 0)
@@ -397,8 +399,8 @@ $(document).ready(function () {
.sort()
.unique()
.each(function (d) {
select.append($('<option value="' + d + '">' + d + '</option>'));
});
select.append($('<option value="' + d + '">' + d + '</option>'));
});
var cells_data = cells.data();
var data = dt
@@ -438,6 +440,9 @@ $(document).ready(function () {
console.log(data);
});
cells.every(function () { });
cells.every(function (cellRowIdx, cellColIdx, tableLoop, cellLoop) { });
var cell = dt.cell(":contains('Not shipped')");
cell = dt.cell(function () { });
cell = dt.cell($(""));
@@ -519,12 +524,12 @@ $(document).ready(function () {
dt.column(colIdx).footer()
)
.on('change', function () {
dt
.column(colIdx)
.search($(this).val())
.draw();
});
dt
.column(colIdx)
.search($(this).val())
.draw();
});
// Get the search data for the first column and add to the select list
dt
.column(colIdx)
@@ -532,8 +537,8 @@ $(document).ready(function () {
.sort()
.unique()
.each(function (d) {
select.append($('<option value="' + d + '">' + d + '</option>'));
});
select.append($('<option value="' + d + '">' + d + '</option>'));
});
});
var columns_data = columns.data();
@@ -545,7 +550,7 @@ $(document).ready(function () {
.sort() // Sort data alphabetically
.unique() // Reduce to unique values
.join('<br>')
);
);
//var idx = dt
// .columns('.check')
@@ -603,12 +608,12 @@ $(document).ready(function () {
dt.column(0).footer()
)
.on('change', function () {
dt
.column(0)
.search($(this).val())
.draw();
});
dt
.column(0)
.search($(this).val())
.draw();
});
// Get the search data for the first column and add to the select list
dt
.column(0)
@@ -616,18 +621,18 @@ $(document).ready(function () {
.sort()
.unique()
.each(function (d) {
select.append($('<option value="' + d + '">' + d + '</option>'));
});
select.append($('<option value="' + d + '">' + d + '</option>'));
});
var column_data = column.data();
alert('Column 4 sum: ' +
dt
.column(4)
.data()
.reduce(function (a, b) {
return a + b;
})
);
.reduce(function (a, b) {
return a + b;
})
);
var column_dataSrc = column.dataSrc();
$('#example').on('click', 'tbody td', function () {
@@ -688,11 +693,11 @@ $(document).ready(function () {
)
.on('change', function () {
dt
.column(colIdx)
.search($(this).val())
.draw();
});
.column(colIdx)
.search($(this).val())
.draw();
});
// Get the search data for the first column and add to the select list
dt
.column(colIdx)
@@ -700,8 +705,8 @@ $(document).ready(function () {
.sort()
.unique()
.each(function (d) {
select.append($('<option value="' + d + '">' + d + '</option>'));
});
select.append($('<option value="' + d + '">' + d + '</option>'));
});
});
var column_visible_get = column.visible();
@@ -709,12 +714,15 @@ $(document).ready(function () {
column_visible_set = column.visible(false, true);
alert('Column index 0 is ' +
(dt.column(0).visible() === true ? 'visible' : 'not visible')
);
);
for (var i = 0; i < 4; i++) {
dt.column(i).visible(false, false);
}
dt.columns.adjust().draw(false); // adjust column sizing and redraw
dt.columns().every(function () { });
dt.columns().every(function (colIdx, tableLoop, colLoop) { });
//#endregion "Methods-Column"
//#region "Methods-Row"
@@ -754,6 +762,8 @@ $(document).ready(function () {
var rows_11 = dt.rows("selector").remove();
var rows_12 = dt.rows("selector").nodes();
var rows_13 = dt.rows.add([{}, {}]);
dt.rows().every(function () { });
dt.rows().every(function (rowIdx, tableLoop, rowLoop) { });
var table3 = $('#example').DataTable();
table3.row.add({
@@ -791,9 +801,9 @@ $(document).ready(function () {
pupil,
])
.draw();
//.nodes()
//.to$()
//.addClass('new');
//.nodes()
//.to$()
//.addClass('new');
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).parents('tr');
@@ -829,7 +839,7 @@ $(document).ready(function () {
'<td>' + rowIdx + '.3</td>' +
'<td>' + rowIdx + '.4</td>' +
'</tr>'
)
)
)
.show();
});

View File

@@ -1,4 +1,4 @@
// Type definitions for JQuery DataTables 1.10.5
// Type definitions for JQuery DataTables 1.10.6
// Project: http://www.datatables.net
// Definitions by: Kiarash Ghiaseddin <https://github.com/Silver-Connection/DefinitelyTyped>, Omid Rad <https://github.com/omidkrad>, Armin Sander <https://github.com/pragmatrix/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -159,7 +159,7 @@ declare namespace DataTables {
/**
* Get jquery object
*/
$(selector: string | Node | Node[]| JQuery, modifier?: ObjectSelectorModifier): JQuery;
$(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery;
///// Almost identical to $ in operation, but in this case returns the data for the matched rows.
//_(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery;
@@ -188,6 +188,11 @@ declare namespace DataTables {
*/
draw(reset?: boolean): DataTable;
/*
* Get the initialisation options used for the table. Since: DataTables 1.10.6
*/
init(): Settings;
/**
* Table events removal.
*
@@ -628,6 +633,13 @@ declare namespace DataTables {
*/
data(): DataTable;
/**
* Iterate over each selected cell, with the function context set to be the cell in question. Since: DataTables 1.10.6
*
* @param fn Function to execute for every cell selected.
*/
every(fn: (cellRowIdx: number, cellColIdx: number, tableLoop: number, cellLoop: number) => void): DataTable;
/**
* Get index information about the selected cells
*/
@@ -749,6 +761,13 @@ declare namespace DataTables {
*/
dataSrc(): DataTable;
/**
* Iterate over each selected column, with the function context set to be the column in question. Since: DataTables 1.10.6
*
* @param fn Function to execute for every column selected.
*/
every(fn: (colIdx: number, tableLoop: number, colLoop: number) => void): DataTable;
/**
* Get the column indexes of the selected columns.
*
@@ -847,7 +866,7 @@ declare namespace DataTables {
*
* @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table
*/
add(data: any[]| Object): DataTable;
add(data: any[] | Object): DataTable;
}
interface RowMethods extends DataTableCore, CommonRowMethod {
@@ -859,14 +878,14 @@ declare namespace DataTables {
/**
* Get the data for the selected row
*/
data(): any[]| Object;
data(): any[] | Object;
/**
* Set the data for the selected row
*
* @param d Data to use for the row.
*/
data(d: any[]| Object): DataTable;
data(d: any[] | Object): DataTable;
/**
* Get the row index of the row column.
@@ -919,7 +938,14 @@ declare namespace DataTables {
*
* @param d Data to use for the row.
*/
data(d: any[]| Object): DataTable;
data(d: any[] | Object): DataTable;
/**
* Iterate over each selected row, with the function context set to be the row in question. Since: DataTables 1.10.6
*
* @param fn Function to execute for every row selected.
*/
every(fn: (rowIdx: number, tableLoop: number, rowLoop: number) => void): DataTable;
/**
* Get the row indexes of the selected rows.
@@ -1031,7 +1057,7 @@ declare namespace DataTables {
*
* @param table Selector string for table
*/
Api(selector: string | Node | Node[]| JQuery): DataTables.DataTable;
Api(selector: string | Node | Node[] | JQuery): DataTables.DataTable;
}
export interface StaticUtilFunctions {
@@ -1175,7 +1201,7 @@ declare namespace DataTables {
/**
* Change the options in the page length select list. Since: 1.10
*/
lengthMenu?: (number | string)[]| (number | string)[][];
lengthMenu?: (number | string)[] | (number | string)[][];
/**
* Control which cell the order event handler will be applied to in a column. Since: 1.10
@@ -1190,12 +1216,12 @@ declare namespace DataTables {
/**
* Initial order (sort) to apply to the table. Since: 1.10
*/
order?: (string | number)[]| (string | number)[][];
order?: (string | number)[] | (string | number)[][];
/**
* Ordering to always be applied to the table. Since: 1.10
*/
orderFixed?: (string | number)[]| (string | number)[][]| Object;
orderFixed?: (string | number)[] | (string | number)[][] | Object;
/**
* Multiple column ordering ability control. Since: 1.10
@@ -1395,7 +1421,11 @@ declare namespace DataTables {
}
interface FunctionAjaxData {
(data: Object): string | Object;
/*
* @param data Data that DataTables has constructed for the request.
* @param settings DataTables settings object. Since 1.10.6
*/
(data: Object, settings: Settings): string | Object;
}
//#endregion "ajax-settings"
@@ -1558,7 +1588,7 @@ declare namespace DataTables {
//#region "callback-functions"
interface FunctionCreateRow {
(row: Node, data: any[]| Object, dataIndex: number): void;
(row: Node, data: any[] | Object, dataIndex: number): void;
}
interface FunctionDrawCallback {
@@ -1590,7 +1620,7 @@ declare namespace DataTables {
}
interface FunctionRowCallback {
(row: Node, data: any[]| Object): void;
(row: Node, data: any[] | Object): void;
}
interface FunctionStateLoadCallback {
@@ -1617,7 +1647,7 @@ declare namespace DataTables {
//#region "language-settings"
// these are all optional
// these are all optional
interface LanguageSettings {
emptyTable?: string;
info?: string;

View File

@@ -15,7 +15,7 @@ declare namespace JSData {
catch<U>(onRejected?:(error:any) => U | JSDataPromise<U>): JSDataPromise<U>;
// enhanced with finally
finally<U>(finallyCb?:() => U):JSDataPromise<U>;
finally(finallyCb?:() => any): JSDataPromise<R>;
}
interface DSConfiguration extends IDSResourceLifecycleEventHandlers {

2
jspdf/jspdf.d.ts vendored
View File

@@ -42,7 +42,7 @@ declare module 'jspdf' {
'getPageInfo'(pageNumberOneBased:number):any;
'getCurrentPageInfo'():any;
};
addPage():jsPDF;
addPage(sizes?: number[]):jsPDF;
setPage(n:number):jsPDF;
insertPage(beforePage:number):jsPDF;
movePage(targetPage:number, beforePage:number):jsPDF;

View File

@@ -619,7 +619,12 @@ knex.select('*')
//
// Migrations
//
var config = { };
var config = {
directory: "./migrations",
extension: "js",
tableName: "knex_migrations",
disableTransactions: false
};
knex.migrate.make(name, config);
knex.migrate.make(name);

2
knex/knex.d.ts vendored
View File

@@ -532,10 +532,10 @@ declare module "knex" {
}
interface MigratorConfig {
database?: string;
directory?: string;
extension?: string;
tableName?: string;
disableTransactions?: boolean;
}
interface Migrator {

View File

@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-curve.d.ts" />

View File

@@ -3,7 +3,7 @@
// Definitions by: Onikiienko <https://github.com/onikiienko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
/**

View File

@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-draw.d.ts" />
@@ -44,4 +44,4 @@ map.on('draw:created', function (e: L.DrawEvents.Created) {
layer = e.layer;
drawnItems.addLayer(layer);
});
});

View File

@@ -3,7 +3,7 @@
// Definitions by: Matt Guest <https://github.com/matt-guest>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface MapOptions {

View File

@@ -3,7 +3,7 @@
// Definitions by: Dominic Alie <https://github.com/dalie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
/**

View File

@@ -1,4 +1,4 @@
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
/// <reference path="leaflet-geocoder-mapzen.d.ts" />
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',

View File

@@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
namespace Control {

View File

@@ -3,7 +3,7 @@
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface IconOptions {

View File

@@ -3,7 +3,7 @@
// Definitions by: Robert Imig <https://github.com/rimig>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {
export interface MarkerClusterGroupOptions {
@@ -51,7 +51,7 @@ declare namespace L {
/*
* The maximum radius that a cluster will cover from the central marker (in pixels). Default 80.
* Decreasing will make more, smaller clusters. You can also use a function that accepts
* Decreasing will make more, smaller clusters. You can also use a function that accepts
* the current map zoom and returns the maximum cluster radius in pixels
*/
maxClusterRadius?: number | ((zoom: number) => number);
@@ -134,9 +134,9 @@ declare namespace L {
getAllChildMarkers(): Marker[];
/*
* Zooms to show the given marker (spiderfying if required),
* Zooms to show the given marker (spiderfying if required),
* calls the callback when the marker is visible on the map.
*/
*/
zoomToShowLayer(layer: any, callback: () => void): void;
}
}

View File

@@ -3,7 +3,7 @@
// Definitions by: Egor Komarov <https://github.com/Odrin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare module L {
module AwesomeMarkers {

View File

@@ -3,7 +3,7 @@
// Definitions by: William Comartin <https://github.com/wcomartin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/// <reference path="../leaflet/leaflet-0.7.d.ts" />
declare namespace L {

View File

@@ -0,0 +1,427 @@
/// <reference path="leaflet-0.7.d.ts" />
// initialize the map on the "map" div with a given center and zoom
var div = document.getElementById('map');
var map : L.Map = L.map(div, {
center: L.latLng([51.505, -0.09]),
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
zoomControl: true,
attributionControl: true,
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
});
map.dragging.enable();
map.touchZoom.enable();
map.scrollWheelZoom.enable();
map.doubleClickZoom.enable();
map.boxZoom.enable();
map.tap.enable();
map.setView(new L.LatLng(42, 51));
map.setView(L.latLng(42, 51));
map.setView(L.latLng(42, 51), 12);
map.setView(L.latLng(42, 51), 12, {
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
});
map.setZoom(50);
map.setZoom(50, {});
map.zoomIn();
map.zoomOut();
map.zoomIn(2);
map.zoomOut(2);
map.zoomIn(2, { animate: true });
map.zoomOut(2, { animate: true });
map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
});
map.fitWorld();
map.fitWorld({
animate: false
});
map.panTo(L.latLng(42, 42));
map.panTo(L.latLng(42, 42), {
animate: true
});
map.invalidateSize(true);
map.invalidateSize({ reset: true });
map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.locate();
map.locate({
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
});
map.stopLocate();
map.remove();
var center : L.LatLng = map.getCenter();
var zoom : number = map.getZoom();
var minZoom: number = map.getMinZoom();
var maxZoom: number = map.getMaxZoom();
var bounds: L.LatLngBounds = map.getBounds();
var boundsZoom: number = map.getBoundsZoom(bounds, true);
var size: L.Point = map.getSize();
var pixelBounds: L.Bounds = map.getPixelBounds();
var pixelOrigin: L.Point = map.getPixelOrigin();
var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
map.addLayer(layer);
map.addLayer(layer, false);
map.eachLayer(l => {});
map.removeLayer(layer);
map.hasLayer(layer);
map.openPopup("canard", L.latLng(42, 51));
var popup = L.popup({
autoPan: true
});
map.openPopup(popup);
map.closePopup(popup);
map.closePopup();
map.addControl(L.control.attribution({position: 'bottomright'}));
map.removeControl(L.control.attribution({ position: 'bottomright' }));
L.control.layers({'Base': layer}).addTo(map);
map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) {
alert(e.name);
});
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
map.containerPointToLayerPoint(L.point(0, 0));
map.layerPointToContainerPoint(L.point(0, 0));
map.project(map.unproject(L.point(10, 20)));
map.project(map.unproject(L.point(10, 20), 12), 12);
var mouseEvent: L.LeafletMouseEvent;
map.mouseEventToContainerPoint(mouseEvent);
map.mouseEventToLayerPoint(mouseEvent);
map.mouseEventToLatLng(mouseEvent);
map.getContainer().classList.add('roger');
map.getPanes().mapPane.classList.add('roger');
map.getPanes().markerPane.classList.add('roger');
map.getPanes().objectsPane.classList.add('roger');
map.getPanes().overlayPane.classList.add('roger');
map.getPanes().popupPane.classList.add('roger');
map.getPanes().shadowPane.classList.add('roger');
map.getPanes().tilePane.classList.add('roger');
map.whenReady((m: L.Map) => {
m.zoomOut();
});
map.on('click', () => {
map.zoomOut();
});
map.off('dblclick', L.Util.falseFn);
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
map.openPopup('contextmenu', e.latlng);
});
var marker = L.marker(L.latLng(42, 51), {
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
});
marker.addTo(map);
marker.on('click', (e: L.LeafletMouseEvent) => {
map.setView(e.latlng);
});
marker.once('mouseover', () => {
marker.openPopup();
})
marker.setLatLng(marker.getLatLng());
marker.setIcon(L.icon({}));
marker.setZIndexOffset(30);
marker.setOpacity(0.8);
marker.bindPopup(popup);
marker.unbindPopup();
marker.bindPopup('hello', {
closeOnClick: true
});
marker.openPopup();
marker.closePopup();
marker.togglePopup();
marker.togglePopup();
marker.setPopupContent('hello 3')
marker.getPopup().setContent('hello 2');
marker.update();
marker.toGeoJSON();
marker.dragging.enable();
popup = L.popup({
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
});
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
popup.update();
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
});
tileLayer.on('loading', L.Util.falseFn)
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
tileLayer.addTo(map);
tileLayer.bringToBack()
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
namespace CustomControl {
export interface Options {
title: string;
position?: string;
}
}
interface CustomControl extends L.Control {
getTitle(): string;
setTitle(title: string): CustomControl;
}
var CustomControl: { new(options: CustomControl.Options): CustomControl };
CustomControl = L.Control.extend<CustomControl.Options, CustomControl>({
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
});
// Different latLng and latLngBounds expressions
var latLngLiteral = [10, 20];
var latLngObjectLiteral = { lat: 10, lng: 10 };
var boundsLiteral = [[10, 20], [20, 20]];
var boundLiteralOfLatLngObjects = [latLngObjectLiteral, latLngObjectLiteral];
var circle: L.Circle = L.circle(latLngLiteral, 4);
circle = new L.Circle(latLngLiteral, 4);
circle.setLatLng(latLngLiteral);
circle = L.circle(latLngObjectLiteral, 4);
circle = new L.Circle(latLngObjectLiteral, 4);
circle.setLatLng(latLngObjectLiteral);
var circleMarker: L.CircleMarker = L.circleMarker(latLngLiteral);
circleMarker = new L.CircleMarker(latLngLiteral);
circleMarker.setLatLng(latLngLiteral);
circleMarker = L.circleMarker(latLngObjectLiteral);
circleMarker = new L.CircleMarker(latLngObjectLiteral);
circleMarker.setLatLng(latLngObjectLiteral);
var latLng: L.LatLng = L.latLng(latLngLiteral);
latLng = new L.LatLng(latLngLiteral);
latLng.distanceTo(latLngLiteral);
latLng.equals(latLngLiteral);
latLng = L.latLng(latLngObjectLiteral);
latLng = new L.LatLng(latLngObjectLiteral);
latLng.distanceTo(latLngObjectLiteral);
latLng.equals(latLngObjectLiteral);
var bounds: L.LatLngBounds = L.latLngBounds(boundsLiteral);
bounds = L.latLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(boundsLiteral);
bounds = new L.LatLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
bounds.extend(latLngLiteral);
bounds.extend(latLngObjectLiteral);
bounds.extend(boundsLiteral);
bounds.extend(boundLiteralOfLatLngObjects);
bounds.contains(latLngLiteral);
bounds.contains(boundLiteralOfLatLngObjects);
bounds.contains(boundsLiteral);
bounds.intersects(boundsLiteral);
bounds.intersects(boundLiteralOfLatLngObjects);
bounds.equals(boundsLiteral);
bounds.equals(boundLiteralOfLatLngObjects);
map.setView(latLngLiteral);
map.setView(latLngObjectLiteral);
map.setZoomAround(latLngLiteral, 15);
map.setZoomAround(latLngObjectLiteral, 15);
map.panTo(latLngLiteral);
map.panTo(latLngObjectLiteral);
map.openPopup('test', latLngLiteral);
map.openPopup('test', latLngObjectLiteral);
map.latLngToLayerPoint(latLngLiteral);
map.latLngToLayerPoint(latLngObjectLiteral);
map.latLngToContainerPoint(latLngLiteral);
map.latLngToContainerPoint(latLngObjectLiteral);
map.project(latLngLiteral);
map.project(latLngObjectLiteral);
marker.setLatLng(latLngLiteral);
marker.setLatLng(latLngObjectLiteral);
var polygon: L.Polygon = L.polygon(boundsLiteral);
polygon = L.polygon(boundLiteralOfLatLngObjects);
polygon = new L.Polygon(boundsLiteral);
polygon = new L.Polygon(boundLiteralOfLatLngObjects);
var polyline: L.Polyline = L.polyline(boundsLiteral);
polyline = L.polyline(boundLiteralOfLatLngObjects);
polyline = new L.Polyline(boundsLiteral);
polyline = new L.Polyline(boundLiteralOfLatLngObjects);
polyline.setLatLngs(boundsLiteral);
polyline.setLatLngs(boundLiteralOfLatLngObjects);
polyline.addLatLng(latLngLiteral);
polyline.addLatLng(latLngObjectLiteral);
var popup: L.Popup = L.popup();
popup.setLatLng(latLngLiteral);
popup.setLatLng(latLngObjectLiteral);
var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});

4382
leaflet/leaflet-0.7.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,427 +1,267 @@
/// <reference path="leaflet.d.ts" />
// initialize the map on the "map" div with a given center and zoom
var div = document.getElementById('map');
var map : L.Map = L.map(div, {
center: L.latLng([51.505, -0.09]),
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
zoomControl: true,
attributionControl: true,
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
});
map.dragging.enable();
map.touchZoom.enable();
map.scrollWheelZoom.enable();
map.doubleClickZoom.enable();
map.boxZoom.enable();
map.tap.enable();
map.setView(new L.LatLng(42, 51));
map.setView(L.latLng(42, 51));
map.setView(L.latLng(42, 51), 12);
map.setView(L.latLng(42, 51), 12, {
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
});
map.setZoom(50);
map.setZoom(50, {});
map.zoomIn();
map.zoomOut();
map.zoomIn(2);
map.zoomOut(2);
map.zoomIn(2, { animate: true });
map.zoomOut(2, { animate: true });
map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
});
map.fitWorld();
map.fitWorld({
animate: false
});
map.panTo(L.latLng(42, 42));
map.panTo(L.latLng(42, 42), {
animate: true
});
map.invalidateSize(true);
map.invalidateSize({ reset: true });
map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.locate();
map.locate({
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
});
map.stopLocate();
map.remove();
var center : L.LatLng = map.getCenter();
var zoom : number = map.getZoom();
var minZoom: number = map.getMinZoom();
var maxZoom: number = map.getMaxZoom();
var bounds: L.LatLngBounds = map.getBounds();
var boundsZoom: number = map.getBoundsZoom(bounds, true);
var size: L.Point = map.getSize();
var pixelBounds: L.Bounds = map.getPixelBounds();
var pixelOrigin: L.Point = map.getPixelOrigin();
var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
map.addLayer(layer);
map.addLayer(layer, false);
map.eachLayer(l => {});
map.removeLayer(layer);
map.hasLayer(layer);
map.openPopup("canard", L.latLng(42, 51));
var popup = L.popup({
autoPan: true
});
map.openPopup(popup);
map.closePopup(popup);
map.closePopup();
map.addControl(L.control.attribution({position: 'bottomright'}));
map.removeControl(L.control.attribution({ position: 'bottomright' }));
L.control.layers({'Base': layer}).addTo(map);
map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) {
alert(e.name);
});
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
map.containerPointToLayerPoint(L.point(0, 0));
map.layerPointToContainerPoint(L.point(0, 0));
map.project(map.unproject(L.point(10, 20)));
map.project(map.unproject(L.point(10, 20), 12), 12);
var mouseEvent: L.LeafletMouseEvent;
map.mouseEventToContainerPoint(mouseEvent);
map.mouseEventToLayerPoint(mouseEvent);
map.mouseEventToLatLng(mouseEvent);
map.getContainer().classList.add('roger');
map.getPanes().mapPane.classList.add('roger');
map.getPanes().markerPane.classList.add('roger');
map.getPanes().objectsPane.classList.add('roger');
map.getPanes().overlayPane.classList.add('roger');
map.getPanes().popupPane.classList.add('roger');
map.getPanes().shadowPane.classList.add('roger');
map.getPanes().tilePane.classList.add('roger');
map.whenReady((m: L.Map) => {
m.zoomOut();
});
map.on('click', () => {
map.zoomOut();
});
map.off('dblclick', L.Util.falseFn);
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
map.openPopup('contextmenu', e.latlng);
});
var marker = L.marker(L.latLng(42, 51), {
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
});
marker.addTo(map);
marker.on('click', (e: L.LeafletMouseEvent) => {
map.setView(e.latlng);
});
marker.once('mouseover', () => {
marker.openPopup();
})
marker.setLatLng(marker.getLatLng());
marker.setIcon(L.icon({}));
marker.setZIndexOffset(30);
marker.setOpacity(0.8);
marker.bindPopup(popup);
marker.unbindPopup();
marker.bindPopup('hello', {
closeOnClick: true
});
marker.openPopup();
marker.closePopup();
marker.togglePopup();
marker.togglePopup();
marker.setPopupContent('hello 3')
marker.getPopup().setContent('hello 2');
marker.update();
marker.toGeoJSON();
marker.dragging.enable();
popup = L.popup({
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
});
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
popup.update();
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
});
tileLayer.on('loading', L.Util.falseFn)
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
tileLayer.addTo(map);
tileLayer.bringToBack()
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
namespace CustomControl {
export interface Options {
title: string;
position?: string;
}
}
interface CustomControl extends L.Control {
getTitle(): string;
setTitle(title: string): CustomControl;
}
var CustomControl: { new(options: CustomControl.Options): CustomControl };
CustomControl = L.Control.extend<CustomControl.Options, CustomControl>({
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
});
// Different latLng and latLngBounds expressions
var latLngLiteral = [10, 20];
var latLngObjectLiteral = { lat: 10, lng: 10 };
var boundsLiteral = [[10, 20], [20, 20]];
var boundLiteralOfLatLngObjects = [latLngObjectLiteral, latLngObjectLiteral];
var circle: L.Circle = L.circle(latLngLiteral, 4);
circle = new L.Circle(latLngLiteral, 4);
circle.setLatLng(latLngLiteral);
circle = L.circle(latLngObjectLiteral, 4);
circle = new L.Circle(latLngObjectLiteral, 4);
circle.setLatLng(latLngObjectLiteral);
var circleMarker: L.CircleMarker = L.circleMarker(latLngLiteral);
circleMarker = new L.CircleMarker(latLngLiteral);
circleMarker.setLatLng(latLngLiteral);
circleMarker = L.circleMarker(latLngObjectLiteral);
circleMarker = new L.CircleMarker(latLngObjectLiteral);
circleMarker.setLatLng(latLngObjectLiteral);
var latLng: L.LatLng = L.latLng(latLngLiteral);
latLng = new L.LatLng(latLngLiteral);
latLng.distanceTo(latLngLiteral);
latLng.equals(latLngLiteral);
latLng = L.latLng(latLngObjectLiteral);
latLng = new L.LatLng(latLngObjectLiteral);
latLng.distanceTo(latLngObjectLiteral);
latLng.equals(latLngObjectLiteral);
var bounds: L.LatLngBounds = L.latLngBounds(boundsLiteral);
bounds = L.latLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(boundsLiteral);
bounds = new L.LatLngBounds(boundLiteralOfLatLngObjects);
bounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
bounds.extend(latLngLiteral);
bounds.extend(latLngObjectLiteral);
bounds.extend(boundsLiteral);
bounds.extend(boundLiteralOfLatLngObjects);
bounds.contains(latLngLiteral);
bounds.contains(boundLiteralOfLatLngObjects);
bounds.contains(boundsLiteral);
bounds.intersects(boundsLiteral);
bounds.intersects(boundLiteralOfLatLngObjects);
bounds.equals(boundsLiteral);
bounds.equals(boundLiteralOfLatLngObjects);
map.setView(latLngLiteral);
map.setView(latLngObjectLiteral);
map.setZoomAround(latLngLiteral, 15);
map.setZoomAround(latLngObjectLiteral, 15);
map.panTo(latLngLiteral);
map.panTo(latLngObjectLiteral);
map.openPopup('test', latLngLiteral);
map.openPopup('test', latLngObjectLiteral);
map.latLngToLayerPoint(latLngLiteral);
map.latLngToLayerPoint(latLngObjectLiteral);
map.latLngToContainerPoint(latLngLiteral);
map.latLngToContainerPoint(latLngObjectLiteral);
map.project(latLngLiteral);
map.project(latLngObjectLiteral);
marker.setLatLng(latLngLiteral);
marker.setLatLng(latLngObjectLiteral);
var polygon: L.Polygon = L.polygon(boundsLiteral);
polygon = L.polygon(boundLiteralOfLatLngObjects);
polygon = new L.Polygon(boundsLiteral);
polygon = new L.Polygon(boundLiteralOfLatLngObjects);
var polyline: L.Polyline = L.polyline(boundsLiteral);
polyline = L.polyline(boundLiteralOfLatLngObjects);
polyline = new L.Polyline(boundsLiteral);
polyline = new L.Polyline(boundLiteralOfLatLngObjects);
polyline.setLatLngs(boundsLiteral);
polyline.setLatLngs(boundLiteralOfLatLngObjects);
polyline.addLatLng(latLngLiteral);
polyline.addLatLng(latLngObjectLiteral);
var popup: L.Popup = L.popup();
popup.setLatLng(latLngLiteral);
popup.setLatLng(latLngObjectLiteral);
var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});
import L = require('leaflet');
const latLngLiteral: L.LatLngLiteral = {lat: 12, lng: 13};
const latLngTuple: L.LatLngTuple = [12, 13];
let latLng: L.LatLng;
latLng = L.latLng(12, 13);
latLng = L.latLng(12, 13, 0);
latLng = L.latLng(latLngLiteral);
latLng = L.latLng({lat: 12, lng: 13, alt: 0});
latLng = L.latLng(latLngTuple);
latLng = L.latLng([12, 13, 0]);
const latLngBoundsLiteral: L.LatLngBoundsLiteral = [[12, 13], latLngTuple];
let latLngBounds: L.LatLngBounds;
latLngBounds = L.latLngBounds(latLng, latLng);
latLngBounds = L.latLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = L.latLngBounds(latLngTuple, latLngTuple);
const pointTuple: L.PointTuple = [0, 0];
let point: L.Point;
point = L.point(12, 13);
point = L.point(12, 13, true);
point = L.point(pointTuple);
point = L.point({x: 12, y: 13});
const boundsLiteral: L.BoundsLiteral = [[1, 1], pointTuple];
let bounds: L.Bounds;
bounds = L.bounds(point, point);
bounds = L.bounds(pointTuple, pointTuple);
bounds = L.bounds([point, point]);
bounds = L.bounds(boundsLiteral);
let mapOptions: L.MapOptions = {};
mapOptions = {
preferCanvas: true,
attributionControl: false,
zoomControl: true,
closePopupOnClick: false,
zoomSnap: 1,
zoomDelta: 1,
trackResize: false,
boxZoom: true,
dragging: true,
// CRS
zoom: 12,
minZoom: 10,
maxZoom: 14,
fadeAnimation: true,
markerZoomAnimation: false,
transform3DLimit: 123,
zoomAnimation: false,
zoomAnimationThreshold: 4,
inertia: false,
inertiaDeceleration: 2000,
inertiaMaxSpeed: 1000,
easeLinearity: 0.5,
worldCopyJump: true,
maxBoundsViscosity: 1.0,
keyboard: false,
keyboardPanDelta: 100,
wheelDebounceTime: 30,
wheelPxPerZoomLevel: 25,
tap: false,
tapTolerance: 10,
bounceAtZoomLimits: false
};
mapOptions.doubleClickZoom = true;
mapOptions.doubleClickZoom = 'center';
mapOptions.center = latLng;
mapOptions.center = latLngLiteral;
mapOptions.center = latLngTuple;
mapOptions.layers = [];
mapOptions.layers = [L.tileLayer('')]; // add layers of other types
mapOptions.maxBounds = latLngBounds;
mapOptions.maxBounds = [];
mapOptions.maxBounds = latLngBoundsLiteral;
// mapOptions.renderer = ?
mapOptions.scrollWheelZoom = true;
mapOptions.scrollWheelZoom = 'center';
mapOptions.touchZoom = false;
mapOptions.touchZoom = 'center';
let layer: L.Layer;
const htmlElement = document.getElementById('foo');
let popupOptions: L.PopupOptions = {};
let tooltipOptions: L.TooltipOptions = {};
let zoomPanOptions: L.ZoomPanOptions = {};
zoomPanOptions = {
animate: false,
duration: 0.5,
easeLinearity: 0.6,
noMoveStart: true
};
let zoomOptions: L.ZoomOptions = {};
let panOptions: L.PanOptions = {};
let fitBoundsOptions: L.FitBoundsOptions = {};
let map = L.map('foo');
map = L.map('foo', mapOptions);
map = L.map(htmlElement);
map = L.map(htmlElement, mapOptions);
let doesItHaveLayer: boolean;
doesItHaveLayer = map.hasLayer(L.tileLayer(''));
// map.getRenderer
let html: HTMLElement;
html = map.createPane('foo');
html = map.createPane('foo', htmlElement)
html = map.getPane('foo');
html = map.getPane(htmlElement);
html = map.getContainer();
const panes = map.getPanes();
html = panes.mapPane;
html = panes.tilePane;
html = panes.overlayPane;
html = panes.shadowPane;
html = panes.markerPane;
html = panes.tooltipPane;
html = panes.popupPane;
html = panes['foo'];
let coordinates: L.LatLng;
coordinates = map.getCenter();
let zoom: number;
zoom = map.getZoom();
zoom = map.getMinZoom();
zoom = map.getMaxZoom();
zoom = map.getBoundsZoom(latLngBounds);
zoom = map.getBoundsZoom(latLngBounds, true);
zoom = map.getBoundsZoom(latLngBoundsLiteral);
zoom = map.getBoundsZoom(latLngBoundsLiteral, true);
let mapLatLngBounds: L.LatLngBounds;
mapLatLngBounds = map.getBounds();
let mapPoint: L.Point;
mapPoint = map.getSize();
mapPoint = map.getPixelOrigin();
let mapPixelBounds: L.Bounds;
mapPixelBounds = map.getPixelBounds();
mapPixelBounds = map.getPixelWorldBounds();
mapPixelBounds = map.getPixelWorldBounds(12);
map = map
// addControl
// removeControl
.addLayer(L.tileLayer(''))
.removeLayer(L.tileLayer('')) // use a different type of layer
.eachLayer((currentLayer) => {
layer = currentLayer;
})
.eachLayer((currentLayer) => {
layer = currentLayer;
}, {})
.openPopup(L.popup())
.openPopup('Hello World', latLng)
.openPopup('Hello World', latLng, popupOptions)
.openPopup('Hello World', latLngLiteral)
.openPopup('Hello World', latLngLiteral, popupOptions)
.openPopup('Hello World', latLngTuple)
.openPopup('Hello World', latLngTuple, popupOptions)
.openPopup(htmlElement, latLng)
.openPopup(htmlElement, latLng, popupOptions)
.openPopup(htmlElement, latLngLiteral)
.openPopup(htmlElement, latLngLiteral, popupOptions)
.openPopup(htmlElement, latLngTuple)
.openPopup(htmlElement, latLngTuple, popupOptions)
.closePopup()
.closePopup(L.popup())
.openTooltip(L.tooltip())
.openTooltip('Hello Word', latLng)
.openTooltip('Hello World', latLng, tooltipOptions)
.openTooltip('Hello World', latLngLiteral)
.openTooltip('Hello World', latLngLiteral, tooltipOptions)
.openTooltip('Hello World', latLngTuple)
.openTooltip('Hello World', latLngTuple, tooltipOptions)
.openTooltip(htmlElement, latLng)
.openTooltip(htmlElement, latLng, tooltipOptions)
.openTooltip(htmlElement, latLngLiteral)
.openTooltip(htmlElement, latLngLiteral, tooltipOptions)
.openTooltip(htmlElement, latLngTuple)
.openTooltip(htmlElement, latLngTuple, tooltipOptions)
.closeTooltip()
.closeTooltip(L.tooltip())
.setView(latLng, 12)
.setView(latLng, 12, zoomPanOptions)
.setView(latLngLiteral, 12)
.setView(latLngLiteral, 12, zoomPanOptions)
.setView(latLngTuple, 12)
.setView(latLngTuple, 12, zoomPanOptions)
.setZoom(12, zoomPanOptions) // investigate if zoomPanOptions are really required
.zoomIn()
.zoomIn(1)
.zoomIn(1, zoomOptions)
.zoomOut()
.zoomOut(1)
.zoomOut(1, zoomOptions)
.setZoomAround(latLng, 12, zoomOptions) // investigate if zoom options are really required
.setZoomAround(latLngLiteral, 12, zoomOptions)
.setZoomAround(latLngTuple, 12, zoomOptions)
.setZoomAround(point, 12, zoomOptions)
.setZoomAround(pointTuple, 11, zoomOptions)
.fitBounds(latLngBounds, fitBoundsOptions) // investigate if fit bounds options are really required
.fitBounds(latLngBoundsLiteral, fitBoundsOptions)
.fitWorld()
.fitWorld(fitBoundsOptions)
.panTo(latLng)
.panTo(latLng, panOptions)
.panTo(latLngLiteral)
.panTo(latLngLiteral, panOptions)
.panTo(latLngTuple)
.panTo(latLngTuple, panOptions)
.panBy(point)
.panBy(pointTuple)
.setMaxBounds(bounds) // investigate if this really receives Bounds instead of LatLngBounds
.setMaxBounds(boundsLiteral)
.setMinZoom(5)
.setMaxZoom(10)
.panInsideBounds(latLngBounds)
.panInsideBounds(latLngBounds, panOptions)
.panInsideBounds(latLngBoundsLiteral)
.panInsideBounds(latLngBoundsLiteral, panOptions)
.invalidateSize(zoomPanOptions)
.invalidateSize(false)
.stop()
.flyTo(latLng)
.flyTo(latLng, 12)
.flyTo(latLng, 12, zoomOptions)
.flyTo(latLngLiteral)
.flyTo(latLngLiteral, 12)
.flyTo(latLngLiteral, 12, zoomPanOptions)
.flyTo(latLngTuple)
.flyTo(latLngTuple, 12)
.flyTo(latLngTuple, 12, zoomPanOptions)
.flyToBounds(latLngBounds)
.flyToBounds(latLngBounds, fitBoundsOptions)
.flyToBounds(latLngBoundsLiteral)
.flyToBounds(latLngBoundsLiteral, fitBoundsOptions)
// addHandler
.remove()
.whenReady(() => {})
.whenReady(() => {}, {});

5095
leaflet/leaflet.d.ts vendored

File diff suppressed because it is too large Load Diff

2
lodash/lodash.d.ts vendored
View File

@@ -501,7 +501,7 @@ declare module _ {
* console.log(array);
* // => [1]
*/
concat<T>(...values: (T[]|List<T>)[]) : T[];
concat<T>(array: T[]|List<T>, ...values: (T|T[]|List<T>)[]) : T[];
}
//_.difference

2
mapbox/mapbox.d.ts vendored
View File

@@ -3,7 +3,7 @@
// Definitions by: Maxime Fabre <https://github.com/anahkiasen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts"/>
/// <reference path="../leaflet/leaflet-0.7.d.ts"/>
//////////////////////////////////////////////////////////////////////
///////////////////////////// MAP OBJECT /////////////////////////////

View File

@@ -344,6 +344,9 @@ declare namespace __MaterialUI {
disabledTextColor?: string;
connectorLineColor?: string;
};
svgIcon?: {
color?: string,
};
table?: {
backgroundColor?: string;
};
@@ -536,7 +539,7 @@ declare namespace __MaterialUI {
type horizontal = 'left' | 'middle' | 'right';
type vertical = 'top' | 'center' | 'bottom';
type direction = 'left' | 'right' | 'up' | 'down';
interface origin {
horizontal: horizontal;
vertical: vertical;
@@ -745,7 +748,7 @@ declare namespace __MaterialUI {
onMouseLeave?: React.MouseEventHandler;
onMouseOut?: React.MouseEventHandler;
style?: React.CSSProperties;
tooltip?: string;
tooltip?: React.ReactNode | string;
tooltipPosition?: propTypes.cornersAndCenter;
tooltipStyles?: React.CSSProperties;
touch?: boolean;

View File

@@ -1,6 +1,10 @@
/// <reference path="mongoose.d.ts" />
/// <reference path="../lodash/lodash.d.ts"/>
import * as mongoose from 'mongoose';
// test compatibility with other libraries
import * as _ from 'lodash';
var fs = require('fs');
// dummy variables
@@ -458,6 +462,20 @@ mongooseArray.unshift(2, 4, 'hi').toFixed();
/* inherited properties */
mongooseArray.concat();
mongooseArray.length;
/* practical examples */
interface MySubEntity extends mongoose.Types.Subdocument {
property1: string;
property2: string;
}
interface MyEntity extends mongoose.Document {
sub: mongoose.Types.Array<MySubEntity>
}
var myEntity: MyEntity;
var subDocArray = _.filter(myEntity.sub, function (sd) {
sd.property1;
sd.property2.toLowerCase();
});
/*
* section types/documentarray.js
@@ -1124,7 +1142,6 @@ MongoModel.create([{ type: 'jelly bean' }, {
arg[0].save();
arg[1].save();
});
MongoModel.discriminator('M', new mongoose.Schema({name: String}));
MongoModel.distinct('url', { clicks: {$gt: 100}}, function (err, result) {
});
MongoModel.distinct('url').exec(cb);
@@ -1386,4 +1403,16 @@ Final2.staticMethod();
Final2.staticProp;
var final2 = new Final2();
final2.prop;
final2.method;
final2.method;
interface ibase extends mongoose.Document {
username: string;
}
interface extended extends ibase {
email: string;
}
const base: mongoose.Model<ibase> = mongoose.model<ibase>('testfour', null)
const extended: mongoose.Model<extended> = base.discriminator<extended>('extendedS', null);
const x = new extended({
username: 'hi', // required in baseSchema
email: 'beddiw', // required in extededSchema
});

View File

@@ -927,7 +927,7 @@ declare module "mongoose" {
* section types/array.js
* http://mongoosejs.com/docs/api.html#types-array-js
*/
class Array<T> extends global.Array {
class Array<T> extends global.Array<T> {
/**
* Atomically shifts the array at most one time per document save().
* Calling this mulitple times on an array before saving sends the same command as
@@ -2119,7 +2119,7 @@ declare module "mongoose" {
* @param name discriminator model name
* @param schema discriminator model schema
*/
discriminator(name: string, schema: Schema): T;
discriminator<U extends Document>(name: string, schema: Schema): Model<U>;
/** Creates a Query for a distinct operation. Passing a callback immediately executes the query. */
distinct(field: string, callback?: (err: any, res: any[]) => void): Query<any[]>;

View File

@@ -1,113 +1,118 @@
/// <reference path="nock.d.ts" />
import nock = require('nock');
import * as nock from 'nock';
import * as fs from 'fs';
var inst: nock.Scope;
var scope: nock.Scope;
var inst: nock.Interceptor;
var str: string;
var strings: string[];
var bool: boolean;
var data: string;
var num: number;
var obj: {};
var objects: Object[];
var defs: nock.NockDefinition[];
var value: any;
var regex: RegExp;
var options: nock.Options;
var headers: Object;
var headers: { [key: string]: string; };
inst = inst.head(str);
inst = scope.head(str);
inst = inst.get(str);
inst = inst.get(str, data);
inst = scope.get(str);
inst = scope.get(str, data);
inst = inst.patch(str);
inst = inst.patch(str, str);
inst = inst.patch(str, obj);
inst = inst.patch(str, regex);
inst = scope.patch(str);
inst = scope.patch(str, str);
inst = scope.patch(str, obj);
inst = scope.patch(str, regex);
inst = inst.post(str);
inst = inst.post(str, data);
inst = inst.post(str, obj);
inst = inst.post(str, regex);
inst = scope.post(str);
inst = scope.post(str, data);
inst = scope.post(str, obj);
inst = scope.post(str, regex);
inst = inst.put(str);
inst = inst.put(str, data);
inst = inst.put(str, obj);
inst = inst.put(str, regex);
inst = scope.put(str);
inst = scope.put(str, data);
inst = scope.put(str, obj);
inst = scope.put(str, regex);
inst = inst.delete(str);
inst = inst.delete(str, data);
inst = inst.delete(str, obj);
inst = inst.delete(str, regex);
inst = scope.delete(str);
inst = scope.delete(str, data);
inst = scope.delete(str, obj);
inst = scope.delete(str, regex);
inst = inst.merge(str);
inst = inst.merge(str, data);
inst = inst.merge(str, obj);
inst = inst.merge(str, regex);
inst = scope.merge(str);
inst = scope.merge(str, data);
inst = scope.merge(str, obj);
inst = scope.merge(str, regex);
inst = inst.query(obj);
inst = inst.query(bool);
inst = inst.intercept(str, str);
inst = inst.intercept(str, str, str);
inst = inst.intercept(str, str, obj);
inst = inst.intercept(str, str, regex);
inst = inst.intercept(str, str, str, value);
inst = inst.intercept(str, str, obj, value);
inst = inst.intercept(str, str, regex, value);
inst = scope.intercept(str, str);
inst = scope.intercept(str, str, str);
inst = scope.intercept(str, str, obj);
inst = scope.intercept(str, str, regex);
inst = scope.intercept(str, str, str, value);
inst = scope.intercept(str, str, obj, value);
inst = scope.intercept(str, str, regex, value);
inst = inst.reply(num);
inst = inst.reply(num, str);
scope = inst.reply(num);
scope = inst.reply(num, str);
inst = inst.reply(num, str, headers);
inst = inst.reply(num, obj, headers);
inst = inst.reply(num, (uri: string, body: string) => {
scope = inst.reply(num, str, headers);
scope = inst.reply(num, obj, headers);
scope = inst.reply(num, (uri: string, body: string) => {
return str;
});
inst = inst.reply(num, (uri: string, body: string) => {
scope = inst.reply(num, (uri: string, body: string) => {
return str;
}, headers);
inst = inst.replyWithFile(num, str);
scope = inst.replyWithFile(num, str);
inst = inst.times(4);
inst = inst.once();
inst = inst.twice();
inst = inst.thrice();
inst = inst.defaultReplyHeaders(value);
scope = scope.defaultReplyHeaders(value);
inst = inst.matchHeader(str, str);
inst = inst.matchHeader(str, regex);
inst = inst.matchHeader(str, (val: string) => true);
scope = scope.matchHeader(str, str);
scope = scope.matchHeader(str, regex);
scope = scope.matchHeader(str, (val: string) => true);
inst = inst.delay(num);
inst = inst.delayConnection(num);
inst = inst.filteringPath(regex, str);
inst = inst.filteringPath((path: string) => {
scope = scope.filteringPath(regex, str);
scope = scope.filteringPath((path: string) => {
return str;
});
inst = inst.filteringRequestBody(regex, str);
inst = inst.filteringRequestBody((path: string) => {
scope = scope.filteringRequestBody(regex, str);
scope = scope.filteringRequestBody((path: string) => {
return str;
});
inst = inst.persist();
inst = inst.log(() => {
});
scope = scope.log(() => { });
scope = scope.persist();
bool = scope.shouldPersist();
scope = scope.replyContentLength();
scope = scope.replyDate();
scope = scope.replyDate(new Date());
inst = inst.delay(2000);
inst = inst.delay({ head: 1000, body: 1000 });
inst = inst.delayBody(2000);
inst = inst.delayConnection(2000);
inst.getTotalDelay();
inst = inst.socketDelay(2000);
inst.done();
bool = inst.isDone();
inst.restore();
scope.done();
bool = scope.isDone();
scope.restore();
objects = inst.pendingMocks();
strings = scope.pendingMocks();
nock.recorder.rec();
nock.recorder.rec(true);
@@ -115,6 +120,579 @@ nock.recorder.rec({
dont_print: true,
output_objects: true
});
nock.recorder.clear();
strings = nock.recorder.play() as string[];
defs = nock.recorder.play() as nock.NockDefinition[];
// Usage
var couchdb = nock('http://myapp.iriscouch.com')
.get('/users/1')
.reply(200, {
_id: '123ABC',
_rev: '946B7D1C',
username: 'pgte',
email: 'pedro.teixeira@gmail.com'
});
// Specifying hostname
var scope = nock('http://www.example.com')
.get('/resource')
.reply(200, 'domain matched');
var scope = nock(/example\.com/)
.get('/resource')
.reply(200, 'domain regex matched');
// Specifying path
var scope = nock('http://www.example.com')
.get('/resource')
.reply(200, 'path matched');
var scope = nock('http://www.example.com')
.get(/source$/)
.reply(200, 'path using regex matched');
var scope = nock('http://www.example.com')
.get((uri) => {
return uri.indexOf('cats') >= 0;
})
.reply(200, 'path using function matched');
// Specifying request body
var scope = nock('http://myapp.iriscouch.com')
.post('/users', {
username: 'pgte',
email: 'pedro.teixeira@gmail.com'
})
.reply(201, {
ok: true,
id: '123ABC',
rev: '946B7D1C'
});
var scope = nock('http://myapp.iriscouch.com')
.post('/users', /email=.?@gmail.com/gi)
.reply(201, {
ok: true,
id: '123ABC',
rev: '946B7D1C'
});
var scope = nock('http://myapp.iriscouch.com')
.post('/users', {
username: 'pgte',
password: /a.+/,
email: 'pedro.teixeira@gmail.com'
})
.reply(201, {
ok: true,
id: '123ABC',
rev: '946B7D1C'
});
var scope = nock('http://myapp.iriscouch.com')
.post('/users', (body: any) => {
return body.id === '123ABC';
})
.reply(201, {
ok: true,
id: '123ABC',
rev: '946B7D1C'
});
// Specifying request query string
nock('http://example.com')
.get('/users')
.query({name: 'pedro', surname: 'teixeira'})
.reply(200, {results: [{id: 'pgte'}]});
nock('http://example.com')
.get('/users')
.query({
names: ['alice', 'bob'],
tags: {
alice: ['admin', 'tester'],
bob: ['tester']
}
})
.reply(200, {results: [{id: 'pgte'}]});
nock('http://example.com')
.get('/users')
.query((actualQueryObject: any) => {
// do some compare with the actual Query Object
// return true for matched
// return false for not matched
return true;
})
.reply(200, {results: [{id: 'pgte'}]});
nock('http://example.com')
.get('/users')
.query(true)
.reply(200, {results: [{id: 'pgte'}]});
// Specifying replies
var scope = nock('http://myapp.iriscouch.com')
.get('/users/1')
.reply(404);
var scope = nock('http://www.google.com')
.get('/')
.reply(200, 'Hello from Google!');
var scope = nock('http://myapp.iriscouch.com')
.get('/')
.reply(200, {
username: 'pgte',
email: 'pedro.teixeira@gmail.com',
_id: '4324243fsd'
});
var scope = nock('http://myapp.iriscouch.com')
.get('/')
.replyWithFile(200, __dirname + '/replies/user.json');
var scope = nock('http://www.google.com')
.filteringRequestBody(/.*/, '*')
.post('/echo', '*')
.reply(201, (uri: string, requestBody: string) => {
return requestBody;
});
var scope = nock('http://www.google.com')
.filteringRequestBody(/.*/, '*')
.post('/echo', '*')
.reply(201, (uri: string, requestBody: string, cb: nock.ReplyCallback) => {
fs.readFile('cat-poems.txt' , cb); // Error-first callback
});
var scope = nock('http://www.google.com')
.filteringRequestBody(/.*/, '*')
.post('/echo', '*')
.reply((uri, requestBody) => {
return [
201,
'THIS IS THE REPLY BODY',
{'header': 'value'} // optional headers
];
});
var scope = nock('http://www.google.com')
.filteringRequestBody(/.*/, '*')
.post('/echo', '*')
.reply((uri, requestBody, cb) => {
setTimeout(() => {
cb(null, [201, 'THIS IS THE REPLY BODY'])
}, 1e3);
});
var scope = nock('http://www.google.com')
.get('/cat-poems')
.reply(200, (uri: string, requestBody: string) => {
return fs.createReadStream('cat-poems.txt');
});
/// Access original request and headers
var scope = nock('http://www.google.com')
.get('/cat-poems')
.reply((uri, requestBody) => {
console.log('path:', this.req.path);
console.log('headers:', this.req.headers);
// ...
});
// Replying with errors
nock('http://www.google.com')
.get('/cat-poems')
.replyWithError('something awful happened');
nock('http://www.google.com')
.get('/cat-poems')
.replyWithError({'message': 'something awful happened', 'code': 'AWFUL_ERROR'});
// Specifying headers
/// Specifying Request Headers
var scope = nock('http://www.example.com', {
reqheaders: {
'authorization': 'Basic Auth'
}
})
.get('/')
.reply(200);
var scope = nock('http://www.example.com', {
reqheaders: {
'X-My-Headers': (headerValue) => {
if (headerValue) {
return true;
}
return false;
},
'X-My-Awesome-Header': /Awesome/i
}
})
.get('/')
.reply(200);
var scope = nock('http://www.example.com', {
badheaders: ['cookie', 'x-forwarded-for']
})
.get('/')
.reply(200);
var scope = nock('http://www.example.com')
.get('/')
.basicAuth({
user: 'john',
pass: 'doe'
})
.reply(200);
/// Specifying Reply Headers
var scope = nock('http://www.headdy.com')
.get('/')
.reply(200, 'Hello World!', {
'X-My-Headers': 'My Header value'
});
var scope = nock('http://www.headdy.com')
.get('/')
.reply(200, 'Hello World!', {
'X-My-Headers': (req, res, body) => {
return body.toString();
}
});
// Default Reply Headers
var scope = nock('http://www.headdy.com')
.defaultReplyHeaders({
'X-Powered-By': 'Rails',
'Content-Type': 'application/json'
})
.get('/')
.reply(200, 'The default headers should come too');
var scope = nock('http://www.headdy.com')
.defaultReplyHeaders({
'Content-Length': (req, res, body) => {
return body.length;
}
})
.get('/')
.reply(200, 'The default headers should come too');
// Including Content-Length Header Automatically
var scope = nock('http://www.headdy.com')
.replyContentLength()
.get('/')
.reply(200, { hello: 'world' });
// Including Date Header Automatically
var scope = nock('http://www.headdy.com')
.replyDate(new Date(2015, 0, 1)) // defaults to now, must use a Date object
.get('/')
.reply(200, { hello: 'world' });
// HTTP Verbs
nock('http://my.domain.com')
.intercept('/path', 'PATCH')
.reply(304);
// Support for HTTP and HTTPS
var scope = nock('https://secure.my.server.com');
// Non-standard ports
var scope = nock('http://my.server.com:8081');
// Repeat response n times
nock('http://zombo.com').get('/').times(4).reply(200, 'Ok');
nock('http://zombo.com').get('/').once().reply(200, 'Ok');
nock('http://zombo.com').get('/').twice().reply(200, 'Ok');
nock('http://zombo.com').get('/').thrice().reply(200, 'Ok');
// Delay the response body
nock('http://my.server.com')
.get('/')
.delayBody(2000) // 2 seconds
.reply(200, '<html></html>')
// Delay the response
nock('http://my.server.com')
.get('/')
.delay(2000) // 2 seconds delay will be applied to the response header.
.reply(200, '<html></html>')
nock('http://my.server.com')
.get('/')
.delay({
head: 2000, // header will be delayed for 2 seconds, i.e. the whole response will be delayed for 2 seconds.
body: 3000 // body will be delayed for another 3 seconds after header is sent out.
})
.reply(200, '<html></html>')
// Delay the connection
nock('http://my.server.com')
.get('/')
.socketDelay(2000) // 2 seconds
.delayConnection(1000)
.reply(200, '<html></html>')
// Chaining
var scope = nock('http://myapp.iriscouch.com')
.get('/users/1')
.reply(404)
.post('/users', {
username: 'pgte',
email: 'pedro.teixeira@gmail.com'
})
.reply(201, {
ok: true,
id: '123ABC',
rev: '946B7D1C'
})
.get('/users/123ABC')
.reply(200, {
_id: '123ABC',
_rev: '946B7D1C',
username: 'pgte',
email: 'pedro.teixeira@gmail.com'
});
// Scope filtering
var scope = nock('https://api.dropbox.com', {
filteringScope: (scope: string) => {
return /^https:\/\/api[0-9]*.dropbox.com/.test(scope);
}
})
.get('/1/metadata/auto/Photos?include_deleted=false&list=true')
.reply(200);
// Path filtering
var scope = nock('http://api.myservice.com')
.filteringPath(/password=[^&]*/g, 'password=XXX')
.get('/users/1?password=XXX')
.reply(200, 'user');
var scope = nock('http://api.myservice.com')
.filteringPath((path) => {
return '/ABC';
})
.get('/ABC')
.reply(200, 'user');
// Request Body filtering
var scope = nock('http://api.myservice.com')
.filteringRequestBody(/password=[^&]*/g, 'password=XXX')
.post('/users/1', 'data=ABC&password=XXX')
.reply(201, 'OK');
var scope = nock('http://api.myservice.com')
.filteringRequestBody((body) => {
return 'ABC';
})
.post('/', 'ABC')
.reply(201, 'OK');
// Request Headers Matching
var scope = nock('http://api.myservice.com')
.matchHeader('accept', 'application/json')
.get('/')
.reply(200, {
data: 'hello world'
})
var scope = nock('http://api.myservice.com')
.matchHeader('User-Agent', /Mozilla\/.*/)
.get('/')
.reply(200, {
data: 'hello world'
})
var scope = nock('http://api.myservice.com')
.matchHeader('content-length', (val) => {
return Number(val) >= 1000;
})
.get('/')
.reply(200, {
data: 'hello world'
})
// Allow unmocked requests on a mocked hostname
options = {allowUnmocked: true};
var scope = nock('http://my.existing.service.com', options)
.get('/my/url')
.reply(200, 'OK!');
// Expectations
var google = nock('http://google.com')
.get('/')
.reply(200, 'Hello from Google!');
setTimeout(() => {
google.done(); // will throw an assertion error if meanwhile a "GET http://google.com" was not performed.
}, 5000);
/// .isDone()
var scope = nock('http://google.com')
.get('/')
.reply(200);
scope.isDone(); // will return false
nock.isDone();
/// .cleanAll()
nock.cleanAll();
/// .persist()
var scope = nock('http://persisssists.con')
.persist()
.get('/')
.reply(200, 'Persisting all the way');
/// .pendingMocks()
if (!scope.isDone()) {
console.error('pending mocks: %j', scope.pendingMocks());
}
console.error('pending mocks: %j', nock.pendingMocks());
// Logging
var google = nock('http://google.com')
.log(console.log);
// Restoring
nock.restore();
// Enable/Disable real HTTP request
nock.disableNetConnect();
nock.enableNetConnect();
// using a string
nock.enableNetConnect('amazon.com');
// or a RegExp
nock.enableNetConnect(/(amazon|github).com/);
nock.disableNetConnect();
nock.enableNetConnect('127.0.0.1'); //Allow localhost connections so we can test local routes and mock servers.
nock.cleanAll();
nock.enableNetConnect();
// Recording
nock.recorder.rec();
/// dont_print option
nock.recorder.rec({
dont_print: true
});
// ... some HTTP calls
var nockCalls = nock.recorder.play();
/// output_objects option
nock.recorder.rec({
output_objects: true
});
// ... some HTTP calls
var nockCallObjects = nock.recorder.play();
var pathToJson: string;
var nocks = nock.load(pathToJson);
nocks.forEach((nock) => {
nock = nock.filteringRequestBody((body: string) => {
return body;
});
});
// Pre-process the nock definitions as scope filtering has to be defined before the nocks are defined (due to its very hacky nature).
var nockDefs = nock.loadDefs(pathToJson);
nockDefs.forEach((def) => {
// Do something with the definition object e.g. scope filtering.
def.options = def.options || {};
def.options.filteringScope = (scope: string) => {
return /^https:\/\/api[0-9]*.dropbox.com/.test(scope);
};
});
// Load the nocks from pre-processed definitions.
var nocks = nock.define(nockDefs);
/// enable_reqheaders_recording option
nock.recorder.rec({
dont_print: true,
output_objects: true,
enable_reqheaders_recording: true
});
/// logging option
var nullAppender = (content: string) => { };
nock.recorder.rec({
logging: nullAppender
});
/// use_separator option
nock.recorder.rec({
use_separator: false
});
// .removeInterceptor()
nock.removeInterceptor({
hostname : 'localhost',
path : '/mockedResource'
});
nock.removeInterceptor({
hostname : 'localhost',
path : '/login',
method: 'POST',
proto : 'https'
});
var interceptor = nock('http://example.org')
.get('somePath');
nock.removeInterceptor(interceptor);
// Events
/// Global no match event
nock.emitter.on('no match', (req: any) => { });
// Nock Back
/// Setup
import { back as nockBack } from 'nock';
nockBack.fixtures = '/path/to/fixtures/';
nockBack.setMode('record');
/// Usage
nockBack.setMode('record');
nockBack.fixtures = './nockFixtures'; //this only needs to be set once in your test helper
var before = (def: nock.NockDefinition) => {
def.options = def.options || {};
def.options.filteringScope = (scope: string) => {
return /^https:\/\/api[0-9]*.dropbox.com/.test(scope);
};
};
var after = (scope: nock.Scope) => {
scope = scope.filteringRequestBody((body: string): string => {
return body;
});
};
// recording of the fixture
declare var request: any;
nockBack('zomboFixture.json', { before, after }, (nockDone: () => void) => {
request.get('http://zombo.com', (err: any, res: any, body: string) => {
nockDone();
// usage of the created fixture
nockBack('zomboFixture.json', (nockDone: () => void) => {
nockDone(); //never gets here
});
});
});
strings = nock.recorder.play();
objects = nock.recorder.play();

237
nock/nock.d.ts vendored
View File

@@ -1,131 +1,164 @@
// Type definitions for nock v0.54.0
// Project: https://github.com/pgte/nock
// Definitions by: bonnici <https://github.com/bonnici>
// Type definitions for nock v8.0.0
// Project: https://github.com/node-nock/nock
// Definitions by: bonnici <https://github.com/bonnici>, Horiuchi_H <https://github.com/horiuchi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/nock.d.ts
/// <reference path="../node/node.d.ts" />
declare module "nock" {
export = nock;
export = nock;
function nock (host: string, options?: nock.Options): nock.Scope;
function nock(basePath: string | RegExp, options?: nock.Options): nock.Scope;
namespace nock {
export function cleanAll(): void;
namespace nock {
export function cleanAll(): void;
export function disableNetConnect(): void;
export function enableNetConnect(): void;
export function enableNetConnect(regex: RegExp): void;
export function enableNetConnect(domain: string): void;
export function load(path: string): Object[];
export function restore(): void;
export function activate(): void;
export function isActive(): boolean;
export function isDone(): boolean;
export function pendingMocks(): void;
export function removeInterceptor(interceptor: Interceptor | RequestOptions): boolean;
export function disableNetConnect(): void;
export function enableNetConnect(matcher?: string | RegExp): void;
export var recorder: Recorder;
export function load(path: string): Scope[];
export function loadDefs(path: string): NockDefinition[];
export function define(defs: NockDefinition[]): Scope[];
export interface Scope {
get(path: string, data?: string): Scope;
get(path: RegExp, data?: string): Scope;
export var emitter: NodeJS.EventEmitter;
post(path: string, data?: string): Scope;
post(path: string, data?: Object): Scope;
post(path: string, regex?: RegExp): Scope;
post(path: RegExp, data?: string): Scope;
post(path: RegExp, data?: Object): Scope;
post(path: RegExp, regex?: RegExp): Scope;
export var recorder: Recorder;
export function restore(): void;
patch(path: string, data?: string): Scope;
patch(path: string, data?: Object): Scope;
patch(path: string, regex?: RegExp): Scope;
patch(path: RegExp, data?: string): Scope;
patch(path: RegExp, data?: Object): Scope;
patch(path: RegExp, regex?: RegExp): Scope;
export var back: NockBack;
put(path: string, data?: string): Scope;
put(path: string, data?: Object): Scope;
put(path: string, regex?: RegExp): Scope;
put(path: RegExp, data?: string): Scope;
put(path: RegExp, data?: Object): Scope;
put(path: RegExp, regex?: RegExp): Scope;
type HttpHeaders = { [key: string]: string | { (req: any, res: any, body: string): any; }; };
type InterceptFunction = (
uri: string | RegExp | { (uri: string): boolean; },
requestBody?: string | RegExp | { (body: any): boolean; } | any
) => Interceptor;
export type ReplyCallback = (err: any, result: ReplyCallbackResult) => void;
type ReplyCallbackResult = string | [number, string | any] | [number, string | any, HttpHeaders] | any;
head(path: string): Scope;
head(path: RegExp): Scope;
delete(path: string, data?: string): Scope;
delete(path: string, data?: Object): Scope;
delete(path: string, regex?: RegExp): Scope;
delete(path: RegExp, data?: string): Scope;
delete(path: RegExp, data?: Object): Scope;
delete(path: RegExp, regex?: RegExp): Scope;
export interface Scope extends NodeJS.EventEmitter {
get: InterceptFunction;
post: InterceptFunction;
put: InterceptFunction;
head: InterceptFunction;
patch: InterceptFunction;
merge: InterceptFunction;
delete: InterceptFunction;
merge(path: string, data?: string): Scope;
merge(path: string, data?: Object): Scope;
merge(path: string, regex?: RegExp): Scope;
merge(path: RegExp, data?: string): Scope;
merge(path: RegExp, data?: Object): Scope;
merge(path: RegExp, regex?: RegExp): Scope;
intercept: (
uri: string | RegExp | { (uri: string): boolean; },
method: string,
requestBody?: string | RegExp | { (body: any): boolean; } | any,
options?: Options
) => Interceptor;
query(params: any): Scope;
query(acceptAnyParams: boolean): Scope;
intercept(path: string, verb: string, body?: string, options?: any): Scope;
intercept(path: string, verb: string, body?: Object, options?: any): Scope;
intercept(path: string, verb: string, body?: RegExp, options?: any): Scope;
intercept(path: RegExp, verb: string, body?: string, options?: any): Scope;
intercept(path: RegExp, verb: string, body?: Object, options?: any): Scope;
intercept(path: RegExp, verb: string, body?: RegExp, options?: any): Scope;
defaultReplyHeaders(headers: HttpHeaders): this;
matchHeader(name: string, value: string | RegExp | { (value: string): boolean; }): this;
filteringPath(regex: RegExp, replace: string): this;
filteringPath(fn: (path: string) => string): this;
filteringRequestBody(regex: RegExp, replace: string): this;
filteringRequestBody(fn: (body: string) => string): this;
reply(responseCode: number, body?: string, headers?: Object): Scope;
reply(responseCode: number, body?: Object, headers?: Object): Scope;
reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope;
replyWithFile(responseCode: number, fileName: string): Scope;
replyWithError(errorMessage: string): Scope;
log(out: () => void): this;
persist(): this;
shouldPersist(): boolean;
replyContentLength(): this;
replyDate(d?: Date): this;
defaultReplyHeaders(headers: Object): Scope;
done(): void;
isDone(): boolean;
restore(): void;
pendingMocks(): string[];
}
matchHeader(name: string, value: string): Scope;
matchHeader(name: string, regex: RegExp): Scope;
matchHeader(name: string, fn: (value: string) => boolean): Scope;
export interface Interceptor {
query(params: boolean | { (querObject: any): boolean; } | any): this;
filteringPath(regex: RegExp, replace: string): Scope;
filteringPath(fn: (path: string) => string): Scope;
filteringRequestBody(regex: RegExp, replace: string): Scope;
filteringRequestBody(fn: (path: string) => string): Scope;
reply(responseCode: number, body?: string | any, headers?: HttpHeaders): Scope;
reply(responseCode: number, callback: (uri: string, body: string, cb?: ReplyCallback) => ReplyCallbackResult, headers?: HttpHeaders): Scope;
reply(callback: (uri: string, body: string, cb?: ReplyCallback) => ReplyCallbackResult, headers?: HttpHeaders): Scope;
replyWithError(errorMessage: string | any): Scope;
replyWithFile(responseCode: number, fileName: string, headers?: HttpHeaders): Scope;
persist(): Scope;
log(out: () => void): Scope;
basicAuth(options: { user: string; pass?: string; }): this;
delay(timeMs: number): Scope;
delayBody(timeMs: number): Scope;
delayConnection(timeMs: number): Scope;
getTotalDelay(): number;
socketDelay(timeMs: number): Scope;
times(newCounter: number): this;
once(): this;
twice(): this;
thrice(): this;
times(repeats: number): Scope;
once(): Scope;
twice(): Scope;
thrice(): Scope;
delay(opts: number | { head?: number; body?: number; }): this;
delayBody(timeMs: number): this;
delayConnection(timeMs: number): this;
getTotalDelay(): number;
socketDelay(timeMs: number): this;
}
done(): void;
isDone(): boolean;
restore(): void;
pendingMocks(): Object[];
}
export interface Options {
allowUnmocked?: boolean;
reqheaders?: { [key: string]: string | RegExp | { (headerValue: string): boolean; }; };
badheaders?: string[];
filteringScope?: { (scope: string): boolean; };
}
export interface Recorder {
rec(capture?: boolean): void;
rec(options?: RecorderOptions): void;
play(): any[];
}
export interface RequestOptions {
proto?: string;
_https_?: boolean;
hostname?: string;
host?: string;
port?: number;
method?: string;
path?: string;
}
export interface Options {
allowUnmocked?: boolean;
}
export interface Recorder {
rec(options?: boolean | RecorderOptions): void;
clear(): void;
play(): string[] | NockDefinition[];
}
export interface RecorderOptions {
dont_print?: boolean;
output_objects?: boolean;
enable_reqheaders_recording?: boolean;
}
}
export interface RecorderOptions {
dont_print?: boolean;
output_objects?: boolean;
enable_reqheaders_recording?: boolean;
logging?: (content: string) => void;
use_separator?: boolean;
}
export interface NockDefinition {
scope: string;
port?: number | string;
method?: string;
path: string;
body?: string | any;
status?: number;
response?: string | any;
headers?: HttpHeaders;
reqheaders?: { [key: string]: string | RegExp | { (headerValue: string): boolean; }; };
options?: Options;
}
export type NockBackMode = "wild" | "dryrun" | "record" | "lockdown";
export interface NockBack {
fixtures: string;
setMode(mode: NockBackMode): void;
(fixtureName: string, nockedFn: (nockDone: () => void) => void): void;
(fixtureName: string, options: NockBackOptions, nockedFn: (nockDone: () => void) => void): void;
}
export interface NockBackOptions {
before?: (def: NockDefinition) => void;
after?: (scope: Scope) => void;
afterRecord?: (defs: NockDefinition[]) => NockDefinition[];
recorder?: RecorderOptions;
}
}
}

View File

@@ -1,3 +1,4 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="node-dir.d.ts" />
import * as dir from "node-dir";

View File

@@ -2,8 +2,11 @@
// Project: https://github.com/fshost/node-dir
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../node/node.d.ts"/>
declare module "node-dir" {
import { ReadStream } from "fs";
export interface Options {
// file encoding (defaults to 'utf8')
encoding?: string;
@@ -37,29 +40,32 @@ declare module "node-dir" {
}
export interface FileCallback {
(error: any, content: any, next: () => void): void;
(error: any, content: string | Buffer, next: () => void): void;
}
export interface FileNamedCallback {
(error: any, content: any, filename: string, next: () => void): void;
(error: any, content: string | Buffer, filename: string, next: () => void): void;
}
export interface StreamCallback {
(error: any, stream: any, next: () => void): void;
(error: any, stream: ReadStream, next: () => void): void;
}
export interface FinishedCallback {
(error: any, files: any): void;
(error: any, files: string[]): void;
}
export interface PathsResult {
files: string[];
dirs: string[];
}
export function readFiles(dir: string, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFilesStream(dir: string, options: Options, streamCallback: StreamCallback,
finishedCallback?: FinishedCallback): void;
export function files(dir: string, callback: (error: any, files: any) => void): void;
export function subdirs(dir: string, callback: (error: any, subdirs: any) => void): void;
export function paths(dir: string, callback: (error: any, paths: any) => void): void;
export function paths(dir: string, combine: boolean, callback: (error: any, paths: any) => void): void;
export function readFilesStream(dir: string, options: Options, streamCallback: StreamCallback, finishedCallback?: FinishedCallback): void;
export function files(dir: string, callback: (error: any, files: string[]) => void): void;
export function subdirs(dir: string, callback: (error: any, subdirs: string[]) => void): void;
export function paths(dir: string, callback: (error: any, paths: PathsResult) => void): void;
export function paths(dir: string, combine: boolean, callback: (error: any, paths: string[] | PathsResult) => void): void;
}

View File

@@ -28,36 +28,36 @@ import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer
/// Assert Tests : https://nodejs.org/api/assert.html ///
//////////////////////////////////////////////////////////
namespace assert_tests{
namespace assert_tests {
{
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
assert.deepStrictEqual({ a: 1 }, { a: 1 }, "uses === comparator");
assert.doesNotThrow(() => {
const b = false;
if (b) { throw "a hammer at your face"; }
}, undefined, "What the...*crunch*");
assert.equal(3, "3", "uses == comparator");
assert.fail(1, 2, undefined, '>');
assert.ifError(0);
assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses !== comparator");
assert.notEqual(1, 2, "uses != comparator");
assert.notStrictEqual(2, "2", "uses === comparator");
assert.ok(true);
assert.ok(1);
assert.strictEqual(1, 1, "uses === comparator");
assert.strictEqual(1, 1, "uses === comparator");
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
}
}
@@ -108,7 +108,7 @@ namespace events_tests {
result = emitter.emit(event, any, any);
result = emitter.emit(event, any, any, any);
}
{
class Networker extends events.EventEmitter {
constructor() {
@@ -145,13 +145,13 @@ namespace fs_tests {
var buffer: Buffer;
content = fs.readFileSync('testfile', 'utf8');
content = fs.readFileSync('testfile', {encoding : 'utf8'});
content = fs.readFileSync('testfile', { encoding: 'utf8' });
buffer = fs.readFileSync('testfile');
buffer = fs.readFileSync('testfile', {flag : 'r'});
buffer = fs.readFileSync('testfile', { flag: 'r' });
fs.readFile('testfile', 'utf8', (err, data) => content = data);
fs.readFile('testfile', {encoding : 'utf8'}, (err, data) => content = data);
fs.readFile('testfile', { encoding: 'utf8' }, (err, data) => content = data);
fs.readFile('testfile', (err, data) => buffer = data);
fs.readFile('testfile', {flag : 'r'}, (err, data) => buffer = data);
fs.readFile('testfile', { flag: 'r' }, (err, data) => buffer = data);
}
{
@@ -183,7 +183,7 @@ namespace fs_tests {
function bufferTests() {
var utf8Buffer = new Buffer('test');
var base64Buffer = new Buffer('','base64');
var base64Buffer = new Buffer('', 'base64');
var octets: Uint8Array = null;
var octetBuffer = new Buffer(octets);
var sharedBuffer = new Buffer(octets.buffer);
@@ -197,7 +197,7 @@ function bufferTests() {
// Class Method: Buffer.from(array)
{
const buf: Buffer = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
const buf: Buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
}
// Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
@@ -262,8 +262,8 @@ function bufferTests() {
// Buffer has Uint8Array's buffer field (an ArrayBuffer).
{
let buffer = new Buffer('123');
let octets = new Uint8Array(buffer.buffer);
let buffer = new Buffer('123');
let octets = new Uint8Array(buffer.buffer);
}
}
@@ -275,14 +275,14 @@ function bufferTests() {
namespace url_tests {
{
url.format(url.parse('http://www.example.com/xyz'));
// https://google.com/search?q=you're%20a%20lizard%2C%20gary
url.format({
protocol: 'https',
host: "google.com",
pathname: 'search',
query: { q: "you're a lizard, gary" }
});
});
}
{
@@ -299,7 +299,7 @@ namespace util_tests {
{
// Old and new util.inspect APIs
util.inspect(["This is nice"], false, 5);
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
}
}
@@ -324,17 +324,17 @@ namespace crypto_tests {
{
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
}
{
let hmac: crypto.Hmac;
(hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => {
let hash: Buffer | string = hmac.read();
});
}
{
//crypto_cipher_decipher_string_test
let key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
let key: Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
let clearText: string = "This is the clear text.";
let cipher: crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
let cipherText: string = cipher.update(clearText, "utf8", "hex");
@@ -369,21 +369,23 @@ namespace crypto_tests {
}
}
////////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html
////////////////////////////////////////////////////
//////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html ///
//////////////////////////////////////////////////
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
namespace tls_tests {
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
var tlsOpts: tls.TlsOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(tlsOpts);
var connOpts: tls.ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(connOpts);
}
////////////////////////////////////////////////////
/// Http tests : http://nodejs.org/api/http.html ///
@@ -397,26 +399,26 @@ namespace http_tests {
}
{
var agent: http.Agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
maxFreeSockets: 256
});
var agent: http.Agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
maxFreeSockets: 256
});
var agent: http.Agent = http.globalAgent;
var agent: http.Agent = http.globalAgent;
http.request({agent: false});
http.request({agent: agent});
http.request({agent: undefined});
http.request({ agent: false });
http.request({ agent: agent });
http.request({ agent: undefined });
}
{
// Make sure .listen() and .close() retuern a Server instance
http.createServer().listen(0).close().address();
net.createServer().listen(0).close().address();
}
{
var request = http.request('http://0.0.0.0');
request.once('error', function() { });
@@ -485,7 +487,7 @@ namespace dgram_tests {
////////////////////////////////////////////////////
namespace querystring_tests {
type SampleObject = {a: string; b: number;}
type SampleObject = { a: string; b: number; }
{
let obj: SampleObject;
@@ -538,7 +540,7 @@ namespace path_tests {
try {
path.join('foo', {}, 'bar');
}
catch(error) {
catch (error) {
}
@@ -652,11 +654,11 @@ namespace path_tests {
// }
path.format({
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
root: "/",
dir: "/home/user/dir",
base: "file.txt",
ext: ".txt",
name: "file"
});
// returns
// '/home/user/dir/file.txt'
@@ -722,7 +724,7 @@ namespace readline_tests {
}
{
let data: string|Buffer;
let data: string | Buffer;
let key: readline.Key;
rl.write(data);
@@ -739,8 +741,8 @@ namespace readline_tests {
{
let stream: NodeJS.WritableStream;
let dx: number|string;
let dy: number|string;
let dx: number | string;
let dy: number | string;
readline.moveCursor(stream, dx, dy);
}
@@ -778,7 +780,7 @@ namespace string_decoder_tests {
namespace child_process_tests {
{
childProcess.exec("echo test");
childProcess.spawnSync("echo test");
childProcess.spawnSync("echo test");
}
}
@@ -786,7 +788,7 @@ namespace child_process_tests {
/// cluster tests: https://nodejs.org/api/cluster.html ///
//////////////////////////////////////////////////////////////////////
namespace cluster_tests {
namespace cluster_tests  {
{
cluster.fork();
Object.keys(cluster.workers).forEach(key => {
@@ -838,7 +840,7 @@ namespace os_tests {
}
{
let result: {[index: string]: os.NetworkInterfaceInfo[]};
let result: { [index: string]: os.NetworkInterfaceInfo[] };
result = os.networkInterfaces();
}
@@ -916,7 +918,7 @@ namespace process_tests {
{
var eventEmitter: events.EventEmitter;
eventEmitter = process; // Test that process implements EventEmitter...
var _p: NodeJS.Process = process;
_p = p;
}

View File

@@ -30,36 +30,36 @@ import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer
/// Assert Tests : https://nodejs.org/api/assert.html ///
//////////////////////////////////////////////////////////
namespace assert_tests{
namespace assert_tests {
{
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
assert.deepStrictEqual({ a: 1 }, { a: 1 }, "uses === comparator");
assert.doesNotThrow(() => {
const b = false;
if (b) { throw "a hammer at your face"; }
}, undefined, "What the...*crunch*");
assert.equal(3, "3", "uses == comparator");
assert.fail(1, 2, undefined, '>');
assert.ifError(0);
assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses !== comparator");
assert.notEqual(1, 2, "uses != comparator");
assert.notStrictEqual(2, "2", "uses === comparator");
assert.ok(true);
assert.ok(1);
assert.strictEqual(1, 1, "uses === comparator");
assert.strictEqual(1, 1, "uses === comparator");
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
}
}
@@ -70,7 +70,7 @@ namespace assert_tests{
namespace events_tests {
let emitter: events.EventEmitter;
let event: string;
let event: string | symbol;
let listener: Function;
let any: any;
@@ -114,11 +114,11 @@ namespace events_tests {
}
{
let result: string[];
let result: (string | symbol)[];
result = emitter.eventNames();
}
{
class Networker extends events.EventEmitter {
constructor() {
@@ -139,31 +139,31 @@ namespace fs_tests {
fs.writeFile("thebible.txt",
"Do unto others as you would have them do unto you.",
assert.ifError);
fs.write(1234, "test");
fs.writeFile("Harry Potter",
"\"You be wizzing, Harry,\" jived Dumbledore.",
{
encoding: "ascii"
},
assert.ifError);
assert.ifError);
}
{
var content: string;
var buffer: Buffer;
content = fs.readFileSync('testfile', 'utf8');
content = fs.readFileSync('testfile', {encoding : 'utf8'});
content = fs.readFileSync('testfile', { encoding: 'utf8' });
buffer = fs.readFileSync('testfile');
buffer = fs.readFileSync('testfile', {flag : 'r'});
buffer = fs.readFileSync('testfile', { flag: 'r' });
fs.readFile('testfile', 'utf8', (err, data) => content = data);
fs.readFile('testfile', {encoding : 'utf8'}, (err, data) => content = data);
fs.readFile('testfile', { encoding: 'utf8' }, (err, data) => content = data);
fs.readFile('testfile', (err, data) => buffer = data);
fs.readFile('testfile', {flag : 'r'}, (err, data) => buffer = data);
fs.readFile('testfile', { flag: 'r' }, (err, data) => buffer = data);
}
{
var errno: string;
fs.readFile('testfile', (err, data) => {
@@ -172,52 +172,52 @@ namespace fs_tests {
}
});
}
{
fs.mkdtemp('/tmp/foo-', (err, folder) => {
console.log(folder);
// Prints: /tmp/foo-itXde2
});
}
{
var tempDir: string;
tempDir = fs.mkdtempSync('/tmp/foo-');
}
{
fs.watch('/tmp/foo-', (event, filename) => {
console.log(event, filename);
console.log(event, filename);
});
fs.watch('/tmp/foo-', 'utf8', (event, filename) => {
console.log(event, filename);
console.log(event, filename);
});
fs.watch('/tmp/foo-', {
recursive: true,
persistent: true,
encoding: 'utf8'
recursive: true,
persistent: true,
encoding: 'utf8'
}, (event, filename) => {
console.log(event, filename);
console.log(event, filename);
});
}
{
fs.access('/path/to/folder', (err) => {});
fs.access(Buffer.from(''), (err) => {});
fs.access('/path/to/folder', fs.constants.F_OK | fs.constants.R_OK, (err) => {});
fs.access(Buffer.from(''), fs.constants.F_OK | fs.constants.R_OK, (err) => {});
fs.access('/path/to/folder', (err) => { });
fs.access(Buffer.from(''), (err) => { });
fs.access('/path/to/folder', fs.constants.F_OK | fs.constants.R_OK, (err) => { });
fs.access(Buffer.from(''), fs.constants.F_OK | fs.constants.R_OK, (err) => { });
fs.accessSync('/path/to/folder');
fs.accessSync(Buffer.from(''));
fs.accessSync('path/to/folder', fs.constants.W_OK | fs.constants.X_OK);
fs.accessSync(Buffer.from(''), fs.constants.W_OK | fs.constants.X_OK);
}
}
@@ -228,7 +228,7 @@ namespace fs_tests {
function bufferTests() {
var utf8Buffer = new Buffer('test');
var base64Buffer = new Buffer('','base64');
var base64Buffer = new Buffer('', 'base64');
var octets: Uint8Array = null;
var octetBuffer = new Buffer(octets);
var sharedBuffer = new Buffer(octets.buffer);
@@ -250,7 +250,7 @@ function bufferTests() {
// Class Method: Buffer.from(array)
{
const buf: Buffer = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
const buf: Buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
}
// Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
@@ -373,8 +373,8 @@ function bufferTests() {
// Buffer has Uint8Array's buffer field (an ArrayBuffer).
{
let buffer = new Buffer('123');
let octets = new Uint8Array(buffer.buffer);
let buffer = new Buffer('123');
let octets = new Uint8Array(buffer.buffer);
}
}
@@ -386,14 +386,14 @@ function bufferTests() {
namespace url_tests {
{
url.format(url.parse('http://www.example.com/xyz'));
// https://google.com/search?q=you're%20a%20lizard%2C%20gary
url.format({
protocol: 'https',
host: "google.com",
pathname: 'search',
query: { q: "you're a lizard, gary" }
});
});
}
{
@@ -410,7 +410,7 @@ namespace util_tests {
{
// Old and new util.inspect APIs
util.inspect(["This is nice"], false, 5);
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
}
}
@@ -430,18 +430,18 @@ function stream_readable_pipe_test() {
// Simplified constructors
function simplified_stream_ctor_test() {
new stream.Readable({
read: function (size) {
read: function(size) {
size.toFixed();
}
});
new stream.Writable({
write: function (chunk, enc, cb) {
write: function(chunk, enc, cb) {
chunk.slice(1);
enc.charAt(0);
cb()
},
writev: function (chunks, cb) {
writev: function(chunks, cb) {
chunks[0].chunk.slice(0);
chunks[0].encoding.charAt(0);
cb();
@@ -449,15 +449,15 @@ function simplified_stream_ctor_test() {
});
new stream.Duplex({
read: function (size) {
read: function(size) {
size.toFixed();
},
write: function (chunk, enc, cb) {
write: function(chunk, enc, cb) {
chunk.slice(1);
enc.charAt(0);
cb()
},
writev: function (chunks, cb) {
writev: function(chunks, cb) {
chunks[0].chunk.slice(0);
chunks[0].encoding.charAt(0);
cb();
@@ -467,23 +467,23 @@ function simplified_stream_ctor_test() {
});
new stream.Transform({
transform: function (chunk, enc, cb) {
transform: function(chunk, enc, cb) {
chunk.slice(1);
enc.charAt(0);
cb();
},
flush: function (cb) {
flush: function(cb) {
cb()
},
read: function (size) {
read: function(size) {
size.toFixed();
},
write: function (chunk, enc, cb) {
write: function(chunk, enc, cb) {
chunk.slice(1);
enc.charAt(0);
cb()
},
writev: function (chunks, cb) {
writev: function(chunks, cb) {
chunks[0].chunk.slice(0);
chunks[0].encoding.charAt(0);
cb();
@@ -499,17 +499,17 @@ namespace crypto_tests {
{
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
}
{
let hmac: crypto.Hmac;
(hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => {
let hash: Buffer | string = hmac.read();
});
}
{
//crypto_cipher_decipher_string_test
let key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
let key: Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
let clearText: string = "This is the clear text.";
let cipher: crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
let cipherText: string = cipher.update(clearText, "utf8", "hex");
@@ -544,21 +544,23 @@ namespace crypto_tests {
}
}
////////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html
////////////////////////////////////////////////////
//////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html ///
//////////////////////////////////////////////////
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
namespace tls_tests {
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
var connOpts: tls.ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(connOpts);
var connOpts: tls.ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(connOpts);
}
////////////////////////////////////////////////////
/// Http tests : http://nodejs.org/api/http.html ///
@@ -572,26 +574,26 @@ namespace http_tests {
}
{
var agent: http.Agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
maxFreeSockets: 256
});
var agent: http.Agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 10000,
maxSockets: Infinity,
maxFreeSockets: 256
});
var agent: http.Agent = http.globalAgent;
var agent: http.Agent = http.globalAgent;
http.request({agent: false});
http.request({agent: agent});
http.request({agent: undefined});
http.request({ agent: false });
http.request({ agent: agent });
http.request({ agent: undefined });
}
{
// Make sure .listen() and .close() retuern a Server instance
http.createServer().listen(0).close().address();
net.createServer().listen(0).close().address();
}
{
var request = http.request('http://0.0.0.0');
request.once('error', function() { });
@@ -663,7 +665,7 @@ namespace dgram_tests {
////////////////////////////////////////////////////
namespace querystring_tests {
type SampleObject = {a: string; b: number;}
type SampleObject = { a: string; b: number; }
{
let obj: SampleObject;
@@ -716,7 +718,7 @@ namespace path_tests {
try {
path.join('foo', {}, 'bar');
}
catch(error) {
catch (error) {
}
@@ -830,11 +832,11 @@ namespace path_tests {
// }
path.format({
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
root: "/",
dir: "/home/user/dir",
base: "file.txt",
ext: ".txt",
name: "file"
});
// returns
// '/home/user/dir/file.txt'
@@ -900,7 +902,7 @@ namespace readline_tests {
}
{
let data: string|Buffer;
let data: string | Buffer;
let key: readline.Key;
rl.write(data);
@@ -917,8 +919,8 @@ namespace readline_tests {
{
let stream: NodeJS.WritableStream;
let dx: number|string;
let dy: number|string;
let dx: number | string;
let dy: number | string;
readline.moveCursor(stream, dx, dy);
}
@@ -959,7 +961,7 @@ namespace string_decoder_tests {
namespace child_process_tests {
{
childProcess.exec("echo test");
childProcess.spawnSync("echo test");
childProcess.spawnSync("echo test");
}
}
@@ -967,7 +969,7 @@ namespace child_process_tests {
/// cluster tests: https://nodejs.org/api/cluster.html ///
//////////////////////////////////////////////////////////////////////
namespace cluster_tests {
namespace cluster_tests {
{
cluster.fork();
Object.keys(cluster.workers).forEach(key => {
@@ -1019,7 +1021,7 @@ namespace os_tests {
}
{
let result: {[index: string]: os.NetworkInterfaceInfo[]};
let result: { [index: string]: os.NetworkInterfaceInfo[] };
result = os.networkInterfaces();
}
@@ -1080,19 +1082,19 @@ namespace vm_tests {
namespace timers_tests {
{
let immediateId = timers.setImmediate(function(){ console.log("immediate"); });
let immediateId = timers.setImmediate(function() { console.log("immediate"); });
timers.clearImmediate(immediateId);
}
{
let counter = 0;
let timeout = timers.setInterval(function(){ console.log("interval"); }, 20);
let timeout = timers.setInterval(function() { console.log("interval"); }, 20);
timeout.unref();
timeout.ref();
timers.clearInterval(timeout);
}
{
let counter = 0;
let timeout = timers.setTimeout(function(){ console.log("timeout"); }, 20);
let timeout = timers.setTimeout(function() { console.log("timeout"); }, 20);
timeout.unref();
timeout.ref();
timers.clearTimeout(timeout);
@@ -1122,7 +1124,7 @@ namespace process_tests {
{
var eventEmitter: events.EventEmitter;
eventEmitter = process; // Test that process implements EventEmitter...
var _p: NodeJS.Process = process;
_p = p;
}
@@ -1149,6 +1151,232 @@ namespace net_tests {
// Make sure .listen() and .close() retuern a Server instance
net.createServer().listen(0).close().address();
}
{
/**
* net.Socket - events.EventEmitter
* 1. close
* 2. connect
* 3. data
* 4. drain
* 5. end
* 6. error
* 7. lookup
* 8. timeout
*/
let _socket: net.Socket;
let bool: boolean;
let buffer: Buffer;
let error: Error;
let str: string;
let num: number;
/// addListener
_socket = _socket.addListener("close", had_error => {
bool = had_error;
})
_socket = _socket.addListener("connect", () => { })
_socket = _socket.addListener("data", data => {
buffer = data;
})
_socket = _socket.addListener("drain", () => { })
_socket = _socket.addListener("end", () => { })
_socket = _socket.addListener("error", err => {
error = err;
})
_socket = _socket.addListener("lookup", (err, address, family, host) => {
error = err;
if (typeof family === 'string') {
str = family;
} else if (typeof family === 'number') {
num = family;
}
str = host;
})
_socket = _socket.addListener("timeout", () => { })
/// emit
bool = _socket.emit("close", bool);
bool = _socket.emit("connect");
bool = _socket.emit("data", buffer);
bool = _socket.emit("drain");
bool = _socket.emit("end");
bool = _socket.emit("error", error);
bool = _socket.emit("lookup", error, str, str, str);
bool = _socket.emit("lookup", error, str, num, str);
bool = _socket.emit("timeout");
/// on
_socket = _socket.on("close", had_error => {
bool = had_error;
})
_socket = _socket.on("connect", () => { })
_socket = _socket.on("data", data => {
buffer = data;
})
_socket = _socket.on("drain", () => { })
_socket = _socket.on("end", () => { })
_socket = _socket.on("error", err => {
error = err;
})
_socket = _socket.on("lookup", (err, address, family, host) => {
error = err;
if (typeof family === 'string') {
str = family;
} else if (typeof family === 'number') {
num = family;
}
str = host;
})
_socket = _socket.on("timeout", () => { })
/// once
_socket = _socket.once("close", had_error => {
bool = had_error;
})
_socket = _socket.once("connect", () => { })
_socket = _socket.once("data", data => {
buffer = data;
})
_socket = _socket.once("drain", () => { })
_socket = _socket.once("end", () => { })
_socket = _socket.once("error", err => {
error = err;
})
_socket = _socket.once("lookup", (err, address, family, host) => {
error = err;
if (typeof family === 'string') {
str = family;
} else if (typeof family === 'number') {
num = family;
}
str = host;
})
_socket = _socket.once("timeout", () => { })
/// prependListener
_socket = _socket.prependListener("close", had_error => {
bool = had_error;
})
_socket = _socket.prependListener("connect", () => { })
_socket = _socket.prependListener("data", data => {
buffer = data;
})
_socket = _socket.prependListener("drain", () => { })
_socket = _socket.prependListener("end", () => { })
_socket = _socket.prependListener("error", err => {
error = err;
})
_socket = _socket.prependListener("lookup", (err, address, family, host) => {
error = err;
if (typeof family === 'string') {
str = family;
} else if (typeof family === 'number') {
num = family;
}
str = host;
})
_socket = _socket.prependListener("timeout", () => { })
/// prependOnceListener
_socket = _socket.prependOnceListener("close", had_error => {
bool = had_error;
})
_socket = _socket.prependOnceListener("connect", () => { })
_socket = _socket.prependOnceListener("data", data => {
buffer = data;
})
_socket = _socket.prependOnceListener("drain", () => { })
_socket = _socket.prependOnceListener("end", () => { })
_socket = _socket.prependOnceListener("error", err => {
error = err;
})
_socket = _socket.prependOnceListener("lookup", (err, address, family, host) => {
error = err;
if (typeof family === 'string') {
str = family;
} else if (typeof family === 'number') {
num = family;
}
str = host;
})
_socket = _socket.prependOnceListener("timeout", () => { })
}
{
/**
* net.Server - events.EventEmitter
* 1. close
* 2. connection
* 3. error
* 4. listening
*/
let _server: net.Server;
let _socket: net.Socket;
let bool: boolean;
let error: Error;
/// addListener
_server = _server.addListener("close", () => { })
_server = _server.addListener("connection", socket => {
_socket = socket
})
_server = _server.addListener("error", err => {
error = err;
})
_server = _server.addListener("listening", () => { })
/// emit
bool = _server.emit("close")
bool = _server.emit("connection", _socket)
bool = _server.emit("error", error)
bool = _server.emit("listening")
/// once
_server = _server.once("close", () => { })
_server = _server.once("connection", socket => {
_socket = socket
})
_server = _server.once("error", err => {
error = err;
})
_server = _server.once("listening", () => { })
/// prependListener
_server = _server.prependListener("close", () => { })
_server = _server.prependListener("connection", socket => {
_socket = socket
})
_server = _server.prependListener("error", err => {
error = err;
})
_server = _server.prependListener("listening", () => { })
/// prependOnceListener
_server = _server.prependOnceListener("close", () => { })
_server = _server.prependOnceListener("connection", socket => {
_socket = socket
})
_server = _server.prependOnceListener("error", err => {
error = err;
})
_server = _server.prependOnceListener("listening", () => { })
}
}
/*****************************************************************************

296
node/node.d.ts vendored
View File

@@ -241,20 +241,20 @@ declare namespace NodeJS {
}
export class EventEmitter {
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
addListener(event: string | symbol, listener: Function): this;
on(event: string | symbol, listener: Function): this;
once(event: string | symbol, listener: Function): this;
removeListener(event: string | symbol, listener: Function): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
listeners(event: string | symbol): Function[];
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(type: string | symbol): number;
// Added in Node 6...
prependListener(event: string, listener: Function): this;
prependOnceListener(event: string, listener: Function): this;
eventNames(): string[];
prependListener(event: string | symbol, listener: Function): this;
prependOnceListener(event: string | symbol, listener: Function): this;
eventNames(): (string | symbol)[];
}
export interface ReadableStream extends EventEmitter {
@@ -464,7 +464,7 @@ interface IterableIterator<T> { }
interface NodeBuffer extends Uint8Array {
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): {type: 'Buffer', data: any[]};
toJSON(): { type: 'Buffer', data: any[] };
equals(otherBuffer: Buffer): boolean;
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
@@ -549,22 +549,22 @@ declare module "querystring" {
declare module "events" {
export class EventEmitter extends NodeJS.EventEmitter {
static EventEmitter: EventEmitter;
static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated
static defaultMaxListeners: number;
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
prependListener(event: string, listener: Function): this;
prependOnceListener(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
addListener(event: string | symbol, listener: Function): this;
on(event: string | symbol, listener: Function): this;
once(event: string | symbol, listener: Function): this;
prependListener(event: string | symbol, listener: Function): this;
prependOnceListener(event: string | symbol, listener: Function): this;
removeListener(event: string | symbol, listener: Function): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
eventNames(): string[];
listenerCount(type: string): number;
listeners(event: string | symbol): Function[];
emit(event: string | symbol, ...args: any[]): boolean;
eventNames(): (string | symbol)[];
listenerCount(type: string | symbol): number;
}
}
@@ -658,8 +658,8 @@ declare module "http" {
}
export interface IncomingMessage extends stream.Readable {
httpVersion: string;
httpVersionMajor: string;
httpVersionMinor: string;
httpVersionMajor: number;
httpVersionMinor: number;
connection: net.Socket;
headers: any;
rawHeaders: string[];
@@ -778,6 +778,56 @@ declare module "cluster" {
disconnect(): void;
isConnected(): boolean;
isDead(): boolean;
exitedAfterDisconnect: boolean;
/**
* events.EventEmitter
* 1. disconnect
* 2. error
* 3. exit
* 4. listening
* 5. message
* 6. online
*/
addListener(event: string, listener: Function): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (code: number, signal: string) => void): this;
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
addListener(event: "listening", listener: (address: Address) => void): this;
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: () => void): this;
on(event: string, listener: Function): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (code: number, signal: string) => void): this;
on(event: "exit", listener: (code: number, signal: string) => void): this;
on(event: "listening", listener: (address: Address) => void): this;
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
on(event: "online", listener: () => void): this;
once(event: string, listener: Function): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (code: number, signal: string) => void): this;
once(event: "exit", listener: (code: number, signal: string) => void): this;
once(event: "listening", listener: (address: Address) => void): this;
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
once(event: "online", listener: () => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (code: number, signal: string) => void): this;
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependListener(event: "listening", listener: (address: Address) => void): this;
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependListener(event: "online", listener: () => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependOnceListener(event: "online", listener: () => void): this;
}
export interface Cluster extends events.EventEmitter {
@@ -851,7 +901,7 @@ declare module "cluster" {
}
export function disconnect(callback ?: Function): void;
export function disconnect(callback?: Function): void;
export function fork(env?: any): Worker;
export var isMaster: boolean;
export var isWorker: boolean;
@@ -1541,7 +1591,7 @@ declare module "dns" {
export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) =>void ): string[];
export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[];
export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
@@ -1616,6 +1666,77 @@ declare module "net" {
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
end(data?: any, encoding?: string): void;
/**
* events.EventEmitter
* 1. close
* 2. connect
* 3. data
* 4. drain
* 5. end
* 6. error
* 7. lookup
* 8. timeout
*/
addListener(event: string, listener: Function): this;
addListener(event: "close", listener: (had_error: boolean) => void): this;
addListener(event: "connect", listener: () => void): this;
addListener(event: "data", listener: (data: Buffer) => void): this;
addListener(event: "drain", listener: () => void): this;
addListener(event: "end", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
addListener(event: "timeout", listener: () => void): this;
emit(event: string, ...args: any[]): boolean;
emit(event: "close", had_error: boolean): boolean;
emit(event: "connect"): boolean;
emit(event: "data", data: Buffer): boolean;
emit(event: "drain"): boolean;
emit(event: "end"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
emit(event: "timeout"): boolean;
on(event: string, listener: Function): this;
on(event: "close", listener: (had_error: boolean) => void): this;
on(event: "connect", listener: () => void): this;
on(event: "data", listener: (data: Buffer) => void): this;
on(event: "drain", listener: () => void): this;
on(event: "end", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
on(event: "timeout", listener: () => void): this;
once(event: string, listener: Function): this;
once(event: "close", listener: (had_error: boolean) => void): this;
once(event: "connect", listener: () => void): this;
once(event: "data", listener: (data: Buffer) => void): this;
once(event: "drain", listener: () => void): this;
once(event: "end", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
once(event: "timeout", listener: () => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "close", listener: (had_error: boolean) => void): this;
prependListener(event: "connect", listener: () => void): this;
prependListener(event: "data", listener: (data: Buffer) => void): this;
prependListener(event: "drain", listener: () => void): this;
prependListener(event: "end", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
prependListener(event: "timeout", listener: () => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
prependOnceListener(event: "connect", listener: () => void): this;
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
prependOnceListener(event: "drain", listener: () => void): this;
prependOnceListener(event: "end", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
prependOnceListener(event: "timeout", listener: () => void): this;
}
export var Socket: {
@@ -1647,6 +1768,49 @@ declare module "net" {
unref(): Server;
maxConnections: number;
connections: number;
/**
* events.EventEmitter
* 1. close
* 2. connection
* 3. error
* 4. listening
*/
addListener(event: string, listener: Function): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "connection", listener: (socket: Socket) => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "listening", listener: () => void): this;
emit(event: string, ...args: any[]): boolean;
emit(event: "close"): boolean;
emit(event: "connection", socket: Socket): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "listening"): boolean;
on(event: string, listener: Function): this;
on(event: "close", listener: () => void): this;
on(event: "connection", listener: (socket: Socket) => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "listening", listener: () => void): this;
once(event: string, listener: Function): this;
once(event: "close", listener: () => void): this;
once(event: "connection", listener: (socket: Socket) => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "listening", listener: () => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "connection", listener: (socket: Socket) => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "listening", listener: () => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "listening", listener: () => void): this;
}
export function createServer(connectionListener?: (socket: Socket) => void): Server;
export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server;
@@ -1738,16 +1902,92 @@ declare module "fs" {
interface FSWatcher extends events.EventEmitter {
close(): void;
/**
* events.EventEmitter
* 1. change
* 2. error
*/
addListener(event: string, listener: Function): this;
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
addListener(event: "error", listener: (code: number, signal: string) => void): this;
on(event: string, listener: Function): this;
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
on(event: "error", listener: (code: number, signal: string) => void): this;
once(event: string, listener: Function): this;
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
once(event: "error", listener: (code: number, signal: string) => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
prependListener(event: "error", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
}
export interface ReadStream extends stream.Readable {
close(): void;
destroy(): void;
/**
* events.EventEmitter
* 1. open
* 2. close
*/
addListener(event: string, listener: Function): this;
addListener(event: "open", listener: (fd: number) => void): this;
addListener(event: "close", listener: () => void): this;
on(event: string, listener: Function): this;
on(event: "open", listener: (fd: number) => void): this;
on(event: "close", listener: () => void): this;
once(event: string, listener: Function): this;
once(event: "open", listener: (fd: number) => void): this;
once(event: "close", listener: () => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "open", listener: (fd: number) => void): this;
prependListener(event: "close", listener: () => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "open", listener: (fd: number) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
}
export interface WriteStream extends stream.Writable {
close(): void;
bytesWritten: number;
path: string | Buffer;
/**
* events.EventEmitter
* 1. open
* 2. close
*/
addListener(event: string, listener: Function): this;
addListener(event: "open", listener: (fd: number) => void): this;
addListener(event: "close", listener: () => void): this;
on(event: string, listener: Function): this;
on(event: "open", listener: (fd: number) => void): this;
on(event: "close", listener: () => void): this;
once(event: string, listener: Function): this;
once(event: "open", listener: (fd: number) => void): this;
once(event: "close", listener: () => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "open", listener: (fd: number) => void): this;
prependListener(event: "close", listener: () => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "open", listener: (fd: number) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
}
/**

2
nvd3/nvd3.d.ts vendored
View File

@@ -159,6 +159,8 @@ declare namespace nv {
interpolate(value: string): this;
rightAlignYAxis(): boolean;
rightAlignYAxis(value: boolean): this;
syncBrushing(): boolean;
syncBrushing(value: boolean): this;
}
interface Nvd3Axis extends d3.svg.Axis {

View File

@@ -88,6 +88,34 @@ declare namespace olx {
target?: Element;
}
interface AttributionControlOptions {
/*** CSS class name. Default is ol-attribution.*/
className?: string;
/*** Target.*/
target?: Element;
/**
* Specify if attributions can be collapsed. If you use an OSM source,
* should be set to false — see OSM Copyright — Default is true.
*/
collapsible?: boolean;
/*** Specify if attributions should be collapsed at startup. Default is true.*/
collapsed?: boolean;
/*** Text label to use for the button tip. Default is "Attributions".*/
tipLabel?: Array<ol.layer.Layer> | ol.Collection<ol.layer.Layer>;
/**
* Text label to use for the collapsed attributions button. Default is i.
* Instead of text, also a Node (e.g. a span element) can be used.
*/
label?: string | Node;
/**
* Text label to use for the expanded attributions button. Default is ».
* Instead of text, also a Node (e.g. a span element) can be used.
*/
collapseLabel?: string | Node;
/*** Function called when the control should be re-rendered. This is called in a requestAnimationFrame callback.*/
render?: Function;
}
interface AttributionOptions {
/** HTML markup for this attribution. */
@@ -2841,7 +2869,41 @@ declare namespace ol {
}
/**
* Control to show all the attributions associated with the layer sources in the map.
* This control is one of the default controls included in maps. By default it will show in the bottom right portion of the map,
* but this can be changed by using a css selector for .ol-attribution.
*/
class Attribution extends Control {
constructor(opt_options?: olx.AttributionControlOptions);
/**
* Update the attribution element.
* @param mapEvent
*/
render(mapEvent: ol.MapEvent): void;
/**
* Return true when the attribution is currently collapsed or false otherwise.
*/
getCollapsed(): boolean;
/**
* Return true if the attribution is collapsible, false otherwise.
*/
getCollapsible(): boolean;
/**
* Collapse or expand the attribution according to the passed parameter. Will not do anything if the attribution isn't
* collapsible or if the current collapsed state is already the one requested.
* @param collapsed
*/
setCollapsed(collapsed: boolean): void;
/**
* Set whether the attribution should be collapsible.
* @param collapsible
*/
setCollapsible(collapsible: boolean): void;
}
class FullScreen extends Control {

View File

@@ -0,0 +1,27 @@
/// <reference path="parse-mockdb.d.ts" />
import * as ParseMockDB from "parse-mockdb";
ParseMockDB.mockDB(); // Mock the Parse RESTController
// from parse-mockdb test suite
ParseMockDB.registerHook("Foo", "beforeSave", (request) => {
const object = request.object;
if (object.get('error')) {
return Parse.Promise.error('whoah');
}
object.set('cool', true);
return Parse.Promise.as(object);
});
// from parse-mockdb test suite
ParseMockDB.registerHook("Foo", "beforeDelete", (request) => {
const object = request.object;
if (object.get('error')) {
return Parse.Promise.error('whoah');
}
return Parse.Promise.as({});
});
ParseMockDB.cleanUp(); // Clear the Database
ParseMockDB.unMockDB(); // Un-mock the Parse RESTController

21
parse-mockdb/parse-mockdb.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
// Type definitions for parse-mockdb v0.1.13
// Project: https://github.com/HustleInc/parse-mockdb
// Definitions by: David Poetzsch-Heffter <https://github.com/dpoetzsch>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../parse/parse.d.ts" />
declare namespace ParseMockDB {
function mockDB(): void;
function unMockDB(): void;
function cleanUp(): void;
function promiseResultSync<T>(promise: Parse.IPromise<T>): T;
type HookType = "beforeSave" | "beforeDelete";
function registerHook(className: string, hookType: HookType, hookFn: (request: Parse.Cloud.BeforeSaveRequest) => Parse.IPromise<any>): void;
}
declare module "parse-mockdb" {
export = ParseMockDB;
}

View File

@@ -1,10 +1,8 @@
/// <reference path="./polylabel.d.ts" />
/// <reference path="../node/node.d.ts" />
import polylabel = require('polylabel');
import * as polylabel from 'polylabel';
const polygon = [[[3116,3071],[3118,3068],[3108,3102],[3751,927]]]
let p: number[]
p = polylabel(polygon)
p = polylabel(polygon, 1.0)
p = polylabel(polygon, 1.0, true)
p = polylabel(polygon, 1.0, false)
polylabel(polygon)
polylabel(polygon, 1.0)
polylabel(polygon, 1.0, true)
polylabel(polygon, 1.0, false)

View File

@@ -15,7 +15,7 @@
* - guarantees finding global optimum within the given precision
* - is many times faster (10-40x)
*/
declare module 'polylabel' {
declare module "polylabel" {
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
*
@@ -28,6 +28,7 @@ declare module 'polylabel' {
* @example
* var p = polylabel(polygon, 1.0);
*/
function polylabel (polygon: number[][][], precision?: number, debug?: boolean): number[];
function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
namespace polylabel {}
export = polylabel;
}

View File

@@ -127,15 +127,16 @@ declare namespace polymer {
unlinkPaths?(path: string): void;
push?(path: string): number;
push?(path: string, ...item: any[]): number;
pop?(path: string): any;
splice?(path: string, start: number, deleteCount: number): number;
splice?(path: string, index: number, removeCount: number, ...item: any[]):
number;
shift?(path: string): any;
unshift?(path: string): number;
unshift?(path: string, ...item: any[]): number;
// ResolveUrl

View File

@@ -38,6 +38,23 @@ namespace PouchDBCoreTests {
});
}
function testBulkDocs() {
const db = new PouchDB<MyModel>();
type MyModel = { property: 'someProperty '};
let model: PouchDB.Core.Document<MyModel>;
let model2: PouchDB.Core.Document<MyModel>;
db.bulkDocs([model, model2]).then((result) => {
result.forEach(({ ok, id, rev }) => {
isString(id);
isString(rev);
});
});
db.bulkDocs([model, model2], null, (error, response) => {
});
}
function testCompact() {
const db = new PouchDB<{}>();
// Promise version

View File

@@ -268,6 +268,12 @@ declare namespace PouchDB {
allDocs(options?: Core.AllDocsOptions):
Promise<Core.AllDocsResponse<Content>>;
bulkDocs(docs: Core.Document<Content>[],
options: Core.PutOptions | void,
callback: Core.Callback<Core.Error, Core.Response[]>): void;
bulkDocs(docs: Core.Document<Content>[],
options?: Core.PutOptions): Promise<Core.Response[]>;
/** Compact the database */
compact(options?: Core.CompactOptions): Promise<Core.Response>;
compact(options: Core.CompactOptions,

50
proj4/proj4-tests.ts Normal file
View File

@@ -0,0 +1,50 @@
/// <reference path="proj4.d.ts"/>
import * as proj4 from 'proj4'
///////////////////////////////////////////
// Tests data initialisation
///////////////////////////////////////////
const name = 'WGS84'
const epsg = {
4269: '+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees',
4326: '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees',
}
const point1 = [-71, 41]
const point2 = {x: 2, y: 5}
const mgrs = "24XWT783908"
///////////////////////////////////////////
// Tests Measurement
///////////////////////////////////////////
proj4(epsg['4269'], epsg['4326'], point1)
proj4(epsg['4269'], point1)
proj4(epsg['4269'], epsg['4326']).forward(point2)
proj4(epsg['4269'], epsg['4326']).inverse(point2)
///////////////////////////////////
// Named Projections
///////////////////////////////////
proj4.defs('WGS84', epsg['4326'])
proj4.defs([
['EPSG:4326', epsg['4326']],
['EPSG:4269', epsg['4269']]
])
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'))
///////////////////////////////////
// Utils
///////////////////////////////////
// WGS84
proj4.WGS84
// Proj
proj4.Proj('WGS84')
// toPoint
proj4.toPoint([1, 2])
proj4.toPoint([1, 2, 3])
proj4.toPoint([1, 2, 3, 4])
// Point
// WARNING: Deprecated in v3
proj4.Point([1, 2, 3, 4])

102
proj4/proj4.d.ts vendored Normal file
View File

@@ -0,0 +1,102 @@
// Type definitions for proj4 2.3.15
// Project: https://github.com/proj4js/proj4js
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "proj4" {
const TemplateCoordinates: Array<number> | InterfaceCoordinates;
interface InterfaceCoordinates {
x: number,
y: number,
z?: number,
m?: number
}
interface InterfaceDatum {
datum_type: number
a: number
b: number
es: number
ep2: number
}
interface Proj4Static {
forward(coordinates: typeof TemplateCoordinates): Array<number>
inverse(coordinates: typeof TemplateCoordinates): Array<number>
}
interface InterfaceProjection {
datum: string
b: number
rf: number
sphere: number
es: number
e: number
ep2: number
forward(coordinates: typeof TemplateCoordinates): Array<number>
inverse(coordinates: typeof TemplateCoordinates): Array<number>
}
namespace proj4 {
/**
* @name defaultDatum
*/
export const defaultDatum: string;
/**
* @name Proj
*/
export function Proj(srsCode:any, callback?: any): InterfaceProjection;
/**
* @name WGS84
*/
export const WGS84: any;
/**
* Depecrated v3
* @name Point
*/
export function Point(x: number, y: number, z?: number): InterfaceCoordinates;
export function Point(coordinates: Array<number>): InterfaceCoordinates;
export function Point(coordinates: InterfaceCoordinates): InterfaceCoordinates;
export function Point(coordinates: string): InterfaceCoordinates;
/**
* @name toPoint
*/
export function toPoint(array: Array<number>): InterfaceCoordinates;
/**
* @name defs
*/
export function defs(name: string): any;
export function defs(name: string, projection: string): any;
export function defs(name: Array<Array<string>>): any;
/**
* @name transform
*/
export function transform(source: InterfaceProjection, dest: InterfaceProjection, point: typeof TemplateCoordinates): any;
/**
* @name mgrs
*/
export function mgrs(coordinates: Array<number>, accuracy: number): string;
/**
* @name version
*/
export const version: string;
}
/**
* @name proj4
*/
function proj4(fromProjection: string): Proj4Static;
function proj4(fromProjection: string, toProjection: string): Proj4Static;
function proj4(fromProjection: string, coordinates: typeof TemplateCoordinates): Array<number>;
function proj4(fromProjection: string, toProjection: string, coordinates: typeof TemplateCoordinates): Array<number>;
export = proj4
}

103
pug/pug-tests.ts Normal file
View File

@@ -0,0 +1,103 @@
/// <reference path="pug.d.ts"/>
import * as pug from 'pug';
////////////////////////////////////////////////////////////
/// Options https://pugjs.org/api/reference.html#options ///
////////////////////////////////////////////////////////////
namespace options_tests {
let opts: pug.Options;
let str = 'string'
let bool = false;
let strArray = ['string'];
opts.filename = str;
opts.basedir = str;
opts.doctype = str;
opts.pretty = str;
opts.pretty = bool;
opts.filters = {};
opts.self = bool;
opts.debug = bool;
opts.compileDebug = bool;
opts.globals = strArray;
opts.cache = bool;
opts.inlineRuntimeFunctions = bool;
opts.name = str;
}
////////////////////////////////////////////////////////////
/// Methods https://pugjs.org/api/reference.html#methods ///
////////////////////////////////////////////////////////////
namespace methods_tests {
let source = `p #{ name } 's Pug source code!`;
let path = "foo.pug";
let compileTemplate: pug.compileTemplate;
let template: string;
let clientFunctionString: pug.ClientFunctionString;
let str: string;
{
/// pug.compile(source, ?options) https://pugjs.org/api/reference.html#pugcompilesource-options
compileTemplate = pug.compile(source);
template = compileTemplate();
}
{
/// pug.compileFile(path, ?options) https://pugjs.org/api/reference.html#pugcompilefilepath-options
compileTemplate = pug.compileFile(path);
template = compileTemplate();
}
{
/// pug.compileClient(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientsource-options
clientFunctionString = pug.compileClient(path);
str = pug.compileClient(path);
}
{
/// pug.compileClientWithDependenciesTracked(source, ?options) https://pugjs.org/api/reference.html#pugcompileclientwithdependenciestrackedsource-options
let obj = pug.compileClientWithDependenciesTracked(source);
clientFunctionString = obj.body;
str = obj.body;
let strArray: string[] = obj.dependencies;
}
{
/// pug.compileFileClient(path, ?options) https://pugjs.org/api/reference.html#pugcompilefileclientpath-options
clientFunctionString = pug.compileFileClient(path);
str = pug.compileFileClient(path);
}
{
/// pug.render(source, ?options, ?callback) https://pugjs.org/api/reference.html#pugrendersource-options-callback
str = pug.render(source);
// test type for callback paraments
pug.render(source, {}, (err, html) => {
let e: Error = err;
str = html;
});
}
{
/// pug.renderFile(path, ?options, ?callback) https://pugjs.org/api/reference.html#pugrenderfilepath-options-callback
str = pug.renderFile(path);
// test type for callback paraments
pug.renderFile(path, {}, (err, html) => {
let e: Error = err;
str = html;
});
}
}

50
pug/pug.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
// Type definitions for pug 2.0.0-beta6
// Project: https://github.com/pugjs/pug
// Definitions by: TonyYang <https://github.com/TonyPythoneer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Table of Contents
*
* - Options https://pugjs.org/api/reference.html#options
* - Methods https://pugjs.org/api/reference.html#methods
*
* The order of contents is according to pugjs API document.
*/
declare module 'pug' {
////////////////////////////////////////////////////////////
/// Options https://pugjs.org/api/reference.html#options ///
////////////////////////////////////////////////////////////
export interface Options {
filename?: string;
basedir?: string;
doctype?: string;
pretty?: boolean | string;
filters?: any;
self?: boolean;
debug?: boolean;
compileDebug?: boolean;
globals?: string[];
cache?: boolean;
inlineRuntimeFunctions?: boolean;
name?: string;
}
////////////////////////////////////////////////////////////
/// Methods https://pugjs.org/api/reference.html#methods ///
////////////////////////////////////////////////////////////
export function compile(source: string, options?: Options): (locals?: any) => string;
export function compileFile(path: string, options?: Options): (locals?: any) => string;
export function compileClient(source: string, options?: Options): ClientFunctionString;
export function compileClientWithDependenciesTracked(source: string, options?: Options): {
body: ClientFunctionString;
dependencies: string[];
};
export function compileFileClient(path: string, options?: Options): ClientFunctionString;
export function render(source: string, options?: Options, callback?: (err: Error, html: string) => void): string;
export function renderFile(path: string, options?: Options, callback?: (err: Error, html: string) => void): string;
// else
export type ClientFunctionString = string; // ex: 'function (locals) {...}'
export type compileTemplate = (locals?: any) => string;
}

View File

@@ -0,0 +1,40 @@
/// <reference path="randomcolor.d.ts" />
// Returns a hex code for an attractive color
randomColor();
// Returns an array of ten green colors
randomColor({
count: 10,
hue: 'green'
});
// Returns a hex code for a light blue
randomColor({
luminosity: 'light',
hue: 'blue'
});
// Returns a hex code for a 'truly random' color
randomColor({
luminosity: 'random',
hue: 'random'
});
// Returns a bright color in RGB
randomColor({
luminosity: 'bright',
format: 'rgb' // e.g. 'rgb(225,200,20)'
});
// Returns a dark RGB color with random alpha
randomColor({
luminosity: 'dark',
format: 'rgba' // e.g. 'rgba(9, 1, 107, 0.6482447960879654)'
});
// Returns a light HSL color with random alpha
randomColor({
luminosity: 'light',
format: 'hsla' // e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)'
});

14
randomcolor/randomcolor.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
// Type definitions for randomColor 0.4.1
// Project: https://github.com/davidmerfield/randomColor
// Definitions by: Mathias Feitzinger <https://github.com/feitzi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function randomColor(options?: RandomColorOptions): string;
interface RandomColorOptions {
hue?: number | "red" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "monochrome" | "random";
luminosity?: "bright" | "light" | "dark" | "random";
count?: number;
seed?: number | string;
format?: "hsvArray" | "hslArray" | "hsl" | "hsla" | "rgbArray" | "rgb" | "rgba" | "hex";
}

View File

@@ -1916,7 +1916,7 @@ declare namespace __React {
* The navigation view that will be rendered to the side of the
* screen and can be pulled in.
*/
renderNavigationView?: () => View
renderNavigationView?: () => JSX.Element
/**
* Make the drawer take the entire screen and draw the background of
@@ -3247,6 +3247,19 @@ declare namespace __React {
debugOverlay?: boolean
}
/**
* Class that contains the info and methods for app navigation.
*/
export interface NavigationContext {
parent: NavigationContext;
top: NavigationContext;
currentRoute: any;
appendChild(childContext: NavigationContext): void;
addListener(eventType: string, listener: () => void, useCapture?: boolean): NativeEventSubscription;
emit(eventType: string, data: any, didEmitCallback?: () => void): void;
dispose(): void;
}
/**
* Use Navigator to transition between different scenes in your app.
@@ -3260,7 +3273,9 @@ declare namespace __React {
export interface NavigatorStatic extends React.ComponentClass<NavigatorProperties> {
SceneConfigs: SceneConfigs;
NavigationBar: NavigatorStatic.NavigationBarStatic;
BreadcrumbNavigationBar: NavigatorStatic.BreadcrumbNavigationBarStatic
BreadcrumbNavigationBar: NavigatorStatic.BreadcrumbNavigationBarStatic;
navigationContext: NavigationContext;
getContext( self: any ): NavigatorStatic;

View File

@@ -0,0 +1,28 @@
///<reference path="react-redux-toastr.d.ts" />
///<reference path="../react/react.d.ts" />
///<reference path="../react/react-dom.d.ts" />
///<reference path="../react-redux/react-redux.d.ts" />
import {toastr, reducer as toastrReducer, actions} from 'react-redux-toastr';
import ReduxToastr from 'react-redux-toastr';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {createStore, combineReducers, bindActionCreators} from 'redux';
import { Provider, connect } from 'react-redux';
function test() {
const store = createStore(combineReducers({ toastr: toastrReducer }));
var toastrFactory = React.createFactory(ReduxToastr);
var element = toastrFactory({ timeOut: 1000, newestOnTop: false });
var providerFactory = React.createFactory(Provider);
var root = providerFactory({ store: store }, element);
function callback() { }
toastr.clean();
toastr.confirm("Test", { onOk: callback, onCancel: callback });
toastr.error("Error", "Error message");
toastr.info("Info", "Info test", { timeOut: 1000, removeOnHover: true, removeOnClick: true, onShowComplete: callback });
toastr.success("Test", "Test message", { component: new React.Component() });
}
test();

View File

@@ -0,0 +1,108 @@
// Type definitions for react-redux-toastr 3.7.0
// Project: https://github.com/diegoddox/react-redux-toastr
// Definitions by: Aleksandar Ivanov <https://github.com/Smiche>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../react/react.d.ts" />
///<reference path="../redux/redux.d.ts"/>
declare module "react-redux-toastr" {
import R = __React;
import _Redux = Redux;
interface ToastrOptions {
/**
* Timeout in miliseconds.
*/
timeOut?: number,
/**
* Show newest on top or bottom.
*/
newestOnTop?: boolean,
/**
* Position of the toastr: top-left, top-center, top-right, bottom-left, bottom-center and bottom-right
*/
position?: string,
confirmText?: ConfirmText
}
interface ConfirmText {
okText: string,
cancelText: string
}
/**
* Toastr react component.
*/
export default class ReduxToastr extends R.Component<ToastrOptions, any>{ }
interface EmitterOptions {
/**
* Notification popup icon.
* icon-close-round, icon-information-circle, icon-check-1, icon-exclamation-triangle, icon-exclamation-alert
*/
icon?: string,
/**
* Timeout in miliseconds.
*/
timeOut?: number,
removeOnHover?: boolean,
removeOnClick?: boolean,
component?: R.Component<any, any>,
onShowComplete?(): void;
onHideComplete?(): void;
}
interface ToastrConfirmOptions {
onOk(): void;
onCancel(): void;
}
interface ToastrEmitter {
/**
* Used to provide a large amount of information.
* It will not close unless a timeOut is provided.
*/
message(title: string, message: string, options?: EmitterOptions): void;
info(title: string, message: string, options?: EmitterOptions): void;
success(title: string, message: string, options?: EmitterOptions): void;
warning(title: string, message: string, options?: EmitterOptions): void;
error(title: string, message: string, options?: EmitterOptions): void;
/**
* Clear all notifications
*/
clean(): void;
/**
* Hook confirmation toastr with callback.
*/
confirm(message: string, options: ToastrConfirmOptions): void;
}
/**
* Possible actions to dispatch.
*/
interface Actions {
addToastrAction: Redux.Action,
clean: Redux.Action,
remove: Redux.Action,
success: Redux.Action,
info: Redux.Action,
warning: Redux.Action,
error: Redux.Action,
showConfirm: Redux.Action,
hideConfirm: Redux.Action
}
/**
* Action creator for toastr.
*/
export var actions: Redux.ActionCreator<Actions>;
/**
* Reducer for the toastr state.
* Combine with your reducers.
*/
export var reducer: Redux.Reducer<any>;
/**
* Used to issue toastr notifications.
*/
export var toastr: ToastrEmitter;
}

View File

@@ -39,10 +39,10 @@ declare namespace ReactRouter {
type RouteComponent = Component
// use the following interface in an app code to get access to route param values, history, location...
// interface MyComponentProps extends ReactRouter.RouteComponentProps<{}, { id: number }> {}
// interface MyComponentProps extends ReactRouter.RouteComponentProps<{}, { id: string }> {}
// somewhere in MyComponent
// ...
// let id = this.props.routeParams.id
// let id = parseInt(this.props.routeParams.id, 10);
// ...
// this.props.history. ...
// ...
@@ -88,6 +88,13 @@ declare namespace ReactRouter {
function createMemoryHistory(options?: H.HistoryOptions): H.History
interface Middleware {
renderRouterContext: (previous: React.Props<{}>[], props: React.Props<{}>) => React.Props<{}>[]
renderRouteComponent: (previous: React.Props<{}>[], props: React.Props<{}>) => React.Props<{}>[]
}
function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: React.Props<{}>) => React.Props<{}>[]
/* components */
interface RouterProps extends React.Props<Router> {
@@ -97,6 +104,7 @@ declare namespace ReactRouter {
onError?: (error: any) => any
onUpdate?: () => any
parseQueryString?: ParseQueryString
render?: (renderProps: React.Props<{}>) => React.Props<{}>[]
stringifyQuery?: StringifyQuery
}
interface Router extends React.ComponentClass<RouterProps> {}
@@ -236,15 +244,15 @@ declare namespace ReactRouter {
// https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md
interface InjectedRouter {
push: (pathOrLoc: H.LocationDescriptor) => void
replace: (pathOrLoc: H.LocationDescriptor) => void
go: (n: number) => void
goBack: () => void
goForward: () => void
setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void
createPath(path: H.Path, query?: H.Query): H.Path
createHref(path: H.Path, query?: H.Query): H.Href
isActive: (pathOrLoc: H.LocationDescriptor, indexOnly?: boolean) => boolean
push: (pathOrLoc: H.LocationDescriptor) => void
replace: (pathOrLoc: H.LocationDescriptor) => void
go: (n: number) => void
goBack: () => void
goForward: () => void
setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void
createPath(path: H.Path, query?: H.Query): H.Path
createHref(path: H.Path, query?: H.Query): H.Href
isActive: (pathOrLoc: H.LocationDescriptor, indexOnly?: boolean) => boolean
}
function withRouter<C extends React.ComponentClass<any> | React.StatelessComponent<any> | React.PureComponent<any, any>>(component: C): C
@@ -361,7 +369,7 @@ declare module "react-router/lib/useRoutes" {
declare module "react-router/lib/PatternUtils" {
export function formatPattern(pattern: string, params: {}): string;
export function formatPattern(pattern: string, params: {}): string;
}
@@ -421,16 +429,16 @@ declare module "react-router/lib/PropTypes" {
}
declare module "react-router/lib/browserHistory" {
export default ReactRouter.browserHistory;
export default ReactRouter.browserHistory;
}
declare module "react-router/lib/hashHistory" {
export default ReactRouter.hashHistory;
export default ReactRouter.hashHistory;
}
declare module "react-router/lib/match" {
export default ReactRouter.match
export default ReactRouter.match;
}
@@ -443,11 +451,15 @@ declare module "react-router/lib/useRouterHistory" {
}
declare module "react-router/lib/createMemoryHistory" {
export default ReactRouter.createMemoryHistory;
export default ReactRouter.createMemoryHistory;
}
declare module "react-router/lib/withRouter" {
export default ReactRouter.withRouter;
export default ReactRouter.withRouter;
}
declare module "react-router/lib/applyRouterMiddleware" {
export default ReactRouter.applyRouterMiddleware;
}
declare module "react-router" {
@@ -494,6 +506,8 @@ declare module "react-router" {
import withRouter from "react-router/lib/withRouter";
import applyRouterMiddleware from "react-router/lib/applyRouterMiddleware";
// PlainRoute is defined in the API documented at:
// https://github.com/rackt/react-router/blob/master/docs/API.md
// but not included in any of the .../lib modules above.
@@ -506,7 +520,7 @@ declare module "react-router" {
export type LeaveHook = ReactRouter.LeaveHook
export type ParseQueryString = ReactRouter.ParseQueryString
export type RedirectFunction = ReactRouter.RedirectFunction
export type RouteComponentProps<P,R> = ReactRouter.RouteComponentProps<P,R>;
export type RouteComponentProps<P, R> = ReactRouter.RouteComponentProps<P, R>;
export type RouteHook = ReactRouter.RouteHook
export type StringifyQuery = ReactRouter.StringifyQuery
export type RouterListener = ReactRouter.RouterListener
@@ -536,7 +550,8 @@ declare module "react-router" {
match,
useRouterHistory,
createMemoryHistory,
withRouter
withRouter,
applyRouterMiddleware
}
export default Router

6
react/react.d.ts vendored
View File

@@ -1181,6 +1181,12 @@ declare namespace __React {
imeMode?: any;
/**
* Defines how the browser distributes space between and around flex items
* along the main-axis of their container.
*/
justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around";
layoutGrid?: any;
layoutGridChar?: any;

View File

@@ -4,4 +4,12 @@
import * as React from 'react'
import DockMonitor from 'redux-devtools-dock-monitor'
let dockMonitor = <DockMonitor toggleVisibilityKey='ctrl-h' changePositionKey='ctrl-q' />
let dockMonitor = <DockMonitor toggleVisibilityKey='ctrl-h' changePositionKey='ctrl-q' />
let dockMonitorOptionalProps = <DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
changeMonitorKey='ctrl-m'
fluid={false}
defaultSize={0.5}
defaultPosition='bottom'
defaultIsVisible={false} />

View File

@@ -1,4 +1,4 @@
// Type definitions for redux-devtools-dock-monitor 1.0.1
// Type definitions for redux-devtools-dock-monitor 1.1.1
// Project: https://github.com/gaearon/redux-devtools-dock-monitor
// Definitions by: Petryshyn Sergii <https://github.com/mc-petry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -8,6 +8,8 @@
declare module "redux-devtools-dock-monitor" {
import * as React from 'react'
type DockPosition = 'left' | 'top' | 'right' | 'bottom'
interface IDockMonitorProps {
/**
* Any valid Redux DevTools monitor.
@@ -15,39 +17,48 @@ declare module "redux-devtools-dock-monitor" {
children?: React.ReactNode
/**
* A key or a key combination that toggles the dock visibility.
* A key or a key combination that toggles the dock visibility.
* Must be recognizable by parse-key (for example, 'ctrl-h')
*/
toggleVisibilityKey: string
/**
* A key or a key combination that toggles the dock position.
* A key or a key combination that toggles the dock position.
* Must be recognizable by parse-key (for example, 'ctrl-w')
*/
changePositionKey: string
/**
* A key or a key combination that switches the currently visible monitor.
* Must be recognizable by parse-key (for example, 'ctrl-m')
* Required if you use more than one monitor.
*
* @default undefined
*/
changeMonitorKey?: string
/**
* When true, the dock size is a fraction of the window size, fixed otherwise.
*
*
* @default true
*/
fluid?: boolean
/**
* Size of the dock. When fluid is true, a float (0.5 means half the window size).
* Size of the dock. When fluid is true, a float (0.5 means half the window size).
* When fluid is false, a width in pixels
*
*
* @default 0.3 (3/10th of the window size)
*/
defaultSize?: number
/**
* Where the dock appears on the screen.
* Where the dock appears on the screen.
* Valid values: 'left', 'top', 'right', 'bottom'
*
*
* @default 'right'
*/
defaultPosition?: string
defaultPosition?: DockPosition
/**
* @default true
@@ -56,4 +67,4 @@ declare module "redux-devtools-dock-monitor" {
}
export default class DockMonitor extends React.Component<IDockMonitorProps, any> {}
}
}

View File

@@ -4,4 +4,34 @@
import * as React from 'react'
import LogMonitor from 'redux-devtools-log-monitor'
let logMonitor = <LogMonitor />
let logMonitor = <LogMonitor />
let logMonitorWithStringTheme = <LogMonitor theme='tomorrow' />
const customTheme = {
scheme: 'Oscar Award Winner',
author: 'Nic Cage',
base00: '#000000',
base01: '#000000',
base02: '#000000',
base03: '#000000',
base04: '#000000',
base05: '#000000',
base06: '#000000',
base07: '#000000',
base08: '#000000',
base09: '#000000',
base0A: '#000000',
base0B: '#000000',
base0C: '#000000',
base0D: '#000000',
base0E: '#000000',
base0F: '#000000'
}
let logMonitorWithCustomTheme = <LogMonitor theme={customTheme} />
let logMonitorWithOtherOptProps = <LogMonitor select={(state: any) => state}
preserveScrollTop={true}
expandActionRoot={true}
expandStateRoot={true} />

View File

@@ -1,39 +1,55 @@
// Type definitions for redux-devtools-log-monitor 1.0.1
// Type definitions for redux-devtools-log-monitor 1.0.11
// Project: https://github.com/gaearon/redux-devtools-log-monitor
// Definitions by: Petryshyn Sergii <https://github.com/mc-petry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
/// <reference path="../base16/base16.d.ts" />
declare module "redux-devtools-log-monitor" {
import * as React from 'react'
import {ColorScheme} from 'base16'
interface ILogMonitorProps {
/**
* Either a string referring to one of the themes provided by
* Either a string referring to one of the themes provided by
* redux-devtools-themes or a custom object of the same format.
*
*
* @see https://github.com/gaearon/redux-devtools-themes
*/
theme?: string
theme?: string | ColorScheme
/**
* A function that selects the slice of the state for DevTools to show.
*
*
* @example state => state.thePart.iCare.about.
* @default state => state.
*/
select?: (state: any) => any
/**
* When true, records the current scroll top every second so it
* can be restored on refresh. This only has effect when used together
* When true, records the current scroll top every second so it
* can be restored on refresh. This only has effect when used together
* with persistState() enhancer from Redux DevTools.
*
*
* @default true
*/
preserveScrollTop?: boolean
/**
* When true, displays the action object expanded rather than collapsed.
*
* @default true
*/
expandActionRoot?: boolean
/**
* When true, displays the state object expanded rather than collapsed.
*
* @default true
*/
expandStateRoot?: boolean
}
export default class LogMonitor extends React.Component<ILogMonitorProps, any> {}
}
}

View File

@@ -185,8 +185,28 @@ interface RequireConfig {
*
* @example
* urlArgs: "bust= + (new Date()).getTime()
*
* As of RequireJS 2.2.0, urlArgs can be a function. If a
* function, it will receive the module ID and the URL as
* parameters, and it should return a string that will be added
* to the end of the URL. Return an empty string if no args.
* Be sure to take care of adding the '?' or '&' depending on
* the existing state of the URL.
*
* @example
* requirejs.config({
* urlArgs: function(id, url) {
* var args = 'v=1';
* if (url.indexOf('view.html') !== -1) {
* args = 'v=2'
* }
*
* return (url.indexOf('?') === -1 ? '?' : '&') + args;
* }
* });
**/
urlArgs?: string;
urlArgs?: string | ((id: string, url: string) => string);
/**
* Specify the value for the type="" attribute used for script

View File

@@ -84,17 +84,26 @@ declare namespace restangular {
one(route: string, id?: number): IElement;
one(route: string, id?: string): IElement;
oneUrl(route: string, url: string): IElement;
all(route: string): IElement;
allUrl(route: string, url: string): IElement;
all(route: string): ICollection;
allUrl(route: string, url: string): ICollection;
copy(fromElement: any): IElement;
withConfig(configurer: (RestangularProvider: IProvider) => any): IService;
restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): IElement;
restangularizeCollection(parent: any, element: any, route: string): ICollection;
service(route: string, parent?: any): IService;
service(route: string, parent?: any): IScopedService;
stripRestangular(element: any): any;
extendModel(route: string, extender: (model: IElement) => any): void;
extendCollection(route: string, extender: (collection: ICollection) => any): void;
}
interface IScopedService extends IService {
one(id: number): IElement;
one(id: string): IElement;
post(elementToPost: any, queryParams?: any, headers?: any): IPromise<any>;
post<T>(elementToPost: T, queryParams?: any, headers?: any): IPromise<T>;
getList(queryParams?: any, headers?: any): ICollectionPromise<any>;
getList<T>(queryParams?: any, headers?: any): ICollectionPromise<T>;
}
interface IElement extends IService {
get(queryParams?: any, headers?: any): IPromise<any>;
@@ -104,8 +113,6 @@ declare namespace restangular {
put(queryParams?: any, headers?: any): IPromise<any>;
post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): IPromise<any>;
post<T>(subElement: any, elementToPost: T, queryParams?: any, headers?: any): IPromise<T>;
post(elementToPost: any, queryParams?: any, headers?: any): IPromise<any>;
post<T>(elementToPost: T, queryParams?: any, headers?: any): IPromise<T>;
remove(queryParams?: any, headers?: any): IPromise<any>;
head(queryParams?: any, headers?: any): IPromise<any>;
trace(queryParams?: any, headers?: any): IPromise<any>;

View File

@@ -452,6 +452,7 @@ declare module "restify" {
responseTimeFormatter ?: (durationInMilliseconds: number) => any;
handleUpgrades ?: boolean;
router ?: Router;
httpsServerOptions?: any;
}
interface ClientOptions {

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