Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,6 @@
/types/digital-goods-browser/ @vantezzen
/types/digital-link.js/ @eoin-obrien
/types/digitalbazaar__bitstring/ @antonio-ivanovski
/types/dinero.js/ @BendingBender @juandaco @peterblazejewicz
/types/dingtalk-robot-sender/ @bangbang93
/types/dir-glob/ @BendingBender
/types/director/ @pastelmind
Expand Down Expand Up @@ -1549,7 +1548,6 @@
/types/dogapi/ @olebedev
/types/doge-seed/ @BendingBender
/types/doi-regex/ @thewilkybarkid
/types/dojo/ @vansimke
/types/dom-background-sync/ @brad4d @blickly @12wrigja
/types/dom-chromium-ai/ @christianliebel @tomayac
/types/dom-chromium-installation-events/ @dartess
Expand Down Expand Up @@ -2147,7 +2145,7 @@
/types/flat-tree/ @martinheidegger
/types/fleximap/ @DanielRose
/types/flexslider/ @diullei @martin-badin
/types/flickity/ @clmcgrath @wagich @aheber @PabloDiablo @Dashiing @rdennis
/types/flickity/ @clmcgrath @wagich @aheber @PabloDiablo @rdennis
/types/flightplan/ @borislavjivkov
/types/flipsnap/ @kubosho @gsino @mayuki
/types/float-equal/ @dmurvihill
Expand Down Expand Up @@ -3211,6 +3209,7 @@
/types/hostile/ @AndrewLeedham
/types/hot-formula-parser/ @joao-mbn
/types/hotwired__turbo/ @G-Rath @lukeify @myabc
/types/hotwired__turbo-rails/ @myabc @G-Rath
/types/howler/ @xperiments @alien35 @nicholashza @cjurango @MrGriefs
/types/hoxy/ @TrueLecter
/types/hpp/ @kryops
Expand Down Expand Up @@ -4939,7 +4938,6 @@
/types/mongoose-auto-increment/ @AyaMorisawa
/types/mongoose-deep-populate/ @AyaMorisawa
/types/mongoose-delete/ @ndunks @alexbrazier
/types/mongoose-geojson-schema/ @bondz
/types/mongoose-id-validator/ @kerolloz
/types/mongoose-lean-id/ @yincrash
/types/mongoose-lean-virtuals/ @isaacdecoded
Expand Down Expand Up @@ -5232,7 +5230,7 @@
/types/node-ssdp/ @OrionNebula
/types/node-ssha256/ @midgleyc
/types/node-static/ @Morfent
/types/node-statsd/ @alexturek @convoyinc
/types/node-statsd/ @alexturek
/types/node-steam-openid/ @joshuajeschek
/types/node-summary/ @manuzcheruz
/types/node-targz/ @junlarsen
Expand Down
20 changes: 6 additions & 14 deletions types/lineclip/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
declare namespace Lineclip {
type Point = [number, number];
type BoundingBox = [number, number, number, number];
type LineClipResult = Point[];
export type Point = [number, number];
export type BoundingBox = [number, number, number, number];
export type LineClipResult = Point[][];
export type PolygonClipResult = Point[];

function polyline(points: Point[], bbox: BoundingBox, result?: LineClipResult[]): LineClipResult;
function polygon(points: Point[], bbox: BoundingBox): LineClipResult;
}

declare function Lineclip(
points: Lineclip.Point[],
bbox: Lineclip.BoundingBox,
result?: Lineclip.LineClipResult[],
): Lineclip.LineClipResult;
export = Lineclip;
export function clipPolyline(points: Point[], bbox: BoundingBox, result?: LineClipResult): LineClipResult;
export function clipPolygon(points: Point[], bbox: BoundingBox): PolygonClipResult;
28 changes: 26 additions & 2 deletions types/lineclip/lineclip-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { type BoundingBox, type Point, polyline } from "lineclip";
import {
type BoundingBox,
clipPolygon,
clipPolyline,
type LineClipResult,
type Point,
type PolygonClipResult,
} from "lineclip";

const line: Point[] = [
[-10, 10],
Expand All @@ -19,6 +26,23 @@ const line: Point[] = [
[-10, 20],
];

const polygon: Point[] = [
[-10, 10],
[0, 10],
[10, 10],
[10, 5],
[10, -5],
[10, -10],
[20, -10],
[-10, 10],
];

const bbox: BoundingBox = [0, 0, 30, 30];

polyline(line, bbox);
const result: LineClipResult = clipPolyline(line, bbox);
const withOptionalResult: LineClipResult = clipPolyline(line, bbox, [[[0, 1], [2, 3]]]);

const polygonResult: PolygonClipResult = clipPolygon(polygon, bbox);

const onePoint: Point = result[0][0];
const onePolygonPoint: Point = polygonResult[0];
7 changes: 6 additions & 1 deletion types/lineclip/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"private": true,
"name": "@types/lineclip",
"version": "1.1.9999",
"version": "2.0.9999",
"type": "module",
"projects": [
"https://github.com/mapbox/lineclip#readme"
],
Expand All @@ -12,6 +13,10 @@
{
"name": "Sikriti Dakua",
"githubUsername": "devloop01"
},
{
"name": "Marc Emmanuel",
"githubUsername": "SheepFromHeaven"
}
]
}