npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oro-php-locutus

v2.1.4

Published

Fork of few Locutus functions that have been rewritten in TypeScript.

Downloads

4,362

Readme

Oro Php Locutus

Overview

Locutus is a project that seeks to assimilate other languages’ standard libraries to JavaScript.

Locutus is a huge library created by a community effort, so instead of downloading all their code, this is just a piece of it.

This package is a fork of few Locutus functions that have been rewritten in TypeScript.

These functions have no dependencies and are browser friendly.

Installation

npm install oro-php-locutus

Methods

serialize()

serialize( mixedValue: any ): string

Here's what Locutus JavaScript equivalent to PHP's serialize looks like.

// cjs
const { serialize } = require( 'oro-php-locutus' );
// mjs, ts
import { serialize } from 'oro-php-locutus';

serialize( { chacho: true, tio: 17 } );
// 'a:2:{s:6:"chacho";b:1;s:3:"tio";i:17;}'

serialize( [ 'chacho', '', true, false, 1, 2.3 ] );
// 'a:6:{i:0;s:6:"chacho";i:1;s:0:"";i:2;b:1;i:3;b:0;i:4;i:1;i:5;d:2.3;}'

unserialize()

unserialize( str: string ): string

Here's what Locutus JavaScript equivalent to PHP's unserialize looks like.

// cjs
const { unserialize } = require( 'oro-php-locutus' );
// mjs, ts
import { unserialize } from 'oro-php-locutus';

unserialize( 'a:2:{s:6:"chacho";b:1;s:3:"tio";i:17;}' );
// { chacho: true, tio: 17 }

unserialize( 'a:6:{i:0;s:6:"chacho";i:1;s:0:"";i:2;b:1;i:3;b:0;i:4;i:1;i:5;d:2.3;}' );
// [ 'chacho', '', true, false, 1, 2.3 ]

htmlspecialchars()

htmlspecialchars(
  string: string,
  quoteStyle?: ENT_OPTION | ENT_OPTION[],
  charset?: null,
  doubleEncode?: boolean
): string

type ENT_OPTION =
  | 0 | 'ENT_NOQUOTES'
  | 1 | 'ENT_HTML_QUOTE_SINGLE'
  | 2 | 'ENT_HTML_QUOTE_DOUBLE'
      | 'ENT_COMPAT'
  | 3 | 'ENT_QUOTES'
  | 4 | 'ENT_IGNORE'

Here's what Locutus JavaScript equivalent to PHP's unserialize looks like.

// js
const { htmlspecialchars } = require( 'oro-php-locutus' );
// ts
import { htmlspecialchars } from 'oro-php-locutus';

htmlspecialchars( '<a href="test">Test</a>', 'ENT_QUOTES' );
// '&amp;lt;a href=&amp;quot;test&amp;quot;&amp;gt;Test&amp;lt;/a&amp;gt;'

utf8Encode()

utf8Encode( str: string ): string

Here's what Locutus JavaScript equivalent to PHP's unserialize looks like.

// cjs
const { utf8Encode } = require( 'oro-php-locutus' );
// mjs, ts
import { utf8Encode } from 'oro-php-locutus';

utf8Encode( 'Chacho' );
// 'Chacho'

utf8Encode( 'cañón' );
// 'cañón'

utf8Decode()

utf8Decode( str: string ): string

Here's what Locutus JavaScript equivalent to PHP's unserialize looks like.

// cjs
const { utf8Decode } = require( 'oro-php-locutus' );
// mjs, ts
import { utf8Decode } from 'oro-php-locutus';

utf8Decode( 'Chacho' );
// 'Chacho'

utf8Decode( 'cañón' );
// 'cañón'

md5()

md5( str: string ): string

Here's what Locutus JavaScript equivalent to PHP's unserialize looks like.

// cjs
const { md5 } = require( 'oro-php-locutus' );
// mjs, ts
import { md5 } from 'oro-php-locutus';

md5( 'chacho' );
// '496c84fb22e82d68fad9e5fe8e89d03d'