Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

protos.js

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protos.js

String and Array prototypes for a more easy life

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

require('protos.js');



var users = [];

users.load('users.txt');  // arrays can load data

if (!users.has('mike')) { // arrays can check content
    users.push('mike')
    users.save('users.txt') // arrays can save data
}

if ('mike'.in(users)) {   // strings can also check if exists in arrays
    'mike is here'.log()  // strings can console.log
    'John'.appendFile('users.txt') // strings can append to file
}

var str = 'test';
str.log(); // same as console.log(str);
str.save('file.txt');
str.save('file.txt', function() {
   'async saved!'.log(); 
});

var str = ''.load('data.txt');

['a','b','c','d'].cut(1,3);
['a','b','c','d'].cut(1,-1); // -1 means last item (like python)

// STRING MANIPULATION MADE EASY (python style)
var el = 'hello'.cut(1,3);
var lo = 'hello'.cut(3,-1); 

var num = '3'.toInt(); 


// JSON FILES
 
var struct = {}.load('file.json');  // load json files into js object
struct.save('file.json');           // save js object into json file
struct.save('file.json', function() { // save async
   'saved'.log(); 
});
struct.dir()  // same as console.dir(struct);


// FUZZY HASHING thanks to ctph.js

'hello'.compare('hell')     // 50%
'hello'.compare('hello')    // 100%
'hello'.compare('abcd')     // 0%

var hash = 'hello'.fuzzyHash();

// calling a function on all items
objects.call('method',[params]);

Keywords

FAQs

Package last updated on 09 Nov 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc