A modern JavaScript utility library inspired by PHP and Python, providing essential helper functions that are missing from native JavaScript. Perfect for developers who miss the simplicity of functions like isset, isEmpty, and other small, focused helpers.
- Zero dependencies — Pure JavaScript, no bloat
- CommonJS compatible — Works in Node.js environments
- PHP-inspired — Familiar functions you already know and love
- Modular design — Import only what you need
- Multiple naming conventions — Both camelCase and PascalCase variants available
import jlang from './index.js'; // const jlang = require("jlang")
console.log(jlang.listFunctions(jlang));
[ 'array', 'isArray', 'empty', 'isEmpty', 'object', 'isObject', 'isset', 'defined', 'isDefined', 'alpha', 'isAlpha', 'function', 'isFunction', 'functionExists', 'isFunctionExists', 'isJson', 'hasAlpha', 'toJson', 'fromJson', 'stringify', 'parse', 'sum', 'len', 'toPascalCase', 'listFunctions' ]
npm install jlangconst { isset, isEmpty, isArray, toJson, fromJson } = require('jlang');
// Check if variable exists (like PHP's isset)
if (isset(variable)) {
console.log('Variable exists!');
}
// Check if value is empty
if (isEmpty(data)) {
console.log('Data is empty');
}
// Check if value is an array
if (isArray(myList)) {
console.log('It\'s an array!');
}
// JSON utilities
const jsonString = toJson({ name: 'John' });
const parsed = fromJson(jsonString);This module contains methods to test values.
| Method | Description | Native JS equivalent / notes |
|---|---|---|
isset(value) |
Checks that the value is neither null nor undefined. |
✘ (JS uses typeof … !== 'undefined' && value !== null) ([1]) |
isEmpty(value) |
Checks whether a value is "empty" (empty string, empty array, object without keys). | ✘ |
isArray(value) |
Checks if the value is an Array. | Exists: Array.isArray() ([2]) |
string(value) |
Checks if it is a String. (work in progress) | ✘ |
isAlpha(str) |
Checks if all characters are alphabetic (like PHP's ctype_alpha). |
✘ (available via packages like Locutus) ([3]) |
hasAlpha(str) |
Checks if the string contains at least one alphabetic character. | ✘ (available via packages like Locutus) ([3]) |
import { is } from './index.js';
if (is.isset(userInput) && is.isArray(data)) {
console.log('Valid array:', data);
}
import { isset, isArray } from './index.js';
if (isset(userInput) && isArray(data)) {
console.log('Valid array:', data);
}- Before adding a method, check if it:
- Already exists in native JS.
- Is provided by a well-known utility library (e.g. Lodash, utilities-js) ([5]).
- Every method must be tested (unit tests).
- Follow naming conventions and modular structure.
- Methods should be pure (no side effects) whenever possible.
- Document each new method in the README.
Add tests in a tests/ folder using a runner like Jest or Vitest. Cover:
- Normal cases
- Edge cases (
null,undefined, empty strings, empty arrays, etc.)
This project is licensed under MIT — contributions welcome.
References:
- https://stackoverflow.com/questions/5436953/php-isset-equivalent-in-javascript "php isset() equivalent in javascript - Stack Overflow"
- https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray "Array : méthode statique isArray() - JavaScript | MDN"
- https://locutus.io/php/ctype/ctype_alpha/ "PHP's ctype_alpha in JavaScript | Locutus"
- https://www.condorinformatique.com/manuali/CourseJavaScript.pdf "ÉLÉMENTS DE JAVASCRIPT"
- https://ironpdf.com/fr/nodejs/blog/node-help/lodash-npm/ "Lodash NPM (How it works for developers)"