ag-common 0.0.449 → 0.0.451

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ export declare const toBuffer: (ab: ArrayBuffer) => Buffer;
2
3
  /**
3
4
  * convert an ArrayBuffer (usually from file.arrayBuffer) to base64. Usually on client side before server send
4
5
  * @param buffer
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.base64ToBinary = exports.arrayBufferToBase64 = void 0;
3
+ exports.base64ToBinary = exports.arrayBufferToBase64 = exports.toBuffer = void 0;
4
4
  const base64_1 = require("./string/base64");
5
- function toBuffer(ab) {
6
- const buffer = new Buffer(ab.byteLength);
7
- const view = new Uint8Array(ab);
8
- for (let i = 0; i < buffer.length; ++i) {
9
- buffer[i] = view[i];
10
- }
11
- return buffer;
12
- }
5
+ const toBuffer = (ab) => Buffer.from(ab);
6
+ exports.toBuffer = toBuffer;
13
7
  function toArrayBuffer(base64) {
14
8
  const binary_string = (0, base64_1.fromBase64)(base64);
15
9
  const len = binary_string.length;
@@ -39,5 +33,5 @@ exports.arrayBufferToBase64 = arrayBufferToBase64;
39
33
  * @param raw
40
34
  * @returns
41
35
  */
42
- const base64ToBinary = (raw) => toBuffer(toArrayBuffer(raw));
36
+ const base64ToBinary = (raw) => (0, exports.toBuffer)(toArrayBuffer(raw));
43
37
  exports.base64ToBinary = base64ToBinary;
@@ -1 +1 @@
1
- export declare function truncate(str: string | null | undefined, n: number, ellip: string): string | undefined;
1
+ export declare function truncate(str: string, n: number, ellip: string): string;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.truncate = void 0;
4
4
  function truncate(str, n, ellip) {
5
5
  if (!str) {
6
- return undefined;
6
+ return str;
7
7
  }
8
8
  return str.length > n ? str.substr(0, n - 1) + ellip : str;
9
9
  }
@@ -1,20 +1,21 @@
1
1
  import React from 'react';
2
+ /** full page title = title | hostname | tagline */
2
3
  export interface IHeadersRaw {
4
+ /** eg https://abc.def */
5
+ siteUrl: string;
3
6
  title?: string;
4
7
  image?: string;
5
8
  description?: string;
6
- /** eg https://abc.def */
7
- siteUrl: string;
8
9
  /** eg 'a site to remember' */
9
- tagline: string;
10
+ tagline?: string;
10
11
  /** csv or separate keyword strings */
11
- keywords: string | string[];
12
+ keywords?: string | string[];
12
13
  }
13
14
  export declare const HeadersRaw: ({ title, image, siteUrl, tagline, keywords, }: IHeadersRaw) => React.JSX.Element[];
14
15
  export declare const HeadersRawNext: ({ title, image, siteUrl, tagline, description, keywords, }: IHeadersRaw) => {
15
16
  title: string;
16
17
  description: string;
17
- keywords: string | string[];
18
+ keywords: string | string[] | undefined;
18
19
  openGraph: {
19
20
  title: string;
20
21
  description: string;
@@ -7,7 +7,7 @@ exports.HeadersRawNext = exports.HeadersRaw = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const HeadersRaw = ({ title, image, siteUrl, tagline, keywords, }) => {
9
9
  const { origin, hostname } = new URL(siteUrl);
10
- const fullTitle = `${title ? `${title} | ` : ''}${hostname} | ${tagline}`;
10
+ const fullTitle = [title, hostname, tagline].filter((r) => r).join(' | ');
11
11
  const titleFallback = title || fullTitle;
12
12
  const titleBlock = [
13
13
  react_1.default.createElement("title", { key: "1" }, fullTitle),
@@ -42,7 +42,7 @@ const HeadersRaw = ({ title, image, siteUrl, tagline, keywords, }) => {
42
42
  exports.HeadersRaw = HeadersRaw;
43
43
  const HeadersRawNext = ({ title, image, siteUrl, tagline, description, keywords, }) => {
44
44
  const { origin, hostname } = new URL(siteUrl);
45
- const fullTitle = `${title ? `${title} | ` : ''}${hostname} | ${tagline}`;
45
+ const fullTitle = [title, hostname, tagline].filter((r) => r).join(' | ');
46
46
  return {
47
47
  title: fullTitle,
48
48
  description: description || fullTitle,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.449",
2
+ "version": "0.0.451",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",