Best JavaScript code snippet using wpt
fabricjs.d.ts
Source:fabricjs.d.ts
1// Type definitions for FabricJS [FIRST REVISION]2// Project: http://fabricjs.com/3// Definitions by: Oliver Klemencic <https://github.com/oklemencic/>4/* 5USAGE6///<reference path="fabricjs.d.ts"/>7*/8declare module fabric {9 function createCanvasForNode(width: number, height: number): ICanvas;10 function getCSSRules(doc: SVGElement);11 function getGradientDefs(doc: SVGElement);12 function loadSVGFromString(text: string, callback: (results: IObject[], options) => void , reviver?: (el, obj) => void );13 function loadSVGFromURL(url, callback: (results: IObject[], options) => void , reviver?: (el, obj) => void );14 function log(values);15 function parseAttributes(element, attributes: any[]): any;16 function parseElements(elements: any[], callback, options, reviver);17 function parsePointsAttribute(points: string): any[];18 function parseStyleAttribute(element: SVGElement);19 function parseSVGDocument(doc: SVGElement, callback: (results, options) => void , reviver?: (el, obj) => void );20 function parseTransformAttribute(attributeValue: string);21 function warn(values);22 var isLikelyNode: bool;23 var isTouchSupported: bool;24 export interface IObservable {25 observe(eventCollection: IEventList);26 on(eventCollection: IEventList);27 observe(eventName: string, handler: (e) => any);28 on(eventName: string, handler: (e) => any);29 fire(eventName: string, options);30 stopObserving(eventName: string, handler: (e) => any);31 off(eventName, handler);32 }33 export interface IFilter {34 new (): IFilter;35 new (options: any): IFilter;36 }37 export interface IEventList {38 [index: string]: (e: Event) => void;39 }40 export interface IObjectOptions {41 angle?: number;42 borderColor?: string;43 borderOpacityWhenMoving?: number;44 borderScaleFactor?: number;45 cornerColor?: string;46 cornersize?: number;47 fill?: string;48 fillRule?: string;49 flipX?: bool;50 flipY?: bool;51 hasBorders?: bool;52 hasControls?: bool;53 hasRotatingPoint?: bool;54 height?: number;55 includeDefaultValues?: bool;56 left?: number;57 lockMovementX?: bool;58 lockMovementY?: bool;59 lockScalingX?: bool;60 lockScalingY?: bool;61 lockUniScaling?: bool;62 lockRotation?: bool;63 opacity?: number;64 overlayFill?: string;65 padding?: number;66 perPixelTargetFind?: bool;67 rotatingPointOffset?: number;68 scaleX?: number;69 scaleY?: number;70 selectable?: bool;71 stateProperties?: any[];72 stroke?: string;73 strokeDashArray?: any[];74 strokeWidth?: number;75 top?: number;76 transformMatrix?: any[];77 transparentCorners?: bool;78 type?: string;79 width?: number;80 }81 export interface ITextOptions extends IObjectOptions {82 fontSize?: number;83 fontWeight?: any;84 fontFamily?: string;85 textDecoration?: string;86 textShadow?: string;87 textAlign?: string;88 fontStyle?: string;89 lineHeight?: number;90 strokeStyle?: string;91 strokeWidth?: number;92 backgroundColor?: string;93 textBackgroundColor?: string;94 path?: string;95 type?: string;96 useNative?: Boolean;97 }98 export interface ICircleOptions extends IObjectOptions {99 radius?: number;100 }101 export interface IPoint {102 add(that: IPoint): IPoint;103 addEquals(that: IPoint): IPoint;104 distanceFrom(that: IPoint);105 divide(scalar: number);106 divideEquals(scalar: number);107 eq(that: IPoint);108 gt(that: IPoint);109 gte(that: IPoint);110 init(x, y);111 lerp(that: IPoint, t);112 lt(that: IPoint);113 lte(that: IPoint);114 max(that: IPoint);115 min(that: IPoint);116 multiply(scalar);117 multiplyEquals(scalar);118 scalarAdd(scalar): IPoint;119 scalarAddEquals(scalar: number, thisArg: IPoint);120 scalarSubtract(scalar: number);121 scalarSubtractEquals(scalar);122 setFromPoint(that: IPoint);123 setXY(x, y);124 subtract(that: IPoint): IPoint;125 subtractEquals(that: IPoint): IPoint;126 swap(that: IPoint);127 tostring(): string;128 }129 export interface IRect extends IObject {130 x: number;131 y: number;132 rx: number;133 ry: number;134 complexity(): number;135 initialize(points: number[], options: any): IRect;136 toObject(propertiesToInclude: any[]): any;137 toSVG(): string;138 }139 export interface IText extends IObject {140 fontSize: number;141 fontWeight: any;142 fontFamily: string;143 text: string;144 textDecoration: string;145 textShadow?: string;146 textAlign: string;147 fontStyle: string;148 lineHeight: number;149 strokeStyle: string;150 strokeWidth: number;151 backgroundColor: string;152 textBackgroundColor: string;153 path?: string;154 type: string;155 useNative: Boolean;156 initialize(text: string, options: any): IText;157 toString(): string;158 render(ctx: CanvasRenderingContext2D, noTransform: bool);159 toObject(propertiesToInclude: any[]): IObject;160 toSVG(): string;161 setColor(value: string): IText;162 setFontsize(value: number): IText;163 getText(): string;164 setText(value: string): IText;165 }166 export interface ITriangle extends IObject {167 complexity(): number;168 initialize(options: any): ITriangle;169 toSVG(): string;170 }171 export interface IEllipse {172 initialize(options: any): any;173 toObject(propertiesToInclude: any[]): any;174 toSVG(): string;175 render(ctx: CanvasRenderingContext2D, noTransform: bool);176 complexity(): number;177 }178 export interface IGradient {179 initialize(options): any;180 toObject(): any;181 toLiveGradient(ctx: CanvasRenderingContext2D): any;182 }183 export interface IColor {184 getSource(): any[];185 setSource(source: any[]): any;186 toRgb(): string;187 toRgba(): string;188 toHex(): string;189 getAlpha(): number;190 setAlpha(alpha: number): IColor;191 toGrayscale(): IColor;192 toBlackWhite(threshold): IColor;193 overlayWith(otherColor: string): IColor;194 overlayWith(otherColor: IColor): IColor;195 }196 export interface IElement {197 }198 export interface IObject extends IObservable {199 // constraint properties200 lockMovementX: bool;201 lockMovementY: bool;202 lockScalingX: bool;203 lockScalingY: bool;204 lockScaling: bool;205 lockUniScaling: bool;206 lockRotation: bool;207 getCurrentWidth(): number;208 getCurrentHeight(): number;209 angle: number;210 getAngle(): number;211 setAngle(value: number): IObject;212 borderColor: string;213 getBorderColor(): string;214 setBorderColor(value: string): IObject;215 borderOpacityWhenMoving: number;216 borderScaleFactor: number;217 getBorderScaleFactor(): number;218 cornerColor: string;219 cornersize: number;220 getCornersize(): number;221 setCornersize(value: number): IObject;222 fill: string;223 getFill(): string;224 setFill(value: string): IObject;225 fillRule: string;226 getFillRule(): string;227 setFillRule(value: string): IObject;228 flipX: bool;229 getFlipX(): bool;230 setFlipX(value: bool): IObject;231 flipY: bool;232 getFlipY(): bool;233 setFlipY(value: bool): IObject;234 hasBorders: bool;235 hasControls: bool;236 hasRotatingPoint: bool;237 238 height: number;239 getHeight(): number;240 setHeight(value: number): IObject;241 includeDefaultValues: bool;242 243 left: number;244 getLeft(): number;245 setLeft(value: number): IObject;246 opacity: number;247 getOpacity(): number;248 setOpacity(value: number): IObject;249 overlayFill: string;250 getOverlayFill(): string;251 setOverlayFill(value: string): IObject;252 padding: number;253 perPixelTargetFind: bool;254 rotatingPointOffset: number;255 256 scaleX: number;257 getScaleX(): number;258 setScaleX(value: number): IObject;259 scaleY: number;260 getScaleY(): number;261 setScaleY(value: number): IObject;262 selectable: bool;263 stateProperties: any[];264 stroke: string;265 strokeDashArray: any[];266 strokeWidth: number;267 268 top: number;269 getTop(): number;270 setTop(value: number): IObject;271 transformMatrix: any[];272 transparentCorners: bool;273 type: string;274 275 width: number;276 getWidth(): number;277 setWidth(value: number): IObject;278 // methods279 bringForward(): IObject;280 bringToFront(): IObject;281 center(): IObject;282 centerH(): IObject;283 centerV(): IObject;284 clone(callback?, propertiesToInclude?): IObject;285 cloneAsImage(callback): IObject;286 complexity(): number;287 drawBorders(context: CanvasRenderingContext2D): IObject;288 drawCorners(context: CanvasRenderingContext2D): IObject;289 get (property: string): any;290 getBoundingRectHeight(): number;291 getBoundingRectWidth(): number;292 getSvgStyles(): string;293 getSvgTransform(): string;294 hasStateChanged(): bool;295 initialize(options: any);296 intersectsWithObject(other: IObject): bool;297 intersectsWithRect(selectionTL: any, selectionBR: any): bool;298 isActive(): bool;299 isContainedWithinObject(other: IObject): bool;300 isContainedWithinRect(selectionTL: any, selectionBR: any): bool;301 isType(type: string): bool;302 remove(): IObject;303 render(ctx: CanvasRenderingContext2D, noTransform: bool);304 rotate(value: number): IObject;305 saveState(): IObject;306 scale(value: number): IObject;307 scaleToHeight(value: number): IObject;308 scaleToWidth(value: number): IObject;309 sendBackwards(): IObject;310 sendToBack(): IObject;311 set (properties: IObjectOptions): IObject;312 set (name: string, value: any): IObject;313 setActive(active: bool): IObject;314 setCoords();315 setGradientFill(options);316 setOptions(options: any);317 setSourcePath(value: string): IObject;318 toDatalessObject(propertiesToInclude): any;319 toDataURL(callback): string;320 toggle(property): IObject;321 toGrayscale(): IObject;322 toJSON(propertiesToInclude): string;323 toObject(propertiesToInclude): any;324 tostring(): string;325 transform(ctx: CanvasRenderingContext2D);326 }327 export interface IGroup {328 type: string;329 activateAllObjects(): IGroup;330 add(object): IGroup;331 addWithUpdate(object): IGroup;332 complexity(): number;333 contains(object): bool;334 containsPoint(point): bool;335 destroy(): IGroup;336 getObjects(): IObject[];337 hasMoved(): bool;338 initialize(objects, options): any;339 item(index): IObject;340 remove(object): IGroup;341 removeWithUpdate(object): IGroup;342 render(ctx, noTransform): void;343 saveCoords(): IGroup;344 setObjectsCoords(): IGroup;345 size(): number;346 toGrayscale(): void;347 toObject(propertiesToInclude: any[]): any;348 tostring(): string;349 toSVG(): string;350 }351 export interface ILine extends IObject {352 x1: number;353 x2: number;354 y1: number;355 y2: number;356 complexity(): number;357 initialize(points: number[], options: any): ILine;358 toObject(propertiesToInclude: any[]): any;359 toSVG(): string;360 }361 export interface IIntersection {362 appendPoint(status: string);363 appendPoints(status: string);364 init(status: string);365 }366 export interface IImage extends IObject {367 filters: any;368 applyFilters(callback);369 clone(propertiesToInclude, callback);370 complexity(): number;371 getElement(): HTMLImageElement;372 getOriginalSize(): { width: number; height: number; };373 getSrc(): string;374 initialize(element: string, options: any);375 initialize(element: HTMLImageElement, options: any);376 render(ctx: CanvasRenderingContext2D, noTransform: bool);377 setElement(element): IImage;378 toObject(propertiesToInclude): any;379 tostring(): string;380 toSVG(): string;381 }382 export interface ICircle extends IObject {383 // methods384 complexity(): number;385 getRadiusX(): number;386 getRadiusY(): number;387 initialize(options: ICircleOptions): ICircle;388 setRadius(value: number): number;389 toObject(propertiesToInclude): any;390 toSVG(): string;391 }392 393 export interface IPath extends IObject {394 complexity(): number;395 initialize(path, options);396 render(ctx: CanvasRenderingContext2D, noTransform: bool);397 toDatalessObject(propertiesToInclude): any;398 toObject(propertiesToInclude): any;399 tostring(): string;400 toSVG(): string;401 }402 export interface IPolygon extends IObject {403 complexity(): number;404 initialize(points, options);405 toObject(propertiesToInclude): any;406 toSVG(): string;407 }408 export interface IPolyline extends IObject {409 complexity(): number;410 initialize(points, options);411 toObject(propertiesToInclude): any;412 toSVG(): string;413 }414 export interface IPathGroup extends IObject {415 complexity(): number;416 initialize(paths, options);417 isSameColor(): bool;418 render(ctx: CanvasRenderingContext2D);419 toDatalessObject(propertiesToInclude): any;420 toGrayscale();421 toObject(propertiesToInclude): any;422 tostring(): string;423 toSVG(): string;424 }425 export interface IStaticCanvas extends IObservable {426 // fields427 backgroundColor: string;428 backgroundImage: string;429 backgroundImageOpacity: number;430 backgroundImageStretch: number;431 clipTo(clipFunction: (context: CanvasRenderingContext2D) => void );432 controlsAboveOverlay: bool;433 includeDefaultValues: bool;434 overlayImage: string;435 overlayImageLeft: number;436 overlayImageTop: number;437 renderOnAddition: bool;438 stateful: bool;439 // static 440 EMPTY_JSON: string;441 supports(methodName: string): bool;442 // methods443 add(...object: IObject[]): ICanvas;444 bringForward(object: IObject): ICanvas;445 calcOffset(): ICanvas;446 centerObject(object: IObject): ICanvas;447 centerObjectH(object: IObject): ICanvas;448 centerObjectV(object: IObject): ICanvas;449 clear(): ICanvas;450 clearContext(context: CanvasRenderingContext2D): ICanvas;451 complexity(): number;452 dispose(): ICanvas;453 drawControls();454 forEachObject(callback: (object: IObject) => void , context?: CanvasRenderingContext2D): ICanvas;455 getActiveGroup(): IGroup;456 getActiveObject(): IObject;457 getCenter(): IObject;458 getContext(): CanvasRenderingContext2D;459 getElement(): HTMLCanvasElement;460 getHeight(): number;461 getWidth(): number;462 insertAt(object: IObject, index: number, nonSplicing: bool): ICanvas;463 isEmpty(): bool;464 item(index: number): IObject;465 onBeforeScaleRotate(target: IObject);466 remove(object: IObject): IObject;467 renderAll(allOnTop?: bool): ICanvas;468 renderTop(): ICanvas;469 sendBackwards(object: IObject): ICanvas;470 sendToBack(object: IObject): ICanvas;471 setBackgroundImage(object: IObject): ICanvas;472 setDimensions(object: { width: number; height: number; }): ICanvas;473 setHeight(height: number): ICanvas;474 setOverlayImage(url: string, callback: () => any, options): ICanvas;475 setWidth(width: number): ICanvas;476 toDatalessJSON(propertiesToInclude: any[]): string;477 toDatalessObject(propertiesToInclude: any[]): string;478 toDataURL(format: string, quality?: number): string;479 toDataURLWithMultiplier(propertiesToInclude: any[]): string;480 toGrayscale(propertiesToInclude: any[]): string;481 toJSON(propertiesToInclude: any[]): string;482 toObject(propertiesToInclude: any[]): string;483 tostring(): string;484 toSVG(): string;485 }486 export interface ICanvas extends IStaticCanvas {487 // constructors488 (element: HTMLCanvasElement): ICanvas;489 (element: string): ICanvas;490 // fields491 containerClass: string;492 defaultCursor: string;493 freeDrawingColor: string;494 freeDrawingLineWidth: number;495 hoverCursor: string;496 interactive: bool;497 moveCursor: string;498 perPixelTargetFind: bool;499 rotationCursor: string;500 selection: bool;501 selectionBorderColor: string;502 selectionColor: string;503 selectionDashArray: number[];504 selectionLineWidth: number;505 targetFindTolerance: number;506 // methods507 containsPoint(e: Event, target: IObject): bool;508 deactivateAll(): ICanvas;509 deactivateAllWithDispatch(): ICanvas;510 discardActiveGroup(): ICanvas;511 discardActiveObject(): ICanvas;512 drawDashedLine(ctx: CanvasRenderingContext2D, x: number, y: number, x2: number, y2: number, dashArray: number[]): ICanvas;513 findTarget(e: MouseEvent, skipGroup: bool): ICanvas;514 getActiveGroup(): IGroup;515 getActiveObject(): IObject;516 getPointer(e): { x: number; y: number; };517 getSelectionContext(): CanvasRenderingContext2D;518 getSelectionElement(): HTMLCanvasElement;519 setActiveGroup(group: IGroup): ICanvas;520 setActiveObject(object: IObject, e?): ICanvas;521 }522 export interface IBrightnessFilter {523 }524 export interface IInvertFilter {525 }526 export interface IRemoveWhiteFilter {527 }528 export interface IGrayscaleFilter {529 }530 export interface ISepiaFilter {531 }532 export interface ISepia2Filter {533 }534 export interface INoiseFilter {535 }536 export interface IGradientTransparencyFilter {537 }538 export interface IPixelateFilter {539 }540 export interface IConvoluteFilter {541 }542 export interface ICanvasOptions {543 containerClass?: string;544 defaultCursor?: string;545 freeDrawingColor?: string;546 freeDrawingLineWidth?: number;547 hoverCursor?: string;548 interactive?: bool;549 moveCursor?: string;550 perPixelTargetFind?: bool;551 rotationCursor?: string;552 selection?: bool;553 selectionBorderColor?: string;554 selectionColor?: string;555 selectionDashArray?: number[];556 selectionLineWidth?: number;557 targetFindTolerance?: number;558 backgroundColor?: string;559 backgroundImage?: string;560 backgroundImageOpacity?: number;561 backgroundImageStretch?: number;562 controlsAboveOverlay?: bool;563 includeDefaultValues?: bool;564 overlayImage?: string;565 overlayImageLeft?: number;566 overlayImageTop?: number;567 renderOnAddition?: bool;568 stateful?: bool;569 }570 export interface IRectOptions extends IObjectOptions {571 x?: number; 572 y?: number;573 rx?: number;574 ry?: number;575 }576 export interface ITriangleOptions extends IObjectOptions {577 }578 declare var Rect: {579 fromElement(element: SVGElement, options: IRectOptions): IRect;580 fromObject(object): IRect;581 new (options?: IRectOptions): IRect;582 prototype: any;583 }584 declare var Triangle: {585 new (options?: ITriangleOptions): ITriangle;586 }587 declare var Canvas: {588 new (element: HTMLCanvasElement, options?: ICanvasOptions): ICanvas;589 new (element: string, options?: ICanvasOptions): ICanvas;590 EMPTY_JSON: string;591 supports(methodName: string): bool;592 prototype: any;593 }594 declare var Circle: {595 ATTRIBUTE_NAMES: string[];596 fromElement(element: SVGElement, options: ICircleOptions): ICircle;597 fromObject(object): ICircle;598 new (options?: ICircleOptions): ICircle;599 prototype: any;600 }601 declare var Line: {602 ATTRIBUTE_NAMES: string[];603 fromElement(element: SVGElement, options): ILine;604 fromObject(object): ILine;605 prototype: any;606 new (points: number[], objObjects?: IObjectOptions): ILine;607 }608 declare var Intersection: {609 intersectLineLine(a1, a2, b1, b2);610 intersectLinePolygon(a1, a2, points);611 intersectPolygonPolygon(points1, points2);612 intersectPolygonRectangle(points, r1, r2);613 }614 declare var Path: {615 fromElement(element: SVGElement, options): IPath;616 fromObject(object): IPath;617 new (): IPath;618 }619 declare var PathGroup: {620 fromObject(object): IPathGroup;621 new (): IPathGroup;622 prototype: any;623 }624 declare var Point: {625 new (x, y): IPoint;626 prototype: any;627 }628 declare var Object: {629 prototype: any;630 }631 declare var Polygon: {632 fromObject(object): IPolygon;633 fromElement(element: SVGElement, options): IPolygon;634 new (): IPolygon;635 prototype: any;636 }637 declare var Polyline: {638 fromObject(object): IPolyline;639 fromElement(element: SVGElement, options): IPolyline;640 new (): IPolyline;641 prototype: any;642 }643 declare var Text: {644 new (text: string, options?: ITextOptions): IText;645 }646 declare var Image: {647 fromURL(url: string): IImage;648 fromURL(url: string, callback: (image: IImage) => any): IImage;649 fromURL(url: string, callback: (image: IImage) => any, objObjects: IObjectOptions): IImage;650 prototype: any;651 filters: 652 {653 Grayscale: {654 new (): IGrayscaleFilter;655 };656 Brightness: {657 new (options?: { brightness: number; }): IBrightnessFilter;658 };659 RemoveWhite: {660 new (options?: {661 threshold?: string; // TODO: Check this662 distance?: string; // TODO: Check this663 }): IRemoveWhiteFilter;664 };665 Invert: {666 new (): IInvertFilter;667 };668 Sepia: {669 new (): ISepiaFilter;670 };671 Sepia2: {672 new (): ISepia2Filter;673 };674 Noise: {675 new (options?: {676 noise?: number;677 }): INoiseFilter;678 };679 GradientTransparency: {680 new (options?: {681 threshold?: number;682 }): IGradientTransparencyFilter;683 };684 Pixelate: {685 new (options?: {686 color?: any;687 }): IPixelateFilter;688 };689 Convolute: {690 new (options?: {691 matrix: any;692 }): IConvoluteFilter;693 };694 };695 }696 declare var util: {697 addClass(element: HTMLElement, className: string);698 addListener(element, eventName: string, handler);699 animate(options: {700 onChange?: (value: number) => void;701 onComplete?: () => void;702 startValue?: number;703 endValue?: number;704 byValue?: number;705 easing?: (currentTime, startValue, byValue, duration) => number;706 duration?: number;707 });708 createClass(parent, properties);709 degreesToRadians(degrees: number): number;710 falseFunction(): () => bool;711 getById(id: HTMLElement): HTMLElement;712 getById(id: string): HTMLElement;713 getElementOffset(element): { left: number; top: number; };714 getPointer(event: Event);715 getRandomInt(min: number, max: number);716 getScript(url: string, callback);717 groupSVGElements(elements: any[], options, path?: string);718 loadImage(url, callback, context);719 makeElement(tagName: string, attributes);720 makeElementSelectable(element: HTMLElement);721 makeElementUnselectable(element: HTMLElement);722 populateWithProperties(source, destination, properties): any[];723 radiansToDegrees(radians: number): number;724 removeFromArray(array: any[], value);725 removeListener(element: HTMLElement, eventName, handler);726 request(url, options);727 requestAnimFrame(callback, element);728 setStyle(element: HTMLElement, styles);729 toArray(arrayLike): any[];730 toFixed(number, fractionDigits);731 wrapElement(element: HTMLElement, wrapper, attributes);732 }...
type.ts
Source:type.ts
1export type obj = { [x: string]: any };2export type ApObject = IObject | string | (IObject | string)[];3export interface IObject {4 '@context': string | obj | obj[];5 type: string;6 id?: string;7 summary?: string;8 published?: string;9 cc?: ApObject;10 to?: ApObject;11 attributedTo: ApObject;12 attachment?: any[];13 inReplyTo?: any;14 replies?: ICollection;15 content?: string;16 name?: string;17 startTime?: Date;18 endTime?: Date;19 icon?: any;20 image?: any;21 url?: ApObject;22 href?: string;23 tag?: IObject | IObject[];24 sensitive?: boolean;25}26/**27 * Get array of ActivityStreams Objects id28 */29export function getApIds(value: ApObject | undefined): string[] {30 if (value == null) return [];31 const array = Array.isArray(value) ? value : [value];32 return array.map(x => getApId(x));33}34/**35 * Get first ActivityStreams Object id36 */37export function getOneApId(value: ApObject): string {38 const firstOne = Array.isArray(value) ? value[0] : value;39 return getApId(firstOne);40}41/**42 * Get ActivityStreams Object id43 */44export function getApId(value: string | IObject): string {45 if (typeof value === 'string') return value;46 if (typeof value.id === 'string') return value.id;47 throw new Error('cannot detemine id');48}49export function getOneApHrefNullable(value: ApObject | undefined): string | undefined {50 const firstOne = Array.isArray(value) ? value[0] : value;51 return getApHrefNullable(firstOne);52}53export function getApHrefNullable(value: string | IObject | undefined): string | undefined {54 if (typeof value === 'string') return value;55 if (typeof value?.href === 'string') return value.href;56 return undefined;57}58export interface IActivity extends IObject {59 //type: 'Activity';60 actor: IObject | string;61 object: IObject | string;62 target?: IObject | string;63 /** LD-Signature */64 signature?: {65 type: string;66 created: Date;67 creator: string;68 domain?: string;69 nonce?: string;70 signatureValue: string;71 };72}73export interface ICollection extends IObject {74 type: 'Collection';75 totalItems: number;76 items: ApObject;77}78export interface IOrderedCollection extends IObject {79 type: 'OrderedCollection';80 totalItems: number;81 orderedItems: ApObject;82}83export const validPost = ['Note', 'Question', 'Article', 'Audio', 'Document', 'Image', 'Page', 'Video', 'Event'];84export interface IPost extends IObject {85 type: 'Note' | 'Question' | 'Article' | 'Audio' | 'Document' | 'Image' | 'Page' | 'Video' | 'Event';86 _misskey_content?: string;87 _misskey_quote?: string;88 quoteUrl?: string;89 _misskey_talk: boolean;90}91export interface IQuestion extends IObject {92 type: 'Note' | 'Question';93 _misskey_content?: string;94 _misskey_quote?: string;95 quoteUrl?: string;96 oneOf?: IQuestionChoice[];97 anyOf?: IQuestionChoice[];98 endTime?: Date;99 closed?: Date;100}101export const isQuestion = (object: IObject): object is IQuestion =>102 object.type === 'Note' || object.type === 'Question';103interface IQuestionChoice {104 name?: string;105 replies?: ICollection;106 _misskey_votes?: number;107}108export interface ITombstone extends IObject {109 type: 'Tombstone';110 formerType?: string;111 deleted?: Date;112}113export const isTombstone = (object: IObject): object is ITombstone =>114 object.type === 'Tombstone';115export const validActor = ['Person', 'Service', 'Group', 'Organization', 'Application'];116export interface IPerson extends IObject {117 type: 'Person' | 'Service' | 'Organization' | 'Group' | 'Application';118 name?: string;119 preferredUsername?: string;120 manuallyApprovesFollowers?: boolean;121 discoverable?: boolean;122 inbox?: string;123 sharedInbox?: string; // å¾æ¹äºææ§ã®ãã124 publicKey: {125 id: string;126 publicKeyPem: string;127 };128 followers?: string | ICollection | IOrderedCollection;129 following?: string | ICollection | IOrderedCollection;130 featured?: string | IOrderedCollection;131 outbox?: string | IOrderedCollection;132 endpoints?: {133 sharedInbox?: string;134 };135 'vcard:bday'?: string;136 'vcard:Address'?: string;137 'vcard:gender'?: string;138}139export const isCollection = (object: IObject): object is ICollection =>140 object.type === 'Collection';141export const isOrderedCollection = (object: IObject): object is IOrderedCollection =>142 object.type === 'OrderedCollection';143export const isCollectionOrOrderedCollection = (object: IObject): object is ICollection | IOrderedCollection =>144 isCollection(object) || isOrderedCollection(object);145export interface IApPropertyValue extends IObject {146 type: 'PropertyValue';147 identifier: IApPropertyValue;148 name: string;149 value: string;150}151export const isPropertyValue = (object: IObject): object is IApPropertyValue =>152 object &&153 object.type === 'PropertyValue' &&154 typeof object.name === 'string' &&155 typeof (object as any).value === 'string';156export interface IApMention extends IObject {157 type: 'Mention';158 href: string;159}160export const isMention = (object: IObject): object is IApMention=>161 object.type === 'Mention' &&162 typeof object.href === 'string';163export interface IApHashtag extends IObject {164 type: 'Hashtag';165 name: string;166}167export const isHashtag = (object: IObject): object is IApHashtag =>168 object.type === 'Hashtag' &&169 typeof object.name === 'string';170export interface IApEmoji extends IObject {171 type: 'Emoji';172 updated: Date;173}174export const isEmoji = (object: IObject): object is IApEmoji =>175 object.type === 'Emoji' && !Array.isArray(object.icon) && object.icon.url != null;176export interface ICreate extends IActivity {177 type: 'Create';178}179export interface IDelete extends IActivity {180 type: 'Delete';181}182export interface IUpdate extends IActivity {183 type: 'Update';184}185export interface IRead extends IActivity {186 type: 'Read';187}188export interface IUndo extends IActivity {189 type: 'Undo';190}191export interface IFollow extends IActivity {192 type: 'Follow';193}194export interface IAccept extends IActivity {195 type: 'Accept';196}197export interface IReject extends IActivity {198 type: 'Reject';199}200export interface IAdd extends IActivity {201 type: 'Add';202}203export interface IRemove extends IActivity {204 type: 'Remove';205}206export interface ILike extends IActivity {207 type: 'Like' | 'Dislike' | 'EmojiReaction' | 'EmojiReact';208 _misskey_reaction?: string;209}210export interface IAnnounce extends IActivity {211 type: 'Announce';212}213export interface IBlock extends IActivity {214 type: 'Block';215}216export interface IFlag extends IActivity {217 type: 'Flag';218}219export const isCreate = (object: IObject): object is ICreate => object.type === 'Create';220export const isDelete = (object: IObject): object is IDelete => object.type === 'Delete';221export const isUpdate = (object: IObject): object is IUpdate => object.type === 'Update';222export const isRead = (object: IObject): object is IRead => object.type === 'Read';223export const isUndo = (object: IObject): object is IUndo => object.type === 'Undo';224export const isFollow = (object: IObject): object is IFollow => object.type === 'Follow';225export const isAccept = (object: IObject): object is IAccept => object.type === 'Accept';226export const isReject = (object: IObject): object is IReject => object.type === 'Reject';227export const isAdd = (object: IObject): object is IAdd => object.type === 'Add';228export const isRemove = (object: IObject): object is IRemove => object.type === 'Remove';229export const isLike = (object: IObject): object is ILike => ['Like', 'Dislike', 'EmojiReaction', 'EmojiReact'].includes(object.type)230export const isAnnounce = (object: IObject): object is IAnnounce => object.type === 'Announce';231export const isBlock = (object: IObject): object is IBlock => object.type === 'Block';...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7 if (err) return console.log(err);8 console.log('Test submitted. Polling results...');9 wpt.getTestResults(data.data.testId, function (err, data) {10 if (err) return console.log(err);11 if (data.statusCode === 200) {12 console.log('Got results!');13 console.log(data.data);14 } else {15 console.log('Test not ready yet. Poll again...');16 }17 });18});
Using AI Code Generation
1var wpt = require('wpt');2var wptObject = new wpt('API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});
Using AI Code Generation
1var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });2var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });3var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });4var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });5var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });6var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3a3e6a8f2e1c6f5b2a5a6a5e6f5a6', { timeout: 30000 });7var wpt = new WebPageTest('www.webpagetest.org', 'A.3b
Using AI Code Generation
1var wpt = require('wpt');2var Wpt = new wpt('API_KEY');3 if (err) return console.log(err);4 Wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.log(err);6 console.log(data);7 });8});
Using AI Code Generation
1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, resp) {4 var infobox = resp.data.infobox;5 console.log(infobox);6});7var wptools = require('wptools');8var wiki = wptools.page('Barack Obama');9wiki.get(function(err, resp) {10 var infobox = resp.data.infobox;11 console.log(infobox);12});13var wptools = require('wptools');14var wiki = wptools.page('Barack Obama');15wiki.get(function(err, resp) {16 var infobox = resp.data.infobox;17 console.log(infobox);18});19var wptools = require('wptools');20var wiki = wptools.page('Barack Obama');21wiki.get(function(err, resp) {22 var infobox = resp.data.infobox;23 console.log(infobox);24});25var wptools = require('wptools');26var wiki = wptools.page('Barack Obama');27wiki.get(function(err, resp) {28 var infobox = resp.data.infobox;29 console.log(infobox);30});31var wptools = require('wptools');32var wiki = wptools.page('Barack Obama');33wiki.get(function(err, resp) {34 var infobox = resp.data.infobox;35 console.log(infobox);36});37var wptools = require('wptools');38var wiki = wptools.page('Barack Obama');39wiki.get(function(err, resp) {40 var infobox = resp.data.infobox;41 console.log(infobox);42});
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3var post = {4};5wp.posts().create(post, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});
Using AI Code Generation
1var wpt = require('webpagetest');2var webPageTest = new wpt('A.1f7d6b0b0c7b6f8b3d7b0e3c2e7e3b2b');3var options = {4};5webPageTest.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 console.log('Test status:', data.statusText);8 console.log('View results at:', data.data.userUrl);9 console.log('View HAR at:', data.data.summaryCSV);10 console.log('View waterfall at:', data.data.waterfallView);11 console.log('View screenshot at:', data.data.userUrl + 'screen_shot.png');12 console.log('View video at:', data.data.userUrl + 'video_1.webm');13});14MIT © [Piyush Gupta](
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!