Skip to content

Instantly share code, notes, and snippets.

@heartforit
heartforit / gist:1bda829c1b12bb2dcdecd02fd8ecc071
Created October 16, 2022 14:08
Check for arrow function / lambda in javascript
function isLambda(func){
if(typeof func !== "function") throw new Error("invalid function was provided")
let firstLine = func.toString()
.split("\n")['0']
.replace(/\n|\r|\s/ig, "")
return (!firstLine.includes("function") && (firstLine.includes(")=>{") || firstLine.includes("){")))
}
java -jar swagger-codegen-cli-2.3.1.jar generate -i swagger.json -o client-generated-folder -l javascript --additional-properties useInheritance=true,useES6=true,usePromises=true -t ./templates
@heartforit
heartforit / ApiClient
Created January 28, 2019 18:35
ApiClient.mustache
{{>licenseInfo}}
import superagent from "superagent";
import querystring from "querystring";
import moment from "moment-timezone"
{{#emitJSDoc}}/**
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
* @version {{projectVersion}}
*/
@heartforit
heartforit / ajax.js
Last active August 29, 2015 14:17 — forked from xeoncross/ajax.js
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {