🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

php-serialize

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

php-serialize

PHP serialize/unserialize in Javascript

1.2.3
Source
npm
Version published
Weekly downloads
40K
13.27%
Maintainers
1
Weekly downloads
 
Created
Source

PHP-Serialize

PHP-Serialize is node library that helpers you encode/decoded data in PHP's Serialization format.

It also supports Serializable objects decode. Here's how you can use them.

const Serialize = require('php-serialize')
class User {
  constructor({ name, age }){
    this.name = name
    this.age = age
  }
  serialize(){
    return JSON.stringify({ name: this.name, age: this.age })
  }
  unserialize(rawData){
    const { name, age } = JSON.parse(rawData)
    this.name = name
    this.age = age
  }
}
const steel = new User({ name: "Steel Brain", age: 17 })
const Serialized = Serialize.serialize(steel)
const Unserialized = Serialize.unserialize(Serialized, {User: User}) // Passing available classes
console.log(Unserialized instanceof User) // true

API

class Serializable {
  serialize(item: any): string
  unserialize(item: string, scope: Object = {}, options: { strict: boolean } = { strict: false }): any
}

License

This project is licensed under the terms of MIT License. See the License file for more info.

FAQs

Package last updated on 12 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts