1.1.0 • Published 15 days ago

apple-news-format v1.1.0

Weekly downloads
1,841
License
MIT
Repository
-
Last release
15 days ago

Apple News Format Types

CircleCI

Current to ANF version: 1.26.0

This is a collection of TypeScript types for the Apple News Format fields, metadata, and components.

Included are a small selection of validation functions for certain fields that contain restrictions on the strings that are passed in.

Usage

Install from npm using your desired package manager

npm install apple-news-format

TypeScript

Simply import the AppleNews namespace from the package.

import AppleNews from "apple-news-format";
// or
import { AppleNews } from "apple-news-format";

You can also import individual types, methods, and namespaces from the individual modules.

import { URI } from "apple-news-format/lib/primitives";
import * as Components from "apple-news-format/lib/components";
import { Image } from "apple-news-format/lib/images";

type Body = Components.Text.Body;

function buildImageComponent(path: string): Image {
  const imagePath: URI = URI(path);

  if (!imagePath) {
    throw new TypeError("Image URI was invalid!");
  }

  const imageComponent: Image = {
    role: "image",
    URL: imagePath,
  };

  return imageComponent;
}

JavaScript

You can import the specific validation functions listed as available below by targeting the specific modules.

const { URI } = require("apple-news-format/lib/primitives");
// OR require("apple-news-format/lib/primitives/uri");

Validation Functions

  • Color
    • Tests for a valid color string. Ex: "#RRGGBB"
  • SupportedUnits
    • Tests for a valid unit type. Ex: "80vw"
  • URI
    • Tests for a properly formed URI, and valid media types. Ex: "bundle://a-video.mp4"
  • Identifier URI
    • Tests for a properly formed internal URI targeting other parts of the document. Ex: "#info"
  • ListItemStyleCharacter
    • Tests for a single valid character for use in lists. Ex: "•"
  • DateTime
    • Tests for a valid ISO 8601 date time string
    • TODO: Make test more explicit
  • HTMLTableData
    • Tests for a valid string containing and opening and closing <table> tag.
    • TODO: Test for appropriate children elements: <thead>, <tbody>, <tr>, <td>, etc.

License

MIT


© 2019 Robert Fairley

1.1.0

15 days ago

1.0.0

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago