-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/feature/11ty' into featu…
…re/11ty-format # Conflicts: # site/pages/Docs/Docs API/Additional API/index.md # site/pages/Docs/Docs API/Get Started/index.md # site/pages/Docs/Docs API/More Information/index.md # site/pages/Docs/Docs API/Usage API/index.md # site/pages/Docs/Docs API/Using WOPI/index.md
- Loading branch information
Showing
90 changed files
with
1,711 additions
and
935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {is} from "uvu/assert" | ||
import {test} from "uvu" | ||
import {isEmpty} from "./main.ts" | ||
|
||
test("isEmpty(): returns false for a string", () => { | ||
const a = isEmpty("") | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for a number", () => { | ||
const a = isEmpty(0) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for an arrow function", () => { | ||
const a = isEmpty(() => {}) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for a function", () => { | ||
// eslint-disable-next-line prefer-arrow-callback | ||
const a = isEmpty(function () {}) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for a boolean", () => { | ||
const a = isEmpty(false) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for a null", () => { | ||
const a = isEmpty(null) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns false for an undefined", () => { | ||
// eslint-disable-next-line unicorn/no-useless-undefined | ||
const a = isEmpty(undefined) | ||
is(a, false) | ||
}) | ||
|
||
test("isEmpty(): returns true for an empty object", () => { | ||
const a = isEmpty({}) | ||
is(a, true) | ||
}) | ||
|
||
test("isEmpty(): returns false for an object with properties", () => { | ||
const a = isEmpty({a: 1}) | ||
is(a, false) | ||
}) | ||
|
||
test.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export function isEmpty(o: unknown): boolean { | ||
if (!isPlain(o)) { | ||
return false | ||
} | ||
|
||
for (const k in o) { | ||
if (Object.hasOwn(o, k)) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
export function isPlain(o: unknown): o is object { | ||
if (!o || typeof o !== "object") { | ||
return false | ||
} | ||
|
||
const p = Object.getPrototypeOf(o) | ||
if (!p && p !== Object.prototype) { | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@onlyoffice/objects", | ||
"private": true, | ||
"type": "module", | ||
"main": "lib/main.ts", | ||
"scripts": { | ||
"test:types": "tsc", | ||
"test:unit": "c8 --config ../../c8.config.json tsx node_modules/uvu/bin.js lib ^.*\\.test\\.ts$", | ||
"test": "pnpm test:types && pnpm test:unit" | ||
}, | ||
"dependencies": { | ||
"typescript": "^5.4.5" | ||
}, | ||
"devDependencies": { | ||
"c8": "^9.1.0", | ||
"tsx": "^4.10.5", | ||
"uvu": "^0.5.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["lib"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.