Registry / http-networking / tui-code-snippet

tui-code-snippet

JSON →
library2.3.3jsnpmunverified

TOAST UI Code Snippet (tui-code-snippet) is a comprehensive collection of modular, lightweight utility methods designed to simplify common JavaScript programming tasks. Currently stable at version 2.3.3, the library maintains a steady release cadence with regular updates including bug fixes and new features, such as the `ajax` module introduced in v2.3.0. A key differentiator since its 2.0 major release is its transition to a fully modular architecture, requiring developers to import individual functions or modules (e.g., `tui-code-snippet/array/inArray`) rather than a monolithic bundle. This approach minimizes bundle sizes by ensuring only the necessary utilities are included in an application. It provides functionalities across various domains including array manipulation, browser detection, collection processing, custom event management, DOM manipulation, class definition, date formatting, inheritance patterns, object utilities, and type checking. It explicitly supports both ES6 module syntax and CommonJS `require` patterns, making it versatile for modern JavaScript development environments. The library is a foundational component within the broader NHN TOAST UI ecosystem.

npm install tui-code-snippet
INSTALL
IMPORT
SIG · TUI-CODE-SNIPPET
T
tui-code-snippet
http-networkingjavascriptv2.3.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

inArray
✓ import inArray from 'tui-code-snippet/array/inArray';
✗ import { inArray } from 'tui-code-snippet';
Since v2.0, functions must be imported individually from their specific module paths, not as named exports from the root package. Each utility function is typically a default export from its module file.
isString
✓ const isString = require('tui-code-snippet/type/isString');
✗ const tui = require('tui-code-snippet'); const isString = tui.type.isString;
CommonJS imports also follow the individual module path pattern since v2.0. The monolithic 'tui-code-snippet' object containing all utilities is no longer available.
ajax
✓ import ajax from 'tui-code-snippet/ajax/index';
✗ import { ajax } from 'tui-code-snippet';
Modules like 'ajax' (introduced in v2.3.0) are typically default-exported from an 'index' file within their respective directories. Always refer to the specific module path.

Demonstrates importing and using several core utility functions like `inArray`, `isString`, `decodeHTMLEntity`, and `extend` for array, type, string, and object manipulation, respectively.

import inArray from 'tui-code-snippet/array/inArray'; import isString from 'tui-code-snippet/type/isString'; import decodeHTMLEntity from 'tui-code-snippet/string/decodeHTMLEntity'; import extend from 'tui-code-snippet/object/extend'; console.log('--- TOAST UI Code Snippet Quickstart ---'); // Example 1: Check if an item is in an array const myArray = [1, 2, 3, 4, 5]; const searchTerm = 3; console.log(`Is ${searchTerm} in [${myArray}]? ${inArray(searchTerm, myArray)}`); const notFoundTerm = 6; console.log(`Is ${notFoundTerm} in [${myArray}]? ${inArray(notFoundTerm, myArray)}`); // Example 2: Check data type const myString = "Hello, world!"; const myNumber = 123; console.log(`"${myString}" is a string? ${isString(myString)}`); console.log(`${myNumber} is a string? ${isString(myNumber)}`); // Example 3: Decode HTML entities const encodedHtml = "<div>Hello & World!</div>"; const decodedHtml = decodeHTMLEntity(encodedHtml); console.log(`Decoded HTML: ${decodedHtml}`); // Example 4: Extend an object const obj1 = { a: 1, b: 2 }; const obj2 = { b: 3, c: 4 }; const extendedObj = extend({}, obj1, obj2); console.log('Extended object:', extendedObj); console.log('------------------------------------');
Debug
Known issues
breakingVersion 2.0 introduced significant breaking changes by moving to an npm-only distribution model. Bower and CDN support were dropped, requiring installation via `npm`.
fix
Migrate your project to use npm for package management. Install with `npm install --save tui-code-snippet`.
affects: >=2.0.0
breakingSince v2.0, all functions are separated into individual files. You can no longer import a single 'tui-code-snippet' object and access utilities like `tui.array.inArray`. Each function must be imported explicitly from its specific module path (e.g., `import inArray from 'tui-code-snippet/array/inArray';`).
fix
Update all import statements to target the specific utility function's module path. Refer to the project's GitHub repository for the folder structure to find correct paths.
affects: >=2.0.0
gotchaFrom v2.1.0 onwards, the package no longer provides pre-built bundle files. If your project requires a bundled version (e.g., for direct browser inclusion without a module bundler), you must generate it yourself.
fix
To create a bundle, use the command `npm run bundle` after installing the package. This will generate the necessary bundled files in your project.
affects: >=2.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'inArray') OR TypeError: Cannot read property 'inArray' of undefined
Attempting to access utility functions from a top-level 'tui' or 'util' object after importing the main package, which is no longer supported since v2.0. You are likely importing `tui-code-snippet` monolithically instead of individual functions.
fix
Ensure you are importing individual functions from their specific file paths (e.g., `import inArray from 'tui-code-snippet/array/inArray';`). Do not try to access `tui.array.inArray` or similar patterns.
Module not found: Error: Can't resolve 'tui-code-snippet'
This error can occur if you're trying to import the root package directly as a main entry point for specific functions without a bundler correctly resolving it, or if you're trying to access a sub-path that doesn't exist. It can also happen if `tui-code-snippet` is not correctly installed via npm or if you migrated from older versions (pre-v2.0) and retained CDN/Bower references.
fix
Verify that `tui-code-snippet` is installed in your `node_modules`. If using a bundler (like Webpack/Rollup), ensure your imports point to the exact module files (e.g., `tui-code-snippet/array/inArray`). Ensure you're not trying to import a non-existent bundle file.
Upgrade
Version history
2.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
tui-code-snippet — npm install tui-code-snippet · libregistry