Microsoft’s GitHub subsidiary on Monday said it has agreed to buy Npm, a company that operates an online service for distributing packages of open-source software written in the popular JavaScript programming language and offers software that companies can use for their proprietary code as well.