Skip to main content
Module

x/enzastdlib/strings/splitlength.ts>splitLength

enzastdlib is a set of TypeScript modules that follow a common design API philosophy aiming at sane defaults and ease-of-use targeting the Deno TypeScript runtime.
Latest
function splitLength
import { splitLength } from "https://deno.land/x/enzastdlib@v0.0.4/strings/splitlength.ts";

Splits a string into lines delimited by a max character length.

Examples

Example 1

import { assertEquals } from 'https://deno.land/std/testing/asserts.ts';
import { splitLength } from 'https://deno.land/x/enzastdlib/strings/mod.ts';

// **NOTE**: Taken from `deno lint --help`.
const text =
    'The configuration file can be used to configure different aspects of deno including TypeScript, linting, and code formatting. Typically the configuration file will be called `deno.json` or `deno.jsonc` and automatically detected; in that case this flag is not necessary.\nSee https://deno.land/manual@v1.33.0/getting_started/configuration_file';

assertEquals(
    splitLength(text, 66),
    [
        'The configuration file can be used to configure different aspects of',
        'deno including TypeScript, linting, and code formatting. Typically',
        'the configuration file will be called `deno.json` or `deno.jsonc` and',
        'automatically detected; in that case this flag is not necessary.',
        'See https://deno.land/manual@v1.33.0/getting_started/configuration_file',
    ];
);

Parameters

text: string
max_length: number

Returns

string[]