Skip to content

Instantly share code, notes, and snippets.

View audinue's full-sized avatar

Audi Nugraha audinue

  • Surabaya, Jawa Timur, Indonesia
View GitHub Profile
@audinue
audinue / Container.cs
Created August 9, 2017 07:19
An automatic dependency injection container.
using System;
using System.Collections.Generic;
using System.Linq;
public sealed class Container
{
private Dictionary<Type, Type> concreteTypes = new Dictionary<Type, Type>();
private Dictionary<Type, object> objects = new Dictionary<Type, object>();
@audinue
audinue / object-map.js
Last active October 30, 2020 02:35
Iterable safe plain JavaScript object as map.
function objectMap () {
return Object.defineProperty(Object.create(null), Symbol.iterator, {
configurable: true, // This descriptor is inspired by Map.prototype[Symbol.iterator]
writable: true,
value: function* () {
for (const key in this) {
yield [key, this[key]]
}
}
})