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

tsoc

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsoc

Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.

  • 0.5.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
4
Weekly downloads
 
Created
Source

Logo

30 seconds of code

License Gitter chat PRs Welcome Travis Build Insight.io js-semistandard-style

Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.

  • You can find the official documentation for each snippet here
  • Contributions welcome, please read the contribution guide.
  • Snippets are written in ES6, use the Babel transpiler to ensure backwards-compatibility.
  • You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in this repo.
  • You can import these snippets into Alfred 3, using this file.
  • :warning: Most of these snippets are not production-ready. This can be verified by the fact that anagrams works in O(n!) time.

Note :-

The version number of this package does not hold any special meaning. The package is updated regularly and depends upon the author. If you want a package which has more meaningful version numbers or is updated regularly(weekly) then you should use the official package.

How to use the snippets?

Node

Install globally

npm i tsoc -g

Install as a dependency

npm i tsoc --save

Using

      var tsoc = require('tsoc'); //The variable name can be anything even, `_` or `$` ;)
      tsoc.sum(1,2,3); //returns 6
      tsoc.scrollToTop(); //Browser snippets are excluded from the node package so this will give a error `scrollToTop` is not a function.
      tsoc.isTravisCI(); //This works

Website

Add the following in the head tag of your html document and place the tsoc.js file in the same directory as your html document

<script src ="tsoc.js">

Or if you want to use CDN :-

<script src = "unpkg.com/tsoc">

Now you can use the snippets in your document by using TSOC.snippetName

  TSOC.sum(1,2,3); //returns 6
  TSOC.isTravisCI(); //Node snippets are excluded from the browser package so this will give a error `isTravisCI` is not a function.
  TSOC.scrollToTop(); //This will work

You can also use your favorite variable by doing :-

var _ = TSOC.
_.sum(1,2,3); //Returns 6

Additional Details

The tsoc.js file is same for node and browser and is UMD. The node snippet and browser snippets are differentiated by doing the following :-

if(typeof window !== "undefined"){
  var functionName =  function functionName(args){
    //Code
  }
  window.tsoc.functionName = functionName;
}
if (typeof module !== "undefined"){
  var functionName = function functionName(args){
    //Code
  }
  exports.functionName = functionName;
}

Keywords

FAQs

Package last updated on 24 Feb 2018

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