Skip to content

Instantly share code, notes, and snippets.

@samdeesh
samdeesh / index.js
Created October 27, 2017 06:40
requirebin sketch
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// Generated by CoffeeScript 1.10.0
var barcodeScanListener;
barcodeScanListener = require('barcode-scan-listener');
/*
Listen for scan with specified product prefix.
@param [Function] onScan - callback to call when scan is successful. Passes the scanned string.
@samdeesh
samdeesh / flatten.js
Created August 25, 2016 14:12
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
/**
*
*Code to flatten multidimensional array in javascript
*
*/
function flatten(array) {
return JSON.parse("[" +
JSON.stringify(array)
.replace(/[\[\]]+/g, "")
.replace(/,,/g, ",") +