I saw a gadget somewhere before, but can't find it anymore. One end should be attached to the wall and the other to the door (of a cupboard). It prevents door from moving freely in both directions, it had a teeth, like on a gear, there was like semi-gear. It's not a door closer. You should be able to move it (open wider, close it) without blocking/unlocking the device, it just moves. The point is that the door shouldn't be moved by itself (by momentum).
There is a device referred to as a "door swing damper" which resists the ability of a door to swing freely. It does not close the door nor does it only hold the door in an open position. It works for doors swinging inward or outward, right or left handed.
Sometimes, a difference in air pressure from an open window will cause a door into a lower pressure room to slam shut. This device will stop the door from moving easily.
One such device is "ActiveStop" manufactured and sold by GEZE in Stuttgart, Germany. You can verify that such a device is what you want from the GEZE website: GEZE WITH EASE
You can take advantage of the eddy currents generated by magnetic fields to build a dashpot. Simply attach a strong neodymium magnet to a rod and then place the contraption inside a conductive metal tube.
When the door closes the magnet will induce an eddy current inside the metal tube and slow down the door. The faster the door moves, the more the magnet will resist. This is similar to how free fall rides at amusement parks like the "tower of terror" are made to stop suddenly, without the risk of brake failure.
The braking force of an eddy current brake is exactly proportional to the velocity V, so it acts similar to viscous friction in a liquid. The braking force decreases as the velocity decreases. When the conductive sheet is stationary, the magnetic field through each part of it is constant, not changing with time, so no eddy currents are induced, and there is no force between the magnet and the conductor. Thus an eddy current brake has no holding force.
Alternatively you can just buy a prebuilt combination dashpot/spring device called a "door closer" and remove the spring to just keep the dashpot.
You can easily make a dashpot. A piece of string or wire attached to the top corner furthest from the hinge through a hoop or hook near the frame so that the remaining string shortens when the door opens. This goes to a can of beans or some equally heavy object which is suspended in a long tube of oil or water on a shelf nearby.