Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Boopathi Rajaa boopathi

💭
I may be slow to respond.
View GitHub Profile
View graphql-optimization-dataloaders.js
const productLoader = new DataLoader(getBackendProducts);
const resolvers = {
Query: {
async product(_, { id }, __, info) {
const fields = getFields(info);
const backendFields = getBackendFields(fields, dependencyMap);
const backendResponse = await productLoader.load({ id, fields: backendFields });
const schemaResponse = getSchemaResponse(backendResponse, fields, transformerMap);
return schemaResponse;
View graphql-optimization-field-filtering.js
const resolvers = {
Query: {
async product(_, { id }, __, info) {
const fields = getFields(info);
const backendFields = getBackendFields(fields, dependencyMap);
const backendResponse = await fetch(`/product?id=${id}&fields=${backendFields}`);
const schemaResponse = getSchemaResponse(backendResponse, fields, transformerMap);
return schemaResponse;
}
}
@boopathi
boopathi / git-cleanup.sh
Last active Jan 13, 2018
Cleanup git branches
View git-cleanup.sh
#!/bin/bash
git branch -r |
awk '{print $1}' |
egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) |
awk '{print $1}'
View stage-3-private.md
class A {
  #x;
  constructor(x, a) {
    #x = x;
    this.foo = this.foo.bind(a);
  }
  foo() {
    console.log(this?.#x); // optional chaining
    // Possible to use optional chaining?
View private.md

Motivation -

  1. use private keyword
  2. Use class private and not instance private.
  3. Statically analysable.

Based on this issue - https://github.com/tc39/proposal-private-fields/issues/14, there is a lot of interest in using the private keyword and no sigils, and sigils cannot be avoided for multiple reasons specified in the FAQ.

Addressing some of the comments by littledan,

@boopathi
boopathi / system-import-sync-plugin.js
Created Oct 31, 2016
Converts System.import to a synchronous require call. For NodeJS
View system-import-sync-plugin.js
const template = require("babel-template");
module.exports = function SystemImportPlugin() {
return {
visitor: {
CallExpression(path) {
const callee = path.get("callee");
if (!callee.isMemberExpression()) return;
const object = callee.get("object");
View keybase.md

Keybase proof

I hereby claim:

  • I am boopathi on github.
  • I am boopathi (https://keybase.io/boopathi) on keybase.
  • I have a public key whose fingerprint is 1FAC 1419 710A D0DB 6C4B 7A11 873B 84CB 3041 903B

To claim this, I am signing this object:

@boopathi
boopathi / cli.js
Created Aug 30, 2016
Transform babel-minify tests
View cli.js
#!/usr/bin/env node
const fs = require("fs");
const minimist = require("minimist");
const transform = require("./index");
module.exports = run;
if (require.main === module) {
run(process.argv.slice(2))
View combine-chunks-plugin.js
var ConcatSource = require('webpack/lib/ConcatSource');
var loaderUtils = require('loader-utils');
module.exports = CombineChunksPlugin;
// opts.filename = 'vendor.[contenthash].js'
function CombineChunksPlugin(opts) {
if (opts) {
this.filename = opts.filename ? opts.filename : 'vendor.bundle.js';
@boopathi
boopathi / gist:57e0e63976d27e969f9c
Last active Sep 6, 2015 — forked from bolshchikov/gist:8069009
Creating read-only JS object
View gist:57e0e63976d27e969f9c
// lo-dash lib is the dependency
function readOnly(target){
var _readOnly = function (target, acc) {
// acc is passed into the function to be used for observer
var _defineProperty = function (propName, target, acc) {
var i, len;
// operation to be performed when add occurred